Find Input Key Closest to World Location return wrong value

Hello, I am making a system to get the closest point of a spline at the player’s position but I am getting the input key and not the values ​​between two points.

I created a spline with 3 points :
Image1

I made this code for get the closest input key :

But if I’m far from the point I still have the key value :
Image3

I have to be really close to the key to have a value between two keys, how can I fix my problem ? Thank you.

A bit confused with wording / expectations. There are 3 spline points here so there only be 3 possible outputs - the location of splines points themselves. Instead, did you mean to:

I had the same problem with this way. In fact I would like a widget that I attach to this spline to be able to move smoothly while being as close as possible to the player’s position.

Post code.

GameNamePreviewNetMode_Standalone064-bit_PCD3DSM62024-06-2613-40-27-ezgif.com-video-to-gif-converter

In this gif you can see that when I’m close to the spline I have a smooth movement but when I’m far from the spline the widget is attached to the points

You’re using the wrong nodes. See above.


I, obviously, do not fully understand how it’s supposed to work but that’s the gist providing I understood the intent correctly.


Your spline is attached to the target, so it should be less janky than what’s in the anim above. Not exactly sure what’s the scope but perhaps this interact thing should belong to the player - so there’s only one rather than every thing in the world owning a widget + spline + logic. Consider the architectural implications before you finalise the mechanics.

Generally speaking, it’s the player who is the instigator who approaches and interacts => show the prompt => send message to the entity. However, you may be after something else, ofc - your mileage will vary.

1 Like

I made this code but I still have the issue. I made a NPC with this logic and I will create chidren for each NPC. I didn’t added this system to the player because I would like my spline attached to the NPC



spline

Without a transform in World Space:

Or, transformed into Local Space:

This is in the NPC, the way you preferred.

You can, ofc, use the widget component in world space which you already rotate. Also, no need to attach the widget to the spline. It would only make things more complicated at times.


To make it work at greater distances, in case it gets jerky, you may need to work in some interpolation.

What’s the closest point changes to rapidly here, for example. Especially noticeable when we’re parallel to the spline.

So the best way is to add some other points in the spline ?

No, this is 3 points. You can do it with 2 points only, too.

What do you mean by interpolation ?

vInterpTo - this will make it less snappy and allow it to glide much more smoother along the spline. It’s used to smooth out data over time. Many variations and applications of this method exist.

Better, far from perfect, though.


While it may seem like it at first, I don’t think this is a good overall method for this. I’d just rotate the widget towards the player. You wouldn’t even need a spline. A spline would be a must if there’s a complex path shape we must follow.

edit: I must admit the accuracy of what the Find Location Close to World Location actually returns leaves a LOT to be desired. I even cranked up the Reparam Steps of the spline segment and it still acts goofy, unable to pinpoint the world loc. And adding extra points make it worse…

In any case, thank you very much for your help :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.