#💻┃code-beginner

1 messages · Page 649 of 1

dry pulsar
#

So i only have that

#

And maybe thats the Problem

#

Maybe I got it.

#

I download it now

#

Got It TYSM

polar loom
wintry quarry
#

This doesn't make any sense

#

Did you forget the * or something

polar loom
#

Lowk I wrote this at 3:00am I don’t even remember

wintry quarry
#

Well I'm showing you now

#

You can see clearly this doesn't make sense right?

polar loom
#

yeah now that im looking back at it

burnt vapor
eternal falconBOT
green karma
#

does anyone know how I can make a newton's cradle

#

only the script side

#

or is there any asset or tutorial

rocky canyon
#

lots of tweeking

#

u cant really rely onphysics alone

rocky canyon
#

i actually did get it somewhat working.. but not by using any type of realism

green karma
#

I understand how it should be done but its too complicated for something for simple

#

yeah same

#

swapping force between the balls colliding

rocky canyon
#

mmhmm thats how i did it as well

green karma
#

but it wont work either 😢 it will break when you pull 2 balls

rocky canyon
#

i almost got it working with realistic physics.. but it slows down way too fast

#

to make it anything like a real craddle u need to hand-hold it

green karma
#

hand hold?

#

btw you made it just now?

rocky canyon
#

basically write a controller that handles everything

green karma
#

it took me 3 hours 😢

rocky canyon
#

the collisions, the forces, etc

green karma
#

yeah

rocky canyon
green karma
#

oh okay XD

rocky canyon
#

i cant find the original tho... just the clip

green karma
#

no worries

rocky canyon
#

im cheating by adding forces to the last balls

#

if i can find the script/setup i'll share it too

polar loom
rocky canyon
# green karma swapping force between the balls colliding

Hey everyone!
In this video,
I have just tested the Hinge Joint Component provided by Unity Engine to Simulate Newton's Cradle, But since Unity Engine is not a Physics Simulation Engine, It doesn't simulate it correctly!

If you want to make your own game then make sure to check my Unity Engine Series:
https://youtube.com/playlist?list=PLrtqd9j...

▶ Play video
burnt vapor
polar loom
#

And I’m trying a new scripting app

rocky canyon
polar loom
#

Im used to VS Code but I’m trying Microsoft visual studio

rocky canyon
#

good news, studio is easier to setup than code

green karma
rocky canyon
#

lol.. made it 3 years ago... apparently my organization skills weren't that great back then..
i know its on github somewhere just can't find it 😅

crystal scarab
#

hewp me i just started

rocky canyon
#

check the pinned content..

bronze sinew
#

Hey guys So I'm making a game that transitions between levels, based on time. The visual scene is the same just the spawning objects frequency and pattern changes. I'm a complete begineer, should I setup a state machine for this?

rocky canyon
#

sounds like a good use of a statemachine 👍

bronze sinew
#

Okk

feral moon
#

!code

eternal falconBOT
feral moon
#

https://hastebin.com/share/borekemuci.cpp
It is code of my transfer between scenes

https://hastebin.com/share/icovusucut.csharp
It is code of my cutscene. We need to method of DestroyZombie

I want to transfer data from one scene to another. For example, I want to make it so that when the DestroyZombie method occurs, then in another scene there is a debug.log stating that this method occurred.

Help, please, I watch guides, but it didn't help me

grand snow
#

Can also use additive scene loading to keep some scenes always loaded but remove/add some others.

quick pollen
#

the most mainstream method though is via ScriptableObjects

rocky canyon
#

i like additive scenes

frail hawk
#

SO for Scene changes?

#

you gotta explain that please

rich adder
frail hawk
#

hm k

rich adder
#

since SO do not erase their data until the game is run again. (they revert back to the original value game was build with)
In Unity editor they don't reset themselves

rocky canyon
#

Shared references (like current level or game mode)

unkempt zodiac
frail hawk
rich adder
unkempt zodiac
#

thanks guys, i found it ♥

https://www.youtube.com/watch?v=QkX1VerPiNQ

Learn how to bend your game world using Unity's Shader Graph to look like Animal Crossing visuals.
The Ultimate 2D & 3D Shader Graph Course: https://www.udemy.com/course/the-ultimate-2d-3d-shader-graph-vfx-unity-course/?referralCode=AA34C472F6CB6B86DE75

00:00 Intro
00:30 The Ultimate 2D & 3D Shader Graph Course Trailer
01:12 Setting up the scen...

▶ Play video
rocky canyon
#

Animal Corssing

rich adder
#

12k views too

frail hawk
#

binary lunar makes really awesome content. how comes no one told him about the typo

hexed terrace
#

Maybe he's been told and he doesn't care/ hasn't changed it

#

Maybe no one noticed it until you, just now. Well done, have a gold star ⭐

rocky canyon
#
keen cargo
#

Could also be just because it's funny

#

I would do that

rocky canyon
#

this guy has some pretty good dev-logs speakin on all sorts of non-euclidean geo

frail hawk
#

Carwash trying to be funny

polar acorn
rocky canyon
#

SEO too

edgy prism
#

Hello I dont know if anyone can tell me why my console statements look so strange now, they've all become really hard to read heres an example:

Unable to find a valid spawn position after multiple attempts.
0x00007ff60f849f0d (Unity) StackWalker::GetCurrentCallstack
0x00007ff60f850be9 (Unity) StackWalker::ShowCallstack
0x00007ff6107b7a83 (Unity) GetStacktrace
0x00007ff610e562fd (Unity) DebugStringToFile
0x00007ff60e90a172 (Unity)

The actual log is too long to post in a discord message but follows the same trend

rich adder
#

or maybe something else

edgy prism
# rich adder did you change one of these ?

Not intentionally, in all honesty I just got a new dog and hes taken to running across my keyboard like a maniac so theres a decent chance hes done something, where can I find that setting?

rich adder
#

check there but doubt if it was a keyboard mash could've been a shortcut for something else.

edgy prism
rich adder
#

ahh maybe then yea

edgy prism
rich adder
#

now thats wonky..

#

some type of editor script somehow doing it ? thats a rough one...

edgy prism
#

Thanks for your help thats been driving me insane and the knowledge to identify that so quick is impressive

keen cargo
#

Preferences > Colors > Playmode tint

edgy prism
earnest wind
#

How can i change the Fast sRGB? its only get but not set

#

never mind i found a way

earnest wind
#

oh wait that was only for editor

#

anyone know?

#

yeah i dont think there are any ways

whole osprey
#

Changing that at runtime is probably not possible. Not sure why you would want to do that.

ruby sparrow
#

How do I correctly lock the mouse for first person in web? we've set CursorLockMode.Locked but it still doesn't capture the cursor..

rich adder
#

ohh ok it was white on white..

#

some browsers you have to click inside the webgl/iframe iirc

ruby sparrow
#

to reach the point with fp controls, we have the player click on a START button so I think that's covered?

rich adder
ruby sparrow
#

on regular build its a-ok

quick pollen
#

So I have a small conundrum:
I have some visual effects that I want to play at specific times, but I'm having problems with setting the rotations for it
I found the timings for getting the rotations right, but the problem is that the effect plays late, and I don't know how to go about it

ruby sparrow
#

at least, in editor it does

quick pollen
#

this one

#

and because I found the correct rotations through movement, idk how to "save" it, so I can play the effect earlier

#

is there a way to do this maybe?

#

if I play the effect earlier, then, because the effect is attached to the sword and the sword is in a different angle, the rotation will be different

eternal falconBOT
quick pollen
#

theres no real code to be shown

#

I play the effect through animation events

naive pawn
#

well this is a code channel

quick pollen
#

well yes

#

I need to make this work in code

#

I used animationevents until now

#

I need to find a way to write this into code

polar acorn
#

This is a help server. Jokes go elsewhere

queen adder
frosty hound
quick pollen
#

