- Home /
How do I drop a GameObject on top of Grid/mesh's Vector3 coordinates?
Hello Everyone! This is my first post on Unity Answers. I have an array of vector3s that are part of a mesh (i.e. the mesh's vertices). I want to be able to drag and drop gameobjects on top of them. Drag part is fine. I need help for the drop. I’m using the ondrop method (Unity Event System) and I managed to somewhat drop my gameobjects exlusively on top of the mesh, though only at random position (not what I wanted). What am I missing that would allow me to drop them correctly on the vector3's coordinates ? Here's the part of the script where I use the ondrop method (not working as I would want).
public Vector3[] vertices;
public void OnDrop(PointerEventData eventData)
{
eventData.pointerDrag.transform.position = vertices[Random.Range(0, vertices.Length)];
}
For more details, you can check the question I posted last week on the Unity Forum, where you can find the full script: link text
I appreciate any help you can provide.
Your answer
Follow this Question
Related Questions
split vector3 coordinates in to x,y,z 1 Answer
Vector3.Lerp works outside of Update() 3 Answers
Position in Vector (C#) 1 Answer
Cannot implicitly convert type 'int' to 'UnityEngine.Vector3' 3 Answers