- Home /
Having an error with the operator
Im following the iTeeski FPS Tutorials. and i got this error when i tried to this:
var horizontalMovement : Vector2; var maxWalkSpeed : float = 20;
function Update() { //After proceeding with the other codings which work really fine this is where i found the error
horizontalMovement = horizontalMovement.normalized; horizontalMovement *= maxWalkSpeed;
}
Error : Assets/PlayerMovementScript.js(16,35): BCE0051: Operator '*' cannot be used with a left hand side of type 'System.Type' and a right hand side of type 'float'.
Answer by shaystibelman · Dec 05, 2012 at 08:41 AM
I haven't yet seen this tutorial but my guess is that your problem lies in fact in the types: A vector2 wants 2 variables, while you are giving your horizontalMovement only one, horizontalMovement*maxWalkSpeed. Not sure how this calculation really should work but I would try:
horizontalMovement.x*=maxWalkSpeed;
horizontalMovement.y*=maxWalkSpeed;