A more practical way of creating a fireball?

Hi, I am creating a fireball that bounces up and down, and my problem is I can’t seem to get past it. 

It is simply moving up and down to fast to get through it. I am using applyLinearImpulse because I like the realistic way it falls back down, it decelerates, peaks, and then falls back downwards. Lowering the linearImpulse causes the fireball to not even make it out of the lava. timer.performWithDelay does not work either.

Just to be clear, this about making my fireball appear less so that the player can actually get through the fireball.

Here’s my code:

 function instance:collision(event) if event.phase == "began" then if event.other.objType == "ricochet" then instance:applyLinearImpulse(0, -60, self.x, self.y) end end end

Any other ways to go about doing this? 

Try changing the linearDamping (default 0) of the ‘fireBall’.  This will require a change to your impulse force.

obj.linearDamping = 1

Alternately, OR IN ADDITION (try one at a time first, then try combining),  try changing the ‘fireball’ gravityScale

obj.gravityScale = 0.5

Thanks, I’ll give these a shot.

Thanks, roaminggamer, now it’s not impossible. But still kinda hard. :slight_smile:

https://www.youtube.com/watch?v=Rsvr096rtCM&feature=youtu.be

local physics = require "physics" --physics.setDrawMode("hybrid") physics.start() local cx = display.contentCenterX local cy = display.contentCenterY local function newFireBall( x, y, impulseMag, params ) params = params or {} local fireBall = display.newImageRect( "fireball.png", 100, 100 ) fireBall.x = x fireBall.y = y physics.addBody( fireBall, { radius = 40, bounce = 0 } ) for k,v in pairs( params ) do fireBall[k] = v end fireBall.isFixedRotation = true fireBall.collision = function( self, event ) if(event.phase ~= "began" ) then return false end timer.performWithDelay( 1, function() self:applyLinearImpulse( 0, -impulseMag \* self.mass, self.x, self.y ) end ) return true end; fireBall:addEventListener( "collision" ) end local ground = display.newRect( cx, cy + display.actualContentHeight/2- 40, display.actualContentWidth, 80 ) ground:setFillColor(0,1,0,0.2) physics.addBody( ground, "static", { bounce = 0 } ) -- base case newFireBall( cx - 300, cy, 10 ) -- base case -- typical damping newFireBall( cx - 150, cy, 20, { linearDamping = 1 } ) -- strong damping (I like this one the best) newFireBall( cx, cy, 30, { linearDamping = 2 } ) -- half gravityScale newFireBall( cx + 150, cy, 10, { gravityScale = 0.5 } ) -- half gravityScale + typical damping newFireBall( cx + 300, cy, 20, { gravityScale = 0.5, linearDamping = 1 } )

Get the demo here: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2017/08/fireBall.zip

Thanks! This will be helpful. 

Great answer Ed, especially with the video! A handy nugget!

Try changing the linearDamping (default 0) of the ‘fireBall’.  This will require a change to your impulse force.

obj.linearDamping = 1

Alternately, OR IN ADDITION (try one at a time first, then try combining),  try changing the ‘fireball’ gravityScale

obj.gravityScale = 0.5

Thanks, I’ll give these a shot.

Thanks, roaminggamer, now it’s not impossible. But still kinda hard. :slight_smile:

https://www.youtube.com/watch?v=Rsvr096rtCM&feature=youtu.be

local physics = require "physics" --physics.setDrawMode("hybrid") physics.start() local cx = display.contentCenterX local cy = display.contentCenterY local function newFireBall( x, y, impulseMag, params ) params = params or {} local fireBall = display.newImageRect( "fireball.png", 100, 100 ) fireBall.x = x fireBall.y = y physics.addBody( fireBall, { radius = 40, bounce = 0 } ) for k,v in pairs( params ) do fireBall[k] = v end fireBall.isFixedRotation = true fireBall.collision = function( self, event ) if(event.phase ~= "began" ) then return false end timer.performWithDelay( 1, function() self:applyLinearImpulse( 0, -impulseMag \* self.mass, self.x, self.y ) end ) return true end; fireBall:addEventListener( "collision" ) end local ground = display.newRect( cx, cy + display.actualContentHeight/2- 40, display.actualContentWidth, 80 ) ground:setFillColor(0,1,0,0.2) physics.addBody( ground, "static", { bounce = 0 } ) -- base case newFireBall( cx - 300, cy, 10 ) -- base case -- typical damping newFireBall( cx - 150, cy, 20, { linearDamping = 1 } ) -- strong damping (I like this one the best) newFireBall( cx, cy, 30, { linearDamping = 2 } ) -- half gravityScale newFireBall( cx + 150, cy, 10, { gravityScale = 0.5 } ) -- half gravityScale + typical damping newFireBall( cx + 300, cy, 20, { gravityScale = 0.5, linearDamping = 1 } )

Get the demo here: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2017/08/fireBall.zip

Thanks! This will be helpful. 

Great answer Ed, especially with the video! A handy nugget!