Jump to content

How make player rotate in jump function?


angelkom
 Share

Recommended Posts

How can I make the player rotate in jump function i'm using flying dog demo, the player doesn't jump if I put in jump function, but if I put in update function it rotates but I want to rotate only when he jumps I tried with this.sprite.rotation = -1, this.sprite.rotate, this.body.rotation, this.body.rotate, this.sprite.angle, this.body.angle but no luck

Link to comment
Share on other sites

Well of course id doesn't work because you have to check wether the player is jumping or not with a boolean variable.
But I do this in another way:

In the update function of the player I check if it's body's y velocity is <0 (going up) or >0 (going down) and then I adjust it's sprite rotation.

 

if(this.body.velocity.y < 0){  this.sprite.rotation = -0.4;}else{  this.sprite.rotation = 0;}

Since the rotation is immediate I would suggest to lerp the rotation.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...