- Home /
Change Object's Position OnTrigger
I made a script to change a gameobject when in a trigger collider and when I pressed "e". I had an earlier script that changed its position but it was not on trigger but just when I pressed "e". Here's the script:
var Skull : GameObject; var x = 0.0; var y = 0.0; var z = 0.0;
function OnTriggerEnter (other : Collider) {
Skull = GameObject.Find("Skull");
}
function Update() {
if (Input.GetKeyDown("e")) Skull.transform.position = Vector3(x, y, z);
}
I need to have the player find the skull, have the collider that is in front of the player have the skull inside of it, and the player to press "e" to move its position. Please help and thank you.
Your answer
Follow this Question
Related Questions
How do I add force in the on trigger 1 Answer
Show message when gameobject hits other gameobject.. 1 Answer
static var for one object. 2 Answers
"GameObject.Find();" not working 2 Answers
Get game component type? 1 Answer