Ahh I see, so the value of 30 is the radius, not the diameter. Thank you.FruityLark wrote:In your custom border collision code, you are dividing the circle radius by 2 as if it were the diameter. There will be no shape intersection if you use 30 (half the width of your circle) instead of 30/2.
Also you should have player:draw('line') instead of player:draw('line',50) on main.lua:103
Hardon Collider Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: Hardon Collider Help
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: Hardon Collider Help
Don't worry I've fixed it now.Muzz wrote:I did, the wall collision worked fine?
But from this another problem has arised.
The collision with the sqaure is also offset.
- FruityLark
- Prole
- Posts: 28
- Joined: Sat Jun 13, 2015 8:18 pm
Re: Hardon Collider Help
Since the square is a collider shape, you need to fix the onCollide function.
When you fix this, you will have an interesting situation where the ball jumps to the other side of the square as you continue to force the camera past the square.
When you fix this, you will have an interesting situation where the ball jumps to the other side of the square as you continue to force the camera past the square.
Code: Select all
function onCollide(dt, shape_a, shape_b, dx, dy)
if shape_a.type == "player" then
--movement.yvel = 0
--movement.xvel = 0
shape_a:move(dx, dy)
end
end
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: Hardon Collider Help
How do I calculate dx and dy?FruityLark wrote:Since the square is a collider shape, you need to fix the onCollide function.
When you fix this, you will have an interesting situation where the ball jumps to the other side of the square as you continue to force the camera past the square.
Code: Select all
function onCollide(dt, shape_a, shape_b, dx, dy) if shape_a.type == "player" then --movement.yvel = 0 --movement.xvel = 0 shape_a:move(dx, dy) end end
The player just seems to go right past the sqaure
- FruityLark
- Prole
- Posts: 28
- Joined: Sat Jun 13, 2015 8:18 pm
Re: Hardon Collider Help
Declare your onCollide function exactly the same as I showed, and you can just use them.
HC provides these values (dx, dy) for you to resolve the collision.
You also need to add the property 'type' or 'name' or whatever to your player shape, else the if statement in onCollide won't fire.
HC provides these values (dx, dy) for you to resolve the collision.
You also need to add the property 'type' or 'name' or whatever to your player shape, else the if statement in onCollide won't fire.
Code: Select all
player = collider:addCircle(movement.x, movement.y, 30)
player.type = "player"
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: Hardon Collider Help
Hmm, still the problem ...FruityLark wrote:Declare your onCollide function exactly the same as I showed, and you can just use them.
HC provides these values (dx, dy) for you to resolve the collision.
You also need to add the property 'type' or 'name' or whatever to your player shape, else the if statement in onCollide won't fire.
Code: Select all
player = collider:addCircle(movement.x, movement.y, 30) player.type = "player"
Code: Select all
function onCollide(dt, a, b, dx, dy)
if a.type == "player" then
-- movement.yvel = 0
-- movement.xvel = 0
a:move(dx,dy)
end
end
- FruityLark
- Prole
- Posts: 28
- Joined: Sat Jun 13, 2015 8:18 pm
Re: Hardon Collider Help
I can't see what you're missing without the code. Try the attached version.
- Attachments
-
- game-updated.love
- (117.62 KiB) Downloaded 71 times
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: Hardon Collider Help
just set the velocity to 0 now?FruityLark wrote:I can't see what you're missing without the code. Try the attached version.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests