x

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"

Movement along looping spline

https://forums.unrealengine.com/showthread.php?24522-Tutorial-Blueprint-Spline-locked-sidescroller-(e-g-Klonoa-Pandemonium-style-game)

I completed the above tutorial and have it working. But what I want is to have that same movement along a spline in a loop. I found the option "Closed Loop" in the details of the spline component within the spline blueprint. When activated it looks as if it should work, see picture.

http://imgur.com/xCZMDa0 - This should make it clear what I am trying to do, I want him to run forward along the spline when I hold right (counter-clockwise in the image) and the other way with left. It all works except for the looping part.

But there is no difference with "Closed Loop" checked or unchecked. The player character stops in the same place every time. What I am trying to get is for him to run in a circuit along this spline when I hold left or right.

Is "Closed Loop" not working or am I using it wrongly?

Product Version: UE 4.10
Tags:
more ▼

asked Mar 14 '16 at 03:47 AM in Using UE4

avatar image

Kura7
6 1 3 5

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

3 answers: sort voted first

I know this is an old thread but for anybody having the same issue, the modulo operator is what you're looking for. If you do something like the picture I've attached, it should work smoothly in the loop alt text

Modulo returns the remainder of input A over input B. That way, when your distance spills over (reach the end of the spline) it'll seamlessly loop back to the beginning of the spline :)

splineloop.png (150.5 kB)
more ▼

answered Mar 31 '17 at 04:13 PM

avatar image

Shempii
86 5 8 12

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

As with the tutorial, what did you do with the "Distance along spline" to loop? Also, what do you mean player character stop in the same place every time? Did it happen at the end of the spline, when you are about to loop the entire spline again?

You didn't give out enough informations, so i can only guess that it has something to do the variable which you used to store "Distance along the spline", after the first loop, you didn't reset it's value back to 0 and keep letting it grow, while your spline's max distance doesn't change, so your spline keep clamping your input variable to the maximum spline distance, thus setting your character at the same place.

I suggest that after you increase your "Distance along the spline " variable, add a branch, if that variable's value is bigger than the maximum spline distance, set that variable's value back to 0. Vice versa if you want to go backward, but this time check for value that go below 0 and set it's value back to maximum spline distance.

more ▼

answered Mar 14 '16 at 05:08 AM

avatar image

CKong
874 27 18 48

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

Yes it stops at the end of the spline.

I think your suggestion is what I need to do but i'm not sure how to do it. I do not know how to define what the max spline distance is for use in the < branch. I tried what you suggested but I can't work it out. Below are some pictures I took which should communicate the problem better. I removed my attempt at your suggestion as I did not know how to do it. These are what I have now;

Character Blueprint - http://imgur.com/5xxa0cJ

Spline Blueprint - http://imgur.com/oDbPC1R

Spline Path - http://imgur.com/GogIyhA

All I want is my character to run in circles when I hold left or right on the analog stick.

more ▼

answered Mar 14 '16 at 10:33 PM

avatar image

Kura7
6 1 3 5

avatar image CKong Mar 15 '16 at 07:47 AM

Basically, it is something like this, you may need to change here and there to fit your need: alt text

My suggestion is that you modify your MoveRight event, add the branch check right after you set your DistanceAlongSpline variable, and i think it will work out with your code pretty well.

splineloop.jpg (162.8 kB)
avatar image Kura7 Mar 15 '16 at 11:13 PM

Thanks a lot that did the trick. I worked out myself how to make him run in the oposite direction by adding the below piece. Thanks for taking the time to help me man. :)

alt text

capture.png (89.8 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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