I’m trying to implement a boost pad into a space shooter, and I’m scratching my head on what I’m doing wrong here.
The elements are:
A ship
A boost pad
The ship is controllable on its own, but when it hits a target I want a temporary pickup in speed.
Using different examples from the forums, I came up with this and attached it to my Boost Pad (a GO with a box collider set to Trigger).
var boostPad : GameObject;
var ship : GameObject;
var target : Transform;
var boostSpeed = 1000;
//Sets up the Booster function
function Booster() {
if( ! target )
return;
var dir=(target.position - transform.position).normalized;
transform.position += dir * boostSpeed * Time.deltaTime;
}
//Calls the Booster function when triggered
function OnTriggerEnter(col : Collider) {
ship.Booster();
Destroy (boostPad.gameObject);
}
The error is in the “ship.Booster()” line.
"Booster is not a member of ‘Unity.GameObject.’ I’m confused because I thought this error happened when something wasn’t defined. Am I not defining “function Booster” correctly?
I tested this by just placing the Booster function on the Ship itself and it works fine as a “function Update” but obviously that won’t let me use a trigger.
I also tried splitting the script between the Boost Pad and the Ship, still with the same error. For this, I used the SuperJump example from the ThirdPersonController script as an example, where the function SuperJump is defined in the TPC script and then called by the Jumppad script.
Combining them into one script was an attempt to narrow down the problem, but I’m stuck…
Any help is greatly appreciated.
(Also, I realize that once the Ship arrives at the target location it will be stuck at that spot, so the next step after fixing my current problem is to destroy the target location upon arrival - but that part I think I have covered).