I’m trying to make bullet holes, but every time i shoot it creates the bullet holes at the wrong angle.
Here’s the code:
var maxDist : float = 10000000;
var decalHitWall : GameObject;
var floatInFrontOfWall : float = 0.01;
function Update () {
var hit : RaycastHit;
if(Physics.Raycast(transform.position, transform.forward, hit, maxDist))
{
if(decalHitWall && hit.transform.tag == “Level Parts”)
Instantiate(decalHitWall, hit.point +(hit.normal * floatInFrontOfWall), Quaternion.LookRotation(hit.normal));
}
Destroy(gameObject);
}
Any help is appreciated!
mgear
May 8, 2015, 10:20pm
2
For rotation try,
Quaternion.EulerAngles(hit.normal)
Thanks for the help but now it only spawns it correctly on certain faces.
i think if you call the main function in the thing it might help idk
use the second parameter of lookRotation: up
I’m a 7th grade kid who’s trying to learn but i don’t really know how to use the second parameter of lookRotaion.
An example would be very helpful.
Thanks for the answers though.
well i think i had a similar problem
i think the problem is that you are not specifying an up direction for your look at
there ate an infinite number of rotations from which to ‘look at point’
but only one when also specifying up direction
another way to look at it is:
what axis do you want to rotate about when ‘look at point’
i think
idk