It’s crazy that I can’t find any answers already on the forum for this… but… how do you take a model, and move it in a random direction? I.e., taking x,z axis, and picking a random angle (0-360 degrees), and moving forwards on that random angle?
- Ignoring Y axis - keeping it at exacly the same height.
- The model contains a primaryPart (which is a box with a decal on the top).
- I want collisions to work for it as normal. When it hits a wall, it’s going to bounce.
- It should just move in that direction until I say otherwise.
part.Anchored=false
local randomVector = Vector3.new(math.random(-math.pi * 90, math.pi * 90), 0, math.random(-math.pi * 90, math.pi * 90))
--monster.wsObj.AssemblyLinearVelocity=randomVector --tried this because .Velocity is deprecated
local bodyVelocity = Instance.new("BodyVelocity", part)
bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
--bodyVelocity.Velocity = Vector3.new(0.5,0,0)
bodyVelocity.Velocity = randomVector * 500000 -- tried 1,5, 50, 500
Some of my problems are… if it moves, it shoots off way too fast. Or, if I set MaxForce to low values, it only moves a short distance then stops. And I think the random Vector3 has a potential to make (0,0,0) (or near to it) resulting in no movement sometimes. I want to guarantee it moves, and not to calculate the X and Z both randomly (as they could both end up as 0).