Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I rotate player follow ground? #11

Open
ghost opened this issue Mar 8, 2017 · 1 comment
Open

Can I rotate player follow ground? #11

ghost opened this issue Mar 8, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 8, 2017

untitled

@Koopa1018
Copy link

Are you trying to make the player sprite rotate to match the ground, a la Sonic? That's pretty simple:

  1. Put the sprite in its own game object.
  2. Have some component that has a reference to the sprite object's Transform. This can be the Player script, or it could be some other script. For the sake of organization and reuse, I'd create a new component to do this, but that's just one option.
  3. In this component's Update method, have it get the angle of the slope (from collisions.slopeNormal) and write that value over the sprite Transform's eulerAngles.z.
  4. Some extra work will probably be needed to get the sprite to stop floating above slopes with higher angles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant