Beginner in C# - Simple Rotation Script
Hi all,
I'm a beginner in C#, and am running Unity VR Enabled Executables through my Vive Headset. I'm trying to incorporate more behaviors into my VR files, and am writing a very simple script to press down the Vive Controller Trigger and have my .obj (object) rotate with trigger held down.
My compiler gives me the same error twice :
Delegate "ClickedEventsHandler" Does not take '1' Arguments.
Delegate "ClickedEventsHandler" Does not take '1' Arguments.
Here is the script :
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour
{
SteamVR_TrackedController controller;
public float turnSpeed = 50f;
public float GetButtonDown;
public event ClickedEventHandler TriggerButtonDown;
void Update ()
{
if (TriggerButtonDown(Input.GetButtonDown));
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
if (!TriggerButtonDown(Input.GetButtonUp));
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime * 0);
}
}
I know this is a very simple problem, but I would love to hear what I am doing wrong if anybody has some advice.
Many thanks!
Did, you tested to handle Trigger button pressing before it? Did you write all necessary code lines for it? For example check this article: https://unity3d.college/2016/11/16/s$$anonymous$$mvr-controller-input/
It seems you have a problem with TriggerButtonDown.
Answer by UnbreakableOne · Jun 11, 2018 at 05:47 PM
I'm not sure as I can't test if for myself and I'm not familiar with it but searching around I think you're following this.
My best guess is that you need to "subscribe" (also known as "register") to the event handler. Something like:
private void OnEnable()
{
_controller.TriggerClicked += TriggerEventHandler;
}
So you don't use them directly. If this is not clear, read about event management.
OR
Delete that public event ClickedEventHandler TriggerButtonDown;
line.
Your answer
Follow this Question
Related Questions
Switch between 5 cameras in the game by clicking. 0 Answers
why the Timer isn't working 0 Answers
I can't figure out why this variable is not updating 0 Answers
Rotating an object with VR controller 1 Answer
Start() and Update() execution issue 6 Answers