You could fire another trace from the opposite direction. Use the collision mins/max to calculate how far away to begin.
MindBlaster wrote: > Hi everybody! > > I have a question about traceline, i've managed to get bullets "penetrating" > surfaces (walls, ceiling, floor). It works like a charm, the bullet comes > out on the other side as intended. But the problem is when I try shooting at > chairs, barrels, crates. The traceline just wont do the trick. > > What im doing with surfaces that I make the traceline start solid and tell > him to look forward 16 units. Then I check if the traceline has a valid > value n the variable fractionleftsolid. It gives me the perfect exit on the > otherside. > > But for props, he just won't do the same. Is there a another way to find out > where the bullet would exit in entities? I could use a for-loop to find out > when the bullet really leaves the entity. But I'm trying to avoid loops, > since they might get cpu intense (or just become a time-stealing-loop). > > Some code to relax your eyes on: > > // tr is from FireBullet in CBaseEntity (baseentity_shared.cpp) > // Force the traceline into the surface. > Vector vecNewPos = tr.endpos + vecDir * 0.5; > > // Perform the traceline. MAX_PENETRATION is 16.0f currently. > UTIL_TraceLine( vecNewPos, tr.endpos + vecDir * MAX_PENETRATION , MASK_SHOT, > pTraceFilter, &penetrationTrace ); > > // Check if the traceline was a success. Fractionleftsolid is always false > on props, but it does start solid. > // MAT_TOUGHNESS is my custom material toughness variable. If it's 0, then > it's a unhandled surface. > if ((penetrationTrace.fractionleftsolid == 0 && tr.DidHitWorld()) || > penetrationTrace.fractionleftsolid >= 1.0 || tr.fraction == 0.0f || > MAT_TOUGHNESS == 0.0f) > return; > > // Some refire bullet code. > ... > ... > ... > > Im open for any idea that you might have :) > Oh, the mod is based on HL2MP (OB SDK?) > > // Tommi 'MindBlaster' Bordi > > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, please > visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

