Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can i fix this error (31,22) primary constructor body is not allllowed

Discussion in 'Getting Started' started by Shadowman507, Aug 18, 2017.

  1. Shadowman507

    Shadowman507

    Joined:
    Sep 2, 2015
    Posts:
    5
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class EasyAI : MonoBehaviour {

    public float fpsTargetDistance;
    public float enemyLookDistance;
    public float attackDistance;
    public float enemyMovementSpeed;
    public float damping;
    public Transform fpsTarget;
    Rigidbody theRigidBody;
    Renderer myRender;

    void Start () {
    myRender = GetComponent<Renderer> ();
    theRigidBody = GetComponent<Rigidbody> ();
    }

    void Update () {
    fpsTargetDistance = Vector3.Distance (fpsTarget.position, transform.position);
    if(fpsTargetDistance<enemyLookDistance){
    myRender.material.color = Color.yellow;
    lookAtPlayer();
    print("Look At The Player");
    }
    }


    void lookAtPlayer();{
    Quaternion RotationDriveMode = Quaternion.LookRotation(fpsTarget.position - Transform.position);

    }
    }
     
  2. Shadowman507

    Shadowman507

    Joined:
    Sep 2, 2015
    Posts:
    5
    fixed it, now im getting another error
     
  3. Shadowman507

    Shadowman507

    Joined:
    Sep 2, 2015
    Posts:
    5
    ok all solved now
     
  4. Dave-Carlile

    Dave-Carlile

    Joined:
    Sep 16, 2012
    Posts:
    967