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
@mesolagic3 жыл бұрын
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!
@richterdelgan1239 жыл бұрын
Thanks a lot. dude you save us. all bless you for the eternity and eons.
@n3ken9 жыл бұрын
cheers :)
@petemon699 жыл бұрын
This is awesome. This is exactly what I needed for my game. Thanks a lot.
@n3ken9 жыл бұрын
+petemon69 Glad you like it! I'm upgrading the system a bit, I will release a more versatile version in the upcoming weeks :)
@johnnymcfettsack35525 жыл бұрын
@@n3ken where can i find this upgraded version?
@master2k278 жыл бұрын
Thanks very much! Helped me out alot :)
@celticdragonstudio55609 жыл бұрын
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
@GWKTM2 жыл бұрын
Is there a way to give rail bezier corners?
@GWKTM3 жыл бұрын
How to change it so that it can pick a path on intersections?
@zanekarl83916 жыл бұрын
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!
@niallmccaffrey7916 жыл бұрын
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.
@SordidInteractive7 жыл бұрын
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.
@dmitrykot61857 жыл бұрын
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); } }
@SheepYT6 жыл бұрын
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?
@TheBrownGaming5 жыл бұрын
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
@gutozardy6 жыл бұрын
Maybe the GetChildCount method is no longer available. I used transform.childCount.
@n3ken6 жыл бұрын
This is correct, thank you for the specification
@armin18888 жыл бұрын
Thanks alot for the video! Could u make more comments next time? Alot of things were hard to understand :/
@n3ken8 жыл бұрын
For the next big serie, i plan on commenting out pretty much anything, but its not just yet finished scripting
@asdasdasd98157 жыл бұрын
Can write the script in the comments?
@boshygames23496 жыл бұрын
can anyone tell me why my camera is shaking?
@niallmccaffrey7916 жыл бұрын
Move the camera first, thn do the LookAt?
@tribbeh7 жыл бұрын
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.