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. Dismiss Notice

Question How can I realize a dash system?

Discussion in 'Entity Component System' started by iamshenkui_gee, Jul 7, 2022.

  1. iamshenkui_gee

    iamshenkui_gee

    Joined:
    Apr 24, 2021
    Posts:
    30
    I would like to realize dash in my game. If I press w, the player will move forward. I was considering changing the transform value of the player. However, I wish my player would not pass the wall or something else. I also tried to change the velocity of the player temporarily, which works wired.
    So is there any good idea about realizing a dash system in the ECS?
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    939
    Cast a ray forward of the maximum dash distance and change the player transform to the hit point of the ray cast. You can then use the collision layer to choose what your player can dash through (other player but not walls).
     
    iamshenkui_gee likes this.
  3. iamshenkui_gee

    iamshenkui_gee

    Joined:
    Apr 24, 2021
    Posts:
    30
    Thank you!