Collisions on my tile scroller don't work well at all.

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
GooseyMcGoosington
Prole
Posts: 4
Joined: Tue Sep 26, 2023 9:20 pm

Collisions on my tile scroller don't work well at all.

Post by GooseyMcGoosington »

I have basic entity collisions for things like monsters, the player, etc. However, there's a problem where it jumps up and down as I try to correct the player position if it's went into the block. My world starts at X0, Y0 so, a block to the right would be X1, down would be Y1.

My whole game is in the .love file. If anyone has any ideas on what I should do or is able to post code that is a solution, then I'd be happy to listen. I apologise if there is anything left out. If you need anything else, then I'll be happy to answer.

I want to be able to never go through solids regardless of how fast I am. Like any other game engine. Sorry if I am sounding like I am requesting anything or whatever.
Attachments
Tunneler.love
(5.37 KiB) Downloaded 98 times
User avatar
darkfrei
Party member
Posts: 1196
Joined: Sat Feb 08, 2020 11:09 pm

Re: Collisions on my tile scroller don't work well at all.

Post by darkfrei »

GooseyMcGoosington wrote: Tue Sep 26, 2023 10:28 pm I want to be able to never go through solids regardless of how fast I am. Like any other game engine. Sorry if I am sounding like I am requesting anything or whatever.
You are need to use rays and find intersections along the whole ray from start position until your deltaX and deltaY.

For example by using the diagonal marching from here:
viewtopic.php?p=254145#p254145
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
GooseyMcGoosington
Prole
Posts: 4
Joined: Tue Sep 26, 2023 9:20 pm

Re: Collisions on my tile scroller don't work well at all.

Post by GooseyMcGoosington »

darkfrei wrote: Wed Sep 27, 2023 10:57 am
GooseyMcGoosington wrote: Tue Sep 26, 2023 10:28 pm I want to be able to never go through solids regardless of how fast I am. Like any other game engine. Sorry if I am sounding like I am requesting anything or whatever.
You are need to use rays and find intersections along the whole ray from start position until your deltaX and deltaY.

For example by using the diagonal marching from here:
viewtopic.php?p=254145#p254145
sorry if this is a dumb question, but how should I try implement it with my x and y pos, and vels?
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Collisions on my tile scroller don't work well at all.

Post by Bobble68 »

GooseyMcGoosington wrote: Tue Sep 26, 2023 10:28 pm I have basic entity collisions for things like monsters, the player, etc. However, there's a problem where it jumps up and down as I try to correct the player position if it's went into the block. My world starts at X0, Y0 so, a block to the right would be X1, down would be Y1.

My whole game is in the .love file. If anyone has any ideas on what I should do or is able to post code that is a solution, then I'd be happy to listen. I apologise if there is anything left out. If you need anything else, then I'll be happy to answer.

I want to be able to never go through solids regardless of how fast I am. Like any other game engine. Sorry if I am sounding like I am requesting anything or whatever.
Ok so I'd like to preface this that it's obvious that you're quite inexperienced at using lua (and potentially coding in general), and it's fine to make mistakes. With this in mind, I'd seriously recommend trying a simpler project than the one you're currently attempting.

I'm trying to give you good advice on what exactly to fix, but the way it's coded is quite unclear and messy, so I'm struggling to find the exact code that needs changing - but from what I can see of playing it, the jittering you're getting is caused by the player being put in the wrong spot when it collides with a block.

I would recommend reading these two chapters from Sheepolution:
https://sheepolution.com/learn/book/13
https://sheepolution.com/learn/book/23
In fact, I would recommend reading the whole thing, it's pretty good at teaching Lua and Love2D.
Dragon
GooseyMcGoosington
Prole
Posts: 4
Joined: Tue Sep 26, 2023 9:20 pm

Re: Collisions on my tile scroller don't work well at all.

Post by GooseyMcGoosington »

Bobble68 wrote: Wed Sep 27, 2023 11:25 pm
GooseyMcGoosington wrote: Tue Sep 26, 2023 10:28 pm I have basic entity collisions for things like monsters, the player, etc. However, there's a problem where it jumps up and down as I try to correct the player position if it's went into the block. My world starts at X0, Y0 so, a block to the right would be X1, down would be Y1.

My whole game is in the .love file. If anyone has any ideas on what I should do or is able to post code that is a solution, then I'd be happy to listen. I apologise if there is anything left out. If you need anything else, then I'll be happy to answer.

I want to be able to never go through solids regardless of how fast I am. Like any other game engine. Sorry if I am sounding like I am requesting anything or whatever.
Ok so I'd like to preface this that it's obvious that you're quite inexperienced at using lua (and potentially coding in general), and it's fine to make mistakes. With this in mind, I'd seriously recommend trying a simpler project than the one you're currently attempting.

I'm trying to give you good advice on what exactly to fix, but the way it's coded is quite unclear and messy, so I'm struggling to find the exact code that needs changing - but from what I can see of playing it, the jittering you're getting is caused by the player being put in the wrong spot when it collides with a block.

I would recommend reading these two chapters from Sheepolution:
https://sheepolution.com/learn/book/13
https://sheepolution.com/learn/book/23
In fact, I would recommend reading the whole thing, it's pretty good at teaching Lua and Love2D.
i understand lua just fine - i've used it in ROBLOX before, but i'm on Love2D now which is quite different. it's just that I don't know how I should do the collisions properly.

each scripts just do different things - entities are for moving objects like the player for example. lighting and physics do nothing anymore, though. apologies about it being messy. it'd be helpful to know what method to do for collisions anyways, because i'd be able to research about that thing and attempt to implement it into my game.
User avatar
darkfrei
Party member
Posts: 1196
Joined: Sat Feb 08, 2020 11:09 pm

Re: Collisions on my tile scroller don't work well at all.

Post by darkfrei »

GooseyMcGoosington wrote: Wed Sep 27, 2023 9:52 pm sorry if this is a dumb question, but how should I try implement it with my x and y pos, and vels?
Your velocity is a coordinate difference between two frames. If your movement is slow, it can be just 1 pixel per frame, but by the velocity 6000 it makes line 100 pixels by 60 fps.

The main idea is to find collisions between this line (in order from start to the end of line) with all possible solids, as tiles, rectangles, polygons and lines. If collision found then the end position must be earlier as the end of line.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests