Stop actor falling over

thelogobarthelogobar Member Posts: 93
edited March 2012 in Working with GS (Mac)
Been searching for an answer, but it's tricky finding things on the forum.

I'm fiddling with a game idea and wanted someone on a skateboard or similar, just skating and using ramps at the moment. So far so good, but the actor keeps falling onto its side. I want the actor to be able to rotate on ramps and in the air, but not so far that it falls over completely.

Can I constrain the rotation angle? Or make the actor right itself when on its side?

Best Answers

  • lukey5227lukey5227 Posts: 111
    Accepted Answer
    You can use the "Constrain Attribute". Constrain the Skateboard.Angle to 90 degrees.

    You can also say:

    If
    { Skateboard. Angle > 10 degrees }

    Do {
    After 3 seconds {
    Change Attribute "Skateboard.Position.Y" to "Skateboard.Position.Y+25"
    -- Move up so it can correctly adjust angle --
    Change Attribute "Skateboard.Angle" to "0"

    -- You can also add this: --
    Change Attribute "Game.Lives" to "Game.Lives-1"
  • MotherHooseMotherHoose Posts: 2,456
    edited March 2012 Accepted Answer
    what @lukey5227 said:
    in GS language …
    Rule: when
    Attribute: self.Rotation > 10
    --Timer behavior
    [After: 3 seconds
    --changeAttribute: self.Position.Y To: self.Position.Y+25
    --changeAttribute: self.Rotation To: 0 ]
    ===

    suggestion:

    gameAttribute …angle type … name: rampAngle

    on your rampActor (prototype)
    add an attribute: angle type … name: myAngle
    Rule: when
    Event: overlaps/collides with Player
    --changeAttribute: game.rampAngle To: self.myAngle

    on instance of rampActor in scene
    set myAngle to 10 or -10 … 10 for leanLeft … -10 for leanRight

    on your playerActor
    Rule: when
    Event: overlaps/collides with ramp
    --Timer behavior
    [Ater: 0.1 seconds … this gives time for the value to be changed by ramp
    --changeAttribute: self.Rotation To: game.rampAngle ]
    Otherwise:
    --changeAttribute: self.Rotation To: 0

    @};- MH

Answers

  • thelogobarthelogobar Member Posts: 93
    edited March 2012
    Aha, so I have done this...

    If self motion linear velocity X = 0
    Interpolate attribute to 0
    Duration 1 sec ease in.

    This way if it stops upside down, then it self rights. Does the job.
  • thelogobarthelogobar Member Posts: 93
    That looks a touch over my head, but I'll give it a go.
    Constraining the angle to 90 degrees, won't that stop it rotating at all?
Sign In or Register to comment.