Saturday, November 23, 2013

[TUT] Flight ideas for peds

I know basically three tips that can be utilised in GTA IV to simulate an ped flying.

  • A single: Manage ped velocity home
  • Two: Control ped existing car speed
  • Three: Handle an object velocity, and attach the ped to this object

To handle the path of the flight we can use game camera path or produce and vector3 to handle the path utilizing keys like we can do with an plane or helicopter.

Download the code of this tutorial right here

Very first ped flight thought (Fundamental a single)

Technique 1 is very simple but has some limitations, all we need to do is control the ped velocity, if we set the ped velocity is x=, y= and z=1 we will make it float simply because he will be frozen in X and Y and will be with 1 in Z, and thinking about the frequent 3D vector components X and Y indicates horizontal measure and Z vertical:


The limitations of this thought, that i noticed, are:

  • Speed, we can't attain much more than 80 (mph i guess)
  • Can not handle Pitch and Roll, we can not change the pitch or roll of the ped so we will usually have the animation pitch or a tough to manage pitch in outcome of ragdoll state, we only can set the heading

Controlling the flight

To create an controllable flight we can:

  • Adjust straight his velocity to the vector velocity that we want, for example, we can make him move in the camera direction setting the ped velocity to be equal the camera direction, also we can use an incremental multiplier to figure out the speed multiplying the camera direction by the multiplier.


As we can see we have some side effects, for instance, ped can turn into Ragdoll state and then we are vulnerable to collisions and we can accidentally trigger that automated ground camera that is used to appear at ped when he is falling.

  • Or we can set ped velocity to often zero ( - x, y and z = ) and use ApplyForce to push the ped to exactly where we want, controlling his flight:


It's a lot more straightforward use the second concept.

Second ped flight thought (using invisible car)

This ped flight idea i saw for initial time in Superman script created by nixolas1, i used very same notion in my Basic Automobile Fly cheat with no excellent benefits due to the fact automobiles have some kind of turn mass velocity (or inertia) that impacts the rotation of the car when hit anything.

In resume the notion consists in warp or attach the ped to an invisible vehicle, then handle automobile velocity and direction. I use an small bike (Faggio) because bikes have an better result with this speed manage notion and the "collision region" is smaller :)

So we want an automobile:

We require to produce this new automobile and hide it:

And, when activating flight, we need to have to attach or warp the ped into this vehicle:

Ok, now we have our invisible bike:

Let's make it fly, in the tick we want to modify this bike path based on the flight path and handle his speed to make it float.

We can do this setting bike speed to zero and utilizing ApplyForce to push the bike in the flight path, but we will have the max speed of 80 once more. To attain higher speeds we want to use an native call:


Using this native get in touch with we often will move the bike in his direction with the speed determined by the native get in touch with:

Native.Function.Call("set_car_forward_speed", myFlyingVehicle, force)

A single side effect of this thought is that with speeds more than 200 we have some instability, occasionally speed just drops back to 80 :(

Result (Obs.: In this vid i'm already making use of the flight animations):

I am not positive why i cannot make it fly with speeds greater than 80 in this script sample, in Iron Man IV i use identical concept and can attain more than 80.

Third ped flight notion

An third flight technique is use an object and the native get in touch with SET_OBJECT_INITIAL_VELOCITY:

Also we need to attach the ped to this object and detach when finish the flight:

The flight animations

To make the impression of flight more true we can use some EFLC parachute animations like:
  • complete_brake_for_landing - To simulate an float state with low speed
  • free_fall_deccelerate - To simulate an medium flight speed
  • free_fall_fast - To simulate an flight at complete speed
To use this in GTA IV we require to export the parachute.wad from EFLC anims.img and import into GTA IV.

To make the ped play the animation we use this:

And to stop the animation:

I will speak much more about animations in a future tutorial :)
[TUT] Flight ideas for peds
9out of 10 based on 10 ratings. 9 user reviews.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.