c# - Unity Operator `-=' cannot be applied to operands of type `float' and `UnityEngine.Vector3' -
I want to jump in my character in unity, but I get this error: Operator - = 'did not apply To work type type,
float 'and' UnityGen ' Vector 3 '
Public class ExampleClass: Monobehavak {Speed of public float = 6.0F; Public float jumpSpeed = 8.0F; Public float gravity = 20.0 f; Private vector 3 Movement direction = Vector 3 Jero; Zero Update () {Character Control Controller = GetComponent & lt; Character controller & gt; (); If (Controller.grated) {moveDirection = New vector 3 (Input Gatexis ("Horizontal"), 0, Input Gatexis ("Vertical"); Move Direction = Transform. Transform direction (move direction); Move direction * = speed; If (input. Getbutton ("jump")) conduction. Y = jumpSpeed; } MoveDirection.y - = gravity * Time.deltaTime; Controller Forward (Moving Direction * Time.deltaTime); }}
You can not modify a value for one axis at a time In C # You must reassign the entire vector:
moveDirection = new vector 3 (move direction x, move direction. Y - (gravity * time daltatime), move direction.
("was copied from ... this was the same issue!)
Comments
Post a Comment