PDA

View Full Version : moving entities with vectors


fretn
8th July 2002, 00:36
I'm making an airplane for the airstrikes, I added two entities for radiant (startposition, and stopposition), the airplane has to fly between these two spots in a 'parabole flight'...but I can't let the plane fly from point a to point b ... so I better forget the parabole flight.

I'm setting a dir vector to the stop-spot and then I move the plane with vectorMA to that stop spot by using the speed, and the dir vector. But It won't work :sad:

the Airstrike_Gen is called by a cmd.

=============

void Airstrike_Gen( gentity_t *ent ) {
gentity_t *plane;
//vec3_t start, dir;

plane = G_Spawn();
plane->classname = "airstrikeplane";
plane->nextthink = level.time + 10;
plane->think = Airstrike_Think;
plane->r.ownerNum = ent->s.number;
plane->parent = ent;
plane->s.eType = ET_AIRSTRIKE;

}

void Airstrike_Think( gentity_t *self ) {

/*
===
some code cut

stopSpot represents the 'stopposition-entity' that is placed in the map by radiant.

*/

VectorSet( dir, stopSpot->r.currentOrigin[0], stopSpot->r.currentOrigin[1], stopSpot->r.currentOrigin[2] );

speed = 50;


VectorMA(self->r.currentOrigin, speed, dir, self->r.currentOrigin);

trap_LinkEntity(self);

//Prepare for next move
self->nextthink = level.time + 10;


}

============

fretn 'damn vectors :sad:'

fretn
10th July 2002, 15:53
ok, the problem was:

plane->r.svFlags = SVF_USE_CURRENT_ORIGIN | SVF_BROADCAST;
plane->s.pos.trType = TR_LINEAR;
plane->s.pos.trTime = level.time - 50;

after adding these my plane wants to move :smile:


<font size=-1>[ This Message was edited by: fretn on 2002-07-10 16:54 ]</font>

digibob
10th July 2002, 16:16
You may, or may not want to remove that - 50, what it does is project the object forward 50ms into it's trajectory, this is done for the panzerfaust, buy may not look so good on a plane.

fretn
10th July 2002, 19:45
is it possible to make it turn when it's flying ? Cause now it's flying straight forward, but it should: appear under the skybox and dive and after a little dive (and bomb dropping), it should go up again and disappear above the skybox

or will this be very hard to code ?

fretn

digibob
10th July 2002, 20:24
Create a new parabolic trajectory type :smile: and no, it's not too hard really :eek:

fretn
10th July 2002, 21:58
hmmm...I'll take a look :smile:

Be sure I'll come back :razz:

[edit 1]::

found a tutorial on adding trajectories...http://www.planetquake.com/code3arena/tutorials/tutorial38.shtml

is there somewhere a tutorial with good explanation on working with vectors ... I understand the basics but not everything like setting a direction vector to move to a certain point in a map ... ?

[edit 2]::

ok I inverted the TR_GRAVITY and it seems it's doing what I want :smile:

what's left:
1- stop spinning around own axis (easy, but haven't found yet :grin: )
2- dropping bombs (easy)
3- let the plane fly in right direction (based on the points added in gtkradiant), if I leave it like now...it would like stupid, isn't it ?

anyway thanks for the (help & advice) !

fretn

_________________
No man's land
http://www.planetwolfenstein.com/nml

<font size=-1>[ This Message was edited by: fretn on 2002-07-10 23:12 ]</font>

<font size=-1>[ This Message was edited by: fretn on 2002-07-11 00:01 ]</font>