Changing gravity at runtime ?

YannBouschetYannBouschet Member Posts: 10
edited November -1 in Working with GS (Mac)
Hi,

Is there a way to increase the gravity of a scene while a game is running ?

I can't see any attribute in the expression editor :-/

Thanks

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Yes and No. I don't think you can change scene gravity during the game. But I personally think that using scene gravity causes more issues than it's worth. I would just put a downward (270) acceleration in any actors that you want to have fall. This can easily be changed during the scene. So create a game attribute called gravity. Put this attribute in the 270 acceleration behavior and have a rule that changes game.gravity when ever you need it to (or use a timer if it is regularly occuring change).
  • YannBouschetYannBouschet Member Posts: 10
    Well, I found a way, but ain't a straight line...

    First I was wrong : there is an attribute for gravity in the expression editor.

    BUT it's only for the current scene. You can change it from a custom behavior of an object set on the scene (and not from its prototype).

    So I create an empty actor and dump it in the corner of the scene (Careful : this one shouldn't be moveable.) Then I override its prototype to create some custom rules. In this script I put a timer to check a boolean game attribute every second. If this attribute goes true the rule change the gravity and bring the attribute back to false.

    Everywhere else in the game the actors will only have to switch the game attribute to true when gravity change is needed.

    There's a little lag for sure, but in my case it doesn't matter.
    And that's it for now.

    Thanks !
  • rebumprebump Member Posts: 1,058
    So you cannot alter the scene level gravity attribute in a behavior when editing an actor prototype but you can edit it in an instance (i.e. manually placed actor in a scene) of an actor?

    Strange. Of course, the change wouldn't occur unless there is an instance of the actor in the scene but you should be able to edit the prototype's behavior and then either manually place the actor or have it spawn at some point (the two usual ways to instantiate an actor).
Sign In or Register to comment.