My script is designed so when a button is clicked, the sprite will move 45 degrees. when another button is clicked, the same sprite will move -45 degrees. The scripit has no errors but the variable wont show up in the onclick funtion of the button? Please help. Here is my script:
using UnityEngine;
using System.Collections;
public class PlatformBehaviour : MonoBehaviour {
/* ATTACH THIS AS A CHILD TO "Platform" gameObject*/
public float turnSpeed = 40f;
public ControlScript control;
private float currentAngle;
void Start()
{
control = GetComponent<ControlScript>(); //this references the ControlScript so you can use it for the rest of the script
currentAngle = 0f;
}
void Update(){
if (control.currentAngle >= control.maxBlueAngle && control.currentAngle <= control.maxRedAngle)
FixedUpdate();
}
void FixedUpdate()
{
Turn();
}
void Turn(){
float turn = control.InputValue * turnSpeed * Time.deltaTime;
Quaternion rotation = Quaternion.Euler(0f, 0f, turn);
}
}
using UnityEngine;
using System.Collections;
public class ControlScript : MonoBehaviour {
public float maxBlueAngle = -45f;
public float maxRedAngle = 45f;
public int InputValue;
public int currentValue;
public float currentAngle;
void Start(){
currentValue = 0;
}
void BlueRotate(){
currentValue = -1;
currentAngle -= 1f;
}
void RedRotate(){
currentValue = 1;
currentAngle += 1f;
}