Need help with a crosshair

Hello!

I have created a crosshair that gets the same rotation as the hit point for the bullet.
It’s already working, but it look not good on the edges of objects.
Is there a way to ignore the edges or something like that?

I use this code to set the rotation for the crosshair:

// Set crosshair rotation
this.shootingRotation.copy(hit.normal).scale(-1).add(hit.point);
var vec = pc.Vec3.UP;
var dot = vec.dot(hit.normal);
if (dot > 0.999) vec = pc.Vec3.FORWARD;
this.shootingCrosshair.lookAt(this.shootingRotation, vec);

Impression:
Crosshair

1 Like

What do you mean by edges of objects?


Right there is an edge of a platform part that affected the crosshair.

That’s a tough one as all your blocks are individual entities and rigid bodies.

Don’t have a good idea at the moment tbh.

I’m still not sure what the issue is?

The raycast is somehow hitting the edge of a physics block (the floor is made up of X unit size rigidbodies) so there’s about 12 blocks in that image above. :thinking:

1 Like

Yes that’s right. To make easy levels I created different blocks to build the environment.

Expected result:

Actual result (on the edges):