Walkable slope for pawn

Hi!

So I’m making a 2d adventure game and since I ran into some problems with the character class I decided to use a pawn class and write my movement from scratch. I’ve been making good progress so far (jumps, ladders, gravity, ledgeclimbing…) but one thing that has me stumped is walking up- or downhill hah.

How I’ve gone about it now is do a linetrace down from the pawn and getting the normal of the surface it’s walking on, but the closest I’ve gotten after that is getting it to kinda hop up the slope because it’s moving up and away from the floor causing gravity to kick in repeatedly. it does not look very well.

I’ve been scratching my head for a couple of days on this would really appreciate some input or ideas on how to make a pawn move up/downhill. Remember, I’m also moving the character with Adding world offset and not movement input since I don’t wanna use the character movement component (partly because I ran into some limitations but mostly because I wanna challenge myself and learn more basic stuff)

Thanks in advance!

Is there a specia reason for using a “pawn” instead of a “character” blueprint class?

As far as I recall it had mostly to do with movement modes, especially switching to flying when I needed to give the player character upwards movement for ladders. I think there was some other reason too but I can’t quite remember. :stuck_out_tongue: Also, as I said it’s a nice way to learn

So I have the code for figuring out the movement vector, tho it seems getting the sampling of the groundnormal is actually kinda tricky. The ways I’ve tried ends up causing the player to snag at certain points where it transitions from one normal to another, i.e. transition between flat surface to hill. I’ll fiddle around with it and post my findings as an answer. or if someone has any input on how I should trace for the normal please feel free to help out:D

So for anyone reading this who has the slightest bit of knowledge about vector math should be able to solve this problem fairly easily.

I used a box trace for my floorcheck, got the floorNormal and crossProducted that with the world Y-axis. I multiplied that vector with the float I got from dotproducting input and the crossproduct.

I fixed the snagging by only sweeping the movement along x axis and not the movement along z axis. :slight_smile:

Hey ZeoZen,
I don´t know if I am a stupid to comment on your solution that you have posted in 2015 but it would really help me with my project.
Your suggestion seems pretty convincing but would really appreciate if you could explain it with some screenshot or simple drawing for those who have problems with Vectors.
PS: I am working with the mannequinn of ue4 in a irregular terrain and I need the foot to be placed correctly according to nature of ground where the character is stepping.

Thank you so much for understanding!

Hey! I don’t even have this project around, it got deleted by mistake a long time ago:( But from what you’re saying it sounds like you want to know more about using IK (inverse kinematics) to animate feet according to terrain? Try searching for those keywords. Nothing I did in that project would help you do what you’re explaining. All I did was get a sprite to receive input and move up and down 45 degree slopes, and I haven’t used Inverse Kinematics for anything yet, but try looking that up! Cheers!