informatica:realidad_virtual:unity:3apersona
Differences
This shows you the differences between two versions of the page.
informatica:realidad_virtual:unity:3apersona [2023/04/02 15:35] – created jose | informatica: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:// | https:// | ||
+ | ====== Movimiento ====== | ||
+ | < | ||
+ | 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(" | ||
+ | if (Input.GetMouseButton(0) && !isDeath) | ||
+ | { | ||
+ | Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition); | ||
+ | RaycastHit myRaycastHit; | ||
+ | |||
+ | if(Physics.Raycast(myRay, | ||
+ | { | ||
+ | playerNavMeshAgent.SetDestination(myRaycastHit.point); | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | if (playerNavMeshAgent.remainingDistance <= playerNavMeshAgent.stoppingDistance) | ||
+ | { | ||
+ | isRunning = false; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | isRunning = true; | ||
+ | } | ||
+ | playerAnimator.SetBool(" | ||
+ | } | ||
+ | } | ||
+ | </ |
informatica/realidad_virtual/unity/3apersona.1680449738.txt.gz · Last modified: 2023/04/02 15:35 by jose