0
Answered

Trying to find a raycast point

Martin Saldert 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 3

Hi.

Im trying to create a simple flow were a cube is moved around and a sphere is following it around but on the terrain below.

I use a raycast to find the point below the cube and moves the sphere to that point.

Quite simple. But one problem.

The sphere is moving along X and Z when i move the cube bit instead of having Y locked to the surface the raycast hits its animated between the cube and terrain surface. I only want it to glide along the surface.

Any ideas?

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Answered

Instead of setting position directly to the point, use Create Vector 3 and Expose Vector 3 to create a new vector 3 that copies the X and Z, but sets a new Y.

It does not matter.
If i make sure Y is 0 into the origin in the raycast the hitpoint Y is animating between 0 and the hit point Y. I have tried everything i can think of. But as soon as i use Y from the hitpoint (And thats what i use the whole raycast to get) the Y value out from the hit point is animated. It always navigate from the Y origin to hit point Y. I need the actual hit point position to place a sphere on the terrain. This has to be a bug? Or am i missing something?

What I'm suggesting is not that you change the the origin vector: I'm suggesting you create a new vector after Get Point, using the X and Z of Get Point, and the Y you want.