I ended up pausing the game during attacks and copying the effect prefabs

#

not the best way, but it works

naive pawn
golden notch
#

oh

woven scaffold
#

where do i ask for asset store publishing help?

crisp token
#

does unity have some form of dependency injection

gentle bone
#

not sure if its so hard to put 3 words into google "unity dependency injection"

night mural
#

you can get some libraries which will make all of that much more complicated if you want though

crisp token
night mural
#

I don't think that dependency injection will help you at all there

#

character controllers are inherently very coupled and quite complex

crisp token
#

true, its just annoying having to pass around references through large hierarchies

night mural
#

if you have a bunch of non-movement code in there or something though, that's worth pulling out

night mural
#

anyway, people do use zenject and there's other ones too

#

I just wouldn't unless you have a very good reason (like you're working on a size of team where extreme decoupling is important)

crisp token
#

yeah prob not worth it for now

#

just kinda a mess

night mural
#

well you're always welcome to post some code and maybe people will have advice on how to decouple it

#

it's just that good code mostly comes from meeting the specific needs of a situation, not applying some general pattern globally

#

so you gotta do what you gotta do, and it's hard to offer real advice without something concrete to work from

crisp token
#

I can descrbie the pattern im using; there's no real need for me to post the files (too many of them)

#

To keep it simple, any class that kinda acts as a root class or a manager class passes a reference of itself to any objects it creates, and then those root classes kinda act like a hub so that all the objects instantiated in them can access stuff from all the other instantiated in them

#

idk dont worry about it, I think im fine tbh

night mural
#

yeah, sounds backwards to me

#

most games make more sense when you think top down than bottom up

#

instead of telling individual objects what to do and having them all reference managers which they then need to delegate that to, you can have your objects be stupider and let the managers manage them directly

#

I see very little value in the kind of indirection you're describing (though if you do, that's cool) and as you say, it means you have to do some silly dependency management

crisp token
crisp token
frigid sequoia
#

What does this mean?? Should I be using something else?

night mural
night mural
frigid sequoia
#

It's a singleton

#

But better if I just do it rigth no?

night mural
#

yeah, I mean it's probably a micro-optimization that won't matter either way but I would prefer to not create the garbage

#

and the API is slightly different in a way that could be educational, so give it a go

frigid sequoia
#

Mmm, do I need to give the NonAlloc a maximum of hits?

#

Cause it's kinda unclear how many I would need tbh

night mural
#

ideally you wouldn't have so many collisions at once that it's a concern

frigid sequoia
#

Yeah, but it migth happen that the actual thing I am looking for is behind a bunch of non-related colliders

night mural
#

how about some layer masks

frigid sequoia
#

Yeah, should be doing that tbh

#

Everything it's on default for now

olive axle
#

Hay, I am looking to get into Unity. Are there any good resources I should know about for coding?

#

I have a lot of experience with C++ for microcontroller applications but I have yet to really work with C#.

slender nymph
#

there are beginner c# courses pinned in this channel and the pathways on the unity !learn site are a good next step

eternal falconBOT
#

:teacher: Unity Learn ↗

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

olive axle
#

Thankyou very much!

#

I just sat down and did the basic moving cube.

#

It's my first time coding anything higher level. I have a lot to learn

#

Just found the unity 6 documentation. It should help a lot with things.

golden notch
#

is there a component that fades a texture into another one?

brave robin
olive axle
#

Yeah it feels very familiar. It feels like I mostly need to learn what unity can do.

brave robin
olive axle
#

I am coming off of a very difficult C++ project lol. So this is very fun.

#

I was working on a electronic board game that uses nfc tags to read what cards you played.

#

Dealing with learning a real time operating system to run on a esp32

brave robin
#

Now you get to make the game part of the game, and not worry about how the hardware interfaces with all of that

fair shore
#

Why in my game 4 pieces in wrong place and the other one is out of place with them, I think this is a code issue.

