I’m trying to make homing projectile, I need to get angle to rotate angle each frame.
speed of projectile between frames is constant. (2 studs per frame)
red arrow is no homing direction, and blue line is how it should rotate. How can I get that angle between blue line connection? also, the angles between blue lines should same, ex - it should not change to 10 to 7
You should probably change it to be time-dependent and not frame-count dependent. That way the speed doesn’t change if the frame rate drops.
The only way to do that is with a circle arc, since circles are the only type of curve with constant curvature. This means you actually need another constraint to define the circle, since there’s an infinite number of circles that can be made to go through any 2 points. So you need a 3rd point to define the circle.
Some good points made, I belive you are referancing beizer curves which are created by 3 points, its a good idea but keep in mind that the target will be on the move.
A better option would be to get the change required in angles and devide it up by whatever limitations e.g max rotation of 10 as well as the distance. This would give you a nice projectile turn radius whether you use speed or frame.
No, just circles, they need 3 points as well. E.g. all these circles are possible with just 2 points fixed:
So if you want to go from A to B through a circular arc, there’s infinite possible ways of doing that:
I found how to use bezier curves and tried to apply on my script, but I got another problem, I thought I can get first position of bezier curve and calculate angle per frame but I don’t know how to apply
I found this and now I don’t know how to apply this with cframe.angles or something else.
local Angle = math.acos(PartA.Position:Dot(PartB.Position)/(PartA.Position.Magnitude * PartB.Position.Magnitude))
uh also position between p0 and p1, p1 and p2 is same.
local posFirst = fireCF.Position
local posBetween = selectedTarget.Postion
local posLast = posBetween + fireCF.LookVector * (posFirst - posBetween).magnitude
since position between points are same, I think bezier curves’s angle will be same.
if not, I should use circle arc
since I’m bad at math, I need explanation…(I only checked about bezier curves)
post is worded poorly. I’m not even sure why you’re doing this in the first place. If you’re trying to make a homing/heat seeking missile, you can just use a cframe to point the missile at the target. if you don’t want it to turn instantly, give it a bodygyro and stiffen it so it moves slowly.
Excuse me if I’m misunderstanding.
But if you want to make a homing missile, you can simply point the missile towards the part using builtin functions.
See here:
Point part in direction of another part - Help and Feedback / Scripting Support - DevForum | Roblox
Then, you can just move it forwards in the direction it is facing.
what if you want it to lead the target? what formula would I use to off set the cframe so it doesn’t just follow behind it
add its velocity to the target’s position