#💻┃code-beginner

1 messages · Page 263 of 1

polar acorn
#

It doesn't look like Sound.AttackFlesh is a collection

rich adder
#

no such thing as good "Ai" its all crap search engine results mashed together + some babbling

polar acorn
#

What type is Sound.AttackFlesh?

weak geyser
#

Hello! I have a question. I have a wall that should be touchable from all directions, but the touch should be directed from some distance, so I inflated the collider. The green cube should follow the hand, which it does perfectly only in two rotations around Y axis at 0 and 180 degrees. I'm definitely handling the rotation wrong, but can't figure out how to do it right. How to do this right? Thank in advance!

proven junco
#

yeah but this one has more for coding

austere hedge
eternal needle
#

Well also one thing to consider is, since you dont know the basics, you are gonna need a entirely premade system. Not one that you code with, because you wont know how. Those are definitely gonna be expensive IF you find one u need.

polar acorn
rich adder
proven junco
#

so I get to undestand why I do something

#

but not how

#

so useful for understanding where and what to put

#

and more useful when I actually learn

rich adder
eternal needle
#

Oh u meant you use ai to code. I meant AI like a automated character in the game

proven junco
#

yeah

#

I mean rn that's the best chance I have

#

and ofc watching yt

#

but both is crucial rn

polar acorn
#

You could also, like, learn things

eternal needle
#

No, your best chance is to ask your teacher for advice on what you can do. Maybe get an extension and ask them what kind of game can be reasonably done

proven junco
#

and I spend a lot of time

#

yeah well pal this is bigger then just a game project

#

so I am kinda screwed

polar acorn
proven junco
#

yuh should have

#

but here I am

#

learning as much as possible in a really short time

#

and getting codes from ai

eternal needle
# proven junco and getting codes from ai

You really dont wanan end up like half the people in here who use AI. With systems they dont understand, which doesnt work, and then they try to fix a system which was flawed from the start.

#

Sure, itll do the absolute basics correctly, but when it gives you a hammer instead of a saw, you wont know the difference. Then you'll be stuck wondering why you cant cut anything with a hammer

#

Anyways, AI code isnt allowed in here so you also likely wont be getting help if you choose to continue with it.

austere hedge
uncut wolf
#

I've done everything it said here it still doesn't work.

polar acorn
wintry quarry
austere hedge
#

No, I haven't worked with enums much. I wasn't sure if any of the values I put in the original enum were carried over once I made a new list.

rich adder
wintry quarry
proven junco
austere hedge
#

Got it.

uncut wolf
rich adder
rich adder
uncut wolf
proven junco
#

I've found some

rich adder
proven junco
#

but don't really know what is best

austere hedge
#

I think this is right.

rich adder
polar acorn
#

If you had it in that list, why would you need to add it to the list

proven junco
austere hedge
#

I don't understand. The list started off empty, but I'm not supposed to add to the list?

rocky canyon
#

same concepts..

proven junco
#

alr

rocky canyon
#

the basics of c# doesnt change

polar acorn
eternal needle
polar wasp
#

just figured out how to solve a system of equations with a matrix lol

#

i really should not have dropped out of college

queen adder
#

yo i followed this tutorial on data saving and we were printing an error when we can't find save file and it prints for me so how to fix this?
https://www.youtube.com/watch?v=XOjd_qU2Ido&t=957s

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

public static class SaveSystem
{
    public static void SavePlayer(DataGroup player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string path = Application.persistentDataPath + "/player.fun";
        FileStream stream = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player);

        formatter.Serialize(stream, data);
        stream.Close();

    }

    public static PlayerData LoadPlayer()
    {
        string path = Application.persistentDataPath + "/player.fun";
        if(File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open);

            PlayerData data = formatter.Deserialize(stream) as PlayerData;

            stream.Close();

            return data;
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return null;
        }
    }
    
}

Here's everything you need to know about saving game data in Unity!
► Go to https://expressvpn.com/brackeys , to take back your Internet
privacy TODAY and find out how you can get 3 months free.

● Easy Save: https://bit.ly/2BzgdXb

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

·····················································...

▶ Play video
queen adder
polar acorn
queen adder
#

so how to create it?

polar acorn
short hazel
#

Save once first. The code that saves the file will create it if it's not there

short hazel
#

As per the FileMode.Create argument.
But also I wish this video did not exist since they use the BinaryFormatter which has security vulnerabilities

#

Consider using another means of serializing your data, like with JSON

austere hedge
# rich adder made it worse

I'm not ready to jump into Dictionary with this quite yet. I'd like to figure out what I'm doing wrong. I thought the goal to be able to pass AttackFlesh[i] to the method was to add AttackFlesh1, AttackFlesh2, AttackFlesh3, and AttackFlesh4 to the AttackFlesh list. Based on what digiholic said it sounds like that's either not the case and/or I'm doing it wrong.

polar acorn
weak geyser
# eternal needle What is the hand object, is this some UI object? You may be able to raycast from...

The hand is just a kinematic rigid object at the moment. I have a problem with the spatial relations. I was thinking about raycast and another collider, but there are other limitations for the green object's position on top. Now I am thinking that maybe I can use the Transform's right and forward vectors that should rotate together maybe... after the changes of the basic code between different versions of Unity - I have hard time figuring out what holds and what doesn't.

polar acorn
austere hedge
#

Yes.

polar acorn
austere hedge
#

Now I'm just trying to figure out how to get the shoes on the table in the box.

#

I think I see the problem.

polar acorn
#

Programming deals with logic and rules. If you don't even understand basic reality to the point that the scenario provided makes sense, it will be impossible to help

polar acorn
#

Just like if you want to add something to a list, you add that thing to the list

#

You don't add an element of the list to itself

austere hedge
#

I understand now, I didn't realize I put the list back into the Add section.

#

I am working on trying to add the enum into the add section instead of the list itself.

static bay
polar acorn
wintry quarry
#

A list is a list

#

it doesn't have sections

#

it starts empty. Things don't exist inside it until you Add them

polar acorn
#

The parameter to Add is the thing you want to add to the list

rocky canyon
#

i think he just means the .Add function

polar acorn
#

If you want to add one of your enums to the list, add that to the list

austere hedge
#

Yeah, I've looped back to the same original problem. (Image 1)

I can make it work if I do it this way though, but not as ideal. (Image 2)

polar acorn
#

Why are you trying to index it like a list

#

And the second image is what you should be doing

#

that's the solution

static bay
polar acorn
austere hedge
#

Oh, but I need to get rid of the for loop now.

static bay
wintry quarry
#

yes they can do that certainly

weak geyser
austere hedge
#

I think I have what I need. I'll work more with dictionaries in the future, but for now I'll be avoiding unless I run into a situation where it's required, or once I'm more comfortable with lists. Thanks digiholic.

static bay
# wintry quarry yes they can do that certainly

Real problem here is this that enums aren't good for this scenario. Some type of string ID to AudioClip dictionary would be best, but even that is likely overdoing it.

@austere hedge What's your goal exactly? Do you just want to play a random sound?

austere hedge
#

My goal is to keep all sounds within a Sound Manager so I don't have to add an audio source for every single sound. Some of those sounds I want to play from a selection of random sounds instead, so in the example of AttackFlesh I want it to make a different attack sound each time an attack happens. So some sound effects are random, others are always the same.

rich adder
#

List<AudioClip> fleshSounds

#

etc..

polar acorn
#

You could just make a list of AudioClips and then play a random one without needing an enum at all

#

A list with only one clip in it means that clip is the only one that can be rolled

static bay
austere hedge
#

The tutorial video that I went through on how to create a sound manager utilizes enums, so that's why I have been using them.

rich adder
#

enum can be useful to know which sound type/audioclip to play

austere hedge
rich adder
#

not storing sounds

static bay
austere hedge
#

