body.isFixedRotation doesn't seem to work

Hi,

I have a bouncing crate that I apply a large horizontal force on when it hits the ground. This causes the crate to bounce to one side. I then detect it going off screen and do a “screen wrap” on it by setting the x value. However I noticed that after a couple of wraps, the crate starts to spin. To prevent it, I tried setting isFixedRotation to true on the crate. Unfortunately it doesn’t seem to prevent the spinning.

Am I missing something? [import]uid: 8434 topic_id: 1909 reply_id: 301909[/import]

For a working example, run the “DragPlatforms” sample code: the Question Block has fixed rotation, and can’t be made to spin, but the Companion Cube and the crate will spin normally. I just tested this in our new release, and it seems to work as expected.

I’m not sure what would be different in your case, but you could try setting object.rotation=0 and object.angularVelocity=0 whenever the crate wraps around. [import]uid: 3007 topic_id: 1909 reply_id: 5626[/import]

Well it appears I was setting isFixedRotation before I added the physics body. Thanks for the help! [import]uid: 8434 topic_id: 1909 reply_id: 5666[/import]

I’m having trouble with this too. Isn’t isFixedRotation supposed to prevent ALL kind of rotations?
Because currently, no matter if I set the property before or after adding the physics body, if the player is on the edge of a platform, the sprite will rotate unless I use an ugly hack and keep resetting the rotation to 0 in a runtime enterFrame event.

Does anyone have an idea why it is not working? (tried on build 484 and 268) [import]uid: 51516 topic_id: 1909 reply_id: 34799[/import]

I was setting isFixedRotation before I added the physics body

as Poonaka has said it will solve ur issue

first add object to physics body

and then apply isFixedRotation make sure for the spelling it will solve problem [import]uid: 12482 topic_id: 1909 reply_id: 34804[/import]

I tried both, before and after, without any change. Hell, I even tried both at the same time without any visible effect! [import]uid: 51516 topic_id: 1909 reply_id: 34805[/import]

replace below sprite with any one and see

in config file i had set 1024 * 768

[lua]module(…, package.seeall)

function new()
local localGroup = display.newGroup()

require “sprite”
local physics = require “physics”
physics.start()
physics.setGravity(0,10)
local eagleSprite = sprite.newSpriteSheet( “eagle.png”, 55, 95, 15 )
local eagleSprite_set = sprite.newSpriteSet(eagleSprite, 1, 15 )
sprite.add( eagleSprite_set, “eagleSprite_set”, 1, 15, 200, 0 )
local eagle = sprite.newSprite( eagleSprite_set )
eagle:prepare(“eagleSprite_set”)
eagle.x = 512
eagle.myName = “eagle”
eagle.y = 240
eagle:play()
local Width = eagle.width * 0.5
local Height = eagle.height * 0.4
local eagleShape = {-Width,-Height,Width,-Height,Width,Height,-Width,Height}
physics.addBody(eagle,“dynamic”,{shape = eagleShape,density = 1})
–eagle.isFixedRotation = true
localGroup:insert(eagle)

eagle:applyForce(-10000,-1000,eagle.x,eagle.y)

for i=1,10 do
local rect = display.newRect(0,0,50,50)
physics.addBody(rect,“dynamic”,{bounce = 1})
rect:applyForce(10000,10000,rect.x,rect.y)
–rect.isFixedRotation = true
end

local wall = display.newRect(0,0,5,768)
physics.addBody(wall,“static”)

local wall1 = display.newRect(1000,0,5,768)
physics.addBody(wall1,“static”)

local wall2 = display.newRect(0,0,1024,5)
physics.addBody(wall2,“static”)

local wall3 = display.newRect(0,763,1024,5)
physics.addBody(wall3,“static”)

return localGroup
end[/lua]

[import]uid: 12482 topic_id: 1909 reply_id: 34810[/import]

This is true when applying a force, but I’m talking about falling from the edge of a platform. Does this work for you? [import]uid: 51516 topic_id: 1909 reply_id: 34811[/import]

can u plz provide me sample code

thanks [import]uid: 12482 topic_id: 1909 reply_id: 34826[/import]

seth,

I confirm that this does NOT work exactly as stated. Setting “isFixedRotation=true” might prevent some kinds of physical forces acting upon an object (rotating it), but it certainly does not prevent ALL forces, which I believe it should do!

In my game, I even set my “non-moveable, fixed” objects to a ridiculously high density of 100000000.0 and the objects that might collide with them to a featherweight density of 0.00001. In some cases I’m STILL seeing a physical reaction (nudge and rotate) of the heavy objects upon collision. It’s not significant or frequent enough to spoil my design, but it’s a bit annoying.

I also can’t set these bodies to “static” type (versus “dynamic”) because in my scenario, they are moving objects, like heavy boulders. I need them to move in linear directions, but I really wish that they wouldn’t rotate when “isFixedRotation” is set.

Ansca, is this a bug? Can you please investigate when you have a chance?

Brent Sorrentino
Ignis Design

[import]uid: 9747 topic_id: 1909 reply_id: 34850[/import]

I see. I’m going to check the bug database and report it if I don’t see it listed. [import]uid: 51516 topic_id: 1909 reply_id: 34854[/import]