Help me! Please. I am a student new!
using UnityEngine; using System.Collections;
public class PlayerKeyboard : MonoBehaviour { public float speed = 8f; public float maxVelocity = 4f;
[SerializeField]
private Rigidbody2D myBody;
private Animator anim;
void Awake(){
myBody = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
PlayerKeyboard ();
}
void PlayerMoveKeyboard(){
float forceX = 0f;
float vel = Mathf.Abs (myBody.velocity.x);
float h = Input.GetAxisRaw ("Horizontal");
if (h > 0) {
if (vel < maxVelocity)
forceX = speed;
} else if (h < 0) {
if (vel < maxVelocity)
forceX = -speed;
}
myBody.AddForce(new Vector2 (forceX,0));
}
}
Assets/Scripts/PlayerKeyboard.cs(25,17): error CS0119: Expression denotes a type', where a
variable', value' or
method group' was expected
Unity3D v5.3.6f1. Thanks you!!!
Answer by Jessespike · Jul 28, 2016 at 07:49 PM
void FixedUpdate () {
PlayerKeyboard ();
}
You are trying to call a constructor? I think you meant PlayerMoveKeyboard() instead:
void FixedUpdate () {
PlayerMoveKeyboard();
}
Also note "Help me. Please, etc etc" is not a descriptive title, it doesn't describe anything about the problem, choose better words next time and use the 101010 button to properly format code.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085708im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Missing button on some devices for Instant App 0 Answers
Differences between iPhone and Android development? 0 Answers
Mobile bloom kills performance 1 Answer
Gradle Build failed unity 2020.3.14. incompatible daemon, commandInvocationFailure 7 Answers
Camera following player is jerky and has bad visual effect. 0 Answers