- Home /
place a object on the position where the object is colliding with the terrain.
Hello,
I have a character that has a object the player can put this object in the ground. I was thinking about a system that can the detect the y and x position of the object on collision. But how do i do this? Or is there a much simple way.
Rick Grendel.
you can simply access the player.transform.position.x and player.transform.position.y
Answer by MrSoad · Dec 18, 2014 at 07:30 PM
Hi, place this on you character script and it should output the position of the gameobject in the Debug Window. Remember to change the Tag name to the Tag name of the object you want to detect the position of :
function OnCollisionEnter (other : Collision) {
//Replace -> Tag name here
//With the name of your object
if (other.gameObject.tag == "Tag name here") {
//Display position of object in the Debug Console
Debug.Log(other.gameObject.transform.position);
}
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to see object through collision? 0 Answers
Help with hiding an object on trigger enter 1 Answer
Trouble grabbing and holding a cube. 0 Answers
Triangle Mesh Problem 2 Answers