#help

1 messages · Page 1 of 1 (latest)

wraith spruce
#

over here

next frost
#

Okay

#

You here?

wraith spruce
#

yea

next frost
#

Give me a sec to type I'm on mobile after all

wraith spruce
#

its ok

#

its 2:33am

#

gotta get the grind

#

what if i was to create 2 bools where 1 tests if mouse is down and the other tests if the button has been pressed

#

if the mouse was up then set the other bool to false

#

3 bools sorry

#

left bool right bool mouse bool

#

if left bool and mouse bool = true player move ect

next frost
#

Okay

#

I'll type fast

#

Sorry I was talking to someonne

wraith spruce
#

its ok

next frost
#
Public rigidbody2d rb;
Public float Speed;

//True Dir is right
//False Dir is left
MyMethod(bool IsMoving, bool Dir)
{
     if(IsMoving)
     {
          If(Dir)
          {
               rb.velocity = new Vector2(Speed, 0);
          }else
          {
               rb.velocity = new Vector2(-Speed, 0);
          }
     }else 
     {
          rb.velocity = new Vector2(0, 0)
     }
}
#

If you try to copy and paste that it will give errors becuase I miss spelt things

wraith spruce
#

er

next frost
#

Some variables are capitals where they shouldn't be

wraith spruce
#

do i just copy it

next frost
#

Dont

#

I can't use the Tab button on mobile

#

So I put spaces to make it more readable

#

Write what you see

#

Let me know when your done and send a screen shot so I can see if possible

#

It shouldn't take long to code. When you have your cursor in between things like {} just hit enter and it will put it where it where it should go.

wraith spruce
#

sorry theres a noise outside

#

sounds really bad

#

like a dying cat

next frost
#

Np

#

Did you get it typed or were you busy with the noise?

wraith spruce
#

nearly done

next frost
#

K

wraith spruce
#

what in the hell has happend

next frost
#

I didn't mean actually write exactly what I had

wraith spruce
#

oh

next frost
#

It's fine though

#

We can fix these

wraith spruce
#

then what was i supposed to do

#

ok

next frost
#

Let's start at the top

#

Public is public

#

No caps

wraith spruce
#

done

next frost
#

Send new screenshot

wraith spruce
next frost
#

Now rigidbody2d

#

If you hit tab while writing the code it will put the highlighted word

#

That's what visual studio is for

#

It's to be faster

#

So remove the rigidbody2d rb

#

And start typing rig...

#

Then hit tab

#

You will see it autofill

wraith spruce
#

no

#

oh it did

next frost
#

Yea

wraith spruce
next frost
#

I use it for almost every word

#

You will learn to use it a lot

wraith spruce
#

ok

next frost
#

It can MASSIVLY help

wraith spruce
#

ok

next frost
#

MyMethod is supposed to be that method you made a while ago

#

Not actually "MyMethod"

wraith spruce
#

what method

next frost
wraith spruce
#

ok

next frost
#

I would suggest calling it Move not move

#

If your going for that

wraith spruce
#

its PlayerMovement

next frost
#

Good

#

How are the errors looking?

wraith spruce
#

34

next frost
#

Can I see a picture?

wraith spruce
next frost
#

Play so these are green indicating that these are classes

#

You did something wrong

#

Oh

#

you need "void"

#

That needs to be in front of playermovement

wraith spruce
#

ok

#

33 errors

next frost
#

You put a - in your code😆

wraith spruce
#

changed nothing

next frost
#

The If should be if

#

That's an if statement seeing if something is true or false

wraith spruce
#

even more errors

next frost
#

Send a picture

wraith spruce
next frost
#

I need to see farther down too!

#

?

#

Not the messages

#

Ohhhh

wraith spruce
#

wrong one

next frost
#

void MyMethod()
{

}

#

You need those

#

That holds all that code in the method

wraith spruce
#

its all good now

next frost
#

Okay

#

Can I explain it to you?

wraith spruce
#

i get the rb.velocity stuff but everything else sure

next frost
#

The IsMoving will get set to true when we press the buttons

wraith spruce
#

ok

next frost
#

The if statement that is checking the IsMoving is checking to see if it's true

#

It's short for
if(IsMoving == true)

wraith spruce
#

oh ok

next frost
#

Then we check for the direction we will be moving by making a left/right bool

#

I just called that Dir

wraith spruce
#