private Dictionary<GameObject, List<int>> piecedictionary = new Dictionary<GameObject, List<int>>();
public GameObject inventorycount;
void Start()
{   // Add pieces to the dictionary with their values (attack, number of pieces, number of rows )
   piecedictionary.Add(GameObject.Find("Prince"), new List<int> {675, 1, 1});
   piecedictionary.Add(GameObject.Find("Junior pawn"), new List<int> { 75, 12, 6 });
   piecedictionary.Add(GameObject.Find("Senior pawn"), new List<int> { 225, 8, 4 });
   piecedictionary.Add(GameObject.Find("Knight"), new List<int> { 400, 2, 2 });
   piecedictionary.Add(GameObject.Find("General"), new List<int> { 450, 2, 1 });
   
   foreach (GameObject key in piecedictionary.Keys)
   {      // Create a TextMeshPro object for each piece in the dictionary
       Vector3 offsetvector = new Vector3(-0.08f, -0.32f, 0);
       GameObject inventoryspawn = Instantiate(inventorycount, key.transform.position + offsetvector, Quaternion.identity);
       
   }
}```
olive axle
#

"Did I use C style strings or C++ strings for this?"

#

type stuff

#

I had an Idea for a game I would like to make and it will be a fun side thing

brave robin
olive axle
#

My end goal for learning unity is a mech game with a unique high skill ceiling movement system.

fair shore
brave robin
brave robin
# fair shore Yes it is

Are the "Prince" and other items in the UI, or are they in the world? Because if they're UI then you don't want their transform, you want their RectTransform to place them properly

brave robin
#

So the Pieces are in the world, and the "text" isn't really Text, it's a sprite of some kind?

#

It looks like the pieces are Images though, from the screenshot of your hierarchy

#

It will be much easier to place the UI Text on the UI Images exact position with that offset

crisp token
brave robin
#

Generally the "dumber" your low level monobehaviours are, the better. ECS just goes the extra step of having those components be nothing but data storage with no methods. The state management is handled by systems, which will take care of processing every entity based upon what components they have.

night mural
# crisp token just read a short article on ECS. Their point was for systems where you really n...

☝️ Yep, though you don't have to go that hard since it only makes sense for some things. You'll find that some code, especially presentation code, feels better with more 'doThis' kind of methods. It's just that they're then controlled by high level systems which can consider all the things they need to know, rather than individual agents who either have no context, or need to be passed all sorts of random context to do anything useful.

brave robin
#

I go a quasi-ECS route where I have separate systems classes that listen to events and process specific parts of my game. Helps prevent me from making god classes, when instead I can have a class just for leveling up, and another just for processing damage over time. Nicely compartmentalizes those mechanics.

crisp token
#

how do the high level systems have accesses to everything they need

brave robin
#

In pure ECS, they have access because the entities and their components do not hide any of their data. Its all public.

#

In something less extreme, you'd probably go with properties that manage some of it to prevent things getting out of hand.

night mural
# crisp token how do the high level systems have accesses to everything they need

Really however you want as long as systems have some way to query data. You could even use the unity scene and Find calls at initialization time and that would probably be ok. Depending on the game you're making, I would recommend either:

  1. The managers are the sources of truth for everything, and so have references to whatever exists within their domain, either because they created it, or it registered itself with them at initialization time.
  2. Your state is stored in a blob that's globally accessible.
#

or some combination, I guess

#

I sort of do both

crisp token
#

So like for a movement system, I'd have a movement state calculator system, A gravity calculator system, whatever kind of functionality I need I can have a system for. And then these all have access to the global state of entities as their input?

night mural
#

essentially, though movement is one of those things that tends to end up tightly coupled and I wouldn't fight that

#

again, everything depends on what you're making

crisp token
#

interesting, I doubt im going to make any changes to my movement system rn, but this is def good to know for the future

#

Just because its really a one time problem system with setting up the framework, which like you said is bound to be a mess for movement, but once its done modifying the system and adding behaviors would be straightforward

#

Appreciate it lads

crisp token
brave robin
# crisp token so you treat your monobehaviors as low level data inputs, and then send data "up...

In pure ECS, nothing gets sent up. I haven't done much with it, but generally ECS can quickly iterate over all entities, so systems can see what entities with specific components need to be processed. Something without a bullet component gets ignored by the bullet system, and so on.

For something like what I'm doing, here's a UI example. I used to have AbilityButton which was a fancier Button that knew what Ability was assigned to it. The icon, the text, etc.

Eventually I realized that was unnecessary and tangled up. It was better for the button to just be what it is, it didn't need to know what ability was assigned to it. A layer above it would assign the correct icon and text to it, and add itself as a listener to the button being clicked. Then remove itself as a listener and clear out the button's icon and text when no longer in use, or set the button inactive altogether.

night mural
#

top-down

night mural
jade niche
#

just got here 😋

crisp token
#

so I see the value of an ECS like setup / separation of data and behavior for things like buttons or whatever that have a lot of variation in how they can be setup or a lot of different behavior. For something like a movement system though, the complexity more comes from having a lot of systems needing to interact, not necessarily needing super modular design, so I'm having trouble seeing if it applies.

jade niche
#

so is there like a beginner's guide to programming lingo cuz i am confused XD

crisp token
jade niche
#

lowkey just lingo for the discord cuz there are alot of abbreviations i dont understand

teal viper
jade niche
#

sorry just nervous since im just starting out in here and script altogether

crisp token
night mural
hallow rock
#

this is not really a code but I need help.

crisp token
hallow rock
#

Im deving rn. And we cant open our studio using via playfab?

night mural
crisp token
#

Ok that makes sense

night mural
#

and for communicating between systems, you'd usually add or remove components from an entity, or modify their existing components

crisp token
#

i'd assume the goal would be to limit the use of singleton entitys as much as possible? or no

night mural
#

you end up doing some things which feel slightly weird at first, like having a PlayerInputSystem which adds a WantsToMove component with some movement data, which is then processed by your actual MovementSystem to do the movement

#

the result of this though is that you're forced to keep everything data-driven which ends up being very useful in many cases

night mural
#

it'd depend on the game

#

I guess if you feel like you need a lot of those, maybe ECS isn't the best fit for that kind of game

hallow rock
#

Hello! Trying to fix a unity or playfab issue,

#

I dont know whats going on.

ruby sparrow
#

having this horrible issue where my game gradually allocates more memory until I hit memory exceeded and the webgl game just crashes and I dunno how to debug this! any help would be appreciated

teal viper
#

You'd need to debug it in the editor or a desktop build though

ruby sparrow
#

should I be using the package? I tried to debug but like I don't really understand how to glean any info from the default profile

teal viper
ruby sparrow
#

so I got this thing pulled up now, how can I find any memory leaks or weird behavior?

ruby sparrow
#

yea

teal viper
# ruby sparrow

Select a frame in the graph and it should show more info in the bottom tab.

ruby sparrow
#

and at this point idk how to interpret any of this

teal viper
#

I haven't used the memory module in the regular profiler in a while, but in the memory profiler package, you can inspect different memory categories in details.

#

You should probably go and read the manual a bit on how to use it.

ruby sparrow
#

should I use the package then?

#

honestly I am under a lot of time pressure here to figure out something really quick

#

it's a game jam submission and the deadline is in like 12 hours

#

unfortunately the crash happens consistently - the game starts off using like 600 MB of memory and gradually increases until it exceeds roughly GB and taps out

teal viper
ruby sparrow
teal viper
charred spoke
#

Use the memory profiler package. Take a snapshot at the start. Wait a bit for memory to increase take another snapshot and compare them in the UI. Profit.

maiden estuary
#

Hey everyone! I've opened Visual Studio for the first time via unity by following a Unity Begginer tutorial I found on YouTube. The guy says that I'm using things in C#, but that's not the language I plan on learning. Do I have to calibrate Visual Studio/Unity in order for it to accept C++ or does it just accept any language I feed it?

slender nymph
#

if you want to use unity you'll need to use c#

regal flame
#

c# is easer

maiden estuary
slender nymph
#

just make sure you configure visual studio so you get intellisense 👇 !IDE

eternal falconBOT
dapper mirage
#

Why cant I select all the frames and drag it into the animation timeline like the other animations

slender nymph
#

this is a code channel. but you need to select the object you are animating, and add the sprite renderer's sprite property

dapper mirage
#

My bad thanks for the help

maiden estuary
#

So Im following that tutorial, and noticed that when this guy types it pops up with what I'll call "suggestions," gut when I do it I dont see that. How does one turn that on?

naive pawn
maiden estuary
naive pawn
#

no, it's valid; it's just not the one you said it was

maiden estuary
#

Shuld probably get what the tutorial has, thats probably smart.

naive pawn
maiden estuary
naive pawn
#

there are 3 main options, vscode, vs (windows only), rider. (in no particular order)
do you have experience with any of them (or any jetbrains products)

naive pawn
#

it's just a tool to write code
there are plenty of tools that do approximately the same thing with small differences in usage

maiden estuary
dapper mirage
#

Can someone please explain to me why this jitter is happening?

maiden estuary
#

Dunno why im responding like i could possibly know

naive pawn
maiden estuary
naive pawn
naive pawn
dapper mirage
naive pawn
#

you'd only need to search for your ide with stuff related to the act of writing code, like "find and replace" "find in project" "rename symbol" "find references" etc

naive pawn
dapper mirage
#

Im just using this built in stuff no code

naive pawn
#

a static rigidbody? is this on the terrain or on the player?

dapper mirage
#

Terrain

ruby sparrow
dapper mirage
naive pawn
# dapper mirage This is the player

ok so you're using a rigidbody; that controls the transform. you shouldn't modify the transform directly, since it would conflict with the rigidbody's control, leading to unexpected results like you're seeing.

you have a rigidbody already, just use that for movement. the equivalent rigidbody control to the motion you have now would be setting the rigidbody's velocity.

#

it would be something like this (spoilered in case you want to figure it out yourself)
||```cs
Vector2 vel = rigidbody.velocity;
vel.x = input * speed;
rigidbody.velocity = vel;

naive pawn
dapper mirage
#

Thank you very much for the help :)

maiden estuary
#

why is it different

rich adder
#

if its not in the dropdown you missed a step

maiden estuary
rich adder
maiden estuary
#

so I just redownloaded it and am re-setting it up

rich adder
#

then you should probably make sure you have the unity workload first

maiden estuary
#

Im usint the guide in the bot

rich adder
#

did you restart unity after you installed unity workload

maiden estuary
maiden estuary
#

What have I done wrong here? It wont let me enter play mode, and I'm not seeing any indicator, if there is one, as to what I've done wrong.

maiden estuary
teal viper
#

Scope

#

Do you know what the curly braces are for?

maiden estuary
#

Guys Im watching says theyre like fences that make sure that this code is only executed once th egate has been opened

#

which is the code that I am currently trying to execute

maiden estuary
teal viper
#

The curly braces define the scope of class/structs/methods and other code structures. They define what belongs where.

#

And they always come in pair. If there is an opening brace, there must be a closing one

maiden estuary
teal viper
#

Count the open and close ones and see for yourself

maiden estuary
teal viper
#

No

maiden estuary
#

Or am I just dumb

teal viper
#

There are 3 opening ones.

#

4 if you count inside methods

maiden estuary
#

what

#

huh?

#

What the fuck am I

#

Im sorry its like 4am I am rather

#

tired and I am very confused

teal viper
#

So, does that fix your issue?

maiden estuary
#

No

#

not

#

really

teal viper
#

Makes sense?

naive pawn
naive pawn
#

on the last line

maiden estuary
#

No the problems tab mb

maiden estuary
#

is this supposed to be in reverse?

teal viper
maiden estuary
#

OOOOOOOOOOOOOOH

#

WHAT WAIT WHAT THE FUCK

#

srry caps

teal viper
naive pawn
#

ah there you go

maiden estuary
#

So wait a minute

naive pawn
maiden estuary
#

{ leaves it open, correct?

naive pawn
#

you didn't have anything closing the class

maiden estuary
#

Ive made bar for bar what this guide is telling me

#

have I not?

naive pawn
fair shore
#
    [SerializeField] private GameObject slot;
    private GameObject[] slots;
    // Start is called before the first frame update
    void Start()
    {   // Add pieces to the dictionary with their values (attack, number of pieces, number of rows )
        piecedictionary.Add(GameObject.Find("Prince"), new List<int> {675, 1, 1});
        piecedictionary.Add(GameObject.Find("Junior pawn"), new List<int> { 75, 12, 6 });
        piecedictionary.Add(GameObject.Find("Senior pawn"), new List<int> { 225, 8, 4 });
        piecedictionary.Add(GameObject.Find("Knight"), new List<int> { 400, 2, 2 });
        piecedictionary.Add(GameObject.Find("General"), new List<int> { 450, 2, 1 });
        slots = new GameObject[slot.transform.childCount];
        for (int i = 0; i < slots.Length; i++)
        {
            slots[i] = slot.transform.GetChild(i).gameObject;
        }

        foreach (GameObject key in piecedictionary.Keys)
        {
            int dictionaryindex = piecedictionary.Keys.ToList().IndexOf(key); // Get the index of the key in the dictionary  
            // Create a TextMeshPro object for each piece in the dictionary
            Vector3 offsetvector = new Vector3(-0.08f, -0.32f, 0);
            GameObject inventoryspawn = Instantiate(inventorycount, slots[dictionaryindex].transform.position + offsetvector, Quaternion.identity);
        }
    }``` There is an error called index was outside the bounds of the array, how to make the index in the bounds of the array or the array outside the piece index.
naive pawn
teal viper
teal viper
maiden estuary
#

So then what have I done wrong? How is Image One different from Image Two?

naive pawn
#

they aren't different

maiden estuary
naive pawn
#

but there are other differences in the file

#

buddy slow down

#

every { needs a corresponding }

#

you've successfully done that for Update

teal viper
naive pawn
#

you have not successfully done that for the entire BirdScript class

#

there's a { right here. where's its corresponding }?

#

the error should be telling you, "} expected"

#

or i guess "unexpected EOF", not sure

fair shore
maiden estuary
naive pawn
#

how so

maiden estuary
#

before

teal viper
naive pawn
maiden estuary
#

after

naive pawn
#

yeah you put it in the wrong spot lol

teal viper
maiden estuary
#

oh my fucking god I see it

teal viper
#

You should probably start with the basics !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

naive pawn
#

you're saying the class is empty, and then you have a bunch of random code after it
} needs to go at the end, meaning the other parts are inside the class

maiden estuary
#

there we fucken go

#

As soon as I noticed theres not a } at the bottom i instantly got it

#

The way the tutorial cut fucked me ut

naive pawn
maiden estuary
#

ty and I apologize for my density

naive pawn
maiden estuary
#

🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and...

▶ Play video
teal viper
maiden estuary
#

I mean it just seems logical to understand how to use the paper before using the pencil

formal valley
#

how can I make a good jump like when he jump he continue at his speed but when he go to opposite direction it move slowly.

tulip scroll
#

Someone here trying to learn how to script in unity?
I do want to learn together with someone who does want to and do some projects together 🙂
DM if you want..

naive pawn
#

also, see below
!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

naive pawn
#

if you're looking to learn, check out unity !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

formal valley
naive pawn
formal valley
#

no just you always help me soo........

naive pawn
#

i have no idea what you want lol

#

gonna need more context

formal valley
#

you know crash bandicoot right?
when he jump, in the air he continue at his speed to the direction but when he goes opposite direction it goes slow down( it's hard for him to getcontroll on mid air)
and sorry for ping.

naive pawn
#

i don't

#

so.. sounds like you want reduced air control?

formal valley
sour fulcrum
#

the answer is kinda just re-arranging the sentence 😄

#

reduce the control while in air

formal valley
#

😅

sour fulcrum
#

fair, I mean more about pointing out how to think about the problem logically than specifically language though

#

breaking down what you want into the separate steps

naive pawn
#

how do you have movement currently?

#

what's the current issue with it?

formal valley
#

3d unity
void Update()
{
ForBack = Input.GetAxis("Vertical");
LeftRight = Input.GetAxis("Horizontal");

    Vector3 move = new Vector3(LeftRight, 0f , ForBack)* speed;
    Vector3 newVelocity = new Vector3(move.x, rb.linearVelocity.y, move.z);
    rb.linearVelocity = newVelocity;


    if(Input.GetButtonDown("Jump") && IsGrounded()){
        rb.AddForce(Vector3.up * JumpForce, ForceMode.Impulse);
    }
}
 bool IsGrounded(){
    
    return Physics.Raycast(transform.position, Vector3.down, 1.1f);
}

}

naive pawn
#

!code

eternal falconBOT
formal valley
#

🫱🏿‍🫲🏻

dark vine
#

so im trying to run a collision for a bunker, replicating space invaders. and for some reason this code will only detect the missiles and not the invader. i have the exact same code for the player, and it works for the player, idk if its the collisions. anything i should be looking for? ive got it on the right collision layer, but am stumped?

naive pawn
dark vine
jade niche
#

hello again im starting to learn C# language so i can understand script a little better using some lesson thingy called brilliant honestly its pretty fun to use

umbral bough
#

Is there a way to execute OnEnable in both play and edit mode but not affect other functions?
If I add [ExecuteAlways] on the class, all the methods will execute in editor, which is not what I want.

naive pawn
umbral bough
quick fractal
#

I would've just used a ContextMenu item if you don't want stuff getting run in editor

#

Not fully, anyway

gray coral
#

why the icon within my invetory bar is pressed like this.

strong wren
nimble apex
umbral bough
#

it's fine either way, I made all the functions work properly with ExecuteAlways now so ye

nimble apex
#

execute always or in edit mode will affect all functions inside the class , its either 0 or 100 , no 50.

if u only have a particular function thats not needed for execute always, u need to isolate it out

#

or go find another attribute tag that can ignore execute always

hidden marten
#

can someone give me a rigidbody addforce based movement script or tutorial which doesnt use drag to slow the player down? after drag gave me a lot of issues i switch to setting velocity instead of addforce. this is also giving me problems now, so i would like to swtich back again

frigid sequoia
#

Can I tell a script to do something when its game object is destroyed directly or do I need an event for that?

dark vine
#

my buttons dont work, trying to run a function for a main menu button and for some reason they wont let me click them.

frigid sequoia
dark vine
frigid sequoia
#

If the background it's a big panel it may be totally covering the play button

frigid sequoia
naive pawn
ripe shard
naive pawn
dark vine
dark vine
#

but still not allowing to click

#

ive deleted the background and now just have buttons, but they still dont work, could it do with the function itself

#

like this is how i have my quit and it wont work, am i missing something

frigid sequoia
#

Are u even making sure that is being called?

ripe shard
# dark vine but still not allowing to click

you need to

  1. Put a graphic raycaster on each canvas component that the button is part of, not just the root.
  2. Check that the component can intercept/block raycasts (the graphic image component next to the button or below it must "block raycasts" and exists, and is not part of a canvas group that is set as "non-ineractive")
  3. Ensure there is a EventSystem in the scene and it is configured correctly
  4. Make sure the button is under a canvas.
  5. Ensure the button is not part of a CanvasGroup that is "non-interactive"
dark vine
frigid sequoia
ripe shard
#

doesn't hurt to check

#

Also ensure there is a EventSystem in the scene and it is configured correctly

keen dew
#

Are you testing this in a build or in the editor? Application.Quit doesn't do anything in the editor

frigid sequoia
dark vine
dark vine
ripe shard
dark vine
#

I will restart it, as it only takes a couple sec, and if it still doesnt work ill come back, thank you otherwise

faint tulip
#

is there any guide on making a book in game then viewing its content on the screen? i do not know what they call it

eternal needle
# hidden marten any help please

no, people will not give you a script, no one will do your work for free. Likely no tutorial out there will fully cover the exact movement you want to achieve in your game. If you need help with code, then ask properly. Saying that you have problems is too vague for anyone to help

frigid sequoia
eternal needle
#

"create a book unity tutorial" plus 2d or 3d should get you enough results on google

hidden marten
echo ruin
faint tulip
rocky canyon
#

i like using Interfaces for interactables

#

thatInteractable.Interact()

grand snow
rocky canyon
eternal needle
rocky canyon
#

Quaternion.Identity for no rotation

echo ruin
grand snow
#

Read the doc page

hidden marten
rocky canyon
alpine wraith
#

I have some weird problem where I use

Destroy(gameObject, 5f);
```Now if the 5s aren't up when I exit the play mode, the object is apparently saved in the scene. Is there a reason for that? context might be important, it's instantiated as child of a dontDestroyOnLoad object
eternal needle
eternal needle
rocky canyon
naive pawn
#

shaders?!

rocky canyon
#

well i imagine its something like that

naive pawn
#

wow i need to learn what shaders actually do idontfeelsobad

rocky canyon
#

make things pretty

hidden marten
rocky canyon
#

yessir thast how i do it

hidden marten
rocky canyon
#

then i have some code in update detecting if we're grounded or not.. if we are groundvector will have a value but airVector will be zero

#

and vice-versa

#

groundVector + 0 = groundVector

#

0 + airVector = airVector

alpine wraith
rocky canyon
#

ohh yea u had a null error.. probably paused ur code execution

ivory bobcat
alpine wraith
# alpine wraith yes, these 3

I assume it is somehow instantiated in the editor then, because it doesn't resemble the altered object but rather the normal prefab

rocky canyon
#

well can u show the instantiation code?

alpine wraith
#

ill make a pastebin

ivory bobcat
hidden marten
rocky canyon
#

either moveVector = input * groundSpeed;

alpine wraith
rocky canyon
#

or moveVector = input * airSpeed;

#

then u can use a simple if statement to assign whichever version u need

hidden marten
#

ohhhh okay.. thanks a lot!! i will make sure to try that

ivory bobcat
alpine wraith
rocky canyon
#

my Lerps are awful.. so ignore those.. i'll change em to smoothdamp or movetowards eventualy

hidden marten
hidden marten
rocky canyon
#

Move() and PlayerInput() are the two important functions in ur case

alpine wraith
rocky canyon
#

thats the confusing part..

#

why would something u add during runtime be left over after u stop the game?

alpine wraith
#

exactly

rocky canyon
#

have u tested it out on some other part of ur project?

alpine wraith
#

Destroy may not be called from edit mode! Use DestroyImmediate instead.
this line in the error implies that it's trying to destroy in edit mode

rocky canyon
#

maybe its just this specific situtation causing an issue like that

rocky canyon
alpine wraith
#

yes

rocky canyon
#

DestroyImmediate is for things like Editor scripts

alpine wraith
#

but maybe due to the 5s delay?

rocky canyon
#

i dont see why.. tho

#

did u share the full script?

alpine wraith
#

in the pastebin yes

rocky canyon
#

i found it 👍

alpine wraith
#

not the singleton part, but other than that yeah

rocky canyon
#

i can look.. thats all i can promise

alpine wraith
#

thanks :)

