the situation:
I have one script named GameController .In this script,i want to record the mouse delta position when putdown jump button.the code show as following:
public class GameController : MonoBehaviour
{
private Vector3 lastPos;
public Vector3 deltaPos;
private Boolean duringStop = false;
private Boolean trackMouse = false;
void Update ()
{
if(Input.GetButtonUp("Jump"))
{
Time.timeScale = Time.timeScale==1.0f ? 0.0f : 1.0f;
duringStop = Time.timeScale == 1.0f ? false : true;
}
if (duringStop)
{
if (Input.GetMouseButtonDown(0))
{
trackMouse = true;
lastPos = Input.mousePosition;
}
if (Input.GetMouseButtonUp(0))
{
trackMouse = false;
deltaPos = Input.mousePosition - lastPos;
Debug.Log(deltaPos);
}
}
}
}
then after putdown jump button again,the game will continue.But i want that vale deltaPos
can be passed to another script that control player movement.the player will add a force from the value,and change the velocity.
so how to pass value that when the deltaPos
changes? because it can be changed after every time jump button has been putdown,so I don’t know how to notify another script that the value has been changed. whats more,the value will be used in fixedupdate funtion.