I imported a model from Maya, ticked the Generate Colliders, added a mesh collider to it and attached the script onmousedown () {transform.position} and it’s not working how should I do it?
I think you have to be more specific with the position, where do you want to move it to?
you have to do something like this:
transform.position = Vector3(0,0,0);
the 0s = x,y,z
well sorry for not putting my whole code
– charnew
Maybe you should post more of your code then, rather than having everyone try to guess whats wrong when they have no idea what your script looks like.
Can you point to an exact location specified by another person on a map, if the map they hand you is a blank sheet of paper?
Maybe it’s not even your script that is the problem, which could be determined if we saw your script.
if your script doesn’t look something similar to this (UnityScript since I don’t know what you’re using) →
function OnMouseDown(){
transform.position = someVector3 ;
}
then your code is screwy…
if your code isn’t screwy, then maybe the game object you attached the script to is a parent game object of objects with the mesh colliders, and the parent has no collider. Check to see. If that’s the case, then clicking on it won’t do anything. Move the script onto the child with the collider, then click that and see if it moves. Add a Debug.Log to your mousedown function to see if your click is being detected, then if it doesn’t move but you do get the debugger, then your movement is messed up somewhere.
If you want the parent object to be the one you click to move the whole family of objects, then attach a primitive collider to it (sphere,box,capsule,etc) , put the script back on that parent object, then click it to test again.