I’ve used the following code in Javascript for using the numeric 2 button to call a trigger in my scene and i want to know what the equivalent way to write it would be for C#
If(Input.GetKeyDown(KeyCode.Alpha2)){
I want to have it here instead of being on mouse down, on the same call as above- on 2 being pressed on the keyboard.
Void OnMouseDown ()
Is there a library anywhere which has this kind of thing listed?
I managed to figure out what I was doing at long last! I stuck to rearranging the code and eventually found a helpful topic, this is a code to open doors with this script attached to them at the press of a keyboard key! In this example, key “2” will open it:
using UnityEngine;
using System.Collections;
public class passdoorfront : MonoBehaviour
{
bool b = true;
private Vector3 v3To;
void Update () {
if(Input.GetKeyDown(KeyCode.Alpha2))
{
SetOpenClose (b);
b = !b;
}
}
void SetOpenClose(bool bOpen) {
if (bOpen) {
iTween.MoveBy(gameObject, iTween.Hash("z", 0.7, "easeType", "easeInOutExpo", "delay", 1, "Speed", 0.2));
}
else {
iTween.MoveBy(gameObject, iTween.Hash("z", -0.7, "easeType", "easeInOutExpo", "delay", 1, "Speed", 0.2));
}
}
}