Unreal Engine 4 Tutorial: Player Follow Spline

  Рет қаралды 12,763

Nebula Games Inc

Nebula Games Inc

Күн бұрын

Пікірлер: 59
@greencubed1
@greencubed1 14 күн бұрын
thank you this helped so much. it was exactly what i was looking for and works flawlessly even in VR and UE5.
@NebulaGamesInc
@NebulaGamesInc 14 күн бұрын
Happy to hear it!
@bastienw4806
@bastienw4806 3 жыл бұрын
Amazing thanks for the tutorial, still usefull 2 years later 🙂
@blackbomb64
@blackbomb64 5 жыл бұрын
My suggestion would be instead of using a direct reference to a spline object in the blueprint, add a variable to the blueprint of the type "Spline Component." Make that new variable "instance editable" which allows you to dynamically set which spline the blueprint should follow. In the main editor window, when you add the blueprint, you can set the spline variable of the blueprint to the spline of your choice. It's a bit more convoluted if you spawn the blueprint instead of manually adding the blueprint to the level (e.g. the common case with the player controller blueprint), which means you will probably have to set the player blueprint's spline variable in the Level Blueprint instead.
@leonf0394
@leonf0394 4 жыл бұрын
Dude you helped me so much with my university project! Thanks a lot for this tutorial!
@NebulaGamesInc
@NebulaGamesInc 4 жыл бұрын
Happy to help!
@leonf0394
@leonf0394 3 жыл бұрын
@@NebulaGamesInc I gotta return one more time... In the map, where I am applying your method, my character is "walking" through a forest and upon mountains. I therefore had to adpat the z-components of the spline points. The Problem is, that the spline sometimes dives into the ground and other times, it is way too high above the ground. My prof isn't helpful at all, he just said something about setting up collision and gravity. So what i basically want is, is that my character gets dragged down by gravity, but he must not sink into the ground. Do you have a recommendation how to implement this?
@NebulaGamesInc
@NebulaGamesInc 3 жыл бұрын
You are using a spline?
@leonf0394
@leonf0394 3 жыл бұрын
@@NebulaGamesInc correct. I could add more spline points to adapt the spline to the ground. But I also wonder if there is a different way like allowing some degree of freedom in the z component with respect to the gravity and ground collision.
@NebulaGamesInc
@NebulaGamesInc 3 жыл бұрын
Not sure exactly what you're looking for but a spline is a very rigid thing. It is a hard coded path through the world that the player travels along with little to no "wiggle room". So what is your actual objective? A spline may not be the tool you want to use to begin with.
@GingerbreadFetus
@GingerbreadFetus 6 жыл бұрын
Great stuff man. Exactly what I needed for what I'm doing.
@Sportkid-wi7zw
@Sportkid-wi7zw 3 жыл бұрын
question, when you grab the reference to spline track and plug it into the "get Spline" I don't see the Spline component under Variables > Default. I only see the spline track variable. I followed everything exactly as you said
@androidwithsteve2629
@androidwithsteve2629 6 жыл бұрын
damn this man you are great LOVED your work man keep good work UP
@yasinozkan
@yasinozkan 4 жыл бұрын
Could you explain more about the delta time + game time in seconds why you did it?
@NebulaGamesInc
@NebulaGamesInc 4 жыл бұрын
Delta Time = real world time elapsed between frames/ticks of the game To know where the player needs to be on the spline path you need to know how much total time has elapsed and keep track of this for the calculations. Since the code moves the player frame by frame you add "delta time" to the "game time" which is just the value of all previous delta times up to that point added together. This gives you the total time passed and smooth movement along the spline path.
@yasinozkan
@yasinozkan 4 жыл бұрын
thank you
@Xegethra
@Xegethra 3 жыл бұрын
Bit stuck here, as far as I can tell I set it up the same, the only difference is I am using a car, one that I can drive. But I can never get it to follow the spline. I want this system to make the car only go in one direction but you are still able to swerve obstacles. Only when I do this, the camera follows the spline path but the actual thing to control just stays put, I don't have an actual playable character, it is strictly cars.
@NebulaGamesInc
@NebulaGamesInc 3 жыл бұрын
A spline path doesn't give you the option of "swerving" because at every point it dictates where you must be.
@Xegethra
@Xegethra 3 жыл бұрын
@@NebulaGamesInc Yeah I thought that too. Then I saw a video on someone using it as a guide. The car didn't look stuck to it so much.
@NebulaGamesInc
@NebulaGamesInc 3 жыл бұрын
I'm sure there are ways you can modify it, but technically speaking a spline is very rigid haha
@Romain_Derelicts
@Romain_Derelicts 4 жыл бұрын
Thank you for this tutorial :)
@pleasurepalace9338
@pleasurepalace9338 4 жыл бұрын
Do you have a tutorial on how to set the camera up to follow the character? I was able to create a player character to follow the spline but the camera does not follow when I press play.
@NebulaGamesInc
@NebulaGamesInc 4 жыл бұрын
Do you have a camera attached to your player?
@Goddisz
@Goddisz 4 жыл бұрын
Sweet tutorial, but how to detect when player get the end of the spline? Let's say the player be able to move outside spline when they reach the end of it and go back inside when he move back?
@NebulaGamesInc
@NebulaGamesInc 4 жыл бұрын
Once the player reaches the end of the spline the timeline stops and you should be able to freely move the player with your regular inputs. To go backwards you'd need to have some sort of collision sphere so that when the player entered that space it would trigger the spline to start pathing for the player again. I hope that is what you're asking..... otherwise not really sure what you mean ha
@LuizzSoares
@LuizzSoares 5 жыл бұрын
Como faço para um veiculo parar em determinado caminho da spline por um tempo e depois seguir How do I stop a vehicle in a given spline path for a while and then follow
@androidwithsteve2629
@androidwithsteve2629 6 жыл бұрын
just 1 thing how do I make it loop
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
Loop how? Like have the player start back at the beginning of the spline path or ‘loop’ like go up in the air and ‘loop’?
@androidwithsteve2629
@androidwithsteve2629 6 жыл бұрын
Player came back to start
@androidwithsteve2629
@androidwithsteve2629 6 жыл бұрын
And then start following the path
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
So you will nee to do a few things to get that to work. 1. In the spline BP select the spline utility component, then on the right hand side details panel you need to check the box for "closed loop" under the tab "Spline" 2. In the character BP where we ran the movement logic on the spline you will need to manually keep track of the "time", so you will have to create a float variable call it "Time". Replace "get game time in seconds" with your new variable "Time". Right after the Timeline the next node that should be connected is "Set Time" BEFORE you "Set Distance". Once "Time" is set, you can use it to multiply by "Speed" and the result will be used to "Set Distance". 3. Drag out from the Spline BP reference, and search for "Get Location At Spline Point". Leave the "point index" at 0, change the coordinate space to world. 4. From the return value of that node (yellow vector pin) drag out and search for "equal vector". 5. Get the player's location and connect it to the remaining vector pin of the "equal vector node". (The green pin is for accuracy, the greater the number you type in there the less accurate). 6. After the "Set World Location Node" have a branch node. Off the true "Set Time" and leave it at 0 7. Connect the return value (red pin) of the equal vector node to the branch node. This will reset time to 0 so that the distance calculation will be reset every time the player reaches the start point.
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
Can you email/post a screenshot somewhere with your set-up?
@godzoproduction843
@godzoproduction843 5 жыл бұрын
great tutorial but why when I want to change the speed of the player with a trigger box my character is teleported to the beginning of the spline?
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
Not sure, probably because you're resetting the distance variable.
@amt8965
@amt8965 5 жыл бұрын
But how do we rotate the actor along the spline. No tutorials about that anywhere in the hole web :(
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
You either rotate the actor independently with a "set actor rotation" node, or you use the node set actor location and rotation and take the rotation from the spline using the node "get rotation at distance along spline"
@amt8965
@amt8965 5 жыл бұрын
@@NebulaGamesInc Wow, that worked. So fast. Thanks :)
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
No problem. Glad it worked easily 😊
@destinationunknown6665
@destinationunknown6665 5 жыл бұрын
Great video. Just wondering how to make my character jump? (I'm using a sphere as my character. It's just stuck to the floor and I have no control of making it jump).
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
Make the character jump while on the spline or just jumping in general?
@destinationunknown6665
@destinationunknown6665 5 жыл бұрын
@@NebulaGamesInc Jump while on the spline. I'm wanting my character to follow the spline but then also be able to jump when you press the space bar. When the character jumps it should still be moving in the direction of the spline and not stop.
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
What you're describing is incompatible with how the spline works. Since the spline is literally "setting" the world location of your player character you can't run the spline AND also jump at the same time. What you could possibly do is allow a jump while on the spline by having some branch check to see if jump was pressed if so it prevents the spline from updating the player location temporarily until the jump is completed. But you will have to figure out something out for restarting the player on the spline at a point which would make it appear as if he never left the spline. So long story short, you can't do what you want with a regular spline. It will take some finagling to accomplish.
@destinationunknown6665
@destinationunknown6665 5 жыл бұрын
@@NebulaGamesInc Ah ok, thank you so much for you help. I will have to speak to my tutor at university when I'm next in to see what I could do as I'm still learning to become a games designer (In the early stages and everything is confusing haha).
@Jigglychad
@Jigglychad 2 жыл бұрын
@@NebulaGamesInc this is so not true
@Kramez
@Kramez 6 жыл бұрын
Hi, what would you do in the case of there being multiple splines, more specifically the same spline actor being duplicated across the level?, I have a grinding system in my game and Im unable to have more than one spline since it just teleports the player to the most recently duplicated one. Great tutorial though thanks!
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
I messed around with the splines today and I think I have a solution that will work for you. I can make a tutorial and have it up by next Wednesday and show you how to implement it. But basically you can place as many splines in the world as you like and when the player overlaps part of the spline (I had this just be the beginning area but you can make it whatever you want) it will move the player along the length of the spline. Once the player reaches the end they are free to go back to walking around and are able to overlap another spline mesh. If that is too long to wait I can send you screen shots and you can put it together yourself.
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
@Christopher Kissoon, here is a link to a tutorial on how to use multiple splines within a single level. Hope this helps answer your question! kzbin.info/www/bejne/rXmWZHaJfNmra8k
@Kramez
@Kramez 6 жыл бұрын
Thanks just what I needed.
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
Awesome! Glad we figured something out for your needs.
@androidwithsteve2629
@androidwithsteve2629 6 жыл бұрын
Not sure if this can work so iam gonna give it a try and lets see what happends i think it can work
@NebulaGamesInc
@NebulaGamesInc 6 жыл бұрын
I tested it out before I wrote the instructions it works no worries. Haha
@petertremblay3725
@petertremblay3725 5 жыл бұрын
Can you imagine a guy is selling this for 90$ on the unreal market place!
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
Haha no. That's ridiculous. I doubt anyone is buying. I hope it's more than just the basic spline path I show here 🤣
@petertremblay3725
@petertremblay3725 5 жыл бұрын
@@NebulaGamesInc It's a little more elaborated but 90$ is ridiculous when one can do it without too much of a problem.
@NebulaGamesInc
@NebulaGamesInc 5 жыл бұрын
Agreed! But some people don't want to put in the work to learn things. You'd be surprised even for tutorials people request such specific things instead of trying to modify something slightly I did here they want a whole new tutorial 🤷‍♂️
@petertremblay3725
@petertremblay3725 5 жыл бұрын
@@NebulaGamesInc Yep nowadays people are looking for the lazy way unfortunately!
Unreal Engine 4 Tutorial: Multi-Spline Pathing
11:50
Nebula Games Inc
Рет қаралды 7 М.
How to Move a Character Along a Spline in Unreal Engine 5
8:04
Gorka Games
Рет қаралды 55 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Unreal Engine 4 Tutorial - Splines - Moving Platforms
18:12
Ryan Laley
Рет қаралды 48 М.
Unreal Engine 4 Tutorial - Splines - Spline Meshes
21:21
Ryan Laley
Рет қаралды 224 М.
Recreating Star Fox's Rail Movement | Mix and Jam
5:26
Mix and Jam
Рет қаралды 95 М.
UE4 Tutorial: Add spline-meshes procedurally
7:59
Playful Synapse
Рет қаралды 159 М.
Unreal Engine 4 Tutorial: Health Bar
4:54
Nebula Games Inc
Рет қаралды 1 М.
How To Make An Object Follow A Spline Path - Unreal Engine Tutorial
16:11
Unreal Engine 4 Guide - Spline component - road, pipe, railroad
9:23
Tefel - Astro Colony
Рет қаралды 134 М.