MouseEnter and MouseExit

Hello, its me ><>FreakFish<>< requesting your wisdom again! Today i’ve been having a bit of an issue with my Weeping Angels - the game is first person, and the Angels can only move when you cant see them. Here is my original script - its fully functional:

var LookAtTarget:Transform;
var damp = 5;
public var angel1speed = 1;

function FixedUpdate () 
{
			if(LookAtTarget)
			{
				var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
				transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);
				rigidbody.AddForce(transform.forward * angel1speed);
			}
}

function OnMouseEnter () 
{
	angel1speed = 0;
}

function OnMouseExit ()
{
	angel1speed = 1;
}

That controls the Angel’s movement. My problem is that because i modelled the angel lying down i had to rotate it, then stick an invisible box on its feet that can host the script and keep the angel the right way up. It works fine, except you have to look at the angel’s feet where the invisible box is to make it stop. I tried to solve this problem by adding another invisible box that covers the correct area, then i wrote this script for it:

function OnMouseEnter () 
{
	angel1speed = 0;
}

function OnMouseExit ()
{
	angel1speed = 1;
}

Now, i remembered from a tutorial video i watched a week or so ago that public var makes the variable, well, public. I thought it made it so it could be used and changed in multiple scripts. I tried declaring it again in the above script, but it still didnt want to work - so where have i gone wrong? Why doesnt this public variable change in the other script when its meant to in this one?

Thanks in advance - ><>FreakFish<><

Call the script holding the public var first, then the var, they should be separated by a period.

Kind regards, Robert

You might have some trouble with this from the BBC if you try and sell it. They’ve been known to be nazi like when it comes to protecting Dr. Who related IP.

yeah i know, this is just a bit of a tester really. wont be selling it under any circumstances lol - but come on, they really killed the angels didnt they?

Robert, thank you for the tip but i dont have a clue how to call scripts D: could you give me a little example please?

Love from ><>FreakFish<><

Sure, just like this:

 Otherscript.angel1speed = 1;

Otherscript is of course the script that contains angel1speed.

All the best, Robert

absolutely brilliant, thanks for this robert you’ve made my day :slight_smile:

Glad it worked out all right and you are welcome of course.

All the best, Robert