SFML 2.4 For Beginners - 12: Collision Detection (AABB).

  Рет қаралды 65,097

Hilze Vonck

Hilze Vonck

Күн бұрын

Пікірлер: 174
@GrandBenja
@GrandBenja 7 жыл бұрын
As many people before me, I'd like to thank you for this series. Your explanations are detailed, but easy enough for even a beginner to understand. I also appreciate that you tried to show us very clean, reusable code. (As opposed to less professional "as long as it compiles, it's good enough" tutorials.) Your series may (so far) only teach the basics, but they are good, solid basics on which we can build further learning. Your personality is a big + too. The viewer can feel that you're a good person who enjoys sharing his knowledge. That's important too when you teach beginners, since a beginner may need to feel some comforting human warmth in this unknown SFML territory. You got a well deserved donation from me. Thank you, sir. :)
@yogxoth1959
@yogxoth1959 4 жыл бұрын
This is the ONLY resource on the entire internet that worked for me, I've been tearing my hair out over this for days. THANK YOU SO MUCH!
@turbo30067
@turbo30067 8 жыл бұрын
your tutorials are the best out there. really good job. you make it so easy to follow. thanks for existing
@evanmcblevan
@evanmcblevan 2 жыл бұрын
the same: IM SUBBING
@t-jolt7235
@t-jolt7235 5 жыл бұрын
I have a problem with my collision where it doesnt accept player before .GetCollider(). This happens at the very end between player.Update and view.setCenter. If you know what my problem could be please tell me.
@mudzi9433
@mudzi9433 7 жыл бұрын
Thank you so much for this tutorial! :3 Not only did I finally make my collision work, but I also understood what I was doing C:
@Tomab3
@Tomab3 2 жыл бұрын
Thank you for all the work that you put into these videos, I learned a lot and really became fond of sfml it feels more natural than SDL2.
@RameenRameen-g6o
@RameenRameen-g6o Ай бұрын
Thank you soooo muchh for this series man ...I wish I could get more
@lorow2542
@lorow2542 8 жыл бұрын
It seems so damn easy with your tutorial!
@PflanzenChirurg
@PflanzenChirurg 8 жыл бұрын
i might repeat but i want more of ur stuff :D
@dafemele10
@dafemele10 8 жыл бұрын
I get an error "Expression must be LValue" on this part: platform1.getCollider().chechCollision(player.getCollider(), 0.0f); ^
@Pedro62ful
@Pedro62ful 6 жыл бұрын
I got the same error, did you fix yours?
@invis7476
@invis7476 6 жыл бұрын
Same here, not sure what I'm doing wrong.
@blueseelen8047
@blueseelen8047 6 жыл бұрын
So I quess we will never get an answer what's wrong :(
@TheCarljeff
@TheCarljeff 6 жыл бұрын
Hey, I was just having this same problem and I fixed it by removing the & in the CheckCollision parameters. So instead of CheckCollision(Collider &other, float push), it is CheckCollision(Collider other, float push). (make sure to modifyt the header as well)
@niallmaple
@niallmaple 6 жыл бұрын
It needs you to store the players collider before passing it by reference, so Collider col = player.GetCollider(); , then pass col in. Since the getcollider returns a Collider, not a Collider* or & so as soon as that finishes it goes out of scope, meaning the pass by reference will be referencing bad memory. It's usually more efficient to pass by const reference for somewhat complicated data structures (aka anything thats not a standard int or float etc) but if within the function that is taking it, wants to modify that type - it cannot be const.
@bendgk123
@bendgk123 6 жыл бұрын
Instead of push you could say inertia. Inertia is defined as how resistant an object is to any force. An object having a higher inertia would “push back” harder
@keithan7387
@keithan7387 2 жыл бұрын
in 14:33 i made that getCollision in my player.cpp file but it says that body is an undeclared identifier? I have even include the collision file in the h file of my player.
@tomgola3
@tomgola3 3 жыл бұрын
Hey its me from earlier videos! Don't worry i didnt give up and am still plugging away! I actually feel proud i managed to make a little "game" where a character moves and shoots and learned quite a bit! now im trying to understand collision this is really tough and my next challenge. I am probably going to watch this video alot!
@_simobr
@_simobr 4 жыл бұрын
When I write player.getCollider() in the CheckCollision method it tells me this: initial value of reference to non-const must be an lvalue 49 cannot convert argument 1 from 'Collider' to 'Collider &' Can anyone tell me why?
@aayushkarki108
@aayushkarki108 4 жыл бұрын
did you fix it? I got the same thing
@_simobr
@_simobr 4 жыл бұрын
@@aayushkarki108 nope, I've done the collider method in the class to resolve, but it isn't very correct
@aayushkarki108
@aayushkarki108 4 жыл бұрын
@@_simobr is it possible for you to share the resolved code?
@_simobr
@_simobr 4 жыл бұрын
@@aayushkarki108 meme its not properly solved
@eduardomora6028
@eduardomora6028 3 жыл бұрын
I got this error too, I don't know how he didn't get this. The problem is that in the getCollider function you are returning a temporary Collider object and you have a reference to Collider in CheckCollision function, you are trying to bind a non-const reference to a temporary object which is not allowed. What I did was create an empty default constructor for Collider class, create private default Collider objects in the platform class and player classes, then in the getCollider function I set these objects to Collider(body) and return that value. Lastly, I have the type of getCollider be Collider& (reference to collider object) instead of Collider. Now when you use pass in player.getCollider() in the CheckCollision method you are actually passing a reference to a non-temporary Collider object. There might be a shorter way to bypass this issue but this is what worked for me.
@quinn7630
@quinn7630 3 ай бұрын
As of 2.5.1 the coordinates systems is a bit different so if the colliders go crazy after touching, try inverting the ">" on the if statements in the checkCollision method I think its because the Y axis becomes positive when tou go down and negative if you go up in the lasts updates. Idk why i also had to invert the X axis tho, i think that one is still normal
@witzur5695
@witzur5695 7 жыл бұрын
This is the best tutorial series on YT great job.
@rexy_mirror1225
@rexy_mirror1225 6 жыл бұрын
Hello good sir! So far your tutorial videos have been fantastic. However, I encountered an error on the main.cpp. The player in platform1.GetCollider().CheckCollision(player.GetCollider(), 0.0f); platform2.GetCollider().CheckCollision(player.GetCollider(), 1.0f); gives an error: initial value of reference to non-const must be Ivalue. Do you know how I can fix it?
@teamfortress2ful
@teamfortress2ful 6 жыл бұрын
me too, i don't now how fix ;(
@teamfortress2ful
@teamfortress2ful 6 жыл бұрын
see the comentary of Brian, fixed here
@craig15murdoch
@craig15murdoch 5 жыл бұрын
@@teamfortress2ful Who is Brian?
@camerontelford7667
@camerontelford7667 3 жыл бұрын
YOU HAVE TO TAKE & OUT OF collision & other, float push IN COLLISION.CPP AND COLLISON.H
@soliderarmatang5664
@soliderarmatang5664 3 жыл бұрын
@@camerontelford7667 Thank you so much!!!!
@frederikja2210
@frederikja2210 7 жыл бұрын
your thing called push in physics is named mass :D
@douglasyamasaki1095
@douglasyamasaki1095 5 жыл бұрын
i`m trying to work your code out on my project , but somehow i cant collide in both ways , only on one way. if i do platform1.checkcollision with player it works well , but if i do player.checkcollision with platform1 it doesnt work . any clue on that? tried revising everything and it looks ok.
@tushankhan1853
@tushankhan1853 4 жыл бұрын
How to fix redefinition in collider??
@Esteban3999
@Esteban3999 7 жыл бұрын
error: no matching function for call to 'Collider::CheckCollision(Collider, float)'| on platform1.GetCollider().CheckCollision(player.GetCollider(), 0.0f); same for platform2 What might be the reason? Anyone?
@orocimarosay1447
@orocimarosay1447 7 жыл бұрын
same
@lukalazic7999
@lukalazic7999 6 жыл бұрын
Hey did you fix this problem?
@mr.lowpoly3882
@mr.lowpoly3882 6 жыл бұрын
Hey.. For all who have the same problem, Here is the simply solution: ..... case sf::Event::Resize: ResizeView(window, view); break; } } Collider playerCollRect = player.GetCollider(); // (or) auto playerCollRect = player.GetCollider(); player.Update(deltaTime); platform1.GetCollider().checkCollision(playerCollRect, 0.5f); platform2.GetCollider().checkCollision(playerCollRect, 0.5f) ----------------------------------------------------- I hope i could help.. Nice Tutorials Hilze Vonck
@chez-wren
@chez-wren 6 жыл бұрын
@Mr.Lowpoly Hey thanks a lot man! Really needed this for my project. I also have a correction though: you spelt "CollRect" wrong on the platform1 and platform2 lines
@mr.lowpoly3882
@mr.lowpoly3882 6 жыл бұрын
@Chez Boyz Oh yes sorry .. I changed it, thanks
@EricZeBaws
@EricZeBaws 8 жыл бұрын
YAY THANK YOU FOR MAKING THIS!!
@ron0gamingplayz102
@ron0gamingplayz102 6 жыл бұрын
Great tutorial as always Vonck! I may be asking too late now, but can you start an openGL series?
@Jayggz
@Jayggz 8 жыл бұрын
Great video! can't wait to see a gravity tutorial
@asm-ex1jw
@asm-ex1jw 8 жыл бұрын
And here I am at the end of the journey, eagerly waiting for your next video. As many others here, I have a question for you: I code on a laptop, and I've noticed that CPU usage goes up by a lot (from ~10% to ~70%) when I launch the application, so my machine starts heating up real quick. Apparently, this is due to the opening of the app window, and it's just in part VS's fault: if I open the .exe in the release folder it's still at least 40% extra work on the CPU. I wonder if that's normal and if there's a way to improve the performance on the system. Thanks
@FilipTutorials
@FilipTutorials 5 жыл бұрын
Realy nice examples that are easy too folow and bring much programming value with them. Thanks ;)
@vunguyenhoang3075
@vunguyenhoang3075 5 жыл бұрын
i think "push" variable can be rename to "resistance'
@EricZeBaws
@EricZeBaws 8 жыл бұрын
Does it have to be a perfect square or would a rectangle work
@HilzeVonck
@HilzeVonck 8 жыл бұрын
+EricZeBaws The collider does not have to be a perfect square.
@EricZeBaws
@EricZeBaws 8 жыл бұрын
okay
@shiwanggupta8608
@shiwanggupta8608 6 жыл бұрын
I have done exactly what is shown in the video but the platform is not moving. I tried writing platform1.GetCollider().Move(0.1f,0.0f); directly in my main file but still my platform isn't moving. Can anyone think of any mistake that I might be doing? I have already checked the video once again and haven't found any mistake
@eneszeqiri3364
@eneszeqiri3364 6 жыл бұрын
samee! ;(
@PleaseWait...
@PleaseWait... 3 жыл бұрын
whats the point of (1.0f - push) ????
@parthrupareliya625
@parthrupareliya625 5 жыл бұрын
can You please send me the code of player.h where you returns the collider of body. because i got an error that cannot bind non-constant value reference of type 'Collider&' to a reverse Type Collider.
@HilzeVonck
@HilzeVonck 5 жыл бұрын
This has something to do with the vs2017 and vs2019 compiler. With the vs2015 compiler you were able to directly use a returned copy as a constant reference, but you are not allowed to do this anymore with the vs2017 and vs2019 compilers. To fix this you simply have to store the collider in a local variable first and then pass that collider into the function, or change the function so it takes a collider instead of a constant reference to a collider.
@parthrupareliya625
@parthrupareliya625 5 жыл бұрын
@@HilzeVonck actually i am compiling this project using latest version of gcc compiler.
@dreamhollow
@dreamhollow Жыл бұрын
@@HilzeVonck I haven't quite figured out how to store the Collider inside of a variable, could you explain what you mean please?
@ron0gamingplayz102
@ron0gamingplayz102 6 жыл бұрын
8:29 Hilze is now an evil eyed sorcerer
@raidoukuzunoha9874
@raidoukuzunoha9874 4 жыл бұрын
can this 1 collision system be appliied to multiple sprites or game objects like enemies, pickups and walls as i thought this is some sort of collision parents for all objects. If so, how can i include it inside each one of them, means like do i have to declare different names of the collider for every different objects. Please let me know cuz im kinda new to sfml and also c++. T-T
@maciejstefanski1652
@maciejstefanski1652 5 жыл бұрын
Hey i have an error C2664 "bool Collider :: CheckCollision (Collider &, float)": it is not possible to convert argument 1 from "Collider" to "Collider &"
@maciejstefanski1652
@maciejstefanski1652 5 жыл бұрын
Please really help me i wanna make the game but i cant
@HilzeVonck
@HilzeVonck 5 жыл бұрын
Hey, the problem is that it is trying to get a reference to an object that isn't defined anywhere. The solution is to simply store the result of the getcollider function and use that variable as an input for the checkcollision function. This is an lvalue vs rvalue issue. vs2015 didn't see this as an issue, but since vs2017 the compiler started to treat this as an error. I hope this helps
@maciejstefanski1652
@maciejstefanski1652 5 жыл бұрын
@@HilzeVonck i love u Man. Thanks for fast response. You made mine Day better 😀
@maciejstefanski1652
@maciejstefanski1652 5 жыл бұрын
@@HilzeVonck anyway i am new and i work at sfml like 1 hours can u tell me how can i use code to do it and where should i put it please. Still thanks a lot dude
@maciejstefanski1652
@maciejstefanski1652 5 жыл бұрын
@@HilzeVonck i am 14years So i am bad xD
@thebeanz7838
@thebeanz7838 8 жыл бұрын
Hi! I am trying to apply this code into my project, changing it up a bit so it runs with sprites instead of a rectangleshapes, however, when it goes into the "GetPosition" function, it is tossing an Exception thrown at error, Access violation reading location.......not entirely sure what I am doing wrong and why returning a position is giving me this
@КристианИлиев-х5щ
@КристианИлиев-х5щ 8 жыл бұрын
Hey, I have a question. I need to know how can I make my character to pass through the, lets say right side of the window and appear on the left? Its really important for me.Ty
@leonisadonis
@leonisadonis 2 жыл бұрын
ATTENTION EVERYONE WHO USED A LIST AND A FUNCTION INSTEAD OF CLASSES if you had a list that you go throw with a for loop in a function to check for each individual tile then when you collide do break; or its gonna continue to loop after collision has been detected and set collision to false thus fucking it up but I recommend if you are gonna use a functions make it a bool copy the code then in the update set isColliding = collisionFunc(tiles) (or however you called them) and everything is gonna be fine
@stfoggy124
@stfoggy124 2 жыл бұрын
at higher speeds you can easily glitch through the collision, does anyone know how to fix this?
@edgar5686
@edgar5686 5 жыл бұрын
A better name for the variable "push" would be "movability", for example since a wall is not movable then you have a movability of 0.
@mort0303
@mort0303 5 жыл бұрын
Why isn't it a bool if it's always going to be either 1 or 0?
@edgar5686
@edgar5686 5 жыл бұрын
@@mort0303 it is not always going to be 1 or 0.. The case can happen that it is for example a heavy box and you want the push to be around 0.8 or so..
@mort0303
@mort0303 5 жыл бұрын
Edgar ah, ok. thank you
@Lyoshiiro
@Lyoshiiro 8 жыл бұрын
is it possible to use this format/lib file to make 3D AABB instead of 2D AABB? * still for opengl
@johnmaquis6272
@johnmaquis6272 6 жыл бұрын
I get an error "error: no matching function for call to 'Platform::Platform(std::nullptr_t, sf::Vector2f, sf::Vector2f)'" when creating the platforms. Help anyone please?
@ron0gamingplayz102
@ron0gamingplayz102 6 жыл бұрын
Hello, my Player keeps moving left or right through the screen at an absurdly high speed. Any solution?
@Welniukstele
@Welniukstele 5 жыл бұрын
Please tell me you sorted it out, and can share how, because I'm having the same problem, but it's either moving downwards or upwards. :D
@ghostly_zsh9609
@ghostly_zsh9609 5 жыл бұрын
I believe that issue is because you aren't multiplying by deltaTime.
@maxtwist3598
@maxtwist3598 7 жыл бұрын
it doesnt works if object are moving fast?
@RedubbledD
@RedubbledD 7 жыл бұрын
Hello, i realy like you tutorials. You realy explain things well. but it would be nice if you could put the files online (or code). I am running into some problems when i am colliding with the platforms. When i walk to the platforms, platform 1 is moving away(without colliding), and platform 2 isnt doing anything. except when walking upstairs, then it starts blinking Could someone help?
@EricZeBaws
@EricZeBaws 8 жыл бұрын
Sorry I have one more question, How do you check a border in sfml. Ex If an object is touching the border it will do something
@HilzeVonck
@HilzeVonck 8 жыл бұрын
+EricZeBaws do you mean the border of the screen?
@EricZeBaws
@EricZeBaws 8 жыл бұрын
Yes
@HilzeVonck
@HilzeVonck 8 жыл бұрын
Here you go, this function will check if a collider touches the border of a view. bool TouchesViewBorder(Collider collider, sf::View view) { sf::Vector2f colliderHalfSize = collider.GetHalfSize(); sf::Vector2f colliderPosition = collider.GetPosition(); sf::Vector2f viewHalfSize = view.getSize() / 2.0f; sf::Vector2f viewPosition = view.getCenter(); float rdx = colliderPosition.x - viewPosition.x; float rdy = colliderPosition.y - viewPosition.y; float dx = abs(rdx) - (viewHalfSize.x - colliderHalfSize.x); float dy = abs(rdy) - (viewHalfSize.y - colliderHalfSize.y); if ((dx < colliderHalfSize.x * 2.0f && dx > 0.0f) || (dy < colliderHalfSize.y * 2.0f && dy > 0.0f)) { return true; } return false; } As you can see it looks almost exactly the same as the collision code for checking if two colliders are colliding. That is because a view also has a center position and a size. The only thing that really changed is the if statement at the end. This if statement consists out of two parts: (dx < colliderHalfSize.x * 2.0f && dx > 0.0f) and (dy < colliderHalfSize.y * 2.0f && dy > 0.0f). both of these parts basically do the same thing but one of them checks the collision on the x axis and the other one on the y axis. let's take one of these parts and see what it does. The first part (dx < colliderHalfSize.x * 2.0f) basically checks if the collider is within a certain range from the border (inwards), we need to multiply the halfSize by two because we need the full size for this calculation. The second part (dx > 0.0f) basically checks if the rectangle is within a certain range from the border (outwards). So the first part checks the collision for the left and top side of the collider and the second part checks the collision for the right and bottom part of the collider. The reason that they are separated by an or ( || ) is because we want this statement to be true whenever the collider is colliding with one of the sides of the view, and not just the corners.
@EricZeBaws
@EricZeBaws 8 жыл бұрын
Thanks so much!!
@estar500
@estar500 7 жыл бұрын
I keep getting the error 'bool Collider::checkCollider(Collider &,float)': cannot convert argument 1 from 'Collider' to 'Collider &' At the very end, I've tried re watching the video multiple times but the code seems to be fine, anybody know what is going wrong here?
@AdrianWitzil
@AdrianWitzil 6 жыл бұрын
Hey. I got the same error. Did you manage to resolve it?
@brianmontgomery6502
@brianmontgomery6502 6 жыл бұрын
I've got this one too... If I find a solution I'll post it
@brianmontgomery6502
@brianmontgomery6502 6 жыл бұрын
Okay the solution I found was to put this line before we check collisions between (platform1 and player) and (platform2 and player in main.cpp: 'Collision (name of your Collider member) = player.getCollider(); After that, just replace player.getCollider with (name of your Collider member) in both checkCollision calls that follow
@brianmontgomery6502
@brianmontgomery6502 6 жыл бұрын
As far as I can tell, the compiler just didn't want us to use a member function for this variable. If anyone has a better explanation, I would love to hear it.
@njsfryj
@njsfryj 6 жыл бұрын
Not a solution, but I did this tutorial a while back on VS community 2015, and the code worked exactly as is, I am redoing it now to get back into SFML with VS community 2017, and I get this exact same error. So, perhaps it is something weird in the newest iteration of the compiler. And your solution did work for me.
@elijahandrushenko6313
@elijahandrushenko6313 8 жыл бұрын
Can you do a tutorial on gravity, so that when you jump you will fall down and so that standing on blocks matters otherwise you will fall through the screen.
@HilzeVonck
@HilzeVonck 8 жыл бұрын
+Elijah Andrushenko Yeah, that is going to be the topic of the next video. :)
@lorow2542
@lorow2542 8 жыл бұрын
When we should expect it? :D
@HilzeVonck
@HilzeVonck 8 жыл бұрын
+SmykuPyka As soon as possible. I don't have any time to make an episode right now, but I'll probably have some time next week.
@HiagoRAD
@HiagoRAD 6 жыл бұрын
My getCollider function is not working! It has no match for Collider(body). Does anyone had the same issue?
@KKr0lik
@KKr0lik 8 жыл бұрын
I walk by the square, and its not moving. 0 errors or warnigs. whats wrong?
@traveler2158
@traveler2158 7 жыл бұрын
Maybe you should check if you are passing the body in the Collider class by a reference.
@fahdv2597
@fahdv2597 6 жыл бұрын
Bro how did you color code visual studio?
@ModerateDev
@ModerateDev 6 жыл бұрын
there's a bunch of tuts on YT
@dreamhollow
@dreamhollow Жыл бұрын
I like this, but it's a lot more difficult to get to work with smart pointers.
@koraykahraman9031
@koraykahraman9031 2 жыл бұрын
Please keep the tutorial videos coming
@fanut3599
@fanut3599 7 жыл бұрын
error: no matching function for call to 'Collider::CheckCollision(Collider, float)' anybody else had this problem? :(
@TheDorkol5
@TheDorkol5 3 жыл бұрын
would you happen to know of a way to write *(simple)* non OOP no structs nothing, just bare bones code. of aabb response of 2 regular rectangles. or point me in the right direction? i am desperate. ive spent hours and hours looking for a simple implementation that i can read, i just want to a solid square!!!!!! why is this so hard to find!!!!!!!!!!!!!!!!!. im sure its not ideal but its the only way i can understand it. so many tutorials. or rather always have the starting ccordinates as something crazy like "entity.x.whatever.idontcare = delta.whatever.why?"
@HilzeVonck
@HilzeVonck 3 жыл бұрын
You can use the same code as is in the final check collision method. Just also pass in the position for the first aabb as a reference the size of the first aabb, the position of the second aabb as a reference and the size of the second aabb. It shouldn't be hard to convert this to a simple, c like function.
@TheDorkol5
@TheDorkol5 3 жыл бұрын
@@HilzeVonck converting it is the problem I just wanna *(see)* an example so that I know how it works. Everything being in objects makes it way to hard to pick apart. Also I'm asking in every KZbin video about aabb resolution.
@Herovy070
@Herovy070 3 жыл бұрын
@ It could look something like this. (keep in mind that I just wrote the code and did not test it, so there might be some small syntax errors) The functionality of the function stays the same, the only thing that I changed is that we now are passing the positions and half sizes in directly, and we are also modifying these positions directly. Just make sure that the position that you pass in is the center of the AABB, and the size is half of the total size of the AABB. bool CheckCollision(sf::Vector2f& thisPosition, sf::Vector2f thisHalfSize, sf::Vector2f& otherPosition, sf::Vector2f otherHalfSize, float push) { float deltaX = otherPosition.x - thisPosition.x; float deltaY = otherPosition.y - thisPosition.y; float intersectX = abs(deltaX) - (otherHalfSize.x + thisHalfSize.x); float intersectY = abs(deltaY) - (otherHalfSize.y + thisHalfSize.y); if (intersectX < 0.0f && intersectY < 0.0f) { push = std::min(std::max(push, 0.0f), 1.0f); if (intersectX > intersectY) { if (deltaX > 0.0f) { thisPosition.x += intersectX * (1.0f - push); otherPosition.x -= intersectX * push; } else { thisPosition.x -= intersectX * (1.0f - push); otherPosition.x += intersectX * push; } } else { if (deltaY > 0.0f) { thisPosition.x += intersectY * (1.0f - push); otherPosition.x -= intersectY * push; } else { thisPosition.x -= intersectY * (1.0f - push); otherPosition.x += intersectY * push; } } } return false; }
@TheDorkol5
@TheDorkol5 3 жыл бұрын
@@Herovy070 wow to be honest this is way more than I could have asked for thank you I'll check it out when I get home. I appreciate it. I'm gonna go ahead and give you a like and a sub
@christiancarter255
@christiancarter255 2 жыл бұрын
It's not compiling, and it's telling me: "initial value of reference to non-const must be an lvalue" and "'bool Collider::CheckCollision(Collider &, float)': cannot convert argument 1 from 'Collider' to 'Collider &'" :(
@christiancarter255
@christiancarter255 2 жыл бұрын
I figured it out.
@mr.fantasy1
@mr.fantasy1 11 ай бұрын
how @@christiancarter255
@woff5
@woff5 7 ай бұрын
@@christiancarter255 what was wrong plz tell us
@christiancarter255
@christiancarter255 7 ай бұрын
@@woff5 I wish I remembered 😔😭
@woff5
@woff5 7 ай бұрын
@@christiancarter255 no worries someone had the same problem and had the awnser
@ThePlayerNotJump1
@ThePlayerNotJump1 7 жыл бұрын
You do know that, SFML has functionality to detect collisions right?
@mistermaddock
@mistermaddock 7 жыл бұрын
Frixoe i
@thewhiteprogrammer9633
@thewhiteprogrammer9633 2 жыл бұрын
bruh he is detecting aabb to do the tile collsion
@thewhiteprogrammer9633
@thewhiteprogrammer9633 2 жыл бұрын
Collsion GetCollider() { return Collsion(shape); there is a error coming collsion.h is not inaccesbile
@lva98
@lva98 7 жыл бұрын
Nice job, thanks!
@azaria_phd
@azaria_phd 2 жыл бұрын
10:35 reminder that std::clamp() exists too.
@sc5shout
@sc5shout 7 жыл бұрын
Im actually more confused then before. You're doing with the centers, others with some shit like min and max and some with x, y, w and h...
@anonymousgaming911
@anonymousgaming911 5 жыл бұрын
Delta is called Δ in Greek Its the letter D
@johnlight-knight8060
@johnlight-knight8060 5 жыл бұрын
I didn't understand the init-list (body(body)) but I will try to understand. :D
@boenaman4154
@boenaman4154 4 жыл бұрын
What this means is that the private variable body, will be initialized by the parameter body which is given by the constructor.
@tundrummax6221
@tundrummax6221 6 жыл бұрын
will this only ever work for squares? will it ever work for rectangles?
@tundrummax6221
@tundrummax6221 6 жыл бұрын
Nevermind, I can see that it works.
@navaneeth6157
@navaneeth6157 6 жыл бұрын
holy shit this is soo hard :)
@ahoiioha
@ahoiioha 8 жыл бұрын
Hey, first, its a good tutorial, thank you. But could you pleaseupload your code to github or something else? I'm geting two errors in the code for this two lines: platform1.GetColider().CheckCollision(player.GetCollider(), 0.0f); platform2.GetColider().CheckCollision(player.GetCollider(), 1.0f); Invalid arguments ' Candidates are: bool CheckCollision(Collider &, float) ' Invalid arguments ' Candidates are: bool CheckCollision(Collider &, float) ' invalid initialization of non-const reference of type 'Collider&' from an rvalue of type 'Collider' invalid initialization of non-const reference of type 'Collider&' from an rvalue of type 'Collider' Can anybody help?
@Herovy070
@Herovy070 8 жыл бұрын
I have actually been working on rewriting all the code to upload to the site that I am building all day. All of the source code for this video should be up there. Here is the link: lucrifi.com/index.php/24-sfml-2-4-for-beginners-12-collision-detection-aabb?start=1. As a note though. The site is not yet finished at all, so if something is wrong or if something does not work, It'll be fixed as soon as possible. I think that the problem is either in the player's GetCollider() function or in the variables that you are passing into the CheckCollision() function. Make sure that the player's GetCollider() is NOT returning a reference to a collider. And make sure that the CheckCollision() DOES have references to the collider (both in the .h and the .cpp).
@HilzeVonck
@HilzeVonck 8 жыл бұрын
+Herovy070 whoops, I replied with my secondary YT account. Herovy070s reply is mine.
@ahoiioha
@ahoiioha 8 жыл бұрын
Thanks for the quick respons, I checked your link and checked your code with this page www.qualidator.com/WQM/de/Tools/TextDiff.aspx, I could not see any significant difference to my code, This is the play's GetCollider() Collider GetCollider() { return Collider(body);} and this is CheckCollision() in .h bool CheckCollision(Collider& other, float push); in .cpp bool Collider::CheckCollision(Collider & other, float push){
@rasen_nax
@rasen_nax 8 жыл бұрын
Hi,Thx for this great tutorial! I'm using code::block and got the same error even after copying all files from lucrifi.com/index.php/24-sfml-2-4-for-beginners-12-collision-detection-aabb?start=1. I've solved it by using bool CheckCollision(Collider , float).
@muffinspuffinsEE
@muffinspuffinsEE 7 жыл бұрын
Please help! I have the same issue, or if there is anyone else who has a fix for that matter.
@AndrewOBannon
@AndrewOBannon 8 жыл бұрын
thanks
@ricanteja
@ricanteja 7 жыл бұрын
Great video but I got a question. Why didn't you just use self.getGlobalBounds().intersects(other.getGlobalBounds()); ? Much simpler for AABB IMHO
@AdrianWitzil
@AdrianWitzil 6 жыл бұрын
Hey Ricardo, I got an error. Can you give me a hand?
@mosesvalentin1600
@mosesvalentin1600 5 жыл бұрын
yeah that's what I thought too
@AdrianWitzil
@AdrianWitzil 6 жыл бұрын
I did it!!!
@richardlighthouse5328
@richardlighthouse5328 7 жыл бұрын
Please I need missing Clip!!!!!!!!!!!!!!!!!!!!!!
@bondjovi4595
@bondjovi4595 Жыл бұрын
Redraw Relocate
@Donaldbeebi
@Donaldbeebi 4 жыл бұрын
this guy reminds me of pewdiepie lmao
@yagami1160
@yagami1160 Жыл бұрын
why was I making this whole lot of stupid stuff
@vedatemin7639
@vedatemin7639 2 жыл бұрын
platfom1.GetCollider().CheckCollision(player.GetCollider(), 0.0f); platfom2.GetCollider().CheckCollision(player.GetCollider(), 1.0f); player gives an error in my code?
@woff5
@woff5 7 ай бұрын
yeah same did you figure it out
SFML 2.4 For Beginners - 13: Jumping.
16:37
Hilze Vonck
Рет қаралды 45 М.
Collision Detection (An Overview) (UPDATED!)
7:27
MacroPixel
Рет қаралды 44 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
Software Engineering has forever changed - What's Next
11:53
Cody Codes
Рет қаралды 1,5 М.
Bounding Box Collision Detection - Game Coding Tutorial
9:15
Bytes N Bits
Рет қаралды 10 М.
SFML 2.4 For Beginners - 9: Animation.
15:50
Hilze Vonck
Рет қаралды 84 М.
Convex Polygon Collisions #1
36:40
javidx9
Рет қаралды 130 М.
Ray Tracing with Bounding Volume Hierarchies
15:40
GetIntoGameDev
Рет қаралды 3,1 М.
K-d Trees - Computerphile
13:20
Computerphile
Рет қаралды 242 М.
One year of my C++ SFML journey
5:39
Snapi
Рет қаралды 431 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН