2

I have a base plane and when I click on the plane I need to add some other object at the exact location the user is touched. the newly added object is not a child of base plane it will be a child of another object which will present the same base plane

I tried using raycast position but it didn't work well.

Vector3 objLocation = new Vector3(raycastHit.transform.position.x, 180.0f, raycastHit.transform.position.z);
GameObject newObj = Instantiate(singleDustBin, objLocation, Quaternion.identity);                  newObj.transform.SetParent(dustBinPrefab.transform);
Ramprasath Selvam
  • 3,868
  • 3
  • 25
  • 41

1 Answers1

4

Instead of raycastHit.transform.position use raycastHit.point - that should do the trick

derHugo
  • 83,094
  • 9
  • 75
  • 115
zambari
  • 4,797
  • 1
  • 12
  • 22