So yea I need to instantiate an object but I cant make it to follow the surface angle.
I use Phisycs.Raycast to set the position of the instantiated object but I need the rotation.
Example(Java):
var object:Transform;
var placePosition:RaycastHit
function Update()
{
var layerMask = 1 << 8;
layerMask = ~layerMask;
if(Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), placePosition, 10, layerMask))
{
if(Input.GetButtonDown("Place Object")
{
//Here it instantiates the object using the "placePosition.point" position and the rotation of x=0,y=0 and z=0
Instantiate(object, placePosition.point, Quaternion.Euler(0,0,0));
}
}
}
Sorry if there is an error somwhere in the example code but I wrote it in a hurry and it isnt the real code its just an example so…
Please if you know how to do this please help me.
Thank you.