#💻┃code-beginner

1 messages · Page 626 of 1

dense mica
#

Its the workaround I've been doing

#

Just no idea why the scene tools themselves no longer seem to function.

grand snow
#

what happens when you change to this tool?

dense mica
#

I can click the snap points but dragging does nothing

#

The cursor changes to the arrows you would normally see, indicating an intent to allow for adjustment.

#

I CAN still click/drag the yellow Text Mesh Pro boxes

grand snow
#

this isnt in a layout group or something right? does it work if you make a new scene and spawn a new canvas + image?

dense mica
#

What is a layout group?

#

And yes, a new scene works. Like I said, feels as though I must have toggled something that is really well hidden...

grand snow
#

same for other components like aspect ratio fitter

dense mica
#

Well I haven't done such a thing intentionally. Given I can still use the inspector to fully customize the objects, that also wouldn't seem to be the case?

#

At the top level I have a Canvas of type Screen Space - Camera. It uses a Canvas Scalar for Scale with Screen Size, Expand, which is how I usually approach mobile dev Canvas spaces.

#

Below that is a Rect Transform of type Expand. And below that are the various elements I cannot edit.

#

They are all set for a center anchor point on their Rect Transforms.

#

But even global objects in the scene cannot be edited. I have a group of Manager objects that are just off-screen, and various other housekeeping objects that exist on top of the heirarchy. They too are uneditable live in the scene view.

craggy marten
#

can someone help. i have been trying to implement ads to my game for around 2 days now and spent over 10 hours on it, it just wont work i tried the unity advertisment legacy package and now i am trying the levelplay mediation. just someone please

surreal minnow
#

Does LZ4HC compression method have any peformance penalties apart from longer loading times? Can't find a definite answer

slender nymph
craggy marten
#

can´t even ask questions

#

i will literally pay someone to add me an help me

wintry quarry
dense mica
#

Will do, and no nothing is marked static.

slender nymph
# craggy marten can´t even ask questions

mate you haven't even specified what part you are actually struggling with. and this is a code channel so we expect to see the relevant code. if you don't want to actually provide the useful information that would make it easier for someone to help you then kindly fuck off so other people can get help

craggy marten
#

i am strugling with basically everyhting, no need to get salty tho

dense mica
#

Ok try this? I just right clicked and added a New Empty Object.

#

It also cannot be modified in-scene.

slender nymph
craggy marten
#

basically yeah, i dont know any code really. i am being honest

slender nymph
#

then start by learning wtf you are doing. there are beginner c# courses pinned in this channel to get you started

craggy marten
#

i made eveythign with chat gpt, why would i learn coding if it can do it all, it did all but the last part in my project was adding ads and now i am stuck. so i came here to ask for help

slender nymph
#

lol no wonder it won't work. the bullshit generator was generating bullshit for you

craggy marten
#

kinbd of shot my self in my own leg with not learning

dense mica
#

And thus did he learn, that ChatGPT could not, in fact, do it all...

craggy marten
#

no everyhting else works liek a charm

slender nymph
grand snow
# dense mica

check your layers as i think there you can change interaction stuff too

craggy marten
#

iu thougth people would be nice here and not hostile. i would save a lot of time if someone just helped me a bit and i would pay for it. other wise i would have to learn coding just to add ads to my game, but i agree with you

slender nymph
#

if you want to pay someone to help you then post on the job forum 👇 !collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

slender nymph
#

if you want someone to help with your AI generated crap, then go somewhere else.
if you want to actually learn, which is what this server is for, then start by learning the c# basics since you claimed you don't know them. there are beginner courses in the pins

craggy marten
#

i dont have time for that, but thank you

sour fulcrum
craggy marten
#

i dont need teaching, i just needed for someone to do it for me for a price

slender nymph
#

and we don't allow collaboration or job posts here as the bot message said

sour fulcrum
#

Hence me saying that’s not what these channels nor server is for

craggy marten
#

i dint know that, sorry.

slender nymph
#

then read the information provided to you

craggy marten
#

thank you for tellign me where to look

slender nymph
#

you would also have known that if you'd bother reading #🔎┃find-a-channel like you were instructed to 20 minutes ago

craggy marten
#

true

surreal minnow
#

When I went to windowed mode in game and then back to full screen these black bears appeared where the windows top bar UI was, does anyone know why?

if (Input.GetKeyDown(KeyCode.F11))
{
   Screen.fullScreen = !Screen.fullScreen;
}
slender nymph
#

well that code wouldn't have caused black bars to appear. if you have some sort of letterboxing set up (which is not something built into unity so you would have had to download an asset or set it up yourself) that may have caused it. otherwise it might be a bug of some sort (possibly driver or display bug or an engine bug)

surreal minnow
#

Im confused because they didnt exist when the game first launched in full screen until i pressed F11 to go to windowed mode. Now it is there even after i relaunch the game

dense mica
#

Nothing seems amiss?

#

If anything was locked I'd expect to not be able to actually edit it in the inspector, you know?

grand snow
# dense mica

has to be something with those objects then 🤔 can you show all the components on one of em?

dense mica
#

I did already above where I added a new blank empty game object to the bottom of the scene.

#

Such a strange thing to run into. I spent years working in Unity 2021 w/o this happening. And its been months in Unity 6 before this popped up out of nowhere.

grand snow
#

unless there are new options that affect this stuff in the scene view im not sure what it could be

dense mica
#

No worries, I appreciate your taking a look. Probably some silly Unity 6 bug/corruption... I can still do everything I need by dragging the invisible sliders over the inspector variables at least.

rocky canyon
#

people put alot faith in those things...
feel similar to me as bringing my cellphone w/ me on a commercial airliner..
asking chatgpt to help me fly across the country and expecting to live thru the experience

craggy marten
#

it accually did good job made me a whole working game, but the only part it couldnt help me was with the ads, hope it wont replace coders in a few years

rocky canyon
#

anyway.. back to the question. I don't do Ads so i can't honestly provide any help

#

i can wish u best of luck tho 🍀

craggy marten
#

thanks

rocky canyon
#

u might find some useful stuff on the unity discussions forums

craggy marten
#

i have goon trough all forums all reddit treads, everything.

#

wait not goon gone

rocky canyon
#

lol, i figured

toxic quiver
#

can anyone help w/this?

rocky canyon
#

i think its TMP_InputField

toxic quiver
#

ok let me try that

#

"Assets\NewBehaviourScript1.cs(59,30): error CS0119: 'GameObject.GetComponent<T>()' is a method, which is not valid in the given context"

rocky canyon
rich adder
rocky canyon
#

soo many things about that line makes my head hurt

toxic quiver
#

Sorry hold on ill try fixing it and if i still cant ill send more stuff

rocky canyon
#

if u use SerializeFields u can drag and drop the component right in the inspector

#

ir ur using GetComponent.. make sure ur getting the exact same type

toxic quiver
#

this is the code i wrote i might have done something stupid on it

coarse magnet
#

So..i'm trying to get this item to self destruct when collides with the player, they do collide in playmode but for some reason nothing happens, why?

#

(Yes i have set the player tag to player, yes i added the item into the variable in the editor)

eternal falconBOT
#

mad No

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

rich adder
#

👇 @toxic quiver

eternal falconBOT
coarse magnet
rich adder
#

browser version

#

regardless use proper code sharing options

polar acorn
coarse magnet
#

Well it certainly isn't because nothing happens

#

And also every other game object with collisions towards this gameobject doesn't work aswell

wintry quarry
polar acorn
#

The Three Commandments of OnCollisionEnter2D:

  1. Thou Shalt have a 2D Collider on each object
  2. Thou Shalt not tick isTrigger on either of them
  3. Thou Shalt be moving via a 2D Rigidbody on at least one of them
sharp bloom
#
IEnumerator IdleMove()
    {
        while (true)
        {
            IdleMoveUp();
            yield return new WaitForSeconds(3f);
            IdleMoveDown();
            
        }
    }
    void IdleMoveUp()
    {
        transform.DOMoveY(transform.position.y + 2f, 5f);
    }

    void IdleMoveDown()
    {
        transform.DOMoveY(transform.position.y - 2f, 5f);
    }

Why does the object keep moving up with this script?

#

If anyone is familiar with Dotween

tribal wave
#

not really related to scripting, but are colliders hollow?

rich adder
frank flare
#

am I doing something wrong?

tribal wave
#

now i need to find a sphere mesh

rich adder
slender nymph
sharp bloom
tribal wave
digital kayak
tribal wave
#

hard to explain

rich adder
#

just make it a trigger?

tribal wave
#

shit

#

