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 / Wrong coordinates returned from GetSpriteContactWorldX/Y ??

Author
Message
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 21st Nov 2012 18:36
I'm trying to get physics contact point from just one sprite and these point seems to be wrong at some times.. my sprite just floats and sometimes hits map sprites so I can see clearly where contact should be. Now it seems to give me contacts that were true earlier.

I place particle emitter to contact point to get some nice sparks but now sparks appear in wrong places..

(contains some debugging lines..
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Nov 2012 18:32
Did you set physics for all of the sprites involved?

(Also, what version are you using: v1076, v1082, v1083)

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 25th Nov 2012 19:26
Yes I did and I tried both v1076 and v1083 beta. Same result on both and I tried polygonal and square collision shapes, same result.

From attached image you can see how strange collision point can be..

Attachments

Login to view attachments
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 25th Nov 2012 19:30
This was bit wrong: " Now it seems to give me contacts that were true earlier. " This does not seems to be case, it just almost randomly picks coordinates that are not near contact area, looks bit like x/y/or both coordinates jump around the sprites origin..
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Nov 2012 16:06
I can't see what's wrong in the image you posted.

The physics box for the ship is in contact as it should be in both images, based on it's shape (a box).

The 'not ok' image has three contacts and the 'ok' image has two.

How is the 'not ok' image not okay?

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 26th Nov 2012 16:38
Sorry, I forgot to write that there is that yellow point sprite in picture that shows GetSpriteContactWorldX and Y coordinate (first one), in "not ok" picture contact point is far away from actual contact/collision points.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Nov 2012 19:05
Okay, that does make a difference.

Have you tried taking "GetParticlesMaxReached( 2 )=1 AND" out of the if statement and see what happens?

I don't know if the AppGameKit engine caches contacts and is reporting something that happened earlier.

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 26th Nov 2012 19:43
I did try that and few other trick that could make difference, like getting that second sprite that was collided (GetSpriteContactSpriteID2) and then checking that sprite contact x/y coordinates.. but same result.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Nov 2012 16:05
How about doing a loop that collects all contacts after the first one and just ignore them:


This is based more on your first code snippet than your last.

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 28th Nov 2012 17:54
Same result with that code.. I tried polygonal and box shapes, they gave similar contact placing errors but circle shape somehow gave circle center as contact point!! Even more odd..
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Nov 2012 18:18
Can you show some of the code for how you are creating the sprites?

It is sort of hard to debug with limited information.

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 29th Nov 2012 07:37 Edited at: 29th Nov 2012 17:51
I'm at work now so I tried to make little collision test with trial AppGameKit (might behave differently than norman AGK).. it is different than code I use but I hope it shows something. Use mouse to "guide" one sprite collide other in different angles/sides. Small rectangle shows collision point and very small one is just for mousejoint.



edit: typo fixed "GetSpriteContactWorldX()" -> Y
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Nov 2012 15:48
I'll give it a test in v1076 and v1083 if you'll load the image file referenced (or tell me the shape/size of it).

Cheers,
Ancient Lady
AGK Community Tester
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 29th Nov 2012 17:45
It is a 50*50 square sprite image from "Physics-StaticAndDynamic" example.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Nov 2012 18:16
Okay, tested in v1076.

Strange behavior indeed.

If the contact point is between a flat edge on the moving sprite and a corner on the non-moving one, the reported/displayed contact is in the correct place.

If it is between a corner on the moving and a flat on the non-moving, it reports the contact on the corner of the non-moving one that corresponds to the corner on the moving one that actually made contact.

If I use a round image and set the shape on sprite 3 to circle, the 'reported' contact point is always the center of sprite 3.

If I make sprite 2 a circle and sprite 3 a box, the contact point is always in the center of sprite 2.

Setting both to square and box, and we are back to wierd reporting.

The behavior persists in v1083 and v1084.

This is officially a bug.

I'll report/confirm it in the official bug lists.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-05-03 06:16:16
Your offset time is: 2024-05-03 06:16:16