Match Character Angle to to the Angle of the Terrain

1

Index

Attached Files

The following files have been attached to this tutorial:

.capx

character-parallel-to-ground.capx

Download now 206.97 KB

Stats

1,330 visits, 1,778 views

Translations

This tutorial hasn't been translated.

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Step one:

-> Give the Ground a behaviour of solid

-> Give the Character a behavior of platform

Step two:

-> Adjust the collisions of the Ground and the Character, but don't use too many collision dots as they can slow down your game.

Step three:

-> Create two sprites, which will simulate sensors, put one sensor to the left at a desired distance from the character and it needs to be a bit below the characters' feet and call the sensor sensor_left

-> Do the same for the right sensor, except it goes to the right and you can call it sensor_right

It should look something like this:

Step Four:

-> Add a behavior of Pin to each sensor

Step Five:

Go to the event sheet - System -> on start of layout | Pin the sensors to the character at position and angle

Step Six:

Now what line 5 does is: It checks every tick if the right sensor is in collision with the ground, and if it is, it will rotate the character to the left for -0.7 degrees (negative angle value) every tick (1/60th of a second) until the right sensor isn't in collision with the ground anymore.

Now what line 6 does is: It checks every tick if the left sensor is in collision with the ground, and if it is, it will rotate the character to the right for +0.7 degrees (positive angle value) every tick (1/60th of a second) until the left sensor isn't in collision with the ground anymore.

Download the .capx I provided and try it out and play around a bit to get a deeper understanding of how it all works

Hopefully, this has helped you :-)

.CAPX

character-parallel-to-ground.capx

Download now 206.97 KB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!