Player becomes invisible after transform.position change,I cant see my Player after transform.position change.
I'm trying to make a game with "Death Blocks" that move the player to the respawn point after triggering the OnTrigger method. Here is the code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class DeathBlock : MonoBehaviour
{
public GameObject respawnPoint;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name == "Player")
{
collision.gameObject.transform.position = respawnPoint.transform.position;
}
}
}
,In a game that i'm making, i want to have "Death Blocks" which triggers the OnTrigger method that moves the player to the spawn point. Here is the code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class DeathBlock : MonoBehaviour
{
public GameObject respawnPoint;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name == "Player")
{
collision.gameObject.transform.position = respawnPoint.transform.position;
}
}
}
Your answer
Follow this Question
Related Questions
Transform.find Does not work 0 Answers
How to turn off isTrigger when on Entering and turn on isTrigger on Exiting. 1 Answer
How can i make my object go back to its start position? 3 Answers
Object moves when game starts, but shouldn't until player collides with trigger 0 Answers
Resetting my cannon fire to its original transform 0 Answers