Collision just doesn't work.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
lolcon9
Prole
Posts: 1
Joined: Tue Mar 02, 2021 4:18 pm

Collision just doesn't work.

Post by lolcon9 »

Hey so I am trying to make a top down shooter game, but I am having many different issues. I am not sure if those issues are occurring due to something going wrong with the installation of LOVE2D, the installation of the love framework in Atom (oh yeah I use Atom text editor) or just me being dumb. When I made pong using a tutorial, while you can play the game, many of the things that are supposed to work just don't. For example, when making the AI paddle track the ball, while it will do that, it does it very like not smoothly. Also, adding something like a timer/delay onto the paddle does nothing. The hitboxes are also very glitchy, and 1 wrong move means that the collision just breaks and senses that as long as the ball has the same x position of the player then it hit the paddle. Another thing is that collision just straight up doesn't work at the top of the window.
I said all of that just too give you an idea of what is wrong with everything. With the pong example, I followed a tutorial on YouTube so perfectly that you can mix my code with his code and it will look like nothing happened (as in switch his main.lua with mine or something). Now for the problems that I have encountered while making this top down shooter, with no tutorials. The only thing that I can do is look at the forums and the wiki. I can also post things on the forum if I don't find answers. Anyways back to the point.
So the first thing that I want to mention is that I implemented a system where if the player moves outside of the window, it's position would be just set back into the window. I am not sure if this is a logic error, but for some reason the function just doesn't work. Instead of setting the position back into the window, it just doesn't do anything. Another problem that I have is that when I try and put in Bounding Box collision, it says that it can't find anything called "x2" which is fair enough. I still don't see why it says that, though it makes sense considering that I still really haven't defined it, even though I don't think that I should have to do that. When I first started to add collision, it worked. By worked I mean it didn't crash the program. What it does do is just not work. I set the collision so that if the player collides with another box, the box should move. The other box just didn't move. I also tried to color the enemy red, and it also colored the player red (I have my code so that everything is in a different file, with main.lua starting off with requiring those files). I'll post a download to my files, since there are a lot and they are quite long (mainly the bullet and the player). Please check everything and tell me if there is something that I did wrong, or a logic error or something. If there isn't anything wrong, then please tell me why all my code isn't working. Sorry for the long post but this is all the information that I have.
Okay so I can't figure out how to put a download, so can someone please tell me how to do that? I am new to the forums.
MrFariator
Party member
Posts: 543
Joined: Wed Oct 05, 2016 11:53 am

Re: Collision just doesn't work.

Post by MrFariator »

I think the forums don't let new users to attach files to posts right away, so you'll have to make a few more posts first, or link to some filehosting site. Maybe even copy-pasting your code to pastebin, and linking that here.

In the mean time, you could also share your code in your forum posts (remember to use the [ code ] tags). Just need the relevant snippets to see why something might not be working, like the thing you mention about snapping-player-back-in-to-window.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests