Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Chest Interaction Unity
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChestScript : MonoBehaviour { public GameObject player; public Animator animator; bool inRange = false; float interactRange = 1.5f; void Update() { if (inRange != true) { animator.SetBool(“IsOpen”, false); } TestRange(); OpenClose(); } void TestRange() { if (Vector2.Distance(player.transform.position, this.transform.position) <= interactRange) { inRange = true; animator.SetBool("InRange", true); } else { inRange = false; animator.SetBool("InRange", false); } } void OpenClose() { if (Input.GetKeyDown(KeyCode.E)) { if (inRange) { if (animator.GetBool("IsOpen") { animator.SetBool("IsOpen", false); } else { animator.SetBool("IsOpen", true); } } } } void OnDrawGizmosSelected() { Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(this.transform.position, interactRange); } }
run
|
edit
|
history
|
help
0
Simple Selection Sort
Planet-D ver. 0.7
4/03/2017
Hello
Const
sdfgtrewqdsc sdzdxsd
JagArray
Update 2D Array
sdfghjuyhtgrfedsdf
Intuit // C# // Lecture_4 // Laba_#1