Answer the question
In order to leave comments, you need to log in
Unity how to remove duplicate objects?
When I press W, only the object is duplicated (the player, but only visually), and when I attached the camera, the surrounding objects themselves were duplicated!
Here is the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class moving : MonoBehaviour {
public GameObject obj;
private float speed = 5f;
private Rigidbody2D rb;
private Vector3 directionY;
private void Awake(){
rb = GetComponent <Rigidbody2D> ();
}
private void Update () {
if (Input.GetKey (KeyCode.W)) {
directionY = transform.up;
transform.position = Vector3.MoveTowards (transform.position + directionY, transform.position,speed * Time.deltaTime);
} else if (Input.GetKey (KeyCode.D)) {
}
}
}
Answer the question
In order to leave comments, you need to log in
You have "Depth only" or "Don't Clear" on your camera 's clearFlags , so all your objects draw plumes. Install Solid Color or Skybox, then there will be no such problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question