Simple DASH Mechanic in Unity

  Рет қаралды 21,446

BMo

BMo

Күн бұрын

Пікірлер: 32
@rikm2745
@rikm2745 11 ай бұрын
I love the fact you explain what every line does at the end. This makes it clear to me as a total noob exactly what line does what so that I can implement those lines in other methods I'm making. Thank you!
@Rakadeja
@Rakadeja 5 ай бұрын
Alright, subscribing. Your tutorials are very chill. Thanks so much! Sometimes I over-complicate things, so when I see a guide like this it helps me to comprehend other ways I can accomplish the same thing.
@regys9521
@regys9521 Жыл бұрын
Glad you are back!
@mandamoon9149
@mandamoon9149 Жыл бұрын
Love the simplicity, only 7 lines of code 🤯 like Bmo says, it’s fun to go fast 💨
@zote1
@zote1 4 ай бұрын
oh my this is so.... love it dude
@revmatch6r
@revmatch6r Жыл бұрын
Yasssss bmo is back 👏 👏 👏
@CodingCenter1
@CodingCenter1 Жыл бұрын
Don't mind but CAN I ASK THAT WHY ARE YOU NOT AN ANGEL, BRO KNOWS EVERTHING. THX SOSOSOSOSOSOSOSOSOSOS Much
@senordygus919
@senordygus919 11 ай бұрын
This methods seems hard to to implement in the new input system, do you have any suggestions?
@iR3dyOfficial
@iR3dyOfficial 9 ай бұрын
If you still want to know Use public InputActionReference actionKey; And then in the if statement you’ll do this If(actionKey.action.triggered) This will act like KeyCode Key, but you will be able to select the input action you created
@whyamihere555
@whyamihere555 Жыл бұрын
The player isn't stopping once the duration is over for me, just continuing to slide.
@shad7270
@shad7270 3 ай бұрын
The rb isnt speeding up Ive been trying to fix it but i have no idea what is wrong please help. using System.Collections; using System.Collections.Generic; using System.Xml.Serialization; using Unity.VisualScripting; using UnityEditor.Callbacks; using UnityEngine; public class MovmentScript : MonoBehaviour { [SerializeField] private TrailRenderer tr; [SerializeField] public Rigidbody2D rb; [SerializeField] float movespeed = 5f; Vector2 moveDirection; Vector2 mousePosition; [SerializeField] float dashSpeed = 10f; [SerializeField] float dashDuration = 1f; [SerializeField] float dashCooldown = 1f; bool isDashing = false; // Update is called once per frame void Update() { if (isDashing == true) { return; } float verticalInput = Input.GetAxis("Vertical"); float horizontalInput = Input.GetAxis("Horizontal"); moveDirection = new Vector2 (horizontalInput, verticalInput).normalized; mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (Input.GetKeyDown(KeyCode.LeftShift)) { StartCoroutine(Dash()); } } private void FixedUpdate() { rb.velocity = new Vector2(moveDirection.x * movespeed, moveDirection.y*movespeed); Vector2 aimDirection = mousePosition - rb.position; float aimAngle = Mathf.Atan2(aimDirection.y, aimDirection.x)*Mathf.Rad2Deg -90f; rb.rotation = aimAngle; } private IEnumerator Dash() { isDashing =true; rb.velocity = new Vector2(moveDirection.x * dashSpeed , moveDirection.y * dashSpeed ); yield return new WaitForSeconds(dashDuration); isDashing = false; Debug.Log ("speed applied"); } }
@shad7270
@shad7270 3 ай бұрын
When i press the shift key the only thing that happens it the rb moves in the right direction but will stay the same as the movespeed no matter how much i increase the dashspeed.
@MajesticMindGames
@MajesticMindGames Жыл бұрын
Lovely ❤👍
@bigp0y
@bigp0y Жыл бұрын
We all know it should've been the red knight in the thumbnail
@Apek44
@Apek44 Жыл бұрын
My dash speed variable roesnt make me go faster, its the only thing that doesnt work, no matter what i do it stays constant, i coppied everythign down exactly from this video cause i was so frustrated and it still dont work, maybe its clashign with my other movement code but idk
@Apek44
@Apek44 Жыл бұрын
PLEASE HELP ME BMo IM GOING INSANE TRYING TO FIX THIS BUT BOTHING WORKS
@Unknown-nv9so
@Unknown-nv9so Жыл бұрын
Have you gotten it fixed yet
@Apek44
@Apek44 Жыл бұрын
@@Unknown-nv9so nope. Gave up on fixing that nd decided to do sum else, sorry
@danilroiven2428
@danilroiven2428 Жыл бұрын
I solved it with changing my character movement function to function rb.MovePosition and dashing with increasing value of the speed. Like rb.MovePosition(rb.position+direction.normalized * speed * Time.fixedDeltaTime); // when player is dashing, speed = dashSpeed, after dash time ends speed = defaultSpeed Also it can be done with rb. velocity for both but in my case i did not solve that in a way that gives player little control while dashing. MovePosition method is easier, just increase the speed while dash time is not ended
@danilroiven2428
@danilroiven2428 Жыл бұрын
@@Unknown-nv9so I solved it with changing my character movement function to function rb.MovePosition and dashing with increasing value of the speed. Like rb.MovePosition(rb.position+direction.normalized * speed * Time.fixedDeltaTime); // when player is dashing, speed = dashSpeed, after dash time ends speed = defaultSpeed Also it can be done with rb. velocity for both but in my case i did not solve that in a way that gives player little control while dashing. MovePosition method is easier, just increase the speed while dash time is not ended
@Somedudewatchingyoutubee
@Somedudewatchingyoutubee Жыл бұрын
Hey so I tried adapting the tutorial without the shooting mechanic. I used the movement script and it worked but when I tried to implement the dash my character didn’t move anymore and the dash didn’t work either. Unity also didn’t recognise the KeyCode Term. Any help would be appreciated! :]
@idabthereforeiam7479
@idabthereforeiam7479 Жыл бұрын
What input system are you using? The new input system doesn't use the .keycode fuction.
@federicorodriguez8419
@federicorodriguez8419 11 ай бұрын
It works fine for me, but I can't run the dash diagonally when I press the up-left and down-right keys, but it works when I press up-right and down-left. Does anyone know why this happens?
@arcadeii
@arcadeii 5 ай бұрын
this is happening to me too, but only with up left and only on the arrow keys, works fine for wasd
@RandomDude00001
@RandomDude00001 11 ай бұрын
Idk but I have notice that if you collide with something like enemies of walls when you dash the player rotates like crazy how do I fix that? And hey any Idea how to put a cooldown GUI for this?
@arcadeii
@arcadeii 5 ай бұрын
you probably figured this out but im pretty sure you have to check “freeze rotation” in the rigidbody settings ?
@ElDonitazz
@ElDonitazz Жыл бұрын
Can you use character controller?
@LaughingMan44
@LaughingMan44 Жыл бұрын
is having a coroutine in update not seen as a bad idea?
@Apek44
@Apek44 Жыл бұрын
Why would it be?
@PeterSmith-pg7oi
@PeterSmith-pg7oi Жыл бұрын
"PromoSM" 😉
Level Up with Experience Points in Unity
8:27
BMo
Рет қаралды 17 М.
Cinemachine Is Really Powerful, Set It Up EASILY
7:26
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
I Made A Platformer Game But You're The Enemy
6:12
BMo
Рет қаралды 651 М.
A Great Way To Setup POWERUPS In Your Unity Game
13:43
The Trick I Used to Make Combat Fun! | Devlog
8:12
Game Endeavor
Рет қаралды 1,7 МЛН
CUTSCENES in Unity using Timeline
13:24
BMo
Рет қаралды 73 М.
Blend Trees Unity - Movement And Jump Animations
9:48
Simon Lee
Рет қаралды 17 М.
Easy Ammo & Reloading System in Unity
7:48
BMo
Рет қаралды 11 М.
So I made every block act differently..
11:41
Element X
Рет қаралды 317 М.
MELEE COMBAT in Unity
21:07
Brackeys
Рет қаралды 1,6 МЛН
TOP DOWN SHOOTING in Unity
19:52
Brackeys
Рет қаралды 873 М.
I Made 82,497 People Redraw Famous Logos
10:39
RoyalPear
Рет қаралды 128 М.