Moving Gradually from one angle to another

BlitzMax Forums/BlitzMax Programming/Moving Gradually from one angle to another

SillyPutty(Posted 2006) [#1]
I know there is bound to be something like this laying around, but how does one move gradually from one angle to another ?


ImaginaryHuman(Posted 2006) [#2]
Use a Float variable?


SillyPutty(Posted 2006) [#3]
I found this code




SillyPutty(Posted 2006) [#4]
ok guys I need some help here

I want the rect to move gradually from one point to another, not at the speed of the mouse, this will also stop the rect from jumping from one side to the other if you quickly move across.

here is the code.




klepto2(Posted 2006) [#5]
Do you mean like this ?




Eric(Posted 2006) [#6]
I have been Using this...
         Method LookAt(X:Float,Y:Float,Turnspeed:Float=.001)
 		Local Target:Float=ATan2(Y-Position.Y,X-Position.X) +180
		Local X1:Float = Sin(Angle)
		Local Y1:Float = Cos(Angle)
		Local X2:Float = Sin(Target)
		Local Y2:Float = Cos(Target)
		Local Current:Float =ATan2(X1-(X1-X2)*Turnspeed,Y1-(Y1-Y2)*Turnspeed)+180
		Local DX:Float = Target-Current
	 	If Abs(DX)>180 Then DX=DX-Sgn(DX)*360
		
	End Method 


I Don't know if it will suit your needs. It works with in a Type. I hope it helps.

This method is part of an "Ememy" Type and this code creates an angular offset which turns the enemy to face the X,Y that I specify. It will choose the closest angle to turn.

DX Contains the Direction to turn.

Regards,
Eric


SillyPutty(Posted 2006) [#7]
Thanks for the code, Eric, it will be very useful in future

but right now, I want the rectangle to have a gardual smooth movement to the mouse pointer.

Kleptos is close, but sometimes bounces back


SillyPutty(Posted 2006) [#8]
Is there anybody that knows how CurveAngle really works ? I am really battling to get this useable, I know the math gurus here could solve this.


JoshK(Posted 2006) [#9]
Use something called Slerp for interpolation between two complex rotations.