- Home /
Cloned Bullets not triggering door
so, I have a gun script that fires a clone of a bullet. Very early in the test level, there is a door utilizing my "shootDoorScript" which is designed to rotate the door when an object with the "Attack" tag (already on the bullet) enters the trigger (in the path between the player and the door.
I'd like to note that I know the shoot door script works because I originally had a giant "Attack" bubble attached to the player's head.
we can't help you without the code. post your door script. also, what do you mean by "clone" - a prefab instance?
yes. The "Clones" are instances of the "Plasma Bullet" Object. it's a simple sphere with a light. code to follow.
var smooth = 2.0;
var open : boolean;
private var enter : boolean;
private var defaultRot : Vector3;
var openRot : Vector3;
function Start(){
defaultRot = transform.eulerAngles;
}
//$$anonymous$$ain function
function Update (){
if(open){
//Open door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth);
}
else{
//Close door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth);
}
}
//Activate the $$anonymous$$ain function when player is near the door
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Attack") {
open = true;
}
}
side note, this code does work, I set one of my doors to open by default and it swings open at the start of the level.
edit your comment and use "code" marker for the code. Also post your Bullet prefab inspector view
all you can't see in this picture is the name (plasma bullet) the static button (unchecked) and the material (standard, transparent).
Sure you have "trigger" tick enabled on the door collider?
yes. I had it working before by attaching an "attack" to the player's head. for some reason it stopped working.
Your answer
Follow this Question
Related Questions
shoot projectile from weapon 2 Answers
How can I rotate a rigid body based on its velocity? 3 Answers
How to instantiate a projectile only from the weapon prefab of the firing player? 1 Answer
Could you advice me why this Gun and Ballistic Script doesn't work? 1 Answer
how to only be able to shoot if an object is active 2 Answers