Character leaning rotation

Hi people,

Ive been working on an endless runner type game where the player controls a bike, Ive not used a vehicle BP but instead i just used the 3rd person BP template.

Its going well so far but I’m just trying to get the bike controls to look more realistic, at the moment the bike goes forward without any input and the player is able to turn left and right to avoid incoming obstacles which is all fine.

But id like it so the player character (The Bike) leans left and right when turning to make it look more believable and move like a two wheeled vehicle would.
Id also like the camera to lean with the player movement but ill be fine doing that when i figure out how to make the bike lean i think.

Just looking at the 3rd person character BP it looks like this part is where it controls the character turning rotation? and possibly where ill be able to control the character lean (Roll?) with some extra work… ill keep playing around myself but so far Ive not been able to figure it out :confused:

Any help or a nudge in the right direction would be much appreciated :slight_smile:
Cheers!

Roll should do the trick, can You show us where this bike model has pivot?

Ok cool! do you know how i could access the Roll from ‘input axis move right’ node so that it rolls say 25 degrees when the direction keys are pressed?

Sure here’s an image showing where the pivot is for the bike.

Ok cool! do you know how i could access the Roll from ‘input axis move right’ node so that it rolls say 25 degrees when the direction keys are pressed?

You have to do it yourself, try something like this: input axis right * 25 degress and pass result to SetActorRotation on the roll component, but if input axis values comes instantly to 0 or 1 you should use smooth interpolation. Also you would straighten roll rotation if bike velocity is greater than 0.25* max speed.

I would move pivot to the botton of the bike, otherwise the bike roll rotation may look weird, but it’s your decision.

Ok, i get what i need to do but i cant figure out how i exactly implement this in the BP :confused: Ive tried to get it working but I’m just guessing really with no outcome, i can get the bike to rotate on its side but it seems to get stuck like that and only will work in one direction not leaning left and right :confused:
Do you know how id get started?
Thanks for the reply and help :slight_smile:

I’m still really stuck on this problem :frowning: I’m a bit lost on what to do, I’ve tried so many options but I’m doubtful that I’m even going about it in the correct way. but also I’m unsure if its even possible with my BP because i have already put a line trace to keep the bike on the floor for going up and down ramps… which is stopping the bike character from rotating on its side :confused:

(to trace the floor)

Finally! after hours of trial and error i figured out a way to get it working :smiley:
This may be a little different to anyone else that is looking for the same solution because I’m doing a line trace on the character but it may help so ill post what i did to get it working anyway :slight_smile:

I just removed the roll stuff from the line trace as i don’t really need it anyway, i then put the roll into a Var so i could alter it later.
Next i simply just changed the Var with a left and right key press that went to a “set var” node and that’s it! annoyed that i didn’t do this earlier but i guess i didn’t really have a clue.

Now my bike has some sweet left and right leaning :smiley:

I just got there, and I’m a bit confused on what was done to solve the problem ?
could we get the complete process that you got through ?

Hey, Beaulamb, can you shere your project BP setup for pawn ?