My Script just won't work at all?
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;
 
     }
 
 
              dont call FixedUpdate() from your Update() method. FixedUpdate is called automatically from unity. dont use FixedUpdate at all for non-physical-things. it won't give you any benefit.
from your code: ControlScript->InputValue is always 0 so your Turn-method will always compute turn = 0 
Your answer
 
             Follow this Question
Related Questions
cannot convert double to int when trying to increment another script's variable by 0.10 1 Answer
Cant access variables outside of On Click() function 1 Answer
Error CS1525: Unexpected symbol 'else' 1 Answer
onClick.AddListener IndexOutOfRangeException error and listener not seen in inspector 0 Answers