Moving Gradually from one angle to another
BlitzMax Forums/BlitzMax Programming/Moving Gradually from one angle to another
| ||
I know there is bound to be something like this laying around, but how does one move gradually from one angle to another ? |
| ||
Use a Float variable? |
| ||
I found this code |
| ||
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. |
| ||
Do you mean like this ? |
| ||
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 |
| ||
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 |
| ||
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. |
| ||
Use something called Slerp for interpolation between two complex rotations. |