#πŸ’»β”ƒcode-beginner

1 messages Β· Page 427 of 1

round plover
#

yeah id di

#

i dont get it

#

omgh

#

nevermind

#

i see

#

i put a , after 500 lmao

cinder crag
#

oh my god , im dumb mb , now the error doesnt show up but the weapon gets destroyed

summer stump
#

Simply... don't

#

If you want to destroy the PREVIOUSLY held item, call destroy BEFORE instantiating and setting the new one

cinder crag
#

love you bro

round plover
#

can anyone help me via dm hjaving trouble w my project

cinder crag
#

now DoTween gives me warnings since im using it for my weapon rotation but it stops when i have a new weapon in hand but just in case how can i get rid of the warning

raw token
#

Most people won't commit to go into DMs and trying to answer a question they know nothing about, especially when they don't even know the scope or focus of the question. It's detrimental for all parties involved - the asker ends up with fewer eyeballs on the question and possibly with someone who can't solve their problem, or may lead them astray, and the answerer has no idea what they're getting into or what they're committing to. See also

rich adder
cinder crag
cinder crag
rich adder
round plover
summer stump
# round plover what the gyatt

You probably don't want to be moderated at this stage of your learning, so I recommend taking a minute to go do something else and be careful when coming back

eternal needle
rich adder
summer stump
round plover
#

okay my problem is my getkey command isnt working it does nothing

rich adder
#

isn't working ? what does that mean?

round plover
#

well im following a tutorial to get fimilar with unity and c# and just followed what the guy did and im having issues i feel maybe because the vid was 7 years ago

rich adder
#

what kind of issues? thats vague

summer stump
rich adder
#

what is supposed to happen vs what is happening instead

summer stump
#

You should maybe... show the code...

rich adder
#

& link tutorial too

mint remnant
#

you've added debug lines already right?

round plover
summer stump
#

You are adding force twice

#

And that should be upper case iirc

rich adder
#

def dont use time.deltaTime on addforce

#

thats why you had to crank it to 500

round plover
#

idk im just following the guy idk why it shoould be any different

rich adder
#

show tutorial. sounds like its a bad one lol

summer stump
round plover
#

In this video we learn to control our player!

● Download scripts, assets and project files for this course: http://devassets.com/assets/how-to-make-a-video-game/

● Developer Forum: http://forum.brackeys.com/

Difficulty of lesson: Novice.

Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·

This video is part ...

β–Ά Play video
#

its a8 min video

summer stump
#

Ah brackeys. Of course

radiant frigate
rich adder
#

what a surprise

raw token
#

oof - I didn't realize he was the source of some of that confusion πŸ˜…

round plover
#

womp womp rookie mistake?

rich adder
#

oh mygod he doesnt even use KeyCode

radiant frigate
#

lmao

rich adder
#

was it not available back then ? or just typical bad brackys

round plover
#

i just need help figuring it out

rich adder
#

dont follow this tutorial is bad

#

Time.deltaTime in Force while in fixedupdate is horrid

rich adder
#

if you want to learn unity properly start wiht !learn

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

radiant frigate
#

vector zero

summer stump
# round plover

Verified that lowercase d SHOULD work. Add some debugs as suggested

round plover
#

oh and also when i put my foward force to 200 so my cube rolls foward it doesnt do anything unless i put it aobve 300

radiant frigate
round plover
#

hard to explain for me

summer stump
eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

rich adder
#

thats why the numbers are ridiculously high

#

but if the cube is flipping you probably forgot to lock the rotation

round plover
#

yeah but i dont get why it isnt working the same as his?

raw token
# radiant frigate vector zero

Even when you apply the appropriate input? It sounds like that input action might be misconfigured... Maybe share a screenshot of the inspector for this script, and one of the configuration for the action?

summer stump
round plover
rich adder
radiant frigate
#

maybe its just a rookie mistake, but i did a movement system like 3 hours ago and it worked

summer stump
round plover
#

ah

#

but whjat do i add then

summer stump
#

But seriously, you keep ignoring this so I will keep saying it. Start over with a decent tutorial (like the one you were linked to)

summer stump
round plover
#

no i know i just removed it

round plover
summer stump
#

And would rather learn properly

round plover
#

i mean i alridy put 5 hours into this id hate to js quit

summer stump
#

Because doing it this way will take far longer

summer stump
cinder crag
summer stump
#

You will not lose your knowledge. And 5 hours is a tiny tiny tiny fraction of the time it will take for anything worthwhile

rich adder
round plover
#

okay

#

ill talk to him i guess

rich adder
raw token
radiant frigate
#

the unity tutorials on their page are actually goated

round plover
#

i mean ill wait since hes more fimilar then me with c# and unity and see what he says

summer stump
#

Or maybe he just didn't look at it before suggesting it. Might have been first google result

radiant frigate
round plover
radiant frigate
round plover
#

lol

summer stump
#

Ah makes sense. That is messed up of him

wanton kraken
#

in my game, i have a powerup that the player can collide with in order to gain. how can i sense the collision with the player, without the player momentarily being slowed down/stopped while the two collide?

round plover
#

i mean hes a busy guy so.

#

i really want to figuyre it out tho

radiant frigate
#

again, im lacking context but pretty sure thats what you want

wanton kraken
#

how do i implement that instead of oncollideenter?

radiant frigate
#

exactly the same but with OnTriggerEnter

#

and change the collider to trigger

wanton kraken
#

thank you! :)

rich adder
summer stump
# round plover i really want to figuyre it out tho

Well the issue is not with the code shown, other than the deltaTime issue we mentioned. So you would need to provide more information. Share ALL the code (not with screenshots)
!code

Show the inspector of the object with that script attached

eternal falconBOT
round plover
cinder crag
raw token
summer stump
round plover
#

wait whta

#

where rotation

rich adder
summer stump
#

I also do not see the script

round plover
#

yeah my bad

#

wheews rotation

#

wheres

summer stump
round plover
#

i dont see rotation

#

😭

rich adder
rich adder
summer stump
round plover
#

do i check all the boxes?

summer stump
round plover
#

didnt

#

lol

#

its literllymnot moving

summer stump
#

We said "freeze rotation" and that is the only place those words are shown in that screenshot

round plover
rich adder
#

and why is time.delta time still there..

round plover
rich adder
#

I said rotation

#

never said position

raw token
# radiant frigate they dont

Okay cool. You could enable the specific action with

movementReference.action.Enable();

if necessary. Enabling the whole action map varies depending on how your Input System is configured, but if you're using the global workflow, it'd be like... uhh...

round plover
#

misclicke

cinder crag
summer stump
round plover
#

when i set my foward force to 200 it never moves

round plover
cinder crag
# rich adder nicee

also i wanna hear ur thoughts , what if chargeable bow that deals damage based on how long you held ur charge button or smth like that

summer stump
cinder crag
summer stump
#

And it had a syntax error that you SAID you removed, but apparantly did not

cinder crag
raw token
round plover
rich adder
rich adder
summer stump
radiant frigate
#

i dont know why now i need to do it tho, literally have the last player controller that i had on my other screen and it didnt need to be activated

rich adder
#

!screenshots

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

round plover
#

πŸ˜‚

#

wdym sent it then

#

send

#

oh copy n paste

summer stump
round plover
#

πŸ˜‚

#

then idk

rich adder
#

if you aren't willing to properly help yourself to get helped, you're just gonna get a mod on you

round plover
#

what you mean

raw token
rich adder
#

this is a waste of everyones time. Put some effort

cinder crag
#

also since i alr have a WeaponShooting script that handles all the weapon shooting stuff , if i wanna make the chargeable bow , do i replace the WeaponShooting with the new BowShooting script and then reference the WeaponShooting in the BowShooting script?

round plover
summer stump
#

I linked you to how to share code three times @round plover

#

!code

eternal falconBOT
summer stump
#

Look at "large code blocks"

round plover
#

kk

summer stump
#

And also ffs remove the syntax error you said you took out
On line 16
Also remove deltaTime from line 20

round plover
#

how does that work i copy n past my code into whjat u sent me

rich adder
#

its not complex

round plover
#

ok

raw token
round plover
#

okay i clicked enter

#

what now

rich adder
cinder crag
rich adder
#

cause ill jst get mod on you

round plover
#

oh okay

rich adder
cinder crag
#

also u still didnt delete that syntax

#

delete/remove

summer stump
rich adder
#

why are you sending code with synax errors

cinder crag
summer stump
#

How can you say ik and still send it

round plover
#

this cant be real okay

#

idk

rich adder
#

are you 12 ? what is happening

round plover
#

whaty ou emkan by remove delta time though

summer stump
#

Send the most current code including all changes you have been told to

round plover
#

idk what you mean*

summer stump
rich adder
#

Time.deltaTime its an entire thing

#

remove it

#

all

round plover
#

ohh

#

kk

rich adder
#

and lowerr the speeds

#

they should be 10 times less

cinder crag
summer stump
round plover
#

is this fine

#

ill send link

summer stump
#

Do you see the red underline?!

rich adder
round plover
rich adder
#

its not fine

summer stump
#

I think I am going to have to block you and leave. I wish you the best lano

round plover
#

yeah i know i didnt notice

#

fixed it

cinder crag
rich adder
#

dont do something without knowing why you are doing it

round plover
#

im just annoyed why it isnt working like the tut is telling me

rich adder
#

well we told you its a bad tutorial

round plover
#

okay but how if it works fine for him?

rich adder
#

again its wrong

#

prove to me that now it doesn't work with this new code

#

and lower the speed

round plover
#

wheres the error smh

rich adder
summer stump
round plover
#

oh you said there was okok

#

nvm then

velvet mango
#

How would i go about checking if a function has been just called for an if statement in another script

summer stump
#

Nah actually, inb4 "it is so fast"
Because ignoring 90% of what we say seems the norm here

summer stump
round plover
#

i ran it and my foward force is crazy high even if its still at 200

#

idk what i did jow

#

now

rich adder
rich adder
round plover
#

what should i change it to then

rich adder
#

what do you think..
its trial and error, not that difficult

round plover
#

okay

cinder crag
rich adder
round plover
#

its still crazy fast

rich adder
#

then obviously 200 is too high?

#

use your brain for a moment

round plover
#

2000 was high and 200 was slow sooo idk

#

okay then

cinder crag
rich adder
#

which was wrong

round plover
#

ohhhhhhhhhhhhhhhhhh

rich adder
#

thats why he cranked up

#

cause its wrong

round plover
#

i see

#

also i changed this

rich adder
#

Physics objects already move on their fixed Update

cinder crag
round plover
rich adder
round plover
#

should i keep it at 2000

#

or leave it as it is

#

it was 2000f before

rich adder
#

to compensate for "charge time" and whatnot (timer)

tight owl
#

I restarted it because it arrived after 15 minutes, it gets stuck there, why doesn't it load?

rich adder
#

thats why we have Serialized in the inspector so they can be adjusted, also while playing to figure out th eproper numbers

rich adder
round plover
cinder crag
rich adder
round plover
#

ah opkay

#

okay

rich adder
cinder crag
rich adder
#

ig depends where you are storing that info

cinder crag
#

also i dont want the other guns to be able to charge so how can i check if its the bow ?

rich adder
round plover
#

navarone my getkey command isnt working

velvet mango
#

my problem is i have a function that it is essentially i have the function im trying to check has a string name (example 1) and in the if statement im trying to actually check for a specific string name (Example 2)

public void Function(string name)

if (script.instance.Function("nameofthing"))

how would you go about it?

