Profile

Cover photo
Karolis Strazdas
Lives in Anyksciai
1 follower|313 views
AboutPostsPhotosYouTube

Stream

Karolis Strazdas

commented on a video on YouTube.
Shared publicly  - 
 
using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
    public Transform target;
    public int moveSpeed;
    public int rotationSpeed;

    private Transform myTransform;
    void awake (){
        myTransform = transform;
        }

    // Use this for initialization
    void Start () {
        GameObject go = GameObject.FindGameObjectWithTag ("Player");
        target = go.transform;
    }
    
    // Update is called once per frame
    void Update () {
                Debug.DrawLine (target.position, myTransform.position, Color.yellow);
    
                //look at target
                myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position, myTransform.position), rotationSpeed * Time.deltaTime);
        }
    }

Whats wrong here? I got Null reperence Exception error: "NullReferenceException
UnityEngine.Transform.get_position () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/UnityEngineTransform.cs:27)
EnemyAI.Update () (at Assets/Scripts/EnemyAI.cs:22)"
1
sparda060's profile photoKarolis Strazdas's profile photo
2 comments
 
+sparda060 Thanks! :D
Add a comment...
Have him in circles
1 person
People
Have him in circles
1 person
Basic Information
Gender
Male
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Anyksciai
Links