Hello, i am getting error "CS1514" With this code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PortalManager : MonoBehaviour

    public Transform APos;
    public Transform BPos;


    private void onTriggerEnter(Collider col)
    {
        if (col.CompareTag("Portal Blue"))
        CharacterControl cc = GetComponent<CharacterController>();

        cc.enabled = false;
        transform.position = BPos.transform.position;
        (transform.rotation = BPos.transform.rotationtion.x, Bpos.rotation.y, transform.rotation.z, transform.rotation.w);

        cc.enabled = true



    }       
        if (col.CompareTag("Portal Orange"))
       {
           CharacterController cc = GetCpmponent<CharacterController>();

           cc.enabled = false
           transform.position =APos.transform.position
           transform.rotation =new Quaternion(transform.rotation.x, Bpos.rotation.y, transform.rotation.z, transform.rotation.w);

           cc.enabled = true

       }



}

and for the non psychic amongst us, what does the full error text say, cos it will be telling you which line and character it has found the problem at… and what that number means…

But Id guess line 15 moaning cc has not been defined

Agreed, mind-reading exercise. But take your pick. This code is a mess. If you're following a tutorial without understanding code, you have to be precise.

  • Line 11: onTriggerEnter is not capitalized correctly to be called by Unity
  • Line 14: declaring a variable is not a valid single-statement if-block body
  • Line 18: assignment statement begins with parenthesis, mis-spells rotation, has a comma-separated list of values
  • (also Line 18: trying to use quaternion elements individually, bad practice)
  • Line 25: starting an if-block outside of a method
1 Like

There are a few things wrong with your code. You can start with putting a { on line 6.

1 Like