Hey, so I wanted to create a room that has low gravity, I used this for it:
Player_SetGravity(-0.45f);
Now I don't know if that's the best code to use if I want to get low gravity, but it works (kind of) except for one little issue where the character is slowly moving to some direction, but it's not the main problem.
The main problem is that I can't set the gravity back to normal. I've tried so many things, i.e Player_SetGravity(1.0f); or Player_SetGravity(-1.0f); or even Player_ChangeStateToNormal();
void UnderWater(string &in asParent, string &in asChild, int alState) ////this function was executed when entering an area, making the player float in low gravity { SetLanternActive(false, true); SetLanternDisabled(true); SetPlayerLookSpeedMul(0.85f); SetPlayerRunSpeedMul(0.8f); SetPlayerMoveSpeedMul(0.7f); AddTimer("slow", 0.01f, "SlowJump"); }
void SlowJump(string &in asTimer) { if(asTimer == "slow") { AddTimer("slow", 0.01f, "SlowJump"); ////this is the proper part that gives low gravity - it has to be a timer on a loop if(GetPlayerYSpeed() > 0.01f) { AddPlayerBodyForce(0, 600, 0, false); } } if(asTimer == "normal") { RemoveTimer("slow"); }
}
void NoWater(string &in asParent, string &in asChild, int alState) /////andd this was executed when leaving the area, which resulted in normal gravity { SetLanternDisabled(false); SetPlayerLookSpeedMul(1.0f); SetPlayerRunSpeedMul(1.0f); SetPlayerMoveSpeedMul(1.0f); AddTimer("normal", 0.01f, "SlowJump"); }
void UnderWater(string &in asParent, string &in asChild, int alState) ////this function was executed when entering an area, making the player float in low gravity { SetLanternActive(false, true); SetLanternDisabled(true); SetPlayerLookSpeedMul(0.85f); SetPlayerRunSpeedMul(0.8f); SetPlayerMoveSpeedMul(0.7f); AddTimer("slow", 0.01f, "SlowJump"); }
void SlowJump(string &in asTimer) { if(asTimer == "slow") { AddTimer("slow", 0.01f, "SlowJump"); ////this is the proper part that gives low gravity - it has to be a timer on a loop if(GetPlayerYSpeed() > 0.01f) { AddPlayerBodyForce(0, 600, 0, false); } } if(asTimer == "normal") { RemoveTimer("slow"); }
}
void NoWater(string &in asParent, string &in asChild, int alState) /////andd this was executed when leaving the area, which resulted in normal gravity { SetLanternDisabled(false); SetPlayerLookSpeedMul(1.0f); SetPlayerRunSpeedMul(1.0f); SetPlayerMoveSpeedMul(1.0f); AddTimer("normal", 0.01f, "SlowJump"); }
(08-03-2016, 03:05 PM)Venom Fox Wrote: Hey, so I wanted to create a room that has low gravity, I used this for it:
Player_SetGravity(-0.45f);
Now I don't know if that's the best code to use if I want to get low gravity, but it works (kind of) except for one little issue where the character is slowly moving to some direction, but it's not the main problem.
The main problem is that I can't set the gravity back to normal. I've tried so many things, i.e Player_SetGravity(1.0f); or Player_SetGravity(-1.0f); or even Player_ChangeStateToNormal();
None of them works, any ideas...? :S
Have you got any other events occurring when Gravity resets so you can confirm the script is actually working? If you can make use of Debug Messages, I really recommend it.
(08-03-2016, 03:53 PM)Darkfire Wrote: So if anything else fails, try my script. It works and looks quite good.
And while it does work, we're working with SOMA here, not Amnesia
Discord: Romulator#0001
(This post was last modified: 08-03-2016, 05:00 PM by Romulator.)
(08-03-2016, 03:05 PM)Venom Fox Wrote: Hey, so I wanted to create a room that has low gravity, I used this for it:
Player_SetGravity(-0.45f);
Now I don't know if that's the best code to use if I want to get low gravity, but it works (kind of) except for one little issue where the character is slowly moving to some direction, but it's not the main problem.
The main problem is that I can't set the gravity back to normal. I've tried so many things, i.e Player_SetGravity(1.0f); or Player_SetGravity(-1.0f); or even Player_ChangeStateToNormal();
None of them works, any ideas...? :S
Have you got any other events occurring when Gravity resets so you can confirm the script is actually working? If you can make use of Debug Messages, I really recommend it.
(08-03-2016, 03:53 PM)Darkfire Wrote: So if anything else fails, try my script. It works and looks quite good.
And while it does work, we're working with SOMA here, not Amnesia
Yeah, the script is working. I went through most of SOMA's hps files in codelite searching if they included any information, but found nothing. I doubt that there's a code that would automatically default the gravity, too bad.
So that means the argument you give it is a 3d vector, not just a single float value. (So you could have sideways gravity, if that was what you wanted.)
Secondly, this is the actual acceleration due to gravity in metres per second per second, not just a 0-1 multiplier. Normal acceleration due to gravity is about 9.8ms^2 on Earth.
So that means the argument you give it is a 3d vector, not just a single float value. (So you could have sideways gravity, if that was what you wanted.)
Secondly, this is the actual acceleration due to gravity in metres per second per second, not just a 0-1 multiplier. Normal acceleration due to gravity is about 9.8ms^2 on Earth.