Комментарии:
I've made a few door tutorials in the past before, but I always like to improve upon the methods I teach in my videos, thus why I'm making another door tutorial. The scripts I make in this video are a lot cleaner in my opinion and the main door script in particular can be used for opening/closing doors, wardrobes, closets, drawers, cupboards, etc.
Scripts:
Player Raycast script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerRaycast : MonoBehaviour
{
public GameObject crosshair;
public float interactionDistance;
public LayerMask layers;
void Update()
{
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit, interactionDistance, layers))
{
if (hit.collider.gameObject.GetComponent<door>())
{
crosshair.SetActive(true);
if (Input.GetKeyDown(KeyCode.E))
{
hit.collider.gameObject.GetComponent<door>().openClose();
}
}
else
{
crosshair.SetActive(false);
}
}
else
{
crosshair.SetActive(false);
}
}
}
Door script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class door : MonoBehaviour
{
bool toggle;
public Animator anim;
public void openClose()
{
toggle = !toggle;
if(toggle == false)
{
anim.ResetTrigger("open");
anim.SetTrigger("close");
}
if (toggle == true)
{
anim.ResetTrigger("close");
anim.SetTrigger("open");
}
}
}
this actually worked unlike the other tutorial you have
ОтветитьNice
Ответить[[[[[ PAY REAL ATTENTION TO THIS: THE "KEY" TO CREATE MULTIPLE DOORS WITH THE SAME ANIMATOR AND THE SAME SCRIPT IS IN MIN 6, the hierarchy of the game objects of the door]]] This is a very good tutorial!
ОтветитьWhy it does not work ? I did the code, placement and animation perfectly.
ОтветитьThank you so much works perfectly
ОтветитьTo see the crosshair you almost have to walk in the door. Could you help me with that?
Ответитьthank you so much bro! This really helped!
Ответитьtutorial on how to add open and close sound to the door please?
ОтветитьDoes the this game is for you series actually steal your date or is that just to scare people.
ОтветитьCan you please show me how to make a interactable laptop in unity. I would appreciate is allot.
ОтветитьCan you create tutorial for objectives that player must do. if the player pressed 'Tab' all the objectives will be shown and when the player do that certain task, it will disappear. Thank you so much
ОтветитьCan you create tutorial for objectives that player must do. if the player pressed 'Tab' all the objectives will be shown and when the player do that certain task, it will disappear. Thank you so much
ОтветитьWill there ever be a foreboding tales 2? It’s one of my favorite games made by you
ОтветитьProtect this guy at all cost
ОтветитьCan you do a tutorial how to do this cool thing in My Friendly Neighborhood. When you open the door. It plays an animation of you entering the room then loads a diffrent scene... If it's possible.
ОтветитьWould be useful if VS were in dark mode and abit zoomed.
ОтветитьYo what was the first game you made and published
ОтветитьI’m just saying but what if in the next this game is for you installment the bunny takes over the players phone and locks them in there house.
ОтветитьThis is a great tutorial
ОтветитьHow much you earn bro please 🥺
ОтветитьTy now ik how to do it
Ответить