i need a function that works like pointentity

Blitz3D Forums/Blitz3D Programming/i need a function that works like pointentity

skyfire1(Posted 2005) [#1]
i have a entity in my game that needs to point at a another entity (like PointEntity()) except the mesh only needs to move it's yaw angle. also, i need it to work like in metal gear solid - you know, the enemy soldiers turn left or right if they aren't pointing directly at solid snake.

does anyone have a function that will tackle this problem that i'm having or am i not being clear enough. any help is appreciated


big10p(Posted 2005) [#2]
Use DeltaYaw.


skyfire1(Posted 2005) [#3]
thanks.


Viperfish(Posted 2005) [#4]
I think the function you might need to use is ATAN2(x,y). I haven't got the time at the moment to put some code together but basically use TFORMPOINT to determine the destination entity's x and z position relative to the source entity. Then use ATAN2(x,z) to determine the EntityYaw() of the source entity.

I hope that's not too vague.

Regards
Johnno


big10p(Posted 2005) [#5]
I think that's basically what DeltaYaw does internally.


Mr Snidesmin(Posted 2005) [#6]
why not just save the entity's pitch + roll, use pointentity and then set it's pitch and roll back to the saved values?

like:
pitch# = EntityPitch(e)
roll# = EntityRoll(e)
PointEntity e, e2
rotateentity e, pitch, entityYaw(e), roll

Can anyone think of a reason this might not work?


Mr Snidesmin(Posted 2005) [#7]
Just looked up DeltaYaw in the manual - I didn't know that such a function existed!

Wish I'd known about it before - About 2 years ago I spent ages working out a way (using the Atan math stuff) to get objects to slowly turn to follow each other (like homing missiles)