Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
111
KeyValue pair C#
svitch
How to find the first index of a sub-string in a given string?
fds
Intuit // C# // listing_4.4 (StreamReader // input.txt)
C# request sending cookie with request using httpclient
Dokkan Awaken Calculator 1.1
mnnjhjhjbhjb
linked list reversal recursive
Please log in to post a comment.