#Movement

1 messages · Page 1 of 1 (latest)

grave parcel
#

Heya

hidden tangle
#

hallo

#

so firstly, what things do you want to do first?

grave parcel
#

Make the movement

#

Just horizontally

hidden tangle
#

yeah you can use the code that ive sent earlier

#

just remove movVer

#

and replace it in rb.velocity with, rb.velocity.y

grave parcel
#

Well, I tried it and I just fly through the ground at insane speeds

hidden tangle
#

XD

#

can i see it? XD

grave parcel
#

Oh it works now for some reason

hidden tangle
#

wha--

grave parcel
#

Nvm

#

It stopped working again

#

LOL

hidden tangle
#

LMAO

#

maybe make the speed a lil bit

#

its up to you how slow it is

#

or fast

grave parcel
#

So, whenever it's above 5

#

I just fly through the ground

hidden tangle
#

LMAO

#

so just adjust it at your own accord

#

XD

#

so is it working?

grave parcel
#

Kind of

hidden tangle
#

XD

#

like i said im not that good at movement XD

grave parcel
#

Lol, don't worry. it's fine

#

Whenever I move to the right, I go diagonally up

#

wtf

hidden tangle
#

can i see ?

grave parcel
#

Idk how to record

hidden tangle
#

okay, lemme see the code

#

so we can fix it, kind of

grave parcel
#
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    private Rigidbody2D rb;
    public int speed = 5;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    void Update()
    {
        float movement = Input.GetAxisRaw("Horizontal");

        rb.velocity = new Vector2(rb.velocity.y * speed, movement);
    }
}








        ```
#

I changed it A bit

hidden tangle
#

its not right..

grave parcel
#

Oh

hidden tangle
#

vector2 stores in x and y

#

so movement should be on x

#

Vector2(x, y)

#

this is how vectors work

#

or not

#
rb.velocity = new Vector2(movement * speed, rb.velocity.y);
#

this is how it should be done

#

you can think of vectors as axis

#

although im not sure of that

#

like x and y axis on Vector2

#

and x, y, and z on Vector3

grave parcel
#

Ah, works.

hidden tangle
#

naysu

#

nice

#

so horizontal movement is now done?

grave parcel
#

Yeap

hidden tangle
#

oke, wanna hop on vertical or ill explain to you how horizontal works?

grave parcel
#

Now I just need to add a force to velocity in order to stop inf jumping

#

Let's hop on vertical first

hidden tangle
#

wait, you'll add jumping?

grave parcel
#

Yea

hidden tangle
#

oh wait i didnt see your game yet

#

can you ps it?

#

print screen

grave parcel
#

U saw it

hidden tangle
#

i forgor

grave parcel
hidden tangle
#

XD

#

i easily forgor im sorry

grave parcel
#

np

hidden tangle
#

oh i see

#

so we will not use vertical movement in that

#

instead we will use jump

#

get it?

grave parcel
#

Yea

hidden tangle
#

welp its up to you what to use

#

if its vector like movement script or just addforce

grave parcel
#

What's better, GetButtonDown or KeyCode

hidden tangle
#

i use new input system

#

cause its kinda easy to put many diff key binds

#

welp i use GetKeyDown

#

in the old input

grave parcel
#

Oh okay

#

So..

hidden tangle
#

Input.GetKeyDown(KeyCode.Space)

#

kinda thinggy

grave parcel
#

Yeah

#

Instead I'll use W

hidden tangle
#

so should i help you in jump mechanism?

grave parcel
#

Ya

hidden tangle
#

or youll get it done in your own

#

oh oke

hidden tangle
grave parcel
#

AddForce, since it is easier to stop infinite jumping

hidden tangle
#

oh i see

#

can you do it on your own then?

#

like a bit of a challenge for you

grave parcel
#

But shouldn't it be ```If Input.GetKeyDown(KeyCode.W)

hidden tangle
#

and ill just help if it gets any error

grave parcel
#

Sure

hidden tangle
#

no thats wrong

grave parcel
#

Why

#

The If statements should help the Jump to run right?

hidden tangle
#

