#🖼️┃2d-tools

1 messages · Page 40 of 1

inner vine
#

im not fully stoping

jovial cedar
#

so do as Pancake says and replace input with Input

#

and try again

thorn dirge
#

if it doesn't work keep trying

inner vine
#

i just deleted it

thorn dirge
#

coz that suc-

thorn dirge
#

at least try and make another game

#

keep trying

#

there are so many things to learn in unity

inner vine
#

im gonna use the same assets

jovial cedar
#

still confused why it would even compile though

inner vine
#

but a dif tutorial

#

and im not doing a shooter

signal aspen
#
        float x = Input.GetAxis("Horizontal"); //Checks for forward/backwards movement on a keyboard or controller.
        float z = Input.GetAxis("Vertical"); //Checks for movements on the sides.

        Vector3 move = transform.right * x + transform.forward * z; //Defines what MOVE is
        "YOUR PLAYER GAME OBJECT".Move(move * speed * Time.deltaTime);
``` This code might work
thorn dirge
signal aspen
#

you might wanna use vector 2 tho

jovial cedar
#

unity is full of ways to move things around :d

inner vine
#

ok

#

i have 1 question tho

jovial cedar
#

this is mine, but you could also use transform.Translate()

thorn dirge
#

uhhh

#

wait limme try and remember

#

its been long since I did a top down shooter

#

ah yes rb.Moveposition( Movment * speed) * Time.deltatime

inner vine
#

OMG

#

I FORGOT TO

thorn dirge
#

probably got it wrong

inner vine
#

EAT MY BANANA

#

BRB

#

(also im not even kidding i forgot to eat my banana)

thorn dirge
#

ok take your time

signal aspen
#

@inner vine also, try to follow the lords tutorial... Brackeys 2d series https://www.youtube.com/watch?v=on9nwbZngyw&list=PLPV2KyIb3jR6TFcFuzI2bB7TMNIIBpKMQ&ab_channel=Brackeys

Want to make a 2D game but don't know where to start? This video should help point you in the right direction!

● Free Assets List: https://bit.ly/2tv7aBU

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

····················································································

♥ Subscribe: http://bit.ly/1kMekJV

● Websit...

▶ Play video
#

he covers everything

thorn dirge
#

like still have somethings but pretty outdatted

#

I recommend using the unity tutorial playlist

#

I think this one will lead to the entire playlist

#

yeah unity covers almost all the basic c sharp programming things so I recommend that tutorial since its the most reliable

inner vine
#

nvm ill just find a dif one that is not that outdated

thorn dirge
#

the unity tutorials explain them very clearly

#

the brackeys tutorial cover the intermediate things about unity like shooting and ui

#

if you want to learn unity like a master I recommend an underrated youtuber called code monkey

#

his tutorials are 20 minutes long but the code is simple enough to modify but not understand

inner vine
#

can you send me to a tutorial of him with a 2d platformer?

thorn dirge
#

I haven't seen a better tutorial of it

#

but he did make an excellent top down shooter

#

brackey mainly focus on the other aspects of unity like homing missles

#

so I guess you will have to make the 2d code yourself

inner vine
#

i found one from 9 months ago

#

ill use that

#

if i need help ill ask here

thorn dirge
#

yes

inner vine
#

OMG LOL

#

HE DIDNT EVEN MAKE ART OR CODE IN THAT TUTORIAL ALL HE DID WAS THIS

#

its funny to me

thorn dirge
#

what the brackeys movement tutorial?

#

yea its not really good

inner vine
#

no

#

this

thorn dirge
#

hmmm never seen that one before

abstract olive
#

It is called Setting up, and looks to be a first video in a series.

inner vine
#

lol

#

also after my 2d platformer is done ill make a shooter game

halcyon gorge
#

Can someone tell me why is there 2 red ans blue
line

inner vine
#

i tested this and there is errors. why wont it move?

weak sinew
#

whats the best way to implement a main menu

snow willow
weak sinew
#

ive tried to make a seperate scene but it just gets layered on top of the other scene.

#

wait

inner vine
weak sinew
#

i might have put the seperate scene inside of the current scene o-o

weak sinew
#

¯_(ツ)_/¯

inner vine
#

oh

#

im fricking stupid

#

NVM it is there

weak sinew
#

k

#

uh

#

dunno then

thorn dirge
#

hm

inner vine
#

i realized why

#

i didnt save it

thorn dirge
#

yeah its rb.velocity = movemen-

thorn dirge
#

it was so dumb

thorn dirge
#

lol

#

the pain when you realized you made the world's most rookie mistake

inner vine
#

idk how to save tho oof

thorn dirge
#

that we both need to press

#

hm

inner vine
#

THATS WHY IT DIDNT WORK WITH THE SHOOTER GAME DANGIT

#

I QUIT BC OF NOTHING

#

DANGIT

weak sinew
#

o u forgot to save? lmao

thorn dirge
#

lol

#

it was so inexpected

weak sinew
inner vine
#

.

weak sinew
#

o

inner vine
#

...

weak sinew
#

what errors are there

inner vine
thorn dirge
weak sinew
#

o-O

inner vine
#

can you tell im annoyed rn?

thorn dirge
#

beside the movement logic

#

and not a semi colon

weak sinew
#

: != ;

thorn dirge
#

it was one mistake lol

#

the compiler thinks its the brackets wrong

#

hm

#

I need to learn my grammer

inner vine
#

can you screen shot and put a circle at whats wrong?

inner vine
#

it makes it easier for me

thorn dirge
#

this thing is a colon and not a semi colon

#

unless I am blind

weak sinew
thorn dirge
# weak sinew

I am too lazy to fire up paint to this this shit lmao

weak sinew
thorn dirge
inner vine
#

i fixed it and guess what

thorn dirge
inner vine
thorn dirge
#

it would usually bring you to the place they think is wrong

inner vine
thorn dirge
# inner vine

hmm I think you should do it like:

void Update()
{
\\code
}

#

oh I see now

#

your spacing is wrong af

weak sinew
#

i dont see the spacing issue where?

rough peak
#

also no semi colon on line 18

thorn dirge
#

try to tab the funcitiom

weak sinew
#

wasnt it there before wtf

rough peak
#

Heyo, I have a question about UI

#

is this the place for it?

weak sinew
rough peak
#

I mean in coding

weak sinew
#

is it for a 2d game

snow willow
#

¯_(ツ)_/¯

rough peak
#

Oh i see

obsidian smelt
#

I cant run this function through update since it has the "Collision collision"

rough peak
#

rename collision?

#

in the function arguments

obsidian smelt
#

im a begginer btw

thorn dirge
#

m

obsidian smelt
#

but I need help with that

#

because I can't run it

#

and I don't think this works at all

thorn dirge
thorn dirge
#

tab it kinda like solves things automatically

obsidian smelt
inner vine
thorn dirge
thorn dirge
#

and press

#

the button tab

#

on your keyboard

inner vine
#

this? lol

thorn dirge
obsidian smelt
#

is there anyway to fix this? I have a platform that moves up and down, but when it moves down my character bounces

thorn dirge
#

and yes you did it right

#

just press tab

#

on the function

#

void

#

plus it keeps your code clean and tidy

inner vine
#

cs1002

#

gtg

obsidian smelt
#

can anyone help me with that ^

thorn dirge
#

uhhh haven't encountered something like this

thorn dirge
#

idk how to do with that

#

dani said something about that before I think

obsidian smelt
#

I was trying to find things searching but only found something about when colliding to set the player as a child to the platform

#

and that was what I was asking help for up there

#

but I can't run the code through update

thorn dirge
#

use rb.moveposition

thorn dirge
#

OnColliderStay2D

#

same thing

#

but you can run the code multiple times

#

I wished I found out about that sooner

obsidian smelt
#

so how do I do it? I'm a bit confused on where to put things I just got into learning this stuff

thorn dirge
#

but it hits multiple times

#

or you can

#

OnColliderEnter2D(stuff)
{
(parent player with platform
}

obsidian smelt
#

so it's basically its own Update function

thorn dirge
#

OnColliderExit2D(stuff)
{
(unparent)
}

thorn dirge
#

I think you should use the OnColliderExit way

obsidian smelt
#

when it sets the player as a child it still bounces

#

I saw something saying to attack the player to the platform

#

would that be making it a child

#

nvm

obsidian smelt
dense saffron
#

hello! I am athran and I want to learn how to move the camera's w/ the player

weak sinew
#

any tips on how to make a trailer? (not really sure what channel this question goes into)

thorn dirge
obsidian smelt
thorn dirge
#

or you can transform.parent = null

hardy heart
#

Hey there! Can i have a tutorial for pathfinding when i have dynamic spawning objects with colliders in 2d?

still tendon
#

hey guys
I am trying to have a panel with clamp and snap properties to basically pull up the top of the panel to snap at 3 different positions(bottom, mid to show partial information, top to show complete panel). Should I be using the default scripts for both? Any suggestions?

Also, how do I change TMPro button's Text color from black (interactable on) to grey(interactable off)? For normal text component its just using GetComponent<Text>().Color but for TMPro I get lost when I get to GetComponent<TextMeshProUGUI>().text ...
Is it vertex gradient or Color32?

Thank you

inner vine
#

cs1002

#

what the frick do i do then

#

also why is unity acting like the files are corrupted

#

heres my code

warm pebble
#

missing semicolon at the end

#

line 19

inner vine
#

how do i fix?

warm pebble
#

rb.velocity.y = movement;

#

should be that line

snow willow
#
Vector3 vel = rb.velocity;
vel.y = movement;
rb.velocity = vel;
warm pebble
#

srry srry wasnt paying attention to the other stuffs

snow willow
#

replace yours with mine

inner vine
#

why do you have it with vel?

inner vine
snow willow
#

line 19

inner vine
snow willow
#

you need to use all of the code I gave

inner vine
#

like this?

#

oh frick

snow willow
#

And you've simply misspelled Vector2

inner vine
#

should i replace vector 3 with vector 2?

snow willow
#

no

#

why

inner vine
#

ok

snow willow
#

The error messages have line numbers on them. Look at the line to see where the error is

inner vine
#

oh frick

snow willow
#

oh wait

#

my bad

#

yeah use Vector2 instead of Vector3

#

I didn't notice this is 2D physics

#
Vector2 vel = rb.velocity;
vel.y = movement;
rb.velocity = vel;```
inner vine
#