ok

next frost
#

BTW that top info I changed to this in the message

#

Not positive and negative. I wrote the wrong thing😆

wraith spruce
#

i dont want the charator to move all the time

next frost
#

Ik

#

I'm not finished explaining

wraith spruce
#

ok

next frost
#

See that bottom else statement?

#

else statements are like saying "if the opposite happened do this"

wraith spruce
#

ye

next frost
#

So if we do

{
}
else
{
//This is what happens when it's not true in this case
}```
wraith spruce
#

ok i get that#

next frost
#

So then we will call this method and set that to be false when we release our finger from the screen

#

👍

#

Now to set up the buttons then we are done

wraith spruce
#

ok

next frost
#

Remember those components I said to add onto both buttons?

wraith spruce
#

yea

next frost
#

Well on each one get the "OnPointerDown" and "OnPointerUp"

#

Hit the + icon for those

wraith spruce
#

wtf

next frost
#

What?

wraith spruce
#

ah foud it

next frost
#

So you got both buttons all set up?

wraith spruce
#

yep

#

pointer up and down

next frost
#

What are your button names?

wraith spruce
#

left and right#

next frost
#

Okay

#

So add your script to your player

wraith spruce
#

ok

next frost
#

And attach the rigidbody to the rb

#

You can just drag the component to the slot

wraith spruce
#

doe

#

what should speed be

next frost
#

Make it 1 for now

wraith spruce
#

done

next frost
#

Now go to one of your buttons

next frost
wraith spruce
#

change what now

next frost
#

Instead of
//Positive Dir is right
//Negative Dir is left

wraith spruce
#

oh ok

next frost
#

Positive and negative have nothing to do with this. I got those messed up with true and false

wraith spruce
#

ok

next frost
#

I typed the wrong thing basically

#

Okay so save that

#

Then go to your right button

#

Go to that component

#

Drag the Player gameobject into the gameobject slots for both pointer down and up

wraith spruce
#

wht gameobject

next frost
#

The player gameobject

#

Becuase the player gameobject is the one with the script 👌

wraith spruce
#

ah

#

what function

next frost
#

The function we made 🙂

wraith spruce
#

cant findit

next frost
#

Oh that's becuase it's private

#

And public in front of the void

#

When you just have void it's short for
private void

wraith spruce
#

cant find it

next frost
#

You need to put the public

wraith spruce
#

i did

next frost
#

Can you send a picture of the menu?

wraith spruce
#

public void PlayerMovement(bool IsMoving, bool Dir)

next frost
#

No the menu

#

From where you select

wraith spruce
#

i can see move but no playermovement

next frost
#

Okay

#

Send the menu before this

wraith spruce
next frost
#

You selecting the move script of gameobejct?

wraith spruce
#

ye

next frost
#

Can you send a picture of the script and a picture of the component on the button?

#

That should be all I will need

wraith spruce
next frost
#

Okay

#

Now the component?

#

Please

wraith spruce
#

what component

next frost
#

The component you added to the button

wraith spruce
next frost
#

Is the Main Camera the player?

wraith spruce
#

no

next frost
#

Is it the gameobject with the script?

wraith spruce
#

main charactor is

#

i set it to main charator

next frost
#

Okay so it was a mistake?

wraith spruce
#

yea

next frost
#

It should be there now.

wraith spruce
#

it still wont show

next frost
#

Hmm

#

You might not be able to pass multiple peramiters through one button

#

So change the peramiters to only have int dir

#

You will get errors again

wraith spruce
#

is moving dosnt exist

next frost
#

Yes

wraith spruce
#

cannot change a int to a bool

next frost
#

Make the if(IsMoving)
if(dir != 0)

#

So change it to that

wraith spruce
#

still cant change an int to a bool

next frost
#

Let me see the code

wraith spruce
next frost
#

Okay now change that Dir to Dir ==1

wraith spruce
#

fixewd

#

yay]

next frost
#

Okay now change that else below that to
Dir == 2

wraith spruce
#

i selected it

#

done

next frost
#

K

wraith spruce
#

says ; expected

next frost
#

So put ;

#

See where the red is?

#

It's expecting it there

wraith spruce
#

yea

next frost
#

Fixed?

wraith spruce
#

no

next frost
#

Oh no

#

You needed to change the else to an if

#

Then remove the ;

wraith spruce
#

fixed

next frost
#

Good, now lets change those comments again in the script

wraith spruce
#

ok

#

1 and 2

#

1 is right

#

2 is left

next frost
#

//0 = don't move, 1 = move right, 2 = move left

wraith spruce
#

ok

next frost
#

Good your understanding it!

#

Let's go to the components on each button and select the method

#

Do this for each field

wraith spruce
#

all the buttons are dont with the thing

next frost
#

?

#

Wdym?

#

Like 0?

wraith spruce
next frost
#

Okay good!

#

So on pointer down on the right button make it 1

#

Then on the left button on the on pointer down make it 2

#

Then leave the on pointer ups to 0

wraith spruce
#

done

next frost
#

It should work!

#

Mobile and pc

wraith spruce
#

it moves when i click it

#

but not hold

next frost
#

Wdym?

wraith spruce
#

if i hold it it only goes forword 1 bit then stops

next frost
#

Okay

#

So this is probably your friction

#

Where you created your script now created a physics material 2d

wraith spruce
#

ok

next frost
#

And set the friction to 0

wraith spruce
#

where is it

next frost
#

Lol

#

I wondered the same thing my first time trying to get it

wraith spruce
#

lol

next frost
#

Send a picture of the menu

wraith spruce
next frost
#

No when your trying to create it

wraith spruce
#

create what

next frost
#

The physics material 2d

wraith spruce
#

how do i get that

next frost
#

R8ght click that grey area where the script is

wraith spruce
#

yea

#

nothing happend

next frost
#

Down here

#

Them show me that menu

wraith spruce
next frost
#

Create

#

Ohh you got the duel monitor display as well!

wraith spruce
#

yea

next frost
#

It's very useful for things like this

wraith spruce
#

yup

#

i used to have a laptop

next frost
#

Okay so when in create what options pop up?

wraith spruce
#

?

#

wdym

next frost
#

Click create

wraith spruce
#

i did

next frost
#

And it will pop up with a menu

#

Show me that menu

wraith spruce
next frost
#

Okay it's in 2d

#

Top of the menu

#

Physics material 2d

wraith spruce
#

got it

#

stil dont work

next frost
#

Like you got the physics material 2d made?

wraith spruce
#

oh wai

#

im retard

#

it did work

#

i didnt put it on the player

#

it works

next frost
#

Assign it to the rigidbody 2d

wraith spruce
#

thank you soo much

next frost
#

Wait you did?

wraith spruce
#

yea

next frost
#

Sorry that took so long

wraith spruce
#

u must have no life uve been helping me for hours

#

jeez man

next frost
#

Lol

wraith spruce
#

thank you so much

next frost
#

No problem

wraith spruce
#

its 4 am rn bro ☠️

next frost
#

9 for me

#

Lol

wraith spruce
#

sm

#

am or pm

next frost
#

Pm

wraith spruce
#

u in austraillia or smthin

next frost
#

That's why, becuase I'm not doing anything right now

wraith spruce
#

ah ok

#

well ima get some sleep

next frost
next frost
wraith spruce
#

yea

#

ive been up on my pc since 10pm

next frost
#

It's am??????

wraith spruce
#

yea

next frost
#

Geeeeez

wraith spruce
#

ikr

#

theres a rule where if u can stay up u can play

#

i cant be load

next frost
#

Lol

wraith spruce
#

lol

#

aight have a good one and thx so much

next frost
#

Yea, glad I could help

#

You understand it all right?

wraith spruce
#

saved 30 times ☠️

#

i do

next frost
#

Good so if you put a wrong value you now what its doing now and you'll be able to fix it?

wraith spruce
#

yea

#

when the button is pressed it gives that value and the player detects fro that value and givs an output

next frost
#

Yes! It's checks to see what the value is

wraith spruce
#

yea

next frost
#

Then based off that it will act

#

Just don't set it to things like 4 or 5

wraith spruce
#

yea

next frost
#

It might cause problems

wraith spruce
#

ill add a jump later

next frost
#

If you want, we can make a debug for that

#

So it doesn't cause errors

wraith spruce
#

not right now im gonna sleep

next frost
#

Okay

wraith spruce
#

tmr?

next frost
#

Gn glad I could help!

wraith spruce
#

what timezone are you so i know when

next frost
wraith spruce
#

ok well im gmt so yea gn

next frost
#

Gn