How can you change attributes based on movement direction?

design219design219 Member Posts: 2,273
edited November -1 in Working with GS (Mac)
Here's my problem: I'm updating my game to add a joystick option. I have the joystick working (finally!), but I have an effect that I want to maintain from the other control setup. The current controls are left, right, up and down with the large arrow buttons. These buttons also change attributes called Left, Right, Up and Down when they are pressed or released.

The main Actor (the Nose) is moved by the buttons, but there are constrained actors (the gears) that move with the nose AND are changed by the different attributes (an animation of them spinning up and down). The below image shows the Up button pushed and the respective gear spinning. A subtle effect, but I don't want to lose it.

image

So, I need to find the simplest way to change these attributes with the joystick controlling the nose... either detecting the direction the actor is in, or by the actual joystick itself.

Any suggestions?

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Well, the joystick uses vectorToangle, correct? Seems like you should be able to check that value and if it is between 45 and 135 do the UP stuff. If it is 135 to 225 then left stuff, etc.
  • design219design219 Member Posts: 2,273
    Thanks scitunes, that worked perfectly!

    _________________________________

    HOLY NOSE JOB!: Nesen Probe: Is this the single most unappealing game in the history of GameSalad? I can't seem to give it away! Anywhere. But if anyone want's to try it out, codes are still available near the end of the thread! http://gamesalad.com/forums/topic.php?id=8097
  • design219design219 Member Posts: 2,273
    Ah, spoke too soon. It's partially working. It works for the "up" : if angle is >0 but <180, but it doesn't seem to be doing anything for angles larger than 180.

    Does the vector to angle do something different with the bottom half of the circle?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    here's what I did once for an image change based on actor rotation and it works great:

    up image: >=45 , <135
    left image: >=135, <225
    down image: >=225, <315
    right image: >=315
    right image: <45

    because of the way GS handles the 360/0 point of rotation I had to do the right image as two separate rules for some reason.

    Good luck!
  • design219design219 Member Posts: 2,273
    Thank scitunes, I've tried a variety of adjustments, but it just wont take any number above 180. Weird.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Slap a Display text on the joystick so you can read what the angles are. They might be flipping to negative numbers.

    If so, just account for that.

    And you will probably need to split the right direction anyway because it wraps around at 0 back to 359...

    So:

    If angle > 0 and < 45 => game.right = true
    If angle > 315 and < 359 => game.right = true

    You might need to do a similar thing at 180...
  • design219design219 Member Posts: 2,273
    image

    That's it! Thanks guys!

    The readout was a great idea, I should have thought about that. A great tool for tracking down such things.

    As you can see, it is negative. This will make left and right a multi condition rule, but at least I've got it now.
Sign In or Register to comment.