Instantiated Players Transform Not Changing
Hello, I've been trying to fix this issue all night but can't seem to figure it out. I am attempting to write a code that respawns the player at his last position on a gameobject with the tag "checkpoint" however his transform stays the same. It is worth noting I am using UNET and I made this script derived from NetworkBehaviour as I probably will make references to it if I get this fixed. It might be do to the fact that the network transform is teleporting the player back but I've tried fiddling with that and still no luck. I also tried making a command function and having that called with no luck either. Any help is appreciated! Thank you guys.
using UnityEngine;
using UnityEngine.Networking;
public class respawn : NetworkBehaviour
{
Vector3 checkpointPos;
void Start()
{
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Checkpoint"))
{
Debug.Log("Player Entered Checkpoint: " + checkpointPos);
checkpointPos = transform.position;
}
if (collision.gameObject.CompareTag("Ground"))
{
Debug.Log("Respawned Player: " + transform.position);
transform.position = checkpointPos;
}
}
}
Your answer
Follow this Question
Related Questions
dedicated server 0 Answers
UNET Clients Laggy 0 Answers
[UNet] Network Animator transition stutters 0 Answers
UNET (Multiplayer) calling [command] function twice 0 Answers
Bullets showing only on host and weapons not appearing 3 Answers