Sunday, September 25, 2022
HomeGame Developmentc# - My participant strikes again after i cease any person enter...

c# – My participant strikes again after i cease any person enter in Unity


Within the first scene(grass scene), the participant works advantageous within the grass scene, however inside the home, the participant after any enter the participant strikes again a bit.

https://i.imgur.com/aHXwCR7.mp4

my participant motion script is beneath.

utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
 
public class playeMovement : MonoBehaviour
{
 
 
 
    //public Animator animator;
 
    public float moveSpeed = 5f;
 
    public Rigidbody2D rb;
    public Animator animator;
 
    Vector2 motion;
 
    public static playeMovement occasion;
 
    public string areaTransitionName;
 
    public void Awake()
    {
        if(occasion == null)
        {
 
        }
        else
        {
            Destroy(gameObject);
        }
 
        occasion = this;
 
        DontDestroyOnLoad(gameObject);
 
    }
 
    public void Replace()
    {
 
        motion.x = Enter.GetAxisRaw("Horizontal");
        motion.y = Enter.GetAxisRaw("Vertical");
 
        animator.SetFloat("Horizontal", motion.x);
        animator.SetFloat("Vertical", motion.y);
        animator.SetFloat("Pace", motion.sqrMagnitude);
 
    }
 
    non-public void FixedUpdate()
    {
 
        rb.MovePosition(rb.place + motion * moveSpeed * Time.fixedDeltaTime);
 
    }
 
 
 
 
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments