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 / Sprite shape problems

Author
Message
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 22nd Nov 2012 12:32
I have a couple issues - hope someone can shed some light.
1. Why can't I see my physics debug shape on a dummy sprite which I have created using SetSpriteShapePolygon. The collision works as expected but I cannot see the shape (I can see other normal sprite shapes), making it very difficult to set the shape how I want it.

2. Can anyone tell me why my polygon shape (using SetSpriteShape(sprite,3)) shows the blue debug shape around the sprite but the actual collision shape is offset somewhat. I have used SetSpriteOffset on this sprite, but it still doesn't explain why the blue outline shown is not the actual collision zone??? Have been scratching my head for 3 days. If I use a circle or the bounding box shapes it works perfectly! Very annoying
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 22nd Nov 2012 14:06
Ok, if I SetSpritePhysicsOn I can now see the dummy sprite shape (in green). All good, but still question 2 exists, although box and polygon do not work as expected. If I use a circle, the circle shape is centered on the offset and collision works as expected (my player collides with the green physics circle). If I use a polygon it draws the shape (in green) where I expect, but the actual collision is happening at a different offset. Anyone might know what happens here?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 22nd Nov 2012 23:45
first set the offset then set the shape
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 22nd Nov 2012 23:59
I know to set the offset first. A circle works fine, for polygons (or box) the green sprite shape is drawn using 0,0 offset but the actual collision occurring as though the shape is centered on this point. Why would the debug shape shown not be the collision zone. Even if it was offset incorrectly surely the idea is for the debug shape to show this.
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 09:20
Please look at these images. Same code, using circle the collision works fine. I change one line to be box shape and the collision does not work but instead I collide with an invisible square offset from the debug shape. Any ideas why?

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2012 09:49
Can you share some code? It is hard to guess what you are doing wrong or if it's a bug otherwise. A simple, compilable example would be great.


this.mess = abs(sin(times#))
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 11:42
Run this code. Why don't the two shapes collide correctly??
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2012 12:11 Edited at: 23rd Nov 2012 12:18
OK, it seems that setSpriteShapeBox has the collision shape reversed. Also it doesn't work with offsets as described in the help.

Setting your shape up as follows will create a centralised box shape that collides correctly and as expected:
SetSpriteSize(2,50,50)
SetSpriteShapeBox(2,10,10,40,40,0)

If you want your box shape to be offset from centre you have to reverse the positioning and ignore the debug shape drawn.

I will raise this as an issue on the bug board if it isn't already there. Sorry for the trouble this has caused you, it's certainly a tricky bug!

EDIT: Bug raised here: http://code.google.com/p/agk/issues/detail?id=441&thanks=441&ts=1353669485


this.mess = abs(sin(times#))
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 12:21
Wow, I thought I was going crazy! This problem also exists with SetSpriteShapePolygon; the example shown was simply that, an example to demonstrate. My problem is I need to use offsets for my shapes because the objects are on an isometric map and I change player depth based on the offset point of the object (so the player can move 'behind' the object). Mostly I'm using polygons and not squares. Looks like I'm stuck for the moment...
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 12:21 Edited at: 23rd Nov 2012 12:22
Thanks for your help baxslash, much appreciated.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2012 12:23
I have been using polygon shapes with no problem. Have you tried using my ShapeUp program?

ShapeUp


this.mess = abs(sin(times#))
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 12:37
I've seen your ShapeUp briefly before. I'll take a look. Also noteworthy is the previous code is only problematic between circles and polygons (or box). Change one to match the other the problem disappears!
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 23rd Nov 2012 13:13
Funny, that circle <-> "little rectangle" collision works ok if you reverse the checking order..

if GetSpriteCollision(1,2) then print("Collision")
to
if GetSpriteCollision(2,1) then print("Collision")

Anyway, lets hope the bug is fixed fast. (I have other collision problems with physics shapes )
Atreyu
11
Years of Service
User Offline
Joined: 16th Oct 2012
Location: Australia
Posted: 23rd Nov 2012 13:33 Edited at: 26th Nov 2012 01:24
Jogimus, well done. Yes the box collision seems to work if the checking order is reversed. However, try this code using a polygon. Very buggy. Guys, we need this fixed fast, this does not work at all.


UPDATE: My workaround is to create my collision shape as an image and use SetSpriteShape(sprite,3) to create this shape. This looks to be working, but means creating images for collision shapes I was hoping to only use dummy sprites for. Looks like the problems exist in SetSpriteShapeCircle, SetSpriteShapeBox, and SetSpriteShapePolygon only.

UPDATE: Looks like SetSpriteShape(sprite,3) is also reversing the shape as mentioned earlier.

UPDATE: I have had some success by reversing the checking order in GetSpriteCollision for either circle-circle or circle-polygon collisions.

Login to post a reply

Server time is: 2024-05-05 21:01:23
Your offset time is: 2024-05-05 21:01:23