How do I rotate a pinned sprite with constraints

0 favourites
  • 10 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Hi,

    Im trying to create a player unit that has an upper and lower body, upper being the torso and lower the legs so i can set it upso that the legs canbe controlled separately as well as the upper body. Now it was a cinch to get it to work like a tank so that the upper body would rotate a full 360 degrees where the mouse points and moving the lower part with arrow keys. But id like it to have a constraint such as a normal body that it cannot rotate more than say 90 degrees to either side from where the lower half is pointing at. How would i get such a thing done?

  • Using the clamp expression you could probably get this done.

    It would look something like this:

    Upper body set angle - clamp(angle(upperbody.x, upperbody.y, mouse.x, mouse.y), lowerbody.angle-90, lowerbody.angle+90)

  • It actually seems to work in the starting direction allright, but as soon as you walk a different way, the upper body stops functioning right.Why is this? Im guessing the program gets confused on the angle of the player since the staring angle is 0, but when you start walking left. it changes to 180, so the upper body cant work on the mentioned +/- 90 degree angles? Or is it something else.

    ..why cant i post a file anymore ?? would be easier to show the file. Oh well..dropbox will do

    https://dl.dropboxusercontent.com/u/73502848/upperlowerbody/uplow.capx[/code:32p2rrld]
    
    I suppose it would be worth mentioning that im trying to make an isometric game if i get somewhere with this, so that will propably create its own problems too. im guessing id have to greate a frame to each individual turn degree or am i going this completely the wrong way? Im pushing for an isometric world with an alien swarm type of movement.
  • I would really appreciate any pointers with this, i can't figure it out even though im pretty sure its something simple.

  • I was playing with "is between angles" (see: https://www.scirra.com/manual/131/common-conditions) a while ago - maybe this could give you another starting point ?

    https://dl.dropboxusercontent.com/u/143 ... /tank.capx

  • I was playing with "is between angles" (see: ) a while ago - maybe this could give you another starting point ?

    That..actually works quite damn well ! The only issue i get now, is that the rate of turn is somewhat slow. I tried increasing the rotation from 1 to 10 which speeds things up, but also increases the jutter you experienced as well. Figured a way to stop this from happening?

  • Tried everything in my very slim book of tricks, but im still fighting to get this done. RamPackWobbles idea works like a charm, but it creates a jutter when the angle exeeds its limit. This can be minimized by lowering the degree amount that the object rotates, but this also slows the momement down. Its so close i can taste it, but still not there, so help..please.

  • I will have another play over the weekend and see if I can improve on it (one idea does come to mind).

  • RamPackWobble

    we already got alot further in this thread:

    But maybe you could shine your light on it..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LittleStain

    Thanks - didn't realise there was another thread. I will download and assimilate...

    Once again my light is redundant

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)