i forgot about that

slender nymph
sharp bloom
frank flare
tribal wave
rich adder
slender nymph
sharp bloom
sharp bloom
#

Shit I don't know then

rich adder
#

Uness Rider doesnt underline it at all

slender nymph
# rich adder thats not the issue

it sort of is though, seems like they were using a different Random class than the UnityEngine one if using the fully qualified name fixed it

sharp bloom
slender nymph
#

i'd bet they have their own Random class

rich adder
sharp bloom
rich adder
#

maybe yeah it wasnt even from System.Random

sharp bloom
rich adder
#

oh rider is different

frank flare
slender nymph
# sharp bloom

this isn't quite what nav was referring to. using the fully qualified name completely bypasses the error nav was expecting

rich adder
#

normally even just putting Random threw ambiguous error thats why I got confused myb

#

mine stops at Random not Range 😢

slender nymph
#

yeah that would normally be it if they had using System, but i'd be willing to bet they have their own class called Random and is likely either the type they were currently working in or is in the same namespace as the type they were working in

rich adder
#

Yeah this makes more sense

rich adder
sour fulcrum
#

cuz someone had this exact random problem

slender nymph
#

issues with the Random class are pretty common, but it's usually due to System.Random

sour fulcrum
#

yeee, the other one wasnt which is why i asked, probably nothing

rich adder
#

Ya some times you don't even realize the System namespace is there

digital kayak
rich adder
digital kayak
rich adder
#

so many times i had VisualScripting namespaces, like what?

digital kayak
#

Like for vectors system.numarucs and unity engine

slender nymph
#

gotta pay attention to what you are autocompleting

digital kayak
#

Well gtg

#

Bye

rich adder
#

speaking of which, anyone know sometimes why using Mono.Cecil.Cil; is added ?

rich adder
#

guessing this something to do with IL or something..

raw fiber
#

can someone explain me Transform?

high solstice
#

Im spawning an enemy and it just falls through the ground here is my spawner script code (the original enemy does not fall through the ground but the enemy that spawns through the spawner does) https://paste.mod.gg/ndnocokhwnto/0

raw fiber
naive pawn
raw fiber
#

what is it=

#

what is it?

slender nymph
#

it's the component that describes the object's transformation in the scene

#

hierarchy relationship, scale, position, rotation

raw fiber
#

and what about the translate?

wintry quarry
#

that's position

slender nymph
#

that is a method on the Transform class and the documentation makes it pretty clear what it does

frozen yew
slender nymph
#

unless you literally mean "what is an object's translation" in which case, yeah, it's the position

frozen yew
#

its there

slender nymph
wintry quarry
#

the only thing I see in there is playing a particle system

slender nymph
#

it's in the second file in the link

frozen yew
wintry quarry
#

didn't realize there were two

frozen yew
#

mbmb

wintry quarry
frozen yew
#

wdym?

surreal minnow
#

I'm using DrawMeshInstancedIndirect() to render a bunch of quads with a compute buffer storing their positions. The issue is that when I need to add more positions dynamically, I have to overwrite the entire compute buffer every time, instead of just appending new points. This causes the performance to tank because the GPU buffer needs to be reallocated each time. Does anyone know what to do instead?

slender nymph
frozen yew
#

i dont know what could be causing the issue like the loop is off and the Has exit time is also off

raw fiber
#

for what does the zero stand

slender nymph
#

the 0 stands for 0

raw fiber
#

yes but why is there a zero

slender nymph
#

you should start smaller, there are beginner c# courses pinned in this channel that you should start with instead of skipping straight to learning unity if you don't know what numbers are for

verbal dome
raw fiber
slender nymph
#

okay, then let me rephrase

if you don't know what numbers method arguments are for

surreal minnow
#

I need to write to the buffer like every frame and it is not really efficient with my current method

verbal dome
#

So that you don't have to reallocate the whole buffer when it grows larger, unless you exceed the count you first set it to

verbal dome
#

Does it have to happen on the cpu?

surreal minnow
surreal minnow
verbal dome
#

Some sort of scan effect?

surreal minnow
#

Lidar effect yeah, similar to scanner sombre

verbal dome
#

Ideally you'd do that all on the GPU with some depth buffer tricks etc

surreal minnow
#

I already have it set up to render thousands of quads with a shader and it works fine, the issue is adding new positions. With DrawMeshInstancedIndirect() it seems to reallocate the whole buffer each time

verbal dome
#

Just saying that the bottleneck is often the CPU -> GPU bandwidth

#

With the current method you still need to send a bunch of data from the CPU to GPU when the buffer changes, I think

#

So optimally you would do it all on the GPU

#

But that's a bit more advanced

narrow pulsar
#

i have a ton of missing textures and im not sure why

surreal minnow
#

Yeah well I tried a few other things but it quickly grew out of my grasp. Looked into, but didnt try, buffers I could append to or doing the raycasting in a compute shader

long meteor
#

I have a script and gameobject enabling sth, where do I put inside the object its supposed to enable?

verbal dome
#

Can you rephrase that?

slender nymph
# narrow pulsar i have a ton of missing textures and im not sure why

not a code issue, but you've downloaded an asset that was made for a different render pipeline than the one you are using. you need to fix the materials so they use shaders from your current pipeline. if they are made for BiRP but you are using URP or HDRP then you will have a convenient material converter you can use

narrow pulsar
slender nymph
narrow pulsar
#

kk

surreal minnow
#

I looked into trying to raycast using a compute shader but I would have to implement raycasting from scratch
Or ComputeBufferType.Append but I am not sure if it will help

#

But it got very difficult

noble sonnet
#

anyone know how to sort this? ive deleted library and still cant get it to go away lol. was fine till i moved project and downloed from version control...

frank flare
#

How can I make the object not blink at it's spawn position? (SetActive way doesn't work because you can't teleport a GameObject in SetActive(false)

lines I have the problem with:

Rigidbody2D coinRb = Instantiate(coinPrefab);

coinRb.position = new Vector3(spawnX, 0f);
void Update()
    {
        if (Time.time > _nextDropTime ) {
            _nextDropTime += _period;
            
            float spawnX = Random.Range(_dropperStart.transform.position.x, _dropperEnd.transform.position.x);
            
            Rigidbody2D coinRb = Instantiate(coinPrefab);
            
            //coinRb.gameObject.SetActive(false);
            
            coinRb.position = new Vector3(spawnX, 0f);
            
            //coinRb.gameObject.SetActive(true);

            float flyX = Random.Range(-10f, 10f);
            coinRb.linearVelocity = new Vector2(flyX, -5f);
        }
    }
ivory bobcat
#

Try setting the position of the transform property rather than the position of the rigid body property.

#

The rigid body property called position would update the position using the physics simulation, which may occur too late and produce what you're seeing - there might not have been a physics update that frame.

#

Rigidbody.position allows you to get and set the position of a Rigidbody using the physics engine. If you change the position of a Rigibody using Rigidbody.position, the transform will be updated after the next physics simulation step.

