-2
using System.Collections.Generic;
using UnityEngine;

public class DinoYonDuzeltme : MonoBehaviour
{
    public LayerMask katman;
    public DinoHareket hareket;
    public Transform dino;
    void Start()
    {
        hareket = GetComponent<DinoHareket>();
        dino = transform.parent;
    }

    void Update()
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, 0.1f, katman);
        if(hit.collider == null)
        {
            dino.localScale = new Vector3(dino.localScale.x * -1, dino.localScale.y, dino.localScale.z);
            hareket.hiz *= -1f;
        }
    }
}

so this is the code and I get a error called this if you know please help me, Im trying to make a enemy mob turn around

derHugo
  • 83,094
  • 9
  • 75
  • 115
Akashial
  • 1
  • 1
  • 1
    [Please include errors as text not as images.](https://idownvotedbecau.se/imageofanexception/) – Ruzihm Sep 17 '20 at 16:11
  • As I can't tell by the line number of the error, I'm not quite sure. Does the `DinoHareket` class contain a `hiz` property? – Luc Sep 17 '20 at 16:56
  • So either `dino` or `hareket` is not set to a reference but `null` – derHugo Sep 18 '20 at 06:43

1 Answers1

0

I suppose it's the line

hareket.hiz *= -1f;

It must be because

    GetComponent<DinoHareket>();

is null, meaning you forgot to add the DinoHareket component to your object.

Entapsia
  • 51
  • 4