round plover
#

can u see if theres a problem

cinder crag
rich adder
cinder crag
rich adder
#

but yeah that works

cinder crag
summer stump
rich adder
#

except you use " not '

cinder crag
#

time to stay all night working on this

rich adder
#

' is for chars

cinder crag
round plover
#

iput deltatime because i wanteds the force value i put in to represent the force per second

rich adder
rich adder
round plover
#

also the getkode didnt work

cinder crag
round plover
#

its not moving at all

rich adder
#

send it the proper way as shown to you earlier

round plover
cinder crag
#

wtf

cinder crag
rich adder
cinder crag
#

oh wait "im stupid"

round plover
cinder crag
#

thought `` was the same as "

round plover
#

and so forth yk what im trying to do

rich adder
rich adder
#

i know what ur trying to do

#

I asked you if its moving forward

round plover
#

oh yeah

#

when i press d nthg happens

rich adder
#

ok can you show the inspector for the object

round plover
#

ok

#

its for the red cube

ivory bobcat
#

Also, don't acquire input in the fixed update method

rich adder
#

this might be part of it too ^

ivory bobcat
#

Acquire it in Update as some bool and use the bool in fixed update

rich adder
#

though since its GetKey and not KeyDown it should work fine

#

since it doesn't apply the force till fixedupdate frame anyway

round plover
ivory bobcat
#

Ideally, yes - relative to key held

rich adder
round plover
#

while i ran it

#

yes it changes

ivory bobcat
#

So the object does move

round plover
#

i mean yeah its moving foward

#

lol

ivory bobcat
#

Are you perhaps moving the floor as well?

round plover
#

nope

ivory bobcat
#

Forward in the standard position would be the z axis - I'm assuming your object's forward is in the standard position.

round plover
#

so why is my getkey working

#

solution?

rich adder
#

if it moved its working

ivory bobcat
#

Put a log and see if it prints

round plover
#

yeha not lol

round plover
#

can u type it

#

so i can copy n paste

#

or do it to my getkey statement

round plover
#

wdym put a log

summer stump
round plover
#

i did

summer stump
round plover
#

ok i will do that

summer stump
#

If you do that, you should absolutely know what a log is

#

Oh my god, you actually didn't? I was joking by suggesting you click it. I assumed you would have tried that already

round plover
#

huh

#

im so lost

#

idfreakin know wym by log

raw token
#

Spoonfeeding, on sympathy for their early juncture in the learning experience.

It prints a message to the console. So if you put it in your if statement's body and it logs a message, you know that execution has reached the statement body, and thus that the condition was true:

if (Input.GetKey(KeyCode.D))
{
    Debug.Log("D key was down during FixedUpdate");
    rb.AddForce(500, 0, 0);
}
round plover
#

yeah ik that but i js didnt know where u guys weanted me to writ it lol

summer stump
# round plover idfreakin know wym by log

For perhaps the fifth time, you need to IMMEDIATELY stop what you are doing
You need to do some very very basic courses (preferably not on youtube). This is quite ridiculous

summer stump
ivory bobcat
#

I just wanted to see if the code was executing.

round plover
summer stump
eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

ivory bobcat
#

Check your console logs

summer stump
#

How many times have you been told no screenshots

round plover
#

@ivory bobcat

#

wont letr me run it

summer stump
ivory bobcat
# round plover

I'm assuming you aren't aware of what the console window is

round plover
#

i am

rich adder
round plover
#

becuase i ran it first

summer stump
#

Show the whole thing, not cropped

rich adder
round plover
rocky canyon
#

i belive he has

rich adder
#

ohits collapsed ofc

round plover
#

ya

rich adder
#

gg

summer stump
#

Errors are hidden

void thicket
#

lul

round plover
rich adder
#

amazing , how did you manage to do that

summer stump
rocky canyon
#

click the stop sign icon

raw token
rocky canyon
#

yu've gotten ur errors disabled

void thicket
#

I only want warnings no errors 😠

rich adder
#

ima laugh if its still broken from * Time.

round plover
eternal needle
#

It's a miracle you guys are even helping still

summer stump
#

Just for the sixth time, but in a different way. You would probably be FURTHER in your project if you had restarted and followed the guide I linked when I first sent it

rocky canyon
#

i just peeked in

rich adder
round plover
#

alright whatever ill just dropp unity isnt for me lol to confusing

raw token
# round plover

I suspect you pasted what I wrote into the class body, instead of adding the Debug.Log to your existing if statement in the FixedUpdate() method.

But yeah, if you do want to pick up a higher quality tutorial, the Junior Programmer Pathway on Unity Learn is a good start

rich adder
#

how would you follow a movie from the middle of the story or beginning ?

ivory bobcat
round plover
#

C# is new to me im only familiar with python 🀣

eternal needle
rich adder
eternal needle
#

Even if you were familiar with python, some skills would translate. But you dont even seem to be aware what debugging is. Start from the absolute beginning

round plover
#

little

rich adder
summer stump
# round plover eh its a bit diff for me

I started with python and moved to c#

You know how I did that? It wasn't by jumping into an intermediate tutorial and demanding help on every sub-step and issue along the way.

I took basics courses.

Unity is one of the simpler game engines. If you are giving up on it as too confusing, don't think anything else is going to be LESS confusing.

You need to actually try. Trying means doing the basics, which Nav just linked (which is what, the eighth time it was linked?).

#

But if you wanna stick with python and use a slightly more confusing engine, check out pygame

round plover
#

yeah im only doing this because i was put on to learn wich i am going to be creating a demo for someone and obv im getting run trhough it all i needed to do was copy exactly what brackeys did but apperantly it doesnt even work

summer stump
#

But it is too hard to even find out what because it is like nails on a chalkboard trying to get any info from you

#

I did remove the deltaTime and fix the force, but it did work before that too

round plover
#

