Welcome to Incels.is - Involuntary Celibate Forum

Welcome! This is a forum for involuntary celibates: people who lack a significant other. Are you lonely and wish you had someone in your life? You're not alone! Join our forum and talk to people just like you.

help me with this tbh

AccountError

AccountError

Banned
-
Joined
Feb 24, 2020
Posts
5,547
@RemoveNormalfags
What has happened so far is that I've made a script for the player to move left, right, including a jump button. Some lines are irrelevant as I plan to use them in the future. The application shows 0 errors but the script does not work upon testing it out, during the earlier versions of the code the player was able to move around, but as soon as I implemented the ability to jump it's stopped working. Posting here cos too long for a reply

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movebasic : MonoBehaviour {

    private Rigidbody2D rb;

    private bool isFacingRight = true;

    private float movementInputDirection;

    public float movementspeed = 10.0f;

    public float jumpForce = 16.0f;



    // Use this for initialization
    void Start () {
        rb = GetComponent<Rigidbody2D>();
    }
    
    // Update is called once per frame
    void Update () {
        CheckInput();
        CheckMovementDirection();
    }

    private void FixedUpdate()
    {
        ApplyMovement();
    }

    private void CheckMovementDirection()
    {
        if(isFacingRight && movementInputDirection < 0)
        {
            Flip();
        }
        else if(isFacingRight && movementInputDirection > 0)
        {
            Flip();
        }
    }
    private void CheckInput()
    {
        movementInputDirection = Input.GetAxisRaw("Horizontal");
        {
            if (Input.GetButtonDown("jump"))
            {
                Jump();
            }
        }

    }

    private void Jump()
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
    }

    private void ApplyMovement()

    private void Flip()
    {    {
        rb.velocity = new Vector2(movementspeed * movementInputDirection, rb.velocity.y);
    }

        isFacingRight = !isFacingRight;
        transform.Rotate(0.0f, 100.0f, 0.0f);
    }
}
 
cucks know how to code better than us go ask them
 
then why make a thread for solely one person go dm instead them instead you faggggot :feelstastyman:
I can finally agree with you lmao fuck this OP
 
You're missing a semi colon on line 63

private void ApplyMovement()
god tier perception tbh. all of my code looks way simpler than this and I still have trouble locating what's wrong half the time
 
does it have an error console that tells you what line is screwy?
 
does it have an error console that tells you what line is screwy?
usually you can just run it in codeskulptor or something and it'll show you what line isn't working but for more complicated code it might not be immediately able to tell you
 
usually you can just run it in codeskulptor or something and it'll show you what line isn't working but for more complicated code it might not be immediately able to tell you
I only ever have used Java on Eclipse for the most part so I’ve never really touched more than the basics I guess
 

Users who are viewing this thread

shape1
shape2
shape3
shape4
shape5
shape6
Back
Top