so I have this game that you play as a cube on top of a platform while other cubes charge towards you and try to knock you of the platform. I have the enemy in a prefab that I summon with a simple spawner script every time and the movement for the enemy is here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyScript : MonoBehaviour{
public Rigidbody rb;
public float speed = 1f;
GameObject player;
void Start(){
player = GameObject.Find("player");
}
// Update is called once per frame
void Update()
{
Vector3 way = (player.transform.position - transform.position) * Time.deltaTime;
way.y = 0;
rb.AddForce(Vector3.Normalize(way)*speed*20);
}
}
the problem is that when I run it as a simple test the enemies move in enormously fast and then when I build the same game the enemies move enormously slow. is this a well known problem or am I doing something wrong?
,so I have this game that you play as a cube on top of a platform while other cubes charge towards you and try to knock you of the platform. i have the enemy in a prefab that I summon with a simple spawner script every time and the movement for the enemy is here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyScript : MonoBehaviour{
public Rigidbody rb;
public float speed = 1f;
GameObject player;
void Start(){
player = GameObject.Find("player");
}
// Update is called once per frame
void Update()
{
Vector3 way = (player.transform.position - transform.position) * Time.deltaTime;
way.y = 0;
rb.AddForce(Vector3.Normalize(way)*speed*20);
}
}
the problem is that when I run it as a simple test the enemies move in enormously fast and then when I build the same game the enemies moves enormously slow. is this a well known problem or am I doing something wrong.