MelloDaMonke4221
can anyone see if this c# script is right for gorilla tag
using UnityEngine;
using System.Collections;
public class AdminBanGun : MonoBehaviour
{
public LineRenderer lineRenderer;
public float maxDistance = 10f;
private bool isLineVisible = false; void Start() { if (lineRenderer == null) { Debug.LogError("LineRenderer is not assigned."); return; } lineRenderer.positionCount = 2; // Set the number of positions in the line lineRenderer.enabled = false; // Initially disable the line renderer } void Update() { UpdateLine(); // Update the line position HandleInput(); // Check for user input } private void HandleInput() { float gripValue = ControllerInputPoller.instance.right.Controller.index.grip; float triggerValue = ControllerInputPoller.instance.right.Controller.index.trigger; if (gripValue > 0.2f) { if (!isLineVisible) { isLineVisible = true; // Show the line if grip is pressed lineRenderer.enabled = true; } } else { if (isLineVisible) { isLineVisible = false; // Hide the line if grip is released lineRenderer.enabled = false; } } if (triggerValue > 0.2f && isLineVisible) { StartCoroutine(DelayBanUser(12345)); // Example user ID } } void UpdateLine() { if (isLineVisible) { lineRenderer.SetPosition(0, transform.position); // Set start position lineRenderer.SetPosition(1, transform.position + transform.forward * maxDistance); // Set end position } } private IEnumerator DelayBanUser(int userId) { PerformAction(userId); // Perform the ban action yield return new WaitForSeconds(6 * 60 * 60); // Wait for 6 hours } private void PerformAction(int userId) { Debug.Log("User banned: " + userId); // Log the ban action } }
private bool isLineVisible = false; void Start() { if (lineRenderer == null) { Debug.LogError("LineRenderer is not assigned."); return; } lineRenderer.positionCount = 2; // Set the number of positions in the line lineRenderer.enabled = false; // Initially disable the line renderer } void Update() { UpdateLine(); // Update the line position HandleInput(); // Check for user input } private void HandleInput() { float gripValue = ControllerInputPoller.instance.right.Controller.index.grip; float triggerValue = ControllerInputPoller.instance.right.Controller.index.trigger; if (gripValue > 0.2f) { if (!isLineVisible) { isLineVisible = true; // Show the line if grip is pressed lineRenderer.enabled = true; } } else { if (isLineVisible) { isLineVisible = false; // Hide the line if grip is released lineRenderer.enabled = false; } } if (triggerValue > 0.2f && isLineVisible) { StartCoroutine(DelayBanUser(12345)); // Example user ID } } void UpdateLine() { if (isLineVisible) { lineRenderer.SetPosition(0, transform.position); // Set start position lineRenderer.SetPosition(1, transform.position + transform.forward * maxDistance); // Set end position } } private IEnumerator DelayBanUser(int userId) { PerformAction(userId); // Perform the ban action yield return new WaitForSeconds(6 * 60 * 60); // Wait for 6 hours } private void PerformAction(int userId) { Debug.Log("User banned: " + userId); // Log the ban action } }
12 replies