if(Input.GetKeyDown(KeyCode.W)){

#

this is how it should be done

#

you put your condition in the brakets

hidden tangle
#

but the concept is kinda right

grave parcel
#

Oh

#

Oh ya also

#

My brackets don't work

#

If I press "{"

hidden tangle
#

eh??

grave parcel
#

The other one wont "spawn" lkol

hidden tangle
#

the curly brackets?

grave parcel
#

yea

hidden tangle
#

what ide are you using?

grave parcel
#

ide?

hidden tangle
#

oh, the app that you use to code

#

like visual studio

grave parcel
#

Visual studio

hidden tangle
#

then why its not working?

grave parcel
#

No idea

hidden tangle
#

maybe you didnt install it properly?

grave parcel
#

It worked fine yesterday though

hidden tangle
#

maybe restart vs?

#

visual studio

grave parcel
#

Nope

hidden tangle
#

lmao

grave parcel
#

Normal brackets work but curly dont

hidden tangle
#

i dont know any solutions about that sorry

grave parcel
#

np

hidden tangle
#

maybe take a research of it later?

#

so how's the coding?

grave parcel
#

Uhh

hidden tangle
#

looks like a no-no eh?

#

XD

grave parcel
#

Lol ya

hidden tangle
#

so what's the problem?

grave parcel
#

Idk where to start

hidden tangle
#

XD

grave parcel
#

Oh and I get errors of the if statement

#

BRUH 13 ERRORS

hidden tangle
#

LMAOOO

#

XDD

#

13 ERRORS REALLY XD

grave parcel
#

Yeah wtf

hidden tangle
#

can you fix it? XD

grave parcel
#

Curly brackets work again

#

I just messed up my script

hidden tangle
#

lmao

#

thats a pain in the *ss

grave parcel
#
        {
            rb.AddForce(new Vector2)
        }

    }``` So start like this right
#

not finished with vector2 yet

hidden tangle
#

in if statement, you dont need ;

#

and instead add ';' this in the rb.AddForce

#

rb.AddForce() ;

#

like put that at the end of the line of code

grave parcel
#

So not vector2?

hidden tangle
#

i mean i dont know

#

its up to you

#

if you want to use vector2

#

i dont usually use addforce so i dont have a clue about that

grave parcel
#

U use velocity?

hidden tangle
#

yep

grave parcel
#

Ah okay

#

I usually use that too but I want to stop the character from sliding

hidden tangle
#

int jumpForce = 69;

rb.velocity = new Vector2(rb.velocity.x, jumpForce);

#

kinda like this

grave parcel
#

GetKeyCode does not exist in the current context

#

fuck you

#

stupid code

hidden tangle
#

lmao

#

add Input

#

at the first

#

Input.GetKeyDown

#

thatll not work if you didnt put it

grave parcel
#

Definitely did not forget to add input

hidden tangle
#

lmao

#

can i see the code?

grave parcel
#
        {
            rb.AddForce(new Vector2(rb.velocity.x * jumpForce, rb.velocity.y));
        }
    }
}
#

Doesnt work tho

hidden tangle
#

oke lemme rewrite the code

grave parcel
#

Gonna try veloicty

hidden tangle
#

and also using addforce is kinda wrong

grave parcel
#

Works

hidden tangle
#

nope, you use th ejumpForce in the x of vector

#

XD

#

wanna have a listen first at how vectors work?

#

i mean i don't know them fully

grave parcel
#

Alr

hidden tangle
#

first of all do you know axis or the thing, x y and z?

grave parcel
#

Yeah

hidden tangle
#

so vectors kinda works like thta

#

Vector2 only uses x and y

#

incase of your code, you try to jump which is would be on y axis right

grave parcel
#

yea

hidden tangle
#

but the way you did it was you put the jumpForce on the x

#

instead of y

#

so the jumpFOrce would apply on horizontally

#

in rb.velocity.x

#

and not in y

#

so do you understand it now?

grave parcel
#

Yeah

#

It's fairly simp[le

#

Simple*

hidden tangle
#

oke lemme have you a quiz then

grave parcel
#

Alr

hidden tangle
#

Vector2(15, 48)

#

whats the y value

grave parcel
#

48

hidden tangle
#

oh wait

#

but now you kinda get the idea

#

y will go up and down

#

x is left and right

#

z is forward and backward

#

which is only on 3d

#

2d is only ay x and y

grave parcel
#

Yep

hidden tangle
#

so yeah you need to apply the jumpForce right

grave parcel
#

Yeah I got it

hidden tangle
#

oke rewrite the code and give it a shot

#

oh

#

does it work?

grave parcel
#

Yep

dry heath
#

you could also rb.AddForce(transform.up)

hidden tangle
#

oh nice

grave parcel
#

I just need it to stop inf jumping

hidden tangle
#

yeah thatll do also

#

i think

#

so to stop jumping we need some complicated stuffs

#

like ray

#

or you can just use trigger collider

#

Hol, what do you think is the best for you tho?

#

to make the jump mechanism?

dry heath
#

idk im a beginner too and havent done jumping yet

hidden tangle
#

what--

#

seriously?

dry heath
#

yes

hidden tangle
#

i think you have way more knowledge about unity than me

#

but you do right

#

then what games are you doing?

#

or you don't do?

dry heath
#

you mean like what types of game im making?

hidden tangle
#

yeah?

#

sorry, im not that good at english XD

#

english is not my first language im sorry XD

dry heath
#

i just started unity like a week ago so i only did one where you dodge a cube which moves in a box and comes towards you whenever it hits the side of the box

hidden tangle
#

wait really??

dry heath
#

yes

hidden tangle
#

i started like half a year now, but i didnt actually use unity

#

cause my pc can't keep up

#

i just entered a game jam now

#

that's why i kinda know a lot of stuff

#

as a beginner

dry heath
#

o

hidden tangle
#

that game was pretty sh*t tho XD

dry heath
#

anyways i think quentuhnn said he wanted to use rays

hidden tangle
#

yeah

#

do you know how it works?

grave parcel
hidden tangle
#

its Brackey's Game Jam

#

wanna check it?

grave parcel
#

Brackey's quit right?

hidden tangle
#

i can't change the zip file cause of the rules of the game jam

hidden tangle
#

here's my game XD

#

its kinda trash tho

#

i have like 19 scripts in that game

#

and just make it in a week

#

if you want to try it, try reading the instructions on how to dl it first XD

#

cause i kinda messed up in that zip file

#
IF YOU'VE DOWNLOADED THE ZIP FILE, YOU NEED TO PUT THE "Ror.exe" FILE INTO THE "Ror_Data" FOLDER, BECAUSE I KINDA MESSEP UP XD. I'm sorry about that.
#

here's the instructions XD

#

anyways

#

hows the code quentuhnn?

grave parcel
#

Still need to stop it from inf jumping

#

im too stupid for this

hidden tangle
#

welp you need to use rays

#

if you want

#

or you can use trigger colliders

grave parcel
#

How :D

hidden tangle
#

what do you want tho?

#

colliders or ray?

grave parcel
#

I dunno

hidden tangle
#

for starters why not use collider first?

#

cause its kinda easy to setup and code

#

it doesnt need a lot of understanding as well

grave parcel
#

Sure

hidden tangle
#

so for it to work

#

do you use box collider?

grave parcel
#

yup

hidden tangle
#

and also tag the platforms

#

so

#

we need to add ONE more box collider to your player

#

so where to put i hear you asked

#

from where the feet is

#

or where the player touches the floor

#

make it lower a bit

#

and smaller

#

did you get it?

grave parcel
#

done

hidden tangle
#

can i see?

grave parcel
hidden tangle
#

can i see it in scene view

#

so i can see the borders of the collider

grave parcel
#

that is scene lol

hidden tangle
#

oh my bad

#

then zoom it XD

#

brb imma eat

#

please wait a bit

grave parcel
hidden tangle
#

and search for documentations if you want XD

grave parcel
#

alr

dry heath
#

since i think this is what you'll be using

hidden tangle
#

aight you there?

#

@grave parcel

#

you alive?

grave parcel
#

Yup