- Home /
Move position of box collider using javascript
I have a 2d game object in my scene, and I want to place the box collider in the same position as my 2d game object, so that when I click on the 2d game object the player will enter another scene. How do I adjust the x, y, and z positions of the box collider using the script?
I'm new to unity and trying to finish my game. =)
rigidbody.addforce http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
transform.position http://docs.unity3d.com/Documentation/ScriptReference/Transform-position.html
???
Answer by cagezero · Dec 22, 2012 at 10:45 PM
If you are trying to move the collider independently of the GameObject you will need to do something like this:
((BoxCollider)collider).center = new Vector3(10,10,10);
Cast to the appropriate type of collider as appropriate...
Your answer
Follow this Question
Related Questions
What is the advantage of using Box Collider with a center of (0.5, 0.5, 0.5) 1 Answer
destroy touch the screen on gameobject in camera 0 Answers
Player's Collider Stuck Help 1 Answer
How to block dragging if collider hits 1 Answer
Is it possible to destroy an object at a specific position? 2 Answers