GoulStorm
(Cassie)
November 3, 2023, 7:00am
#1
I am trying to make some parts get an impulse using .AssemblyLinearVelocity
, but I want them to not go straight forward to the same direction, but have some small random offsets. However, my knowledge on math in general is really bad and I’m not really experienced with Vector3’s in Roblox when it isn’t to position some parts.
This is the piece of the code in which I want to make the offset:
pebble.AssemblyLinearVelocity = Vector3.new(humanoidRootPart.CFrame.LookVector.X * 100, math.random(25, 30), humanoidRootPart.CFrame.LookVector.Z * 100)
I just want to know a way I could make the “pebble” also go to different directions inside 15 degrees. I think this image can describe it better:
2 Likes
Try this:
pebble.AssemblyLinearVelocity = Vector3.new(humanoidRootPart.CFrame.LookVector.X * 100 + math.random(0,15), math.random(25, 30), humanoidRootPart.CFrame.LookVector.Z * 100 + math.random(0,15))
1 Like
GoulStorm
(Cassie)
November 3, 2023, 7:52pm
#3
That worked, thanks. Quite questionable why it worked because I did the same yesterday and the objects got flung away.
Just an addition: using math.random(-15, 15)
is the right way, math.random(0, 15)
makes the offset just to one side.
pebble.AssemblyLinearVelocity = Vector3.new(humanoidRootPart.CFrame.LookVector.X * 100 + math.random(-15, 15), math.random(25, 30), humanoidRootPart.CFrame.LookVector.Z * 100 + math.random(-15, 15))
1 Like
system
(system)
Closed
November 17, 2023, 7:53pm
#4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.