XycaleTh Posted March 22, 2008 Share Posted March 22, 2008 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 More sharing options...
Tinny Posted March 22, 2008 Share Posted March 22, 2008 A little confused, is it traveling in the right angle and not sticking in the right angle? Link to comment Share on other sites More sharing options...
XycaleTh Posted March 23, 2008 Author Share Posted March 23, 2008 Maybe I didn't make myself very clear :s So here's a little diagram of what I'm trying to do ^_^ The first one is what's happening at the moment. The second one is what I want to happen Link to comment Share on other sites More sharing options...
ensiform Posted March 23, 2008 Share Posted March 23, 2008 Which TR type? You'll need to modify the missile angle as it travels somehow. Link to comment Share on other sites More sharing options...
XycaleTh Posted March 23, 2008 Author Share Posted March 23, 2008 Using TR_GRAVITY as the TR type for the arrow. I've had a look at ent->s.apos but haven't had much luck with it. Link to comment Share on other sites More sharing options...
XycaleTh Posted March 24, 2008 Author Share Posted March 24, 2008 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 Link to comment Share on other sites More sharing options...
Tinny Posted March 24, 2008 Share Posted March 24, 2008 So it works ok? You might want to look at the client side too to have it look smoother, the effect code as the projectile traveling is usually done in the client codes that start with fx_. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.