The bool activates and deactivates but the script in the if statement doesn´t work
So the problem is that the bools movingLeft and movingRight activate and deactivate correctly with the event trigger pointer down and pointer up put in 2 different images, but the camera doesn´t move. What i want to do is that the camera moves constantly while the player is pressing the image and doesn´t just make one move.
This is the Touch Controls script (the pause void works fine):
private CameraController Camera;
private PauseMenu pauseMenu;
private bool movingLeft;
private bool movingRight;
// Use this for initialization
void Start () {
Camera = FindObjectOfType<CameraController> ();
pauseMenu = FindObjectOfType<PauseMenu> ();
}
public void LeftMove ()
{
movingLeft = true;
}
public void RightMove ()
{
movingRight = true;
}
public void NoTouchL ()
{
movingLeft = false;
}
public void NoTouchR ()
{
movingRight = false;
}
public void Pause ()
{
pauseMenu.PauseUnpause();
}
void FixedUpdate ()
{
if (movingLeft = true)
{
Camera.Move(-1);
}
if (movingRight = true)
{
Camera.Move(1);
}
}
}
And this is the camera script:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
public float turnSpeed = 4.0f;
private Vector3 offset;
public bool isNotPaused;
public DeathMenu deathMenu;
public PauseMenu pauseMenu;
// Use this for initialization
void Start () {
FindObjectOfType<DeathMenu> ();
FindObjectOfType<PauseMenu> ();
offset = transform.position - player.transform.position;
}
void FixedUpdate () {
if (deathMenu.isDead || pauseMenu.isPaused) {
isNotPaused = false;
}
else
{
isNotPaused = true;
}
if (isNotPaused)
{
Move (Input.GetAxis("Horizontal"));
}
transform.position = player.transform.position + offset;
transform.LookAt(player.transform.position);
}
public void Move (float moveInput)
{
offset = Quaternion.AngleAxis (moveInput * turnSpeed, Vector3.up) * offset;
}
}
Answer by Daviant · Aug 30, 2015 at 03:13 PM
Thanks for answering, but the voids are being called, i put the voids on public to check if it was working and they get checked.
aptura2.png
Your answer
Follow this Question
Related Questions
Tutorial 3.1-7 "&& isOnGround == true" 0 Answers
Bools not changing... 0 Answers
Issue with if-statements requiring two conditions. 1 Answer
how do i say this 1 Answer
if statements are running when they are not suppose to be 1 Answer