Unity doesn't seem to like the way I'm declaring my variables, I was just trying to clean up my code and moved some of the variables and now it doesn't work.
The Error:
Assets\Movement.cs(33,22): error CS0029: Cannot implicitly convert type 'UnityEngine.Vector3' to 'float'
Assets\Movement.cs(39,29): error CS1503: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector3'
Assets\Movement.cs(41,29): error CS1503: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector3'
Assets\Movement.cs(43,29): error CS1503: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector3'
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Movement : MonoBehaviour{
public CharacterController controller;
public Transform Player;
public Transform groundCheck;
public Text StaminaBar;
public LayerMask groundMask;
Vector3 move;
Vector3 velocity;
float WalkingSpeed = 12;
float SprintingSpeed = 15;
float CrouchingSpeed = 6;
float gravity = 30;
void Update(){
Speed();
Jump();
Crouching();
//Gravity
controller.Move(velocity * Time.deltaTime);
}
void Speed(){
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
float CurrentX = Player.transform.position.x;
float CurrentZ = Player.transform.position.z;
float move = transform.right * x transform.forward * z;
bool isWalking = Input.GetKey(KeyCode.W);
bool isCrouching = Input.GetKey(KeyCode.LeftShift);
bool isSprinting = Input.GetKey(KeyCode.R);
velocity.y = gravity * Time.deltaTime;
if (isWalking){
controller.Move(move * WalkingSpeed * Time.deltaTime);
} else if (isCrouching){
controller.Move(move * CrouchingSpeed * Time.deltaTime);
}else if(isSprinting){
controller.Move(move * SprintingSpeed * Time.deltaTime);
}
}
void Jump(){
bool isGrounded = Physics.CheckSphere(groundCheck.position, 0.1f, groundMask);
}
void Crouching(){
}
void Sliding(){
}
void Climbing(){
}
void WallRunning(){
}
}```
CodePudding user response:
You are declaring your variable move multiple times.
float move = ... should be move = ...
