public virtual void PhysicsUpdate()

{

Move();

}


protected virtual void Move()

{

if (sm.character.IsOnSlope() == true)

{

sm.character.rb.AddForce(GetSlopeMoveDirection() * moveSpeed * 10f, ForceMode.Force);

}

else

{

sm.character.rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);

}

}


protected void SpeedControl()

{

if (sm.character.IsOnSlope() == true)

{

if (sm.character.rb.velocity.magnitude > moveSpeed)

{

sm.character.rb.velocity = sm.character.rb.velocity.normalized * moveSpeed;

}

}

else

{

Vector3 flatVel = new Vector3(sm.character.rb.velocity.x, 0f, sm.character.rb.velocity.z);


if (flatVel.magnitude > moveSpeed)

{

Vector3 limitedVel = flatVel.normalized * moveSpeed;

sm.character.rb.velocity = new Vector3(limitedVel.x, sm.character.rb.velocity.y, limitedVel.z);

}

}

}


IEnumerator PostSimulationUpdate()

{

YieldInstruction waitForFixedUpdate = new WaitForFixedUpdate();

while (true)

{

yield return waitForFixedUpdate;

SpeedControl();

Rotate();

}

}

๋‚ด ์ฝ”๋“œ๊ฐ€ ์ด๋Ÿฐ์‹์ธ๋ฐ ์ตœ๋Œ€์†๋„๊ฐ€ 5๋ผ๊ณ  ํ–ˆ์„ ๋•Œ SpeedControl()์ด update๋‚˜ waitforfixedupdate์—์„œ ๋ถˆ๋ฆด ๋• ์ตœ๋Œ€ ์†๋„๋ฅผ ์•ˆ๋„˜๊ณ  5๊ฐ€ ๋‚˜์˜ค๊ฑฐ๋“ ? ๊ทผ๋ฐ fixedupdate์—์„œ SpeedControl()์„ ๋ถ€๋ฅด๋ฉด 5.9์ด๋Ÿฐ์‹์œผ๋กœ ์œ ๋‹ˆํ‹ฐ ์ธ์ŠคํŽ™ํ„ฐ์—์„œ ๋‚˜์˜ค๋Š”๋ฐ ์™œ ์ด๋Ÿผ? ์–ด์ฐจํ”ผ velocity ์„ธํŒ…์„ update๋‚˜ waitforfixedupdate์—์„œ ํ•ด๋„ ์‹ค์งˆ์ ์ธ ๋ฌผ๋ฆฌ ๊ณ„์‚ฐ์€ fixedupate ๋‹ค์Œ internalย physics update์—์„œ ์ผ์–ด๋‚˜๋Š”๊ฑฐ ์•„๋‹˜? ๊ทธ๋Ÿผ ๊ฒฐ๊ณผ๊ฐ€ ๋˜‘๊ฐ™์•„์•ผ ๋˜์ง€ ์•Š๋‚˜? ๊ทธ๋ƒฅ ์œ ๋‹ˆํ‹ฐ ์ธ์ŠคํŽ™ํ„ฐ์ƒ์—์„œ๋งŒ ์†๋„๊ฐ€ 5๋กœ ๋‚˜์˜ค๊ณ  ์‹ค์งˆ์ ์€ ์†๋„๋Š” ์–ด๋””์„œ ๋ถ€๋ฅด๋“  ๊ฐ™๋‚˜?
์•„๋‹˜ ์œ ๋‹ˆํ‹ฐ ๋ฌผ๋ฆฌ์—”์ง„ ๋‚ด๋ถ€์—์„œ ๋ญ ๊ณ„์‚ฐํ•  ๋•Œ addforce์ด๋Ÿฐ๊ฑฐ ๋‹ค ๊ณ„์‚ฐํ•˜๊ณ  ๋‚˜์„œ velocity๋Š” ๋งจ ๋งˆ์ง€๋ง‰์— ์ ์šฉํ•˜๊ณ  ์ด๋Ÿฐ๊ฑด๊ฐ€?

๋‚˜ ๊ฐœ๋ณ‘@ ๋งž์œผ๋‹ˆ๊นŒ ์ฐฌ์ฐฌํžˆ ์„ค๋ช…์ข€