My Vehicle keeps turning to one side whenever it moves [SOLVED]

Hello, recently I’ve been working on making a space ship, the way it works is that whenever you sit in the space ship, you are prompted to choose what planet you wish to go to. Once you click which one you want to visit. It will take you there, however, there is a small problem that I’m not fully sure why is happening.

Keep in my mind, this is only one of my very few times I worked with stuff that’s related to Roblox physics such as BodyVelocity and such, so I am not completely sure how to work, I’m still learning.

Bascially, when you click on the planet you wanna go to, your spaceship will rotate and face towards that planet and then proceed to move over there. Problem with it is that when it begins to move to the planet, the spaceship rotates back to one side and doesn’t any longer stay in the direction it was facing towards the planet.

Line 4 is what makes the spaceship face the planet. I believe the problem lies on line 9 which is what makes the spaceship move to the planet.

Not fully sure why this is happening, I tried doing research and attempted to fix it myself but came up with nothing. If you have any questions then please ask, any help is appreciated!

2 Likes

i’d assume it would have something to do with the body gyro, but without the full picture its hard to tell.
make sure the body gyro isnt affecting the rotation

BodyGyro maintains a constant orientation alongside a CFrame (it’s a property of BodyGyro). It’s why whenever you set the initial CFrame, it rotates back to one side – because it’s rotating towards the CFrame set on the BodyGyro.

Instead, you should replace the first line of playersRocketShip.Base.CFrame = ... with:

playersRocketShip.Base.BodyGyro.CFrame = CFrame.lookAt(playersRocketShip.Base.Position, SelectedPlanet.Planet.Position)
-- btw the way ur using CFrame.new() is the same as CFrame.lookAt() so yeah

Hey so I just did some research on AlignOrientation and AlignPosition and I got it to work instead of continuing to use BodyGyros but now I’ve ran into a different problem.

When the rocket moves it, moves all around, what I mean is it keeps rotating in all different directions, when it reaches its destination it does stay in that place, but it doesn’t stay in a stable direction, it keeps turning left and right or up and down.

And also, when using AlignOrientation to make it face the planet, it works but for some reason it faces it using the right face of the Space Ships base instead of the front face to make it face the planet.

Heres the code for what I did so far

And heres where I set it up

Any idea for why this may be happening?

1 Like

Hey actually I just solved the problem for the AlignOrientation, it was something to do with the attachment not facing the front face and instead the right face. The AlignPosition remains a issue though.

1 Like

Try enabling RigidityEnabled on your AlignOrientation which forces the “physics solver” to orient towards the other attachment as quickly as possible (and this usually stabilizes the orientation)

Here’s a comparison between:

  • YELLOW → RigidityEnabled = true
  • BLUE → RigidityEnabled = false, but MaxAngularVelocity & MaxTorque & Responsiveness are maxxed
  • GREEN → RigidityEnabled = false, but on the default properties

1 Like

Just did this and it does help. I tried using this on AlignPosition to since it does stablize it more, it may help out, but it seems to only make it worse lol.

The AlignOrientation seems all good now it’s just really the AlignPosition thats the problem, heres a video showing the problem.

1 Like

Is RigidityEnabled turned on for AlignPosition? If it’s still doing weird movements, try toggling ApplyAtCenterOfMass and ReactionForceEnabled and see what combination gives off the most stable movement? You could also try doing the same for AlignOrientation.

In fact, try disabling AlignOrientation and test if the iffy movement still happens even without AlignOrientation.

Just keep messing with properties and try to isolate what’s causing the issue, I think you’ll eventually find something that works.

1 Like

Just tried this, ApplyAtCenterOfMass seemed to solve it. Everything seems all good now. Thank you so much for your help, I really appreciate it! :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.