ivory bobcat
rocky canyon
# alpine wraith thanks :)

Destroy(gameObject, 5f) schedules a delayed destruction at runtime, only if the game keeps running.
If you exit Play Mode before the 5 seconds pass, the object never gets destroyed, because Unity stops all coroutines, tweens, and delayed calls immediately when exiting Play Mode.
BUT since the object was instantiated inside a DontDestroyOnLoad object, Unity moves it to the special "DontDestroyOnLoad Scene."

Unity can't clean up stuff that's been manually moved to that internal scene unless you do it yourself — so it persists even after you exit Play Mode.

Short version:
Destroy() was scheduled but never happened because exiting Play Mode interrupts the process.
Anything in DontDestroyOnLoad outlives normal cleanup unless manually handled.

#

does this seem legit ^?

alpine wraith
#

i think I got something

rocky canyon
#
    void OnApplicationQuit()
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            foreach (Transform child in toastParent)
                DestroyImmediate(child.gameObject);
        }
#endif
    }```
#

clear toasts manually at exit

alpine wraith
#

I apparently called the method somewhere in an OnApplicationQuit()

ivory bobcat
eternal needle
#

you most definitely dont need to delete objects manually like that

eternal needle
rocky canyon
#

^ ya i thought that at first too but

alpine wraith
#

Sorry for all the fuss, that was it probably 😅

rocky canyon
#

i wonder if my toast system still works

eternal needle
# alpine wraith Sorry for all the fuss, that was it probably 😅

just as a note for the future, none of the code you shared used unity functions. meaning none of this wouldve ran by itself, so something else was calling it. it's usually worth going through and showing all the places that call it. You can usually right click the method in your IDE and find all references

eternal needle
rocky canyon
#

it was my phones gemini..

alpine wraith
rocky canyon
#

just curious how gemini handled reading over it

eternal needle
rocky canyon
#

if my projects would open THIS century

rocky canyon
alpine wraith
# rocky canyon can i possibly see ur generic singleton code?

I got this online and changed some small things.

using UnityEngine;

public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{

    private static T _instance;
    private static readonly object _instanceLock = new object();
    protected static bool _quitting = false;

    public static T Instance
    {
        get
        {
            lock (_instanceLock)
            {
                if (_instance == null && !_quitting)
                {
                    _instance = FindFirstObjectByType<T>();
                }
                return _instance;
            }
        }
    }

    [Header("Singleton")]
    [SerializeField] protected bool dontDestroyOnLoad = false;

    protected virtual void Awake()
    {
        if (_instance == null) _instance = gameObject.GetComponent<T>();
        else if (_instance.GetInstanceID() != GetInstanceID())
        {
            Destroy(gameObject);
            throw new System.Exception(string.Format("Instance of {0} already exists, removing {1}", GetType().FullName, ToString()));
        }

        if (dontDestroyOnLoad) DontDestroyOnLoad(gameObject);
    }

    protected virtual void OnApplicationQuit()
    {
        _quitting = true;
    }

}
rocky canyon
#

thank you friend! 🙂

alpine wraith
#

you're welcome! Might you also show yours? ^^

rocky canyon
rocky canyon
#

i took mine from Vertxyz

#

huh.how.xyz? vertx.huh.how.xyz something another

thick tendon
#

can u help me with an asset ?

rocky canyon
#

not unless u go into a bit more specifics

alpine wraith
# rocky canyon

do you know about base.Awake()? It seems you could also use that. Idk if your DoAwake() is by preference

rocky canyon
#

and then its hit or miss

rocky canyon
#

ive been trying to get used to it

#

but sometimes ill still accidently use the wrong type of awake

cosmic dagger
alpine wraith
ivory bobcat
rocky canyon
#

heres how i typically make my singletons ^

thick tendon
rocky canyon
#

overrides/protected/virtual/ etc still has me a bit confused from time to time

alpine wraith
rocky canyon
#

since DoAwake() gets called by the Singletons Awake() method..

alpine wraith
ivory bobcat
#

And Awake isn't polymorphic in vertz sample to ensure the base behavior always occurs with or without users explicitly calling a base awake

alpine wraith
rocky canyon
alpine wraith
#

make sure to put the scripts into the Editor folder too

alpine wraith
rocky canyon
#

i tend to fall hard down a rabbit hole

alpine wraith
#

but- but... automation... :(

rocky canyon
#

yea i know

rocky canyon
alpine wraith
#

is there so much cool stuff to do with that?

rocky canyon
#

editor scripting?

#

absolutely..

alpine wraith
#

i.e.?

rocky canyon
#

i wish i could just create a "Build Game" button

night mural
#

no editor scripting that way!

rocky canyon
night mural
#

tbh mostly I just copy a file that I already have that's in the right structure and update it >_>

desert palm
#

hi guys i need some help in unity AR mobile app , with the default XR template .. i want to create an app to view my model and rotate and scale basically

night mural
alpine wraith
rocky canyon
alpine wraith
#

can I import a package from git url dynamically via editor scripting?

cosmic dagger
alpine wraith
#

yeah i can see that, that's what I meant with preference

rocky canyon
#

Project Directory Markdown Generator 😉

alpine wraith
#

holy

#

do you actually use that for stuff?

rocky canyon
#

ya, all the time

#

soo much faster to read my project dirctory from a text file

#

than to spend 30 minutes uncollapsing things and searching around

alpine wraith
#

understandable

rocky canyon
#

everything I've made is QOL

#

but thats debateable

#

per person yakno

rocky canyon
#

i just need to stay really alert and focused when working on editor scripting

rocky canyon
#

its mainly for thirdparty cleaning... (and using it for Asset projects, so i can keep my Directory clean and organized)

#

after about a month or so of importing and exporting i'll go in and check the project directory out and get rid of residual stuff

cosmic dagger
#

I feel the same way. I'm trying to look for scripts where I can change the layout because I want to learn editor scripting. But, it's a LOT of boilerplate (so verbose) . . .

rocky canyon
#

u just gotta find em

#

my first forte into Editor scripting was with the URP Template Readme thing

cosmic dagger
#

Oh yeah, I copied a few things they did for myself. I ended up making an extension class for all the styles, add/remove uss classes, binding properties, and setting text because that's a lot of repeating code . . .

#

I bet anyone who messes with editor scripting has their own . . .

rocky canyon
#

not yet.. but im getting there

rocky canyon
#

and use that to style my windows

#

has text sizes, window sizes, scroll or no scroll, icons/ and header graphics, etc

#

then i can just create my editor window and pass in the WindowData i want for that window

#

Features acts as

Headers

and anything beneath it will be

  • bulleted
#

still figuring things out.. but today is Not an editor scripting day

cosmic dagger
rocky canyon
#

one day ill get around to implementing it 😉

frigid sequoia
#

I have notice the scroll component does not detect when you are moving the mouse and click as a drag, but rather you need to stay still with the mouse for a moment and then drag. Is there some way of overriding that?

timber tide
#

Usually you can dissect it a bit and change it up. I do it for buttons sometimes and throw on my own IPointer events

frigid sequoia
#

What event am I looking for?

elfin isle
#

Heyhey people! I was here f or a s imilar issue before and I thought I fixed it but its definitely not fixed.

It's really weird, everything in my game changes its speed depending on the framerate, the jumping, the speed of fish (its a fishing game), but not running speed.

Ive tried using a variety of Time.deltaTime, Time.FixedDeltaTime, neither work, and for some reason when I tab out o f the game while im in it everything gets very very slow and I can only fix it by restarting my game.

Any suggestions?

rich adder
elfin isle
# rich adder no suggestions. we haven't seen the code

It's kinda hard to show the code- in my code, I use Time.Delta time in like 6 different scripts, being movement, camera, fish, shop, movefish, I don't know if I should send all of that

I can send the movement though, which is probably the biggest problem

#
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO.Compression;

public class movefish : MonoBehaviour
{
    float Animation;
    public GameObject Fish;
    private float x;
    private float y;
    private float z;
    private float iy;
    private float iz;
    public float num;
    public float randint;
    public bool Copy;

    public float value;
    public float enemyinc;

    void Start()
    {
        iz = Fish.transform.position.z;    
        enemyinc = 3;
    }

    void Update()
    {
        if(!Copy)
        {
            if(Fish.transform.position.x >= 35)
            {
                    Destroy(Fish);
            }
            if(Fish.GetComponent<Fish>().isAlive == true)
            {
                    num += Time.fixedDeltaTime/4;
                    y = iy + (2f * Mathf.Cos(num  * 2f));
                    Fish.transform.position = new  Vector3(Fish.transform.position.x + 0.02f, y + 0.5f, Fish.transform.position.z);
            } else {
                Fish.transform.position = new Vector3(Fish.transform.position.x + 0.005f, 0.73f, Fish.transform.position.z);
                Fish.transform.rotation = new Quaternion(90f, Fish.transform.rotation.y, Fish.transform.rotation.z, 0f);
                Fish.GetComponent<Outline>().OutlineColor = Color.white;
            }
        } else {
            enemyinc -= Time.fixedDeltaTime/4;
            num += Time.fixedDeltaTime;
            z = iz + (2f * Mathf.Sin( 10*num * 0.2f));
            Fish.transform.position = new Vector3(Fish.transform.position.x, Fish.transform.position.y, z);
            if(enemyinc <= 0)
            {
                enemyinc = UnityEngine.Random.Range(4.0f, 8.0f);
                GameObject NewFish = GameObject.Instantiate(Fish);
                NewFish.GetComponent<movefish>().Copy = false;
                NewFish.transform.position = gameObject.transform.position;
                randint = Mathf.Round(UnityEngine.Random.Range(0.8f, 2f) * 100.0f) *  0.01f;
                NewFish.transform.localScale *= randint;
                NewFish.GetComponent<movefish>().value = randint;
            }
        }
    }
}
rich adder
elfin isle
rich adder
#

Time.deltaTime should work fine, if it wasn't then you used it wrong. Replacing it with something else related to physics instead isn't exactly a way to fix that lol

elfin isle
#

but both still have the same problem of being dependent on framerate

rich adder
rich adder
#

probably placed it at the wrong spot, or its something else

elfin isle
#

i used it the same way im using fixeddelta time

#

just with different proportions obviously

#

i dont see how thats using it wrong

rich adder
#

I'm trying to see where, cause this code is a mess

elfin isle
#

sorry

verbal dome
#

!code

eternal falconBOT
rich adder
#

also are these rigidbodies in any way?

naive pawn
# elfin isle i think so

fixedDeltaTime is the tick speed (1/tickrate) of the physics system
deltaTime is the frame speed (1/framerate) of the update loop
literally the difference (delta) in time between the last iteration

if you do, say, value += deltaTime in Update, then after 1 second, value will be incremented by 1.
same for value += fixedDeltaTime in FixedUpdate.

but fixedDeltaTime is unrelated to Update, so it doesn't make sense to use it there

verbal dome
#

This depends on framerate, for example sc Fish.transform.position = new Vector3(Fish.transform.position.x + 0.02f, y + 0.5f, Fish.transform.position.z);

#

You are adding 0.02 and 0.5 to the position regardless of the frame duration

rich adder
#

oh ya good catch there

#

for a second thought it was a diff object

naive pawn
#

anything that changes over time in Update, FixedUpdate, a coroutine, probably other stuff, all rely on the loop rate. for Update and coroutines (except WaitForFixedUpdate), that's the framerate

verbal dome
#

Also please use proper names for variables, num or enemyinc don't tell me much

rich adder
#

yaa variable names here making 10 times harder to read than it needs to

elfin isle
#

im sorry idk what to say its just how i code

verbal dome
#

This part is also wrongcs Fish.transform.rotation = new Quaternion(90f, Fish.transform.rotation.y, Fish.transform.rotation.z, 0f);

#

Quaternion values aren't euler angles - you probably want = Quaternion.Euler(...)

#

And instead of rotation.y/z you'd use eulerAngles.y/z

rich adder
#

don't take it as criticism on you.. we all been there.. its good to improve for your future self

elfin isle
rich adder
#

quaternion values dont go above 1

#

you should never manually create quaternion values that way

#

always use helper function with euler angles
Quaternion.Euler, rotation.EulerAngles etc.

elfin isle
verbal dome
#

Multiply the value with Time.deltaTime so it scales with the framerate

#

With that you also need to use larger numbers

elfin isle
#

Fish.transform.position.x + (0.02f * Time.deltaTime), like this?

rich adder
elfin isle
rich adder
verbal dome
#

Same with these lines cs y = iy + (2f * Mathf.Cos(num * 2f)); cs z = iz + (2f * Mathf.Sin( 10*num * 0.2f));
You are adding constant values, the additions need to be multiplied by delta time instead

naive pawn
verbal dome
rich adder
#

Fish.transform.rotation is still a Quaternion

#

so .y gives you a quaternion value

#

if you want the euler angle of it it would be rotation.eulerAngles.y or transform.eulerAngles.y

elfin isle
rich adder
#

any time you're adding values over a series of frames / time you need Time.deltaTime
(this is what keeps the adding values consistent through different fps)

verbal dome
elfin isle
#

alright, was just asking cause i have alot of spots that happens in

verbal dome
#

Ofc you can add a local variable float delta = Time.deltaTime and use that to make it a bit more readable

elfin isle
#

that would help

elfin isle
elfin isle
rich adder
#

i meant more like .rotation = Quaternion.Euler(90f, Fish.transform.eulerAngles.y, Fish.transform.eulerAngles.z);
but I would be hesitant using its own eulerAngles into assigning into rotation

verbal dome
elfin isle
rich adder
#

You can probably just do transform.Rotate(myEuler)

verbal dome
#

Just realized you are adding the sine to the initial positions

rich adder
elfin isle
rich adder
#

oh no it does, its just sometimes I get adamant passing its own angles sometimes lol

elfin isle
# verbal dome Actually nevermind that part, these lines don't need delta time

(obv i need to change the values) but, does this look more accurate?

            {
                    num += delta;
                    y = iy + (2f * Mathf.Cos(num  * 2f));
                    Fish.transform.position = new  Vector3(Fish.transform.position.x + (0.02f * delta), y + (0.5f * delta), Fish.transform.position.z);
            } else {
                Fish.transform.position = new Vector3(Fish.transform.position.x + (0.005f * delta), 0.73f, Fish.transform.position.z);
                Fish.transform.rotation = Quaternion.Euler(90f, Fish.transform.eulerAngles.y, Fish.transform.eulerAngles.z);
                Fish.GetComponent<Outline>().OutlineColor = Color.white;
            }```
