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; float interactRange = 1.5f; private bool inRange = false; 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)) & (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
Reed Solomon Demo
C# first code
4
ref variables/parameters
Public access specifier
t
diagonal
axasxasxasaxsd
Examples of JS-Like higher-order functions in C#
Stacks: Balanced Brackets