you at

summer stump
#

I finished it

round plover
#

what the

#

u did exacltyt how he did it?

#

exactly

eternal needle
#

brackeys tutorials are shit but they do work for the purpose of the demonstrations. His video wouldnt be popular if they were filled with actual compile errors
I did the same tutorial years ago, you really just arent copying properly

summer stump
#

I did remove the deltaTime and fix the force, but it did work before that too

#

I made that change at like three quarters of the way through because I just couldn't handle that haha

mint remnant
#

his tower defense tutorial I thought was pretty cool

round plover
#

so should i restart the turoial

#

all im doing is copying

summer stump
#

Do !learn

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

eternal needle
#

πŸ€·β€β™‚οΈ consider that you also refused to read the initial messages any of us sent (which is why i stepped away from helping). Its doubtful that you're even looking at the tutorial properly. its clear you're trying to copy as fast as you can, in which case youve taken a 1 hour process and turned it into a several hour struggle

raw token
mint remnant
#

if you insist on youtube vids, go find Sebastion Lague's

summer stump
#

Sebastian is a bit too advanced for them imo. ("A bit" being QUITE generous)

round plover
rich adder
#

seb is more like Devlogs to learn from

#

not really a beginner tutorials

summer stump
mint remnant
#

fair enough, but he does good clean code

eternal needle
summer stump
#

We try not to spoonfeed

round plover
#

i only just pciked up c# since the morning

summer stump
rich adder
summer stump
#

Dabba table!

rocky canyon
#

(β•―Β°β–‘Β°)β•―οΈ΅ ┻━┻

raw token
#

debebtababble

rich adder
#

debabby

wanton kraken
#

can anyone tell me why this method isn't properly using float RaycastDistance or stopping when it should stop?

                case KeyCode.W:
                    Vector2 RaycastDirection = transform.rotation * Vector2.up;
                    RaycastHit2D forward = Physics2D.Raycast(transform.position, RaycastDirection, RaycastDistance, BulletMask);
                    Debug.DrawRay(transform.position, RaycastDirection, Color.green, RaycastDistance);
                    MoveCheck(forward, PlayerRB, Speed, true);
                    break;
///
    private void MoveCheck(RaycastHit2D hit, Rigidbody2D PlayerRB, int Speed, bool Forward)
    {
        if(Forward == true && (hit.collider == null))
        {
            PlayerRB.AddRelativeForce(Vector3.up * Speed);
        }

        if(Forward == false && (hit.collider == null))
        {
            PlayerRB.AddRelativeForce(Vector3.down * Speed);
        }
    }
teal viper
wanton kraken
#

sorry?

summer stump
#

That parameter is duration (in time), not distance

rich adder
summer stump
#

In drawray

upper tide
#

Someone mentinoed that Debug.log had something to do with varargs, can someone explain what this means?

wanton kraken
raw token
upper tide
wanton kraken
wanton kraken
#

oh, i see

#

well that's probably the issue

upper tide
#

which I have no clue of

teal viper
rich adder
wanton kraken
#

then how do i set it's distance?

summer stump
teal viper
summer stump
#

Direction (a vector3) has a magnitude

raw token
summer stump
upper tide
#

okok so this is just misinformation I've gotten

#

thanks for looking guys

silent tree
#

im very new to unity and i just followed a tutorial completely with the entire game working, but when i go to build the game and run it, it just loads an older version and doesnt work properly? does anyone know any common fixes? let me know if theres any extra info i can provide.

silent tree
#

i saved the game before building and it didnt change

teal viper
wanton kraken
#

welp, i understand the raycasts a bit better, but it's still moving when it shouldn't be.. hmm

silent tree
rich adder
#

3 seconds for a build sounds sus

silent tree
#

its a very simple game

rich adder
#

did you make sure you did a Clean Build?

silent tree
#

whats that? like make a blank game and build it?

rich adder
#

there is a dropdown arrow on the Build button

#

click it

teal viper
# silent tree
  1. Make sure that the scene that you work on is included and loaded first.
silent tree
#

like in the top left here?

wanton kraken
rich adder
summer stump
silent tree
#

i only have one scene so yeah i think

rich adder
weak isle
#

how do i exclude certain gameobjects to be found by findobjectsoftype. im searching for cameras but i want it to ignore itself

silent tree
#

ok got it

wanton kraken
rich adder
silent tree
rich adder
#

in comparison to editor

silent tree
#

it wont detect any input, and i changed the background color to test if it is the same in both versions but it is still the old color

#

i have code that when i click or press space it should fly which works in the editor, like in flappy bird, but in the build it just doesn't move

summer stump
silent tree
#

is there any way to screen record? would that help?

rich adder
#

yes use OBS or ShareX or Windows + G

wanton kraken
summer stump
wanton kraken
#

ah, okay

summer stump
#

What should it be hitting? And what layer is that thing on? Does the layermask INCLUDE that layer

#

Masks are for what it SHOULD hit

wanton kraken
#

the mask is inverted, though

summer stump
#

Ah, so anything that is NOT the player? But it is not registering any of that

wanton kraken
#

it should just be colliding with walls, really. so obstacles. i could uninvert the mask and set it to obstacles

raw token
summer stump
#

I would first of all put in a debug.log including the name of what it should hit

wanton kraken
summer stump
wanton kraken
#

yep, doing that now to see if it helps

silent tree
#

oh it didnt capture the other part hold on one sec

wanton kraken
#

yep, fixing the mask seems to have fixed it. thanks!

rich adder
silent tree
#

oh sweet

rich adder
#

remember when we asked if you're exporting the correct scene?

silent tree
#

yea

rich adder
silent tree
#

oh is it because i changed the name?

rich adder
#

or save As

silent tree
#

oh i figured it out

#

i had to add open scenes

rich adder
#

yes

silent tree
#

i saved as im fairly sure

