- Home /
Question by
Debunklelel · Mar 26, 2020 at 10:48 AM ·
scripting problem3dcompiler error
Unity error code cs0101 already contains a definition for movement?
I'm getting compiler errors when I try to test my scene. Specifically it seems to be having a problem with my player movement script;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.A))
{
Vector3 position = transform.position;
position.x += -10 * Time.deltaTime;
transform.position = position;
}
if (Input.GetKey(KeyCode.D))
{
Vector3 position = transform.position;
position.x += 10 * Time.deltaTime;
transform.position = position;
}
if (Input.GetKey(KeyCode.W))
{
Vector3 position = transform.position;
position.z += 10 * Time.deltaTime;
transform.position = position;
}
if (Input.GetKey(KeyCode.S))
{
Vector3 position = transform.position;
position.z += -10 * Time.deltaTime;
transform.position = position;
}
}
}
This has been attached to my player object, but when I try to test it either refuses to load over a silly compile error or won't allow my player to move when I press the WSAD keys.
Comment
Your answer
Follow this Question
Related Questions
Help attaching object to players hand 1 Answer
When I enable certain scripts on my player, the transform falls through the map. 0 Answers
How to move player or character Left right by 14 unit every at button click on mobile 0 Answers
FPS recoil 1 Answer
How do I make a spotlight make a model play an animation? 2 Answers