Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I let an actor snap to a spline path?

Hello, I'm currently working on a system to draw a spline during gameplay to build walls or other useful stuff. The script is basically an Actor with a Spline Component. When you spawn the Actor a single Static Mesh gets added and the whole BP follows the cursor. When you press the left mouse button it stops following and the second spline point follows the cursor. This way you can click to draw straight lines. When you hold the mouse button you can also draw along a path.

Then I'm constantly checking the length of the spline and spawn static meshes along it. I'm not using spline meshes since I don't want any deformation. This animation shows how it works in-game:

alt text

I use a function to determine how many meshes I need and another one to move those meshes on the spline. This screenshot shows how the meshes are being moved (to the right is just some stuff to check for collisions with other Actors)

alt text

This is what I have and now my actual problem:

1) When I'm done drawing one spline I want to be able to spawn a second one. This second one will be stuck to the mouse cursor just like the first, but when it hits one of the meshes from the first I want it to snap to the closest point on the spline. When I move my move close enough to the spline it should follow the mouse but stay on the spline, only when the mouse gets further away it should follow the cursor again. I am just using the spline to calculate the world location for each mesh so I have no idea how I would get a reference to the spline itself when I hit one of the meshes. I think this would be fairly easy if I could just check for an overlap event with the blueprint that contains the spline but only the meshes have collision and not the spline.

2) If it is actually too complicated to get a reference to the spline when hitting one of the meshes, it would probably be enough to snap to the nearest mesh or something like that also.

I do have some ideas how to achieve this snapping feature but none have worked out so far. I have no working solution implemented so far, so any idea would be greatly appreciated.

Product Version: UE 4.18
meshspawn.jpg (269.3 kB)
more ▼

asked Nov 08 '17 at 05:32 PM in Blueprint Scripting

avatar image

1 3 1 3

avatar image KevinTHart Dec 23 '18 at 09:09 AM

I believe it isn't possible in Blueprints yet however in c++ you could definitly do it

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question