I am using dynamic spheres and moving an AI player towards another player.
I am trying to figure out Angle# in this code snippet:
Power# = 8
Phy Add Rigid Body Force AIPlayer(a).ObjectIndex,Sin(Angle#)*Power#,0.0,Cos(Angle#)*Power#,5
I tried to have a temp object that is pointed at the Object and getting the Y angle, but it doesn't work.
Position Object AIPlayer(a).TempObjectIndex,AIPlayer(a).Position.X#,AIPlayer(a).Position.Y#,AIPlayer(a).Position.Z#
Point Object AIPlayer(a).TempObjectIndex, Object Position X(Object), Object Position Y(Object), Object Position Z(Object)
I even tried adding:
XRotate Object AIPlayer(a).TempObjectIndex,90
which doesn't make any difference.
I have also tried orbiting the temp object around the AI Player Object and using Intersect Object to get the angle, but it is to slow.
Question:
How can I get the Y angle between two object that would cause object one to go towards the other player? ...
using this code snippet:
Power# = 8
Phy Add Rigid Body Force AIPlayer(a).ObjectIndex,Sin(Angle#)*Power#,0.0,Cos(Angle#)*Power#,5
I want to use math as much as possible instead of using "Point Object" or "Intersect Object".
I tried some code on the forums and couldn't get it to work. A code snippet would really help!
Note:
Tried code from this threads:
http://forum.thegamecreators.com/?m=forum_view&t=96978&b=8
Tried this code snippet: Doesn't Work because it isn't the y angle.
`====================================
function AnglePtToPt(x1#,y1#,x2#,y2#)
`====================================
`Gets the angle from one point to another, x1 and y1 being the coordinates
`of that one point
dx#=x1#-x2#
dy#=y1#-y2#
if dx#>0
angle#=atan(dy#/dx#)+90
endif
if dx#<0
angle#=atan(dy#/dx#)+270
endif
if dx#=0
if dy#<0
angle#=0
endif
if dy#>0
angle#=180
endif
endif
`=================
endfunction angle#
`=================
Thanks,
Dark Fire
My future self met up with one day to teach me what I know today.