Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make a part turn its direction half way to another part?

Asked by
Necro_las 412 Moderation Voter
3 years ago

I am trying to make a holming projectile using heartbeat event, so im describing its positions and orientations with CFrame. Its working well but now I want to add holming effect, and I have no idea of how to make the Orientation add half, or 1/5 of the way to facing another part direction.

I know how to describe the orientation to face another part in a single row in plenty ways, but half? Help

2 answers

Log in to vote
1
Answered by
sleazel 1287 Moderation Voter
3 years ago

What does holming mean? Is it the old Welsh practice of slashing female servants and late risers with holly branches?

Jokes aside, it is best to use CFrame.Angles for this task. It is used something like this (lets assume your part is called projectile):


projectile.CFrame = projectile.CFrame * CFrame.Angles(rot1,rot2,rot3)

Replace one of rot1 rot2 rot3 with angle in radians. Rest of them should be set to 0, if you only want rotation on one axis. Which one of those you need to set, depends on your default projectile rotation.

Example, rotating projectile by 30 degrees:


projectile.CFrame = projectile.CFrame * CFrame.Angles(math.rad(30),0,0)
0
This look like it would rotate the projectile in a given direction, but it doesnt make me able to rotate relative to another parts direction, that I dont know what direction is in code. I solved with lerp below Necro_las 412 — 3y
0
Holming is like a guided missile lol Necro_las 412 — 3y
Ad
Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
3 years ago

I solved this with :Lerp()

arrow.CFrame = arrow.CFrame:Lerp(CFrame.new(arrow.Position, Target.Position), 1/10) 

Answer this question