- Home /
namespace error cs0246 :how can i fix it.plz tell me in details!
namespace Assets.Code
{ public class PlayerController {
private readonly Player _player;
private float _baseVelocity,
_targetVelocity,
_variableVelocity;
public vector3 MousePosition { get; private set; }
public float CurrentVelocity { get; private set; }
public float MaxVariableVelocity{ get; set; }
public float Minimumvelocity { get; set ; }
public float Acceleration { get; set ; }
public float velocityDamp { get; set; }
public float RotationSpeed { get; set ;}
public bool UseRelativeMovement { get ; set ;}
public vector2 MouseSensitivity { get; set ; }
public PlayerController (Player player)
{
MaxVariableVelocity = 20;
Acceleration = 70;
velocityDamp = 20;
RotationSpeed = 0.3f;
MouseSensitivity = new vector2 (700, 700);
UseRelativeMovement = false;
_Player = player;
}
public void Update()
{
Screen.lockCursor = UseRelativeMovement;
if (UseRelativeMovement) {
MousePosition += new vector3 (Input.GetAxis ("Mouse X") * Time.deltaTime * MouseSensitivity.x,
Input.GetAxis ("Mouse Y") * Time.deltaTime * MouseSensitivity.y);
} else
MousePosition = Input.mousePosition;
UpdatePosition ();
UpdateRotation ();
}
private void UpdatePosition()
{
_variableVelocity = Mathf.Clamp (_variableVelocity + Input.GetAxis ("Vertical") * Time.deltaTime * Accleration, 0, MaxVariableVelocity);
_targetVelocity = _variableVelocity + Minimumvelocity;
CurrentVelocity = Mathf.Lerp (CurrentVelocity, _targetVelocity, Time.deltaTime * velocityDamp);
_Player.transform.Translate (0,0,CurrentVelocity * Time.deltaTime, Space.Self);
}
private void UpdateRotation()
{
var mouseMovement = (MousePosition - (new vector3 (Screen.width / 2f, screen.heighjt / 2f))) * .2f;
if (mouseMovement .sqrMagnitude >= 1)
_Player.transform.Rotate(new vector3(-mouseMovement .y, mouseMovement .x, 0) * RotationSpeed);
}
}
}
//erorr1 :Assets/Code/PlayerController.cs(29,24): error CS0246: The type or namespace name vector2' could not be found. Are you missing a using directive or an assembly reference? //erorr2 :Assets/Code/PlayerController.cs(29,24): error CS0246: The type or namespace name
vector3' could not be found. Are you missing a using directive or an assembly reference?
Answer by Kiwasi · Aug 13, 2014 at 01:43 AM
To fix change all vector2 to Vector2 and all vector3 to Vector3
Case matters in programming. The compiler doesn't have a definition for vector2, so it throws an error. There is a definition for Vector2.
Capitalisation is very important in program$$anonymous$$g.
Incorrect. Better to say "case matters in program$$anonymous$$g". In most languages.
Technically you are correct.
However in this case the error was due to a lack of capitalisation.
Will update my answer accordingly
I Changed Vector2 Vectore3 But again i Have The Error!!! plz Help $$anonymous$$e $$anonymous$$y PRJ Have Been Stopped
Your answer
![](https://koobas.hobune.stream/wayback/20220613160458im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Compiler errors? 2 Answers
PlayerRespawn coding gone awry 0 Answers
hack and slash game errors 3 Answers
error CS0246: The type or namespace name `List' could not be found. 1 Answer
Error building Player because scripts had compiler errors 2 Answers