I really do hope you come back to this series one day. Your FPS controller is genuinely one of the best I've found. It'd be awesome to see this go on to more mechanics like an inventory system, further interactions, triggers, dialogue scenes, cut scenes and more base line mechanics that you see in games. Rewind or Die was awesome by the way, and I have End Of The Line wishlisted! All the best
If you are facing the issue of the door opening correctly one way but not the other, it could be because the door's front and back are on the x-axis. In the door script, for the doorTransformDirection, instead of Vector3.forward, use Vector3.right. Or simply change your door's front and back to the z axis
@@coolgamerguy436 I've already managed to fix this by simply selecting experimental apply transform in blender export. I forgot that I already had the same issue, and that was the same solution.
Great tutorial series! Love building upon earlier systems. A tip for folks reading this, since it came up in the video, the default hot keys for toggling the transform tool handles position between pivot/center and local/world are 'Z' and 'X' respectively.
You've helped out a ton. I love the series. Are you going to make more videos?? If you do, could you please do one with adding a player model, and potentially objects, like either a gun or throwables that the player can use.
i generally do it with animations and trigger boxes and i prevent bugs with the animation opening and closing by itself but i think this tutorial is much more practical and optimised
This series has been great, thanks a lot! Only one thing missing from this series is picking up objects and throwing them around with the interaction system in place. I can't seem to make it work smoothly
For some reason my door only opens one way (only plays the OpenOut and CloseFromOut animations). And when i change the dot parameters in animator (from ClosedIdle to OpenIn to less 0, and from ClosedIdle to OpenOut to greater 0) it will play the other way around, so it will only play the OpenIn and CloseFromIn. Do you know any fix to that?
youre the best , a little suggestion ( when the player is crouched he still can jump , so u could disable can jump if the player is crouched . Or when the player is crouched and jump he directly stand and jump but the time to do it will be higher than if he is standing,) thanks a lot for those tutorials :D
In HandleJump on the FirstPersonController, add " && !isCrouching" to the if statement with ShouldJump. Then it will only jump if the player is not crouching and should jump.
I would love to see you continue and expand on these videos if you ever get the time. Regardless, thanks for the great tutorials and hope you're doing well!
Absolutely fantastic!! Just finished the entire series and have an awesome playercontroller now! You should make a climbing tutorial next to expand on this! Great job!!
For those of you who can only get the door to open correctly one way and have to click and an angle for the other direction you need to make sure that the 2 sides of the door are aligned on the Z axis because that is the axis we are checking using the dot product.
Adding on to this, to have your door face in any direction, put into an empty GameObject, I called mine "DoorHolder" and rotate that object instead of the actual door.
@@vaqquixx8620 For some reason my door only opens one way (only plays the OpenOut and CloseFromOut animations). And when i change the dot parameters in animator (from ClosedIdle to OpenIn to less 0, and from ClosedIdle to OpenOut to greater 0) it will play the other way around, so it will only play the OpenIn and CloseFromIn. Do you know any fix to that?
For some reason my door only opens one way (only plays the OpenOut and CloseFromOut animations). And when i change the dot parameters in animator (from ClosedIdle to OpenIn to less 0, and from ClosedIdle to OpenOut to greater 0) it will play the other way around, so it will only play the OpenIn and CloseFromIn. Do you know any fix to that?
Hey, I really love your tutorials! But I have a few questions. | 1. Would this work in a horror game? | 2. Could you possibly make an animation tutorial so we can have a player model? | 3. Could you possibly make a tools tutorial? | Your tutorials are awesome and keep up the good work!
I know I m a bit late but you are the only one that can help me now. I m stuck for days now trying to make the character stay on a moving object. I m trying to make a zeppelin that you will control in the game but I can't even get the character to stay on moving cube. I hope you read this and maybe give me an answer. And btw it's the 3 time I m watching your tutorial series it's just to good :)
The usual trick is to have your character become a child game object of the platform or in your case the zeppelin. There are a lot of resources about this subject so I won't go into too much detail, use a raycast or a trigger area to detect the platform and parent/unparent accordingly.
@@Krwatkins0002 thanks for the responds, but the problem is I already did that and the character becomes a child but when I move it in the scene myself the character will not stay on there for long and doesn't move the same distance as the platform. And if I add force to the platform through code the player will just stay and the platform slide under him away
@@cliptimechaos6920 Oof sorry, yeah it seems whenever CharacterController.Move() is called it'll cancel out any movement of a parent game objects transform. Looking like you'll have to match the direction and speed of the platform to the player whenever you detect a player on one. I'm not there yet myself in my prototype and I'm used to using rigid bodies when I figure something out I'll try to remember and post it here. Don't hold your breath tho, I get sidetracked like no other!
Do you also make the maps in Blender? I'd love it if you could make a video about the workflow you use, and whatever tip & tricks you might have up your sleeve. I'm tempted to try using TrenchBroom, because I can never get along with Blender for map making (because of texturing complications). But maybe Blender is fine and I'm just missing something, I dunno.
I've just finished and have to say i really enjoyed the learning experience as well as getting a FPC i fully understand & can customise and use. I'm going to add things like an option screen message like 'Press to open door' when interaction becomes available, optional auto-close door, enums for options like tags and layers, optional crosshair or dot in the centre of the screen, and a few other things, so once again thanks
Super duper useful series man, kudos! If you haven't done it yet, or haven't thought of doing it, could you maybe do a series or a single video on finite state machines? They seem super useful and scalable, which was the point of this series as well, to make the script scalable.
Could you also do videos on UIs such as main menu screens, pause menu screens, inventory, etc. That would be amazing. Keep up the good work! Hope to see this series come back!
For some reason my door only opens one way (only plays the OpenOut and CloseFromOut animations). And when i change the dot parameters in animator (from ClosedIdle to OpenIn to less 0, and from ClosedIdle to OpenOut to greater 0) it will play the other way around, so it will only play the OpenIn and CloseFromIn. Do you know any fix to that?
Hey uhh amazing tutorial dude :D but currently i'm having an issue where my door animation gets stuck from Idle to open basically it gets on a loop of door opening
My door appears to open in one direction only UNLESS I interact while I jump. I've double-checked all my code and can't seem to find any error. Any fix for this?
I have a doubt sir. In my game, I am having a shooting bar. Which means , If I hold the shoot button, then the shooting bar gets decreased and if the bar is at 0 then the player should stop shooting. And the shooting bar regenerates. Problem is if I press the shoot button it is decreasing but it is not stopping to shoot. It is continuously shooting after bar is at 0 while holding the button. And I solved this problem by using setactive. But after that, another problem came, that is, if I press the button, it is not shooting after the bar is 0, yeah that's fine, but the bullets are only disabled, so it is creating many disabled bullets in hierarchy. What should I do sir plz 😥😥
Great tutorial! I am having one issue though; when looking directly at the door straight on from either side, it only plays the 'open in' and 'close from in' animations. But when I look at the door from an angular position, it will play the 'open out' and close from out' animations. Not sure where I goofed but any help would be appreciated! Again, thank you for all of the tutorials!
Holy shit I have no idea how I managed to add that in there... I play that kinda stuff for my dog because I love his reactions 😂 must have been drunk... Good spot though!
Hi, if you walk on the diagonal, the player has more speed than walking just in one direction? because i don't see you normalizing the move input vector
I have checked my Interactable script it is working but when press E or any other... to open doors it does not work. My DOOR script:using System.Collections; using System.Collections.Generic; using UnityEngine; public class DOOR : Interactable { private bool isOpen = false; private bool canBeInteractedWith = true; private Animator anim; private void Start() { anim = GetComponent(); } public override void OnFocus() { } public override void OnInteract() { if (canBeInteractedWith) { isOpen = !isOpen; Vector3 doorTransformDirection = transform.TransformDirection(Vector3.forward); Vector3 playerTransformDirection = PlayerMovement.instance.transform.position = transform.position; float dot = Vector3.Dot(doorTransformDirection, playerTransformDirection); anim.SetFloat("dot", dot); anim.SetBool("isOpen", isOpen); } } public override void OnLoseFocus() { } } My Interactable script: using System.Collections; using System.Collections.Generic; using UnityEngine; public abstract class Interactable : MonoBehaviour { public virtual void Awake() { gameObject.layer = 9; } public abstract void OnFocus(); public abstract void OnInteract(); public abstract void OnLoseFocus(); } and script: [Header("Interactable")] [SerializeField] private Vector3 interactionRayPoint = default; [SerializeField] private float interactionDistance = default; [SerializeField] private LayerMask interactionLayer = default; private Interactable currentInteractable; also (void Update) if (canInteract) { HandleInteractionCheck(); HandleInteractionInput(); } also private void HandleInteractionCheck() { if (Physics.Raycast(playerCamera.ViewportPointToRay(interactionRayPoint), out RaycastHit hit, interactionDistance)) { if (hit.collider.gameObject.layer == 9 && (currentInteractable == null || hit.collider.gameObject.GetInstanceID() != currentInteractable.GetInstanceID())) { hit.collider.TryGetComponent(out currentInteractable); if (currentInteractable) currentInteractable.OnFocus(); } } else if (currentInteractable) { currentInteractable.OnLoseFocus(); currentInteractable = null; } } Edit: in console I get no errors. I checked animations.... everything is fine.
Your line at "Vector3 playerTransformDirection = PlayerMovement.instance.transform.position = transform.position;" is wrong. It should be "Vector3 playerTransformDirection = PlayerMovement.instance.transform.position - transform.position;" with a substract at the end instead of equals
I really dislike the method you use. Using animation to open doors is all wrong because should you need to make changes in the environment, you will have to change the animation. If you used translate it in a direction based on some serialised values in the door script then it would be kind of procedural door opening and you can apply that to multiple doors facing different directions. Also, I would make use of unity events just so that this same interaction could be leveraged to use multiple types of objects with similar movement.
Ive made it easier by a script: private void OpenDoor() { if (doorTransform != null) { Quaternion targetRotation = isDoorOpen ? initialRotation : initialRotation * Quaternion.Euler(0f, doorOpenAngle, 0f); // Drehe die Tür zur Zielrotation StartCoroutine(RotateDoor(targetRotation)); // Aktualisiere den Zustand der Tür isDoorOpen = !isDoorOpen; } } private IEnumerator RotateDoor(Quaternion targetRotation) { float duration = 1.0f; float elapsedTime = 0f; Quaternion startRotation = doorTransform.localRotation; while (elapsedTime < duration) { doorTransform.localRotation = Quaternion.Lerp(startRotation, targetRotation, elapsedTime / duration); elapsedTime += Time.deltaTime; yield return null; } doorTransform.localRotation = targetRotation; } With that and the interact script ive made an switch case for all interactable things ;-)
it works, just not according to where I'm standing. my code is correct isn't it? I've checked it over twice now. public class Door : Interactable { private bool isOpen = false; private bool canBeInteractedWith = true; private Animator anim; private void Start() { anim = GetComponent(); } public override void OnFocus() { } public override void OnInteract() { if (canBeInteractedWith) { isOpen = !isOpen; Vector3 doorTransformDirection = transform.TransformDirection(Vector3.forward); Vector3 playerTransformDirection = FirstPersonController.instance.transform.position - transform.position; float dot = Vector3.Dot(doorTransformDirection, playerTransformDirection); anim.SetFloat("dot", dot); anim.SetBool("isOpen", isOpen); } } public override void OnLoseFocus() { } AND, in FirstPersonController.cs I have public static FirstPersonController instance; under the private float rotationX = 0; AND instance = this; in awake please help :)
I'm having the same issue; looking at the door straight ahead, it only plays the open in animation and pushes your character out of the way. If I look toward the hinge of the door at an angle, it plays the correct animation.