Camera on Rail ( 3D Scroller ) [Tutorial][C#] - Unity 3d

  Рет қаралды 17,865

N3K EN

N3K EN

Күн бұрын

Пікірлер: 25
@darksidebidi
@darksidebidi 2 жыл бұрын
man, i love you for real, this helped me a lot! i need to make a 3rd person camera but camera is fixed on a rail like this so the rail part is done now i need to figure it out on how to keep it on a position behind the player with a certain distance. thanks a lot
@mesolagic
@mesolagic 3 жыл бұрын
This was really helpful! Followed tutorial exactly and it works perfectly still. Instead of having a camera follow my player I needed a 3D spatial audio source to follow my player so I just stuck this rail mover script on there and it perfect! Thanks man!
@richterdelgan123
@richterdelgan123 9 жыл бұрын
Thanks a lot. dude you save us. all bless you for the eternity and eons.
@n3ken
@n3ken 9 жыл бұрын
cheers :)
@petemon69
@petemon69 9 жыл бұрын
This is awesome. This is exactly what I needed for my game. Thanks a lot.
@n3ken
@n3ken 9 жыл бұрын
+petemon69 Glad you like it! I'm upgrading the system a bit, I will release a more versatile version in the upcoming weeks :)
@johnnymcfettsack3552
@johnnymcfettsack3552 5 жыл бұрын
@@n3ken where can i find this upgraded version?
@master2k27
@master2k27 8 жыл бұрын
Thanks very much! Helped me out alot :)
@celticdragonstudio5560
@celticdragonstudio5560 9 жыл бұрын
Hey I'm wondering is there a way to get the camera to follow the player but stay at a fixed distance away from the player using this method
@GWKTM
@GWKTM 2 жыл бұрын
Is there a way to give rail bezier corners?
@GWKTM
@GWKTM 3 жыл бұрын
How to change it so that it can pick a path on intersections?
@zanekarl8391
@zanekarl8391 6 жыл бұрын
Hi @N3K EN, I have a few quick questions about your video. First, how are you controlling your capsule character? I don't see any children under it in your inspector so my thought that it has a third person character camera inside is wrong no? Second, I don't understand how your unity environment immediately generates the Grey checkerboard terrain where is that coming from? Thanks for a great video otherwise!
@niallmccaffrey791
@niallmccaffrey791 6 жыл бұрын
Is it typical to always have the camera at the closest point on the rail? For instance, your third point is explicitly placed further away, but this camera system jumps over it. Have you also tried keeping track of the current nearest node, and then just testing the previous and next on the rail, to see which is closest? This would scale MUCH better.
@SordidInteractive
@SordidInteractive 7 жыл бұрын
Hi, great video! Is there a way to implement split or multiple paths with this? For some reason, I just seem to be unable to figure it out.
@dmitrykot6185
@dmitrykot6185 7 жыл бұрын
using UnityEngine; public class Rail : MonoBehaviour { private Vector3[] nodes; private int nodeCount; void Start () { nodeCount = transform.GetChildCount(); nodes = new Vector3[nodeCount]; for (int i = 0; i < nodeCount; i++) { nodes[i] = transform.GetChild(i).position; } } // Update is called once per frame void Update () { if (nodeCount > 1) { for (int i = 0; i < nodeCount - 1; i++) { Debug.DrawLine(nodes[i], nodes[i + 1], Color.green); } } } public Vector3 ProjectPositionOnRail(Vector3 pos) { int closestNodeIndex = GetClosestNode(pos); if (closestNodeIndex == 0) { return ProjectOnSegment(nodes[0], nodes[1], pos); } else if (closestNodeIndex == nodeCount - 1) { return ProjectOnSegment(nodes[nodeCount - 1], nodes[nodeCount - 2], pos); } else { Vector3 leftSeg = ProjectOnSegment(nodes[closestNodeIndex - 1], nodes[closestNodeIndex], pos); Vector3 rightSeg = ProjectOnSegment(nodes[closestNodeIndex + 1], nodes[closestNodeIndex], pos); Debug.DrawLine(pos, leftSeg, Color.red); Debug.DrawLine(pos, rightSeg, Color.blue); if ((pos - leftSeg).sqrMagnitude (v2 - v1).sqrMagnitude) { return v2; } else { Vector3 fromV1 = segDirection * distanceFromV1; return v1 + fromV1; } } } using UnityEngine; public class RailMover : MonoBehaviour { public Rail rail; public Transform lookAt; public bool smothMove = true; public float moveSpeed; private Transform thisTransform; private Vector3 lastPosition; void Start () { thisTransform = transform; } void Update () { if (smothMove) { lastPosition = Vector3.Lerp(lastPosition, rail.ProjectPositionOnRail(lookAt.position), Time.deltaTime * moveSpeed); thisTransform.position = lastPosition; } else { thisTransform.position = rail.ProjectPositionOnRail(lookAt.position); } //thisTransform.position = rail.ProjectOnSegment(Vector3.zero, Vector3.forward * 20, lookAt.position); thisTransform.LookAt(lookAt.position); } }
@SheepYT
@SheepYT 6 жыл бұрын
I made it exactly like you did in termes of nodes,capsule and ground placement and my camera instead of following my capsule to the left on the direction of the nodes it stands stil when I move left to right , only if I move in a perpendicular way from the line of nodes and in their direction does the camera goes in that direction.Basically the camera is following my character in the wrong direction.Where could I have made a mistake?
@TheBrownGaming
@TheBrownGaming 5 жыл бұрын
May I have Help? Im Getting a Error Saying [19:23:26] Assets\Rail.cs{125,1): error CS1529: A using clause must procede all other elements defined in the namespace except extern alias declarations
@gutozardy
@gutozardy 6 жыл бұрын
Maybe the GetChildCount method is no longer available. I used transform.childCount.
@n3ken
@n3ken 6 жыл бұрын
This is correct, thank you for the specification
@armin1888
@armin1888 8 жыл бұрын
Thanks alot for the video! Could u make more comments next time? Alot of things were hard to understand :/
@n3ken
@n3ken 8 жыл бұрын
For the next big serie, i plan on commenting out pretty much anything, but its not just yet finished scripting
@asdasdasd9815
@asdasdasd9815 7 жыл бұрын
Can write the script in the comments?
@boshygames2349
@boshygames2349 6 жыл бұрын
can anyone tell me why my camera is shaking?
@niallmccaffrey791
@niallmccaffrey791 6 жыл бұрын
Move the camera first, thn do the LookAt?
@tribbeh
@tribbeh 7 жыл бұрын
Hey I'm wondering is there a way to get the camera to follow the player but stay at a fixed distance away from the player using this method.
Dolly Cam using Cinemachine | Unity
7:57
Omar A. Balfaqih
Рет қаралды 53 М.
Better Jumping in Unity With Four Lines of Code
12:47
Board To Bits Games
Рет қаралды 826 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
The Art of Game Optimization
10:18
Worlds In Motion
Рет қаралды 299 М.
How To Build An Event System in Unity
8:01
Game Dev Guide
Рет қаралды 419 М.
Wall Jump (Wall Bounce) - Game Mechanics - Unity 3D
10:57
N3K EN
Рет қаралды 82 М.
The BEST Mechanical Display You've EVER Seen!!!
13:51
Tin Foil Hat
Рет қаралды 551 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
I Remade Star Wars VFX in 1 Week
10:39
ErikDoesVFX
Рет қаралды 2,8 МЛН
Unity 5 Transform on Rail! - Unity 3D[Tutorial][C#]
39:23
N3K EN
Рет қаралды 44 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН