Hello people,
i want to make a pinball game fully in C#,
i am using the gameion pinball template but rewrite it in C#.
i run into the following problem when firing the pinball:
if (CanUse == true)
{
ControlBallLaunchByKeyboard();
}
else {
// Spring resets back to normal position
if (ballLaunch.localScale.y < 12)
{
ballLaunch.localScale.y = (ballLaunch.localScale.y + 12.0f) * 0.5f;
ballLaunch.position.y = (ballLaunch.position.y - 63.00549f) * 0.5f;
}
}
}
private void ControlBallLaunchByKeyboard (){
if (Input.GetKey(KeyCode.DownArrow))
{
// When the player holds down the Down Arrow button, pull down the ball launch
if (ballLaunchForce < 2000)
{
float dt = Time.deltaTime * 8.0f;
ballLaunchForce += dt * 180;
ballLaunch.localScale.y = Mathf.Lerp(12.8f, 1.8f, ballLaunchForce / 2000);
ballLaunch.position.y = Mathf.Lerp(-63.1f, -68.6f, ballLaunchForce / 2000);
}
}
else
{
// Spring resets back to normal position
if (ballLaunch.localScale.y < 12)
{
ballLaunch.localScale.y = (ballLaunch.localScale.y + 12.0f) * 0.5f;
ballLaunch.position.y = (ballLaunch.position.y - 63.00549f) * 0.5f;
}
}
i get allot of the following errors:
- Assets/Scripts/Trig.cs(43,36): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.localScale'. Consider storing the value in a temporary variable
- Assets/Scripts/Trig.cs(44,36): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'. Consider storing the value in a temporary variable
Could anyone point out what i am doin wrong or help me ??
thanks in advance
↧