- Home /
i auto generated a input manager c# script like Brackey's video and i am now getting compiler errors even though i did the exact same thing as him. Very confused.
The error reads " 'InputMaster' does not contain a definition for 'Player' and no accesible extension method "player' accepting a first argument of type "InputMaster' could be found." here is the code from the auto generated script and my script.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class @InputMaster : IInputActionCollection, IDisposable
{
public InputActionAsset asset { get; }
public @InputMaster()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""InputMaster"",
""maps"": [],
""controlSchemes"": []
}");
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
}
///////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
public class Player : MonoBehaviour
{
public float speed;
private float moveInput;
public float jumpForce;
private float _doubleTapTimeDown;
public int extraJumps;
public int extraJumpsValue;
public Rigidbody2D rb;
public EdgeCollider2D m_Collider;
public bool isGrounded;
public bool isAirbourne;
public bool isGliding;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
public InputMaster controls;
void Start()
{
controls.Player.PlayerMove.performed += ctx => Move();
extraJumps = extraJumpsValue;
rb = GetComponent<Rigidbody2D>();
m_Collider = GetComponent<EdgeCollider2D>();
}
void FixedUpdate()
{
}
void Update()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
if (isGrounded == true)
{
isAirbourne = false;
}
if (isGrounded == false)
{
isAirbourne = true;
}
if (isGrounded == true)
{
extraJumps = extraJumpsValue;
}
}
private void OnEnable()
{
controls.Enable();
}
private void OnDisable()
{
controls.Disable();
}
void Move()
{
moveInput = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
}
void Jump()
{
if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
-- extraJumps;
}
if (Input.GetKeyUp(KeyCode.UpArrow) && rb.velocity.y > 0)
{
rb.velocity = Vector2.up * 0f;
}
else if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded == true)
{
rb.velocity = Vector2.up * jumpForce;
}
}
}
Answer by RoastMaster · Jul 29, 2020 at 04:47 AM
The compilation error is telling you exactly what's wrong, you're trying to call controls.Player.PlayerMove.performed += ctx => Move();
but the InputMaster class doesn't contain a Player.
I can't help you any further than that.
Also, stop copy pasting from Youtube. You learn nothing doing it, nothing is actually explained to you, the only result is that you end up confused.
Answer by Predulus · Jun 27, 2021 at 07:52 AM
Also, stop telling people to stop copy pasting from Youtube. They learn nothing from it, nothing is actually explained to them, the only result is that they end up more confused.
Your answer
Follow this Question
Related Questions
2D platformer- getting errors I don't understand (c#) 1 Answer
Multiple Cars not working 1 Answer
[SOLVED]Problem with 2D Collider 0 Answers
How to move objects in the hierarchy 0 Answers
Dying Script error 2 Answers