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
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#2
RE: Underwater Player Physics

You can make it so that the player descends more slowly and can jump higher by applying a +Y force to the player body as you have done, though that value is so low I'm surprised you notice any difference, I was messing around with a similar effect the other day using about 1000 or more for the Y value.

It's likely freezing slightly because the script is not exiting the FOR loop untill all 999 cycles have finished, then running all those timers in a very short space of time. The player will eventually fall all the way down because there isnt enough force to keep her 'afloat', and also because you're only making the grav function loop 999 times within an extremely small space of time

Try it more like this...

void OnStart()
{
AddEntityCollideCallback("Player", "UnderWaterArea", "UnderWaterScript", false, 1);
}

void UnderWaterScript(string &in asParent, string &in asChild, int alState)
{
// any other effects you may want, splashing sound perhaps?
Grav("");
}

void Grav(string &in asTimer)
{
AddTimer("GravTimer", 0.01, "Grav");
AddPlayerBodyForce(0, 1000, 0, false); // tweek to get the right value
}

This way, the Grav function will keep looping every 0.01 secs, since every time it runs it adds a new timer to activate itself. If you want to stop the effect, you'll need to use another area callback or similar using the RemoveTimer("GravTimer"), which should cut off the loop

Hope that helps. This script is entirely untested as I am at work, I accept no liability for grievous damage and/or explosive decompression caused or incurred whilst using the above script

EDIT: Just watched the video (I know, replying without watching how rude), I think the reason its pausing and the reason why such a low force value is throwing the player up is the same, your for loop is making 999 timers all fire at the same time, which means the total amount of force being applied is absolutely huge, you might find 0.01s to be too quick for a loop speed in my script (the force may apply exponentially)
(This post was last modified: 01-07-2013, 04:38 PM by Adrianis.)
01-07-2013, 04:33 PM
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)