Hi...,

I've figured out how `Curve3D.get_closest_point(...)`

works.

How to get the direction at this closest point?

Thanks

Mike

0 votes

Hi...,

I've figured out how `Curve3D.get_closest_point(...)`

works.

How to get the direction at this closest point?

Thanks

Mike

Short answer is`(closest_point - current_point).normalize()`

... but that is a guess. Please add some code in your question (edit)

hi clemens,

the code lools similar to this:

```
var curve := Curve3D()
var closest_point = curve.get_closest_point( point_somewhere )
```

I don't have a current_point on the curve.

Thanks

Mike

I exactly don't know what you want, but i think you need to use curve's

get*point*position(point_index) to get position, and then simply calculate direction vector as CLEMENS.TOLBOOM said:

```
var curve := Curve3D()
var direction_vector = (curve.get_closest_point( point_somewhere ) - curve.get_point_position(any_point_number)).normalize()
```

hi clemens and Falcon,

I have changed my code from `get_closest_point`

to `get_closest_offset`

, which seams to work. Then with `interpolate_baked`

I can calculate the direction like this:

```
var curve := Curve3D()
var offset = curve.get_closest_offset( point_somewhere )
var point_1 = curve.interpolate_baked( offset, true )
var point_2 = curve.interpolate_baked( offset + 0.01, true )
var direction : Vector3 = ( point_2 - point_1 ).normalized()
```

Thank you again

Mike

0 votes

Best answer

Hi again,

I have found a simpler solution. I use a `Path`

with a `PathFollow`

. The PathFollow can be set like this:

```
pathfollow.offset = path.curve.get_closest_offset( point_somewhere )
var basis = pathfollow.global_transform.basis
var y_direction: float = Vector2( basis.z.x,basis.z.z ).angle_to( Vector2( 0,-1 ) )
```

I use `PathFollow`

with `Rotation Mode = Y`

, and I can calculate the y_direction by the `transform.basis`

.

Thanks

Mike

- All categories
- Engine 26,038