Hello all! I am very new to coding here and am having an issue with a mobile game I am attempting to make...
`using UnityEngine;
using System.Collections;
public class CameraControl : MonoBehaviour
{
public float rotSpeed = -0.25f;
public float Decay = 0.25f;
private float rightSpin = 0f;
private float leftSpin = 0f;
private float startPos = 0f;
private float endPos = 0f;
void Update()
{
%|1698064057_9|%
{
Touch swipe = Input.touches[0];
switch (TouchPhase);
{
if (swipe = TouchPhase.Began);
Touch swipe = Input.GetTouch (0);
startPos = (swipe.position.x);
else TouchPhase.Moved;
Touch swipe = Input.GetTouch (0);
rightSpin = (Input.touches[0].deltaPosition.x * rotSpeed);
leftSpin = (Input.touches[0].deltaPosition.x * rotSpeed);
transform.Rotate(Vector3.back, Input.touches[0].deltaPosition.x * rotSpeed);
break;
else TouchPhase.Ended;
endPos = TouchPhase.Ended;
{
if (startPos > endPos) //left swipe
while (leftSpin < 0f)
{
transform.Rotate(Vector3.back, leftSpin * rotSpeed);
leftSpin = (leftSpin + Decay);
}
%|43898681_37|%
else (startPos > endPos); //right swipe
while (rightSpin > 0f)
{
transform.Rotate(Vector3.back, rightSpin * rotSpeed);
rightSpin = (rightSpin - Decay);
}
}
%|112795636_47|%
}
}
}
//wake me up`
So what I'm trying to have happen, is when the player swipes either left or right the camera will rotate with the swipe. When the player's finger leaves the screen the camera should continue to move with the momentum from the swipe and slow to a stop. I'm having issues with line 21
`switch (TouchPhase); `
{ expected
line 23 `if (swipe = TouchPhase.Began);`
Possible mistaken empty statment
31 and 42
else TouchPhase.Moved;
Invalid expression of term else, as well as Expected ;
↧