Hi, I have this simple problem, I have an object and a group of objects (prefab) named coin. All I have to do is addforce to the coins when they enter the main object.
The collision/trigger thingy works, when I change the
“coin.rigidbody.AddRelativeForce (0, power, 0);” line, it works so the problem is with that line.
var coin : GameObject;
static var speed : int;
var power;
function Start () {
InvokeRepeating("checking", 0, 0.3);
}
function OnTriggerEnter ( collision : Collider){
coin.rigidbody.AddRelativeForce (0, power, 0);
}
function checking (){
power = speed/3;
}
(the var power is set in other script
are the coins who enter the trigger? then you could use function OnTriggerEnter ( collision : Collider){ collision .rigidbody.AddRelativeForce (0, power, 0); } And are you sure you are giving a value to power before you use it? Do you see errors in the console?
– moghesare you instantiating objects, because if you are it will name it Coin(clone) and not coin so you will have to make a script to rename it on start.
– Chris12345