Search Unity

Can't move player, even in scene view?

Discussion in '2D' started by jleven22, Jan 19, 2020.

  1. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    I have duplicated a scene with my player. In the original everything is working fine.

    When I play the new scene, I cannot seem to move my player. I can't even move it in the Scene View using the Move Tool. The player just seems to jitter in place when I try and move.

    The only change I have made is created a new tilemap, but there are no colliders in the way of the player. In fact, if I stop, move the player out of the tilemap area, and then press play, I still get the same issue.

    What could be causing this? Thanks!
     
  2. dquek

    dquek

    Unity Technologies

    Joined:
    Apr 17, 2018
    Posts:
    70
    Hi there,
    Could you upload a sample project via bug reporter so we can take a look and investigate this issue?
    This helps us to debug the issue much faster.
    ====
    You can file a bug report with a sample repro project through = Unity > Help > Report a Bug...

    Cheers,
    Darren
     
  3. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    Well I just decided to start from scratch. Not sure what happened there but when I duplicated the scene a second time, everything worked fine! Seems like a bug, but I can't seem to replicate it.
     
  4. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    Here's a look at the issue I'm experiencing.
    https://imgur.com/a/21idBtk

    Here is the code that is instantiating the player switch:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CharacterSelector : MonoBehaviour
    6. {
    7.     private bool canSelect;
    8.  
    9.     public GameObject message;
    10.  
    11.     public PlayerController playerToSpawn;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.        
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {
    22.         if (canSelect)
    23.         {
    24.             if (Input.GetKeyDown(KeyCode.E))
    25.             {
    26.                 Vector3 playerPosition = PlayerController.instance.transform.position;
    27.  
    28.                 Destroy(PlayerController.instance.gameObject);
    29.  
    30.                 PlayerController newPlayer = Instantiate(playerToSpawn, playerPosition, playerToSpawn.transform.rotation);
    31.                 PlayerController.instance = newPlayer;
    32.  
    33.                 gameObject.SetActive(false);
    34.  
    35.                 CameraController.instance.target = newPlayer.transform;
    36.             }
    37.         }
    38.     }
    39.  
    40.     private void OnTriggerEnter2D(Collider2D other)
    41.     {
    42.         if(other.tag == "Player")
    43.         {
    44.             canSelect = true;
    45.             message.SetActive(true);
    46.         }
    47.     }
    48.  
    49.     private void OnTriggerExit2D(Collider2D other)
    50.     {
    51.         if (other.tag == "Player")
    52.         {
    53.             canSelect = false;
    54.             message.SetActive(false);
    55.         }
    56.     }
    57. }
    58.