Search Unity

Question (24,9)(25,9) void cannot be used in this context.I tried replacing it with private,and float. In red

Discussion in 'Input System' started by Volc1, Apr 30, 2023.

  1. Volc1

    Volc1

    Joined:
    Apr 30, 2023
    Posts:
    1
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    public float moveSpeed;
    public Rigidbody2D rb;
    private Vector2 MoveDirection;
    // Update is called once per frame
    void Update()
    {

    }
    void FixedUpdate()
    {
    Move();
    }
    void ProcessInputs()
    {
    void moveX = ProcessInputs();("Horizontal");
    void moveY = ProcessInputs();("Vertical");
    moveDirection = new Vector2(moveX, moveY);
    }
    void Move()
    {
    rb.velocity = new Vector2(MoveDirection.x * moveSpeed, MoveDirection.y * moveSpeed);
    }
    }
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerMovement : MonoBehaviour
    6. {
    7.     public float moveSpeed;
    8.     public Rigidbody2D rb;
    9.  
    10.     private Vector2 MoveDirection;
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.      
    15.     }
    16.  
    17.     void FixedUpdate()
    18.     {
    19.         Move();
    20.     }
    21.  
    22.     void ProcessInputs()
    23.     {
    24.         [U]void moveX = ProcessInputs();("Horizontal");
    25.         void moveY = ProcessInputs();("Vertical");[/U]
    26.  
    27.         moveDirection = new Vector2(moveX, moveY);
    28.     }
    29.  
    30.     void Move()
    31.     {
    32.         rb.velocity = new Vector2(MoveDirection.x * moveSpeed, MoveDirection.y * moveSpeed);
    33.     }
    34. }