- Home /
hierarchical prefabs instantiate wrong positions
Hey
with this line i can instantiate gameobjects at the mouse position.
if (hit.collider.CompareTag("TowerPlace"))
{
Instantiate(tower, hit.collider.transform.position, Quaternion.identity);
}
i made a simple tower prefab (a few cubes,cylinders..) and all of them in an empty gameobject. when i instantiate they are place wrong position. but my script works true if i instantiate single prefab like a cube. what's my wrong?
Is your hit is a RaycastHit? If yes try hit.point. It is the impact point in world space where the ray hit the collider.
they are two different prefabs. instantiate electro_tower
works great. but laser_tower
is not occur at mouse click position. what's the difference between them?
laser_tower>
sphere>
cylinder
cube
cube
electro_tower
Your answer
Follow this Question
Related Questions
How prefab the instance works? 1 Answer
instantiating a projectile continually over time 2 Answers
Adding prefabs to a list or an array from a folder and instantiating them. 2 Answers
Moving a rigidbody prefab forward wafter instantiated 3 Answers
Wrong coordinates of setting position of the object 1 Answer