Hello everyone. The problem i am facing is with the force applied to the object. In my program I want to make a rocket and give a force to perform a thrust. But strange things are happened when simulating. Firstly i put the yReference point the the rocket object to the bottom of it like in normal rocket then i put a dot to see exact point. Also i try to give the force to the rocket related to the rocket rotation. Also i add angular.damping to stop the abnormal rotation of rocket.
1 - When i simulate the code, the dot.x and dot.y is related to the rocket.x and rocket.y in the code enterFrame but dot is moving abnormal positions while the applied force increases.
2- Although i made rocket physics body with physics editor and draw a heavy shape to the nose of the rocket to perform the nose down when applied force is stop. The object doesn’t seem to rotate any angle, just falls like the shape when the applied force is stop.
Here is some of the code. Any help will be highly appreciated. Thank you in advance.
[code]
local scaleFactor = sc
local physicsData = (require “rocket”).physicsData(scaleFactor)
local rocket = display.newImage(“rocket.png”);
rocket.x = 50; rocket.y = _Y-100; rocket.xScale = sc; rocket.yScale = sc; rocket.name = “rocket”
rocket.yReference= 250
physics.addBody( rocket, physicsData:get(“rocket”) )
rocket.bodyType = “kinematic”
rocket.isBullet = true
local dot = display.newCircle(0, 0, 6)
dot:setFillColor(255, 0, 0)
function rocketkontrol (event)
dot.x = rocket.x
dot.y = rocket.y
i=i+1
rocket.bodyType = “dynamic”
rocket.angularDamping = 2;
–Roketle
if i<200 then
forcex = rocket.rotation/10
forcey= -(90 - rocket.rotation)/10
forcelocationX = rocket.x
forcelocationY = rocket.y
rocket:applyForce( forcex , forcey, forcelocationX, forcelocationY);
–[[
–print(“Force X”,forcex)
–print(“Force Y”,forcey)
–print(“Füze X”,rocket.x)
–print(“Force Location X”,forcelocationX)
–print(“Force Location Y”,forcelocationY)
]]
– Yak?t Tükendi
else
tmr3 = timer.performWithDelay(0, scrollDikeyInis,1)
end
–Fuze X Scroll Kontrol
if rocket.x>_GE-400 and rocketdurum == true then
rocket.x = _GE-400
tmr1 = timer.performWithDelay(0, scrollYatay,1)
end
–Fuze Y Scroll Kontrol
if rocket.y<300 and rocketdurum == true then
rocket.y = 300
tmr2 = timer.performWithDelay(0, scrollDikey,1)
end
if rocket.rotation>160 then
rocket.rotation =160
end
end
[/code] [import]uid: 74718 topic_id: 14913 reply_id: 314913[/import]