#
coinRb.transform.position = ...```
frank flare
#

oh yeah thanks I forgot rigidbody stuff update every FixedUpdate

long meteor
#
using UnityEngine;
using UnityEngine.SceneManagement;

public class ButtonAction : MonoBehaviour
{
    public GameObject pauseMenu;
    public void QuitButtonAction()
    {
        Application.Quit();
    }

    public void ReturnAction()
    {
        pauseMenu.SetActive(false);
    }
}

anyone's got an idea why the button does not actually disable the pauseMenu?

ivory bobcat
#

Calling functions from non active objects will still operate. An object being active or not simply affects whether it's Unity callback methods would be running or not.

long meteor
#

ReturnAction which is the action assigned to onClick component of the button is not through ButtonManager object is supposed to disable the pauseMenu tree, but it does not

#

also the transitions arent working but thats not as important as that

sour fulcrum
gleaming totem
#

hello would anyone have some time to help me with making the horse jump when i press the spacebar when the horse has detected the jump?
Basically when the horse approaches a jump it will raise its head which should mean the horse is ready to jump, then press spacebar to jump. but im not figuring out why it wont jump at all :D
None of the debugs in the jump void work at all

Ill send the code if anyone is available to help also im working on 3d unity

ivory bobcat
long meteor
#

when it is enabled using esc key, which does work properly I cannot disable it using the button

ivory bobcat
polar acorn
long meteor
#

still nothing after assigning to space

rocky canyon
#

do u have a graphics raycaster on ur canvas?

gleaming totem
#

oooh i think i know the problem.

rocky canyon
gleaming totem
#

(not related to the topic)

long meteor
ivory bobcat
long meteor
ivory bobcat
#

So your button setup has probably got some issues. You may want to provide an image of the inspector of your button object (components and all)

proven osprey
#

how i fix this when i use unity version control

long meteor
#

the highlighting doesnt work either and its the case with all the buttons because quitting button also doesnt work

proven osprey
#

how i fix

ivory bobcat
proven osprey
#

i need help fixing this when i use unity version control

long meteor
#

nvm found the issue

proven osprey
#

please can i have help fixing this

ivory bobcat
wintry dew
#

I have a coding structure question: So, I want to make sure my game is suited for turning it multiplayer, although im not worried about that for now, meaning there is a player prefab and i want only its movement and the player's stats to be individualized.

However, a problem I've come accross is overusing singletons to manage. For example, I have a PlayerStatsManager, managing high scores, levels unlocked, etc. Also, I have a CheckpointManager that stores the player's last left off checkpoint in each level
However, I also have a PlayerResetManager that keeps track of the resetting of the player and the ongoing timers the player has in each level that saves when they leave mid run.

Im aware this is not a good structure, but I don't know if I should simply make a couple more singletons and have like 7 singletons, one for timer, stats, checkpoints, resetting, etc? Or if i should make one GameManager that does a lot of these things by itself.

final kestrel
#

!code

eternal falconBOT
final kestrel
slender nymph
timber tide
timber tide
#

More that you should have a list (dictionary is better for ID lookup ) of NetworkPlayers on your NetworkManager

wintry dew
#

oh thats a good idea making a player manager

slender nymph
# wintry dew not really helpful

🤷‍♂️
just preparing you for the reality of needing to refactor everything later because you decided way too late to start thinking about networking

wintry dew
#

you dont know any context and are not being helpful. This is my first time making a game and I need to learn how to do all this stuff, and my game isnt very large, it only consists of 2 scenes with very basic scripts that I have already starting remaking from scratch

slender nymph
#

you can start refactoring things now with some advice that people might give you, but it won't be enough. you'll be doing it again when you actually implement multiplayer because, again, multiplayer isn't something you can really just implement later on. it has to be planned from the very start or else it will be loads more work

wintry dew
#

ill keep that in mind

slender nymph
#

yeah so if this is your first time making a game, then ignore that multiplayer exists. you definitely do not have the experience to do it.

#

plan for your third or fourth game to have multiplayer, not your first. your first game is going to be a mess. don't make it 1000 times worse by attempting to brute force multiplayer into it later on

final kestrel
naive pawn
#

add angular drag/damping, perhaps

timber tide
#

really the hard part of multiplayer is interoplation and all that jazz, but if you stick to a strict server authority approach it's just an extra step of asking the server if they can use their input

#

and if you don't care about some client authority then let them do w/e they want with the camera since it's not like you're making the next new counterstrike

#

more conceptionally difficult in the implementation

#

Games like Risk of Rain are purely client authority, so if the client says they warped 100 units in a single frame then the server will be like "ok that's fine"

#

and tell everyone that it was legit

polar acorn
final kestrel
naive pawn
#

yeah

final kestrel
#

I think I need to add checks on my scripts and return if isPaused true.

polar acorn
final kestrel
#

Damn. I gotta go into all my scripts and add checks.

polar acorn
final kestrel
#

I should've done it from the beginning and not the end of my project. Thanks digiholic.

rocky canyon
#

u not noticed anything odd in ur scripts this whole time?

final kestrel
#

Not at all. Its my first game...

obtuse pebble
#

I am trying to instantiate a gameobject, but I am having trouble.
It appears the gameobject I am instantiating, is not being sorted in the grid layout group I have. The grid layout group is a child of a scroll rect in the canvas. Adding objects manually before startup works just fine, but it does not work when instantiated.

Not only do these gameobjects not display anything (perhaps due to the content size fitter as they are outside of the scroll rect), but they are also way outside the scroll rect and changing their transform.position does not change that. Anyone know how I fix this?

wintry quarry
#

Basically just remove that Vector3 and quaternion from the Instantiate call

#

Pass in the content.transform as a parameter instead

#

And get rid of the set parent call

obtuse pebble
# wintry quarry And get rid of the set parent call

Thanks that seemed to change their positions! Thanks for the quick response. However, both their text and their image is not being displayed.
Oh why should I change the set parent call? This code is on the GameManager gameobject. If it's not used, it just gets instantiated randomly in the scene

wintry quarry
#

As I said

#

It will be parented automatically

obtuse pebble
#

That does make sense, thanks

wintry quarry
#

Instantiate(prefab, parent)

obtuse pebble
# wintry quarry `Instantiate(prefab, parent)`

Yup, that worked. Thanks! Still I am having the issue of the text and image not appearing under the gameobjects, but that may be because I deleted the original gameobject before instantiating. Will try to find a fix

compact vine
#

hey i really need help. even though it all seems good in my inspector, my button that appears to play againg doesnt respond at all. i've been trying to debug this for like 4 hours using chatgpt and deepseek but no result. thanks!

keen owl
#

Doesn’t work how?

compact vine
#

like when i press the button it does nothing, it doesnt even show up in the logs i set up

keen owl
#

Do you have an event system in your scene? Is raycasting and button interactability enabled?

compact vine
#

there is an eventsystem and i think rycasting is enabled but i cant find it again so im not sure

#

and interactibilty is enabled

keen owl
#

Should be on the image component on your button. Ensure it’s checked. If it is, then you probably didn’t set your onclickevent correctly

rocky canyon
#

got the graphics raycaster on ur canvas?

compact vine
#

are you talking about raycast target?

rocky canyon
compact vine
#

yes i have

rocky canyon
#

i figured that'd also be one the the first things chatgpt mentioned too tho

#

just checking

#

no no other canva's are blocking?

compact vine
keen owl
#

Your script is on an active object and the raycasting isn’t being disabled at runtime right?

rocky canyon
keen owl
rocky canyon
#

have u shared ur interaction script?

#

or are u just using Events in the button

compact vine
compact vine
#

i could share my code if it helps

#

or my settings or whatever

#

tag me if you have any ideas to fix my problem thanks

rocky canyon
#

the best i can do is look at ur inspectors..
probably start a thread and share a screenshot of ur canvas selected and its inspector,
the root of the button and its inspector, the part that has the event on it.. all that stuff

#

if ur not using scripts then it has to be a set-up issue.. the question is where

#

may be beneficial to just restart on a new canvas..

#

do just a single button.. and get that working first

scarlet aspen
#

What are the best videos to learn unity coding for beginners?

#

Or youtubers

scarlet aspen
#

Yes but they don’t reccomend youtubers

rocky canyon
#

b/c thats not the best way to learn

scarlet aspen
#

Why?

solid heart
#

does someone know a good video for Inventory System with hotbar for 3d ?

rocky canyon
# scarlet aspen Why?

cuz its typically "follow me and now you have this" .. and most people learn nothing more than that

#

if they want to modify it.. they can't

#

and then they're looking for an even more specific tutorial.. which wont exist

final kestrel
rocky canyon
#

maybe look thru it

scarlet aspen
scarlet aspen
rocky canyon
scarlet aspen
rocky canyon
rocky canyon
violet cliff
#

watch then do best advice i ever herd

rocky canyon
rocky canyon
#

ive since learned better practices.. and have filled up countless of notebooks

keen inlet
#

I've been working on this snippet of code for about 3/4 hours and it STILL DOESN'T WORK... The camera is the problem, when I get in the car the camera is VERY far away from the car... Full code: https://paste.ofcode.org/7jBXkk4MUQfkCbdQURwRWi

rocky canyon
#

check the values of ur camera in inspector

#

see if they're waht u expect to see

crystal bridge
#

Hello. I'm following this tutorial (https://www.youtube.com/watch?v=-Iwsz4gdgyQ) and have received this error.

""SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
wonderCamp:Patrol () (at Assets/Scripts/wonderCamp.cs:32)
wonderCamp:Update () (at Assets/Scripts/wonderCamp.cs:27)"

"Camper1" is a human character/object that has the script and Nav Mesh Agent. "Terrain" is the painted landscape with the Nav Mesh Surface. To me, the error sounds like I didn't apply the Nav Mesh Agent to the Camper, but as you'll see in pics, I did and adjusted the layers as shown in video.

Today we're starting off a small mini series in which we make an enemy A.I. This first part focuses on making it patrol around, something that you'll want to re-use for a lot of different NPCs in most of the games you'll end up making!

get the Project here : https://www.patreon.com/posts/unity-3d-75458669

Join the discord for any help you nee...

▶ Play video
teal viper
solid heart
rotund forum
#

I'm trying to be more cognizant of how often I put methods in update or fixed update. Is using Invoke Repeating a good way to help with performance if I want to, say, only check an enemy's line of sight a few times a second as opposed to every frame?

It seems like this is the direction I should go, but I want to make sure I'm not missing something in my ignorance.

keen owl
#

how did you make a game with html exactly?

queen adder
#

Then ripped apart the mainframe from the fancy terminal. True story.

keen owl
queen adder
#

Chat is dead rn though.

keen owl
rotund forum
polar acorn
#

It's not something for you to try to "liven up"

polar acorn
#

As long as what you're doing is itself not heavy, you can do it in Update fine. If you end up hitting performance problems you cna use the profiler to try to find which specific things are causing the problems

rotund forum
# polar acorn As long as what you're doing is itself not heavy, you can do it in Update fine. ...

This function specifically checks distance, angle between player, and then raycasts (one raycast for now, potentially more towards other player body parts in the future if I choose to) to see if there is a line of sight.

I would imagine this would appropriate to put in invokerepeating?

Thank you for the response. If you have a good rule of thumb on when it would be more performant I'd appreciate that.

faint agate
#

hey guys quick question, I have a tracker for my camera for a screen effect to go from 0 to 100 based on my roation(0 to 180 on y axis) from startYRotation to 180. My goal is to have the effect really start at 20 degrees going to 180 so theres a gap from 0 to 20 on y axis where nothing happens.

    float angleY = Quaternion.Angle(startYRotation, currentYRotation);
    float lerpedDither = Mathf.Lerp(DITHERSPREAD_START_AMOUNT, ditherSpreadChange, (angleY / 4f / 180f));
polar acorn
#

If it's just math, and it doesn't involve any loops, reflection, or certain Unity methods (mostly Find and it's ilk), you're probably fine.

rotund forum
#

Thanks again for the help.

polar acorn
rotund forum
#

You can also clamp your value to start at 20 I think.

#

er

#

Wait I'm dumb scratch what I just said.

faint agate
polar acorn
#

Although it's sounding like the interpolation you do want is anything but linear, so maybe lerp isn't what you should be using at all

#

Maybe an AnimationCurve? Despite the name, they can be useful for more than just animating

faint agate
#

thats where im kinda stuck on since im keeping the start point on where the camera starts when I click play since I might decide to move the cam later

rotund forum
polar acorn
rotund forum
#

Then your anglyY would show up as 0 until after 20 degrees

#

then go from 0 to 160 instead

rotund forum
#

Prayge I try; hopefully I didn't misunderstand and make it worse for you

narrow pulsar
#

does anybody know the equivalent to on trigger entered in 2d to 3d

faint agate
rotund forum
#

Nice.

#

Glad to hear it.

mystic ferry
narrow pulsar
#

its still 2d?

#

in 3d

mystic ferry
#

Oh I thought you meant the other way.

#

Well yes in 3D it’s OnTriggerEnter.

nimble apex
narrow pulsar
#

i figured out my issue

#

i just spelled "collectible" in the tags menu wrong

#

works now

#

i thought it was the detection itself

nimble apex
#

intellisense cant help string typo tho 💩

slender nymph
surreal brook
#

Hello, I'm making a 2D game and I want to put a bunch of trees around the border of the environment and throughout it to make a maze-like forest. However, it seems inefficient to create a game object for every tree so I was wondering if there's a way to do this within the script. I came across the terrain system but it looks like that's for 3D only

teal viper
surreal brook
#

Performance, but maybe I'm wrong. Is it normal to create a game object for every tree?

teal viper
#

That being said, In 3d, you'd usually use the terrain system. In 2d tilemaps or something.
But big number of objects in 2d is not as critical as in 3d as most of them would be frustum culled.

#

Using tilemaps is a solid approach if you are worried.

surreal brook
#

Ah, a tilemap makes sense. Thanks, I know what I need to do now

frigid sequoia
#

Would an OnSceneLoaded trigger AFTER all the awakes of the scene?

hardy ibex
#

how should i go about pathfinding for a 3d tower defense game?

sour fulcrum
#

I’ve just used navmesh in the past

#

Just bake the paths enemies can move on

timber tide
eternal needle
hardy ibex
#

so how should i do it then

#

i mean i have a small test set up with a navmesh that seems to be working ok

eternal needle
#

A path can simply just be a list of positions. When I think of tower defence I think of like the bloons tower defence games. If you want enemies to move along the exact same path I'd just define it with a list

#

If you want it to be more random, I guess kinda like zombies then navmesh can work

#

Depends on what kind of game you want

hardy ibex
eternal needle
eternal needle
#

And you'd need some logic to actually increment current point but yea

hardy ibex
#

so this is good i should just define the list somewhere else like in an SO?

eternal needle
#

Scriptable objects cant reference transforms in your scene so this will likely just be a monobehaviour

timber tide
#

I'd say just use it for the local avoidance, but it's pretty bad

sour fulcrum
#

eg. this thing i made in december that just bakes for the enemies on these track prefabs

#

you can def. do with points and depending on the game might be better but your placing the path like this anyway you may-aswell use those paths directly

#

(and in this case you can use it in the opposite way where we sample navmesh position to prevent placing turrets on the track)

hardy ibex
#
using UnityEngine;

public class pathFinding : MonoBehaviour
{
    private navPointsList navList;
    public float speed;
    private int currentPoint = 0;

    void Start()
    {
        navList = GameObject.FindGameObjectWithTag("navPointsList").GetComponent<navPointsList>();
    }

    void Update()
    {
        
        if (navList.navPoints.Count > currentPoint + 1)
        {
            Vector3 targetPosition = navList.navPoints[currentPoint + 1].position;

            
            Vector3 currentPosFlat = new Vector3(transform.position.x, 0, transform.position.z);
            Vector3 targetPosFlat = new Vector3(targetPosition.x, 0, targetPosition.z);

            
            float step = speed * Time.deltaTime;
            float distance = Vector3.Distance(currentPosFlat, targetPosFlat);

            if (step >= distance)
            {
                
                transform.position = new Vector3(targetPosition.x, transform.position.y, targetPosition.z);
                currentPoint++;
            }
            else
            {
                
                Vector3 direction = (targetPosFlat - currentPosFlat).normalized;
                transform.position += direction * step;
            }
        }
    }


    Vector3 dirToPoint(Vector3 point)
    {
        Vector3 dir = (point - transform.position).normalized;
        dir.y = 0;
        return dir;
    }
}

i got something working @eternal needle

sour fulcrum
#

(you can just do Object.FindFirstObjectOfType<NavPointsList> btw)

sour fulcrum
#

kinda nitpicking dw 😄

eternal needle
#

you should just use a singleton instead of either of those

hardy ibex
#

(i have like 1 week of game dev experience)

eternal needle
#

it is a pattern to access a component when there should only be one, google to find implemenations in unity

#

its not specific to game dev

hardy ibex
#

ok well i dont have much coding experience before anyway

#

but ill look into that

noble rover
#

No idea where to put this issue so putting it here, having issues with unity editor not following my mouse while in edit mode it works fine if I hold down right click or go into play mode its 1000% not a code issue its some sort of setting in unity anyone know how to fix?

keen owl
#

Make sure to lock that

noble rover
noble rover
#

fixed it had to make my own script lol

sharp bloom
#
void GetRandomPos()
{   
    var pair1 = GaussianRandom(0, 1);
    var randomX = pair1.x;
    var randomY = pair1.y;
    var randomZ = GaussianRandom(0, 1).x;

    randomX = randomX * 1 / Mathf.Sqrt(Mathf.Pow(randomX,2)+Mathf.Pow(randomY,2)+Mathf.Pow(randomZ,2));
    randomY = randomY * 1 / Mathf.Sqrt(Mathf.Pow(randomX,2)+Mathf.Pow(randomY,2)+Mathf.Pow(randomZ,2));
    randomZ = randomZ * 1 / Mathf.Sqrt(Mathf.Pow(randomX,2)+Mathf.Pow(randomY,2)+Mathf.Pow(randomZ,2));

    newPos = new Vector3(randomX* moveRadius, randomY* moveRadius, randomZ* moveRadius);
  
}


Vector2 GaussianRandom(float mean, float standardDeviation)
{
    float randomX = Random.Range(0f, 1f);
    float randomY = Random.Range(0f, 1f);
    var scale = standardDeviation * Mathf.Sqrt(-2 * Mathf.Log(randomX, 10));
    var theta = 2 * Mathf.PI * randomY;
    var randomPos = new Vector2(mean+scale * Mathf.Cos(theta), mean+scale * Mathf.Sin(theta));
    return randomPos;
}

If someone knows math better than me: this is some box-muller algorithm that produces a pair of random values, I use it to move an object randomly within a certain radius.

I roughly understand how it works, but why is it producing points exactly on the sphere radius? I wanted an even distribution.

sharp bloom
#

Many such cases 😆

stray wigeon
#

Hey! I have a question about how to code a trail that the player leaves underthemselves in my small project. So, my player has a limited resource that they collect at certain checkpoints, the amount of that resource determines how much the player can move. If the player runs out of said resources, they die. I want the player to leave a path behind them out of said resource (visually) every time they move. The path they "paint" stays on the map until they die or get to the end. Where would I start? Can't find any similar guides online other than trails (bullet trails, FPS dash trails, etc etc)

teal viper
stray wigeon
teal viper
stray wigeon
#

Got it. I'll check it out. Thanks!

frozen yew
#

hey so im making a multiplayer game but for some reason when 2 players are connected i am controlling both of them at the same time and i tried turning off the main camera and the player movement script like it said in the video i was following but it dosent seem to be working

https://paste.mod.gg/vdjvqlelrayt/2

thorn trout
#

so I am shifting from godot to unity and had a question regarding the physics bodies

In godot its largely preferred to use character bodies for custom controllers since rigidbodies could work unexpectedly whenever we set physics values directly

So most of the time we see people using character bodies in godot while most of the time whenever I look up tutorials in Unity I only see them using rigidbodies and implementing it like they are characterbodies instead

Is that safe and is it recommended? Should I just stick to characterbodies if I don't want physics? I wanna know. Thanks in advance

#

Also what problems could arise when using rigidbodies like characterbodies i.e, directly setting their values frequently

umbral bough
#

Hi, I would like to add a property to the UnityEngine.Timeline.TrackAsset but I can't figure out how.
According to Rider, it's not defined as partial, however, if I go to it's code on gh it's partial.
I am using Unity 6 with the latest version of the Timeline package.
What am I supposed to do?

naive pawn
#

unity's rigidbody is the thing that interacts with the built-in physics system, anything else would have to do physics on its own, for example the charactercontroller, or implemented yourself
rigidbodies also have 2 modes, dynamic and kinematic, where dynamic receives forces while kinematic does not. perhaps that's the distinction you're thinking of?

naive pawn
umbral bough
chrome wadi
#

I don't know what I'm doing wrong. Movement works. Cursor toggle also works but my look action doesn't work I don't even get log in the console

public void OnLook(InputAction.CallbackContext context)
{
    if (third_Person_Camera != null)
    {
        Debug.Log("Rotate Camera");
        third_Person_Camera.OnLook(context);
    }
}

public void OnZoom(InputAction.CallbackContext context)
{
    if (third_Person_Camera != null)
    {
        Debug.Log("Zoom in or Out");
        third_Person_Camera.OnZoom(context);
    }
}

public void OnToggleCursor(InputAction.CallbackContext context)
{
    if (third_Person_Camera != null)
    {
        Debug.Log("Toggle Cursor");
        third_Person_Camera.OnToggleCursor(context);
    }
}
naive pawn
umbral bough
naive pawn
chrome wadi
naive pawn
#

....and?

chrome wadi
#

the same ^^

naive pawn
chrome wadi
#

thanks

naive pawn
# umbral bough

so it should probably be public, but it might have to also be in the same assembly

#

so you might just be fucked

#

anyhow this is definitely not a beginner topic, so if you still have issues and you're determined to go this route, try #archived-code-general

shy edge
rare basin
#

I have a weird issue with animator, so I want to achieve some kind of my own root motion, by modifying transforms to match the animation movement, and it works perfectly fine BUT only after i turn off and on the animator in the inspector. If I don't do that, then my character just goes crazy and bugs out and goes forward instantly. If i turn off and turn on the animator and then play the animation, everything works fine, why is that lol

void LateUpdate()
{
    if (animator == null || agent == null) return;

    var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
    bool isCurrentlyAttacking = stateInfo.IsName("Attack") && stateInfo.normalizedTime < 1f;

    if (isCurrentlyAttacking)
    {
        agent.updatePosition = false;
        enemy.position = defCharRoot.position;
        agent.nextPosition = enemy.position;
        
    }
    else
    {
        agent.updatePosition = true;
    }

    rigParentHolder.localPosition = -defCharRoot.localPosition;
}
verbal dome
#

See !code

eternal falconBOT
shy edge
verbal dome
#

I do recognize this part though... 😥

shy edge
#

Oh Jesus I didn’t realize it got that compressed mb

verbal dome
shy edge
#
using UnityEngine;

public class PlayerCamera : MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

     private void Start(){
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
     }

     private void Update(){
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
     }
}
verbal dome
#

` <--- backtick

#

Ok now add a new line right after the first cs so it gets formatted

shy edge
#
using UnityEngine;

public class MoveCamera : MonoBehaviour
{
    public Transform cameraPosition;

    // Update is called once per frame
    void Update()
    {
        transform.position = cameraPosition.position;
    }
}
verbal dome
#

There's a space between cs and newline

#

Anyway, start with fixing the mouse, it will otherwise get jittery

shy edge
#

Alr

verbal dome
#

Should it be a first person camera?

shy edge
#

It is supposed to be a first person camera

#

My problem is that it keeps teleporting away from where it’s set

verbal dome
#

Its local position doesn't seem to be changing when you press play

#

So it's the parent (cameraholder?) that is being moved

verbal dome
shy edge
#

yes

verbal dome
#

What transform is assigned to cameraPosition ?

shy edge
#

the camera position object i have in my player object

verbal dome
#

Im guessing it's not centered properly

shy edge
#

this is where its at in the player

verbal dome
#

Set its localpos to zero

shy edge
#

fixed thanks

#

now i just need to figure out why the camera starts by looking at the ground

sand mesa
#

project file lost its unity qualities

#

and I forgot how to repair it

polar acorn
eternal falconBOT
sand mesa
#

that doesnt help me

#

the other project file DOES adhere to unity ide

polar acorn
#

Your IDE is unconfigured, it's a guide on configuring it.

#

That's exactly what you asked for.

viral glen
sand mesa
polar acorn
#

So, maybe actually read it before deciding it isn't what you want

sand mesa
#

look what worked for me last time involved the solutions for VS

frank flare
#

which one is not the impostor?

naive pawn
#

if you want coroutines, you'll want the non-generic one

frank flare
#

ok

livid rock
#

Hello guys ! I'm trying to make something really simple :
Have a VideoPlayer that takes an URL to my remote server that hosts a video
Play the video

But I'm getting this error :
WindowsVideoMedia error 0x80004004 while reading <myURL>

Context: IMFSourceReader::WaitForSample in StepAllStreams
Error details: Op볡tion abandonn맍

The video file seems fine since it works if I put it directly in Unity.
The weird thing is that it sometimes work, sometimes doesn't...

Any ideas what could be the root cause ? Or how to solve this ?
If someone worked with remote mp4 files before, is there a better option than then native videoPlayer ?

sand mesa
#

I tried regenerate project files in the external tools preferences and it doesnt work

frank flare
#

how can I compare layer (int) to ground (LayerMask)

naive pawn
#

yes, that's how bitfields work

naive pawn
frank flare
naive pawn
#

remember, it's not a layer, it's a layer mask

#

a mask of 64 is a layer of 6

polar acorn
# frank flare

Yes, that's what the mask representing layer 6 is when cast to an int

#

A layer mask is essentially an array of booleans stored in a number. You want a mask that can let through layers 3 and 4 but no others?

0000 1100

It's got a 1 in the third and fourth position, so it's got a value of 12

#

So, to check if your layer is in the mask, you need to do some bit shifting. Your layer is index 6, so you need a 1 in the sixth position. You can do this with the "Shift left" operator <<.

1 << n will produce a binary value of a 1 in the nth digit and 0s everywhere else. Then you can use & to compare it with the mask.

#

This'll give you a value that has 1 in every spot present in both the mask and the shifted layer. Since there's only a single 1 in the shifted layer, any int with a value larger than 0, means the mask contains that layer

frank flare
#

if ((mask & (1 << layer)) == 6)

#

would this work

#

nvm it wouldn't

polar acorn
#

It's not going to equal 6, it's going to equal 64

#

It'll have a 1 in the sixth digit, which is 2^6 which is 64

#

As I said, check if it's larger than zero not equal to zero

#

that's all you need to do

naive pawn
#

but really you shouldn't care about what position is there, you just care if there's overlap

#

check if it's not equal to 0, like the link boxfriend sent says. it's an int, not a uint

polar acorn
naive pawn
#

i mean, reasonable assumption, tbh.

polar acorn
#

I feel like it should be, since it's a mask. We don't need to bring twos complement into this

naive pawn
#

to be pedantic; bitwise stuff usually treats the lowest position as bit 0, not bit 1

#

bit n has a value of 2^n

polar acorn
#

I probably wasn't fully clear on that though

naive pawn
#

i assumed that was what you were going for, just felt like adding that footnote 👍

final kestrel
#

Hey all. I have a question... I am doing a pause game feature in my game. I have lots of coroutines that yield WaitForSeconds. And setting Time.timeScale to 0 makes my coroutines act weird. I have done some research but want to know what exactly is happening. When I pause the game on WaitForSeconds, unity does not keep track of where it was and skips counting and to the next line of code?

rich adder
#

if you don't want that then you would use WaitForSecondRealtime

final kestrel
#

When I unpause the game then? It skips waiting completely?

#

I am using a time that I increment with Time.DeltaTime now to solve that. And it works.

rich adder
#

yea deltaTime is just the amount between frames

#

not related to timescale nvm you need unscaledDeltaTime

final kestrel
#

Yeah I see. I am just confused what happens when I unpause inside the WaitForSeconds.

#

by setting Time.timeScale to 1 i mean by unpause

rich adder
#

You mean you're expecting to resume ?

final kestrel
#

Well I expected it to resume from where it left off yeah

rich adder
#

afaik just the way IEnumerator work, pretty sure it completely stops at the yield

final kestrel
#

So what is even the point of using WaitForSeconds?

naive pawn
rich adder
#

Time between frames? why would it

naive pawn
#

Time.unscaledDeltaTime

Unlike deltaTime this value is not affected by timeScale.

rich adder
#

ahh

polar acorn
rich adder
#

im wrong then

final kestrel
#

It will be at 0 when the game pauses though and start counting again then?

polar acorn
#

that is, in fact, all that TimeScale does

naive pawn
rich adder
#

forgot unscaledDelta was a thing UnityChanSorry

#

yeah idk why I was confusing it with update loop ig

naive pawn
final kestrel
#

Well all right. I need to know about all the time stuff. Thanks for the answers.

rich adder
#

makes sense now idk why i found out this many years later 🥵

polar acorn
naive pawn
#

wouldn't physics stuff use fixedDeltaTime

final kestrel
#

damn this is hard...

naive pawn
polar acorn
verbal dome
final kestrel
#

I think I pushed gpt a bit too far...

naive pawn
#

"push gpt a bit too far" happens the instant you trust it

rich adder
# verbal dome That's configurable

oof that makes a lot of sense now lol I never touched those but I do remember timescale was affecteing it but just now realized it was just using deltaTime

rich adder
#

I never use yield classes for time anymore

#

just creating an extra allocation object for no reason
(no big deal creating it once, but in a while loop?)

verbal dome
#

You might want to for example keep animating your UI at normal rate even if the game is paused or you are in a slow mo sequence

rich adder
#

This would've been quite handy when doing black screen fade outs and timescale was 0 😭 ended up doing some hacky shit

rich adder
#

or ig now Time.unscaledDeltaTime for your timescale being 0 😄

final kestrel
#

Yeah I did something similar to this. Its okay now. I was just confused about the execution when used waitforseconds and like pause and unpause my game

final kestrel
#

I figured that much now hahaha.

atomic trench
#

hey, im about to create an idle 2d text/graphic game

Now i need to create a level counter for my character that is displayed and goes up when earning xp

Im also willing to put in the learning to do this by myself instead of using chatgpt. Where can i learn the specific programming that i need for this for example?

rich adder
polar acorn
#

!learn and the pinned C# courses

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

and yes stay away from GPT while you're learning

atomic trench
rich adder
#

eg counting numbers, doing arithmetic in code, something that benefits any game you make

frosty hound
#

There is nothing unique to an idle 2d text/graphic game that could not be used in any other game. You won't find specifics to learn.

polar acorn
frosty hound
#

Break down the aspects of your game, and look those up with a general statement. "How do I make a button".

atomic trench
#

damn i thought i could avoid all the hundreds of hours coding :/

polar acorn
#

You won't make a game by just "what's the code for this specific thing" over and over

#

you need to get to the point where you can take an idea you've never seen before and then implement it

#

otherwise, your game will, by definition, never be unique in any way

#

if it's all just re-used code, it can never be better than the tutorials you copy from

rich adder
atomic trench
#

yea i need to overthink this as an idea then maybe

Cuz doing this on the side while my main job is not coding/computer/Tech at all lol

hmm

rich adder
#

thats why those LLMS memorize all the code that exists but its useless because the machine cannot think and reason as we do

#

you can know the whole documentation, code syntax, in and out, without reasoning and logic its useless

atomic trench
#

had an insane idea for a nice idle game in melvor style with shakes and fidget elements and revolutional idle, but yea rip

thoughts are bigger than possibilitys, rip

polar acorn
#

Or you could actually try to learn

rich adder
#

there is a saying
"eyes bigger than one's stomach"

polar acorn
#

Again, don't try to code for a specific end product. Just get what you currently have one step closer to what you want, and eventually it'll reach somewhere. That somewhere could be drastically different than where you originally started

#

but if you just keep walking, every now and then you find yourself in a different place

atomic trench
#

honestly the intention was "lets learn only what i need for this game, finish it and thats it"

sadly not the ambition to really learn how to code fully D:

#

atleast im honest

#

xD

#

and a lazy dog

rich adder
polar acorn
atomic trench
#

i was just bored that i couldnt find a game to play that offers a lot content/playhours and survival/automation

so i thought that ill give it a try, but nahh

#

ill go look for a game or just quit for now gaming lol

rich adder
#

thats crazy the market is oversaturdated with idle games

#

how can you not find one that similiar

lucid quiver
atomic trench
rich adder
#

they are boring cause the bar is pretty low

#

idle game are next to brain rot

atomic trench
#

didnt like factorio as the ressources are drying up and i dont like moving my machines every 2 minutes

polar acorn
#

Just let the robots do it

lucid quiver
#

people don't like playing their own games

atomic trench
#

yea, guess i have to try to find a game that i can play :/

hearty garnet
#

you could try some older game tho :/

#

megaman maybe

lucid quiver
#

try some classic indie games like rainworld or hollow knight

atomic trench
#

all i wanted is something factorio/palworld like

idle game is fine, but a real survival game is better

i mean even minecraft has survival + automation via redstone somehow xD

lucid quiver
#

or else just play terraria ig

rich adder
#

terraria is great

verbal dome
atomic trench
#

damn im old

verbal dome
#

I wasn't suggesting games, just listing the ones you just mentioned lol

polar acorn
#

I mean, you can still make a game. You can just do the learning

#

If you're looking for stuff to spend time on, you could use it developing a skill

lucid quiver
#

i mean if your bar is as high as palword and minecraft ...... thats gonna take you ages to learn to build a game that complex

atomic trench
#

not sure if the frustration from not finding a game gets better while learning programming and doing my own game, which i then probably wont even play since i created it myself xD

i guess i just take a break and look for games on steam

maybe imma find something

rich adder
lucid quiver
#

someone link him the textmeshpro doc

hearty garnet
#

btw i was working with override controller and was having some problems. When i try to override a loop animation with a no loop animation, the AnimatorStateInfo.loop still return true for some reason. It seem like AnimatorStateInfo.loop always base on the base animation clip and not the override clip

queen adder
#

General Question: 2D Top Down Game / Player faces Up -> Now the player wants to go down. How hard it would be to make it so that the player can't go down instandly, he have to make a little turn, like in a 3d third person game.

#

I didnt find anythink on youtube

rich adder
queen adder
#

okay i will try, would be nice if it's that easy

verbal dome
#

I'd just use Mathf.MoveTowardsAngle to change the Z angle of your transform

#

RotateTowards could mess with other axes than Z

queen adder
#

okay thank you

graceful jasper
#

i have a set number of character prefabs a player can switch between in a game and i need to save the character's currently-selected character to a file so it can be loaded when the game starts up. what would be best way to store a reference to the prefab? should i have a serialized list of each prefab and then just save the index of the active character or is there a better way of doing this?

verbal dome
#

Index is the simplest way, but it breaks if you ever insert/remove characters in the prefab list

#

So you could instead use some other identifier like a unique integer/enum or string for each character and use that for lookup instead of the index

orchid fern
#

Hi, I'm new.
In unity can someone help me how to make a save system in unity that saves the state of everything, because i just found a tutorial on the internet that saved a variable, but i need the details to have all game objects and all scripts inside them saved in js code

rich adder
#

wdym by " all game objects and all scripts inside them saved in js code"

#

js code?

polar acorn
naive pawn
#

...json?

orchid fern
#

yes js code sorry

rich adder
#

like javascript?

naive pawn
#

json is not js code

orchid fern
rich adder
orchid fern
#

Okay then what is the solution.

polar acorn
rich adder
# orchid fern Okay then what is the solution.

an examplecs [Serializable] public struct SaveData{ public string CoolString; public int SomeNumber; //etc. }

        SaveData saveData = new SaveData()
        {
            CoolString = "coolBeans",
            SomeNumber = 66
        };
        var dataJson = JsonUtility.ToJson(saveData);
        File.WriteAllText(path, dataJson);```
orchid fern
#

ok thanks but if I want to save the game objects and stuff

rich adder
#

you dont typically save the entire gameobject

#

but its "state"

cosmic quail
#

i think he wants to save everything automatically without making these extra classes and stuff

rich adder
#

like an entire MB ?

#

idk but I dont see the point in that

#

you have a prefab with all the components then you just put the values as they were

cosmic quail
#

there are also assets on the asset store that make saving easy but i think they cost money

eternal needle
rich adder
polar acorn
rich adder
#

if you gameobject was SetActive(false)
You would store a bool
public bool IsActive or something

#

ideally this way everything is clear on where it goes

#

if you have items that you need to pickup that dont spawn after you already picked up then you start dealing with things like GUID etc

orchid fern
#

ok I will take your advice

graceful jasper
verbal dome
#

You can always generate a dictionary for faster lookups too, but it doesn't really matter if you only have a few characters and it doesn't happen often

#

Another option is to have a list of structs/classes that contain the ID and the prefab

graceful jasper
#

ooo. yeah, that might be a better option

raw fiber
#

hey guys,

#

how can i programm that if a specific button is pressed a sound will play?

slender nymph
#

did you google it first?

rich adder
#

which button. UI ? Keyboard?

#

lookup how to tie methods to button onClick or GetKeyDown respectively

raw fiber
#

keyboard

rich adder
#

okay so "How to detect keyboard specific key press Unity"

#

in google

raw fiber
#

i know how to programm button press event but not how to tie a sound to it

thorn trout
#

why in unity characterbody when I do
velocity.y += gravity
my obj flies upward even when gravity is +9.18 and even when its -9.18
but it works as expected when I do -= gravity

rich adder
#

put the two together

thorn trout
verbal dome
eternal falconBOT
verbal dome
#

(I assume you mean rigidbody)

thorn trout
# verbal dome Show your !code

I am using characterController sorry not characterBody

# movement direction is velocity and gravity is 'gravity'

 private Vector3 velocity;
 public float gravity = 9.81f;

# Inside fixedUpdate
velocity.y += gravity * Time.fixedDeltaTime
characterController.move(velocity * Time.fixedDeltaTime);
#

here, since gravity is positive, its supposed to go upwards

#

but even when I change gravity to a negative value, it refuses to go down and instead chooses to fly up

#

I can only make it fall down by doing velocity.y -= gravity

#

and I don't understand why it does that

polar acorn
polar acorn
#

Python comments

quick pollen
#

ohh

thorn trout
#

sorry I just shifted from godot

polar acorn
#

Which means this code isn't copied from the script

quick pollen
#

also isn't gravity meant to be a negative force?

polar acorn
#

So we still don't actually know what is happening

raw fiber
#

can anyone send a script for the audio button thing

polar acorn
#

That's it that's all the code

raw fiber
#

ok

#

@polar acorn wich of the code do i need to copy im new to programming

polar acorn
#

So, do you know how to detect a button press?

raw fiber
#

yes

polar acorn
#

So, you'd just call Play on the audio source that has the sound you want

raw fiber
#

how do i transfer a video audio into a audio

polar acorn
#

I have no idea what this means

quick pollen
quick pollen
#

like slicing the audio out of a video

raw fiber
#

can someone explain again how a button press event with a if statement works i forgot it

#

i learned it yesterday and now i forgot it

polar acorn
#

why did you keep saying you did

raw fiber
#

i knew

#

because i knew it but then forgot it

quick pollen
raw fiber
#

yes now i remember

#

thanks

quick pollen
#

ur welcome :)

#

its okay to forget

#

gotta practice more

raw fiber
#

im very new to all this

#

yes defently

quick pollen
#

id suggest making like a notebook

#

or to use Obsidian to take notes

raw fiber
#

yes

quick pollen
#

obsidian is very satisfying to use

#

i use it to take notes on databases

raw fiber
#

i will try

quick pollen
#

you could use it for unity

raw fiber
#

i can give objects tags

#

how can i use the tag in my code again?

quick pollen
#

GameObject.CompareTag("tagname")

raw fiber
#

i put the sound as a component on a empty game object

quick pollen
#

GameObject is just there to specify

raw fiber
#

and gave the game object a sound#

#

tag

#

im using a if statment for the key event

#

how do i let the sound play now

quick pollen
#

if you need help with codint later, posting the code you actually have a problem with helps

raw fiber
#

im very sorry i dont want to nerve you but yes

quick pollen
raw fiber
#

if (Input.GetKeyDown(KeyCode.Space))}
Mehmet.

#

thats my code from now

#

in void update#

raw fiber
#

i dont understand the doc

quick pollen
slender nymph
# raw fiber i dont understand the doc

you should really take the advice that has been given to you a few times now and stop what you are doing and go through the unity !learn pathways to learn how to actually use the engine

eternal falconBOT
#

:teacher: Unity Learn ↗

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

quick pollen
#

lmao

raw fiber
#

what is the audio clip called like the file or what?

rough lynx
#

If you don't know that and yet are still trying to play a sound I would learn before taking the advice given above

keen owl
rough lynx
#

I worded that really badly

#

I meant take the advice above

quick pollen
#

(guys be nice we dont want to create another "vibecoder" lmao)

mystic ferry
quick pollen
#

basically not giving a shit and just copy pasting

mystic ferry
#

I should make a vibe code game to see if it’s possible then.

#

Ai generate the art too.

quick pollen
#

cant see why it wouldnt be possible, if not annoying

#

and flavorless

mystic ferry
#

It’d probably be a pain trying to explain to the AI why the way it’s doing something is wrong.

quick pollen
#

exactly

mystic ferry
#

Someone probably made a YouTube video of this already.

quick pollen
#

they say there are "ai debuggers" that just fix your code

#

but i think thats a bit too optimistic

mystic ferry
#

I use Claude to help me find out where tough bugs are coming from though and it’s pretty good.

#

Like I’ll give it a script and it’ll give me a list of things that could be going wrong.

#

And then I look there.

quick pollen
#

i mean

#

i dont recommend it

#

but have fun ig

mystic ferry
#

It hasn’t really given me any problems.

quick pollen
mystic ferry
#

I knew someone would have done it.

keen owl
#

AI is excellent if you already know the basics of overall programming and how it works. You can’t expect to use AI if you don’t for example understand methods or datatypes. Aside from that, it’s very powerful

rancid tinsel
#

If you wanted to store "components" as data, but keep them generic, what data type would you use? Monobehaviour?

#

Like if I wanted to make a FactoryObjectData scriptable object to hold components that a builder pattern would attach

quick pollen
#

@mystic ferry technically AI could be using copyrighted stuff to provide you code

#

so theres that risk

eternal needle
quick pollen
#

altho how thatd work legally is beyond my scope

mystic ferry
#

Can you even copy right little bits of code?

#

Like obviously you can copyright a whole program.

#

But like can you claim a script and say only I can do this?

quick pollen
mystic ferry
eternal needle
#

this is a help channel for coding, not for off topic. @mystic ferry @quick pollen

quick pollen
rancid tinsel
#

Is Component a type tho? I didn't know that

eternal needle
#

Monoscript is a part of unity editor. You cant use it in a build

rancid tinsel
eternal needle
verbal dome
rancid tinsel
verbal dome
#

There is also [SerializeReference] which would let you store non-monobehaviour objects that share a base class or implement an interface

rancid tinsel
#

Could you give an example if you have one

eternal needle
#

It sounds like you want to serialize a type, which so happens to be a component

#

Havent really done it myself but you could probably get away with an enum, and map that to the actual Type in code

rancid tinsel
#

If that exists

#

I'm asking out of pure curiosity though so don't waste too much time on me 😅

eternal needle
#

serializing the type means you want to choose the type in inspector. it's not something built in so you'd have to do some funky workaround like making an enum and mapping all the enums to the correct type in code.

#

At the same time, you might be overusing the inspector if you actually need to do this

rancid tinsel
#

Yeah its likely not needed

#

Ill have a play in a second and see what i could come up with

#

Chances are I'm overcomplicating

sour fulcrum
#

I know it’s a general and generic question but an example would help contextualise an answer since this kinda thing does pop up from time to time and runs up against the walls of what Unity provides and/or what c# is designed to ideally be used for

#

For one game I made i used a scriptableobject class per card game “card” and said class uses inheritance and inspector serialisation to handle the standard stuff (name, icon, cost etc). But to handle the logic of the card in code, defined in the class itself.

Then I made a little editor script where on assembly reload it checks if any types inheriting from by BaseCard exist in the project that don’t have an instanced scriptableobject created and then creates one for me which created a pretty nice workflow for creating these one off scripts that can be drag and droppable and whatnot

#

I wonder if something similar could be used for you but with a ScriptableObject<T> where T is your stored type

#

You can define custom script templates which can massively reduce the time needed to write out the boiler plate of defining the generic so https://www.youtube.com/watch?v=TYRhlOHO_Xk

// Update is called once per frame
I freaking get it, stop showing me!

Don’t put up with the standard Unity templates, make your own! Change the default content in created assets.

Go sub to Jason Storey: https://www.youtube.com/c/JasonStorey

❤️ Become a Tarobro on Patreon: https://www.patreon.com/tarodev

=========

🔔 SUBSCRIBE: https://bit.l...

▶ Play video
#

Slightly more engineered than something like an enum but might feel abit nicer in terms of managing it and inherently associating your data to class connections rather than explicitly in some dictionary or such

eternal needle
#

That doesn't really sound the same as to what they were asking. Theirs was more just serializing a type. What you're describing is reflection to create instances of objects
Doing that in this case would be very questionable. It's really better to just define it manually through an enum if needed or just use deriving classes.

#

Im not really sure what the suggestion of generics even helps at there

sour fulcrum
#

I might be mistaken but I assumed them asking for a way to have a scritpableobject define types that a builder pattern could “attach” would require creating instances of those types so I figured using generic scriptableobjects would allow a nice way to serializable a “type” (just being able to drag and drop the so around), define the type it would create via the generic and allow the scriptableobject to potentially handle the process of creating, initialising and attaching the given type if necessary

eternal needle
#

the generic part does nothing there unless you're actually making a deriving class. What you're suggesting would be making an asset AND class for each type. sure it can be done through code, but there are a shitton of components. If the person whitelists/blacklists components, then might as well just have an enum and define it through code anyways

timber tide
#

Unity provides little for serialization as far as c# goes. But by the sound of it youd probably would like serialized references if you wanted more defined types insertable into the editor, but that requires some loops to jump through too.

crystal bridge
pure pike
#

how would i calculate it so it would messure how far right/left an object is from another object, and display that on a text object?

earnest wind
#

how can i know how many lines the "AAA" text is? since we need to take in mind that characters can be longer than normal, and its a different font, and there is a boundary for it, and its a specific size?
I itred doing textinfo.linecount but that would get me 1 everytime

bright osprey
earnest wind
#

nvm me

#

i found fix

#

i had to update text mesh

crystal bridge
#

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
wonderCamp:Patrol () (at Assets/Scripts/wonderCamp.cs:39)
wonderCamp:Update () (at Assets/Scripts/wonderCamp.cs:34)"

Cylinder is assign the same script and IS doing what I want the Camper to do

grand snow
swift elbow
teal viper
#

And navmesh would often be a bit different than the surface, so if you snap the agent to the surface, it's gonna be out of the navmesh.

teal viper
swift elbow
crystal bridge
teal viper
crystal bridge
teal viper
#

And by "from the start", I meant it could be assigned at editing time.

humble rain
#

hi, i want to ask Can I use RX 9070 XT for Unity development ? Will the card work ?
I mean the card is so cheap compare to nvidia alternative ? Will I get into trouble ? Will the card work with Maya and Substance Painter, Zbrush as well ?

wintry quarry
polar acorn
humble rain
#

i see, the more vram the better right ? RX 7900 XT got 20 gb of vram but same price with 9070 XT at here. Which one should i pick ?

faint agate
#

hey guys, for example I have a script that has a float = 7. I have two scenes and on scene one, I want that float to be 7, but on scene two I want that float to be another number like 9. is there i can do this without creating another script?

#

I made the float a [SerializeField]

wintry quarry
polar acorn
humble rain
polar acorn
#

You could run Unity on an intel integrated graphics card

#

You just need a GPU powerful enough to run the thing you want to make

sour fulcrum
faint agate
polar acorn
wintry quarry
sour fulcrum
wintry quarry
#

Show what you tried

faint agate
wintry quarry
sour fulcrum
#

I’m being specific with my wording here, One script, multiple instances of it

#

The script is a blueprint of a house and the actual houses on your street are the instances

faint agate
#

i feel like im making a simple mistake. This is where im changing the number, when I switch to scene two. It goes to the number I set in scene one

wintry quarry
polar acorn
wintry quarry
#

Show the code, for example

polar acorn
#

You still haven't answered me

wintry quarry
polar acorn
# faint agate sorry, no

Then you would do the following:

  1. Load the first scene
  2. Set the variable you want for scene 1 in the inspector to the value you want.
  3. Load the second scene
  4. Set the variable you want for scene 2 in the inspector to the value you want.
spiral oracle
#

so my buttons are appearing outside of the canvas and I'm wondering how to move UI elements with a script

using UnityEngine;

public class Actions : MonoBehaviour
{
    public GameObject actionButton;
    public GameObject canvasHierarchy;
    public GameObject actionHierarchy;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        AddActionButton(4);
    }

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

    }

    public void AddActionButton(int numberOfButtons)
    {
        if (numberOfButtons > 4)
        {
            numberOfButtons = 4;
        }

        int buttonY = -194;
        int[] buttonX = new int[4];
        buttonX[0] = -664;
        buttonX[1] = -218;
        buttonX[2] = 218;
        buttonX[3] = 664;

        for (int i = 0; i < numberOfButtons; i++)
        {
            GameObject newActionButton = Instantiate(actionButton);
            newActionButton.transform.position = new Vector2(buttonX[i], buttonY);
            newActionButton.transform.SetParent(actionHierarchy.transform, true);

        }


    }
}
faint agate
polar acorn
#

Unless you had code that actually changed it after the program runs, in which case, why expose it in the inspector at all

gaunt cipher
spiral oracle
#

thanks though

compact lodge
#

Quick question, does anyone know where or how I can do a VN dialogue system with stuff like choices (that can do things like call scripts), in a way that doesn't rely on C# code for the actual dialogue itself?

#

Trying to figure out how to approach RPG dialogue text that can do that kind of stuff, but I don't want to hardcode stuff.

compact lodge
#

Sweet, will have to check it out.

versed light
#

how do you give a game object a custom bounds size so when you hit F on the keyboard it will focus to that bounds? I use a lot of graphics api stuff so the game objects has no true bounds other than its actual world position, so focussing on them is a pain

wintry quarry
#

The built in F functionality relies on Renderers afaik

versed light
#

is there no way to push some bounds in an editor script some how to capture the focus?

wintry quarry
#

this is all we get

#

nothing about bounds

#

all the implementation is internal and relies on there being a Renderer or a Collider afaik

#

You could temporarily add a renderer to the object

#

or add one in the editor only

#

and set its bounds

versed light
#

ok ill try it, thanks

grand badger
#

@versed light could also do some

// custom renderer.cs
#if UNITY_EDITOR
void Update() {
  this.bounds = ...;
}
#endif

// editor script.cs
editorUpdate += (e) => {
  var go = this.GetSelectedGameObject();
  if (!go.TryGetComponent<CustomRenderer>(out var customRenderer)) { return; }
  if (e.type == KeyDown && e.key == KeyCode.F) {
      var cam = SceneView.lastActiveSceneView.camera;
      cam.transform.position = this.BringBoundsToView(customRenderer.bounds, out var size);
      cam.orthographicSize = size; // adjust for non-orthographic
  }  
};
narrow pulsar
#

does anybody know whats wrong with my code

rich adder
eternal falconBOT
rich adder
narrow pulsar
#

where

#

you mean the public name?

#

or me trying to refrence it

wintry quarry
narrow pulsar
#

oops

wintry quarry
#

What is even going on here