function init()
	rocketbody = FindShape("rocketbody") 
	emitter = FindShape("emitter") 
	endcap = FindShape("endcap") 
	trigger = FindTrigger("trigger")
	launchtime = GetTime() 
	body = FindBody("body") 
	speedscale = GetIntParam("speed", 75)
	
	rocketshapes = FindShapes("rocket")
	
	broken = false 
end 




function tick()
	if IsShapeBroken(rocketbody) == true then 
		broken = true 
	end 
	--DebugWatch("Broken", broken) 
	--DebugWatch("launchtime", launchtime) 
	--DebugWatch("timenow", timenow) 
	timenow = GetTime() 
	if timenow > launchtime + 0.2 and  broken == false then 
		SetTag(rocketbody, "explosive", 2) 
	end 


	emitpos = GetShapeWorldTransform(emitter).pos 
	endcappos = GetShapeWorldTransform(endcap)
	rocketdirection = TransformToParentVec(endcappos, Vec(0,-1,0))
	
	if timenow > launchtime + 5 and not broken then 	
		Explosion(endcappos.pos, 0.5)
		--DebugPrint("explode") 
		broken = true 
	end 
	
	
	--if GetTime() > 1 then
	newvel = VecScale(rocketdirection, speedscale) 
	SetBodyVelocity(body, newvel)
	--SetBodyAngularVelocity(body, Vec(5,0,0))
	--end 

	


	if broken == false then 
		ParticleType ("plain")
		ParticleTile(0)
		ParticleColor(0.8,0.8,0.8,0.5,0.5,0.5)
		--ParticleEmissive(1, 0,"constant",0.3)
		ParticleStretch(1)
		ParticleRadius(0.1,0.4)
		ParticleAlpha(1, 0, "easeout")
		ParticleGravity(0.05)
		ParticleDrag(0.5)
		ParticleRotation(math.random(), math.random())
		ParticleCollide(0)
		for i=1,3 do 
			SpawnParticle(emitpos, Vec(math.random(), math.random(), math.random()), 15)
		end 
	end 
		
	if broken == true then 
		for i=1,#rocketshapes do 
			Delete(rocketshapes[i])
		end 
	end 



end 