how do i fix this?

#

the code

#

hello?

snow willow
#

movement is a Vector2 now

#

then you just do rb.velocity = movement;

#

instead of all 3 of those lines

brisk flame
#

the problem is that you are trying to put movement (which is a vector2) into vel.y which is a float

snow willow
#

I was under the impression that movement was a float for some reason

brisk flame
#

i think you can use vel.y = movement.y

#

let me know if this works

#

ALSO - make sure to write FixedUpdate correctly using PascalCase

brisk flame
#

make sure to change the class name to your script name

inner vine
#

huh

#

oh let me look at the messages

inner vine
snow willow
# inner vine

You're having some basic structural issues with your code. You should go through some basic C# tutorials so you understand what on earth you're looking at

#

currently I guess the code looks like wingdings to you

inner vine
#

it looks like russian to me

#

tbh

brisk flame
inner vine
#

now you can see the numbers

brisk flame
#

try to replace this code with the hatebin i posted

#

remember to change the class name to your script name

inner vine
#

im confused

#

WITCH LINE

brisk flame
#

all of this

#

your entire class

snow willow
# inner vine

Loks like you're just missing a closing brace at the end of the file

inner vine
#

pls zoom or circle the thing

#

im to dumb to understand

brisk flame
#

try to replace your entire class with this code

inner vine
brisk flame
#

yesss

#

now change the class name

#

its now CapsMover

#

make it PlayerMovement

jovial cedar
#

you should really read what that the compiler is saying, too... missing brackets and semicolons are easy things to fix and very evident

#

from the error messages

inner vine
brisk flame
#

what errors are you getting?

inner vine
#

yo what the frick

brisk flame
#

go to visual studio

#

what errors are you getting?

inner vine
inner vine
brisk flame
#

ok, try this - select the scripts name and press Ctrl + R, Ctrl + R (twice). then remane your script to Movement. then place it on the object again

inner vine
#

i just got a new error

inner vine
#

rename*

#

OOF man im hungry

brisk flame
#

on line 16, change RigidBody to RigidBody2D

inner vine
brisk flame
#

rb = GetComponent<RigidBody2D>

inner vine
#

im luaghing rn

brisk flame
#

rb = GetComponent<RigidBody2D>();

inner vine
brisk flame
#

()

#

brackets

#

before semicolon

inner vine
#

the <>?

brisk flame
#

rb = GetComponent<RigidBody2D>();

#

just paste this line

#

instead of line 15

inner vine
#

OOF

brisk flame
#

on line 11 change to:

#

RigidBody2D rb;

inner vine
brisk flame
#

capital B

#

RigidBody2D

inner vine
#

so many FRICKING ERRORS

brisk flame
#

did you save?

jovial cedar
#

clear the console

brisk flame
#

in visual code

inner vine
jovial cedar
#

most of those are from 10 minutes ago

inner vine
#

then this is the only error

brisk flame
#

show me all of the script

inner vine
#

all of the script

brisk flame
#

should work

#

his save

#

hit save

#

Ctrl + S

#

then go to unity

inner vine
#

i already did

brisk flame
#

still errors?

inner vine
#

thats still there

brisk flame
#

thats from 3 minutes ago

#

go to the robot, look at the Movement component

jovial cedar
#

it's Rigidbody not RigidBody

brisk flame
#

look at the field called movement speed and set it to 5

inner vine
brisk flame
#

oh you are right! so set both lines to Rigidbody2D

inner vine
#

now lets see if it will work

brisk flame
#

press on the Movement component to expand it

#

then set the speed to 5

#

and THEN see if it works

inner vine
#

wat ._.

#

Visual studio code or unity?

brisk flame
#

Click This

#

then set the speed to 5

inner vine
#

IT WORKS

#

i set it to 100

brisk flame
#

yessss

inner vine
#

its still normal speed

brisk flame
#

glad to hear it

inner vine
#

are you sure it wont mess up the tutorial im using? ._.

#

Run, Player, Run! We look at creating a player movement script for a 2D Platformer in Unity. This is the second part of our 2D Platformer in Unity series.

Thanks for watching!

Twitter: https://twitter.com/tyler_potts_
Go check out my main channel: https://youtube.com/c/tylerpotts

I aspire to be an Indie Game Developer making fun and immersive...

▶ Play video
brisk flame
#

if you are using a tutorial, wouldn't it be simpler to just see what they did to make things move?

#

🤓

inner vine
#

where do i put it?

inner vine
#

i decided to redo the whole movement code

#

hello?

#

ive redone the code so it follows the tutorial and its saying: The variable rb of Moving has not been assigned.

#

i need help

#

pls

abstract olive
#

So assign it. This is basic Unity stuff.

#

Also, if you're following a tutorial, follow it.

tidal onyx
#

Hello, i got a quick question

#

So I have a situation where you can pick up objects with the mouse and let them go by releasing the mouse

#

Right now, wherever the player is at you can move the pickup object anywhere on the screen

#

Is it possible to limit where the pickup can be moved to? Like, make it so you can only drop it within a certain distance of the player?

#

This is my current code for the picking up: The script is attached to the pickup object

abstract olive
#

Sure, though it would take a bit of work.

#

The idea is pretty straight forward though:

  • Get the distance between the mouse and the player

In Range:

  • If it's less than a value (range), then allow the position to match the mouse as normal

Out Range:

  • If it's greater, than get the direction to the mouse from the player
  • Normalize that direction and multiply it by the range value
  • Set the position of the item to be the playerPosition + direction
tidal onyx
#

Ok, I think that makes sense

#

Thanks

hollow badge
#

So looking over my code, literally the only thing that stops my horizontal momentum/movement could be the rigidbody/collider's collision. No code(on my side) involved.

What could be the problem here? It runs smooth over a random number of platforms(anywhere from 1 to 50), maintaining a constant speed, and then eventually gets stuck on the next/upcoming platform until i drop said platform down a pixel.

#

i just checked the rigidbody.velocity.x and it is cycling between 10 and 0, due to my code accelerating it to 10 and the rigidbody decreasing it to 0 so it doesnt clip. Does anyone have an explanation why it is colliding despite clearly not crossing the other collider?

#

for reference, if i jump, he continues as normal, and eventually gets stuck again. the platforms are transform.position changed only in the x dimension, endless-runner style

inner vine
#

oh wait

terse thorn
#

i have a quick question and i could'nt find anything in the web, do anyone know if there is a way to make an object always point upwards undependently of his parent rotation?

crystal geode
#

not quite sure how to word this, but is there a way to attach one gameobject to another during runtime? I don't mean like nested objects, but rather taking two independent objects and forcing one to follow the movements of the other

terse thorn
#

i think that will work

crystal geode
#

oh dang, I can do that? Rad

inner vine
#

i know nothing about unity

crystal geode
#

also, not sure if I can answer your question @terse thorn , but how do you have your object set up? Is the sprite attached to a nested object on the one that's rotating?

terse thorn
abstract olive
hollow badge
#

i tried putting in some good effort to explain my problem, anything im missing that would be helpful?
i had this exact same problem a year ago when i gave up on learning bahaha. different platformer prototype, same issue

#

well i have a current workaround where it checks if velocity is 0 and moves the player up .000000001f and it fixes the issue fast enough that you dont notice him stopping and resets the velocity to 10. idk man it just sounds like a unity problem to me considering all 3 platforms are spawned in the exact same Y position and it randomly decides to get stuck, changes every time.

inner vine
#

how is this different

#

im so annoyed rn

hollow crown
#

what's your actual problem?

inner vine
#

its not moving

#

in the video it moved

hollow badge
#

