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; 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
Please
log in
to post a comment.
test
test2
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦
Find duplicates in a given integer array
30272 Program Ex7_1 switch_int
xml
Plt-D v.0.9.6 (Speed Vector)
c# with mysql
1stoccuinsorted
Adding two arrays and print it out..the crude approach
Please log in to post a comment.