I am trying to achieve a somewhat realistic helicopter movement. I am attempting to do this through the use of vectorforce and angular velocity. This is what I have so far:
(click on the broken image picture to open it)
I know that the angular velocity is causing the helicopter to rotate, which is intended, but now the vectorforce is pushing the helicopter in the direction it’s facing, causing it to over-rotate and plummet. How would I get around this? I could constantly update the Attachment’s Y orientation to be within a certain range, but I’m not sure how efficient that would be, and if that would mess things up. Any ideas what I should do? Is there an object that allows me to limit the angle the helicopter can be at? If this thing exists, I MIGHT be able to set the desired angle, and the vector force should do all the work, pushing it in the direction it is tilted. But then, crashing brings up a whole other problem…
Edit: Even if I could figure out a way to limit the rotation, it will still be relative to Attachment, still just sending it downwards at an angle. Not sure what to do I could make it not relative to the attachment but to the world, and I think I would use lookVector to accomplish this, if I am not using the Attachment anymore?
If you want to keep the rotation while maintaining a solely upward thrust, just rotate the body force in the opposite direction of the current orientation relative to the “up” direction.
I’m pretty sure it would look like this,
BodyForce.Force = Vector3.new(-Heli.CFrame *Vector3.new(0,1,0))
-- Force = Opposite rotation of Heli CFrame relative to the y axis(up).
I’m not sure if that works, but hopefully the logic at least makes some sense. Hope that helps.
Hmm… it doesn’t seem to make a difference in the syntax…
I’m pretty sure it has to do with trying to change a read-only property, hence the userdata thing. But the unm thing I’m not so sure. It could be that your Heli CFrame is just a reference, and not the actual CFrame itself? It would be helpful to see a snippet of code where you are applying this.
script.Parent is a MeshPart. Could that be the problem? Also, I might be able to accomplish what I want. I am able to get the helicopter to rise up, and then move in a direction by setting the angular velocity, but the problem is trying to get it to slow down, and go back to just hovering/rising.
In this code, it starts off by going forward, waiting 2 seconds, and I want to reverse what the helicopter is doing. It just doesn’t do it though. It just keeps flying off in that direction, despite the huge number in the opposite direction. In fact, it seems like doing that just makes it fly even faster, even though I made it positive?
For your second script, changing the angular velocity - how does that slow down the force? All it does is change the rotation in the opposite direction. You need to change the vector force too (not sure if you are doing that already in a different script).
I ditched the angular velocity route, and started using torque, and it is looking promising.
It is easier to control! I think this is my best bet. In this gif, the helicopter rises and goes forward due to the torque, I then set it to angle back, the helicopter slows down because of this, and starts rising again. Now the challenge is to get the helicopter to rotate left and right
So now that I have pretty good movement for a helicopter via torque and vectorforce, how would I go about stabilizing the helicopter with the torque, having it just hover in place? I just want to stop the helicopter tilting. Setting Torque to 0,0,0 obviously doesnt do anything, as torque just spins it.
Edit: Going to attempt to do it with an AlignOrientation object.
Edit 2: Don’t think that will help. Attempting to mess with vectorforce to stabilize
Edit 3: I suck at math too much for this
You could probably use a body gyro. They don’t have to be concurrently reset as long as you have simplified states for your helicopter. Moving -> set the gyro to the rotated orientation. Slowing down you would have it back to the initial orientation. The idea is that since you can control how fast body gyro reacts, it can slowly move to the intended position based on how fast you would like it to get there.
But the problem is the vectorforce itself. That’s the thing that doesn’t slown down. I need a way to implement some sort of drag system, which I’m not sure how to do. The helicopter would just keep flying forever in a direction if I didn’t stop it. I think I’ll try a bodyposition first. When no input for the helicopter is found, just repeatedly set the bodyposition to the helicopters current position (?) until it stops moving.
Hmmm… If you are afraid of constantly updating in a loop, you could resort to using TweenService for your bodyposition, or force or otherwise. Physics in Roblox is annoying because there are so many ways to do things and half of them don’t work
I would gladly tween the vectorforce in a way that slows the helicopter down with drag when the user stops input, but I don’t even know where to begin in terms of math with that. I don’t know how to calculate how much velocity the helicopter needs to slow down
I think that’s where bodyvelocity works nicely, you just tween it right down to 0.
If you use your vectorforce, your drag would have to depend on how fast the helicopter is moving, which require you to reset the tween every frame. That’s not really optimal and would be better in a loop, which is still not what you are looking for.
I think a mix would suit your heli best. Keep your existing vector force - but when the player stops input, use a body velocity. The setup would be having the body velocity inactive when the player is providing input; when the player stops inputting, set the force to 0 and then set the velocity to the current velocity. Then you can tween the velocity down to 0, which will (hopefully) keep it at a constant height and stop any jittering.
I mean, it makes sense in my head - what do you think?