Pretty much when the arrow shoots the bird, the movement is a 180 degree angle that drops to the bottom of the screen (kind of realistic when you actually shoot a bird with a gun). I can’t figure out how to create such movement on one of my objects when it gets hit. Any help would be appreciated. [import]uid: 69494 topic_id: 31346 reply_id: 331346[/import]
Make the arrow two physics bodies joined, have the arrow head heavier than body and keep birds fairly light - that should do it I believe. [import]uid: 52491 topic_id: 31346 reply_id: 125367[/import]
Well, I’m using bullets instead. I was thinking more like a bullet set as “kinematic” hitting the birds. I currently have the birds falling down in a strange way by putting this in my event listener when the bullet collides with the bird:
transition.to( deadBird, { time=1500, alpha=0, x=10, y=400 } )
Obviously it’s really ugly when it falls down lol. I’d like it to be more like the way the birds get hit from that game (youtube video I posted) [import]uid: 69494 topic_id: 31346 reply_id: 125370[/import]
I think you need to make the dead birds physics objects and apply a force to them and then just let gravity take over. No transition.to() or anything like that.
Well, you could use that to move the live birds, then when a bullet hits, remove the live bird, create the dead bird as a physics object, and apply a force to it based on the direction of the bullet.
Then watch them plummet to the ground, you horrible killer, you.
Jay
[import]uid: 9440 topic_id: 31346 reply_id: 125373[/import]
I agree with Jay and Peach, and I strongly discourage using transitions to “fake” physical behavior. Unless the motion is very predictable, like moving an object in a vacuum environment from point A to point B, you should use the physics engine. It will look infinitely better and more realistic.
Also, I believe that collision detection is nullified if you transition an object, which is obviously bad if your dead birds might collide with something as they fall. I might be wrong about this, but I’ve read reports of unpredictable collisions or NO collisions when moving objects around by transitions.
Brent [import]uid: 9747 topic_id: 31346 reply_id: 125392[/import]
@Jay - LOL these are EVIL birds!
Unfortunately I was getting all these error messages:
ERROR: physics.addBody() cannot be called when the world is locked and in the middle of number crunching, such as during a collision event.
Runtime error
attempt to call method ‘applyForce’ (a nil value)
[C:]: in function ‘applyForce’
This is what is in my collision event after the bird gets hit and disappears (object1 is the bird heading towards the shooter):
[lua]local square = display.newImageRect(“deadbird.png”, 40, 50)
square.x = object1.x
square.y = object1.y
physics.addBody(square, “dynamic”, {density=2.0})
square:applyForce(90, 180, square.x, square.y) [import]uid: 69494 topic_id: 31346 reply_id: 125413[/import]
Yep, this is a “common” issue, but easily solved. Just delay the addition of addBody() by one game cycle; this could be as little as 10 milliseconds, but you might go as high as 50 milliseconds just to be “safe” and ensure that it happens in the next game cycle.
local function deadBirdPhys( event )
local birdBody = event.source.birdBody
physics.addBody( birdBody, "dynamic", {density=2.0} )
birdBody:applyForce(90, 180, birdBody.x, birdBody.y)
end
local square = display.newImageRect("deadbird.png", 40, 50)
square.x = object1.x
square.y = object1.y
local dr = timer.performWithDelay( 50, deadBirdPhys )
dr.birdBody = square --pass the 'square' object along with the timer as 'birdBody'
Give that a try and let me know how it works. 
Brent
[import]uid: 9747 topic_id: 31346 reply_id: 125454[/import]
Wow, that worked perfectly! Thanks again Brent! Peach and Jay, you’ve all been very helpful! [import]uid: 69494 topic_id: 31346 reply_id: 125458[/import]
Make the arrow two physics bodies joined, have the arrow head heavier than body and keep birds fairly light - that should do it I believe. [import]uid: 52491 topic_id: 31346 reply_id: 125367[/import]
Well, I’m using bullets instead. I was thinking more like a bullet set as “kinematic” hitting the birds. I currently have the birds falling down in a strange way by putting this in my event listener when the bullet collides with the bird:
transition.to( deadBird, { time=1500, alpha=0, x=10, y=400 } )
Obviously it’s really ugly when it falls down lol. I’d like it to be more like the way the birds get hit from that game (youtube video I posted) [import]uid: 69494 topic_id: 31346 reply_id: 125370[/import]
I think you need to make the dead birds physics objects and apply a force to them and then just let gravity take over. No transition.to() or anything like that.
Well, you could use that to move the live birds, then when a bullet hits, remove the live bird, create the dead bird as a physics object, and apply a force to it based on the direction of the bullet.
Then watch them plummet to the ground, you horrible killer, you.
Jay
[import]uid: 9440 topic_id: 31346 reply_id: 125373[/import]
I agree with Jay and Peach, and I strongly discourage using transitions to “fake” physical behavior. Unless the motion is very predictable, like moving an object in a vacuum environment from point A to point B, you should use the physics engine. It will look infinitely better and more realistic.
Also, I believe that collision detection is nullified if you transition an object, which is obviously bad if your dead birds might collide with something as they fall. I might be wrong about this, but I’ve read reports of unpredictable collisions or NO collisions when moving objects around by transitions.
Brent [import]uid: 9747 topic_id: 31346 reply_id: 125392[/import]
@Jay - LOL these are EVIL birds!
Unfortunately I was getting all these error messages:
ERROR: physics.addBody() cannot be called when the world is locked and in the middle of number crunching, such as during a collision event.
Runtime error
attempt to call method ‘applyForce’ (a nil value)
[C:]: in function ‘applyForce’
This is what is in my collision event after the bird gets hit and disappears (object1 is the bird heading towards the shooter):
[lua]local square = display.newImageRect(“deadbird.png”, 40, 50)
square.x = object1.x
square.y = object1.y
physics.addBody(square, “dynamic”, {density=2.0})
square:applyForce(90, 180, square.x, square.y) [import]uid: 69494 topic_id: 31346 reply_id: 125413[/import]
Yep, this is a “common” issue, but easily solved. Just delay the addition of addBody() by one game cycle; this could be as little as 10 milliseconds, but you might go as high as 50 milliseconds just to be “safe” and ensure that it happens in the next game cycle.
local function deadBirdPhys( event )
local birdBody = event.source.birdBody
physics.addBody( birdBody, "dynamic", {density=2.0} )
birdBody:applyForce(90, 180, birdBody.x, birdBody.y)
end
local square = display.newImageRect("deadbird.png", 40, 50)
square.x = object1.x
square.y = object1.y
local dr = timer.performWithDelay( 50, deadBirdPhys )
dr.birdBody = square --pass the 'square' object along with the timer as 'birdBody'
Give that a try and let me know how it works. 
Brent
[import]uid: 9747 topic_id: 31346 reply_id: 125454[/import]
Wow, that worked perfectly! Thanks again Brent! Peach and Jay, you’ve all been very helpful! [import]uid: 69494 topic_id: 31346 reply_id: 125458[/import]