#Enemy bot in 2D Unity Tennis game

10 messages · Page 1 of 1 (latest)

rich forum
#

Hi! I remember giving you some help in establishing the ball bouncing code a while ago!

#

so when the ball is coming, you're extrapolating it's position using the speed, and then moving the racket towards a point above it, right?

#

The anticipated ball position is changing after every update

#

first debugging tip: visualize where is the anticipated ball position. You can create an object there, or use Gizmos to draw a circle there, or a line from the racket to the anticipated position

#

you're adjusting the racket speed based on the distance to the ball, so the racket will end up moving slower when the ball is closer

#

I'd guess that humans do the opposite, they move slower when the ball is far, and end up moving faster when the ball is close

#

(I'm just realizing that the hardest part of game programming is designing the AI)

#

btw, in your video, which one is the AI?

#

(don't feel shy to DM me if I forget to reply)

sacred lance