Hello. I am making a game where a dynamic object randomly moves around the screen. My current code makes sure the two forces add up to a certain value. However this does not give the same velocity. Would there be any way to do that?
Here is my code currently
local impulseVal = 400 local impulseX local impulseY local signDet1 local signDet2local mRand = math.random math.randomseed( os.time() ) local function bubbleClick() --remove later bubble:setFillColor(55,10,0 ) print("rand") --get random number impulseX = mRand(0,impulseVal) impulseY = impulseVal - impulseX signDet1 = mRand(0,1) if signDet1 == 0 then impulseX = impulseX \* 1 elseif signDet1 == 1 then impulseX = impulseX \* -1 end signDet2 = mRand(0,1) if signDet2 == 0 then impulseY = impulseY \* 1 elseif signDet1 == 1 then impulseY = impulseY \* -1 end bubble:applyForce(impulseX,impulseY,bubble.x,bubble.y) end
I cannot use transition to because that messes up my object’s x and y coordinates.
Any help is greatly appreciated!