rich adder
#

or you can drag n drop

#

when you do that(SaveAs) it created a new Scene asset

#

so you just never added it to the build but instead the old one is still there

silent tree
#

i really appreciate it. ill try to keep this in mind next time lmao

ashen sonnet
#

fellas im trying to draw a boxcast for something and im a very beginner to boxcasts entirley, (2d game) and it would be nice to have some help of how to write them and especially how to know where they are/ if ive done it correctly... is there a way to see them ingame?

ashen sonnet
teal viper
teal viper
#

That's just a lazy excuse. !learn properly and you'll figure it out.

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

teal viper
#

If you stumble on an issue while learning feel free to ask the community. But don't ask people to provide you a complete and ready solution. Show some effort.

ashen sonnet
teal viper
#

Well, then consider drawing gizmos as part of learning about box casts. Then it's fine, is it not?

ashen sonnet
#

i guess, it looks complicated tho

#

ig ill never know till i try

teal viper
#

It will look so if you miss some more basic understanding, that you'll need for the boxcast as well. So maybe step back and start with the basics first.

ashen sonnet
#

ive just avoided most things gui cuz it looks like a completley different language
probably not the best thing but i'd rather get the fundamentals of the rest done first

teal viper
ashen sonnet
teal viper
#

If you can't do that, better follow a structured learning course.

ashen sonnet
teal viper
#

Even simple things like ground detection can be pretty complex if you are missing some of prerequisite knowledge. There are many ways to detect ground and box casting is one of them.
If you really want to learn about casts then maybe start with a Raycast, as it's easier to visualize and understand in general. A box cast is just a more sophisticated raycast.

#

A raycastyou can visualize with Debug.DrawRay

ashen sonnet
#

i guess

silver moon
#

Personally if I'm just looking for an easy check I'll just use a debug.log along with a message (you can even print out the item(s) you hit). Then if I'm not getting what I'm expecting back I'll dive deeper into drawing the gizmos. There is an add-on on the unity store which adds a few more easy to use debug.draw extensions, which you may find easier than gizmos (though gizmos are not hard at all, trust. Can be intimidating) https://assetstore.unity.com/packages/tools/debug-drawing-extension-11396#reviews

Get the Debug Drawing Extension package from Arkham Interactive and speed up your game development process. Find this & other Tools options on the Unity Asset Store.

ashen sonnet
#

which, by the way, how would i detect when the player is ON the ground, cuz say the box cast was on like a pixel down, you'd be able to jump higher if you jump exactly as you land right?
maybe i should just use a collision detector for ground detection and use my new found "knolege" of boxcasts for other stuff (i would assume it also transfers to raycasts atleast a bit)

silver moon
#

That depends on the size of your boxcast, so not necessarily.

Yeah there's a few ways to do it. Could certainly use OnCollosionEnter, boxcast is probably the way I'd go but you could also have a child object with your box collider on it, position where you want, set it to trigger and create a new script that uses OnTriggerEnter to detect the ground. And in this case you'd be able to easily see the ground detect box in editor because it's just a box collider component. This video explains this (and boxcast) method better. Trigger method is at the end https://youtu.be/c3iEl5AwUF8?si=0tz5SPYcLn49Krms

βœ… Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=c3iEl5AwUF8
Let's look at 3 different methods for doing a Ground Check which is a necessity if you're making a Platformer.

If you have any questions post them in the comments and I'll do my best to answer them.

πŸ”” Subscribe for more Unity Tutorials https://www.yout...

β–Ά Play video
devout flower
#

!ide

eternal falconBOT
quick fractal
#

Probably a very basic question, do static bools act like switches you can flip from other classes? I'm thinking about hugely simplifying 90% of my code using it

teal viper
quick fractal
#

Oh?

teal viper
#

In general, if you you're thinking of static fields it's usually a bad idea.

#

There are some exceptions.

#

If you're a beginner thinking of static fields, 99% it's a bad idea. Especially if it's to "simplify code"

summer stump
#

Simplifying the code that way is gonna make everything else subtly harder and harder over time until you gridlock. At least that was my experience when I had the same idea years ago haha

quick fractal
#

And allow me to access functions that loop once per frame, which is far more useful than I imagined

#

Coroutines are fine and making an event for it is ok but having it in Update is so much nicer

teal viper
quick fractal
#

Why exactly shouldn't I use them?

teal viper
#

It's a bad habit. If you start using them as a beginner, you'll keep on using them in a more complex project which would bring a lot of issues. But you wouldn't know the proper way of doing it.
Imagine you have more than one character with skills in a game for example.

glass prawn
#

I got an error on my code while trying to do something, could someone help me figure out how to fix it

quick fractal
summer stump
#

Can't help without knowing the error or seeing the code of course

glass prawn
#

I have this error in my console

summer stump
#

Ok, show that code

quick fractal
#

Someone did just fill me in on a little thing called creature.HasSkill(""); which will be far better anyway

glass prawn
#

do you see what could be causing the error

void thicket
glass prawn
#

how is it containing null?

void thicket
#

How do I know

#

I don't know how you are making that enumerable

glass prawn
void thicket
#

Not that

#

TowersInGame

glass prawn
void thicket
#

That does not show any value getting added

glass prawn
#

this is the only other place its referencesd

void thicket
glass prawn
#

how do I prevent it from turning null?

void thicket
#

Make sure it has the component you are querying

glass prawn
#

I think it does, how can I make sure

void thicket
#

Logging, breakpoint, whatever way you can debug

glass prawn
#

I think I just forgot to put the script on the prefab, only the tower originally

summer stump
#

And got that error?

glass prawn
#

i think it was trying to get me to fix this line because I removed it because for some reason it causes an error with enemy spawning

#

when I remove it enemies spawn but it returns the original error I had above

summer stump
#

The line numbers are cropped out here

glass prawn
summer stump
#

Oh, and the script is the wrong one. The error is line 24 of TowerTargeting

glass prawn
#

here is tower targeting line 24

summer stump
#

Wait... new float?

#

There is some odd stuff going on here

glass prawn
#

what do you mean

summer stump
#

Line 37 of GameLoopManager

glass prawn
#

whats wrong with it? I'm pretty new to unity api so I dont see the problems very easily

void thicket
#

You are creating NodeDistances based on NodeDistances.Length ?

summer stump
#

I'm just confused. You are making a new float array that is one shorter than the previous?

#

But also, it is likely emptied at that point? I would need to test. Not sure looks like that is the point

void thicket
#

Recursive definition

#

I assume it should be based on NodePositions.Length instead

summer stump
#

Ahhh, yes that does make more sense

glass prawn
#

so should I change it to NodePositions = new float[NodePositions.Length+1];

void thicket
#

Why it suddenly become +

#

πŸ‘€

summer stump
#

Why +1 now? And shouldn't it be NodeDistances = NodePositions (you changed both sides)

glass prawn
#

misclick sorry

void thicket
glass prawn
#

not really, I usually look at others peoples code until I understand the arguments and can write it myself, thats how I learned C# modding, but I havent used it much in unity context so its still confusing to me

#

They spawn now, but I get this error when I put down a tower

glass prawn
#

jobs

summer stump
glass prawn
#

okay

summer stump
glass prawn
summer stump
# glass prawn why

Well nativeArrays only really make sense in the two contexts I mentioned (and other custom reasons, but not just general unity usage)

#

Unmanaged code vs managed code

glass prawn
#

when I removed the one I got

raw token
# glass prawn when I removed the one I got

Your loop iterates until i == NodeDistances.Length - 1, but inside the loop you're accessing NodePositions[i + 1], which will be the element after the last element in the array on the final iteration

raw token
# glass prawn How can I fix that?

Presumably, stop your iteration at NodeDistances.Length - 2 - since you need two points to calculate a distance, you will have one less distance than you have points. But the solution may vary - I don't really follow what's going on in this code 😁

#

Like maybe you need an equal number of distances and the final one should instead be the distance between the first and last point

glass prawn
#

I changed it to 2 and got this

raw token
#

What's happening around that line?

glass prawn
#

which line

void thicket
#

original - 1 is fine

#

You'd want distance between nodes then it is natural to have one less element

raw token
# glass prawn which line

The line responsible for the error - TowerTargeting.cs:67

But apply the fix cathei mentions and see if the error persists, first. Add the - 1 back to the NodeDistances initializer

glass prawn
#

line 67

radiant frigate
#

how could i make a variable that changes depending on what iteration i am inside a for loop, between certain numbers that i want, and how can i calculate how to rotate an object depending on what direction the objective if respecting the position? (further context in photos)

#

srry for the bad explanation but idk other way of telling what the problem is

#

i want to make a triple missile that goes towards the player, how do i get the degrees i need to set it for?

#

ive been thinking about switch case but i still dont know how to calculate the 3 directions i need

raw token
hollow zenith
#

Hey, is there a shortcut for this:

 DamageText.transform.position = new Vector3(DamageText.transform.position.x, DamageText.transform.position.y + speed*Time.deltaTime, DamageText.transform.position.z);
raw token
# glass prawn is that bad

It's what the runtime is complaining about, so yes. Accessing any index of a 0-length array will throw an error, as will attempting to access the index -1 on any array

hollow zenith
#

oh found this:

transform.position = transform.position + new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
#

To Answer my question:

DamageText.transform.position += new Vector3(0, 1, 0);
void thicket
hollow zenith
#

I assume Vector3.up is same as Vector3(0, 1, 0);

raw token
# glass prawn what should I do with it

I guess you might return null early if EnemiesToCalculate is empty. That may or may not address the other issue with EnemiesToIndex[0] being -1 - I don't know how that's calculated

languid spire
raw token
wary sonnet
#

!help

#

!cmd

raw token
# radiant frigate how could i make a variable that changes depending on what iteration i am inside...

Subtracting the launcher's position from the target's position will give you a vector which describes the distance and direction to the target. You can apply the rotation described with a quaternion to a vector by multiplying the quaternion with the vector - so if I did something like

Vector3 direction = Quaternion.Euler(0f, 30f, 0f) * directionToTarget;

now direction is 30 degrees offset from pointing at the target on the y axis.

You might store different rotations (maybe quaternions, maybe just floats for one axis) in a list or an array, and loop through it to produce directions for each projectile

wary sonnet
#

!docs

eternal falconBOT
toxic frigate
#

hello all, can someone tell me how something like this is possible? i am stumped (sorry if this is a stupid question with a stupid answer it is midnight currently)

#

the string is not changed at all, the first screenshot is taken while the game is running

raw token
radiant frigate
#

but now the last one is the one that is exactly on the player and not the one in the middle

sand epoch
#

help request

I have searched long and far for a working method to do a very simple action.
I have a 3D project with a camera for a player. All I want to do is for it to rotate right when you press the right arrow, and vise versa for the left. I want to be able to control the speed of this, as well.

I do not want acceleration or deceleration, which all the examples i've seen do.

#

Something similar to DOOM (1993) camera movement

radiant frigate
winter tinsel
raw token
sand epoch
radiant frigate
#

now im trying to change it to degrees instead of radians

#

btw love the pfp

sand epoch
languid spire
sand epoch
#

I'll work up something quick to have as reference.

languid spire
sand epoch
#

This is effectively what I want to happen, but getting it to do so has proven difficult

languid spire
#

look at the link i posted

sand epoch
languid spire
#

multiply your cameraspeed by deltatime

sand epoch
#

Thankyouuuu

#

It works

radiant frigate
#

how can i calculate the rotation i need to give in the z axis to an object at the time of instantiating it, taking into acount that it should go to the direction of the "player" originating from the "enemy"(gameobject instantiating the "bullet")

#

ive tried a lot of weird math and i cant make it happen

winter tinsel
#

are you in 2d or 2d

#

3d*

radiant frigate
#

2d

winter tinsel
#

ah

radiant frigate
#

!code

eternal falconBOT
radiant frigate
winter tinsel
#

what i did was just

radiant frigate
#

that is the code for rotating it

winter tinsel
#

is it looking up when it spawns in?

#

the bullet

radiant frigate
#

the transform.up shouldnt be modified

#

if thats what you are asking for

winter tinsel
#

why not

radiant frigate
#

wait

#

it is

#

its currently 09:45 am and i havent slept srry if i dont grab things in an instant

#

sleep depravation hitting me hard currently

winter tinsel
#

then go to sleep

radiant frigate
#

it is indeed being modified

winter tinsel
#

pick this up after a nap dude

#

seriously

radiant frigate
#

i woke up at like 8pm

#

so ive only been awake for 14 hours

#

just that i get sleepy at this time of the day

#

lmao

winter tinsel
#

i encourage you to take a nap

radiant frigate
#

i aprecciate it but im to stubborn to leave it uncompleted

winter tinsel
#

you wont leave it uncompleted

#

youll just complete it

#

later

#

in an hour

#

or smthin

radiant frigate
#

i know what you mean

#

but i cant leave until i finish this

#

im to stubborn, ik i should take a rest because it will help me view it from other pov and think laterally but i have that negative trait

#

take some rest*

winter tinsel
#

so work on the negative trait

radiant frigate
#

i should

winter tinsel
#

take the nap dude, its worth it

#

besides

radiant frigate
#

ik its worth it

winter tinsel
#

your computer wont run away

radiant frigate
#

lmao

winter tinsel
#

take a nap and pick this up later

radiant frigate
#

i would love to

#

but i wont be able to fall asleep

winter tinsel
#

aha okay well

#

i was going to suggetst

#

transform.up = target.transform.position - transform.position

radiant frigate
#

ohhhh

winter tinsel
#

and make the target equal whatever you want to point at

#

in my code

#

target = gameobject.findwithtag("ship")

radiant frigate
#

yeah but my problem is that i want additions,

#

i want there to be 2 more that are slightly offset

#

therefore i think i need degrees and/or radians

winter tinsel
#

i dont know how to do this in code as i am very new myself

#

the way id do it is just make 3 different projectiles, make them all instantiate from one spot

#

and each one has the same code just offset by -30 or 30

radiant frigate
#

exactly

winter tinsel
#

thats the long way around but i believe theres a better way to do it

radiant frigate
#

thats my thought proccess

winter tinsel
#

so do taht

radiant frigate
#

but i dont know how to write it in code neither

#

lmao

#

since it is also in a for loop

winter tinsel
#

why a for loop

radiant frigate
#

because i want to instantiate 3 bullets simultaniously

modest dust
#

And look up rotating vectors online to get the other 2

winter tinsel
radiant frigate
modest dust
#

Nope

#

lemme search for it

stiff birch
radiant frigate
#

oh

#

ill try that

radiant frigate
#

another time caesar coming in handy

stiff birch
#