rich adder
#

at least .rotation = Quaternion.Euler tries to avoid gimbal lock that occurs if you were to assign euler angles manually

elfin isle
elfin isle
#

gonna be real i dont know what euler, quaternion, or gimbal really is i just use them lmao

rocky canyon
verbal dome
#

(I would probably make a local variable for Fish.transform to make it a bit more readable)

elfin isle
#

quaternion is like another word for r otation right ?

verbal dome
#

It's a data type containing a rotation

rocky canyon
#

its a 4Dimensional Value

elfin isle
rich adder
#

its good way to store rotations mainly to avoid gimbal lock + other reasons big brains know about lol

rocky canyon
#

transform is a Transform..

rocky canyon
rich adder
rocky canyon
#

Quaternion myRotation = Fish.transform.rotation;

elfin isle
#

my brain already feels melted lmao

#

4 people spouting info at me

#

OKAY so,

rich adder
#

the great thing about quaternions is you dont have to know HOW they work, just what they're for

elfin isle
rich adder
#

a bit odd naming tbh
Vector3 FISH = Fish.transform.position;

Would be fishPos the fish would be fish.transform

verbal dome
elfin isle
#

it was earlier but im good now

rocky canyon
#

i just wiki'd and now i'll spectate 🙂

elfin isle
#

idk l mao

rocky canyon
#

until u ur scrolling to the top every minute or so checking what the difference between Fish, FISH, and Phish are

elfin isle
#

ykw fair

charred spoke
#

You think bad naming is funny until you come back to a code base a couple of weeks later and have no idea wtf is going on

rocky canyon
#

lol... we've all been on that side of the fence ^

#

its no fun lol

elfin isle
#

okay i changed it to FishPos

rocky canyon
#

fishGO
fishTransform
fishRotation
Etc

#

yea yea..

charred spoke
rocky canyon
#

🐫

rich adder
#

yeah very descriptive names can become funny too..
DeleteAllChildren() **enters watchlist **

elfin isle
#

ykw while im here

rocky canyon
elfin isle
#

stuff gives me warnings sometimes (NOT ERRORS) about something

rocky canyon
#

include the VERY important: "In Unity" to stay off the watchlist

elfin isle
#

if(Player.GetComponent<Inventory>().Spear.active == true)

unity doesent like when i use this

#

why?

rich adder
rocky canyon
#

what is .active?

#

that ur own variable?

elfin isle
elfin isle
rich adder
#

ah yes, use activeSelf

elfin isle
#

literally .setactive

elfin isle
rich adder
#

probably some extra stuff done internally I have no clue about lol

elfin isle
#

ah okay

rocky canyon
#

not sure the difference

elfin isle
#

tysm guys C: i feel smarter now

rich adder
#

when you see ⚠️ its just a warning, not gamebreaking / still compiles fine and works but should be addressed at some point

rocky canyon
#

🗨️ w/e
⚠️ w/e
🛑 hold up..

elfin isle
#

lmao ye

rocky canyon
#

unless u have soo many w/e

#

that u can't find ur hold ups

elfin isle
#

okay i m confused

#

with all my new code

rocky canyon
elfin isle
#

no matter how i change the values the fish just arent moving now

rocky canyon
elfin isle
#

yeeeaaaahhh

verbal dome
elfin isle
rich adder
#

you never assign it back

#

FishPos

verbal dome
#

You need to assign FishPos back to the fish.transform.position

rich adder
#

if(transform.parent == null) IAmBatman()

rocky canyon
elfin isle
verbal dome
#

That just creates a new local copy of the position

#

Changing it doesn't affect the transform.position, you need to assign it back

rich adder
#

value types are copied, you never change the original

verbal dome
#

So do fish.transform.positoin = FishPos when you are done

rocky canyon
#

ur setting ur own variable FishPos to the Fish.transform.position; but u never do anything with it besides ~~read ~~ set it over and over

#

set it over and over*

verbal dome
#

But this will work fine

#

Just extra confusion

rocky canyon
#

heck ya 😄

#

i was just pointing out that Vector3 would come from a position

#

not a transform

#

well, not the Transform by itself.. but its .position

elfin isle
verbal dome
#

I have a feeling that y + (20f * delta) is incorrect tho
You reset y to iy + sine every frame so adding a delta scaled value to it doesn't make sense. You haven't told us what it's supposed to do

rocky canyon
#

i see u setting the rotation.. but never the position

#

Fish.transform.position = FishPos; seems to be missing somewhere.. (if ur trying to move the fish)

elfin isle
#

okay im getting really confused

elfin isle
#

and yeah its still not working

rocky canyon
#

was clicking the wrong link

elfin isle
rocky canyon
#

i'd check if ur else statement is ever running then

elfin isle
#

well the else statement still moves the fish

#

just differently

rocky canyon
#

ohh okay

#

i thought u had sed it wasnt moving at all

#

maybe b/c of the first code

rich adder
#

btw when you add Time.deltaTime you might have to crank up some values

rocky canyon
elfin isle
#

i multiplied them all by like 20

#

and then i checked and they arent moving at all

#

i figured it out

#

i was being stupid

