Help with script!!!
Hello Someone suggested me a script I finally found out how to use the scipt :) but then I got an error... Heres the full error. Assets/Scripts/PlayerController.cs(11,25): error CS1525 Unexpected symbol '(' Also here the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
private Vector3 direction = Vector3.left;
private void Update()
{
if ( /* touch */ )
direction = -direction;
}
}
Also I was told to add an if statement and parenthesis by some other people but I didn't know where to write it. Sorry for the
Inside of the condition of your if statement, you just have a comment - so technically you have no condition specified in your if-statement. Hexagonius is completely right - you need to give some type of condition, and based on the comment, it sounds like your trying to make a "touch" condition in your if-statement.
Answer by doVa09 · Mar 21, 2017 at 03:27 PM
You must have a boolean return in If statement, so comment is invalid. Just declare a bool for example : isTouched and add it between parenthesis and error is gone.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
private Vector3 direction = Vector3.left;
private bool isTouched;
private void Update()
{
if ( isTouched )
direction = -direction;
}
}
Your answer
Follow this Question
Related Questions
How can I make touch input work on my IPhone? 1 Answer
Is my Touch Algorithm right? 0 Answers
Rotate object by touch using Angles? 0 Answers
New input system and touch on webgl 1 Answer
How to replace KeyCode.Space with a simple tap on Android? 1 Answer