[SOLVED] raycastFirst problem

Good question! I actually don’t know that either. But i have no clue how to implant this:

distance(rhs)

Returns the distance between the two specified 3-dimensional vectors.

var v1 = new pc.Vec3(5, 10, 20);
var v2 = new pc.Vec3(10, 20, 40);
var d = v1.distance(v2);
console.log("The between v1 and v2 is: " + d);

Can you give me a single example of a ray with a origin, distance and direction (like 45 degrees)? If that is to much code it means this is not a good solution for my game because i use a lot of rays.

The example code you posted from the docs is straightforward on how to calculate the distance between two points.

But, yes if you aren’t feeling strong with vectors/positions and how to manipulate them I’d say either study some 3D maths / vector course online first or stick with physics and what you are currently doing, finding an alternative to solve your issue.

It takes time and patience to understand the maths of 3D space, though I definitely recommend doing that at some point. It will polish your skills and what you are capable of doing.

I can’t do much with such an answer. Sorry. Thanks anyway.

1 Like

I managed to use the same scripts to solve this problem to.

1 Like