rich adder
elfin isle
#
        Vector3 FishPos = Fish.transform.position;
        if(!Copy)
        {
            if(FishPos.x >= 35)
            {
                    Destroy(Fish);
            }
            if(Fish.GetComponent<Fish>().isAlive == true)
            {
                    num += delta;
                    y = iy + (2f * Mathf.Cos(num * 2f));
                    Fish.transform.position = new Vector3(FishPos.x + (4 * delta), y + 0.5f, FishPos.z);
            } else {
                Fish.transform.position = new Vector3(FishPos.x + (0.02f * delta), 0.73f, FishPos.z);
                Fish.transform.rotation = Quaternion.Euler(90f, Fish.transform.eulerAngles.y, Fish.transform.eulerAngles.z);
                Fish.GetComponent<Outline>().OutlineColor = Color.white;
            }```
#

i needed to change FishPos to Fish.transform.position when setting the new vector

verbal dome
#

Doing cs FishPos = ... Fish.transform.position = FishPos;Isn't different from doing cs Fish.transform.position = ...

rich adder
#

wdym
this is the same thing as this you had

   FishPos = new Vector3(FishPos.x + (0.8f * delta), y + (20f * delta), FishPos.z);
                    Fish.transform.position = FishPos;```
verbal dome
#

Maybe you just forgot to save before 🤷‍♂️

elfin isle
#

idk lm ao

#

oh hey

#

do you guys wanna see my stupid ass jump code

#

its very very bad

verbal dome
#

Ass jump? Hell yeah

elfin isle
#

and then this is how i use y

        Vector3 movement = (horizontal + (transform.up * y));
        controller.Move(movement * Time.deltaTime);```
verbal dome
#

Idk what you are doing with the fall value but that code also depends on frame rate

elfin isle
#

yeeee now i need to put delta in there

verbal dome
#

Maybe just look at a tutorial for character controller jumping and gravity

#

Because that paste looks pretty bad indeed

elfin isle
#

okaaayyy

elfin isle
rich adder
#

they finally fixed it to 1 Move call 🥹
Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up);
controller.Move(finalMove * Time.deltaTime);
what a time

copper nymph
#

hello guys, could anyone help me because i dont know why but my particles stopped showing up

copper nymph
#

thank you

frigid sequoia
#

I am destroying a UI element and I am marking the layout for a rebuild but it just doesn't do it. It does get fixed when I change resolution tho.

#

What am I doing wrong?

lusty grail
#

I can't import any sound, anyone know what is wrong with it?

twin pivot
pure hollow
#

Quick question!
Im trying to use logic on this piece of code but I think im forgetting something
What I want to achieve is an object that follows the player with varying speed based on the distance but stops before reaching the player.

Heres the code

Vector2 endPoint = transform.position + (player.transform.position - transform.position).normalized * (Vector2.Distance(player.transform.position, transform.position) - 2);
rb.linearVelocity = Vector2.MoveTowards(transform.position, endPoint, speed * 100 * Time.deltaTime);

What I "THINK" should happen is:
-I get the normalized direction to reach the player
-Then I multiply it by the distance, but since that would just give me the player position I shorten it by 2
-After all that I just use Unity's moveTowards function

verbal dome
lusty grail
verbal dome
#

Start by googling that

twin pivot
#

Also what is happening instead

pure hollow
#
rb.linearVelocity = Vector2.MoveTowards(transform.position, endPoint, speed * 100 * Time.deltaTime);```
eternal falconBOT
pure hollow
#

ohhh ok

#
Vector2 endPoint = transform.position + (player.transform.position - transform.position).normalized * (Vector2.Distance(player.transform.position, transform.position) - 2);

rb.linearVelocity = Vector2.MoveTowards(transform.position, endPoint, speed * 100 * Time.deltaTime);
#

Instead it gets away from the origin point exponentially faster

verbal dome
#

Might wanna check the doc for how MoveTowards actually works

naive pawn
verbal dome
#

Currently you seem to be plugging a position to a velocity

naive pawn
#

also that endPoint seems a bit... overengineered?

naive pawn
#

yeah do you see the issue with that

pure hollow
#

ohhhhhhh

#

OHHHHHHHH

#

Oh ok I think i see

twin pivot
#

A bit unrelated but is that endpoint formula the lerp formula?

naive pawn
#

doesn't look like it

pure hollow
#

But I understand now, I was just being dumb

naive pawn
#

if the distance is < 2, your original code would make the object walk away from the player
this version makes the endpoint the object's current position

verbal dome
#

I think the endpoint should be something like cs Vector2 directionToPlayer = player.transform.position - transform.position; Vector2 endPoint = player.transform.position - directionToPlayer.normalized * 2;

#

If you want the endpoint to be 2 units away from the target, while keeping distance

naive pawn
#

yeah osmal's version keeps the same behavior

#

different magnitude calculation for the offset
your existing code/osmal's sets the magnitude to 2
mine clamps the magnitude to 2
but overall same idea

verbal dome
#

Yeah my version keeps the distance, so if it's < 2 units away then it would move away instead of towards the player

lusty grail
#

like, it doesn't tell me how to solve it

#

mp3,wav, or ogg doesn't work idk why

verbal dome
lusty grail
#

yeah but i get no response

verbal dome
#

Then wait, and also share more details like what platform your editor is on and what platform you are building for

fiery breach
#

im interpreting lua using moonsharp and trying to make it draw text on the screen. it adds a (string text, Vector2 position) item to a list of them and OnGUI scans through the list and draws each text. BUT if i clear the list at OnGUI, Update or LateUpdate the text simply doesn't draw at all. could someone help me thru this?

#

nvm i got it to work

#

turns out it only took 5 misspellings of "oops" to fix it

frigid sequoia
#

Mmmm.... why this error? None of these objects have a RectTransform, they only use a sprite Renderer

#

I cannot even call that method lol

naive pawn
#

also of course you wouldn't be able to call the method, you wouldn't have anything typed as a RectTransform there

frigid sequoia
#

Quite literally I am clicking on the debug line link

naive pawn
#

it's pointing to the transform.parent = ... line?

frigid sequoia
#

Yes

naive pawn
#

None of these objects have a RectTransform
validate this assumption then, try logging all the waypoints

#

just something like Debug.Log($"{waypoint.gameObject.name}: {waypoint.transform}", waypoint.gameObject); in the loop

frigid sequoia
#

Wait, wtf, THEY ARE. They were normal transforms before, 100% I even took the reference of their possitions to set the default possition

#

I don't even know how to do that if I wanted to

polar acorn
#

Did you make them children of a canvas at any point

frigid sequoia
#

I think I may have added a Canvas to them by mistake at some point

#

But the rectTransform stayed there even after the removal I suppose

#

Can I even change a rectTransform for a normal transform?

polar acorn
#

Remove the RectTransform and it'll revert to a normal transform

frigid sequoia
#

Oh, wow, surprisingly easy

maiden estuary
#

Oh by the way, is there anything I should do in VS to make it easier to use or anything? I turned on the error box thing at the bottom last night, and I'm wondering if there's any other like must haves

verbal dome
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

mortal shadow
#

how do i make it so my script disables the mesh renderer of the object that its on and not the whole object?

teal viper
#

It's like "how do I eat apple and not orange". Just don't eat orange🤷‍♂️

mortal shadow
teal viper
earnest wagon
#

question. is there a means one can programatically exit a unity game without too much issue?

#

idea is a 'blank' unity game who's only purpose is to exit itself for benchmarking purposes.

earnest wagon
#

thank

earnest wagon
tacit torrent
#

I really wish I could use something like the animation state machines to manage my boss attacks

tacit torrent
#

how

#

I couldn't find anything by searching "state machine" on the docs

#

Only the animation controller

cosmic dagger
#

A tutorial uses the animation state machines for an actual state machine. Use Google instead of searching the docs . . .

tacit torrent
#

Okay I'll check that out

cosmic dagger
#

There are pros and cons to using it. I can't remember (them), but the video should have all the info . . .

tacit torrent
#

Is it "finite state machines"

verbal dome
#

If you want to use the animator for a non-animation statemachine, you need to look into StateMachineBehaviours