本文整理汇总了C#中PlayerInput.SetMovement方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerInput.SetMovement方法的具体用法?C# PlayerInput.SetMovement怎么用?C# PlayerInput.SetMovement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerInput
的用法示例。
在下文中一共展示了PlayerInput.SetMovement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInput
//save the left and right stick input axes to Vector2s and give them to 'input'
public void GetInput(ref PlayerInput input)
{
Vector2 leftStickInput = new Vector2(Input.GetAxis("L_XAxis_" + myPlayer.playerNo), Input.GetAxis("L_YAxis_" + myPlayer.playerNo));
Vector2 rightStickInput = new Vector2(Input.GetAxis("R_XAxis_" + myPlayer.playerNo), Input.GetAxis("R_YAxis_" + myPlayer.playerNo));
if(leftStickInput.SqrMagnitude() > (ANALOGUE_STICK_THRESHOLD * ANALOGUE_STICK_THRESHOLD))
{
input.SetMovement(leftStickInput);
}
else
{
input.SetMovement(Vector2.zero);
}
if(rightStickInput.SqrMagnitude() > (ANALOGUE_STICK_THRESHOLD * ANALOGUE_STICK_THRESHOLD))
{
input.SetAim(rightStickInput);
}
else
{
input.SetAim(Vector2.zero);
}
//check if the right trigger is pressed
bool action = Input.GetAxis("TriggersR_" + myPlayer.playerNo) > TRIGGERS_THRESHOLD ? true : false;
//if action was false and is now true, set actionDown to true
if(!input.GetAction() && action)
{
input.SetActionDown(true);
}
else
{
//otherwise actionDown is false
input.SetActionDown(false);
}
//check if the left trigger is pressed
bool secondaryAction = Input.GetAxis("TriggersL_" + myPlayer.playerNo) > TRIGGERS_THRESHOLD ? true : false;
//if secondaryAction was false and is now true, set secondaryActionDown to true
if (!input.GetSecondaryAction() && secondaryAction)
{
input.SetSecondaryActionDown(true);
}
else
{
//otherwise secondaryActionDown is false
input.SetSecondaryActionDown(false);
}
input.SetAction(action);
input.SetSecondaryAction(secondaryAction);
}