12using System.Collections;3using System.Collections.Generic;4using UnityEngine;56[RequireComponent(typeof(Collider))]7public class LootBox : MonoBehaviour
8{9 public GameObject lootBox;10 public GameObject lootReward;1112 private Animator animator;13 private RaycastHit hit;14 private Ray ray;15// Start is called before the first frame update16voidStart()17{18 animator = GetComponent<Animator>();19}2021// Update is called once per frame22voidUpdate()23{24 ray = Camera.main.ScreenPointToRay(Input.mousePosition);2526if(Physics.Raycast(ray, out hit))27{28if(hit.transform.name != gameObject.name)29{30 animator.SetBool("Idle", true);31 animator.SetBool("Hover", false);32333435if(Input.GetMouseButtonDown(0))36{37 animator.SetBool("Open", true);3839}40}41else42{43 animator.SetBool("Idle", false);44 animator.SetBool("Hover", true);4546}4748}49}5051 public voidLootReward()52{53 var loot =Instantiate(lootReward) as GameObject;5455Destroy(lootBox);56}5758}
1// Update is called once per frame2voidUpdate()3{4 ray = Camera.main.ScreenPointToRay(Input.mousePosition);56 var hover = Physics.Raycast(ray, out hit);7if(hover &&(hit.transform.name == gameObject.name))8{9 hover = false;10}1112if(hover)13{14 animator.SetBool("Idle", false);15 animator.SetBool("Hover", true);16}17else18{19 animator.SetBool("Idle", true);20 animator.SetBool("Hover", false);2122if(Input.GetMouseButtonDown(0))23{24 animator.SetBool("Open", true);25}26}27}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/04/22 02:20 編集
2020/04/22 06:50
2020/04/22 09:16
2020/05/03 08:29
2020/05/03 16:25
2020/05/04 04:39
2020/05/05 01:30
2020/05/05 03:25