Whenever I try to run my code the console says "Assets\player.cs(30,64): error CS1003: Syntax error, ',' expected".
I am new to C# and I'm currently learning Unity, so this is all new to me. I have overlooked my code a dozen times, but I can't find the problem.
The function of this piece of code is to set boundaries to limit the place where the player can move to.
Here's the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour
{
public float speed;
// Start is called before the first frame update
void Start()
{
transform.position = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update()
{
// Boundaries
if (transform.position.y >= 3.66)
{
transform.position = new Vector3(transform.position.x, 3.66f, 0);
}
else if (transform.position.y <= -3.47)
{
transform.position = new Vector3(transform.position.x, -3.47f, 0);
}
if (transform.position.x >= 4)
{
transform.position = new Vector3(transform.position.4, y, 0);
}
// Movement
transform.Translate(Vector3.right * Time.deltaTime * speed * Input.GetAxis("Horizontal"));
transform.Translate(Vector3.up * Time.deltaTime * speed * Input.GetAxis("Vertical"));
}
}
CodePudding user response:
