#💻┃code-beginner

1 messages · Page 479 of 1

fiery plume
#

If i have a 3x3 grid of dots and want to make it so you can click on 1 dot and then draw a line between that to the next dot. But also have the program recognize what lines have been drawn so you can see if they have drawn a triangle What would be the easiest way to do that?

eternal needle
fiery plume
#

I have a button Setup for each poin and when pressed it stores a number of 1st point and when clicked on the 2nd it stores the number of second point. This way i store them like Vectors and in the end it checks for what vectors are stored to establish a shape but it seems very over complicated

eternal needle
queen adder
#

Sorry to be here YET AGAIN but I still am not figuring out my issue (fixed parts, new errors) so this time I just took a video, I have also been looking up information and trying hard to understand it myself but my confusion comes from I thought I DID assign the game objects as shown in video, I assigned them on the GameManager script inspector.

#

I can also provide my code if the problem is actually there

#

sorry for what I am sure is massive beginners issue and for still not figuring it out even when given advice. I really have been trying to follow it I am not sure what I am doing wrong

eternal needle
eternal falconBOT
wintry quarry
#

Is there a reason that, for example, the "Barrel" GameObject has the "GameManager" script on it?

#

THat seems wrong

#

you seem to have attached the GameManager script to several objects in the scene

#

typically a GameManager is a singleton - i.e. only one in the scene

queen adder
#

Alright so that shouldn’t be in the inspector on the side of the other objects?

wintry quarry
#

If it's in the inspector, it means you attached it to that object

#

So you really need to think about which object(s) this script should actually be attached to

#

and only attach it where it should be attached

queen adder
#

So just the GameManager object I made then?

wintry quarry
#

As for the error itself, it's pretty clear

wintry quarry
eternal needle
#

ah yes i just noticed as well, when you are clicking those errors its highlighting the actual objects that contain the script as well.

wintry quarry
#

why would you attach it to other things?

queen adder
#

New, this is just for an assignment and they completely skipped certain info like how to make the game manager object so I thought I had to connect it for it to use the script. Very silly newbie error I see

#

“Connect it” but now I know I was just adding multiple instances of it

#

So thank you

rough venture
#

Hi! I'm making a PlayerController, but I have noticed some weird behavior. Whenever I hold down both 'w' and 's' it doesn't move (and it shouldn't). The same is true for 'a' and 'd'. But if I am holding down 'a' and 'd' and then hold down fx. 's' which moves it backwards, and then afterwards also hold down 'w' it doesn't stop moving. It still moves backwards. Why is this? Is it a bug in 2022.3.24f1? Or have I missed something?

    private void Update()
    {
        Vector2 input = Vector2.zero;
        if (Input.GetKey(KeyCode.W))
        {
            // Move up
            input += new Vector2(0, 1);
            Debug.Log("up");
        }
        if (Input.GetKey(KeyCode.A)) 
        {
            // Move left
            input += new Vector2(-1, 0);
        }
        if (Input.GetKey(KeyCode.S))
        {
            // Move down
            input += new Vector2(0, -1);
            Debug.Log("down");
        }
        if (Input.GetKey(KeyCode.D))
        {
            // Move right
            input += new Vector2(1, 0);
        }

        // Vector2(x, y)
        // Vector3(x, y, 0)

        
        //Debug.Log(input);

        transform.Translate(new Vector3(input.x, 0, input.y) * moveSpeed * Time.deltaTime);
    }```
teal viper
#

Ah, maybe I misunderstood what you mean.

rough venture
teal viper
#

In the end you press all the keys and it still moves?

rough venture
#

Yes

#

If I press 'a' and 'd' before 's' or 'w'

teal viper
#

Ok. Start with debugging what's going on. Debug the pressed keys.

rough venture
#

Alright. The if statement that checks 's' is not executed when 'w' + ('a' or 'd') is pressed and vice versa

fickle wagon
#

Is it possible to return multiple values like int and string from one function?

woven crater
#

i freezed the y axis but the bullet move downward

teal viper
rough venture
teal viper
rough venture
#

I'm trying to think of a game where I can test it

rough venture
#

Thank you though 🙏

teal viper
wary gale
#

Hi there, am i correct that gameobject are positioned in reference to the center of the screen but mouse positions are based on the lower left corner of the game screen?

teal viper
rough venture
teal viper
#

In 2d games it might happen to be the same point if you position your camera in a certain way

wary gale
#

Hmm okay, im guessing you can change the scene origin point?

teal viper
wary gale
#

Oof okay. Guesd that makes things more complicated. Im trying to get the angle of my player characters "eyes" and the mouse position. But both use different origin points so its gonna be tough

rough venture
teal viper
languid spire
wary gale
#

Okay thanks for the help ill check it out

queen adder
#

have someone made a nice way to call static methods in unityevents before?

rare basin
#

if I have a static class, and a static int variable inside that class, and If i modify that variable during runtime, would the value be changed back to default when I run the game or it will automatically save? do i need to handle the saving myself?

public static class SaveSlotStaticManager
{
    public static int currentSaveSlotId = 1;
}
rare basin
#

alright, thanks

queen adder
#

easysave saved me all the troubles about any persistent data, I had a working save system before that I wrote for a week and easysave is a ton better than mine cat_shy

shell sorrel
slender bloom
#

following a yt tutorial to make flappy bird, and the text is the same as the video except im not getting the dropdown for variables, his code also looks more colourful than mine

#

any ideas whats wrong?

eternal falconBOT
cosmic dagger
#

you will see intellisense, syntax highlighting, and errors appear in your code . . .

wintry quarry
golden ermine
#

Why it doesnt recognize Im clicking E and nothing happens idk why it should open up menu, this is code its small so I screenshoted

rich adder
#

also the second one should be inside an If else statement no If, because just incase the second one could run

golden ermine
slender bloom
#

Not sure why its not recognizing vector3 in transform

slender bloom
rich adder
rich adder
cosmic dagger
#

smth looks fishy about it . . .

golden ermine
slender bloom
#

Should be the X axis here,,,

cosmic dagger
rich adder
wintry quarry
#

!ide

eternal falconBOT
scenic knoll
#

Hello guys, i dont know if this is a good channel to ask this i just legit joined but i am looking for some guidance in terms of creating a simple "turned based game". I am wondering if i could dm someone with a prototype of the game that i have done like years ago (its the interface and concept art of it in photoshop) in order to know if what i done there can be done in Unity and if its worth to do it in Unity or if i should maybe do it in any other language or engine.
Thank you.

wintry quarry
slender bloom
wintry quarry
wintry quarry
#

It would not say this if it was configured

shell sorrel
slender bloom
#

im a idiot

golden ermine
cosmic dagger
slender bloom
#

unless it reverted back i configured it

rich adder
wintry quarry
#

there are many steps

#

follow them all

cosmic dagger
scenic knoll
# wintry quarry Unity can make any kind of game you can imagine.

I worked one few projects which was the same game i wanna work in, but the game was extremely old and had an old interface, i had the job to upgrade the old interface and add a modern element to it so i just had done the concept art of it in Photoshop, but i guess the programmers were too lazy to do it or couldn't, so they ditched it. Then i also had another project with another name where the leader used Unity, but he still used the old interface and stuff.

Basically my dream concept art for the game was not done and i decided to try to make it into reality, wondering if i could do it using Unity and if its worth it. I don't expect to make this game playable but mostly to just learn programming/coding, and since the only way i think i will have fun learning is to create a game and maybe a project i always wanted to do. What would be your advice if possible?

slender bloom
rich adder
wintry quarry
rich adder
cosmic dagger
rich adder
# golden ermine then how should I handle it

you typically make a bool for them inside Update you capture them then use it inside OnTriggerStay as you need

   bool useKeyHeld;
   private void Update()
   {
       useKeyHeld = Input.GetKey(KeyCode.E);
   }
   void ontriggerstay()
   {
       if (useKeyHeld)
       {
           //watever
       }
   }```
scenic knoll
# wintry quarry > wondering if i could do it using Unity and if its worth it Yes as I mentioned...

I see, would it be possible with your permission to send the print screen to your dms of what i wanna do and maybe if possible you could just tell me what i should search for on youtube or something like that to get started? Like i said, this is not a 3D game or an actual card game, its mostly just images from an Anime and then the interface and the functionality of it behind it. I was trying to learn programming tru cs50 course by harvard and then odin project but i got stuck making a mugen game in scratch, decided to ditch it and try to make my dream project from years ago while actually learning how to code, but unsure what language would be the best language since i also dont know if i wanna be a game developer or anything else, so mostly unsure about the programming language i should choose.

rich adder
# golden ermine then how should I handle it

btw you can also do something like this

    bool isInsideKitchenArea;
    private void Update()
    {
        useKeyHeld = Input.GetKey(KeyCode.E);
        if(useKeyheld && isInsideKitchenArea)
        {
            //do whatever
        }
    }
    void OnTriggerEnter()
    {
        if (tagCheckForKicthen)
        {
            isInsideKitchenArea = true;
        }
    }
    void OnTriggerExit()
    {
        if (tagCheckForKicthen)
        {
            isInsideKitchenArea = false;
        }
    }```
wintry quarry
#

before jumping straight into making your specific game

#

this is true for any engine

#

For Unity I recommend !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

wintry quarry
#

However, in general for a turn-based game you'll want to learn about state machines.

scenic knoll
#

Damn my brain got confused by my own question

polar acorn
#

Switching programming languages is honestly pretty trivial

#

Once you learn a language, it won't be more than a day or two to get up to speed

scenic knoll
#

Yeah i get that, but where else do people use the c# language? Other than game development

#

Just to know my options in case

verbal dome
#

C# is used for web+software dev too

polar acorn
#

It's a fully formed, turing-complete programming language. You can use it basically anywhere for anything, like most other programming languages

#

In the business world, a programming language is basically "Whatever the first guy likes" and there's very little consideration put into any specific reasons

timber tide
#

more like "whatever the first guy used 20 years ago"

#

c# does seem more common than java for the past few years though

shell sorrel
#

yeah C# is pretty decent for almost every purpose but like really high performance stuff and embedded

#

also the hard part is learning to program, once you do learning new languages is not a big deal

rich adder
mint remnant
#

didn't microsoft adopt is mostly to overthrow Java's dominance at the time?

shell sorrel
#

So yes

polar acorn
wintry quarry
#

But as others said - once you know one programming language, it becomes very easy to learn a second, and a third, and so on...

scenic saffron
#

How do i add/subtract the Input of an Input field to an Integer or float?

polar acorn
scenic saffron
#

ok thx

#

how do I prevent negative numbers from being input in my input field

scenic saffron
#

all of them allow negative numbers or allow other characters

tender stratus
#

WHy?

eternal needle
# tender stratus WHy?

It tells you why, it's a method. You dont assign to it, you call the method with the parameters

languid spire
#

dont use a = sign with a method

tender stratus
#

Yep silly me

#

didnt even notice the =

#

Thanks i went on autopilot there

scenic saffron
#

how do i set up a input field so it only positive integers?

#

using this

slate nexus
#

Recently i decided to start making games in unity. I started by watching a tutorial and made a simple flappy bird game. But everytime I try to send my game to a friend of mine it always has lag spikes for him, i tried running it on my pc and it works just fine, i also tried zipping and unzipping to see if it was something with that but no. Note my friends pc is better than mine so theoretically it should be better.

teal viper
slate nexus
#

ok ty for your response

shell sorrel
#

you might be able to profile a build on yours and look for spikes as well, just might be more extream in their case

#

does your game happen to be instantiating and destroying lots of objects?

warm summit
#

hey, i followed the Instruction for custom controller but in my case the only thing that doesnt work with my custom FPS Controller is that the Input goes to the player while using the GUI.

Does anyone a fix for that?
I tried some ways, but it wont work.

i would appreciate it. 🙏🏼

slate nexus
shell sorrel
# slate nexus yeah it does

good chance the spikes are caused by garbage collection, if its constantly the same objects being created and destroyed

#

look into object pooling

slate nexus
#

ill see what i can do

shell sorrel
#

there is a big overhead to destroying objects so the idea is instead of destroying it, you just disable it and restore it to its starting settings

teal viper
shell sorrel
#

then when needed next grab one from teh pool

slate nexus
slate nexus
#

i still dont understand why on my pc it works just fine?

teal viper
shell sorrel
#

it could be many things

#

do you happen to have more ram?

slate nexus
#

nope

#

his pc is better

teal viper
#

Do they use a laptop? Maybe they have it use the integrated GPU?

slate nexus
#

no

teal viper
#

Well, then you'll have to profile it on their machine to figure it out.

slate nexus
#

ok ill try sometime when i can

shell sorrel
#

it is possible to profile across a local network btw, so you do not need to have unity on their machine to do so

teal viper
#

But might need to use a VPN.

shell sorrel
#

just the game, and your dev machine on the same lan

#

yeah i was assuming in person

slate nexus
#

ill try to export it to him

rapid pendant
#

Hi all, I have recently started working with unity and learning through codemonkey tutorial. Can anybody suggest some other resources to learn unity stuff. My focus is towards project based learning

eternal falconBOT
#

:teacher: Unity Learn ↗

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

queen adder
#

Why doesn't freeze position Y come up?

wintry quarry
#

is what you actually want

queen adder
#

ah okay thanks

strong wren
#

what are the apps that people use for sharing code?

dark laurel
#

github, github gists, pastebin

strong wren
#

some friend of mine offered to help with multiplayer so i want to show him some code

strong wren
# dark laurel github, github gists, pastebin

wait i think u missunderstood me, like for exmaple if i have a long code thing to show i cant just post it here i have to go in a website post it then send the link here, to turn the 100 line code into just 1 link

dark laurel
#

that's what you're wanting to do?

eternal falconBOT
strong wren
steep rose
#

this should help you

#

but sharping was saying the same thing

strong wren
steep rose
strong wren
#

oh sorry i just find these alot easier

steep rose
#

he suggested pastebin?

dark laurel
strong wren
#

ye but it says to make an account and stuff, i dont rlly liek doing that

dark laurel
#

they all do the same thing more or less

#

then use pastebin, free, no account needed

steep rose
strong wren
#

oh, sorry im just to slow if its not like 3 buttons to click then it just gets to hard

#

hastebin for example is just copy paste click copy button boom

dark laurel
#

programming may not be for you

#

pastebin = hastebin

strong wren
steep rose
#

pastebin is hastebin but via larger corporation

slate nexus
#

its not constant tho

#

when he alt tabbed back it was smooth

steep rose
#

do you have anything in your game like loading, scene loading, etc?

#

and stutters usually happen when something graphically demanding is happening on screen and its creating a bottleneck with you CPU/GPU

slate nexus
#

no its an extremely simple game

steep rose
#

explain "extremely simple"

slate nexus
#

flappy bird

#

it should not lag on anything

#

+his pc is better than mine and on my pc it doesnt lag

zinc seal
#

Hey, i'm following danis old movement guide and whenever I move my camera up and down my player moves up and down with it? It is hard for me to tell whats going on.

wintry quarry
steep rose
shell sorrel
# slate nexus

you can place the cursor at the spikes and get more detail about exactly what is taking the time

slate nexus
#

isnt it the vsync?

#

its the same color

shell sorrel
#

yeah still a good idea to look at the detail, also vsync can be a bit of a red hering

slate nexus
#

ok ill see

shell sorrel
#

more or less if things are v synced at say 60hz, and soemthing eats a bunch of time, and causes it to not be able to keep up and say you can only render 58 frames a second

#

well the vsync will sync to 30hz causing a large spike in its time when its just in response to something else

slate nexus
#

wouldnt just disabling the vsync solve my problem?

shell sorrel
#

would reduce the scale of the spikes, and make it easier to see the true cause sure

#

but having no vsync can cause issues as well, like screen tearing as the frame rate exceeds the displays refresh rate which is the problem vsync is designed to solve

slate nexus
#

mhm ok ill see how it works without

shell sorrel
#

but yeah if you look at the spike the profiler can show the whole break down of where all the CPU time is being used for that frame

slate nexus
#

one sec my friend is opening it rn

#

ill share screenshots of it

#

this is with the vsync graph disabled

tender stag
#

somehow this limits the velocity at which the player can move

#

and it also allows him to go beoyond the max speed

#

how do they do it

umbral rock
#

hey there! i'v installed visual studio code and i am following c# courses but i need a workload called Universal Windows Platform Development, anyone knows how to install this when i'v already installed vscode?

steep rose
# tender stag and it also allows him to go beoyond the max speed

i actually made my own quake/halifelife movement system and its almost a 1.1 replica but what i did is apply a force in the opposite direction of movement so if you strafe you could easily go past it, of course you need a max speed for strafing but its the same thing with some multipliers to slow the player down effectively

#

he probably is doing something similar

#

since this is what halflife/halflife 2 does

tender stag
#

my question is like how do i limit the force from player input without limiting speed

#

im not really making a strafing/surfing game

steep rose
tender stag
#

isnt that a bad way

#

as in like when im turning lets say

#

it wont always turn

steep rose
#

no

#

it will just stop you from turning more

wintry quarry
lofty sequoia
#

Is there a way to rename a variable but preserve the inspector reference?

steep rose
tender stag
#

like you said to cancel out the inputs

#

thats what i did

#

and it doesnt work

steep rose
#

well i cannot see X or Y or see how fast your RB is actually going so i cannot really tell you why its not working.

#

i should ask How is it not working?

tender stag
#

its not limiting the speed

steep rose
#

on the ground or in the air?

#

the speed limiting will only work on the ground since you are using dani's code

#

thats just how it works

tender stag
#

this is the whole code

eternal needle
#

I dont see anything there that actually limits the velocity

steep rose
#

well the first thing i see is a ton of nesting

eternal needle
#

That's definitely some code. That ternary notlikethis

tender stag
#

wdym

tender stag
eternal needle
#

If you want direct control of what the velocity should be, then just assign the velocity to what you want. addForce doesnt apply right away, it happens during the physics step

eternal needle
tender stag
#

i cant touch that

#

i want external forces working on the player

#

as well as limiting the movement speed

steep rose
#

also dani's code relies on its own friction so thats also a reason its not working

eternal needle
steep rose
#

what are you trying to do exactly

eternal needle
#

But still, if you're not limiting the velocity I dont see why your problem is the velocity isnt being limited

tender stag
steep rose
#

we joined this conversation late so you have to fill us in so thats why i asked

eternal needle
#

Simply put, you cant. The rigidbody doesnt store what an "external force" is. You store this yourself if you want to or dont want to limit that

tender stag
#

other games seem to do it

#

minecraft for example

steep rose
#

you have to make those forces yourself to act against the RB

#

it wont just happen

#

like you think it will

eternal needle
# tender stag other games seem to do it

Did you read the last sentence I wrote? Because it really feels like this is going nowhere. I said you cant, meaning only using the velocity from the rb. You have to store it yourself

eternal needle
pastel wedge
#

How do i fix this

deft grail
pastel wedge
#

just was failing to set the path

deft grail
pastel wedge
#

yea

obsidian granite
rich adder
#

the pc needs restart for PATH to update properly

pastel wedge
rich adder
#

vscode is ide

pastel wedge
#

yeah im p sure i extracted net sdk in downloads folder which is on a diff drive to my main so that could be it

pastel wedge
rich adder
# pastel wedge ment net sdk

just to be clear you should Install dotnet **SDK ** version on C: drive. Shouldn't matter where VSCode is as long as you can get dotnet command running in command line in main OS path

#

sum like this

late burrow
#

will this thing even fit into float

wintry quarry
#

paste it as text

short hazel
#

spoiler: it doesn't store this exact value

wintry quarry
#

(in "decimal representation")

#

nope, not exactly

late burrow
#

i know theres doubles and such

#

what if i go out of these bounds as well/

wintry quarry
#

then... you do

late burrow
#

it was for math

wintry quarry
#

the consequences of that really depend on what you're doing

#

everything is for math in the land of computing

short hazel
#

Absolute precision can be achieved with the decimal type, at the expense of range, values cannot get too high or too low

wintry quarry
#

decimal has limited precision as well

#

just 4 times as many bits to work with

short hazel
#

Enough for their number

late burrow
#

yeah i wondered if i can extend limit of bytes for variable

#

to use as many as i want

wintry quarry
#

Through software, like my link above, yes.

Your computer's hardware is limited to numbers represented with a certain number of bits - usually 64

#

And possibly up to 128 with some special instructions (which I think is how decimal works?)

short hazel
#

decimal takes up 128 bits but only 102 are really used. The mantissa is bigger than other floating point types (96 bits) so you have an accuracy of around 26 decimal digits

queen adder
# tender stag
    void VelocityControl()
    {
        Vector3 currentVelocity = new Vector3(rb.velocity.x, 0, rb.velocity.z);

        if (currentVelocity.magnitude > current_state.speed) 
        {
            Vector3 fixedVelocity = currentVelocity.normalized * current_state.speed; 
            rb.velocity = new Vector3(fixedVelocity.x, rb.velocity.y, fixedVelocity.z); 
        }
    } 
    void SurfaceCheck()
    {
        onSurface = Physics.CheckSphere(surfaceCheckPosition.position, sphereRadius, surfaceLayers);
        if (onSurface)
        {
            rb.drag = surfaceDrag;
        }
        else
        {
            rb.drag = airDrag;
        }
    } 

Your player also needs to have a 0 friction physics material, and some sort of Ground and Air drag like here

        if (onSurface)
        {
            moveDirection = orientation.forward * verInput + orientation.right * hozInput;
            rb.AddForce(moveDirection.normalized * current_state.speed * 10f * rb.mass, ForceMode.Force);
        }
        else
        {
            moveDirection = orientation.forward * verInput + orientation.right * hozInput;
            rb.AddForce(moveDirection.normalized * current_state.speed * 10f * rb.mass * airMultiplier, ForceMode.Force); //Times "Air multiplier"
        }

And some sort of air multiplier

This is my controller

tender stag
#

as in if i add a suffen explosion force to the player

queen adder
tender stag
#

alright thanks so much man

#

i’ll try it in the morning because im going to bed now

#

i’ll let you know if it works

queen adder
brave compass
tender stag
#

your setting the velocity once hes above the speed limit

#

so your directly changing the velocity

queen adder
# tender stag so your directly changing the velocity

Thats true, but Ive used this system for a very long time, including in explosions, and it doesnt seem to cause any issues

You can also put that into a bool, so when the bomb explodes you can turn off that speed control if it does cause issues

tender stag
#

i mean true

#

i mean if i dont figure it out tommorow then im probably going to stick with that

queen adder
eternal needle
# tender stag does it allow external forces?

Just saying, that code above doesnt account for what you were describing some time ago. As I said before, there is no "external forces" stored on a rigidbody. everything is an external force. The rb just stores the current velocity, which may have been a combination of a bunch of forces applied

tender stag
#

i know

#

but theres no other way to describe it

wintry quarry
#

You can calculate what the new velocity will be with this

eternal needle
wintry quarry
#

Well it can help with tracking such forces

teal viper
# slate nexus

In case you didn't get an answer, it is vsync and it acts very abnormally. To be honest the whole capture looks very abnormal. The game execution itself barely takes any time.

eternal needle
# wintry quarry Well it can help with tracking such forces

Even that method just returns a single vector3 of the force. Theres no difference if it came from 1 script used for movement or another knockback script. Im not entirely sure if I understood their problem but I dont think itd work because theres no information about where forces came from. I do think it's just solvable by keeping track of the external stuff themselves instead of having other scripts addForce directly to the rigidbody.

#

And then another thing to consider would be how long to apply those forces for

wintry quarry
#

As for "how long" - it doesn't matter too much, you would just do the tracking and compensation each physics frame.

eternal needle
#

Ah I didnt consider the actual collisions

rocky canyon
tender stag
#

to launch him to the side

wintry quarry
rocky canyon
#

ohhhh... thats YOURs

wintry quarry
#

yep!

rocky canyon
#

well i'll be

#

i think everyone in this server now knows what he's trying to do

tender stag
#

lmao

rocky canyon
#

i tested my implementation earlier.. and it works.. just projecting the would-be velocity of the player movement.. and then adding any other movement later in the loop.. (i added a THRUST FORWARD) mechanic

#

works great

#

can only move 10 units/sec with WASD but can boost up to 30 or 40 if u hit the boost button enough lol (while having the movment only contribute 10)

tender stag
#

thats exactly what i need

#

what do you mean by projecting the would be velocity

rocky canyon
#

ya, ive told u how to do it before.. but not 1:1 ofc cuz i dont know ur mechanics

wintry quarry
#

vector projection. Vector3.ProjectOnPlane(...)

rocky canyon
#

well thats one way cs void ApplyMovement(Vector2 input) { // redacted til bug sorted } i did this route

#

may not work in all use-cases tho.. ive only tested it in a straight line lol

rocky canyon
tender stag
#

im not sure tho

#

i’ll check

rocky canyon
#

could also be true.. hold im testing the projection onto the plane (before my limiter)

#

that may be still fine

#

nope, theres a bug in mine somewhere

radiant meteor
#

how do i get an array/list of every Game Object with a certain component in a scene?

tawdry trench
#

does anyone know why this comes up as a list instead of an empty array?

deft grail
teal viper
tawdry trench
rich adder
deft grail
tawdry trench
#

i c

rocky canyon
#

press the + sign 6 times

#

then it'll look familiar for ya

deft grail
#

or just type the number 6

rocky canyon
#

lol.. rekt

rich adder
#

or just reset the script lol

tawdry trench
#

i see so the 6 i wrote in the code just doesn't do anything?

rich adder
#

not if the value serialized was originally 0

deft grail
#

if you do that before adding the script to your gameobject, then it does something

rocky canyon
#

this.. unity quirks

rich adder
#

if you right click it and hit reset then initilizer values will refresh

rocky canyon
#

pro-move ^.. until its a pro-disaster lol

rich adder
#

but this will reset everything else so use caution

tawdry trench
#

oh i see that nice

#

ty

tired urchin
#

Hi, I need help with my apple picker. the candy corn won't disappear after touching the edge collide. I input the proper codes but it sill won't disappear.

eternal falconBOT
tired urchin
#

Ohh

rich adder
#

if code can't compile, its not going to run your latest changes or at all

deft grail
ivory bobcat
tired urchin
#

Okay, thank yous

ivory bobcat
#

Running the installer again would allow you to configure the Visual Studio ide - it will not reinstall the entire app (no point as well).

spark stratus
#

Hey sorry to bug yall, is this the place to get some pointers on a problem I'm having with my code?

steep rose
#

!ask

eternal falconBOT
steep rose
#

but in short yes, please ask

spark stratus
#

Lol man completely missed that .

So short version, I'm trying to make a top down, 3d game that uses mouse input to control the direction the player faces, but the wasd keys to control the movement(Where W would move the player in the direction of the mouse). So far(With some tutorial code) I've been able to get the movement to work the way I want, and the player to rotate direction with the mouse, but the camera(Despite being a child of my players GameObject) won't follow the player when i have the code that moves the player forward.

https://pastebin.com/mxUE4fL0

Hierarchy of the player object is as follows
GameObject with various scripts
-Mesh, animations etc from blender
-Camera

#

Oh and I forgot to mention, the only way I could get the player to move forwards correctly was to include the line

        if (Input.GetKey("w"))
        {   
            transform.position += transform.forward * 5 * Time.deltaTime;
        }

in the camera script

#

which seems janky as fuck

steep rose
#

i would move the camera independantly with the player like
camera.position = Player.position + vector3(0 , 0 , 0)//some offset if needed;

#

and keep in mind moving the transform of the player will ignore collisions

spark stratus
#

I went with transform.position cuz it was the only thing I could hack together that worked lol

steep rose
#

both respect collisions

#

you can also directly set velocity or a RB as well which also respects collisions

spark stratus
#

Will do some digging to decide the best way to move forward, appreciate the help!

queen adder
#
{
Debug.Log("Test");
    if (collision.CompareTag("Bullet"))
    {
        Destroy(this.gameObject);
    }
}```


Very confused why this isnt working when the object tagged Bullet enters nothing happens but the Debug
deft grail
#

did you make sure the thing your colliding with actually has that?

queen adder
#

Yes the bullet object has the tag

deft grail
frosty hound
#

The debug is outside the compare tag check, it's not detecting any triggers.

#

Presumably, you're missing something such as a rigibody2D, or setting the collider to be a trigger, etc.

queen adder
queen adder
deft grail
queen adder
slender nymph
#

have you considered printing what was hit as well as its tag instead of just "Test"?

vocal wharf
#

Hi! I am making a very basic open world 3d car game and right now I am working on a speedometer. I have a TMPro text on th canvas and I made up my own code to get it to constantly display my rb.velocity but my problem is that it has a lot of decimal places and I will like to round it to the nearest integer. I found out about Mathf.Round and looked up the doc for it and tried to implement it but it makes no change to my speedometer readings. Can someone help me please?
I have the rigidbody movement code in Fixed update (I left that part out because it is unrelated and not connected to this code at all) and part of the speedometer code in regular update. Is this correct?

void FixedUpdate()
    {
        currentSpeed = rb.velocity.magnitude;
    }
    void Update()
    {
        Mathf.Round(currentSpeed);
        speedometer.text = (currentSpeed + " mph");
    }
queen adder
slender nymph
#

right but that doesn't actually provide useful info. but you can print that useful info instead

deft grail
vocal wharf
queen adder
deft grail
solemn summit
frosty hound
#

Knowing what you're hitting is exactly how you debug your issue.

slender nymph
deft grail
fierce shuttle
deft grail
#

well you dont "have" to

#

but for this case you should

vocal wharf
queen adder
frosty hound
#

Okay, good luck then.

vocal wharf
#

@deft grail @solemn summit hmm it still displays many decimals

queen adder
deft grail
frosty hound
queen adder
frosty hound
#

Again, not wasting time. No need to respond/ping me further, thanks.

deft grail
vocal wharf
queen adder
#

This guy is confusing me 🤦‍♂️

solemn summit
vocal wharf
deft grail
queen adder
vocal wharf
vocal wharf
#

oh nvm I lied visual studio shows a syntax error too 😂 my bad

slender nymph
# queen adder Not you. Osteel is sorry my bad

you insisted on not printing out useful information which is literally how you debug this issue. so you were literally resisting the help being offered by not doing the one thing you need to do to figure out why this is not working the way you expect it to

vocal wharf
#

I closed visual studio before it had time to display the error 😂 too impatient I guess

#

@deft grail yes it works now, only shows integers. Thank you very much

queen adder
solemn summit
slender nymph
queen adder
slender nymph
#

with Debug.Log and using the Collider2D provided as a parameter for the method you will be calling that inside of

solemn summit
slender nymph
#

or even better: Debug.Log($"{name} overlapped {collision.name} with tag '{collision.tag}'");

queen adder
slender nymph
#

copy my log and use that

deft grail
queen adder
#

Will do

slender nymph
#

i'm betting there's whitespace in it

queen adder
#

Is that space goofing with it

slender nymph
#

yep, your tag has whitespace in it

queen adder
#

Got it

solemn summit
#

boxfriend big brainin' it over here

slender nymph
#

'Bullet ' != 'Bullet'

queen adder
#

Thank you guys a lot I wasnt trying to be difficult or anything I honestly wasnt understanding. you guys are awesome that fixed it I really appreciate it!

supple wasp
#

Hi people, if you can help me with this code, it's because it can't climb or stop, it just walks.

slender nymph
#

!code

eternal falconBOT
supple wasp
#

Okay, can you help me now?

rich adder
rich adder
supple wasp
rich adder
eternal falconBOT
#

mad No

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

supple wasp
#

I don't have nitro to send a lot of text

supple wasp
#

Have you already tested the code?

#

Have you seen how the NPC behaves?

rich adder
#

sart debugging

supple wasp
#

I wanted to make the NPC able to climb but he doesn't climb or stop, he just walks without stopping

slender nymph
#

have you confirmed whether OnTriggerEnter is being called or not?

#

i'm going to go ahead and guess right now that it isn't considering you're moving this object via its transform rather than with something that would ensure that would be called like a Rigidbody or CharacterController

supple wasp
#

is that all that is in setbool all the parameters have the setbool

slender nymph
#

huh?

rocky canyon
#

you don't need to be in debug mode

slender nymph
#

if it has a rigidbody on it, then why are you moving it via the transform?

#

even still though, have you bothered making sure that OnTriggerEnter is actually being called?

supple wasp
#

That's to put it right because it's not going in the direction from where it is.

slender nymph
#

i have no idea what you mean by that

supple wasp
slender nymph
#

this does not answer the question i asked

worldly mural
#

does anyone know how i can attach an audio source to the script component of an uninstantiated object? its saying theres a type mismatch but im not solve how to solve that

slender nymph
#

that is an AudioClip not an AudioSource. an AudioSource is the component that plays an AudioClip (the sound asset)

worldly mural
#

oh that makes sense

remote lynx
slender nymph
#

!code

eternal falconBOT
slender nymph
#

and have you checked the log files for any errors? can you also be more specific about the actual issue like i asked instead of just dropping the exact same video

remote lynx
#

how do i check logs in players?

slender nymph
#

!logs

eternal falconBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

slender nymph
#

click the documentation link ☝️

remote lynx
supple wasp
#

It can't be that he's that st*pid...

remote lynx
supple wasp
#

I think the game is going to be cancelled, another game is cancelled

slender nymph
#

that's in the player log?

supple wasp
slender nymph
#

obviously not

supple wasp
slender nymph
#

have you confirmed whether OnTriggerEnter is actually being called yet?

supple wasp
#

If you already have the tag on the object and nothing

remote lynx
#

oh this is in edditor logs

#

no errors in player...

slender nymph
remote lynx
slender nymph
#

whatever that message was supposed to mean though, it still does not answer the question i asked. i did not ask about its tag, i asked if you have confirmed whether the OnTriggerEnter method is actually being called

remote lynx
slender nymph
#

do you ever plan on actually providing a description of what you think isn't working? those of us who have not been working on your project directly do not have the context needed to know just from your video (half of which was spent just waiting)

remote lynx
#

when there is only 2 answers to the questions i set the anchorMax of the 0th and the 2nd answer to the 1st and the 3rd answers anchorMax and then when there are 4 questions it should go back to default but it doesnt

silk night
remote lynx
#

I dont actually have time to code it from scratch

silk night
#

Thats the neat part

#

No coding needed, they just align the items for you

slender nymph
#

yeah layout groups are going to require much less code

remote lynx
#

Docs?

slender nymph
#

but i would also like to point out that you are not resetting the anchors on those objects, you are resetting their offsetMin and offsetMax

#

although rereading the information that may not be the issue so you can probably ignore that

remote lynx
#

Why does it work in editor but not in the player though?

quick fractal
#

!ide

eternal falconBOT
languid spire
#

please do not post random files here

grim shuttle
#

this is a file for beginner code - guess its wrong place to post then?

#

It is only for Unity development of games

languid spire
#

you posted a file with no explanation of what or why, so yes this is the wrong place. #1180170818983051344 would be more suitable

grim shuttle
#

nice thanks

#

I thought the file name was explanation enough opps

languid spire
#

you dont think I could post a virus with the same name?

grim shuttle
#

Noice

calm badge
#

Hi, does anyone have an idea/experience for integrating a 3D avatar into a mobile app?

ivory bobcat
calm badge
#

Alright thanks

paper sable
#

hey, i was thinking that i could save some resources by only rendering the objects that are in the player's camera view so i did that and it works pretty well, but if i get too close to an object, it also disables its renderer, does anyone know if i did something wrong in my code?
this is the script that i apply to all the objects in my scene

void Start()
    {
        camera = Camera.main;
        renderer = GetComponent<MeshRenderer>();
        bounds = GetComponent<Collider>().bounds;
    }


    void Update()
    {
       if (!renderer) return;

       cameraFrustum =  GeometryUtility.CalculateFrustumPlanes(camera);
       
       if (GeometryUtility.TestPlanesAABB(cameraFrustum, bounds))
       {
        renderer.enabled = true;
       } else {
        renderer.enabled = false;
       }
    }
slender nymph
#

what you've described is called frustum culling. and unity already includes it

paper sable
#

so the thing im trying to do is useless?

slender nymph
#

yes because unity already does it for you

keen dew
#

All that does is add extra overhead and a source of potential bugs

paper sable
#

alright, im not going to use the code anymore. thanks for telling me guys

formal hill
#

I can't seem to figure out why my enemies are invisible. Can someone help me out? (They were visible before I made the enemy spawner)

keen dew
#

Check that they don't spawn behind the camera

formal hill
#

What do you mean behind the camera?

keen dew
#

I mean that if they're behind the camera then the camera won't see them and they won't be rendered

formal hill
#

How do I check if they are behind the camera?

keen dew
#

What's the Y position of the enemies when they spawn, and what's the Y position of the camera and an object that is visible?

#

Or pause the game, go to scene view, turn on 3d mode and see where they are

formal hill
#

Is it because the enemy spawners y position is minus?

keen dew
#

What's the Y position of the camera? ¯_(ツ)_/¯

formal hill
#

I didn't know I could go to 3d mode in 2d

#

😅

keen dew
#

click here

twilit iris
#

why my quad object won't render the image i imported?

#

nvm im dumb. the image actually shown but it facing the wall 💀

vague oyster
#

help please

languid spire
vague oyster
#

it says that animator does not contain such a definition

vague oyster
#

this is strange because I don't have a class called animator

wet raptor
#

I am trying to make some colliders on an isometric grid. The colliders seem messed up and curved, not like a grid at all.

languid spire
vague oyster
#

I think I understand

wet raptor
vague oyster
#

I clicked on this class in the ad and this opened up for me

languid spire
vague oyster
#

there is no script in the files with the name animator, but for some reason the file name is glow animator, while in the script it is simply called animator

languid spire
vague oyster
#

as it turned out, there really is a class. In any case, thanks for the help, I think I understand what to do next

ripe vigil
#

anyone know what to do im following tutorial and they dont got this

teal viper
ripe vigil
#

idk whats going on

#

can u vc?

teal viper
teal viper
ripe vigil
teal viper
#

There should be a readme or some info at least.

teal viper
ripe vigil
#

i got them in

teal viper
#

You can share a screenshot

ripe vigil
#

ok well

teal viper
#

Or record and share a video here.

ripe vigil
#

the samples are

#

idk where but

#

its in projec setings

ripe vigil
#

com.unity.xr.interaction.toolkit thats something i put in in the plug in things

teal viper
ripe vigil
#

how do i see them then

teal viper
ripe vigil
#

im starting a new thing so i can restart without the errors

neon ivy
#

about to make a ground check (3d not 2d if that matters) with the tried and true "just a raycast down", was wondering if anyone had any ideas for something more or is this truly is the end all be all?

cosmic dagger
wintry quarry
#

It's a pretty good way..what prompted the question, is it not meeting your needs?

neon ivy
#

I mean I can assume it's the best way for me to do it or I can ask more knowledgeable people if my assumption is wrong

#

call it curiosity or just learning

wintry quarry
#

"the best way to do" something always depends on the something you're trying to do. Every game has different needs

#

The shape and movement style of your character is a huge factor

#

A simple Raycast down wouldn't cut it for a complicated worm shaped character for example.

neon ivy
#

UnityChanThink that does make sense, I was kinda just gonna make an all purpose component that I can put on anything that needs a ground check.

languid spire
neon ivy
#

so I just make a new ground check whenever I need one?

languid spire
hushed hinge
#

i have a problem, a code helper did made this changes for like coyote timer and the buffer jump
"Jump buffers are when you press jump before you land but because you haven't touched the ground you don't jump, the buffers fixes that it saves the jump in for a short period letting u jump so its less frustrating,
Same with coyote time that lets u jump after u walked off a platform, like a small window of opportunity"
that is what someone said, but however ever since those things were added, the jumping mechanic haven't been working properly that instead i jump higher instead of normal and i just jump normal instead of higher in my jumping frog power-up, you even jump on the walls. i don't know why since someone did made the coyote timer and buffer timer
https://gdl.space/tupijoxuxa.cs

languid spire
hushed hinge
languid spire
rough orbit
#

In the below, I want there to be a short delay before myRigidbody.useGravity = true; comes into effect. What would be a good way to do that?

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            GetComponent<MeshRenderer>().material.color = Color.red;
            myRigidbody.useGravity = true;
        } 
        else
        {
                myRigidbody.useGravity = false;
        }
    }
hushed hinge
wintry quarry
#

Just because it doesn't solve all cases doesn't mean it won't solve most of yours

neon ivy
safe root
#

How do I solve this problem. I solved it once but completely forgot how. I'm not sure if there was a command for it or not

cosmic dagger
#

that definitely sounds hard to solve . . .

safe root
#

I don't think I can send photos

#

It's the .Net Core SDK not being found so it doesn't show any problems with my code but in Unity I have a problem

languid spire
safe root
#

I solved it through one of these discords

hushed hinge
rustic maple
#

why does my fps controller player keep falling through my terrain? i tried adding multiple colliders to both but nothing works, it also falls through a plane

wintry quarry
#

¯_(ツ)_/¯

rustic maple
#

alr one sec

wintry quarry
#

You would have to show us how its set up, the code, etc.

rustic maple
#

i got these 2

#

and this the script i used

wintry quarry
#

can you share your actual script?

#

!code

eternal falconBOT
wintry quarry
#

I don't see anything odd about the script from the tutorial, o the question is:

  • Did you change anything, or not copy something correctly?
  • Do you have other scripts
  • Is your terrain weird somehow
rustic maple
rustic maple
wintry quarry
#

yeah it's the same

#

can you show your hierarchy

rustic maple
rustic maple
wintry quarry
rustic maple
#

i removed the capsule collider from the player

wintry quarry
rustic maple
wintry quarry
# rustic maple

Can you show Edit -> Project Settings -> Physics and show the layer interaction matrix?

rustic maple
#

you mean this?

wintry quarry
#

I'm not seeing anything wrong

#

Can you try with a basic/empty terrain and see hwat happens?

rough orbit
# languid spire Coroutine

Thanks! The script is on every tile on this chess board. The player moves 1 tile at a time and currently every tile is gonna fall OnCollision. Any idea how I would make it random which tile is gonna fall? I'm thinking 30% chance.

#

Script again:

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            GetComponent<MeshRenderer>().material.color = Color.red;
            myRigidbody.useGravity = true;
        } 
        else
        {
                myRigidbody.useGravity = false;
        }
    }
wintry quarry
languid spire
rough orbit
#

it's there but cant post it for some reason

languid spire
#

you can also use if (Random.Range(0,3) == 0) { }

languid spire
rustic maple
wintry quarry
#

is the player starting above the terrain?

rustic maple
#

it definitely is

outer wigeon
#

Thats the capsule but cant see the actual collider it should be a green wireframe

wintry quarry
#

It's probably underneath

outer wigeon
#

you should send a pic that looks like that

#

@rustic maple

#

and make sure is enabled

rustic maple
#

my capsule doenst have a capsule collider becuase the tutorial said i had to remove

outer wigeon
#

I suspect we are about to solve a lot of those player falling through the terrain issues then

wintry quarry
#

which is a capsule shaped collider

#

And which has a green gizmo just like the one shown in the screenshot above

#

check underneath the terrain

#

i bet you'll find it there

outer wigeon
#

It is definitely just misplaced then

wintry quarry
#

I would also highly recommend setting this to "Pivot"

#

The Center setting can be very confusing and disorienting

#

pivot shows where the object actually "is"

rich adder
#

there are only few specific instances..
Eg Want to rotate a group of objects around a point.. Use Center instead.. but those are very few cases, most times you will use Pivot

rustic maple
rustic maple
#

ooooh wait

#

i think it has something to do with this

rich adder
#

so basically what Praetor said lol

rustic maple
#

thats when i start the game

rich adder
#

also if thats the CC it should be on the root object, only GFX should be child

rustic maple
#

when in edit mode the capsule is on the ground and the character controller is floating in the sky

rich adder
#

reset it

#

just to be clear the CC should not be on the child

rustic maple
#

it is on the parent

rich adder
#

ok so you clearly have 2 objects

#

which one is the child then

#

the "mesh" ? if so it should be ok just reset pos

#

@dusky nest ⏬

eternal falconBOT
rustic maple
#

it works now!

dusky nest
#

how do i do this? the script was given to me by the assignment, but the counter integer was added by me as per instructions. i'm not sure if i even added counter correctly.

using UnityEngine;
using System.Collections;

public class Forces : MonoBehaviour
{
    int counter = 0;
    public float speed;
    // Use this for initialization
    void Start()
    {
         
    }

    // Update is called once per frame
    void Update()
    {

    }
    void FixedUpdate()
    {
        float hor = Input.GetAxis("Horizontal");
        float ver = Input.GetAxis("Vertical");
             
        Vector3 move = new Vector3(hor, 0.0f, ver);
        GetComponent<Rigidbody>().AddForce(move * speed * Time.deltaTime);
        counter++;
    }
}
dusky nest
zinc seal
rich adder
#

also Time.deltaTime is wrong on AddForce, we dont add that since addForce already moves the rigidbody with Physics loop. And you're correctly using FixedUpdate so its fine. Just remove Time.deltaTime

zinc seal
#

how do I start learning C# for unity whenever I find a guide I end up just copying the code without really knowing what it does or how it works

teal viper
rich adder
zinc seal
rich adder
#

learn how to store a name into a string and print it back, etc

rich adder
dusky nest
dusky nest
#

yeah he forgot about his online class 😭

rich adder
#

not a real teacher, and has no clue how Unity works

zinc seal
#

I wish freecodecamp had courses for game development, their courses are just amazing for beginning.

dusky nest
#

and ofc his in-person class is on the further campus

eternal needle
#

GetComponent in fixed update too... what a leader

rich adder
#

big brain moves

#

i bet didnt even explain what velocity of a rigidbody is and how to use it to calculate a magnitude for speed of movement

#

which is basically what ur assignments requires

dusky nest
#

nope 😭 and we're expected to create a game next week

rich adder
#

"move the counter value only when its moving"
yours is counting every physics frames even not moving

dusky nest
#

lmaao

rich adder
#

You need the magnitude of you rigidbody, if its above a threshold , start counting

zinc seal
#

what course would you guys recommend for unity? (preferably free lol)

rich adder
#

particularly do Essentials Pathway and then Junior Programming one

zinc seal
rich adder
#

the last link is the one I first learned unity with

#

they had no pathways when i started :\ consider yourself lucky

zinc seal
#

alright ill spend today (or however long it takes) working on the essentials pathway

hushed hinge
steep rose
zinc seal
#

thanks for the help

rich adder
#

goodluck 🫡

steep rose
#

i never used unity learn to learn i kinda just winged it, dont do what i did

zinc seal
zinc seal
#

worst part of unity is waiting for a project to load 😭

rich adder
zinc seal
#

making my ssd feel like a hard drive

steep rose
#

wait till you get to C++

#

or C

#

thats where the fun happens

rich adder
#

mehh stick to c#

#

if you value your sanity , no reason to ever touch C/C++

#

embedded system notlikethis

steep rose
#

I personally dont so i will use it lmao, scratch that I do, i just like C++ for learning game making, etc

zinc seal
#

if I learn any other language besides C# it will be rust

rich adder
#

its good but very niche usecases atm

zinc seal
steep rose
#

who says that

rich adder
#

just like web assembly supposed to replace javascript...yet here we are...

zinc seal
#

You'd be surprised

#

its like a cult from what i've seen

steep rose
#

they are a silent one then

zinc seal
teal viper
zinc seal
#

I heard more about it when I was big into linux, much less now, so probably just depends what community you're in.

rich adder
#

tru dat

steep rose
#

dilch knows what he is talking about thinksmart

rich adder
#

but if ur coming from html/css you're better off just going to c# and not deal with memory management so early on or you will probably quit

steep rose
#

yeah C# is way easier than C or C++

rich adder
#

c# can pretty much do it all and its easy

steep rose
#

but C++ is so so so so fast

#

but it will make you go insane (if you dont know what you are doing)

rich adder
#

irrelevant to unity

teal viper
#

The gap is not as big as you might think

steep rose
teal viper
#

Code architecture and optimization techniques matter a lot more than the language you're using.

rich adder
steep rose
rich adder
rich adder
#

but yeah going a bit #offtopic from unity before I get the 👢

#

My gameobjects enums keep resetting to the first value ? is this a bug , never had this happen before ?
it happens at random times UnityChanThink

#

and only this specific enum?

brave compass
rich adder
#

ChessPieceColors one is fine though

brave compass
rich adder
#

none

polar acorn
rich adder
steep rose
#

try setting the enum on start

#

the ondrawgizmos stuff now this?

rich adder
#

that would mean All the pieces still have the same type

steep rose
#

i know its janky

#

but it may work

rich adder
#

All my pieces need to bet set in inspector as different chesspieces

#

I think its working now though, I just remade the Enum as something else..I think something got borked in the serialization process..

#

so far hasn't changed 🤞

steep rose
# rich adder not sure I understand

well yeah so you have an enum as your "selector" then a private enum and you set the private enum to the "selector" type and just use the private enum for everything in your scripts

#

if it just started to randomly work then you dont need to do this 😂

lilac moth
#

Is this text channel where we would ask for help?

formal hill
rich adder
formal hill
#

Where?

rich adder
#

when you reset the scene this object goess DDOL while still referencing the TMP instance from earlier

rich adder
#

after resetting scene

eternal falconBOT
formal hill
#

How can I fix it?

rich adder
#

make canvas child of the object with DDOL and Score Manager on it

#

or find it at runtime every scene change

formal hill
rich adder
#

that would be the easiest

#

not as clean but will do

formal hill
lilac moth
#

Im in Unity3d and I have a rotating obstacle that I want to collide with the player and push them. The obstacle collides properly and pushes the player when it moves slow, but the player phases through the obstacle when it moves fast.

The player and rotating object have colliders and rigid bodies using continuous collision detection, yet faster rotation of the obstacle makes the player phase through it. The obstacle is using rigidbody.moverotation (I used https://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html). The player moves with playerRb.velocity = new Vector3(speed * horizontalInput, 0, speed * verticalInput);

rich adder
wintry quarry
formal hill
wintry quarry
#

And there are limits to what the engine can properly compute in terms of rotational collision

rich adder
#

perhaps you should explicitly hide the retry scene on click

formal hill
rich adder
#

indeed.
ideally you eventually want to have a menu/UI manager of sorts for these 😅

wintry quarry
formal hill
rich adder
wintry quarry
# lilac moth

Seems fine to me. Perhaps try decreasing your fixed timestep

formal hill
#

I'll most likely do that at some point. (If I'm not too lazy to😅 )

rich adder
#

you already have a "Score/Game Manager" the concept is the same ( a centralized script that deals with all its related functions/ duties)

formal hill
#

So the score text is no longer glowing or anything

rich adder
#

did you also bring with you the post processing / PP Volume

formal hill
#

Wait

formal hill
rich adder
#

DDOL is convenient but tricky too

wet raptor
#

I am having an issue where my PlayerInputActions. Using the input system is throwing an error.
What have I done wrong?

formal hill
wet raptor
polar acorn
short hazel
rich adder
wet raptor
#

As in one of these needs to be a different name?

polar acorn
formal hill
#

So I think yes

#

Yes it's still enabled after the reset

rich adder
#

this is one of the things I deslike about making everything DDOL lol

formal hill
#

Now it pretty much works but it says

MissingReferenceException: The variable GameOver of GameManager doesn't exist anymore.
You probably need to reassign the GameOver variable of the 'GameManager' script in the inspector.
GameManager.GameOverScreen () (at Assets/Scripts/GameManager.cs:24)
Enemy.OnCollisionEnter2D (UnityEngine.Collision2D collision) (at Assets/Scripts/Enemy.cs:87)

#

And both the scripts that the error is about are turning on the death screen

wintry quarry
#

Specifically whatever the GameOver variable is referencing

formal hill
#

Yeah, but I dont know what

formal hill
wintry quarry
#

Ok, that panel is being destroyed

#

And then you're trying to use it after it's destroyed

rich adder
formal hill
rich adder
formal hill
rich adder
#

once you make something DDOL if you want anything from another scene to access it, it must be done with something like a Singleton , Or some type of GetComponent/DI

rich adder
#

learn how to properly get the references when needed

rich adder
formal hill
rich adder
#

from where?

#

your DDOL scripts should be only ones handling it

#

why does Enemy have it

#

Enemies should not care about Gameover, or UI or any of that

formal hill
#

I don't have a specific ddol script. I have a scenemanager the SceneManager references the death screen to not be destroyed on load

formal hill
rich adder
formal hill
rich adder
#

can you show the function Enemy.OnCollisionEnter2D

formal hill
#

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Bullet")) 
    {

        Vector2 knockbackDirection = (transform.position - collision.transform.position).normalized;

        rb.AddForce(knockbackDirection * knockbackForce, ForceMode2D.Impulse);
    }

    if (collision.gameObject.CompareTag("Player") && !isDead)
    {
        isDead = true;
        ParticleSystem playerEffect = Instantiate(playerDeathEffect, transform.position, Quaternion.identity);
        Destroy(collision.gameObject);

        gameManager.GameOverScreen();
    }```
rich adder
#

as long its not a scene gameplay object , this is fine for a manager script

rich adder
#

you're referencing an instance which no longer belongs to that scene

#

at very least it would be GameManager.Instance.GameOverScreen();

#

personally though I would opt for an event your enemies invoke, then its up to your game manager how to handle it

#

GameManager captures all scene enemies on scene load, then subscribes to such event

#

now your enemies would do their thing without caring about handling game states..

formal hill
#

"Instance" gives an error

#

Severity Code Description Project File Line Suppression State Details
Error (active) CS0117 'GameManager' does not contain a definition for 'Instance' Assembly-CSharp F:\Unity projects and backups\Projects\Shooter Footer Looter\Assets\Scripts\Enemy.cs 87

rich adder
#

assuming you were to make GameManager a proper Singleton instance

formal hill
#

What am I supposed to do to fix this??

rich adder
#

look at least your ScoreManager has one but its lowercase i

rich adder
#

what part confuses you

formal hill
rich adder
#

anything you link inside the inspector that is now on DDOL will BREAK

#

including the GameManager

neon ivy
#

for an open world, how do I differentiate between something walkable and something climbable without tags and layers cuz then it always has to be different objects

rich adder