Jump to content

Rotating a square on a hill


Recommended Posts

Hey all I have this square I am rotating in my simple plat former and it moves along the straight ground perfectly. I am using:


This rotates the enemy perfectly, and moves it along, but I also have these hills in my game and when the enemy square encounters the hill it has a terrible time trying to get up it. Is there some sort of property that I can set that would help with this perhaps mass? Or any ideas on how to resolve this? Thanks!

P.S I've attached a picture of the square on the hill for reference. Thanks!

Screen Shot 2016-04-15 at 1.42.08 PM.png

Link to comment
Share on other sites

22 minutes ago, schmevie15 said:

Hey there thanks for the answer! 
im not sure exactly what you mean though? 
Should I use anchor.setTo to set the anchor/pivot point, 
And then how can I rotate manually??



I think (not sure) that the difference between pivot and anchor is that the pivot does not change the position of the sprite. So set the pivot to 1,1 initially. Rotate 90 degrees (the sprite), Change the pivot to the new point (1,0). I have drawn a picture, hope it helps and you make it work.

By manually, I mean directly to the sprite, without physics. If you can't make it work and are willing to share your code, i can try to play with it a bit in my spare time.





Link to comment
Share on other sites

I see what the problem is. 

As you have already made it work very well, I would just suggest that you use a variable inside your rotateLeft method. If you are on a steep slope the variable will be higher, if you are on a straight line it can be 450 (mby smaller if you are going downhill). You can change it manually, depending on the position of your enemy. How does that sound? 

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.

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.


  • Recently Browsing   0 members

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