Essentially you need to add 2 non-trigger colliders to your player, one of them should be on your games version of the "collide with everything" layer. The important thing to take from the PlayerDash component is the 2 Collider2D fields. The Dash and FixedUpdate method in this class handles Point 1 and 2 of my design. EnemyMovement and PlayerMovement all derive from this. The first component is the base class for all movement components in my project. The code is pretty messy and all over the place so If you are having some trouble following let me know and I will try to help. I will make notes to explain certain things when there is editor/gameobject related setup involved. You are not going to be able to just copy + paste it into your project though since the code structure has been heavily designed around my specific game. I'm going to post all the dash related scripts from my project. In order to facilitate this there needs to be a way to push back enemies that happen to be within a certain distance of the Dash's end position to avoid overlapping colliders. Point 3 : When Dashing the player needs to be able to collide with the levels terrain and "obstacles" while ignoring collisions with enemies. Point 2 : There needs to be a way to dynamically limit the dash distance to avoid situations where the ending position of the dash lands inside of another non-enemy collider. This allows players to build up muscle memory with the Dashing mechanics and enables them to know exactly when and where they will end up at all times after a dash. You need to be able to set a "distance to travel" and a "travel speed" into the dash function. Point 1 : When there is a clear path between Point A and B, the Dash should always get you from Point A to Point B at the same speed every time. Essentially there are about 3 design points that my code follows (which are specific to my project only). I implemented a dashing system into my project that works more or less how you want.
0 Comments
Leave a Reply. |