Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

benny282

New Coder
I am wrinting a script for a FPS game and it is giving me error: CS1061
Here is the code i am using:





C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public Rigidbody2D theRB;

        public float moveSpeed = 5f;

    private Vector2 moveInput;

    private Vector2 mouseInput;

    public float mouseSensitivity = 1f;

 
    void Start()
    {
      
    }

  
    void Update()
    {
        moveInput = new Vector2(Input.GetAxis("Horixontal"), moveInput.GetAxis("Vertical"));


        theRB.velocity = moveInput * moveSpeed;


    }
}
 
Last edited by a moderator:
What are you trying to do? How are you trying to do it? And what have you tried?

Please make sure to add your code into our bbcode feature.

 
Searching for CS1061 turns up https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1061 . Of note from that link: "This error occurs when you try to call a method or access a class member that does not exist."

In your code, moveInput starts off uninitialized, so passing in moveInput.GetAxis() the first time in the Update() function would probably fail as it's null.

Looks like you're using Input.GetAxis() - I suspect this: usage of the Input class not having a static function GetAxis(). I'm guessing this should be moveInput.GetAxis("Horizontal") ?
 
Yes, I agree with this. There is a rule already but it’s vague so I’ll add additional for creating thread titles.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom