- Home /
Player Colision help
I am having a problem with the 1st program I have made(I am a noob) I have a player ( the prebuilt 1st person one and a turret that shoots at me. The problem is thbullets only do damage when I am moving not when I am standing still. var fireBallPrefab:Transform; var other; private var dead = false;
function OnControllerColliderHit(hit: ControllerColliderHit)
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
helth.LIVES -=1;
print (hit);
}
if(hit.gameObject.tag == "enermybullet")
{
dead = true;
helth.LIVES -=1;
}
}
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
var fireBall=Instantiate(fireBallPrefab, GameObject.Find ("spawnPoint").transform.position, Quaternion.identity);
fireBall.rigidbody.AddForce(transform.forward * 2000);
}
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3 (3.385581,1.54974,0);
dead = false;
}
}
This script is attached to the player
#pragma strict
var lifetime = 1.0;
function Awake () {
Destroy (gameObject, lifetime);
}
This one is attached to the projectile
The bit that control death are contain in the if statement with the tag enermybullet I think I have to use "function OnTriggerEnter (other : Collider) {" but being a noob don't know how to fares it so some help would be good. (ps could you repost the working script & instructions AND ex plane why it isn't working.
Thanks
JAmes
Your answer
![](https://koobas.hobune.stream/wayback/20220613065615im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collision Matrix not working properly 0 Answers
Could some one help me with this script... 5 Answers
OnTriggerEnter Issue? 1 Answer
i need help with the on collision script of rigidbody. 2 Answers
Points system for unity 1 Answer