The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Underwater Player Physics
AKZEL Offline
Junior Member

Posts: 3
Threads: 3
Joined: Jan 2013
Reputation: 0
#1
Lightbulb  Underwater Player Physics

Hey everyone, long time lurker - finally registered.
Before making my first custom story, I want to find out what's possible and what is not.

I'm gonna jump straight to business here.

Currently I'm trying to create a small underwater section, and I want the player to be "weightless", or at least experience less "gravity" when submerged. For this I have tried using AddPlayerBodyForce combined with a for-loop and a simple scriptbox. Whenever the player is inside the scriptbox called "UnderWaterArea", I want the player to be constantly but gently pushed upwards (Y+) by AddPlayerBodyForce. The "UnderWaterArea" is just a scriptbox that covers the whole "Liquidarea".

This is my script:
void OnStart()
{
AddEntityCollideCallback("Player", "UnderWaterArea", "UnderWaterScript", false, 1);
}

void UnderWaterScript(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
SetLocalVarInt("underwater", 1);
}
if(GetLocalVarInt("underwater") == 1)
{
for(int g=1;g<999;g++) AddTimer("grav"+g, 0.01, "Grav");
}
}
void Grav(string &in asTimer)
{
AddPlayerBodyForce(0, 58, 0, false); //I have tried tweaking this, any lower and the player falls straight down to the bottom.
}

And this is how said script not works:
https://vimeo.com/56848115

Questions:
1. Is this effect even possible to achieve, or should I just leave it? I have searched the interwebs for this specific effect but haven't found anything...
2. How come the game freezes slightly every time the player collides with the UnderWaterArea?
3. How come the player eventually falls down to the bottom, even though he's still in the UnderWaterArea, thus should be affected by AddPlayerForce?

Hope I haven't made a total fool out of myself, first impression and so on... Wink
Cheers!
(This post was last modified: 01-06-2013, 12:53 PM by AKZEL.)
01-06-2013, 12:50 PM
Website Find


Messages In This Thread
Underwater Player Physics - by AKZEL - 01-06-2013, 12:50 PM
RE: Underwater Player Physics - by Adrianis - 01-07-2013, 04:33 PM
RE: Underwater Player Physics - by Rapture - 01-07-2013, 05:45 PM



Users browsing this thread: 1 Guest(s)