- Home /
enemy targetting not working
hey guys I'm trying to write a targetting script for a small FPS prototype I'm making. I've got 2 problems: 1) once I target & shoot an enemy other than the 1 assigned by default it doesn't receive any damage:
function SelectedTarget(){
selectedTarget.renderer.material.color = Color.red;
var pa : Attacking = GetComponent("Attacking");
pa.target = selectedTarget.gameObject;
var pb : PlayerBullets = GetComponent("PlayerBullets");
pb.enemy = selectedTarget.gameObject;
}
the var pa works just fine (melee attack) on all enemies once they are targeted
2) my "bullets" (sphere rigidbodies...) follow very weird directions sometime (spinning around, going up, waving left/right...)instead of forward
Any suggestions?
In order to solve these issues, the list would likely need to see your code for both how you apply damage, and any code that moves the projectile.
I'm not sure there's enough information in the code you've given. That function seems pretty straight-forward. Have you considered that selectedTarget might be the object that isn't being set right?
@robertu i don't think that's the prob since I used the same method for both shooting & melee, & melee worked:
var pa : Attacking = GetComponent("Attacking");
pa.target = selectedTarget.gameObject;
var pb : PlayerBullets = GetComponent("PlayerBullets");
pb.enemy = selectedTarget.gameObject;
@jbarba_ballytech since melee worked and I used the same method for shooting I don't think it's it. But thanks for trying to help I'll have a look @ my code/inspector again see if I'm missing something
what is your shooting $$anonymous$$ range to apply damage
maybe you're doing if he's in your collider don't know your combat design just guessing
Your answer