(assuming you're in 2d)

radiant frigate
modest dust
radiant frigate
#

oh no... my biggest enemy, letters

#

πŸ’€

#

kewk

eternal needle
#

Unity directly has methods for rotating vectors, also Vector * Quaternion will rotate it.
You really dont need any trig

radiant frigate
#

but the instantiate method asks for a quaternion

raw token
eternal needle
night raptor
radiant frigate
#

im scared of quaternions

#

tried to understand them once

#

was not a pleasing experience

eternal needle
night raptor
#

true

radiant frigate
#

it wouldnt matter since its a multiplication right?

#

or am i delusional right now?

raw token
#

It's an overloaded operator - it's not actually multiplication. Just a fancy function call dressed up as if it were

night raptor
#

for matrices and quaternions the order matters

eternal needle
night raptor
radiant frigate
#

not only that but how it works

night raptor
#

You kinda shouldn't, I know neither and I can use Quaternions to my advantage

eternal needle
#

For quaternions, you truly dont need to know much. Just know how to construct them from values u are familiar with, euler. Then rotating them with multiplication

radiant frigate
#

so i can just quaternion.euler(x,y,z)?

night raptor
#

knowing the multiplication operations and the utility methods provided by unity is all you need in 99.9% of the cases

radiant frigate
#

okay

#

ty!

#

ill try to make the code now

#

lets see if i can make it happen

night raptor
radiant frigate
#

okay

atomic holly
#

Hi !
I develop the system of NPC shop where the player can buy some weapons. Now, I have this UI but I want to highlight what weapon button is selected with changes his opacity compared to the others. The arrows can change what weapon is selected. Someone have some ideas ?

radiant frigate
#

i dont know where i messed up but it doesnt work

atomic holly
#

The UI :

night raptor
radiant frigate
#

but the 3rd parameter in an instantiate needs to be a quaternion right?

night raptor
#

let me see

night raptor
radiant frigate
#

so instead of quaternion.euler i need quaternion.lookRotation(vector3)

radiant frigate
#

for example the .z

night raptor
#

you put these ` around (you can edit your message to see)

radiant frigate
#

testing

#

oh true

#

it works

night raptor
radiant frigate
#

it asks for 2 float3

#

i dont know what float3 is

#

i guess 3 floats?

night raptor
languid spire
#

unless you are using the wrong math library or writing shaders

radiant frigate
#

for what i know im not using a math library at all

languid spire
#

if you hover over Quaternion you will see which one

radiant frigate
#

unity.mathematics.quaternion

languid spire
#

wrong math library

radiant frigate
#

so i need to use Q instead of q?

#

or how do i change it?

#

indeed

#

that was it

languid spire
#

why are you using unity.mathematics at alll?

night raptor
#

yeah, that's meant for the burst compiler/dots stuff afaik

radiant frigate
#

i dont know if it has anything to do, but my objective is to make an enemy that shoots like this

#

one towards the player and 2 slightly offset

#

idk if that has anything to do with why im using maths

languid spire
#

you need to pay more attention to what you are doing. you have obviously mistyped something somewhere and then blindly let the IDE correct it for you without reading what it was doing

radiant frigate
#

IDE?

#

whats that

languid spire
#

your code editor

radiant frigate
#

true

#

could i know where?

#

im really frustated right now since i dont understand on can come up with a solution to it

languid spire
#

look for the using unity.mathamatics statement and remove it. the ide will then highlight the errors

radiant frigate
#

ot does not highlight any error

languid spire
#

then it was only in the one place you have already corrected

radiant frigate
#

oh

languid spire
#

you should ALWAYS look at your using statements to see if there are ones that should not be there

radiant frigate
#

okay

#

i have a question if i may

languid spire
#

you mean here ?
Vector3 bulletDirection = Quaternion.Euler(0f, 0, 30f * i) * direction;

languid spire
radiant frigate
#

srry i was doing a micro mental pause to see if i would detox

#

but it doesnt even work 😭

#

i want it to rotate the z axis

languid spire
#

yes but quaternion rotations can be expressed in multiple euler rotations and that is what you are seeing

radiant frigate
#

i did not understand the meaning of that

#

basically im having a skill issue since im not using the correct euler rotation?

languid spire
#

basically, if you put Euler angles into a Quaternion and then get Euler angles out 99% of the time they will not be the same but they will represent the same rotation

radiant frigate
#

oh

#

so just dont use that for rotating it as i want?

languid spire
#

I'm not sure why you are doing this
Vector3 bulletDirection = Quaternion.Euler(0f, 0, 30f * i) * direction;
as direction is also a Vector3. so calculate the direction first and then convert it to a Quaternion

radiant frigate
#

but the direction should be a vector3 right?

#

or should it be a degree?

#

because ive tried that and it did not work

#

neither with radian

#

probably because i did it wrong tho

eternal needle
radiant frigate
#

rely?

eternal needle
#

you instantiate the fireball with a starting position and rotation, but does the fireball even use its rotation to move? Is there an actual issue with the direction of it moving?
because u shouldnt read the values from inspector to see its euler angles, due to what steve said

radiant frigate
#

it doesnt go on the direction

#

mainly because i havent made the movement yet

#

but if i move it across the new y axis

#

it doesnt match with the direction the player is at

eternal needle
radiant frigate
#

the forward direction is the y right?

#

like the transform.up

eternal needle
#

the forward is forward

radiant frigate
#

the forward is in the z axis

#

but idk how that has anything to do

radiant frigate
#

i might just be talking nonsense at this point

languid spire
radiant frigate
#

you can ofcourse

#

but for what i recall learning the forward direction was along the z axis in 3d

eternal needle
radiant frigate
#

maybe in 2d it works in other way which would make sense and i should look into that 100%, but thats why it seemed odd to me and thought about it being the transform up

vocal junco
#

did you ever get an answer to this, i have the same issue currently

hexed terrace
#

store the string value, and then pass it to the next scene

vocal junco
#

well yes but how do i do that, my script currently does not want to access other scenes things to be able to pass it

vocal junco
#

oh thats really helpful, thank you

hexed terrace
#

first port of call is google

vocal junco
#

i mean i know its just a google search but i searched similar things and found not much useful other than a niche case scenario that didnt work for me

topaz mortar
#

How do I get to Left, Top, Right and Bottom on a RectTransform component in code?

river quiver
#

if the assets database doesnt work on builds then how do i assign a different audio clip to the audio source component

languid spire
zenith crown
#

How do i lerp one value to another?

languid spire
zenith crown
#

Thank you!

languid spire
zenith crown
#

Ohh i see it now

neon ivy
#

I'm creating a procedural animation system and am trying to limit the rotation between segments to a rigidity variable, so if the segment after the one being checked creates too sharp of an angle its supposed to bring the position of the next segment back in line but it kinda just freaks out making me think there's either an issue with the math (probably the cross product being negative or positive) but I have no clue how to fix it.

this is my code:

Vector3 forwardVector = (segment.position - segment.parentReference.position).normalized;
Vector3 connectionVector = (segment.position - Segments[GetChildSegmentIndices(i)[0]].position).normalized;

float angle = Vector3.Angle(forwardVector, connectionVector);
Vector3 cross = Vector3.Cross(forwardVector, connectionVector);
if (angle < 180 - segment.rigidityAngle)
{
    Debug.Log($"Segment {i} is too sharp!");
    Quaternion myRotation = Quaternion.AngleAxis(180-segment.rigidityAngle-3, cross);
    Vector3 result = myRotation * forwardVector;
    Segments[GetChildSegmentIndices(i)[0]].position = segment.position + result;
}
atomic holly
#

Hello
To save data when we changed scene and save some data like the remaining life of the player or his inventory, is using playerprefs is correct or there is something more optimised to do this ?

languid spire
atomic holly
languid spire
#

A ScriptableObject

remote osprey
#

Hello

#

Is there an easy way to make a sliding joint that slowly detaches from a rigid body using gravity?

atomic holly
snow portal
#

heyoo, ive been doin unity for a lil while now but first time actually tryin to do scripting and such and im wonderering if someone has a script to be able to make a collision detect any mesh thats touching it

#

ive been able to make it so when two objects with certain tags touch they send a message in console but i want any mesh that touches it to affect it

eternal needle
river quiver
#

idk why, maybe its a unity version problem

languid spire
remote osprey
river quiver
eternal needle
languid spire
remote osprey