Whats the easiest way to create ProjectTile with CFrame?

So what I want to do, is to create a ProjectTile that will go from pos1 to pos2. How I can make it with CFrame in a easy way? Here is an example on what I mean by that:

(also target will be moving)

2 Likes

Would a RocketPropulsion not be better for something like this? Or am I misreading what you’re asking for?

I dont want RocketPropulsion, I would rather use CFrame, and RocketPropulsion goes straight to target instead of flying up like a missile or a rocket.

You could use a BodyThrust and set the MaxForce (I think) property of the RocketPropulsion to 0,0,0. Then it’s just a case of fiddling around with the turn dampening. But if you’d still prefer CFrames then that’s fair enough.

Is the idea that the projectile will follow its target as it moves? Or just follow a path to the target’s position when it was first fired?

Just follow a path to the target’s position when it was first fired.

If you must use CFrame, then you will need to use the kinematic equations to compute the projectile’s position as a function of time.

1 Like

How I would able to implement that into my game?

x = X + V0 * t * cos(theta)
y = Y + V0 * t * sin(theta) - 0.5g(t^2)

I found this equation online.

X, Y - The x and y start position
v0 - Initial Velocity
t - Time in seconds since initial firing
theta - Angle of firing
g - Gravity

Obviously this is in 2D space, but I presume you can calculate the Z coordinate the same way as the X.

1 Like

How I can move that projectitle tho? I never had to deal with CFrame calculations

If you have an X, Y, and Z coordinate, you can simply set the CFrame to: CFrame.new(X, Y, Z)

You’ll have to find a way of handling rotation, and that’s as simple as multiplying the CFrame by: CFrame.Angles(r1, r2, r3)

Note that r1, r2, and r3 are in radians, as well as theta in the above equation when using the math.cos/math.sin functions.

I will further @Blokav and say that you really should look into the math before attempting something like this. If you need more help with CFrames as well, there’s some useful articles here: Understanding CFrames and here: CFrame Math Operations

2 Likes