Hi There Guys
another simple one …that is doing my head in
basically the code below is attatched to a character collider and the code below takes variables from another script that is also attatched to the character collider(code Below works fine!
now what I am trying to do is create a script that accesses the same variables as the script below but from a seperate trigger collider on another GameObject…as I want a separate set of Idles to be used and a different walk…so your help would be greatly appreciated… I have tried using GetComponent in my trigger script but I think I am getting the syntax wrong…etcetera not even sure if i should be using get component…
//////////////////////////////////////
//// IDLE-CODE//////////////
function Update ()
{
var marioController : standardplayercontrol = GetComponent(standardplayercontrol);
var currentSpeed = marioController.GetSpeed();
// Switch between idle and walk
if (currentSpeed > 0.1)//was 0.1
I think that what you’re saying is that you want to access the ‘currentSpeed’ variable from another GameObject that is a trigger? In that case you maybe should try this:
function OnTriggerEnter(other : Collider){
var variable1 : float;
//Gets the variable from the object that triggered this trigger
variable1 = other.gameObject.GetComponent("TheScriptsName").currentSpeed;
}
Oh and remeber that you have to have a rigidbody attached to the trigger. If you don’t want the trigger to move. make it kinematic.
Thanks for the quick reply Lime x…yes the current speed variable is the variable I wish to access will give your script a go and see how I get on cheers!
Hi There just got a error message unknown identifier CurrentSpeed when I used the above suggestion…?
//TRIGGER ANIMATION PARAWALK////
var emelly : GameObject;//the game object witth the collider/and new animations
function OnTriggerEnter (other : Collider) {
if (other.CompareTag (“Player”)) {
var variable1 : float;
//Gets the variable from the object that triggered this trigger
variable1 = emelly.gameObject.GetComponent(standardplayercontrol).CurrentSpeed;
if (CurrentSpeed> 0.1)