Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Player gets stuck if enemy hits him and death particles don't show

Discussion in 'Scripting' started by DustyShinigami, Jun 23, 2019.

  1. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    I've no idea what or how this has happened as both were perfectly fine not long ago. But I've discovered that if my player walks into an enemy and gets hit, they get stuck in place. Pressing left or right makes the player walk on the spot and facing in the same direction.
    Also, I'm always having issues with the particle effects in Unity where they just don't show. The particles when firing my weapon work, they work when collectibles are picked up, they work when enemies take damage or die, but they don't show when the player dies. The preview works, if I place the object in the scene and tick Play on Awake, they show, but I see nothing when they player dies. I even attached the prefab to my player and I have them instantiated each time the player dies.

    This is my PlayerController script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class PlayerController : MonoBehaviour
    7. {
    8.     public Animator anim;
    9.     public float moveSpeed;
    10.     public float jumpForce;
    11.     public bool jumped;
    12.     public bool allowInteract = false;
    13.     public float gravityScale;
    14.     public float knockBackForce;
    15.     public float knockBackTime;
    16.     public float invincibilityLength;
    17.     public Renderer playerRenderer;
    18.     //public Material textureChange;
    19.     //public Material textureDefault;
    20.     public bool allowCombat;
    21.     public bool allowJump;
    22.     public static bool canMove;
    23.     public ChestTrigger chest;
    24.  
    25.     private Vector2 moveDirection;
    26.     private Vector2 moveHorizontal;
    27.     private float knockBackCounter;
    28.     private float invincibilityCounter;
    29.     private CharacterController controller;
    30.     private Quaternion targetRot;
    31.     private bool headingLeft = false;
    32.     private Pickup pickupWeapon;
    33.  
    34.     void Awake()
    35.     {
    36.         controller = GetComponent<CharacterController>();
    37.         anim = GetComponent<Animator>();
    38.     }
    39.  
    40.     void Start()
    41.     {
    42.         Cursor.visible = false;
    43.         pickupWeapon = FindObjectOfType<Pickup>();
    44.         canMove = true;
    45.         targetRot = transform.rotation;
    46.         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("start_area"))
    47.         {
    48.             allowCombat = false;
    49.             allowJump = true;
    50.         }
    51.         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("hut_interior"))
    52.         {
    53.             allowCombat = false;
    54.             allowJump = false;
    55.         }
    56.         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("start_area 2"))
    57.         {
    58.             allowCombat = false;
    59.             allowJump = true;
    60.         }
    61.         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("level 1, room 1"))
    62.         {
    63.             allowCombat = true;
    64.             allowJump = true;
    65.         }
    66.         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("level 1, room 2"))
    67.         {
    68.             allowCombat = true;
    69.             allowJump = true;
    70.         }
    71.     }
    72.  
    73.     void Update()
    74.     {
    75.         if (knockBackCounter <= 0 && canMove)
    76.         {
    77.             moveHorizontal.x = Input.GetAxis("Horizontal");
    78.             //moveVertical.y = Input.GetAxis("Vertical");
    79.             moveDirection = new Vector2(moveHorizontal.x * moveSpeed, moveDirection.y);
    80.             controller.Move(moveDirection * Time.deltaTime);
    81.  
    82.             //Adds character rotation when changing direction horizontally
    83.             if ((moveHorizontal.x < 0f && !headingLeft) || (moveHorizontal.x > 0f && headingLeft))
    84.             {
    85.                 if (moveHorizontal.x < 0f) targetRot = Quaternion.Euler(0, 270, 0);
    86.                 if (moveHorizontal.x > 0f) targetRot = Quaternion.Euler(0, 90, 0);
    87.                 headingLeft = !headingLeft;
    88.             }
    89.             transform.rotation = Quaternion.Lerp(transform.rotation, targetRot, Time.deltaTime * 20f);
    90.             //Adds character rotation when changing direction vertically
    91.             /*if(moveVertical.y < 0f && lookingUp || (moveVertical.y > 0f && !lookingUp))
    92.             {
    93.                 if (moveVertical.y > 0f) targetrot = Quaternion.Euler(0, 0, 0);
    94.                 if (moveVertical.y < 0f) targetrot = Quaternion.Euler(0, 180, 0);
    95.                 lookingUp = !lookingUp;
    96.             }*/
    97.         }
    98.         else if (SceneManagement.insideHut && canMove)
    99.         {
    100.             float moveHorizontalSnap = Input.GetAxis("Horizontal");
    101.             float moveVerticalSnap = Input.GetAxis("Vertical");
    102.             //Adds character rotation when changing direction horizontally, but snaps instead of fully rotating
    103.  
    104.             if (moveHorizontalSnap > 0)
    105.             {
    106.                 transform.eulerAngles = new Vector2(0, 90);
    107.             }
    108.             else if (moveHorizontalSnap < 0)
    109.             {
    110.                 transform.eulerAngles = new Vector2(0, -90);
    111.             }
    112.             //To possibly prevent diagonal movement with some control setups, try adding 'else if'
    113.             //Adds character rotation when changing direction vertically, but snaps instead of fully rotating
    114.  
    115.             else if (moveVerticalSnap > 0)
    116.             {
    117.                 transform.eulerAngles = new Vector2(0, 0);
    118.             }
    119.             //Use this to make the character face towards the camera.
    120.             /*else if (moveVertical < 0)
    121.             {
    122.                 transform.eulerAngles = new Vector3(0, 180);
    123.             }*/
    124.         }
    125.         if (controller.isGrounded)
    126.         {
    127.             if (allowJump)
    128.             {
    129.                 moveDirection.y = -1f;
    130.                 //GetKeyDown will require the player to press the button each time they want to jump. GetKey will allow the player to spam the jump button if they keep pressing it down.
    131.                 if (Input.GetKeyDown(KeyCode.KeypadPlus))
    132.                 {
    133.                     moveDirection.y = jumpForce;
    134.                     jumped = true;
    135.                 }
    136.                 else if (!Input.GetKeyDown(KeyCode.KeypadPlus))
    137.                 {
    138.                     jumped = false;
    139.                 }
    140.                 if (SceneManagement.xbox360Controller == 1)
    141.                 {
    142.                     if (Input.GetKeyDown("joystick button 0"))
    143.                     {
    144.                         moveDirection.y = jumpForce;
    145.                         jumped = true;
    146.                     }
    147.                     else if (!Input.GetKeyDown("joystick button 0"))
    148.                     {
    149.                         jumped = false;
    150.                     }
    151.                 }
    152.                 else if (SceneManagement.ps4Controller == 1)
    153.                 {
    154.                     if (Input.GetKeyDown("joystick button 1"))
    155.                     {
    156.                         moveDirection.y = jumpForce;
    157.                         jumped = true;
    158.                     }
    159.                     else if (!Input.GetKeyDown("joystick button 1"))
    160.                     {
    161.                         jumped = false;
    162.                     }
    163.                 }
    164.             }
    165.  
    166.             if (allowCombat)
    167.             {
    168.                 if (Input.GetKeyDown(KeyCode.Space))
    169.                 {
    170.                     anim.SetTrigger("Attack");
    171.                 }
    172.                 else if (SceneManagement.xbox360Controller == 1)
    173.                 {
    174.                     if (Input.GetKey("joystick button 1"))
    175.                     {
    176.                         anim.SetTrigger("Attack");
    177.                     }
    178.                 }
    179.                 else if (SceneManagement.ps4Controller == 1)
    180.                 {
    181.                     if (Input.GetKey("joystick button 2"))
    182.                     {
    183.                         anim.SetTrigger("Attack");
    184.                     }
    185.                 }
    186.             }
    187.  
    188.             if (allowInteract)
    189.             {
    190.                 if (Input.GetKeyDown(KeyCode.Return))
    191.                 {
    192.                     anim.SetBool("Interact", controller.isGrounded);
    193.                     pickupWeapon.ObjectActivation();
    194.                     allowInteract = false;
    195.                 }
    196.                 else if (SceneManagement.xbox360Controller == 1)
    197.                 {
    198.                     if (Input.GetKeyDown("joystick button 2"))
    199.                     {
    200.                         anim.SetBool("Interact", controller.isGrounded);
    201.                         pickupWeapon.ObjectActivation();
    202.                         allowInteract = false;
    203.                     }
    204.                 }
    205.                 else if (SceneManagement.ps4Controller == 1)
    206.                 {
    207.                     if (Input.GetKeyDown("joystick button 0"))
    208.                     {
    209.                         anim.SetBool("Interact", controller.isGrounded);
    210.                         pickupWeapon.ObjectActivation();
    211.                         allowInteract = false;
    212.                     }
    213.                 }
    214.             }
    215.             if (ChestTrigger.allowOpen)
    216.             {
    217.                 if (Input.GetKeyDown(KeyCode.Return))
    218.                 {
    219.                     anim.SetBool("Interact", controller.isGrounded);
    220.                     chest.ChestOpen();
    221.                 }
    222.                 else if (Input.GetKeyDown(KeyCode.Return) && !ChestTrigger.allowOpen)
    223.                 {
    224.                     anim.SetBool("Interact", false);
    225.                 }
    226.                 else if (SceneManagement.xbox360Controller == 1)
    227.                 {
    228.                     if (Input.GetKeyDown("joystick button 2"))
    229.                     {
    230.                         anim.SetBool("Interact", controller.isGrounded);
    231.                         chest.ChestOpen();
    232.                     }
    233.                     else if (Input.GetKeyDown("joystick button 2") && !ChestTrigger.allowOpen)
    234.                     {
    235.                         anim.SetBool("Interact", false);
    236.                     }
    237.                 }
    238.                 else if (SceneManagement.ps4Controller == 1)
    239.                 {
    240.                     if (Input.GetKeyDown("joystick button 0"))
    241.                     {
    242.                         anim.SetBool("Interact", controller.isGrounded);
    243.                         chest.ChestOpen();
    244.                     }
    245.                     else if (Input.GetKeyDown("joystick button 0") && !ChestTrigger.allowOpen)
    246.                     {
    247.                         anim.SetBool("Interact", false);
    248.                     }
    249.                 }
    250.             }
    251.         }
    252.         else
    253.         {
    254.             knockBackCounter -= Time.deltaTime;
    255.         }
    256.         moveDirection.y = moveDirection.y + (Physics.gravity.y * gravityScale * Time.deltaTime);
    257.  
    258.         anim.SetBool("isGrounded", controller.isGrounded);
    259.         //If the character can't move, then the Speed is set to 0. Otherwise it'll use the horizontal input value.
    260.         anim.SetFloat("Speed",
    261.             !canMove
    262.             ? 0f
    263.             : Mathf.Abs(Input.GetAxis("Horizontal")));
    264.  
    265.         //anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis("Horizontal")));
    266.  
    267.         /*if (interact)
    268.         {
    269.             if (Input.GetKeyDown(KeyCode.Return))
    270.             {
    271.                 anim.SetBool("Interact", controller.isGrounded);
    272.                 FindObjectOfType<Pickup>().ObjectActivation();
    273.                 interact = false;
    274.                 allowInteract = false;
    275.             }
    276.         }*/
    277.     }
    278.  
    279.     public void Knockback(Vector3 direction)
    280.     {
    281.         knockBackCounter = knockBackTime;
    282.  
    283.         moveDirection = direction * knockBackForce;
    284.         moveDirection.y = knockBackForce;
    285.     }
    286. }
    My HealthManager script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.SceneManagement;
    6.  
    7. public class HealthManager : MonoBehaviour
    8. {
    9.     //The counters will count down and will keep counting down based on the length variables
    10.     public int maxHealth;
    11.     public int currentHealth;
    12.     public float invincibilityLength;
    13.     public Renderer playerRenderer;
    14.     public float flashLength;
    15.     public float respawnLength;
    16.     public GameObject deathEffect;
    17.     public Image blackScreen;
    18.     public float fadeSpeed;
    19.     public float waitForFade;
    20.  
    21.     private float invincibilityCounter;
    22.     private float flashCounter;
    23.     private bool isRespawning;
    24.     private Vector3 respawnPoint;
    25.     private bool isFadetoBlack;
    26.     private bool isFadefromBlack;
    27.     private PlayerController thePlayer;
    28.     private Quaternion startPosition;
    29.  
    30.     void Start()
    31.     {
    32.         thePlayer = FindObjectOfType<PlayerController>();
    33.         currentHealth = maxHealth;
    34.         respawnPoint = thePlayer.transform.position;
    35.         startPosition = thePlayer.transform.rotation;
    36.     }
    37.  
    38.     void Update()
    39.     {
    40.         //These functions are checked every frame until the player takes damage
    41.         if(invincibilityCounter > 0)
    42.         {
    43.             invincibilityCounter -= Time.deltaTime;
    44.             flashCounter -= Time.deltaTime;
    45.             if(flashCounter <= 0)
    46.             //The Flash Counter is currently set at 0.1 and will be within the 0 region as it counts down. During this period, the playerRenderer will alternate between on and off
    47.             {
    48.                 playerRenderer.enabled = !playerRenderer.enabled;
    49.                 //The Flash Counter will keep counting down and reloop depending on the Flash Length time
    50.                 flashCounter = flashLength;
    51.             }
    52.             //This makes sure after the flashing and invincibility has worn off that the player renderer is always turned back on so you can see the player
    53.             if(invincibilityCounter <= 0)
    54.             {
    55.                 playerRenderer.enabled = true;
    56.             }
    57.         }
    58.         if (isFadetoBlack)
    59.         {
    60.             blackScreen.color = new Color(blackScreen.color.r, blackScreen.color.g, blackScreen.color.b, Mathf.MoveTowards(blackScreen.color.a, 1f, fadeSpeed * Time.deltaTime));
    61.             if (blackScreen.color.a == 1f)
    62.             {
    63.                 isFadetoBlack = false;
    64.             }
    65.         }
    66.         if (isFadefromBlack)
    67.         {
    68.             blackScreen.color = new Color(blackScreen.color.r, blackScreen.color.g, blackScreen.color.b, Mathf.MoveTowards(blackScreen.color.a, 0f, fadeSpeed * Time.deltaTime));
    69.             if (blackScreen.color.a == 0f)
    70.             {
    71.                 isFadefromBlack = false;
    72.             }
    73.         }
    74.     }
    75.  
    76.     public void HurtPlayer(int damage, Vector3 direction)
    77.     {
    78.         //If the invincibility countdown reaches zero it stops, making you no longer invincible and prone to taking damage again
    79.         if (invincibilityCounter <= 0)
    80.         {
    81.             currentHealth -= damage;
    82.             if (currentHealth <= 0)
    83.             {
    84.                 Respawn();
    85.             }
    86.             else
    87.             {
    88.                 thePlayer.Knockback(direction);
    89.                 invincibilityCounter = invincibilityLength;
    90.                 playerRenderer.enabled = false;
    91.                 flashCounter = flashLength;
    92.             }
    93.         }
    94.     }
    95.  
    96.     public void Respawn()
    97.     {
    98.         //A StartCoroutine must be set up before the IEnumerator can begin
    99.         if (!isRespawning)
    100.         {
    101.  
    102.             StartCoroutine("RespawnCo");
    103.         }
    104.     }
    105.  
    106.     //IEnumerators or Coroutines will execute the code separately at specified times while the rest of the code in a codeblock will carry on executing as normal
    107.     public IEnumerator RespawnCo()
    108.     {
    109.         if (!Checkpoint.checkpointActive)
    110.         {
    111.             isRespawning = true;
    112.             thePlayer.gameObject.SetActive(false);
    113.             Instantiate(deathEffect, respawnPoint, startPosition);
    114.             yield return new WaitForSeconds(respawnLength);
    115.             isFadetoBlack = true;
    116.             yield return new WaitForSeconds(waitForFade);
    117.             isFadefromBlack = true;
    118.             isRespawning = false;
    119.             thePlayer.gameObject.SetActive(true);
    120.             currentHealth = maxHealth;
    121.             invincibilityCounter = invincibilityLength;
    122.             playerRenderer.enabled = false;
    123.             flashCounter = flashLength;
    124.             SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    125.             GameManager.currentEmbers = 0;
    126.         }
    127.  
    128.         else if (Checkpoint.checkpointActive)
    129.         {
    130.             isRespawning = true;
    131.             thePlayer.gameObject.SetActive(false);
    132.             Instantiate(deathEffect, respawnPoint, startPosition);
    133.             yield return new WaitForSeconds(respawnLength);
    134.             isFadetoBlack = true;
    135.             yield return new WaitForSeconds(waitForFade);
    136.             isFadefromBlack = true;
    137.             isRespawning = false;
    138.             thePlayer.gameObject.SetActive(true);
    139.             thePlayer.transform.position = respawnPoint;
    140.             thePlayer.transform.rotation = startPosition;
    141.             currentHealth = maxHealth;
    142.             invincibilityCounter = invincibilityLength;
    143.             playerRenderer.enabled = false;
    144.             flashCounter = flashLength;
    145.         }
    146.     }
    147.  
    148.     public void HealPlayer(int healAmount)
    149.     {
    150.         currentHealth += healAmount;
    151.         if(currentHealth > maxHealth)
    152.         {
    153.             currentHealth = maxHealth;
    154.         }
    155.     }
    156.  
    157.     public void SetSpawnPoint(Vector3 newPosition)
    158.     {
    159.         respawnPoint = newPosition;
    160.     }
    161. }
    HurtPlayer script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HurtPlayer : MonoBehaviour {
    6.  
    7.     public int damnageToGive = 10;
    8.  
    9.     private void OnTriggerEnter(Collider other)
    10.     {
    11.         if(other.gameObject.tag == "Player")
    12.         {
    13.             Vector3 hitDirection = other.transform.position - transform.position;
    14.             hitDirection = hitDirection.normalized;
    15.             FindObjectOfType<HealthManager>().HurtPlayer(damnageToGive, hitDirection);
    16.         }
    17.     }
    18. }
    And EnemyController:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AI;
    5.  
    6. public class EnemyController : MonoBehaviour
    7. {
    8.     //public Transform thePlayer;
    9.     public Animator anim;
    10.     public float moveSpeed;
    11.     public float rotSpeed;
    12.     public Transform startPoint;
    13.     public Transform target;
    14.     public int maxHealth;
    15.     public float currentHealth = 30;
    16.     public float invincibilityLength;
    17.     public Renderer enemyRenderer;
    18.     public float flashLength;
    19.     public ParticleSystem enemyDamage;
    20.     public HealthManager theHealthManager;
    21.  
    22.     private float invincibilityCounter;
    23.     private float flashCounter;
    24.     private CapsuleCollider enemyCollider;
    25.     private bool moveLeft;
    26.     private bool canMove;
    27.  
    28.     void Awake()
    29.     {
    30.         anim = GetComponent<Animator>();
    31.         enemyCollider = GetComponent<CapsuleCollider>();
    32.     }
    33.  
    34.     void Start()
    35.     {
    36.         //thePlayer = GameObject.FindGameObjectWithTag("Player").transform;
    37.         canMove = true;
    38.         currentHealth = maxHealth;
    39.     }
    40.  
    41.     void Update()
    42.     {
    43.         if (invincibilityCounter > 0)
    44.         {
    45.             invincibilityCounter -= Time.deltaTime;
    46.             flashCounter -= Time.deltaTime;
    47.             if (flashCounter <= 0)
    48.             {
    49.                 enemyRenderer.enabled = !enemyRenderer.enabled;
    50.                 flashCounter = flashLength;
    51.             }
    52.             if (invincibilityCounter <= 0)
    53.             {
    54.                 enemyRenderer.enabled = true;
    55.             }
    56.         }
    57.         if (canMove)
    58.         {
    59.             if (moveLeft)
    60.             {
    61.                 transform.position = Vector3.MoveTowards(transform.position, startPoint.position, moveSpeed * Time.deltaTime);
    62.                 transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 270f, 0f), rotSpeed * Time.deltaTime);
    63.             }
    64.             else if (!moveLeft)
    65.             {
    66.                 transform.position = Vector3.MoveTowards(transform.position, target.position, moveSpeed * Time.deltaTime);
    67.                 transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), rotSpeed * Time.deltaTime);
    68.             }
    69.             if (transform.position == target.position)
    70.             {
    71.                 anim.SetBool("isFloating", true);
    72.                 anim.SetFloat("Speed", 0.2f);
    73.                 moveLeft = true;
    74.             }
    75.             else if (transform.position == startPoint.position)
    76.             {
    77.                 anim.SetBool("isFloating", true);
    78.                 anim.SetFloat("Speed", 0.2f);
    79.                 moveLeft = false;
    80.             }
    81.         }
    82.     }
    83.     public void Damage(float amount)
    84.     {
    85.         if (invincibilityCounter <= 0)
    86.         {
    87.             currentHealth -= amount;
    88.             enemyDamage.Play();
    89.             if (currentHealth <= 0)
    90.             {
    91.                 enemyDamage.Play();
    92.                 StartCoroutine("EnemyDeath");
    93.             }
    94.             else
    95.             {
    96.                 invincibilityCounter = invincibilityLength;
    97.                 enemyRenderer.enabled = false;
    98.                 flashCounter = flashLength;
    99.             }
    100.         }
    101.     }
    102.     public IEnumerator EnemyDeath()
    103.     {
    104.         transform.localScale += new Vector3(5f, 5f, 5f) * Time.deltaTime;
    105.         enemyCollider.enabled = false;
    106.         Instantiate(theHealthManager.deathEffect, transform.position, transform.rotation);
    107.         yield return new WaitForSeconds(0.5f);
    108.         Destroy(gameObject);
    109.     }
    110. }
    111.  
     
  2. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    Totally baffled with this. I have nothing to go on as to why the character gets stuck if an enemy hits it. I've loaded up an older build of the project where it doesn't happen, and I've tried putting the code back the way it was, but it hasn't made any difference. I can't see anything that stands out. Animations and colliders appear to be set up the same as well. :(
     
  3. ManuelSegura

    ManuelSegura

    Joined:
    Dec 12, 2015
    Posts:
    19
    I'm not gonna read all of that but:

    knockBackCounter -= Time.deltaTime; => only happens if player is NOT grounded, so if for some reason the grounding check doesn't work well, it will stay infinitely knockbacked, I guess. Debug.Log this variable to see if this is happening. (maybe it's detecting the enemy as ground?)

    The instantiation of the particles is probably messed up, so instead of:
    Instantiate(deathEffect, respawnPoint, startPosition);​
    Do:
    GameObject x = Instantiate(deathEffect, respawnPoint, startPosition);
    Debug.Log("DeathParticles should be here: " + x.transform.position)​

    Idk, maybe they are destroyed too soon or something, just play with the debugs.
     
  4. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    Thanks for replying.

    Turns out, after much experimenting, all the if statement code that comes after knockBackCounter <= 0 && canMove needed to be placed under that first code block and it wasn't. The problem appears to be sorted now. :)

    The particle system always causes much confusion and works one minute and then not the next. This time, I changed the respawnPoint and startPosition to thePlayer.transform.position and thePlayer.transform.rotation, which is what I did for the enemy's death effect. Seems to be working. For now...