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
Making an entity fly
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: Making an entity fly

(05-26-2011, 08:22 PM)xtron Wrote: The thing is that I'm gonna do so when you enter a door and you walk in you're gonna get pushed out of the room and the door with lock.

So you want to push the player out a room? Here's a guide:

Note: We are assuming for this that the player is coming through the door to the room, and not arbitrarily placed inside the room. This case is much simpler than the latter, and probably the case you are after.


First the arguments of "AddPlayerBodyForce":
"afX" is the X-component of the force, afY the Y-component etc. You want to be using false as "abUseLocalCoords", unless you can guarantee the direction the player is facing (By using a look-at script).

To work out what components you want you need to take a look in the level editor at your door. Make a box, and imagine it is the player for now; Place it by your door and move it to where you want the player to go, roughly speaking. Take note of the position fields in the object properties before and after you do this - and now do a little bit of maths to calculate the change in position (Final location - starting location : Signs are important here!).
You now have the direction to push the player in, in components. These are the afX, afY and afZ values pretty much. But we ain't there yet - the function wants a force - we just have a change in position!

As you are applying a brief impulse, we can skip complex maths shenanigans, and get straight to the trial and error part:
float mult = 1500.0f;
AddPlayerBodyForce(mult * afX, mult * afY, mult * afZ, false);

What we are trying to do here, is approximate the mass of the player, and slightly adjust the force you have already got. To do this effectively you want a single point of control called "mult" so you can tweak all your values to get the right force without having to re-calculate the arguments to the force function over, and over, and over.
Remember, The player is pretty heavy, but you now just have to experiment to see what value of "mult" gets the effect you are after.
(This post was last modified: 05-26-2011, 11:08 PM by Apjjm.)
05-26-2011, 11:07 PM
Find


Messages In This Thread
Making an entity fly - by xtron - 05-26-2011, 08:11 PM
RE: Making an entity fly - by Apjjm - 05-26-2011, 08:18 PM
RE: Making an entity fly - by xtron - 05-26-2011, 08:22 PM
RE: Making an entity fly - by Apjjm - 05-26-2011, 11:07 PM
RE: Making an entity fly - by xtron - 05-27-2011, 02:27 PM
RE: Making an entity fly - by Apjjm - 05-27-2011, 03:28 PM
RE: Making an entity fly - by xtron - 05-27-2011, 11:04 PM



Users browsing this thread: 1 Guest(s)