Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Bots facing to Player?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Daywalker313   Members   

122
Like
Likes
Like

Posted 19 August 2001 - 06:16 AM

The bots in my game should be able to rotate until they face to a point, but i dont know how i could do it. They should easily adjust their heading in degrees until they face to the player (point), i dont need look up/down. Bot: x,z,heading Player: x,z I think that are enough informations to perform it. Could somebody please post the code, because i dont understand the vector/dotproduct stuff. Thanks

#2 Xeno   Members   

122
Like
Likes
Like

Posted 19 August 2001 - 08:10 AM

well , i know how to do it in 2D if it helps you...
email me if u need me.

velich@matavtv.net


"Thats who you are. Thats what you could."
------------------------------
- Goblineye Entertainment
------------------------------


#3 TerranFury   Members   

142
Like
Likes
Like

Posted 19 August 2001 - 01:15 PM

If you only need to rotate a bot in the Y axis, knowing the x and z coordinates of the bot and the player, then that's a 2d problem.

bot.rotation = atan2(bot.z - player.z, bot.x - player.x);

Of course, this will be in radians. OpenGL accepts arguments in degrees (I don't know about Direct3d). So, depending on whether your rotation function takes degrees or radians, you may need to convert the return of atan2 to degrees. That is accomplished by multiplying by a conversion factor. That conversion factor is 180/PI . Similarly, if you ever need to convert degrees to radians, multiply by PI/180. Of course, multiplication by one is the same as division by the other.

Edited by - TerranFury on August 19, 2001 8:17:56 PM




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.