I have this issue. I’m raycasting with a weapon, and I just can’t seem to get bullet holes (being that I have an open-world element/sprite) to get the right angle on any surface it hits.
Here is what I have right now:
if (result) {
var hitEntity = result.entity;
var hitAngle = result.normal;
var hitPoint = result.point;
var newHole = this.bulletHole.clone();
this.bulletHole.parent.addChild(newHole);
newHole.setPosition(hitPoint);
var q = new pc.Quat().setFromAxisAngle(hitAngle, 90);
newHole.setRotation(q.invert());
this.app.root.findByName('Debug Text').element.text = newHole.getPosition();
// newHole.setRotation(hitResult.hitAngle);
}
The hitAngle is actually a normal (E.G. new pc.Vec3(0, 1, 0);
)
I have no idea what math I need to do to get this normal to turn into a simple rotation for my element.
This is my fifth iteration, and I know that it’s incorrect, I just can’t seem to find a proper solution using the engine’s currently available math. Also, Unity forums and other game development forums haven’t been of much help…
I know this is a stupid question, but I’d really appreciate it if one of you could through me in the right direction!
Thanks,
Noah