Click here to Skip to main content
15,796,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<pre>using UnityEngine;
using System.Collections;

public class Movimento : MonoBehaviour {

    public Animator Animacao; 

    // Use this for initialization
    void Start () {


    // Update is called once per frame
    void Update () {
         Animacao = gameObject.GetComponent<Animator> ();  
         if (Input.GetAxisRaw ("A") == 1) {
             Animacao.SetBool ("Andar(a)", true);
             gameObject.transform.Translate(new Vector2(-0.1, 0f));
         if (Input.GetAxisRaw ("A") == 0) {
             Animacao.SetBool ("Andar(a)", false);


Hi, can you help me with my error? Its in Unity, and the app to i program its VisualStudio (VS Code).

The full error is: Assets\Movimento.cs(18,57): error CS1503: Argument 1: cannot convert from 'double' to 'float'

Help-me pls!!!

What I have tried:

I searched for videos on youtube and searched on google but none helped me, I also tried to change the code but it was not
Updated 30-Mar-22 14:48pm

1 solution

If you don't specify a literal number as a float, it's is assumed to be a double:
gameObject.transform.Translate(new Vector2(-0.1, 0.0f));

The fix is easy:
gameObject.transform.Translate(new Vector2(-0.1f, 0.0f));
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900