I was coding on movement for my sidescroller like Game. after I finished everything worked fine, except moving the ship past the point where it was when the Game started would make it invisible for some Reason.here is a Gif showing that : http://shadow.bplaced.com/gifs/wtf.gif
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour {
public GameObject Player;
public GameObject Player_Movement_Point;
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown(0))
{
Player.transform.parent = null;
Player_Movement_Point.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.x));
}
if (Input.GetMouseButton(0))
{
if(Player.transform.parent == null)
{
Player.transform.parent = Player_Movement_Point.transform;
}
Player_Movement_Point.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.x));
}
}
}
can someone tell me what causes this ? ![]()
btw, when I move it in the Editor it works, and when I use transform.position to tp it to the middle it doesnt work.