Dani can you pls help me about changing 2d characters on buttons. But that they are on diferent scene. Like you are on character scene and they are changing in game scene
IF YOUR CHARACTER IS ALWAYS LOOKING AT THE CENTER OF THE SCREEN (or some other fixed point) and not rotating towards your mouse cursor, change the camera to ORTHOGRAPHIC. By default the main camera seems to be set to PERSPECTIVE which adds a Z component into the mix which isn't handled by the code shown in this video.
@@unlockener omg perfect joke for this scenario lol... now we just wait for Asbjörn to reply with "You're breathtaking", and our mission is completed bois
5 лет назад+1
When ur scrolling brackeys comments and you find golden unity channel 😍
syko that is what i thought whie watching this video too. i gotta admit he does look good with this length of hair though. also love your videos too sykoo.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float moveSpeed = 5f; public Rigidbody2D rb; public Camera cam; Vector2 movement; Vector2 mousePos; // Update is called once per frame void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); mousePos = cam.ScreenToWorldPoint(Input.mousePosition); } private void FixedUpdate() { rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime); Vector2 lookDir = mousePos - rb.position; float angle = Mathf.Atan2(lookDir.y ,lookDir.x) * Mathf.Rad2Deg - 90f; rb.rotation = angle; } } this is for 2d movement and for me so i can come back in the future
I love how genuinly excited Brackeys gets with something like a bullet shooting out.. he's probably written a similar script to that a million times but still acts like its the first time he has ever done it... ahhaaha love him
@@LeMustache Yes, the workflow is very different, but Clean Code is always welcome and SOLID can be applied. If you search a bit on youtube there are some videos on it. (Even tho I'm not a fan of OOP xp)
@@rafaeldefreitas5689 True, but I still don't think unity projects would benefit much from SOLID principles. Doing a video how to create and manage a big project without making it an unreadable, chaotic mess would be much nicer, since they aren't many good tutorials on this out there. Quill18creates has some good videos on this, but they are usually part of some long series where he basically creates a game, not real tutorials.
I think the reason Brackeys is more popular than other unity youtubers is that not only he makes great tutorials, he also explains the code so even a 5 year old could understand. Great job brackeys!
@9:23 you have to do -90f because for Unity the std 0 degree is to the right. and you later addForce to the up vector. if you use rb.AddForce(firePoint.right) you dont have to do -90. But beware you have to rotate the sprite in the prefab also to point to the right.
i grew up playing gta2 and hotline miami was one of those games that made me wanna be a game developer. top down shooters will always have a special place in my heart :)
@@animationspace8550 Thats cool and all but its not like he's dead or something. He has other things in life but true he will be in our hearts forever.
Hi! I'm Brazilian, and, to love your channel, many things are not found for my language unfortunately, but you do it so calmly, and step by step you can understand it without knowing anything about English, just knowing a little of a language ,the creation.
i don't make 2D games, but i still end up learning tips and tricks from these videos that i can use. Thanks for another awesome, well explained video :)
You can solve the "need to offset by -90°" problem by having your sprites start pointing to the right rather than up. 0° in screen space points to the right rather than up/forwards like a compass.
Next video is about Particle Effect Shooting? :D Create a Flamethrower-like particle effect at the end of the gun, give the particles a Collider... and set everything on fire!
After bombing the recent GameJam I just signed up for Jason's course. I'm a little skeptical but if Brackeys recommends him then I'm all for it. Wish me luck everyone!
I was wondering if someone was going to comment this I always use transform.up/right rather than the atan2 function just cause I feel like I can write my code in less lines (and it's been a while since I worked with trigonometry haha)
where i must put it in using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float moveSpeed= 5f; public Rigidbody rb; public Camera cam; Vector3 movement; Vector3 mousePos; // Update is called once per frame void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); mousePos = cam.ScreenToWorldPoint(Input.mousePosition); } private void FixedUpdate() { rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime); Vector3 lookDir = mousePos - rb.position; float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f; rb.rotation = angle; } }
My boy Brackeys is slowly but surely becoming the John Wick of Game Devs. Look at that mane 😎 "People keep asking me if I've implemented a back button. I'm thinkin I'll implement a back button" 😂
when i was making the shooting code when i had just started out in unity i didnt know anything about what he was saying but now after me getting 3 months of experience... i find it really clever he played around with like the variables and using the "= sign" to reference to the bullet and get its rigidbody2d and transfer it to the player rigidbody2d im bad at explaining but in my head its a really cool thing to use references like this
Roleks And Mao dude he legit JUST SAID he is having trouble with something pretty basic. Ok well, not THAT basic but it's not exactly computer science either, meaning that Sir is probably a beginner. And usually, they need more time. I honestly think a 1-month jam would be good for beginners.
Well...this tutorial is WAY better than the one I was working on, with the same end result. I went the raycasting route. I am gonna attempt my dream game (GTA+NFS+CAR MECHANIC SIM) in top down 2D. You are the best, Brackeys! Awesome teaching skills!
@@TrashEntertainment_hehe That's okay! Everybody has their own style. It makes the world interesting! I've learned so much since this video from so many talented people! I just discovered Greg Dev Stuff. Thick Russian accent but amazing channel, check it out!
@@redwaffle6717 I'm afraid I have lost most of my vision now and only JUST got a computer going again after quite some time. If I can still find my way around a game engine I just might start back up again lol Thanks for asking!
@@apolion6197 I think they caught on to the high volume of free downloads coming from here and decided they'd adjust things according to supply & demand :)
Brackeys you are reading my mind. i have been drifting in and out of game dev but this time i want to stick with it and whenever i start again i think of a cool game type to make you just upload a video on it. for example before i thought it would be fun to make a 2d game and of course you just made a video about it and now the same with top down shooting
Reminds me of a fourth grade exercise that my teacher made us do. Try to explain to an alien how to make a peanut butter and jelly sandwich. She did literally everything we said. Literally. When someone said to put the peanut butter on the bread, she put the whole jar on top of the loaf.
Even with brackeys gone from RUclips, the first thing that pops in my head whenever I encounter a problem is his name, he is basically the Jesus Christ of gamedev
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg = 90f; show ing error The left-hand side of an assignment must be a variable, property or indexer
//I hope I saved you some time using System.Collections; using System.Collections.Generic; using UnityEngine; public class shooting : MonoBehaviour { public Transform firePoint; public GameObject bulletPrefab; public float bulletForce = 20f; // Update is called once per frame void Update() { if(Input.GetButtonDown("Fire1")) { Shoot(); } } void Shoot() { GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); Rigidbody2D rb = bullet.GetComponent(); rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float moveSpeed= 5f; public Rigidbody rb; Vector3 movement; // Update is called once per frame void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); } private void FixedUpdate() { rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime); } }
@ImJelli6117 Gone using System.Collections; using System.Collections.Generic; using UnityEngine; public class playerMovement : MonoBehaviour { public float speed; public float jump; private float move; private Rigidbody2D rb;
void Start() { rb = GetComponent(); }
void Update() { move = Input.GetAxis("Horizontal"); rb.velocity = new Vector2(move * speed, rb.velocity.y); if (Input.GetButtonDown("Jump")) { rb.AddForce(new Vector2(rb.velocity.x ,jump));
Hi.. 👐there have been many updates to the Unity Engine lately so therefore could you make another MAKE YOUR OWN VIDEO GAME TUTORIAL with latest programming tips... Plz that would help a lot
8:38 The explanation why the y component comes first is the following: In trigonometry the tangent of an angle is the ratio of the y component to the x component of a line, y/x. It's like the slope the line makes: tan(angle) = y/x We got the x and y component, and we need to get the angle. To translate the slope to an angle we gotta inverse the tangent, aka use the arctangent. So what you actually do here is get the arctangent of the tangent of the angle, which actually is equal to the arctangent of the ratio: atan(tan(angle)) = atan(y/x) Aand cuz the y comes before the x in the ratio, it's atan(y, x) in unty. ... Probably
There is small problem with movement code - moving in X direction is faster than horizontally or vertically. This should fix the problem, put this in FixedUpdate : float m; if (movement.x * movement.y != 0) // checking if input is X shape m = 0.707f; // when moving in X directions. sin45 = 0.707 else m = 1f; // move speed normal rb.MovePosition(rb.position + movement * m * moveSpeed * Time.fixedDeltaTime);
// This has the same effect as his aiming code, but you're letting the engine handle the math instead. Assumes your sprite is facing up by default. Vector3 v = Camera.main.ScreenToWorldPoint(Input.mousePosition); v -= transform.position; v.z = 0; transform.up = v;
This is a lifesaver, I'm using cinemachine and couldn't get it to work right w/ the Brackeys method (forcefully considered the mouse to always be in the center). This method managed to fix the problem I was running in to. Kudos to you!
Once again an amazing and useful video! Would love to see a video from you about the 2D Shadergraph that got introduced in 2019.2f Keep up the good work
@@aaaaaaaaaaaaaaaaaaaaaaaaa275 ben zaten kendi yolunu aç demediğim için; hakkın rahmetine ulaşacağın gün "Allah taksiratını affetsin" diye arkandan rahmet duasında bulunacakların dualarını ilettiği makam tüm dilleri biliyo problem yok hatta pek bi anlamı var 😉
out of curiosity is there a way to get a weapon to float around the player as a pivot point that rotates around the player based on the mouses position ?
Ok so- I was originally gonna just use a triangle for my model, but somehow I cant manage to make a triangle in unity 2d, so I struggled for a bit before deciding to just use the soldier you used from the unity store. Turns out it's no longer free, so now I'm struggling trying to find a free top down model that would work for this. Fun fact, there are none.
if your using the new input system, in update void Update() { moveDirection = playerControls.ReadValue(); mousePos = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue());
Whoah hello there handsome are you new around here??
Hej dani
Im your fan
Can i ask you something
Dani can you pls help me about changing 2d characters on buttons. But that they are on diferent scene. Like you are on character scene and they are changing in game scene
Pls help
IF YOUR CHARACTER IS ALWAYS LOOKING AT THE CENTER OF THE SCREEN (or some other fixed point) and not rotating towards your mouse cursor, change the camera to ORTHOGRAPHIC. By default the main camera seems to be set to PERSPECTIVE which adds a Z component into the mix which isn't handled by the code shown in this video.
omg thank you sooooooo much you just saved me from total failure in a game jam
This dident work for me :(
Edit:I found the problem turns out i was just stupid
Amazing LEGEND!
Thank you
Thanks so much man, was stuck on this for like hours
There are rumors that those bullets that exited the screen without any collision are still flying around these days.
Actually, they all get deleted once you leave the play test :)
R/whoosh
*I've always wanted to say that*
@@aisforanimate4703r/foundthemobileuser
@@aisforanimate4703 r/itswooooshwith4os
Brackeys is nice, easily understood, and his tutorials are great.
i had an issue and i figured it out without Brackey i am truly evolving
great job man improvement doesnt come immediatly
I miss a couple of brackeys episodes and suddenly he is jesus LOL
too :D
lmao
unity jesus
Y E S !
HAHAHHAHA
AHHHH YOUR HAIR!! I was like "ah neat they hired a new guy at Brackeys!"
Sykoo Hahaha same!!!!! Love your content Sykoo
Breathtaking hair
@@unlockener omg perfect joke for this scenario lol... now we just wait for Asbjörn to reply with "You're breathtaking", and our mission is completed bois
When ur scrolling brackeys comments and you find golden unity channel 😍
syko that is what i thought whie watching this video too. i gotta admit he does look good with this length of hair though. also love your videos too sykoo.
this is the first thing i've been able to successfully get working on unity- thank you so much man.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Camera cam;
Vector2 movement;
Vector2 mousePos;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y ,lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
}
this is for 2d movement
and for me so i can come back in the future
Lemme just control c and control v
you didn't deleted the "// Update is called once per frame" and made everyone triggered.
@@esertekin9727 @least there is no // Start is called...
@@esertekin9727 lol I would edit the comment just it is on my other account
Thanks ur a legend , my script didn't work for some reason i just copy and pastet this and it works :)
I love how genuinly excited Brackeys gets with something like a bullet shooting out.. he's probably written a similar script to that a million times but still acts like its the first time he has ever done it... ahhaaha love him
Brackeys ur becoming John Wick :O
Keanu god bless that mans soul...
Didn't like because I didn't want to ruin the 69
Jonathan.....
Swedish John Wick
Nope he is becoming the Jesus Christ of game dev 🤣
Brackeys please make a video about clean code or solid solid principles :)
Would be nice
Most of them don't apply to unity, because the workflow is so different from a regular .NET app
Would be awesome
@@LeMustache Yes, the workflow is very different, but Clean Code is always welcome and SOLID can be applied. If you search a bit on youtube there are some videos on it. (Even tho I'm not a fan of OOP xp)
@@rafaeldefreitas5689 True, but I still don't think unity projects would benefit much from SOLID principles. Doing a video how to create and manage a big project without making it an unreadable, chaotic mess would be much nicer, since they aren't many good tutorials on this out there. Quill18creates has some good videos on this, but they are usually part of some long series where he basically creates a game, not real tutorials.
*_Thank you for tuning in at Brackeys_*
*cue happy guitar sounds*
I think the reason Brackeys is more popular than other unity youtubers is that not only he makes great tutorials, he also explains the code so even a 5 year old could understand. Great job brackeys!
@9:23 you have to do -90f because for Unity the std 0 degree is to the right. and you later addForce to the up vector. if you use
rb.AddForce(firePoint.right) you dont have to do -90. But beware you have to rotate the sprite in the prefab also to point to the right.
i grew up playing gta2 and hotline miami was one of those games that made me wanna be a game developer. top down shooters will always have a special place in my heart :)
This is so sad because he stopped making vids now
yeah he was one of thee best :(
he was a good man
RIP brackeys. They will forever be in our hearts. ✊😞
@@animationspace8550 Thats cool and all but its not like he's dead or something. He has other things in life but true he will be in our hearts forever.
Hi! I'm Brazilian, and, to love your channel, many things are not found for my language unfortunately, but you do it so calmly, and step by step you can understand it without knowing anything about English, just knowing a little of a language ,the creation.
i don't make 2D games, but i still end up learning tips and tricks from these videos that i can use. Thanks for another awesome, well explained video :)
for anyone who came here just for the shooting tutor 10:01 no need to thank me we all needed it :D
I like this new hairstyle man :)
Me too!
if when you fire the bullet doesnt show and it just does the hit effect immediately, make sure the player hitbox doesnt go in front of the fire point.
Are the armored tanks assets free for you?
*Source Code*
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Camera cam;
Vector2 movement;
Vector2 mousePos;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y ,lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
}
I've already done this a couple times but I still like watching your videos to see how others would do it!
You can solve the "need to offset by -90°" problem by having your sprites start pointing to the right rather than up. 0° in screen space points to the right rather than up/forwards like a compass.
its because you put -90 not - 90
@Concrete thx
@Concrete Mine are still flying 90 degrees in the wrong direction even though I rotated the firePoint :(
You magnificent beast, thank you for sharing this wizardry! This sparked my interest in Unity one again. Nicely done, well put, amazing job!
Next video is about Particle Effect Shooting? :D
Create a Flamethrower-like particle effect at the end of the gun, give the particles a Collider... and set everything on fire!
*unity's particle system*
@@theindianyouwatch a great system for making particles
@@ThoonderClips *making particles*
Nobody:
Brackeys: "Now if we save this and head back into unity..."
Me: I'm a bout to witness some magic aren't I?
Haha can't relate more
After bombing the recent GameJam I just signed up for Jason's course. I'm a little skeptical but if Brackeys recommends him then I'm all for it. Wish me luck everyone!
I wish you luck.
Was it good?
1:41 *Top ten heroes Thanos was to afraid to fight*
lol
lol
lol
Can't not say that i feel like Brackeys is trolling us, uploading this right after the jam! Great video though!
This is the only tutorial I could find that actually does what I need it to do.
Thanks!
8:00 If you don't want to mess with angles and rotations, just do transform.up = direction.normalized
I was wondering if someone was going to comment this
I always use transform.up/right rather than the atan2 function just cause I feel like I can write my code in less lines (and it's been a while since I worked with trigonometry haha)
I dont know but i think Atan2 is butter cuz it will return one angle transform.up change all angles
where do i put this?
It is easier to write but will mess up player directions.
We miss you
Can u say which version is this
I've been waiting for this tutorial. Thanks Brackeys, please keep it up.
Well about that last part...
14:37 Really, really i spent a lot of time on this shooting feature, thank you so much! 💙💙💙
Brackeys: **exists*
Jason Weimann: *Allow Me To Introduce Myself*
After watching like 10 tutorials, this one actually worked for me. I'm so happy I could finally make my character rotate 😭😭😭😭
Instead of angle calculation, you can use
transform.rotation = Quaternion.lookdirection(mausepos-rb.pos, vector3.forward);
where i must put it in
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed= 5f;
public Rigidbody rb;
public Camera cam;
Vector3 movement;
Vector3 mousePos;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector3 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
}
@@Alex-oy4qn
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
rb.rotation = Quaternion.lookdirection(mausepos-rb.pos, vector3.forward);
}
@@gorkemvids4839 thx
I like your videos because you explain what's happening and that's very useful for me as a beginner
Well, I guess I don't mind my Unity teacher being the Lord himself. All hail Brackeys!
My boy Brackeys is slowly but surely becoming the John Wick of Game Devs. Look at that mane 😎
"People keep asking me if I've implemented a back button. I'm thinkin I'll implement a back button" 😂
one of the best videos of yours! simple and complete not split in many parts!
Bullet Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bullet : MonoBehaviour
{
public GameObject hitEffect;
private float effectDuration;
void Start()
{
effectDuration = hitEffect.GetComponent().main.startLifetime.constant;
}
void OnCollisionEnter2D(Collision2D collision)
{
GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity);
Destroy(effect, effectDuration);
Destroy(gameObject);
}
}
Don´t you mean "Code Bullet"?
my bullets do not destroy themselves on collision but the code is exactly the same as here, could you suggest an
ything?
Well, didn't think I'd end up inadvertently finding this by searching the *exact title* on Google a mere twenty minutes after it got posted.
9:37 "rb.rotation = angle" angle is red marked "CS0029"
Try rb.SetRotation(angle) instead.
Bro i love you so much that I actually be watching the ad's
Doesnt know why but that shooting looks really satisfying :O
You're breathtaking, Brackeys!
george floyd?
can u look in the future
brackey you are my best teacher
Yet again, brackeys reads my mind.
I don´t know what I would do without your videos. I´m sure, I couldn´t complete at least one game. Thanks.
I didn't know john wick is making unity tutorials.
🤣🤣🤣🤣🤣🤣🤣🤣
when i was making the shooting code when i had just started out in unity i didnt know anything about what he was saying but now after me getting 3 months of experience... i find it really clever he played around with like the variables and using the "= sign" to reference to the bullet and get its rigidbody2d and transfer it to the player rigidbody2d im bad at explaining but in my head its a really cool thing to use references like this
Lol i was just learning how to make a topdown game and could figure out the shooting lol....
Perfect timing!
Can you please make a 1 month jam?
1 month is a lot
Cus you can make a game in 1 day
Wich can be a cube with physics and an enemy spawnere and your done
lol
1 month is too much. Even 1 week was pretty long so no, 1 month game jam is out of the question imo.
Roleks And Mao dude he legit JUST SAID he is having trouble with something pretty basic. Ok well, not THAT basic but it's not exactly computer science either, meaning that Sir is probably a beginner. And usually, they need more time. I honestly think a 1-month jam would be good for beginners.
@@zokaper801 nope, 1 month jam is too much even for a beginner. A week is alright, but 1 month is too much.
Asbjörn, you are breath-taking
when i got back form school i will try recreating something like this good work! +like :)
@Yolo KFC Maybe he isn't a english native speaker? He misspelled one word and you are calling him a kid?? What if he is 19 y.o. lmfao
@Yolo KFC Go back to school, kid.
:)
He has fully embraced the role as lord and savior of gamedev community.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Camera cam;
Vector2 movement;
Vector2 mousePos;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y ,lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
}
Well...this tutorial is WAY better than the one I was working on, with the same end result. I went the raycasting route. I am gonna attempt my dream game (GTA+NFS+CAR MECHANIC SIM) in top down 2D. You are the best, Brackeys! Awesome teaching skills!
You can’t attempt your dream game with this crappy guy he dosent even teach you anything he just says hey retard do this
@@TrashEntertainment_hehe That's okay! Everybody has their own style. It makes the world interesting! I've learned so much since this video from so many talented people!
I just discovered Greg Dev Stuff. Thick Russian accent but amazing channel, check it out!
have u start ur dream game ?
How is your dream game going??
@@redwaffle6717 I'm afraid I have lost most of my vision now and only JUST got a computer going again after quite some time. If I can still find my way around a game engine I just might start back up again lol Thanks for asking!
NOTE : the character pack is no longer available, for me atleast
You can buy it for 5$ but you probably searched for free assets, thats why it did not show up.
@@apolion6197 I think they caught on to the high volume of free downloads coming from here and decided they'd adjust things according to supply & demand :)
@@lozD83 yeah pretty smart move, but i still wont buy anyways.
Brackeys you are reading my mind. i have been drifting in and out of game dev but this time i want to stick with it and whenever i start again i think of a cool game type to make you just upload a video on it. for example before i thought it would be fun to make a 2d game and of course you just made a video about it and now the same with top down shooting
*Its actualy fairly easy * (continues to speak in alien language)
Reminds me of a fourth grade exercise that my teacher made us do.
Try to explain to an alien how to make a peanut butter and jelly sandwich.
She did literally everything we said. Literally.
When someone said to put the peanut butter on the bread, she put the whole jar on top of the loaf.
@@chaosmastermind That must have been fun
@@sir_pheonez4048 It was extremely frustrating for the entire class to find the right words without her making a monkey paw mockery of it.
@@chaosmastermind :| oh...
Relay table
your videos are just gold
the armored soldiers pack thing isn't free anymore but thats cool i guess
This covered EXACTLY what I was struggling with!
Can you please make *3d* game tutorials again?
Even with brackeys gone from RUclips, the first thing that pops in my head whenever I encounter a problem is his name, he is basically the Jesus Christ of gamedev
Hey Brakeys, can you do a tutorial on character selection? It would be really nice!
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg = 90f;
show ing error The left-hand side of an assignment must be a variable, property or indexer
- 90f
@@stabby6521 thanx
//I hope I saved you some time
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shooting : MonoBehaviour
{
public Transform firePoint;
public GameObject bulletPrefab;
public float bulletForce = 20f;
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody2D rb = bullet.GetComponent();
rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
}
}
Absolute legend, my script didn't work but yours did, I must of spelt something wrong or something, thanks
my hero
i got 9 errors from this :/
I fixed it was a simple mistake from me :)
@@heartloss3751 i am having issues too what did u do
Thx for the video, Jason(unity college) is realy the man you need for advance to the next step in Unity after watching Brackeys.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed= 5f;
public Rigidbody rb;
Vector3 movement;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
this helped thanks
@ImJelli6117 Gone
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerMovement : MonoBehaviour
{
public float speed;
public float jump;
private float move;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent();
}
void Update()
{
move = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(move * speed, rb.velocity.y);
if (Input.GetButtonDown("Jump"))
{
rb.AddForce(new Vector2(rb.velocity.x ,jump));
}
}
}
I cant make a float even when i make it it does nothing nvm im just dumb
Man looks like the coolest Viking I've ever seen
Hi.. 👐there have been many updates to the Unity Engine lately so therefore could you make another MAKE YOUR OWN VIDEO GAME TUTORIAL with latest programming tips... Plz that would help a lot
8:38
The explanation why the y component comes first is the following:
In trigonometry the tangent of an angle is the ratio of the y component to the x component of a line, y/x. It's like the slope the line makes:
tan(angle) = y/x
We got the x and y component, and we need to get the angle. To translate the slope to an angle we gotta inverse the tangent, aka use the arctangent. So what you actually do here is get the arctangent of the tangent of the angle, which actually is equal to the arctangent of the ratio:
atan(tan(angle)) = atan(y/x)
Aand cuz the y comes before the x in the ratio, it's atan(y, x) in unty.
...
Probably
Are the armored tanks assets free for you?
Would be interested to see 2D melee combat covered. I tried doing it once and it was a bit of a mess... nice vid and hair :D
brackeys did do that actually
ruclips.net/video/sPiVz1k-fEs/видео.html
Yessss I was loooking for this for a long time
There is small problem with movement code - moving in X direction is faster than horizontally or vertically. This should fix the problem, put this in FixedUpdate :
float m;
if (movement.x * movement.y != 0) // checking if input is X shape
m = 0.707f; // when moving in X directions. sin45 = 0.707
else m = 1f; // move speed normal
rb.MovePosition(rb.position + movement * m * moveSpeed * Time.fixedDeltaTime);
Or just normalize movement?
if (movement.magnitude > 1.0f)
movement.Normalize();
you can use this too, movement is a Vector2, the same as your code.
@@joaoandrea.1954 you can just get rid of some lines and just use
movement = movement.normalized;
@@Nugg3tNugg3t yep, your right, i figured It out a few days ago by debuging, however i have forgotten to update this comment. Thx for optimize it!!
I love this video because I was thinking of making a game using these exact mechanics. Thank you so much.
Don't mind me,i just doing a stamps for myself.
2:56 - 4:57 player movement
5:21 -10:23 - 14:46 Player aiming
@Yolo KFC i said i just doing a stamp FOR MY SELF!!!!!!!!!!!!!!!!!!!!!!
Lmao
I was just wondering how to do this yesterday! Now this is super convenient. Great work, as always.
// This has the same effect as his aiming code, but you're letting the engine handle the math instead. Assumes your sprite is facing up by default.
Vector3 v = Camera.main.ScreenToWorldPoint(Input.mousePosition);
v -= transform.position;
v.z = 0;
transform.up = v;
It causes wierd sprite flipping glitch when aiming directly up. Rather use brackeys method
This is a lifesaver, I'm using cinemachine and couldn't get it to work right w/ the Brackeys method (forcefully considered the mouse to always be in the center). This method managed to fix the problem I was running in to. Kudos to you!
Jason is personally bankrolling Brackeys!
I need help, every time I try to shoot the bullet would only shoot up no matter where I would aim it
Once again an amazing and useful video! Would love to see a video from you about the 2D Shadergraph that got introduced in 2019.2f
Keep up the good work
if "Fire1" dosent work there is "Mouse0"
Thanks but destroy(gameobject); does not work
I really dig the new style of yours with that hair!
Great Tutorials as always bud, my explosion animation is playing twice before being destroyed however, not sure what i did wrong there.
Steven Moore You might check to see if you have loop time on. If so turn it off then it will only play once. Idk if that’s your problem but good luck!
Harikasın!! Sen en takıldığım işi çözmeme yardım ettin ya; Allah'ta senin yolunu açık etsin :))
Amin
@@aaaaaaaaaaaaaaaaaaaaaaaaa275 ben zaten kendi yolunu aç demediğim için; hakkın rahmetine ulaşacağın gün "Allah taksiratını affetsin" diye arkandan rahmet duasında bulunacakların dualarını ilettiği makam tüm dilleri biliyo problem yok hatta pek bi anlamı var 😉
Brackeys: Only one that participates in own game jam.
Also Brackeys: Makes video on topdown shooting.
Me: Where’s the game jam video! : )
I think many of the creators of the collaboration jam did join in as well. BTP did!
out of curiosity is there a way to get a weapon to float around the player as a pivot point that rotates around the player based on the mouses position ?
OMG!!! For the first time brackeys didn't deleted the two using tags😲😲
Ok so- I was originally gonna just use a triangle for my model, but somehow I cant manage to make a triangle in unity 2d, so I struggled for a bit before deciding to just use the soldier you used from the unity store. Turns out it's no longer free, so now I'm struggling trying to find a free top down model that would work for this. Fun fact, there are none.
That hair fits you so well!
There is a problem: He set rb.rotation to a float, but rb.rotation is a Quaternion so that didn't work for me.
Edit: I think its bc im in 3d
Try quaternion.euler and put the angle in the axis your rotating around
This video was extremely helpful, thank you!
My character is moving back when ever i shot and my bullets come out at a -90 degree angle and i dont know how to fix it
I fixed it all I had to do was change my gun point rotation to -90.
@@jhosuarodriguez8243 Thanks!!
My bullet is not showing
Relja Margetic pls can you send me that code I don’t know where to change the gun point rotation
if your using the new input system, in update
void Update()
{
moveDirection = playerControls.ReadValue();
mousePos = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue());
}
and in fixed update change the - 90f to + 90f
Hair looks good dude, almost as good as mine :P muahaha I made it to 1k subs. How many more before we can collab? lol