Question by
NUKETheWay · Nov 18, 2021 at 06:39 AM ·
rigidbody2dupdatefixedupdate
How to do Inputs in Update and AddForce in FixedUpdate, infinite jumps ?
I know this has been asked a lot.
But most solution involved checking if player is grounded.
My game doesn't have a ground.
Here is the code, how can I add forces in fixedupdate by taking input signal in Update ?
void Update()
{
if(Input.touchCount > 0)
{
for(int i=0; i<Input.touchCount; i++)
{
TouchPosInWorld = Camera.main.ScreenToWorldPoint(Input.touches[i].position);
//Debug.DrawLine(Vector2.zero , TouchPosInWorld, Color.red);
if(Input.GetTouch(i).phase == TouchPhase.Began)
{
AddBodyForce();
}
}
}
}
void AddBodyForce()
{
//Add Forces to Rigidbody in FixedUpdate
}
Comment