Please help me i want to make a movement script and i don’t know how to fix it :(( (Player is named “Mov” too)
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mov: MonoBehaviour
{
public float moves = 1f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
public float move = 10;
void update()
{
if (Input.GetKey(“w”))
{
transform.Translate(0f, movesTime.deltaTime, 0f);
}
if (Input.GetKey(“s”))
{
transform.Translate(0f, -movesTime.deltaTime, 0f);
}
if (Input.GetKey(“a”))
{
transform.Translate( movesTime.deltaTime, 0f, 0f);
}
if (Input.GetKey(“d”))
{
transform.Translate( -movesTime.deltaTime, 0f, 0f);
}
}
}
A few things here. You need to state the error you are getting. Also, please use code tags (i recommend editing your current post and pasting the code into code tags so it is easier to read). But I think your issue could be a couple things.
-
You arent using GetKey properly. Try using this: Input.GetKey(KeyCode.W)
-
Your title of the post makes it seem like you maybe changed the script title and didnt adjust the class name in the script afterwards. Here is what I mean: If you create a script called “mov” and hit enter, it compiles for a few seconds and then you can jump into it and edit it. But, if you then change the name of the script in Unity, you need to make it identical in the script itself. Aka, you changed the script’s name in Unity to a capital M in “mov” but in your script you posted it clearly states it just as “mov”
Hopefully that helps and fixes your issue.
Uhh my code isn’t working right now; -;
“All compiles error have to be fixed before you can enter playmode”
But there’s no error’s
I think I have to give up
Now this thing is entering playmode
but this code doesnt work
Here is your code with code tags:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mov: MonoBehaviour
{
public float moves = 1f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
public float move = 10;
void update()
{
if (Input.GetKey("w"))
{
transform.Translate(0f, moves*Time.deltaTime, 0f);
}
if (Input.GetKey("s"))
{
transform.Translate(0f, -moves*Time.deltaTime, 0f);
}
if (Input.GetKey("a"))
{
transform.Translate( moves*Time.deltaTime, 0f, 0f);
}
if (Input.GetKey("d"))
{
transform.Translate( -moves*Time.deltaTime, 0f, 0f);
}
}
}
Your Update function is spelled incorrectly, you need to capitalize the U and change it from “update” to “Update”
Your Update function is spelled incorrectly, you need to capitalize the U and change it from “update” to “Update”. Dont give up dawg, we are here to help.