I´m trying to make a game where you drive a physics-based bobsled down a hill.
Now i´m trying to implement the steering, but lacking mathematical and programming knowledge. I imagine it how you would steer on a real bobslide, where you steer with brakes.
So what i want is, when you press A/D ( or Controller L/R Trigger) it will steer the sled in either the Left or Right direction. It should interpolate (if i use this correct), so the longer you press, the more it will steer in given direction (or if you use controller and press the trigger, it will steer depending on how much you press it).
Get the Forwad Vector and Right Vector and Interp(?) it to a curve depending on the given Axis Input. For example steer in a less steep curve like #1 on the picture (axis input value like 0,2 for example) and steer in a steeper curve if pressed fully (1, or -1) like 2. on the picture.
Is this the right way? Could this work? Would i use AddForce? And if this is the right way which mathematics/nodes do i have to use to get this curve?
Thanks for your help guys, looking forward learning new things!
Hey @Elucca! If you were wanting to specifically use physics, yes it’d be AddForce. However… that may not be necessary.
Instead you could do something based on the axis input… which would ideally be used with triggers (Like RT/LT || R2/L2) so you could fine-tune your input. Unless you’re trying to get specific exact curves, you likely won’t need to use any math. Because if you were going to truly steer with brakes, you would have to have multiple movement components and a split vehicle and… too much to think about.
So what you can do instead: just use addforce on a specific point on your sled in a direction (Make it a good spot, I’m thinking middle-frontish, about where the first rider’s feet would be in a bob). Use the getAxisInput, multiply it by a big number (we’re talking tuning by adding and removing 0’s at first), and give it a clamp(float) to lock the value at what you want to be the top point. That part will take some fiddling.
Also, you will likely need to go to the movement component and fiddle with the “Braking friction” value. I’d start there, but you really don’t seem to actually need to do the math yourself, that’s what all this other stuff is for, it’s there to do the physics algebra in your place
This works somehow, but not like intended. It moves it like on a constant left/right but when you would hit the brake on a sled it would be slowly getting more left/right the longer you brake, i think. And how could i implement it so it gets slower, when pressing the Input, and especially do a fullbreak if both inputs are hold at the same time?
(Couldn´t add the Clamp, or didn´t know how)
Somehow this movement input also gets me some issues with my way of having the sled facing it forward direction.
Also, i dont have any movement component… I could add the Floating movement component to my Pawn, should I? In what way can/should i integrate it and why is it important?
Also what i don´t unterstand is, why do i have to apply the forces to steer on the X and not on the Y Axis, i really watched it so the mesh faces the right direction because i had some trouble with it earlier. In my understanding i should add the force on Y because it´s the left/right of the sled or am i wrong?
Trying to understand everything is like having 1 question and getting an answer resulting in having 3 more questions
So you can’t lock yourself into thinking too realistically. Game design is like magic… Everything is an illusion. So adding left/right input and adding left/right brake is the same thing. However, if you’re trying to go full physics… yeah what @ugmoe said.
Also to add a clamp float:
It just locks the value between the minimum and maximum is all.
This gets my sled to stop, but even if i let go the trigger my sled won´t start sliding again, even if given some force/impulse input after reactivating the simulate physics.
Anyway I kinda feel like disabling physics is not the right way, because it would stop for example another player into crashing and influencing the player who is on brakes.
Tried it with linear, angular damping, mass override too, but didn`work out.
Hey again @Elucca! Super happy to hear you got that part figured out!
As for your new issue, what about adding force towards the back of the sled, or using the same code as your forward, but when BOTH are pressed, apply force in the negative numbers?