Shooter Problem

betazerobetazero Member Posts: 39
edited November -1 in Working with GS (Mac)
I have an actor which has a turret on top that rotates to the mouse position. It works fine except for when I tap the perfect 0 on the screen relative to the actor. It wants to spin 360 degrees to get to that point. Its not the worst thing in the world but it annoys me. Any way to work around this? am I doing something wrong?

Comments

  • synthesissynthesis Member Posts: 1,693
    add a rule...
    if angle = 0 ... don't spin ... otherwise ... spin to location/angle

    The above is a principle of logic...not an actual implementation.
    Set up a rule that achieves the above principle
  • rebumprebump Member Posts: 1,058
    I've seen some inconsistency with angles over the various versions of GameSalad and within the various behaviors that use them. Seen angles, upon a rotation, grow beyond 359. Seen angles greater than 359 being converted to their modulus 360 form. Seen negative angles converted to their positive equivalents. I don't recall which was which but it is best to play around a little.

    You may want to take the expression you are using for the turret to "track" the mouse and simply add parenthesis around it and then modulus that by 360. It maybe interpreting zero as 360 and thus the unnecessary spin. The modulus would make sure it is zero if the value was 360. But given the beta nature of GS, it may very well be interpreting 0 (while at 0) as go ahead and spin anyway. ;-)
  • synthesissynthesis Member Posts: 1,693
    an alternative is
    on touch - get the new touch position angle relative to turret center (which might require some trig calcs...that ARCSIN, ARCCOS, ARCTAN stuff)

    RULES:
    when newTouchAimingAngle is < currentGunAngle
    AND
    currentGunAngle is < 180
    .......spin clockwise
    otherwise
    .......when newTouchAimingAngle is < currentGunAngle + 180
    ..............spin clockwise
    .......otherwise
    ..............spin counter clockwise

    Then set up rules to rotate clockwise or counterclockwise within that structure
Sign In or Register to comment.