Yes.

polar acorn
austere hedge
static bay
eternal needle
austere hedge
buoyant knot
#

can a string hold japanese characters?

#

ty

rocky canyon
rich adder
#

imagine a neat buckets you can throw your sounds in

wintry quarry
austere hedge
rocky canyon
#

yes.. creating and destroying over and over is bad for performance

austere hedge
rich adder
#

and yeah def add audiosource on it

#

I keep a few so i can split them inside the Audio Mixer so users can decrease different sounds like Bg musics vs SFX

weak geyser
# eternal needle How is the hand controlled though? Because if it's by the screen space (user is ...

It's a mockup for VR. But this specifically is just a static puppet that I drag by hand for debugging. Somehow it seems I forgot how the scale influences everything. Normalized vectors in combination with global wall position seem to give a stable reference after all. Now I need to define all the limitations for the green cube with this in mind, and then make it work from all sides... Thanks for your help!

static bay
# austere hedge I started with PlayClipAtPoint originally, but if I remember correctly the issue...

At the end of the day you're going to need to specify some "collection" of potential sounds to play. Try adding a method like this to your SoundManager.

    public void PlayRandomSound(params Sound[] options)
    {
        if (options.Length == 0)
            return;

        int randomIndex = Random.Range(0, options.Length);
        Sound chosenSound = options[randomIndex];

        //Play your shit.
    }
```And then you can just specify the options by listing them off like this.
```cs
    soundManager.PlayRandomSound(Sound.ZombieAttack, Sound.CoinTwinkle);
```Assuming an enum like this.
```cs
    public enum Sound
    {
        ZombieAttack,
        CoinTwinkle,
        Eating,
        Drinking
    }

I agree with the others though that enums aren't the best for this.

stone nimbus
#

how do I reset the deltaTime, can't find anything online?

slender nymph
#

wdym by reset the deltaTime?

stone nimbus
timber tide
#

make a timer

stone nimbus
#

and I use deltaTime as timer

slender nymph
#

and why would that have anything to do with deltaTime? you reset your timer variable

rich adder
#

so reset the number you increased with deltaTime

stone nimbus
#

ouh

austere hedge
#

I will work on converting from enums to a list of audioclips. Thanks guys.

stone nimbus
#

bro i'm stupid

sour yew
#

hey guys. can smb help me out? visual studio doesnt recognize unity code for some reason. although i have unity extension installed for the ide. and as always, theres no info on how to config it.can smb help me out? thx

eternal falconBOT
slender nymph
#

regenerate project files and restart visual studio after following the instructions

tawny cave
#

I have this error, and here is the script (line 27 triggers the error with mesh.enabled)
Can anyone help fixe it please ?

slender nymph
#

swap the two lines in Start

#

you're getting an exception on that first line because it hasn't been assigned so it never calls GetComponent

#

oh and always start debugging your issues with the first error in the console

rich adder
#

weird that you serialized EmoteTrigger in inspector but not MeshRenderer :p

tawny cave
sour yew
tawny cave
rich adder
slender nymph
obtuse axle
#

Hello, I have an issue, i forgot how you could teleport a player to specifc coordinates. Anyone can help pls?

slender nymph
#

!code

eternal falconBOT
eternal falconBOT
slender nymph
#

double kill

obtuse axle
#

mb

slender nymph
#

does the player object have a CharacterController on it?

wintry quarry
#

You can just get the reference from OnTriggerEnter

#

Also

#

OnTriggerEnter takes a Collider parameter

#

not a Collision

slender nymph
#

they do have a Collider parameter, it's just named collision

obtuse axle
wintry quarry
obtuse axle
sage mirage
#

Hey, guys! I have a small problem. I am instantiating game object but whenever I want to enable my options menu my clone game objects are still active. So, I have a game object to my prefabs and I am instantiating them. For one reason only my first original game object deactivates but my clones/instances are staying there. Can you please me?

stone nimbus
wintry quarry
#

or use events

polar acorn
stone nimbus
rocky canyon
polar acorn
wintry quarry
#

there is no link between the clones and the original

sour yew
spiral narwhal
#

I'm thinking of adding a UI Scale setting in my game and would do it like this:
Have a scene loader script that accesses all Canvas objects and sets their localScale to the setting value.

I was asking if there is a builtin Unity functionality for this or if this is how its done

unreal comet
#

Im creating some text ui in a flappy bird game for the score, and in the scene viww the text is easily 10-20 times the size of my flappy bird, but in game view it is so small that only a little bit of it fits on the screen. Another thing is that the positioning in scene view vs game view is not consistent

polar acorn
#

Can you send a screenshot of your canvas with the text on it

unreal comet
#

I tried to click on the canvas element but there is not overview or any indicators showing me where it is, but i see it in my hierarchy

sacred rapids
#

sorry for the vagueness hard to explain. i have a script that simulates a guns recoil (on the camera) basically lerps the current position to the target position then resets to where it started. the issue is if you move the mouse down to control the recoil, after you stop firing, even if you are not moving the mouse anymore, it will reset lower than were it started. i want it to be in the same spot you started, or just not have it reset at all but every time i try and implement either of those the screen jus go crazy start shaking after firing a few rounds. https://hastebin.com/share/vikujugara.csharp

#

should probably put this in the advanced one

polar acorn
unreal comet
dawn kestrel
#

so, I'm modifying code someone else wrote, and I want to keep changes to a minimum. Is it possible to create a script that essentially "appends" to a class from another script, and allows me to add variables and methods to that class, and write code as if the appended methods were inside the class itself, private variables and all?

polar acorn
# unreal comet

So, this New Text is pretty tiny in the bottom left corner of your canvas. That's why it's pretty tiny in the bottom left corner of your screen

polar acorn
# dawn kestrel so, I'm modifying code someone else wrote, and I want to keep changes to a minim...

Kind of. You can make extension methods:
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

But you cant add variables or anything to that class

unreal comet
polar acorn
sacred rapids
#

yea just select the canvas and hit f then scale it how u want

polar acorn
sacred rapids
#

i meant the text inide it

polar acorn
#

Right. That's what should be changed

#

the canvas itself is where it is for a reason, so it can use pixels as coordinates and have a 1:1 correlation between screen space position and transform

#

So you shouldn't touch that

proven junco
#

how would someone make an UI that uses Int to categorize Objectives and have a script that gets rid of the tasks that are done and with that get rid of the interactive ui.

lone comet
#

Is there a best method to define swappable behavior in the editor? The best thing I can think of is to have a class with an empty method that other behaviors (in this case interactions) override and hopefully that will let me swap them as a parameter in the editor?

proven junco
#

like having an int system that categorizes all objective and when one obj is done it switches to the other obj "int = 1-10" " int = 1 = obj 1

lone comet
proven junco
#

what and how

#

in small word

lone comet
#

You would use your int as a unique key and your objective as a value for the dictionary.

#

YT should have a lot of great tutorials aswell.

sage mirage
eternal needle
sage mirage
#

How to disable already existed clones/instances of my game object?

quiet scaffold
#

Why does the enemy (red cube) ignore ALL colliders except the players? the orange cube also has a collider, i can collide with it, but the enemy completely ignores it?

polar acorn
stone nimbus
#

can someone help me to do a score board in my racing game? Idk how to sort them. I get values for min, sec, millisec and need to do a all time player highscore board and idk how to realise it. Google also doesn't help at all

quiet scaffold
#
transform.position = Vector2.MoveTowards(transform.position, playerPrefab.transform.position, moveSpeed * Time.deltaTime);
polar acorn
quiet scaffold
#

is MoveTowards not physicS?

devout flower
#

Rigidbody is physics

polar acorn
quiet scaffold
#

ohhhhhh

scarlet skiff
#

wait why did i get 2 "start"?

polar acorn
scarlet skiff
polar acorn
#

