I’m making a simple game and this error keeps showing up and then just stops me from playing my game:
Skipped updating the transform of this rigidbody because its components are infinte, could you have applied infinite forces, acceleration or set huge velocity?
please help!
@JPhilipp Heres the script and I think its talking about a cylinder object
using UnityEngine;
public class PlayerCollision : MonoBehaviour{
public PlayerMovement movement;
public Rigidbody rb;
void OnCollisionEnter (Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false;
FindObjectOfType<GameManager>().EndGame();
FindObjectOfType<AudioManager>().Play("PlayerDeath");
}
}
}
heres another one
this is the GameManager
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
bool gameHasEnded = false;
public float restartDelay = 100f;
public GameObject completeLevelUI;
public void CompleteLevel ()
{
completeLevelUI.SetActive(true);
}
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log("Game Over");
Invoke("Restart", restartDelay);
// Restart Game
}
}
void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
And there was another problem, in the error list at the script it says : The type or Namespace name ‘sound’ could not be found (are you missing a using directive or an assembly reference?)
using UnityEngine.Audio;
using System;
using UnityEngine;
public class AudioManager : MonoBehaviour {
public Sound sounds;
public static AudioManager instance;
// Use this for initialization
void Awake () {
if (instance == null)
instance = this;
else
{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
foreach (Sound s in sounds)
{
s.source = gameObject.AddComponent<AudioSource>();
s.source.clip = s.clip;
s.source.volume = s.volume;
s.source.pitch = s.pitch;
s.source.loop = s.loop;
}
}
public void Play (string name)
{
Sound s = Array.Find(sounds, sound => sound.name == name);
if (s == null)
{
Debug.LogWarning("Sound: " + name + " not found!");
return;
}
s.source.Play();
}
void Start ()
{
Play("Song");
}
}
Check your collider’s radius. You may have changed in update method ? You probably changed your collider’s radius and it’s going to infinite. This can lead to collide everything at the same time in your scene. That’s why you got that error.