Jump to content

Home

Arrow trajectory


XycaleTh

Recommended Posts

Hi, I've modded the game so I can fire an arrow from a long bow, but the problem I'm having is making the arrow point towards the direction its traveling in. If you fire the arrow as it is now at, say, a 45 degree angle, it will remain at 45 degrees until it hits an object and then sticks into it at the angle the arrow was traveling at as the arrow hit it.

 

So any ideas?

Link to comment
Share on other sites

Found a possible solution, which I've based off the direction changing for the homing missile.

 

g_missile (G_RunMissile):

	if ( tr.startsolid || tr.allsolid ) {
	// make sure the tr.entityNum is set to the entity we're stuck in
	trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );
	tr.fraction = 0;
}
else {
	VectorCopy( tr.endpos, ent->r.currentOrigin );
}

Now looks like:

	if ( tr.startsolid || tr.allsolid ) {
	// make sure the tr.entityNum is set to the entity we're stuck in
	trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );
	tr.fraction = 0;
}
else {
	VectorCopy( tr.endpos, ent->r.currentOrigin );

	// [NDA] - Rotate arrow to simulate heavier arrow head
	if ( ent->s.weapon == WP_BOW && ent->s.pos.trType == TR_GRAVITY && !(ent->flags & FL_BOUNCE_SHRAPNEL) )
	{
		// We're still in the air
		VectorCopy (ent->r.currentOrigin, ent->s.pos.trBase);
		BG_EvaluateTrajectoryDelta (&ent->s.pos, level.time, ent->s.pos.trDelta);
		ent->s.pos.trTime = level.time;

		SnapVector (ent->s.pos.trDelta);
	}
	// [/NDA]
}

The arrow has FL_BOUNCE_SHRAPNEL added to its flags if it hit something at a very shallow angle so it doesn't stick.

 

I was hoping that it could be client-side predicted as well seeing as the arrow has a predetermined path. I'm happy with this solution but I'm sure there's a better one somewhere :p

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...