Entity Moving Help
Could someone plz explain to me how exactly you could make a entity move at a constant speed from one location to another? I know how to spawn the entity, and all that, but how do you make it fly to that destination?
|
Give it a velocity :)
It's a vector, look in engine_const |
hmm, never thought it would be that simple. All that is needed is a set velocity in a direction and it will continue to fly in that direction?
|
Until its friction settng stops it, or gravity, I assume.
|
How could i get a velocity to set the entity with if the angles are from another entity? Like, does anyone know what format the velocity should be in, i know it is Float:velocity[3] but what do the 3 values need to look like? Does the velocity have anything to do with which way the entity goes or is that angle entirely?
|
As the angles vector represents a certain rotation on a certain axis (X, Y, or Z), the velocity vector represents speeds in a certain direction (X, Y, Z).
|
so i could just set the velocity[0] to something in order for it to go in a straight horizontal line?
|
I see what you mean now, thank you everyone for your help. I still can't figure out how to calculate a velocity that goes from 1 origin to another. Any great math people know a formula to do this?
|
Quote:
soooo velocity.x=(origin_finish.x-origin_start.x)*speed velocity.y=(origin_finish.y-origin_start.y)*speed velocity.z=(origin_finish.z-origin_start.z)*speed Where speed is any number you feel like (higher number == faster speed) Quote:
|
Ummm... Normalized vectors are vector with length = 1 ... So, to normalize a vector, you have to divide each compenent by the length of the vector.
If you want something to move from origin A to origin B, and want it to be done after y seconds, do what BlueRaja proposed. If you want it to go at a constant speed, no matter how far A and B are from each other, first normalize the vector ( the vector I refer to is the result of the subtraction ), and then multiply it by the speed. You can find some vector functions in my "XS Library"; amxmodx/scripting/include/xs.inc |
| All times are GMT -4. The time now is 19:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.