Hello all,
basically I’m working on a fighting game, and I’m using a raycast from the player position forward at given punch distance to test for a hit. I’m using controller.SimpleMove for movement. Everything seems to work right if I’m standing still, but if I’m walking toward the other character, punches will land from far, far away (and even then the hit.distance is extremely low). Here’s the relevant code:
function ApplyPunch(punchType : punch)
{
var hit : RaycastHit;
var fwd = transform.TransformDirection (Vector3.forward);
var pos = transform.position;
var distance = punchType.distance;
if (Physics.Raycast (pos, fwd, hit, distance)) {
etc....
If I’m standing right in front of the other guy, hit.distance is about .5, but if I’m moving toward him, even from all the way across the scene, it’s about .02. So I guess the question is, how can I get my raycast to ignore the momentum of my character? None of the variables being passed in (as shown above) change when I’m moving, so I just can’t figure out why this is happening. Thanks in advance to anyone with suggestions…