so i have a floor intance calculator to caluclate the floor instance to see if the player should gain or lose speed based on the slope
so some how even though i have the same code asa tutorial i used my player still seems to slide up hill
so i have a floor intance calculator to caluclate the floor instance to see if the player should gain or lose speed based on the slope
so some how even though i have the same code asa tutorial i used my player still seems to slide up hill
Imo all you need is (0.0, 0.0, 1.0) dot FloorNormal
to know how steep the slope is.
The resulting value can be used to control velocity.
isnt that what i have rn?
Don’t see where it affects the velocity.
That’s the return value of the function, but where is the math that affects the characters velocity?
Edit: to elaborate a bit, the bp function you posted returns a vector that is pointing ‘down’ perpendicular to the surface up normal with its magnitude scaled depending on the angle. So if its not working I would assume the issue is where the return value affects the characters velocity.
“Uphill” and “Downhill” are different directions for the same floor for the same location.
You can’t just figure out whether there’s a slope or not, you have to know what direction the slope is in.
Typically, you will calculate the dot product between the surface normal and the players’ forward vector, and apply an impulse in the player forward direction of that magnitude times some scaling factor. Then you’ll calculate the dot product between the surface normal and the player’s right vector, and apply an impulse in the player right direction of that magnitude times some other scaling factor.
You can also choose to not apply an impulse if the value is smaller than some cut-off, and also choose to apply some kind of drag/friction always when the player is in contact with the ground.
You might also want to adjust the direction you apply impulses in to align with the ground direction (esentially, cancel out the direction of the surface normal when applying.)
Another way to achieve the same effect is to do rigid body dynamics (physical simulation) on the player capsule (use a Pawn, not a Character for this) and drive the player entirely with physics.
Think this should return a vector that always points bellow horizon perpendicular to the surface normal.
Atm not at pc to draw debug.
Yea no i still cant figure it out lol
i kind of found a fix by setting the clamping to -1 to 1 it actually stops the play from going up while sliding all i had to do other than that is remove the the subtract 1