Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Installing URP broke my playercontroller

Discussion in 'Editor & General Support' started by Unity-Artcraft, May 16, 2023.

  1. Unity-Artcraft

    Unity-Artcraft

    Joined:
    Jul 28, 2018
    Posts:
    85
    I installed URP and now the controls of my player is broken :( :( :( Player is jiggering (no camera controls) and moving on its own. I don't know what to do/

    Edit I solved it, only thing I had to do was restarting Unity... and I wasted one hour on this...

    my scene:

    upload_2023-5-16_3-46-0.png

    Player Code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerScript : MonoBehaviour
    6. {
    7.     Rigidbody2D rb;
    8.  
    9.     [SerializeField] float movespeed = 10;
    10.  
    11.     //float smoothSpeed = 0.5f;
    12.  
    13.     Vector2 movement;
    14.     Vector2 currentInputVector;
    15.     Vector2 currentVelocity;
    16.  
    17.     private void Awake()
    18.     {
    19.         rb = GetComponent<Rigidbody2D>();
    20.     }
    21.  
    22.     private void Update()
    23.     {
    24.         float moveX = Input.GetAxis("Horizontal");
    25.         float moveY = Input.GetAxis("Vertical");
    26.  
    27.         //movement = new Vector2(moveX, moveY).normalized;
    28.         //currentInputVector = Vector2.SmoothDamp(currentInputVector, movement, ref currentVelocity, smoothSpeed);
    29.  
    30.         movement = new Vector2(moveX, moveY);
    31.  
    32.         movement = Vector2.ClampMagnitude(movement, 1);
    33.  
    34.     }
    35.     private void FixedUpdate()
    36.     {
    37.         rb.velocity = new Vector2(movement.x * movespeed, movement.y * movespeed);
    38.     }
    39. }
     
    Last edited: May 16, 2023