So, I made a turret that shoots the noob. I don’t understand these lines.
upperTurret.CFrame = CFrame.new(upperTurret.Position, torso.Position)
I thought cframe only had one arguement which is the position. Why is there two arguments, what do they do, and what do they mean?
cloneBullet.Velocity = upperTurret.CFrame.LookVector * bulletSpeed
What is velocity. I mean it’s obvious it changes speed. But how do you use it and can’t you just do:
cloneBullet.Position = Vector3.new(0,0,0) + Vector3.new(0,0,10)
Any response is appreciated!
CFrame.new(Position, LookAt) is a way of creating a CFrame at a given position with it pointing at the LookAt position.
Velocity is a constant speed. A part with a Velocity of Vector3.new(0, 0, 1) will move in the Z axis by 1 stud every second.
You can change the position manually, if you really want, but it’s just more work on your end when you could just set the Velocity once and be done.
2 Likes
Not quite sure about the CFrame one, but Velocity is actually a property in a part, you can change the parts velocity by changing the Velocity, like this:
part.Velocity = Vector3.new(10, 10, 10) --Vector3.new(X, Y, Z)
1 Like
So velocity will like go on forever??? Why can’t I just say:
cloneBullet.Position = Vector3.new(0,0,0) + Vector3.new(0,0,10)
And can you explain the second argument of cframe? Thanks so much!!!
You could do that, but if you wanted to keep moving the bullet, you would need a loop.
CFrame.new(Vector3.new(0, 0, 0), Vector3.new(1, 0 0)) is like me telling you to stand at (0, 0, 0) and towards the positive X-axis. First argument sets position, second argument sets orientation.
1 Like
Blizzero
(Blizzero)
March 9, 2021, 2:15am
6
Increasing the velocity of an object will result it in moving forever (assuming it’s unanchored) until its velocity is reset.
cloneBullet.Position = Vector3.new(0,0,0) + Vector3.new(0,0,10)
This will increase the part’s position on the Y-axis by 10 studs. This will happen once, and it will be instant.
If you set the part’s velocity to (0, 10, 0), then it will be moving at a constant, smooth rate of 10 studs increment on the Y-axis each second.
1 Like