Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / What exactly is different with the collision in 108.11?

Author
Message
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Apr 2013 11:25 Edited at: 14th Apr 2013 11:25
OK, so I just installed 108.11. I think I remember something about collisions but couldn't find any about this in the change log. Problem is, my collision boxes are not where they were in 107.6. I don't have time to sit down and start experimenting. If someone could tell me in what way it has changed, it would really help me. Below is my code for setting up the hero sprite and also a screenshot from my editor with visible collision boxes.





Attachments

Login to view attachments
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 14th Apr 2013 11:39 Edited at: 14th Apr 2013 11:42
The offset on SetSpriteShapeBox is "fixed"

The offset is now figured from the center of the sprite, at least before you change offset, but probably after too in the case of setting the shape. I always set shape before I change offset so I'm not sure.

My hovercraft is full of eels
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Apr 2013 11:47
So it positions the box relative to the offset point now instead of the top left corner of the sprite? Not so sure that is the best solution but I can work with that. Thank for the help

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Apr 2013 20:43
Something else have definitely changed because my hero falls through the level tiles. I am using the contact commands and seems like I get no contacts reported between the hero sprite and the level tiles.

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 14th Apr 2013 22:57
How are you checking the contact?

My hovercraft is full of eels
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 15th Apr 2013 00:43
This is from my collision function. It worked in 107.6. I added the print command as a test and get nothing. The level tiles are static objects the hero is dynamic. I use sprite groups, categories and collision bits.



lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 15th Apr 2013 11:15
I'm guessing something has happened with either categories or bits then after the update. I think groups still work for me but I haven't tried the other two since updating.

I'm curious though, I will run some tests later I think

My hovercraft is full of eels
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 15th Apr 2013 15:53
This is something I need to fix so I will try to replicate this in a test project when I have the time.

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 15th Apr 2013 18:54
I believe it may be the category bits, we added a new command SetSpriteCategoryBit to set each bit individually possibly because we couldn't support the binary values in Freedom Engine.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 15th Apr 2013 19:05
Paul:
I already use SetSpriteCategoryBit. That and SetSpriteCollideBit are already in 107. Those and the binary mask versions have been around. But perhaps you have altered the commands somehow?

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 16th Apr 2013 13:55
No matter what I do in my test project my code seems to do fine. I have to investigate further about why my collisions have stopped working in 108.11. Here's my test code. I have done everything I can think of and it still works.



Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 16th Apr 2013 14:23
I made the player able to fly in RTA and I get no contacts reported between the player and everything else. But I can hit enemies with the sword and the plants can bite the player. The only thing special with these attacks are that they are dummy sprites. The projectiles the plants shoot should be the same as the attacks except they move, but they don't register contacts. Does it have something to do with moving the sprites?

EUREKA!!!

Made the player move in the test project and no contacts reported:


Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th Apr 2013 16:27
Moving physics sprites manually has to be done in a special way, firstly you should use kinematic objects SetSpritePhysicsOn(ID,3) so the physics engine knows that it will be moving, and secondly changing an objects position wipes out any existing contacts until the next physics step when they are recalculated. So in your case you'd want to check all the contacts first, then reposition the objects ready for the next frame, then call sync.
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 17th Apr 2013 18:13
Is that how you moved "hero" in your game too DA?

My hovercraft is full of eels
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 17th Apr 2013 18:24
Paul:
I cannot use a kinematic sprite I have to use dynamic, otherwise it wont register any contacts at all. My code works in 107.6, but not in 108.11. This is from the AppGameKit help file.

Quote: "
The mode parameter lets you choose how the sprite should behave in the physics world. Static means it will never move or rotate, dynamic means it will respond to all collisions and forces it encounters, including gravity and collisions with static objects. Kinematic is a special case which can be thought of as a moving static body, it will not respond to collisions or forces and will continue at its specified velocity forever, but dynamic items will respond to it and effectively be pushed out of the way.
"



I did try moving the sync up before the collision check. And this works with my test. However, if I call sync before checking for contacts and repositioning the sprite the hero will be drawn partly inside the level tile. Seems like I must update the physics and the screen separately for this to work, at least in 108.11.

Why has this changed from 107.6?

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 17th Apr 2013 18:27
Quote: "Is that how you moved "hero" in your game too DA?"

Basically, yeah. I do not use the built in physics because I couldn't get the controls to work as I wanted. Spent weeks trying to get them to work. I only use the contacts.

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 17th Apr 2013 18:33
I see. Kinda feels like that's asking for trouble, using the physics system but setting the position yourself. But since it worked before, why not

As a side note I find that setting velocity is the "best" way to use the physics system in a platformer since it gives you direct control but at the same time utilizing the power of box2d.

My hovercraft is full of eels
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 17th Apr 2013 18:43
Can anyone advice me to how I should go about updating the physics and the screen separately? I know there are commands for this but I have never used them.

lilpissywilly:
It's so hard to get a perfect experience with the built in collisions. I have not yet seen a game using it that works exactly how I want it to. My game have one tiny bug in the collisions that I doubt that anyone will notice it. Well, with the exception of low frame rates because the objects start moving too far per frame. I take controls/gameplay very seriously.

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 17th Apr 2013 18:52
That is very true, it's extremely hard to make it feel right, and behave similar(same) every time you play.

My hovercraft is full of eels
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Apr 2013 02:32
You cab use StepPhysics(GetFrameTime()) to update the physics without drawing, then you can get the contacts and Sync later, the Sync won't update the physics again for that frame.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Apr 2013 19:27
Thanks Paul. I'll experiment with this. I need to arrange my code a bit differently.

Login to post a reply

Server time is: 2024-05-02 01:01:10
Your offset time is: 2024-05-02 01:01:10