Frictional Games Forum (read-only)

Full Version: Is this possile?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all-

I know you are all incredibly smart with this engine. After all, you practically made guns! xD So is the following scare, possible?

A player hits an area, which causes an object to raise (preferably slowly) and hover there for a specific amount of time, then be launched away. Is it possible, and HOW?!
I would have the model on a MoveObject and set the axis to Y to be scripted to move up, stop, then have it deactivate and activate the same model, new .ent set to be a normal Object (Grab), with AddPropForce/AddPropImpulse.
Check out this thread... http://www.frictionalgames.com/forum/thread-14448.html

It may be simpler for what you want than what Statyk has suggested. You just need to get the values right for the amount of upward force, then after a set amount of time, stop applying a constant upward force and apply a very large amount of force in whatever direction you want. Hope that helps
Just for fun I thought I'd try to do this, I made this little script Smile
Code:
void OnStart{

AddEntityCollideCallback("Player" , "FlyArea" , "FlyNow" , false , 1);

}

void FlyNow(string &in asParent, string &in asChild, int alState) // Player hits area
{
    SuperFlyScript("vase_1"); // Function to start flying
}
void SuperFlyScript(string &in asEntity){
    AddTimer(asEntity, 0.05f, "FloatUp");
    AddTimer(asEntity, 1.5f, "PushHard");
}
void FloatUp(string &in asEntity){ // Entity floats for 1.5s
    if(GetTimerTimeLeft(asEntity)!=0.0f){
        AddDebugMessage("FloatModeActivated!", true);
        AddPropImpulse(asEntity , 0.0f , 0.5f , 0.0f , "world");
        AddTimer(asEntity, 0.05f, "FloatUp");
    }
}
void PushHard(string &in asEntity){ // Entity is pushed away!
    AddDebugMessage("PushModeActivated!", true);
    AddPropForce(asEntity , 3000.0f , 1000.0f , 0.0f , "local");
    RemoveTimer(asEntity);
}

You can even use different entities! SuperFlyScript(asEntity);
(Heavy objects probably wont be affected, because only a small force is applied)
AddPropForce is all you need....and a lot of patience.

Make a looping function that runs every 0.0166f seconds. Every time the function runs, increase a local variable by a miniscule amount, and translate that variable into vertical force applied to the object. At a certain point, stop increasing the variable, and pause. After a certain amount of time, add a force to throw the object away and stop the timer which keeps it afloat.

Good luck, and make sure you bring a soda or something while you test it out....slight miscalculations can cause your object to fly through a wall. Haha.
You could also use a sticky area for the initial floating, then detatch the floating prop and apply a large impulse or force.
Haha Apjjm's idea is actually quite clever. I can't remember off the top of my head what the function is, but there should be a variable to change the speed the object attaches in the properties of the sticky area.
Apjjm, if he did that it wouldn't be so dynamic.