Since i know this community has very helpful users, i started this thread to get me helped with solving my scripting problem. Here it is:
// This script rotates an object if "Player" enters a trigger
var playerObject : GameObject;
var rotatingObject : GameObject;
var speed = Vector3(10,0,0);
function OnTriggerEnter (theTrigger : Collider)
{
if(theTrigger.gameObject == playerObject)
{
Debug.Log("Trigger started");
rotatingObject.transform.Rotate (speed * Time.deltaTime) = true;
}
}
function OnTriggerExit (theTrigger : Collider)
{
if(theTrigger.gameObject == playerObject)
{
Debug.Log("Trigger stopped");
rotatingObject.transform.Rotate (speed * Time.deltaTime) = false;
}
}
I think the drawing explains what i mean. Sorry it’s so simple, had to do it in a hurry.
Any help would be appreciated. And once i know this one i’ll be able to share my knowledge with other newbies among us. So they thank you too.
Rotation isn’t a boolean (true/false). You’d probably be better off putting your rotation inside function Update(). Then use OnTriggerEnter () to set the speed variable to some value and OnTriggerExit() to reset it to zero. Instead of setting speed to a Vector3, why not just set it to a float value, then define your rotation inside Update?
Thank you sooo much for a fast respond. It works great, thank you tool55!
Further upgrades and problems on the script will be posted here so whoever needs this kind of scripts can always come to this thread and get their problems solved.