Answer the question
In order to leave comments, you need to log in
Missing using directive or c# assembly reference?
using System.Collections.Generic;
using UnityEngine;
public class MovePlayer : MonoBehavior
{
public Transform player;
[SerializeField]
private float speed = 10f;
private void OnMouseDrag()
{
if (!player. lose )ERROR
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.x = mousePos.x > 2.5f ? 2.5f : mousePos.x;
mousePos.x = mousePos.x < -2.5f ? -2.5f : mousePos.x;
player.position = Vector2.MoveTowards(player.position,
new Vector2(mousePos.x, player.position.y), speed * Time.deltaTime);
}
}
}
ERROR, code for Unity
Missing using directive or assembly reference !
Answer the question
In order to leave comments, you need to log in
Let's try to learn and explain)))
Here is your code from the comments to another answer (to make it clearer what other people are talking about)
public class player : MonoBehaviour
{
public static bool lose = false;
private void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.tag == "bomb")
lose = true;
}
//public Transform player;
public SomeClassName someObjectRef;
//////
//bool flagFromStatic = player.lose;
bool flagFromStatic = SomeClass.staticVariableInClass;
bool flagFromClassObject = someObjectRef.nonStaticVariableInClass;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question