# How do I set the character to the same angle as the ground?

0 favourites
• 7 posts
From the Asset Store
25 high quality isometric ground blocks + sprite sheet
• I've been playing around trying to make a nice way of making the player's angle be the same angle as the ground using physics. It kinda works, but it's buggy because of the physics rotation... I've been thinking of making empty line sprites and use them as a collision system and set the player's angle to them, but I guess it would take too many resources and affect the performance. There must be a better way to do this. Any suggestions?

This is how almost all the ground in my game looks like: https://prnt.sc/hqrs2x

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• you could have an invisible object in the center of the ground that always points towards the player, and then have the player constantly set its angle to the same angle as the invisible object. not sure if this would work, but its worth a shot.

• You can define two image points on the player sprite on both sides, just above the ground level. (Blue line represents Player sprite)

Like those little training wheels on kids' bicycles

Then use these checks on every tick:

System -> Pick Ground by overlapping point (player.ImagePointX(1), player.ImagePointY(1))

...Rotate player 0.5 degrees

System -> Pick Ground by overlapping point (player.ImagePointX(2), player.ImagePointY(2))

...Rotate player -0.5 degrees

You can use lerp or tween for smooth rotation.

To detect ground angle when player is on top of the hill, you need to define two additional image points just below the ground level and perform similar checks for them..

If you are good with math, instead of using 4 image points, you can do lots of overlapping checks around the player to determine ground angle with better precision. Overlapping tests in C2 are fast, even if you are doing a couple of hundreds of them every tick, they should not affect the performance.

• I was thinking about that as well, but I didn't think it would perform well either and lerp came nowhere near my mind

• Made a tutorial about it so that other's dont' have to go through my struggle

https://www.scirra.com/tutorials/9615/m ... he-terrain

• You don't really need sprites, you can use "overlapping a point", should be a bit faster. Also, when the ground curves inwards, you need to check overlapping higher than the character's feet level.

• I don't really like using image points for when I would need them outside of my character sprite, I like to have things like "sensors" visually in my layout so that I can tweak their positioning faster. And I did "when the ground curves inwards, you need to check overlapping higher than the character's feet level." this using image points in my main project. Assigned one to the bottom left and another to bottom right, so it's checking every tick if the image point is not overlapping the ground and adjusts the rotation accordingly. Works fine for now. -I might edit the tutorial into using only image points and add more overlapping checkings, but they aren't very newb friendly and I made a beginner tutorial (a foundation to build up upon).

• 7 posts