Please help fix my code

ERRORS:
CS0029- (6,41) Cannot implicitly invert type “float” to “UnityEngine.transform”
CS0029- (7,41) Cannot implicitly invert type “float” to “UnityEngine.transform”

using UnityEngine;
using System.Collections;

public class RespawnScript : MonoBehaviour
{
[SerializeField] Transform player = 0f;
[SerializeField] Transform respawnPoint = 0f;

void OnTriggerEnter(Collider other)
{
player.transform.position = respawnPoint.transform.position;
}
}

Hello

Transform is not float.

Christoph

Please use code tags to make your code more readable.

If you wish to reset the transform position of a GameObject use:

transform.position = Vector3.zero

A Vector3 is essentially 3 floats that relate to the x, y, z co-ordinates of your transform. So if you wanted finer control you could use:

transform.position = new Vector3 (0, 10, 0)
1 Like