It’s just as your error says. You have a Vector3 variable:private Vector3 moveInput; and a float variable: float yStore = moveInput.y; and then you’re trying to assign the float to the Vector3 variable: moveInput = yStore;This doesn’t make sense. You can’t put a float into a Vector3 variable anymore than you can shove a square peg into a round hole.
Did you perhaps mean to do something like this?moveInput.y = yStore;
You need to think consciously about what each line of code is doing and whether it makes sense.
(42,23): error CS1061: ‘Vector3’ does not contain a definition for ‘GetKey’ and no accessible extension method ‘GetKey’ accepting a first argument of type ‘Vector3’ could be found (are you missing a using directive or an assembly reference?)
need help again
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed, gravityModifier, jumpPower, runSpeed = 12f;
public CharacterController charCon;
private Vector3 moveInput;
public Transform camTrans;
public float mouseSensitvity;
public bool invertX;
public bool invertY;
private bool canJump;
public Transform groundCheckPoint;
public LayerMask whatIsGround;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//moveInput.x = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
//moveInput.z = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
float yStore = moveInput.y;
Vector3 vertMove = transform.forward * Input.GetAxisRaw("Vertical");
Vector3 HoriMove = transform.right * Input.GetAxisRaw("Horizontal");
moveInput = HoriMove + vertMove;
moveInput.Normalize();
if (moveInput.GetKey(KeyCode.LeftShift))
{
moveInput = moveInput * runSpeed;
}
else
{
moveInput = moveInput * moveSpeed;
}
moveInput.y = yStore;
moveInput.y += Physics.gravity.y * Time.deltaTime;
if (charCon.isGrounded)
{
moveInput.y = Physics.gravity.y * gravityModifier * Time.deltaTime;
}
canJump = Physics.OverlapSphere(groundCheckPoint.position, .25f, whatIsGround).Length > 0;
//handle jump
if (Input.GetKeyDown(KeyCode.Space) && charCon.isGrounded)
{
moveInput.y = jumpPower;
}
charCon.Move(moveInput * Time.deltaTime);
//control camera rotation
Vector2 mouseInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")) * mouseSensitvity;
if (invertX)
{
mouseInput.x = -mouseInput.x;
}
if (invertY)
{
mouseInput.y = -mouseInput.y;
}
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y + mouseInput.x, transform.rotation.eulerAngles.z);
camTrans.rotation = Quaternion.Euler(camTrans.rotation.eulerAngles + new Vector3(-mouseInput.y, 0f, 0f));
}
}