- Home /
unity cant run my movement code smoothly
Hi guys I use below code for moving a prefab , but it doesn't move the prefab smoothly , I thought that maybe its too heavy for my i5 cpu to calculate q points , so this is the reason for step to step movement ( in a frame my prefab stops for a while and then jumps some steps …) But when I looked at the frame rate It wan on 70 and more , the game runs with 15 draw calls 7 mb for pictures , this is a 2d game Would anyone tell me whats happening that my computer cant do this in a smooth way….and not Hi guys I use this code for moving a prefab , but it doesn’t move the prefab smoothly , I thoought that maybe its too heavy for my i5 cpu to calculate q points , so this is the reason for step to step movement ( in a frame my prefab stops for a while and then jumps some steps …) But when I looked at the fram rate It wan on 70 and more , the game runs with 15 draw calls 7 mb for pictures , this is a 2d game Would anyone tell me whats happening that my computer cant do this in a smooth way and not Interrupted , Thanx a lot and more This is my code
function Update ()
{
if (c <=5)
{
c += 0.83 * Time.deltaTime;
q1 = CalculateSlowTankBombBezierPoint(c, FixStartSmoothMovement, EndPointForSmoothMovement);
q0 = q1;
transform.position = q1 ;
}
}
function CalculateSlowTankBombBezierPoint(t : float , P0 : Vector3 , P1 : Vector3):Vector3
{
var u : float ;
var p : Vector3 ;
u = 1 - t ;
p= u * P0 ;
p += t * P1 ;
return p ;
}
The amount of math/code doesn't seem even close to being a problem. I've used much more math with a worse CPU and had it be fine.
There's probably something else making it jiggle (in what way is it not smooth? stutters? lots of visible snaps? Looks "bumpy"? ... ) For evaluating the curve, isn't t
(your c
) usually in range 0-1?
Couldn't you just use move it along a certain axis ins$$anonymous$$d??
@ham: CPUs can perform gazillions of calculations per second; some completely trivial math code will never even register unless you loop it millions of times per frame.
lots of visible snaps , maybe i can do it,move it along a axis ..i should check it , thanx