see what objects have the script

thin hollow
#

how do i call the Sprite in a script?

#

light.sprite inst working

chilly moat
#

guys why this isn't working 😦

#

it be such simple code

devout flower
#

Isn't working how?

#

Error message? Not intended result?

chilly moat
#

it just ignores the entire operation and prints out the little 'ö' despite my efforts to substitute it with some variable

#

no error tho

polar acorn
#

Your string could be, for example, ö\n and you wouldn't enter this condition

scarlet skiff
polar acorn
eternal needle
ionic zephyr
#

How can I create a method that only executes WHILE Im pressing a key with the Callback Context stuff?

scarlet skiff
#

cuz i checked that

polar acorn
scarlet skiff
#

ah

#

ok yea it has the script twice, my thinkign process was almost right 💀

#

imma check my scripts see were this happens

dawn kestrel
#

https://hastebin.com/share/supiyubawo.csharp

For some reason, Unity keeps throwing this error that I appended to the bottom of this code.

polar acorn
dawn kestrel
#

is assigning it in the class not good enough?

polar acorn
dawn kestrel
#

wait, maybe I am misunderstanding the meaning of the term "assign". Is that different from either setting a value to it or declaring it?

polar acorn
scarlet skiff
#

I dont want it to clone the current one i want it to use the prefab... how come it wont? i have dragged the prefab into that slot

script incase its needed: https://gdl.space/uwijixipad.cs

polar acorn
scarlet skiff
#

its like its not refering to the prefab but the spawned bomb

polar acorn
#

You could very easily be changing it in another class this way

scarlet skiff
#

sounds like a tip to think about in general

polar acorn
#

Make it private and see if you get any new errors. That would be a different script modifying it which would mean that's your problem

#

This is the reason you generally should always use private unless you very specifically need to access it from another class

scarlet skiff
chilly moat
#

my first time manipulating strings so I might be missing a lot

scarlet skiff
#

its still closing the gameobject

dawn kestrel
#

oh huh, so assigning "default" to worldLocation didn't give it a default valid Transform?

polar acorn
scarlet skiff
#

but ye i dont think u meant that as a solution just a tip i think

polar acorn
dawn kestrel
#

ah. Is there shorthand for a Transform with zeroed out position and rotation, and a scale of 1 in all directions?

cerulean stag
#

I tried a year or so ago, I'll try getting into unity again (I fell back into roblox development again)
(aka I'll be asking a lot of Q's later, may or may not have sent this message in the wrong chat)

polar acorn
chilly moat
#

man none of this stuff works 😦

polar acorn
scarlet skiff
#

There is only one prefab and at the time i took that ss only one instance in the scene, the only other script the bomb has is this but ye it doersnt change anything but that instances renderer not anything in the prefab

#

ill check what spawns the bomb but i dont think there is naythign thee either

polar acorn
chilly moat
#

this works, neat, thanks guys who pointed me in the right direction

violet token
#

Any suggestions on how to handle tutorial on new game vs no tutorial on load game?
I've searched online but no luck, keep showing me tutorials on a bunch of stuff but not how to implement gameplay tutorial within a game

scarlet skiff
#

how could this happen

polar acorn
#

So when the prefab is spawned it updates the reference to "itself"

#

I'm not actually sure the best way to deal with this, hang on

#

In general, having a prefab spawn more of itself is a bad idea since that's a fast track to stack overflow-town

#

I think you'll need to have a different object pass the prefab reference to this object after you spawn the first one. The prefab is designed to replace references to parts of the prefab with their in-scene equivalents when instantiated. It's how you can drag in the Rigidbody of the prefab and the one in the scene properly references the Rigidbody on that object

ionic zephyr
#

How can I do "while pressing a Key" with CallbackContext stuff

timber tide
scarlet skiff
#

well uhm

#

what im trying to do is spawn 2 more bombs when the first one hits the grounbd, just that they have slightly different movement, so thats why i used the prefab itself to spawn those new ones

#

i suppose i could create another rpefab for the smaller bombs?

#

but that would be mean more scripts, and maybe even confusion down the line

#

or i could without a prefab somehow create the smaller bombs?

polar acorn
obtuse axle
#

Guys do you recommend fishnet or Photon for multiplayer and which is easier and faster to implement?

polar acorn
#

I'mma be honest if you see fit to post in #💻┃code-beginner my recommendation is neither and don't make a multiplayer game yet

#

But if you really do feel confident in your abilities, #archived-networking would be where to ask about frameworks

scarlet skiff
violet token
#

Storing prefabs within prefabs can become confusing

#
Instantiate(Armory.bigBomb, transform.position, Quaternion.Identity);
Instantiate(Armory.bomb, transform.position, Quaternion.Identity);
Instantiate(Armory.smallBomb, transform.position, Quaternion.Identity);
scarlet skiff
#

so that way it doesnt inherit from itself

violet token
scarlet skiff
violet token
#

You would have to create a method to call i.e. "Armory.LoadBombs();" that will load your bomb prefabs

#

At the beginning you will call this method to find and store all bombs for later use

silk night
# scarlet skiff u mean something like thsi but for prefabs?

The way i did that was put all prefabs I want to dynamically load in Resources folder and then have a code generator that looked for all resources with the .prefab ending, then create a class that looked like what you have above, then you could just load the desired prefab with Resources.Load(Names.xxx) while not even having to manually setup the names class

outer frost
#

First time here, is this the place to look for answers to problems? Also I don't want to interrupt what's going on here if your problem solving things.

violet token
#

I wouldn't say answers lol

#

Guidance

silk night
ionic zephyr
#

Does somebody know how to Deactivate Inputs while "Blocking"??

outer frost
#

lol, well im Day 3 of learning C# and Unity so im hoping someone can assist

spiral narwhal
#

Using the new input system, why is there started, canceled and performed, but not updated for hold actions?

I want to know the percentage the key is held before being performed?

silk night
timber tide
#

if(blocking) -> dont read input

ionic zephyr
polar wasp
timber tide
ionic zephyr
#

this is the structure

#

i want that whenever OnBlock, It generates a shield which makes the player not to do any other input),

outer frost
#

!code private void Awake()
{
if (instance == null)
{
instance = this;
}

 iconHandler = FindObjectOfType<IconHandler>();

 Baddie[] baddies = FindObjectsOfType<Baddie>();
 for (int i = 0; i < baddies.Length; i++)
 {
     baddies.AddRange()baddies[i];
 }

}

eternal falconBOT
silk night
outer frost
#

i cant get .Add to work

#

it keeps putting in AddRange

obtuse axle
#

Guys anyone knows how to correctly use Git?

#

Especially GitLFS

silk night
# ionic zephyr

Depends on how complex your stuff is, you can switch a different key map, you can create a seperate keymap that holds all stuff that should be disabled while blocking and just turn off that keymap while blocking

#

or just manually do ifs in the actions

ionic zephyr
#

this is the method

timber tide
#

there's no real continuous callback with the new input system so you may need to poll stuff yourself despite it being more event based

ionic zephyr
#

the thing is that if I disable PlayerInput, the method doesn´t even execute

silk night
outer frost
#

sorry made a correction to that code i posted, this is my issue.

timber tide
#

you can disable the input, but honestly I'd just read the state that you're in and just decide not to move

#

or w/e behaviour you're looking for

timber tide
outer frost
#

I am basically following a tutorial and everything looks correct to the letter but his works and mine doesnt

timber tide
#

actually you're adding it to itself eh

outer frost
#

ill give a full picture to show more

timber tide
#

Is there a this that you're missing maybe?

outer frost
#

nope thats in another script

timber tide
#

looks like you're missing a this

outer frost
outer frost
#

its in this script

ionic zephyr
#

isnt there another way to do it?

timber tide
# outer frost

