Rotate map AND physics

How would I go about rotating a map AND the physics? I can rotate the map just fine, using map.rotation = whatever, but doing physical.rotation = whatever doesn't work. Help anyone?

I'm not at my Pc right now but if map.world.rotation doesn't work then you may have found a bug.

Hmmm. It's on hybrid mode, and the hybrid boxes move with the map, but the player doesn't interact correctly. It still sits on a platform that existed before the map was rotated. I've inserted the player into a tilemap layer, but do I need to do something else? Here's a link to the code: http://cl.ly/062y1u241H1z3m1y3D3z (check level1.lua, line 21 for the rotation stuff)

I think you may have found a bug/limitation in Corona itself, as if you see my simple test here - http://dl.dropbox.com/u/571145/RotationTest.zip - rotation with physics all works fine when you rotate the image itself but if you rotate the group that the image and body are in it all goes haywire.

To demonstrate this just run the linked project and click above the rotating box, you will see the new boxes fall fine (well nearly fine, there are some oddities when you hit the rotating box at certain angles) but if you comment back in line 29 and comment out line 30 to rotate the group instead the physics doesn't seem to rotate correctly and the new boxes will land on an invisible physics body.

presumably when you rotate the image group, you're not actually also rotating the gravity. won't this affect things?

Hi! Sorry to hijack but I am facing the same issue as NayGames. Has this been confirmed as a bug or are there any workarounds?

I have found another forum post with a similar issue.

https://developer.anscamobile.com/forum/2011/03/14/physics-and-groups

Hey,

I have just yesterday added in some rotation helpers to the code, however haven't made a release yet (haven't made one for a while actually, trying to wait till I have something bigger in it) but if you can get access to the SVN then you should be able to get those fixes.

However I can't guarantee they will solve your issues as they don't fix the weird physics in groups issue that for quite a while I've been thinking was a Lime only issue however after reading that thread you just linked me it is clear that it is happening outside of Lime too. And from the sound of that thread it wasn't always like this.

I will try to get Ansca more aware of this issue to see if they can shed some light on it.

The hybrid mode does not work well with rotation and scaling. The actual physics will rotate fine if in a group but the hybrid mode will not overlay correctly.

The hybrid mode is only designed as an aid to setting up your collisions and cannot be used reliably with rotations and I would recommend that on a device it is disabled as it has quite a large processor overhead.

As for map rotations, ive had not issues with Lime as such but in general you will notice artefacts at the edges of the tiles when at certain angles due to a number of things not necessarily related to Lime but how openGL / Corona works.

As far as physics goes, Ive had a lot of discussions with Ansca about how and why things happen and the limitation involved. The best thing not to rotate objects with physics manually. Insert everything into one group and rotate the group, everything in the game ( that has physics) should be in this master group.

Yea it's that limitation/issue about having all physics bodies in a single group that is causing issues, I'm thinking how things could be sorted in Lime so that could be done.

@Matthew Pringle: Weirdly, I am getting the opposite behaviour than the one you described. The hybrid mode shows the layout of where the physics should be nicely, i.e. rotated. But the actual physics is still in the original position. Kind of similar to the code which I linked in my previous post. I will try some more tweaking in the next few days.

@GrahamRanson: I did put everything in one group as suggested in another post but to no avail.

I have now noticed that display group does not play a part in the wrong physics in my code. The thing is, if I rotate the ground from a different axis, the physics will not move.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
local physics = require( "physics" )
physics.start()
physics.setDrawMode("hybrid");
 
local crate = display.newCircle(180, 0, 10);
physics.addBody( crate, { density=3.0, friction=0.5, bounce=0.3, radius = 10 } )
 
local circle = display.newCircle(180, 400, 100);
physics.addBody( circle, "static", { friction=0.5, bounce=0.3, radius = 100 } )
 
-- rotation from another reference point does not move the physics
circle.xReference = -180;
circle.yReference = -400;
circle.rotation = 30;

Hi,
Seeing that this topic is from March 2011, I am following up. I was looking at doing a rotation of map as well, but haven't actually started coding for this.

I figured rather than waste time, I'd follow up to see if this is possible yet, I've been reading the replies and such and it appears there are issues.

Is this a workable feature as of yet (Rotation of map, and physics objects but not the physics itself)? I am using lime for my basic mapping for grids and such, but then I am snatching the x/y coords and coding natively in Corona and using lime to load the map borders. All the physics objects are running natively in Corona (higher performance, and limitations such as bezier curves and odd shapes I had to use PhysicsEd to code)

Right off the bat, I think groups and rotate the groups and physics objects, and don't rotate the player. It's either that or keep spinning the device around which I am not sure would be fun or not.

Anyway, if someone has this working already, let me know?

-Nick G.

views:2050 update:2011/10/13 16:30:09
corona forums © 2003-2011