- Home /
how can i fix a object in a particular place of another mesh or object by click on it
i would like to know how can i fix a object in a particular place of another mesh or object by click on the object which is placed away from that mesh or object
Answer by ben · Mar 08, 2011 at 11:09 AM
place the script in clickable object - in that script while mouse down , place the target object over it by getting the clickable objects position using transform function
Answer by The_r0nin · Dec 24, 2010 at 01:53 PM
Your need to separate out, programmatically, what it is you need to happen. Something like:
- Register mouse click on object
- Determine the place the object should move to.
- Move the object into place and set rotation.
Then work on each individually. As for step two, I have a GameObject that is my player. Then I parent the mesh to it (with the mesh as the child). Then I parent additional gameobjects for where I want other objects to appear. This way, if I want a missile to appear on a tank, I have an object in the right place tagged "missilespawn", and I can find the transform.position and rotation of that child to spawn the missile at.
Also, if you've rigged your model, you can attach your objects to the bones in the rig, just like if they were independent gameobjects... that's how most people attach guns to the hands of their characters...
No... the script depends on your objects, your setup, and what you want to happen. $$anonymous$$ost of it is set up in the inspector (and not scripted), anyway. If you post what you have, I can help you with the next step (or the part that is causing you problems).
Your answer
Follow this Question
Related Questions
C# Check If Scripted Gameobject goes Past Variable Gameobject 0 Answers
Position of a GameObject 2 Answers
How can i auto Position my Game Object? 0 Answers
How to tell if two blocks are right next to each other?(2D) 1 Answer
how to call a gameobject in one function(mouse selection) to another function (GUI) 1 Answer