User Tools

Site Tools


informatica:realidad_virtual:unity:3apersona

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

informatica:realidad_virtual:unity:3apersona [2023/04/02 15:35] – created joseinformatica:realidad_virtual:unity:3apersona [2023/04/03 17:51] (current) jose
Line 1: Line 1:
 +tags: 3apersona tercera 3a
 +
 ====== Abrir puerta ====== ====== Abrir puerta ======
  
Line 5: Line 7:
 https://www.youtube.com/watch?v=BZZ6C97e7s0 https://www.youtube.com/watch?v=BZZ6C97e7s0
  
 +====== Movimiento ======
 +<code>
 +using System.Collections;
 +using System.Collections.Generic;
 +using UnityEngine;
 +using UnityEngine.AI;
 +
 +public class CharacterMovementScript : MonoBehaviour
 +{
 +    public NavMeshAgent playerNavMeshAgent;
 +
 +    public Camera playerCamera;
 +
 +    public Animator playerAnimator;
 +    public bool isRunning;
 +    public bool isDeath;
 +
 +    // Start is called before the first frame update
 +    void Start()
 +    {
 +        
 +    }
 +
 +    // Update is called once per frame
 +    void Update()
 +    {
 +        bool isDeath = playerAnimator.GetBool("isDeath");
 +        if (Input.GetMouseButton(0) && !isDeath)
 +        {
 +            Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition);
 +            RaycastHit myRaycastHit;
 +
 +            if(Physics.Raycast(myRay, out myRaycastHit))
 +            {
 +                playerNavMeshAgent.SetDestination(myRaycastHit.point);
 +
 +            }
 +        }
 +
 +        if (playerNavMeshAgent.remainingDistance <= playerNavMeshAgent.stoppingDistance)
 +        {
 +            isRunning = false;
 +        }
 +        else
 +        {
 +            isRunning = true;
 +        }
 +        playerAnimator.SetBool("isRunning",isRunning);
 +    }
  
 +}
 +</code>
informatica/realidad_virtual/unity/3apersona.1680449738.txt.gz · Last modified: 2023/04/02 15:35 by jose