my dumb question is do you have the Rigidbody assigned in the inspector

hollow crown
#

have you set movement speed in the inspector?

inner vine
#

nvm im just stupid

hollow crown
#

are there errors in your console?

inner vine
#

pls face palm yourself

hollow badge
#

is that the inspector value? too high or somethin? idk

#

im still scrub

inner vine
#

nah its still slow

hollow badge
#

ah ic

inner vine
#

im just being stupid

#

next time i be stupid pls slap me in the face

abstract olive
#

@inner vine Don't post gifs.

hollow badge
#

@terse thorn https://answers.unity.com/questions/1360351/how-to-rotateposition-the-child-object-independent.html theres a workaround mentioned in this, i think he mentions there is no direct way to do what you are asking though

terse thorn
#

:(

hollow badge
#

the workaround should work fine though, i actually came up with the same workaround for my old project a while back

inner vine
#

me dumb

hollow badge
#

you got this my dude, no stress

inner vine
#

and also i read rules now

inner vine
#

oh frick i forgot

#

im getting these errors

#

the code

hollow badge
#

can you show the numbers on the side as well

inner vine
#

the tutorial's code

hollow badge
#

jumpforce has a : not a ;

inner vine
#

what

hollow badge
#

you have a : on line 9, not ;

inner vine
#

public float jumpForce = 20f:?

hollow badge
#

should be 20f; not 20f:

inner vine
#

OH FRICK

#

i realize

hollow badge
#

ye common mistake yo

#

see if the other one disappears too, idk

inner vine
#

i prob should go back to the tutorial

#

dang i cant jump still

#

frick why cant i jump?

hollow badge
#

are the buttons assigned properly in unity?

inner vine
#

the tutorial's code

hollow badge
#

edit > project settings > input manager is already configured?

#

oh jump is default, guess its spacebar default?

#

does any movement work and just jump doesnt?

inner vine
#

the movement works

#

but the jump doesnt

#

i can show you a video

hollow badge
#

its ok im thinkin bout it

#

you are using spacebar right? and edit > project settings > input manager > axes > jump is configured correctly?

#

thats all i can think of

#

unless maybe your collider in unity is huge and getting stuck in stuff, idk

#

sorry, im pretty scrub so idk

inner vine
#

here

#

do i sound tired

#

?

#

HELLO!?!?

hollow badge
#

thats all i got buddy, idk what the problem is. tried looking it over but im too scrub to figure it out 🤷‍♂️

#

maybe send a screenshot of the movement script in the inspector for good measure though

inner vine
hollow badge
#

moving script* in inspector, on the gameobject

inner vine
#

you mean the player?

hollow badge
#

yea

inner vine
hollow badge
#

something wrong here. the script you sent was "moving" but the script on the player is "movement"

#

so either way, you gotta add the "moving" script to the player gameobject

inner vine
#

OH FRICK

#

THEN ITS THE WRONG SCRIPT

#

i had a script named movement but i was not planing on using it

#

i was actually gonna delete it

#

thats why

#

frick

#

dangit

#

NO WONDER

hollow badge
#

yea after swapping scripts, youll need to reassign the scripts variables in the inspector ye

#

hopefully it works now

inner vine
#

and i forgot to save

inner vine
#

let me guess more coding : (

hollow badge
#

in unity > select the player > look at inspector > look at "moving" script > see "none" in the rigidbody variable > drag the "rigidbody 2d" in said inspector window into the "none" space

inner vine
#

i-

#

what

hollow badge
#

could be wrong on that one, and if im wrong, then indeed it takes more coding

inner vine
#

select the player means the model right?

hollow badge
#

select the player gameobject in the hierarchy or the scene yea

#

something like this basically. there should be a "rb none" space in your "moving" (script) that you drag the rigidbody 2d into

#

but idk if that works tbh

#

i just assume it does

inner vine
#

IT WORKS

#

THANK YOU SO MUCH

hollow badge
#

yup

#

imo before continuing any tutorial i have a recommendation

#

im basically fresh out of this tutorial series

#

probably the best iv ever taken

#
Unity Learn

In this official course from Unity, you will learn to Create with Code as you program your own exciting projects from scratch in C#. As you iterate with prototypes, tackle programming challenges, complete quizzes, and develop your own personal project, you will transform from an absolute beginner to a capable Unity developer. By the end of the c...

#

be patient and literally watch the videos and try and understand what is going on BEFORE you do it yourself

#

if you rush then it wont sink in and youll forget steps down the line

#

i had college classes and boot camp classes related to programming and they wernt as good as that series, legit

inner vine
#

i want to learn unity when im done with the tutorial so i can add my own spins to it

#

so no thanks for rn

#

i want to make the basics before learning

hollow badge
#

eh this series is legit a steal, i'm surprised it doesn't have a pricetag

#

anyway good luck yo

inner vine
#

ok ill ask when i need help

raven forge
#

Hello, can somebody help me with something. Right now I'm trying to implement some enemy awareness (detect if the player is behind a enemy, etc.) So this is my code for when the enemy detects that the player is attacking from behind. My issue is that the condition always throw a 1, and that makes the enemy rotates every time the player attacks him. How can I fix that? Is there a better implementation of the problem?

inner vine
#

...

#

i already know what the problem is i just dont know how to fix it

hollow crown
inner vine
#

wat

hollow crown
#

Also, the error tells you what line of code it is, so you can look to that line for the issue

#

which is this

inner vine
#

uhhh

#

is it the s?

hollow crown
#

it should show a red underline where the issue is

#

it doesn't, meaning your IDE isn't configured properly

#

also, read the error, look at that part of the code, and think about how the two might connect

inner vine
#

ide?

hollow crown
#

VS / VS Code

inner vine
#

bruh the problem is THE FEET

hollow crown
#

?

inner vine
#

there is meant to be a feet thing here

hollow crown
#

The code cannot compile

#

so it will not show any new values in the inspector

inner vine
#

oh

#

the ground layers arent there either

inner vine
hollow crown
inner vine
#

how do i fix?

hollow crown
#

What is that error I just posted talking about?

#

what character is it saying is missing?

inner vine
#

OH

#

i think ik what this means now

#

its missing a ;

#

i think

hollow crown
#

yahuh

#

again, with a configured IDE it would be underlining the issue as you write the code

inner vine
#

idk how

hollow crown
inner vine
#

is that right? or is it just a download for visual studio code?

hollow crown
#

Do what it says? It tells you what you need

raven forge
inner vine
hollow crown
#

no, it says to install it, and tells you briefly what that includes

inner vine
#

ah frick i have to restart my computer

inner vine
#

cya

#

back

#

uh oh

inner vine
#

?

#

im missing a ; in my coding and idk where it is where is it?

coral dock
#

so im trying to make wasd controls for a sprite idk what im doing wrong

inner vine
#

!!!

#

idk

inner vine
# coral dock so im trying to make wasd controls for a sprite idk what im doing wrong

Run, Player, Run! We look at creating a player movement script for a 2D Platformer in Unity. This is the second part of our 2D Platformer in Unity series.

Thanks for watching!

Twitter: https://twitter.com/tyler_potts_
Go check out my main channel: https://youtube.com/c/tylerpotts

I aspire to be an Indie Game Developer making fun and immersive...

▶ Play video
coral dock
#

nvm i just had to hit save im a walnut

inner vine
#

classic misstake

inner vine
#

bruh

#

B R U H

formal scarab
#

@inner vine Looks like the first line of IsGrounded, but if you editor isn't telling you that you need to stop and fix that

inner vine
#

you'r*

abstract olive
#

@inner vine Don't spam this channel please.

inner vine
#

sorry

#

also

native fog
#

Hi guys,
I am making a 2D game just like Terrarian.
I see there are two options for player movement now

  1. Use kinematic Rigid Body and self-control player position
  2. Use dynamic Rigid Body
    What is the Pros and Cons of that?
dense saffron
#

Particles??

#

How

loud dawn
#

what am i supposed to do

nova remnant
#

I got this problem here... I make the white ball track the mouse by adding movement towards it, then the camera tracks the white ball. I also made the player(dynamic rigidbody) able to collide with the static wall. I want to make it so the white ball can crash against walls so people can't zoom past them, but it's already got a dynamic collider and it isnt colliding against the wall. However, it does crash against the player and can even move him around, which i definetevely do not want. How can I avoid this, while making it collide with walls?

still tendon
#

f(Input.GetButtonDown("Jump") i have this code, i wanna jump with W but i dont know how to make it

still tendon
graceful aspen
graceful aspen
graceful aspen
nova remnant
graceful aspen
#

oh

#

u are setting the position of crosshair to mouse position

#

not moving it towards it

#

does the crosshair have a rigidbody on it

nova remnant
#

wait uhh uhh

#

wtf

#

i fugd up

graceful aspen
#

lol

nova remnant
#

i thought i'd done that lol, i'll do it properly later

graceful aspen
#

give it a collider and a rigid body

#

set the rigid body to dynamic with 0 gravity

nova remnant
#

the crosshair does have a dynamic rigidbody with 0 gravity

snow willow
#

You'll have to start moving it with forces or at least setting velocity

graceful aspen
#

use rigidbody.moveposition

snow willow
#

Setting position directly will ignore physics

nova remnant
#

but anyways i think that explains why its not colliding, its mo-

#

yeah exactly what he said

#

i'd swear i set it to moveposition

#

but i only did that for the camera

rocky mirage
#

hello, i need help for a little problem (for you i think but big for me)
I make a system to save and load, But when i load my game after quit, The game load lvl but dont load music and my canvas with my deathcounter,settings button fadesystem and other thigs, how i can load this to ?

nova remnant
#

silly me

snow willow
#

Normally alot of those things would just be in your scene and not related to the save load system

rocky mirage
#

hum so if i make in any scene this , no problem ? but i use DontDestroyOnLoad, so when i make them on scene a have 2 time sound and other things

#

cause i didnt find other system for having my audio and my deathcounter on everyscene alltime, if i dont do that they reload at ever scene

lusty valley
#

im not sure if here is the place to ask- im a bit new here
but im trying to use cinemachine, but for some reason the camera keeps pulling wayyy back as you see in the ss
and i cant modify the camera either soo what am i doing wrong here?

#

ermmm anyone?

lusty valley
rocky mirage
#

let the time here to ppl read and wait like me ^_^

timber bramble
#

Question, how do i access IsMine in GridElement.cs using the coord?

#

from Populate.cs

rocky mirage
#

need instance i think

#

and you can use GridElement.instance.Ismine i think

timber bramble
rocky mirage
#

yea but you need to create a public

#

public GridElement instance ;

#

private void Awake()
{instance=this;}

timber bramble
#

within GridElement?

rocky mirage
#

and with that you can use instance on your script

#

in your GridElement script you need to create this instance

#

for using IsMIne on you other script

timber bramble
#

im having trouble understanding

#

both the reason for "instance" within a script, and the definition of instance

rocky mirage
#

hum. instance is used for take something on your script for other script

#

so if on your GridElement you creat this void for instance

#

you can use your IsMine on your script Populate.cs

timber bramble
#

does that mean, i have to create another class to take in xcoord & ycoord?

#

to return true or false?

rocky mirage
#

where is your "mineCheck"?

#

GridElement script?

#

ok so your mine check is on isCellMine

#

do you creat the void awake instance?

timber bramble
#

uh, no?

rocky mirage
#

you need it, if you dont create this public GridElement instance ; private void Awake() {instance=this;} you cant use your isMine

timber bramble
#

im getting more confused with the errors

rocky mirage
#

if you want to use something to your script GridElement on other script

#

you need to do GridElement.Instance.isMine for exemple

#

so you mineCheck is what?

#

you use mineCheck somewhere?

timber bramble
#

basically, it's a code to check the surrounding coord if there's any mines, if so, add 1 to the counter, and after double forloop is over, it will print out the total of mines into the cell

rocky mirage
#

and on your error can you show me the line Populate.mineCheck ?

timber bramble
#

ignore the first error

rocky mirage
#

and on GridElement.cs you have my private void awake instance=this; ?

timber bramble
#

oof

#

yea

#

was it meant to replace with something else?

rocky mirage
#

its instance not Instance

timber bramble
#

problem still remains the same

rocky mirage
#

btw did you link visual studio to unity ? you have lot of things on white and no error return

timber bramble
#

i did?

#

i opened the script from unity, and it just open the script on vs

#

or am i doing it the wrong way?

rocky mirage
#

and you quote mineCheck=gridElement

#

he dont know what is mineCheck

#

cause is quoted

#

mineCheck=gridElement.instance.isMine(row,col)

timber bramble
#

well, i didnt know which kind of code am i suppose to type, in order to get isMine from gridelement, so i typed it, and due to error, i quoted it, for at least i know where to work around with and from

rocky mirage
#

btw your if i think you dont need it, cause you make if its true=true, else false=false

#

after maybe my explication is really bad cause im not really good at english and not pro dev atm :/ so i hope other one can help you more than me.

#

jsut for me you need instance for using your isMine to your script for other script

timber bramble
#

honestly

#

i have absolutely no clue where in the hell am i trying to write this code, or what so ever, because my fking lecture wanted this code to be in this way

rocky mirage
#

i think you have prob with your minecheck

timber bramble
#

because in my brain, i have no idea how am i suppose to implement it

rocky mirage
#

ahah i know your feeling ^^

#

i have same problem atm ^^

timber bramble
#

and i need to complete it by tomorrow

#

and none of my mates even started it yet

rocky mirage
#

can yo usend me in private your script? i gonna see on my pc

#

if you want

timber bramble
#

uh,

#

sure?

timber bramble
#

anyone mind helping me out with stupid code? 😄

weak sinew
#

i created a new scene and i can still see the old scene?

#

do i have to add or remove something?

maiden karma
#

Can anyone help me set up player animation for a top down 2d game? I have all the sprites just need help with the technical aspect (inside unity)

weak sinew
weak sinew
#

or do I need to edit the camera or something?

rapid ibex
#

did you select the old scene after creating it?

weak sinew
#

no

#

@rapid ibex

#

Wait would moving the camera in the new scene work? That seems wrong though, cause then it would still be generating the old scene at the same time right?

rapid ibex
#

try just deleting the new scene and making another new scene to see if it fixes it. you can select the camera to see what the camera is showing on the bottom right to see if it's showing nothing in the game view like it should be or if its still showing whats in the old game. if worst comes to worst you can delete one item from the new scene and see if it affects anything in the old scene, if it doesn't affect anything in the old scene then just delete everything in the new scene

weak sinew
#

I haven't put anything in the new scene and I've tried all of the things. The new scene's camera displays the same thing as the old one's, execpt the bg color is different because I changed the old scenes bg color

abstract olive
#

Just to be clear, how are you creating this new scene?

weak sinew
#

oh

#

I made a new scene in the assets folder below, in my script folder

abstract olive
#

And how are you opening this new scene?

weak sinew
#

And then I grabbed it and dragged it up

abstract olive
#

Right, so this is a misunderstanding of scenes.

weak sinew
#

then I clicked on it and the camera bg color changed

abstract olive
#

Scenes are just containers for game objects. You can have multiple of them in the hierarchy.

#

If you want to edit a scene independently, just open it up from the project folder.

weak sinew
#

wdym?

#

the folder below?

abstract olive
#

Just double click the scene in your Project folder to open it up.

weak sinew
#

i don't think I have made a project folder

abstract olive
weak sinew
#

oh

abstract olive
#

It's where you've been dragging the scene out into the hierarchy. Instead of dragging it out, just double click to open.

weak sinew
#

k

#

I'll try it

abstract olive
#

If this is all new to you, you should consider doing some beginner tutorials. This is basic Unity workflow stuff.

weak sinew
#

lmao thanks

#

I was about to spend 20 years trying to figure it out

inner vine
#

theres a ; missing in this code idk where it is.

#

where is it?

warm flame
#

37

inner vine
#

why didnt it save when i save it?

#

last night

rapid ibex
#

I'm trying to get my character to be pulled toward a branch when near one and when he holds down the right mouse button. the check is to make sure he is in range of the trigger in order to use the ability, but the best thing that happens when I press the right mouse button when in range of the branch is that it teleports me back to spawn.

I'm mostly unsure how to make the tether pull me towards that specific branch in range and not towards one of the other branches that are set as a prefab.

snow willow
rapid ibex
#

im not sure how you would go about doing that, nor am I super clear on what you mean.

#

I feel like I understand what your saying but I'm unsure how to pass the location of that specific branch when entering the trigger zone. I was thinking having an empty game object in the center of the branch but I'm unsure how to pass the location of the nearest branch

inner vine
#

i lost sight of the play area what do i do?

rapid ibex
#

@inner vine click on camera

#

and press f

inner vine
#

thank you

rapid ibex
#

np

terse thorn
sonic abyss
#

Im confused???

#

btw playerphysics = rigidbody2d

snow willow
#

Look at what kind of parameter it requires

#

Compare that to what you are passing into it.

pseudo charm
#

the first field goes like (Vector2) forceDirection * (float) forceamount

snow willow
#

It can be any Vector2

#

But certainly not an int or float

sonic abyss
#

ok

coral dock
#

not sure what i did wrong

cinder valley
#

I need help finding where I went wrong with this code, I'm trying to make a shooting system

soft pike
#

@coral dock first line in Update(), UtilsClass.GetMouseWorldPosition, you need to add the namespace wheret the UtilsClass exist, or it might be your project is missing the UtilsClass script

coral dock
#

this is what i got

soft pike
#

can you post the UtilsClass, looking at the error in console, unity cannot find the UtilsClass, so either the namespace missing or the script itself

#

@cinder valley whats the error/issue you're trying to solve?

cinder valley
#

well... um... it shoots... but it just appears and immediately disappears

soft pike
#

okay makes sense, in your Bullet_script classs, FixedUpdate(), rb.velocity is being set every frame

#

and its not frame independent, you might want to multiply the movement with Time.fixedDeltaTime

cinder valley
#

in the FixedUpdate? I'll try it, thank you

soft pike
#

also give rb.MovePosition a try instead of rb.velocity

rocky mirage
#

hello, i have a prob when i load my game, i une script for checking doublon, everything works execpt my canvas ... he destroy it.

MissingReferenceException: The object of type 'Text' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

cinder valley
soft pike
#

can you post the complete log

cinder valley
#

the log?

soft pike
#

errors

cinder valley
#

ahh

soft pike
#

semicolon missing on line 12

cinder valley
soft pike
cinder valley
#

thank you

coral dock
#

what would i put for input if i wanted the animation to play when i hold down left click

#

right now its just click i cant hold

lilac folio
#

On keyboard input hold

#

wait

coral dock
#

how would i go about doing that

lilac folio
#

idk i use bolt

lean estuary
#

@lilac folio If you don't have answers, please don't spam the channels.

lilac folio
#

ok

lean estuary
#

@coral dock You can flip a bool on ButtonDown event and then wait for ButtonUp one to release it.

soft pike
#

@coral dock you can get the events with GetMouseButtonDown & GetMouseButtonUp, so between Down & Up, you know the player is holding

coral dock
#

like this?, sorry very new to coding

soft pike
#

you have duplicate checks, but yeah this should work

coral dock
#

also the second down i just corrected to Up

#

so ima test

soft pike
#

no that wont work, you can trigger your hold anim on Down, and stop the hold anim on Up, but make these 2 separate if checks

#

and ofcourse you can play your shoot anim on Down

coral dock
#

so the one i currently have will trigger it?

soft pike
#

yup thats right

coral dock
#

but as of rn when i click in game or hold it plays the animation once and wont loop it

#

im looking to loop the animation until i stop holding

lilac folio
#

try looping the animation and stopping it when you stop holding the mouse0

soft pike
#

yup, think you're using mecanim, it does have looping flag to enable

lean estuary
#

Additionally, if you want to make sure that animation loop finished playing, you can use animation event placed at the end of the clip timeline to check if it should flip looping state or just interrupting animation.

coral dock
#

how can i create a global float timer variable

soft pike
#

is this for setting the firing rate?

coral dock
#

i got it

#

what is this

soft pike
#

missing semicolon

native pelican
#

I'm building a game that looks like WhatsApp and I have added the functionality to pan and zoom images. I'm wondering how to add inertia to an image, so that when the players pans the image, the movement doesn't stop immediately as the player releases his finger from the screen but decelerates after the finger is released and slowly stops to move. How can I create this effect?

snow willow
native pelican
#

I've added a Rigidbody to the image game object and put this in my code:

if (Input.GetMouseButtonUp(0)){
    rb.velocity = direction * 2.5f * time.deltaTime;
}

It still doesn't work but I hope I'm going in the right direction...

woven lynx
#

hey how do i make animations more snappy? is it just a case of adjust the animation time or are there some settings i shouldf be using?

snow willow
snow willow
woven lynx
#

thanks it's just for punches with are two images.. it just seems when i attack it doesnt keep up with me if you know what i mean.. i'll try adjusting the animation then 🙂

#

is has exit time a thing for a retro pixel game? I dont think i need any smoothing between animations right? as it's just images

snow willow
#

It's a thing. That will determine how "cancelable" an animation is

grim coral
#

So I took a screenshot so u can see and im very new to any coding lol so it might not be right but I'm trying to get my player (red square) to fly (hit the roof) when I click space bar but it comes up with The referenced script on this behaviour (Game Object 'player') is missing! Any 1 know how to help

weak sinew
#

As the code you might have wrote could have been defining Player, instead of player

rocky mirage
#

i try many things but i always have my bug, he dont find my text and give me error on my script. btw when i dont load the game everythings works. just the load of games bug :/

stuck sorrel
#

oh I might understand the error. @grim coral

have you put/drag the script PixelMovement on your player?

#

it says "The referenced script on this Behaviour (Game Object 'player' is missing!". It is as the engine is saying your player don't have the script on it.

grim coral
#

I fixed it by changing the name but now it just moves constantly horizontal and down until it hits a spike

faint socket
#

anyone here know if they could help a fellow potato who does not know hot to code?

#

._.

stuck sorrel
#

Have you put a rigidbody and box collider for your game floor 2d?

stuck sorrel
#

In your code in update. You move the character at 2 different place at the same time.

#

This might cause some bug

undone shell
#

If anyone can help, I want to add a system where if my coinvalue equals a certain amount then an object would be destroyed

sly vessel
#

So i had this problem where my Vector3.Lerp is faster on a bigger screensize. I added divide by Screen.width to the Time.deltaTime counter. but it still doesnt seem to change the speed on a bigger screen. Im really lost atm and have been trying to fix this problem for hours

#

Ive debugged the screen widths and they are different.

rare lake
#

How would someone change their characters sprite, like if they transformed

snow willow
#

Or swap out the entire player prefab

craggy panther
#

I have a question that I can't seem to quite figure out. Lets say I have a starting point, city 1. When I place down city 2, I want a line renderer to be drawn between city 1 and city 2 dynamically. What would be a way to do this? If you could point me in the direction.

#

Right now I have a main city. I'm able to instantiate the smaller cities, just stuck on how to draw a line between them properly

snow willow
#
    line.SetVertexCount(2);
    line.SetPosition(0, city1.transform.position);
    line.SetPosition(1, city2.transform.position);```
#

assuming line is a LineRenderer

craggy panther
snow willow
#

You could do it either with one linerenderer per non-main city

#

or get a little more complicated adding a lot of vertices to a single LineRenderer

#

e.g.
maincity -> city1 -> maincity -> city2 -> maincity -> city3

craggy panther
#

Ah ok, I think the best "maybe" would be for each outlying to have its own.

snow willow
#

yeah that will be simplest

#

start with that

craggy panther
#

Ok thank you for the help!

snow willow
#

yeah

craggy panther
# snow willow yeah

Got it working, is there an api to call a texture for it? It creates a line without a texture bahaha

snow willow
#

you can put any material there you want

craggy panther
#

Correct, I'm talking about it doing that from code. I have the code creating the line renderer, but when it does it doesn't assign it a texture for some reason.

#

Wait I'm dumb, I can do a public materail.

snow willow
#

alternatively, put the LineRenderer on your prefab in the editor, just disabled

#

then you can freely configure it from the editor

#

and just enable the LR when you place the city

craggy panther
light roost
#

Hi! I am making a 2d platformer and I was playing arround with the classic mechanic of jumping ontop of an enemy to kill it. But I am having a problem. I have given my player the "player" tag and I have created an empty game object with a box collider as a children of the player with the tag "player feet". Then in my enemy I have added an OnCollisionEnter2D that checks if it has been hit by another collider with the tag "player" then do damage to the player, if it has been hit from a collider with the "player feet" tag then get destroyed. The problem is that it doesn't get destroyed. I have checked the tag (player feet), I have renamed it , i have put a diffrent tag but still it doesn't work. What am I doing wrong?

rustic stag
#

where to start learn unity scripting

snow willow
still tendon
#

i need help cause im little bid colort blind can get a piskel hex code of brown pls

#

is this brown?

snow willow
#

Looks red to me

still tendon
snow willow
#

definitely brown that one

white bronze
#

also i think this is a bad approach since the player feet could hit the side of the body

#

I think you should have the player feet but also a empty gameobject with a collider that is marked enemy head

#

then if the player feet touch the enemy head you can destroy it

still tendon
#

i got this error while sprite edit

still tendon
#

hello, im trying to make a bomb that destroys tilemap "objects"

#

Heres the code but i dont know why is it only destroying 1 tile, can i get some help?

left lotus
still tendon
#

yes vs is telling me

#

im tryign to use getcontacts but idk how

left lotus
#

I mean the idea of it. .contacts gets you the contact points of a single collision

#

It's probably not the sort of thing you want to use for colliding against many objects

still tendon
#

what sould i use?

#

raycast a circle and destroy the tiles inthere would work better?

left lotus
still tendon
#

ok im using collisions cause i wanted to push back other stuff but i need thrse object in tiles for the navmesh so im gonna try this thank u

left lotus
#

Gotcha, if you want to push stuff back, you can still apply forces to them after detecting them via the CircleCast

still tendon
#

but i would have to calculate a direction for each XD

left lotus
#

lol true

still tendon
#

but yeah

#

ty

left lotus
earnest wind
#

How could i compare two colliders so when they collide something happens?

#

Also the script is in neither the colliders, its in a overallcame controller

snow willow
#

You can use that Script to notify your game controller though

earnest wind
#

How can i do that?

snow willow
#

Call a function on your gane controller from inside OnCollisionEnter in a script on one of the colliding objects

earnest wind
#

Ok ill try it

floral flame
#

Assets/Yarisma.cs(31,20): error CS0178: Invalid rank specifier: expected ,' or ]'

#

Help pls

abstract olive
#

@floral flame Use a proper code sharing site like hatebin.com

snow willow
#

And then ignoring people who are helping you

abstract olive
#

Also don't crosspost in the future.

snow willow
split pasture
#

pls how to make controls like
A-->left
D-->right
Spacebar-->jump

abstract olive
#

What have you tried so far?

terse thorn
#

this is my problem, a especific bullet isnot dealing damage, while other bullets damage the player as normal, this problem is so confusing and some help will be awesome

code anchored to the player gameobject
https://pastebin.com/06bS1jwW

still tendon
#

Hi again

#

im trying to make a bomb that destroyes tiles

#

i tried checking the objects with collisions but dindt work then i got a sugestion to use a raycast instead

#

but just now i realized that the tile map obejacts are all under 1 collider

#

thats why it just destrying the first tile it collides with i guess but detecting all

#

how can i make this destroy all the tiles inside he raycast instead? without checking for collision just and offset in every direction?

silent breach
light roost
light roost
#

this is the part of my script that handles the collision with the player

snow willow
light roost
#

it fixed it. Thanks!

snow willow
#

I was only about 10% confident that was your issue haha

#

the problem is that collision.gameObject gives you the GameObject that the Rigidbody is attached to, which may be a parent of the actual collider

rocky mirage
#

hello, how i can load my canvas to all scene,.? i have a deathcounter on my canvas but i cant make him on DontDestroyOnLoad cause if i do that when i die, game crash cause he cant implement the death

still tendon
tame lake
#

I'm having some oddities with a 2D sprite animation looping that I don't want to loop. I've unchecked Loop Time on that animation, which seems like the most common cause of this, but it's not stopping my animation from looping. This is just a simple Unity animation with an animation controller. All my animation is doing is periodically changing which sprite is rendered in a sprite renderer.

#

Oh nevermind. I'm a dolt.

#

I forgot to disable "Can transition to self" for that state.

dark furnace
#

How would one go about accomplishing a Photoshop-style additive blend mode for a sprite in URP?

rocky mirage
split pasture
#

hey guys, im making a 2D game and when my player collides with ground which is higher, then it rotates, and i dont want that, please can someone help me?

#

pliz

potent iris
#

Can anyone help me with 2d Tilemaps

#

i have a procedural generated map and i just want to get a few chunks around the player loaded

split pasture
#

okay

potent iris
#

I´ll have a look

split pasture
#

okay

potent iris
#

click on your player > inspector>Rigidbody>freeze Rotation Z

#

maybe could do it

#

and i would change the line 19 from movement to movement.x

split pasture
#

okay thanks :)

#

ima beginner in c#

potent iris
#

can ask me if you need help

split pasture
#

oke, can i add you?

potent iris
#

yes

spice thistle
#

so i added a bullet to shot in my 2D game and its works perfect.

#

so now i want to add a animation fireball, so i added a fireball and copy the same things as i did in the bullet prefab and for some reason it dosent work right, the fireball Disappeared after less then a sec.