Changing gravity at runtime ?
YannBouschet
Member Posts: 10
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
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
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 !
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).