Y
Y
yaroslav56192021-06-18 14:55:12
C++ / C#
yaroslav5619, 2021-06-18 14:55:12

What is wrong in the 45th and 12th line, Unity says that there is an error?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playermovment : MonoBehaviour
{
    public Rigidbody rb;

    public float runSpeed = 500f;
    public float strafeSpeed = 500f;
    public float jumpForce = 15f;
    protected bool strafeLeft = false;
    protected bool strafeRight = false;
    protected bool doJump = false;

    void Update()
    {
        if (Input.GetKey("a"))
        {
            strafeLeft = true;
        } else
        {
            strafeLeft = false;
        }

        if (Input.GetKey("d"))
        {
            strafeRight = true;
        } else
        {
            strafeRight = false;
        }

        if (Input.GetKeyDown("space"))
        {

            doJump = true;
         }

  
    }

    void FixadUpdate()
    {
        rb.Addforce(0, 0, runSpeed * Time.deltaTime);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kachan, 2021-06-18
@yaroslav5619

Please post as code next time, + ideally a screenshot with an error. Recalculate the lines to guess where the error is not at all a thrill.
Error in function name. Should be AddForceand you have a small f in the middle. Also, this logic will not be executed for you, because FixadUpdatethere should be an error in the function name. FixedUpdate
And if you install the free Visual Studio 2019 Community and select it as a tool for the code in the settings and regenerate the project files, then you will have these errors with tips on how to fix them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question