Hey guys. I’m trying to get my static mesh vehicle to be able to steer like a normal vehicle when moving left or right (i.e. I want it to be able to turn). My blueprint is a pawn class so I can’t use any of the fancy wheeled vehicle functions. What’s the best way to do this?
vehicle mesh have to be a skeletal mesh, to have bones to rotate in an animation blueprint. unless the wheels are on separate meshes. I really do not recommand the path you are taking tho, would be much easier to follow some tutorials and use the wheeled vehicle class instead of pawn.
But I wanted my vehicles to be more like spaceships i.e. not have wheels, levitate of the ground and move like a car would (even if it’s just basic steering, acceleration etc). Is there any way at all to do this?
oh ok, of course there is a way I see 2 options: either make a regular vehicle with invisible wheels so it would appear to be levitating.
or make a levitating vehicle the way you want it, still rig what you want to be steering on bones to be able to rotate them inside an animation blueprint. You would then need to create a float variable for steering angle, and increment or decrement this variable with inputs in the vehicle pawn and pass the variable to the animation blueprint.
Do you want to move it using physics or more like kind kinematic body where you calculate movement and rotation yourselves?
Ideally I’d want to use physics but if I wanted to calculate the movement and rotation myself, how would I do that? I’ve tried using RInterpTo but I’ve had no luck with it
Have you checked out Anti Gravity Levitation System by James Wirick? It’s in the market place. This sounds like something you would want. I’ve tried it myself. I haven’t tested out the upgrade for 4.11 but I will this weekend. It works for what I want it to do. I’ve been trying to make a decent AI for it. If you try it and come up with one let me know.
You can do it by using few node. For example, throttle of the car can be done by changing velocity of the car in the direction where wheels are pointing.
On each Tick() event, you can calculate new Velocity of the car as:
NewVelocity = GetActorLinearVelocity(car) + GetForwardVector(SteeringWheels) * DeltaTime * EngineAcceleration * ThrottlePedal
where EngineAcceleration is just some constant and ThrottlePedal is value from 0 to 1 or from -0.25 to 1 if you want to go backward 4 times slower than forward.
To steer you just rotate Wheel component using AddRotation, this will change direction in which wheels are pointing and so GetForwardVector(SteeringWheels) will be different to direction where car points.
On top of that you need to manage rotation of the car itself, which you can do by building new Rotation vector out of Velocity vector, there is node GetRotatorFromVector for that.
If you don’t have any wheels, you could simply AddRotation to the car mesh and replace GetForwardVector(SteeringWheels) with GetForwardVector(DesiredDirectionOfTravel) where DesiredDirectionOfTravel is a vector where you want car to go.
I took a look at it and yea that’s kind of like what I want. The price tag for it is too steep for me tho but I would love to make my own similar system.
Thanks a lot! Will try when I get the time
^I can’t seem to get this to work. How do I correctly use the ‘add rotation’ node so that my mesh would only rotate when I press the left/right movement keys? When I try using the add rotation node, my mesh rotates constantly when the game starts
Just interpolate the amount by which it should rotate on tick, by using Interp node. Multiple InputAxis by some constant and provide this as a target to Interp node. Current and result value should be the same variable and this variable is used in AddRotation node