I have a pretty simple, basically right off a tutorial, 2D scene in Unity. It contains only movement scripts for the camera, player, and an enemy. 16x16 sprites, small test scene, and nothing going on other than player movement and the enemy moving towards the player. I have the Pixel Perfect Camera experimental package, but disabling it doesn’t seem to help at all.
Basically, when I run the game in the Unity editor the game is very slow. I have the player’s movement set at an int of 15, and it moves at a slow walk across the scene. However, if I build the game and run it, the player (and enemy) sprints across the screen with the same move speed. My movement scripts contain the normal Time.deltaTime, so I’m not sure why this is happening. Granted, I’m not on the best laptop ever, but I don’t think I should be seeing these huge differences in movement.
I’m quite new to unity so maybe I’m missing something completely obvious. Thanks in advance!
Player Movement script (enemy is very similar):
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private SpriteRenderer mySprite;
private Rigidbody2D myRigidbody;
private Animator myAnimator;
// Start is called before the first frame update
void Start()
{
mySprite = GetComponent<SpriteRenderer>();
myRigidbody = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
Vector3 change = Vector3.zero;
change.x = Input.GetAxisRaw("Horizontal");
change.y = Input.GetAxisRaw("Vertical");
if (change != Vector3.zero)
{
MoveCharacter(change);
myAnimator.SetFloat("MoveX", change.x);
myAnimator.SetFloat("MoveY", change.y);
myAnimator.SetBool("Moving", true);
}
else
{
myAnimator.SetBool("Moving", false);
}
}
void MoveCharacter(Vector3 change)
{
Vector3 temp = transform.position + (change * speed * Time.deltaTime);
myRigidbody.MovePosition(temp);
}
}