basically in the class scope you have a baddies in the class outter scope, but in the inner scope you also have a baddies

#

so you need to clarify what baddies you are using and to do this you use the this syntax keyword to clarify that this is the class scope variable

outer frost
#

ok, i see the issue. This is day 3 for me so i understand alot of what i read but dont know how to do it on my own

timber tide
#

or, just dont use the same name in the inner scope

outer frost
#

lol

#

Thanks Mao, ill see what i can do

timber tide
#

ye np

ionic zephyr
#

Ive realized if I use Unity Events for Inputs it doesnt matter if I disable a Script

#

first

#

is that true?

#

and also, how can I solve thos?

timber tide
#

disabling an object usually just stops any update loops, but methods are still callable

#

so if you want to prevent using that object's methods completely, then consider using your own flag

scarlet skiff
#

although.... it is also a learning opportunity... hmm

timber tide
#

and sticking them into each method call

public void NewMethod()
{
  if(!activeBool) return;
}```
silk night
polar wasp
#

how in depth should i go into linear algebra

ionic zephyr
#

which controlls if I can call them?

silk night
buoyant knot
timber tide
polar wasp
buoyant knot
#

but you only need a very strong understanding of the basics of vectors, dot products, and geometry for unity

timber tide
#

read into that

ionic zephyr
polar wasp
timber tide
#

tells you how to enable and disable actions

buoyant knot
polar wasp
#

so to learn the other parts of what i'm trying to learn, i should learn all of this? 🥲

#

i'm following a youtube series and taking a lot of notes

buoyant knot
#

quantum mechanics, ODEs, PDEs, anything with waves needs it, computational stability needs it, any multivariable math needs it, high level statistics

#

it’s basically mandatory for any of those

timber tide
# ionic zephyr I am using Ujnity Events

Ah, ok. I don't usually use unity's events but I would assume you can unsubscribe similarly to c# events, but otherwise the flagging method I've shown is straight forward.

buoyant knot
#

if you don’t know linear algebra, you can expect to struggle in higher level sciences

timber tide
#

otherwise read those documentations I've linked and bind input to the class

ionic zephyr
#

Okay, thanks

polar wasp
buoyant knot
#

if you want to be a great programmer, it is also naturally required, as there are several things that require an underatanding of it

#

you don’t need a full course on linear algebra to do game development

scarlet skiff
buoyant knot
#

in game development, if you don’t understand vectors, you are shit out of luck, friend

#

like, really screwed. lots of things you just can’t do

dawn kestrel
#

is it possible to create what looks like a Transform, but isn't tied to a game object?

summer stump
#

But yeah, you could create a struct with some values similar to a Transform

eternal needle
buoyant knot
dawn kestrel
#

I suppose nothing, except maybe my current workflow? Basically I want to make a reference point on an object, but for now I did just make it as its own object with its own script.

buoyant knot
#

it is worth creating

summer stump
dawn kestrel
#

with its own rotation

buoyant knot
#

but you do need to make a gameobject for it

summer stump
#

If you need more than that, just use an empty gameobject

buoyant knot
#

yep, gameobject with a script that tells it what it should be, and some sort of rendered thing to be controlled.

dawn kestrel
#

right now I'm just rendering a gizmo (though accidentally discovered in the process that if you draw a gizmo using several colours, then the lines drawn later will always appear in "front" of earlier lines)

summer stump
#

Compared to the extremely cheap empty gameobject

dawn kestrel
#

I mean, the gizmo is literally just to see where the otherwise empty object is when its parent is selected

buoyant knot
#

gizmo is unique to editor mode

#

it will not display ingame

#

gizmos are literally designed for this sort of thing in editor mode.

summer stump
buoyant knot
#

i do the exact same thing in my game for anchor points

#

my objects have a specific point considered to be its grid origin position, which i display with gizmos.

#

player has no business caring about this

dawn kestrel
summer stump
buoyant knot
red geyser
#

how can I require a button to need multiple presses before becoming inactive?

I currently having a button working that will SetActive(false) after being clicked, but I want to require an amount.

Something like create a variable buttonPresses and then assign it a static amount?

buoyant knot
#

disable the button component using a function

summer stump
buoyant knot
#

keep a variable of button presses

#

check if button presses == max button presses

red geyser
#

ahh, so similar to setting something active if you need x currency to buy?

#

but in reverse

buoyant knot
#

yes

red geyser
#

ty I think I understand ❤️

#

trying really hard to get off the tutorial addiction lol

dawn kestrel
#

though, the one I made for the reference point is this one, which is just there to remind me where the empty game object is when said object isn't selected. Maybe it was a bit of a waste of effort, maybe I'm just procrastinating a bit before getting to my next task >.>

buoyant knot
#

i made a static class to make stock shapes with gizmos

#

like DrawArrow, DrawTriangle, DrawX, DrawRectangle…

dawn kestrel
#

do you know of any way to change the order in which lines are drawn, based on where your viewpoint is?

dire tartan
#

i honestly have no idea whats wrong here the error code is Assets\scripts\Launcher.cs(18,5): error CS0246: The type or namespace name 'Players' could not be found (are you missing a using directive or an assembly reference?)

summer stump
dire tartan
#

i mean im following this tutorial

#

and ive done it exactly as he has

#

there is no player script btw

summer stump
#

They could not have had this code if there is no script called Players

dire tartan
#

unless im too tired ive triple checked it so many times

summer stump
dire tartan
#

when i did what they did orignally it gave more erros

#

errors

summer stump
#

Player, not Players

#

As I said at first

#

There HAS to be a Player script for this to work too. They don't have an error, so they made one somewhere

dawn kestrel
#

could Player be defined in either Photon.Pun or Photon.Realtime? Would that work instead of making a Player script?

summer stump
#

If it is part of Photon, quick fixes may find the using for them

#

So, worth a shot

polar bane
#

can someone help me with c# i have been making a parkour game for my first projects and so far i have just been copying scripts and combining them can someone help me

summer stump
#

Show the code and any errors

polar bane
#

just generally understanding c#

#

there is nothing wrong with my code

dawn kestrel
#

do you have any background in any programming languages?

polar bane
#

i know some html and python also just a bit of js

summer stump
#

There are also resources pinned here in this channel

polar bane
#

ok thank you

summer stump
#

And of course !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

dim bridge
#

Quick Question what would be the easiest method of storing some very bare savegame data? All I need to save is a single integer for a highscore

polar wasp
#

and the book unity in action

#

i've been reading that one a bit

quiet scaffold
nocturne parcel
#

That's a very broad question. We'd need to know your intentions, how do you plan to expand the game, etc.

#

And also depends on the style?

wintry quarry
nocturne parcel
#

I myself prefer making things more modular

wintry quarry
#

An Enemy component - has the basic HP, take Damage, give XP etc
and a SlimeAI component - controls the special movement and attacking for slimes

#

there's not really a good reason to use inheritance here.

quiet scaffold
#

i see

nocturne parcel
#

Or he could just have one and a IDamageable interface

#

That's my go to method

wintry quarry
#

That requires you to reimplement the health etc on every script

#

i don't see what it gains you over just having a separate component

summer stump
#

I think the Enemy dying should be an event that the XPManager can subscribe to

wintry quarry
#

definitely ^

#

could even be a static event

quiet scaffold
nocturne parcel
quiet scaffold
#

thanks

wintry quarry
#

eugh

#

I mean yes

nocturne parcel
#

Unity may handle events differently, but start with the source

wintry quarry
#

but i hate how the .NET guide encourages the EventHandler pattern

#

it's fine for .NET apps

#

not the best for Unity games

nocturne parcel
#

I mean, yeah, but I guess starting with the OG guide ain't that bad

wintry quarry
#

yeah it's fine

nocturne parcel
#

I have this problem with Unity devs making everything observe patterns

#

In this second devlog, we look at how we employed ScriptableObjects to create a flexible and powerful game architecture for "Chop Chop", the first Unity Open Project.

🔗 Get the demo used in this video on the Github branch:
https://github.com/UnityTechnologies/open-project-1/tree/devlogs/2-scriptable-objects
(compatible with Unity 2020.2b and la...

▶ Play video
eternal needle
wintry quarry
#

I think he's talking about people following patterns as programmers

nocturne parcel
#

Yes, but Unity usually encourages making it again.

#

I mean, not Unity

#

ofc

#

For example, the observe pattern with SOs. Do you really need it?

#

"It's better for designers" is it really

#

Instead of just making an event, you'd create an scriptable object for the event, and a game object for every listener, etc.

#

I think it overcomplicates something that is already well made by the language

north kiln
#

"It's better for designers" is it really
Depends on the project

#

and the team

red geyser
# buoyant knot yes

would just like to say I did it, so thank you again! I appreciate it so much actually lol

nocturne parcel
#

Anyways, going out of scope here. I think that's a too deep of a topic to talk on the #💻┃code-beginner lol.

#

So for that, sorry.

cosmic dagger
nocturne parcel
#

Oh, I mean because it isn't about scripting really anymore?

#

So i think it would go out of topic

cosmic dagger
nocturne parcel
#

True

#

Well, my main criticism is how there is this pushing for the "remaking" of the observe pattern using scriptable objects when C# already does it well, so it only overcomplicate things.

#

Suddenly there is so many layers you can't even know what is using what and what is calling what

cosmic dagger
# nocturne parcel "It's better for designers" is it really

It is because designers can create their own events, set listeners (to these events) on GameObjects, and invoke the events from the inspector. This frees up the programmer and needing to wait for updates

It's one option for a person/team to use . . .

nocturne parcel
#

yes, not having too many dependencies and links are good, but cutting them out completelly makes the code so hard to fix when something is wrong

cosmic dagger
#

I wouldn't call it a push, but a designer-friendly method . . .

#

It's just an option for non-coders . . .

#

There are definitely issues with it—the layering you mentioned . . .

#

It's similar to using C# events vs Unity events (which I've taken a liking to) . . .

nocturne parcel
#

I mean, I'm totally not against it

#

In fact, I do use it

#

But a lot of things that could easily be solved with a line of code gets pushed into a code/design pattern

frosty lantern
#

hey how would I convert a mouse.delta to a vector2? I looked through documentation and I could get the individual fields, but they returned an axiscontrol type instead of a double or float

nocturne parcel
#

Can't you do ReadValue<Vector2>?

frosty lantern
#

thanks

frosty lantern
#

alright so I clearly have no Idea how quaternions work yet so heres some naive code of mine:

cameraTransform.position = playerTransform.localPosition + offsetLoc;
mouseRot = Quaternion.Euler(mouse.delta.ReadValue());
playerTransform.rotation *= mouseRot;
cameraTransform.rotation = playerTransform.localRotation * offsetRot;
#

My idea was if the mousedelta returns an x and y value, and the z value is zero for the euler, then it gets convertet into a quaternion for rotation, then in order to apply that rotation, I use multiplication, and since it only has x and y euler values it only rotates in he x and y local space

#

right?

timber tide
#

is this like topdown 2d rotation

frosty lantern
#

no, third person

#

the mouse rotates the character and tha camera strafes behind

#

think I used localrotation wrong

timber tide
#

there's a third person template from unity that you could probably rip apart

#

it's in the hub if you're interested

frosty lantern
#

yeah, I just want to get in the habit of learning how it works. I think the axes are misaligned, because up and down are rotating clock and counter, like the up and down of my right side
left and right are doing up and down

timber tide
#

I usually just use angleaxis for stuff and rotate on the world axis by an angle in xyz ordering

radiant glen
#

I am having a really weird issue, I have an image used for transitions, that in a few not all but a few scenes wont show up in, any ideas?

summer stump
#

Can you show the code that would have to do with this?

#

!code

eternal falconBOT
static mortar
#

so uhhh, im trying to make a sonic like game.
and i got movement working-ish.
i did use chatgpt to generate the code because i have no clue what im doing and i wanted to save some time
case in point, breaking and jumping doesnt work.

here is a video of very much what i mean.
and the code.

cosmic dagger
eternal falconBOT
static mortar
static mortar
cosmic dagger
# static mortar aight

Also, if you have no clue what you are doing, how can we provide help that you will understand or use to fix your problem?

cosmic dagger
# radiant glen

Use the links provided from their message to send your code . . .

summer stump
#

Looks fine there

static mortar
radiant glen
#

That is what I was thinking, it is the same code as some of my other scenes but this ones it doesnt show...

summer stump
static mortar
radiant glen
#

Okay thank you

pine pike
#

so i know i can't use a variable from one void to another (e.g. define in start void, but use in update void), but i dont want the variable redefined every frame. what should i do? fore more context, the variable is just textmeshpro.GetComponent<TMP_Text>()

wintry quarry
#

Make a field

#

Also that thing you wrote is not a variable it's an expression

pine pike
#

oh sorry, thanks

low perch
#

when I import photon pun I keep getting
InvalidCastException: Specified cast is not valid.

It's an error that goes to PhotonNetwork.cs

photonServerSettings = (ServerSettings)ScriptableObject.CreateInstance("ServerSettings");

I've search everywhere and nothing matches this

wintry quarry
#

Even that code snippet is dated

#

Why isn't it using the generic form?

low perch
#

well it's cheap and simple but also I'm not doing it for me

low perch
wintry quarry
#

The generic form of CreateInstance

#

E.g. CreateInstance<ServerSettings>()

low perch
sleek thorn
#

I'm developing my first project in unity and I'm stuck at how to detect collision with a TextMeshPro object.
Would someone be able to help out with this, please?

wintry quarry
#

TextMeshPro has nothing to do with physics

sleek thorn
#

Should've added more context. I tried adding a BoxCollider 2D to it.
The work around I've been trying out is making the text a child of a 2D square, sizing the collider to match the text, adding the BoxCollider 2D to the 2D square parent, and enabling the isTrigger flag.

wintry quarry
#

When you say "TextMeshPro" are you talking about the UI version or the world space version?

#

If you're talking about UI then this is all completely off base

#

UI lives in a completely different coordinate system than physics objects

sleek thorn
#

The UI version. I tried changing the layer to default. I understand what you are saying about the use-case of having a UI Text object though, that it's not intended to be a physics body.
I guess that why I'm here, to figure out a way to get the desired outcome :)
All I care about is having a visual of a text, and detecting when the player collides with it. Is there a way to achieve this?

wintry quarry
#

That's the simplest way

#

A more complicated way is write some code to position a world space invisible collider in the position , size and shape that corresponds to the UI element converted to world space

sleek thorn
#

Got it, I can totally use the world space version. To clarify, this would be just changing the render mode to World Space?

rich adder
#

there is mesh version of TMP too

sleek thorn
#

Yeah, I was looking into it - added a rect transform, added the collider and resized it, but I couldn't get it to work. Is that what you have in mind?

rich adder
#

you added it from here yes?

sleek thorn
#

Oh, no, I just used the one under UI. I'll try the one under 3D obj

wintry quarry
#

And don't put it inside a canvas

sleek thorn
#

Okay, thanks!

covert sinew
#
    public void OnDrag(PointerEventData eventData)
    {
        mousePosition = eventData.position;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(parentTransform, mousePosition, Camera.main, out Vector2 localPoint);

        mousePixelPosition = localPoint;

        VOnDrag(eventData);
    }

This script isn't corrrectly converting the mouse position being provided into the local space equivalent for a given canvas element. Can anyone help me figure out how to use this function correctly?

#

it IS getting the correct mouse position, but when I use it in the ScreenToLocalPointInRectangle, it's returning a far lower value, and I'm not sure why

#

Okay, I haave no clue what I did, but apparently it is now registering correctly...

#

I think it had to do with what anchor orientation the object had?

sleek thorn
#

you added it from here yes?

supple needle
#
IEnumerator CheckHoldAcceleration()
    {
        if(accelerationCheck){
            holdTime += Time.deltaTime;
             if (holdTime > 4f)
            {
                accelerationTimeThreshold = true;
                accelerationCheck = false;
            }
        }
             if(accelerationTimeThreshold){
                accelerationTimeThreshold = false;
                instructionText.text = " ";
                currentText = "The car is now moving!";
                instructionText.text = currentText;
                yield return new WaitForSeconds(5f);
                
                currentText = "Good job! \n Now Press SPACE to brake!";
                instructionText.text = currentText;

                if(Input.GetButton("Brakes"))
                {
                    Debug.Log(Input.GetButton("Brakes"));
                    brakeCheck = 1;
                    //Debug.Log(brakeCheck);
                }
             
                if(brakeCheck==1){
                    currentText = "Well done!";
                    instructionText.text = currentText;
                    checkFirstTask = 1;
                }
             }
#

Here i want the message in my canvas object to change to "Well done!" When i press spacebar, which is what ive assigned Brakes button to, but nothing happens when i press the spacebar

rich adder
#

You could use something like WaitUntil

supple needle
#

Yea last time i asked something u said the same thing, so i should just use waituntil instead of if condition to avoid the frame perfect input right

rich adder
#
...
yield return new WaitUntil(()=> Input.GetButton("theButton"));
...
supple needle
#

Waituntil, yes this is what i need, i knew something like this would be there, thanks, will try

#

Its tough to findwhat i need in unity docs

#

Especially when i dunno what im looking for

rich adder
#

true sometimes you need to dig in docs

dawn kestrel
#

I keep getting the error
Assets\SaccFlightAndVehicles\Scripts\Other\SaccTeleportButton.cs(16,17): error CS0246: The type or namespace name 'BoxRegion' could not be found (are you missing a using directive or an assembly reference?)
yet I have this script:
https://hastebin.com/share/osenonowig.csharp

Anyone know what's holding me back? I can post the SaccTeleportButton script as well if needed, though I'm still trying to troubleshoot a number of things on it.

#

how do I define a type?

wintry quarry
#

(depending on what kind of type you wish to define)

dawn kestrel
#

I have a gameObject with this script on it:
https://hastebin.com/share/osenonowig.csharp
How do I declare a variable in a different script that uses this as a variable type?

wintry quarry
#

BoxRegion myBoxRegion;

#

Variables are:
type name

#

My guess is that one of your scripts is inside an assembly definition

#

And it's trying to reference another that is NOT

dawn kestrel
#

how would I check that?

wintry quarry
#

What folders are they in?

#

See if there's any asmdefs in those folders

dawn kestrel
#

one is in Assets, and the other is in Assets\SaccFlightAndVehicles\Scripts\Other

wintry quarry
#

Sure and that seems like an asset

#

Most assets have assembly definitions

#

Is there a good reason you're modifying code inside an asset?

#

That's generally poor form, especially if you don't understand assemblies

#

The quick fix here is putting both scripts in the same folder.

The better fix is there's most likely a better way to achieve what you want than modifying code inside an asset you downloaded

dawn kestrel
#

that's just where those two different scripts were made. I put BoxRegion in the Assets folder because I wanted it to be more generic, and possibly reuse it in the future, while SaccTeleportButton is specific to a specific asset.

#

both scripts were made from scratch

wintry quarry
#

You don't want to put the teleport button script inside the asset

#

That's what's breaking everything

#

It's also really weird to put your code in the namespace of the asset

#

Put both scripts in Assets and not inside the SaccFlightAndVehicles folder

#

And I highly recommend not in their namespace but namespaces aren't actually relevant to your issue here

dawn kestrel
#

that's where the original creator has all the other scripts

wintry quarry
#

Yes _their scripts _ go there

#

Your scripts do not

#

Try it and see

dawn kestrel
#

moving both my scripts up to Assets breaks more things when they get referenced by the script I modified. Moving them down to Assets\SaccFlight\Scripts though fixes the issue.

wintry quarry
#

You are now spiraling down a dark path where all your scripts will slowly need to live inside that asset 🥴

dawn kestrel
#

though, what's the worst that could happen? And to be fair, pretty much everything is living inside those assets

summer stump
wintry quarry
#

Maybe the asset updates and you need something from the update. Then all your modifications are gone and all your other scripts are trapped and broken

dawn kestrel
#

Ooh yeah, migration will be a pain. Though, is there a way to make a script that essentially just adds functions and variables to an existing script, and is able to use that script's private variables and functions?

static bay
#

What's going on?

wintry quarry
#

You would simply add more open access to the thing and then do the interaction from outside

#

What exactly are you trying to do

dawn kestrel
#

I mean, it's not one asset I'm modifying. Just about everything relevant to the scene is in Assets\SaccFlightAndVehicles\

#

I'm adding components to prefabs, so that I can use them for a game world in VRChat

wintry quarry
#

Can't you just make a prefab variant and add your components to that?

#

Or just duplicate the prefab

#

Both of which can be done outside the asset

eternal needle
dawn kestrel
#

I do ask them questions, but usually when it's specific to VRChat

eternal needle
#

Having any limited access, or just scripts in general that do things you may be unaware of will be a massive pain to debug in here, while it would be common knowledge in the correct chats

dawn kestrel
#

one big difference though is that this is specifically a channel for beginner coders, and in the short time I've been here I've gotten absolutely fantastic knowledge that's general to Unity. It was just this particular case in which I couldn't understand why one script couldn't see another that was tripping me up.

radiant frigate
#

hi! is there any way of making power ups that are permanet through out the run but not for each time you do a run?
example: you have a primary fire and you want to make it be double shoot when they get that powerup, but the next run they will have the normal shooting version

frigid sequoia
#

Like if you don't want to have like any peogession between runs you can just reload the initial scene, without saving anything

radiant frigate
#

yeah but how can i even implement it

frigid sequoia
#

Just load the menu as any other scene and don't do anything to save anything from the run itself

timber tide
#

should just have a big-o method that resets the states of everything

#

or reloading the scene works too

radiant frigate
#

im talking more of the powers itself

#

making them seems a bit weird how i plan to do it

#

if i want to modify 3 times for example the bullet it will be a bit spaguetti coder

timber tide
#

youtube usually have basic bits of code to follow for stuff like that

frigid sequoia
#

I mean, the optimal way should be to have like two different datas stored, the overall game data and the run's data in case you want to have progression between runs and be able to quit a run an come back late, but honestly that's kinda a lot of work that you don't really need if you are doing something small and contained

radiant frigate
#

im doing something basic just to learn how things work

frigid sequoia
radiant frigate
#

btw srry if im slow at answering i wanted to take a break and im in a game now xD

static bay
#

a game of what

radiant frigate
#

but if you have multiple things affecting the same stat would it bug out?

static bay
#

LEAGUE OF LEGENDS?

frigid sequoia
#

Makes the modified stuff kinda code bloaty, but it is readeable and organized so....

radiant frigate
static bay
#

Playing Aurelion? YOU HEATHEN.

radiant frigate
#

BHAHHAHAHAHAH

#

i just felt like it

#

he is my comfy guy

radiant frigate
#

i had in mind smth like that

#

but i thought there was a more easy way

#

more than easy i mean clean

frigid sequoia
#

Probably there is one, but I don't know about it so... 😛

#

This works fine I guess

radiant frigate
#

then ill do that

#

it just seems like i will need to do a lot of maths

frigid sequoia
#

For example, I got a proyectile for the player and it has all these stats where it gets damage, range, speed, size, knockback and all that straigh up from the players stats, you can do exactly the same for powerups. Does the proyectile bounce? How many times? And just add it one by one

#

As I said, seems, really, really bloated once you start adding more stuff, but should be fine

radiant frigate
#

yeah thats what my idea was but as you said it seemed to bloated

#

and thought that maybe there was some unity implemented function that helped or whatever

burnt vapor
#

No because that does not make sense

#

You can have static methods in interfaces but this is not supported in Unity as far as I am aware

#

Nope, it's a c#11 thing and Unity is still on 8

static bay
#

Someone give me a coding tip. Need to add one to my collection.

rare basin
#

dont use chat gpt

static bay
#

It's sometimes good with algorithm requests, or at least "stimulating your brain" with some potential implementation.

#

But it really fucks up sometimes.

burnt vapor
burnt vapor
#

Because people think struct is a better class without realizing just how much they need to do to actually make structs work properly

frigid sequoia
static bay
#

I really only use structs for stuff I know will be short lived.

#

Events usually.

burnt vapor
#

It's a very good helping hand

frigid sequoia
#

Ask for a potential implementation and it would probably give you something to start working with. Or ask for something superspecific if you want to copy it. Or you can just try to copy a full chunk of code and see how it runs, but never trust it would do it properly

burnt vapor
# static bay Someone give me a coding tip. Need to add one to my collection.

I have another one. Consider supporting this in your project: https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022
And also having a Directory.Build.props file in your project with this:

<Project>
    <PropertyGroup>
        <AnalysisLevel>latest</AnalysisLevel>
        <AnalysisMode>All</AnalysisMode>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
        <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
        <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    </PropertyGroup>
</Project>

Combining these two is a very good way to write better code, assuming you configured it properly.

static bay
#

wtf is this

burnt vapor
#

This puts in very strict code analysis, combined with various rules that are considered best practice

#

Takes a while to get used to but almost all rules are something you should learn if you want to improve as a programmer

static bay
#

I'll give a tip.

#

Guard clauses are cool.

#

Use them.

#

Deeply nested functions are ugly for my monkey brain.

#

else is the devil

burnt vapor
#

Not really, but guard clauses are generally a good way to define a proper flow in methods

#

But let's not bloat this chat with any more off-topic, because this is not the point of it

static bay
#

mmm fine

errant canopy
#

Is there a way in the script to differentiate between which trigger is touched first?

frigid sequoia
#

What are you even trying to do here? Like check for a combiantion of ordered triggers?

errant canopy
#

So the purpose of this is to check where the player is going in the map and spawn the next section appropriately.
The first trigger "behind level trigger" is supposed to change the section behind the player to a level shower in case they go back there.
The 2 forward triggers are for checking which direction the player goes (wrong or correct way) and then spawning the next section.
the 2 backward triggers are for checking if the player after choosing that direction then decides to go back (if they try and cheat the game), which they would then be responsible for spawning the level 0 sign.

errant canopy
frigid sequoia
#

So... you want to have múltiple colliders cause you want to know in which direction the player is moving?

frigid sequoia
errant canopy
#

So I can spawn the next section of the map

#

To explain it more simple, I'm trying to create a simple version of the game "Exit 8" if you've heard of it

frigid sequoia
#

Pretty sure you just need to know WHERE the player is and not in which direction they are moving

#

But yeah, you could just dissable and enable colliders as the player passes through them

#

Like if the player is entering this direction check if they also pass through the next

errant canopy
frigid sequoia
#

How are you differenciating between colliders?

errant canopy
#

Yeah that's the problem I ran into

frigid sequoia
# errant canopy As I asked

As I said, you should have each collider assigned to an empty parent so can easily ser which one you are checking

errant canopy
#

An empty parent? Or child?

radiant frigate
#

daleo idk if you remember me im the power up guy, could i take a look at how you did it?kinda curious and im having a meal so i cant focus on programing

frigid sequoia
errant canopy
#

Well I'm unsure how I'd then use these in the script?

#

Should I place the script on each of them and then just check for what the name of the object is?

#

Or is there a better way

frigid sequoia
errant canopy
#

But how does that allow me to check which trigger is activated?

eternal needle
frigid sequoia
errant canopy
#

How.

frigid sequoia
#

Before they were indistinguishable

frigid sequoia
errant canopy
#

Dude, I'm asking how in the script I can check which is triggered.

frigid sequoia
#

You cannot give the component itself a name

errant canopy
#

That's been my question since I posted.

eternal needle
errant canopy
#

Ok, and how do I do that.

static bay
#

unity events

#

or give the children a ref to the parent

errant canopy
#

As I've said before, I'm new to Unity, so I'm not sure how to use all those, could you give a small example?

frigid sequoia
#

Unity events are just a tiny bit more complex. Just place the collision check on a new script on each of the collider objects, and have a reference to the main script in them so you can call whatever method you want to call from It when the players collide with them

errant canopy
#

and have a reference to the main script in them
Yeah I'm unsure how to do this

eager elm
errant canopy
#

And each having an instance of the main script

eternal needle
frigid sequoia
errant canopy
#

So as said earlier, I want to be able to spawn and despawn the sections and level signs

#

Would that need 5 scripts?

frigid sequoia
frigid sequoia
#

If you want to check for an specific order of collisions, you could have a script that handles collision detection on the colliders and just send a boolean to the second script that does the logic. Like "is this triggered correctly?"

#

But each of the colliders would need to have a copy of the first script

errant canopy
#

Yeah, so I'm thinking, wouldn't it be easier to make a script that checks the name of the object it's on

#

I have another script that handles map spawning

#

So trigger manager takes care of... managing which trigger is touched and then it has an instance of the map spawning script to then call whatever method I need

eternal needle
# errant canopy Would that need 5 scripts?

this is all possible under 1 script, have you tried using unity events yet? even if not connecting it to any parent script, try to just see what they do and mess around with it

frigid sequoia
#

You could swap it around and place the collision detection on the player and check for the name of the collider the player is entering, yes

#

You can do that

#

Is ir better for you though?

errant canopy
eternal needle
errant canopy
#

So in all, I would still use 5 children to the main thing with each having a trigger on

errant canopy
#

Other than using an event to call the method

eternal needle
# errant canopy So is there any difference between that and this

just to preface: string (name) based anything is bad. its fragile, you change the name accidentally and suddenly you have a major bug.
also check the name of what object? the issue was that you had no way to differentiate between triggers. It was suggested above that the child object call a function on the parent object. if you are trying to find an alternative to this, how are you gonna know what name of the object was hit if you dont call any function? if you intend to pass the name through a function, then just instead call the exact function that you want to execute

errant canopy
#

I get it's fragile, but I'm not looking to make this the best game ever, it's just a quick side project for fun

#

And it seems to work

rare basin
#

that is terrible way of doing it

burnt vapor
#

I have many questions

eternal needle
# errant canopy And it seems to work

If it's a quick side project for fun, then why not learn and do it properly? You will very quickly learn to hate this. Wait until the day that you accidentally change the name of one of these objects and dont notice. Itll go from "everything works" to "why wont it work??? I changed nothing!!".

#

At least with unity events or anything else serialized in inspector, when you notice it doesnt work, you look at the trigger object and see "oh its missing".

honest haven
# errant canopy

change it to a switch statement switch (score) { case 0: Debug.Log("Score is 0"); break; case 1: Debug.Log("Score is 1"); break; case 5: Debug.Log("Score is 5"); break; default: Debug.Log("Score is not 0, 1, or 5"); break; }

eternal needle
#

Do not do that

errant canopy
#

I read the docs you sent for events

#

Idk if they're outdated, but I'm not getting the AddListener method on mine

#

Nvm sorry, IDE error

errant canopy
#

Like how would you want me to use them.

eternal needle
# errant canopy Could you just help me understand what you mean by wanting to use UnityEvents?

Unity events is just one way to simply do it. First start simpler because I think this is not even the first step. You need a script which has the functionality that you described above about spawning certain things. Make these things and put it inside a method.
Next you can actually worry about calling these methods. UnityEvent is just one way to do it from another script. Like for example you would now have a script with OnTriggerEnter, and inside that you invoke the unity event. In the inspector, you would setup the unity event to call a public function (the functionality you made in the previous step) which would be on another script, likely on the parent object here

#

But also there really should be a lot of tutorials out there for unity events

queen adder
#
using System.Collections;
using UnityEngine;

public class Movement : MonoBehaviour
{
    
    void Start()
    {
        StartCoroutine(MoveObject(transform, Vector3.right, 15f, 3f));
    }

    IEnumerator MoveObject(Transform obj, Vector3 direction, float speed, float duration)
    {
      

        while (true)
        {
            float startTime = Time.time;
            float endTime = startTime + duration;

            while (Time.time < endTime)
            {
                obj.Translate(direction * speed * Time.deltaTime);
                
            }
            yield return new WaitForSeconds(1f);

        }
        
    }
}

why the editor is crashing bcs of this code of piece? Isn't logic is right?

#

all I wanted move the cube every 1f seconds towards to Vector3.right side

ivory bobcat
#

The inner while loop looks dangerous

north kiln
ivory bobcat
#

Maybe have a yield statement inside the inner loop

#

yield return null;

queen adder
#

its strange.. but what if i would give the values before run the Coroutines. Do you guys think it would work?

ivory bobcat
#

Whatever the case, you've got an infinite loop

queen adder
ivory bobcat
ivory bobcat
#

Yielding for a second only after the duration has been met.

queen adder
whole idol
#

Is there a way I can delete everything from a unity file project and start from zero ?

ivory bobcat
#

Create a new project

hidden sleet
#

Been working on a player movement controller which is a modified version of the provided third person controller template, but it's behaving strangely. Basically, sometimes it just moves perfectly fine, but other times it sticks to where it is and won't move at all, with a max speed of like 0.02, before just randomly moving at the speed I define. Got the code here -https://hastebin.com/share/eboyusanep.csharp - and a video showcasing what is happening. Why might this be behaving this way?

swift crag
#

Something like "minimum movement distance"

#

Reduce that by a factor of 10 and see if it behaves better.

hidden sleet
#

that's what it's set to at the moment

hidden sleet
swift crag
#

and what if it it's a flat zero?

#

If you accelerate slowly, then it's possible that you move less than the minimum move distance on the first frame. And since you read the velocity back at the start of the next frame, you can wind up sitting there until you framerate randomly drops and you accelerate enough to get past the threshold in one frame

hidden sleet
#

makes sense

#

flat zero has it working flawlessly

#

so I take it, either raise the speed or set that threshold to nothing

#

what are the downsides to setting it to zero?

#

if any

swift crag
#

I'm not really sure. I guess it can help filter out unwanted small movements?

proven junco
#

how does someone make an UI system that changes text based on events, so when I ineract with a obj it triggers an event and that event triggers a change in the UI

swift crag
#

I use root motion for all movement in my game, so I don't actually accelerate the character. I just move the blend parameter around.

hidden sleet
#

I assume it would cut out any jitters, yeah

#

I'll keep it on zero then until I come across an issue

swift crag
#

so in my case, this problem didn't come up

hidden sleet
#

fair enough

buoyant knot
#

damn he has a case of the jitters

#

luckily it is curable

golden ermine
#

Hey guys, as you can see in the video, my problem is that player if he touches the wall he will just keep sliding on it and I cant walk anymore no matter what I press. My Player is Rigidbody based its not Character Controller. How can I fix this issue?

proven junco
#

help, this thing is not working, unity say "Assets\Objsystem\Scripts\Objective system\Objective.cs(31,9): error CS0103: The name 'thisText' does not exist in the current context"

and I have no clue how to fix it

#

I followed a video and did exactly like he did but nothing

burnt vapor
eternal falconBOT
burnt vapor
#

Your issue is a lot easier to fix after you've done this too

proven junco
#

what you mean, I am using vs mannually and I am using for unity

#

code for Ui

hazy ridge
proven junco
#

trigger

#

something

violet token
burnt vapor
#

You are expected to have it configured if you want to be helped

violet token
#

The variable name declared is theText not thisText

proven junco
#

should I change the one who has "thisText" or just the ones that has thetext

violet token
proven junco
#

oh so I can just change the thisText part

#

to theText

violet token
#

Yes that should fix it

proven junco
#

Assets\Objsystem\Scripts\Objective system\Objective.cs(31,17): error CS0119: 'GameObject.GetComponent<T>()' is a method, which is not valid in the given context

#

I got this instead

burnt vapor
eternal falconBOT
burnt vapor
#

@violet token Please do not help people with a misconfigured editor, have them configure it first

proven junco
#

it is in my assetstore

burnt vapor
#

What do you mean no clue? Just press the bot's link depending ont he editor you use. Did you install Visual Studio manually or did you download it when you were downloading Unity?

proven junco
#

manually probbably

burnt vapor
#

Then follow the steps as pointed out by that page

proven junco
#

still have no clue what to do

cosmic dagger
# proven junco

compare that error line 31 to line 29 and find the difference between the two . . .

proven junco
#

omg

#

i think I dounf

cosmic dagger
#

check letter by letter, one by one . . .

proven junco
#

found

#

omg

#

Thx

fringe plover
#

Is it good idea to make character controller with kinematic rigidbody?

#

It tried, but it really hard and i didnt even found any tutorials for it..

queen adder
proven junco
burnt vapor
# proven junco

See how clear the error is now? Just find the red underline

queen adder
#

if u change the public GameObject theText to public Text theText and assign it to your gameobject, its gonna take your text component anyway

cosmic dagger
# proven junco omg

think of () as the invocation. it is needed to actually call or invoke the method. it's much easier to see the problem when your IDE is confgured, no?

proven junco
burnt vapor
cosmic dagger
queen adder
#

and then theText.text = "anything"

proven junco
#

yeah no errors

#

imma make the thingy more worky

#

IT WORKS

#

now the question begs

#

can I connect that code with interaction with object

inland cobalt
#

Hey all, kind of struggling how best to go about writing this.

I have a base class we’ll call “Enemy” and other classes for specific enemy types inherit from Enemy, and define their own custom stats, death behaviour, etc. The issue I’m running into is how best to actually instantiate them, afaik I can’t just pass the class type as an option into some function for it, and I’m also unsure how best to give each class prefabs, as it’s something I have to define inside of the editor and I would have to attach the script to a game object

If anyone has any suggestions that would be appreciated

cosmic dagger
cosmic dagger
proven junco
#

is it possible to have an interaction activate the UI

#

that is done with the script that I was wobling about

wintry quarry
#

Everything is possible with the right code and setup.

proven junco
#

's that are not helping me rn

#

haha

sterile wraith
#

Does anyone have experience implementing steering in a car without wheel colliders.

swift crag
proven junco
#

how

proven junco
#

yeah thx

#

im still kinda clueless cuz I got no clue what Im even doing ngl

#

but it will help

swift crag
#

if you have no idea what you're doing then you should be following structured lessons on a site like !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

quartz mural
#

anyone have any idea how i can fix this

#

how to fix a null at a certain index

#

and how to fix and index out of bounds error?

wintry quarry
wintry quarry
quartz mural
#

yooooo

#

i dm u?

wintry quarry
#

no thanks

quartz mural
#

no i did time ago

#

u asked me to send u my code

#

and i did

#

and u never responed?

wintry quarry
#

I don't help people over DM

quartz mural
#

i see

quartz mural
#

they become null at a certain index