Hi I make a basic space shooter game.
The space ship has a shield, when a specific button clicked
when I link shield to parent, then collison does not work ?
// HERE COLLISION WORKS
// BUT SHIELD DOES NOT MOVE WITH PARENT
if(Input.GetKeyDown(shieldKeyInput)){
if(!shieldOn){
Instantiate(shield, transform.position, transform.rotation);
shieldOn = true;
}
// THIS MAKES SHIELD MOVE WITH SPACE SHIP
// BUT THE COLLISION NOT WORKING
if(Input.GetKeyDown(shieldKeyInput)){
if(!shieldOn){
var clone = Instantiate(shield, transform.position, transform.rotation);
clone .transform.parent = gameObject.transform;
shieldOn = true;
}
}
// COLLISON SCRIPT OF SHIELD
function OnTriggerEnter (other:Collider) {
if(other.gameObject.tag == "astroid"){
shieldStrength--;
print(shieldStrength);
print("HIT");
}
}