#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 141 of 1

teal gulch
#

Did you assign sword in inspector?

sacred egret
#

do isend the log

#

yes

rocky canyon
#

do u get a debug.log???

#

in teh console?

sacred egret
#

no

rocky canyon
#

cuz if not ur question should be "Why doesn't my if() conditional even run

#

did you set up the "e" button in ur input settings?

#

b/c if not it wont work..

#

KeyCode.E would be an alternative

#

that would work regardless b/c its a generic Input

sacred egret
#

ill try it thx

rocky canyon
#
      if (Input.GetKey(KeyCode.E))
        {
            Debug.Log("e pressed");
            sword.SetActive(true);
        }```
#

when you just use something like "e" it would need to be set up in the Input's so Unity knows what "e" even is

#

KeyCodes are easy to use when prototyping

sacred egret
#

it worked thx

amber spruce
#

how do i make a dash that has the player like flicker in and out

rocky canyon
#

probably a shader or visual effect of some sort

#

u could just enable and disable the Renderer component..

amber spruce
#

im also struggaling with the actual dash part to

timber tide
#

could make that in the animator

rocky canyon
#

to fake it

ornate patrol
#

hello! i just started learning unity and ran into this problem, where only the idle animation is visible and others are not (only the outline in preview is visible). how can i turn them on?

timber tide
#

do a animation clip that changes the alpha of your character and move it some units forward

rocky canyon
#

make sure the graphic is IN FRONT of the background

#

ur Z position is 0.. probably the same as ur background

#

u should move it a little forward towards the camera..

#

so it stays on top

amber spruce
#

just to test it

timber tide
#

well, you can do it by transform position if you use the animator

#

but you may want to also do an additional raycast check so you dont teleport into walls

rocky canyon
#

u can animate the graphics only.. then still use ur physics to move it

amber spruce
#

well my physics isnt working

rocky canyon
#

graphics would control the flicker.. the movement code, the movement

#

ahh, gotcha

amber spruce
#

weird thing is if i switch it around to apply the force to the y axis the player moves up properly just doesnt work on the x axis

rocky canyon
#

well.. if u move it upwards u lose contact with the ground..

#

if u moving laterally u would remain in contact with the ground..

#

could the ground and the drag/friction/ stuff have anything to do with that?

#

try changing values... give it a BIG force and see what happens

amber spruce
#

i did i gave it like 1000

rotund hull
#

!code

eternal falconBOT
queen adder
#

what is the default layermask that doesnt filter anything?```cs
public static Collider2D[] OverlapCircleAll(Vector2 point, float radius, int layerMask);

rotund hull
#

https://gdl.space/ecasemivap.cs i am trying to print the int the is Amount in this code but it logs "Script or property 'Amount' not found" and i know that it is not finding the Amount int, can someone help

rocky canyon
#

Default is the "Default" Layer

queen adder
#

ohh so -5

soft steppe
#

check if player is grounded without using raycasts and ground layers (2d)

gilded ibex
#

when smoothly changing things in unity, is something like DOTween the standard, or is there something I'm missing?

timber tide
rocky canyon
#

ya that code is confusing..

rotund hull
#

but i am trying to make it so that it can get any script and i dont have to change anything

#

trying to make an item pickup

slender nymph
#

why would you need to get any component?

#

use an interface if you want a specific group of separate components

rotund hull
#

Amount is a int in another scripts

timber tide
#

target by interface or abstraction class

rotund hull
#

what is interface

timber tide
#

good time to learn them

rocky canyon
rotund hull
#

alrighty

#

thanks

gilded ibex
true pasture
#

would it be okay to just continually set the text value in update referencing my stats. That way I don't have to update this manually each time a stat changes?

rocky canyon
#

yup, u can use interfaces. they're basically contracts.. meaning if you make an interface that has a Amount variable then all the scripts that use that interface MUST have an Amount variable. same for functions..

this way when you try to get something thru an interface you know that it MUST have the things ur searching for..

#

thus making it much easier to access stuff like that

slender nymph
rocky canyon
#

^ yea, the common consensus is the opposite of what u just said.

#

u want to try to update things like UI as little as possible..

true pasture
rocky canyon
#

if it doesn't change you shouldnt need / want to update it

rocky canyon
queen adder
slender nymph
rocky canyon
#

isntead of checking every frame.. to see if it changed

queen adder
#

id use a prop instead of events though

#

simpler

#

actually that's quite the same

rocky canyon
#
    void DamagePlayer(int damageTaken)
    {
        // the player just got damaged..
        PlayerHealth.value -= damageTaken;

        // then the UI should Update
        MyUIManager.UpdateHealth(PlayerHealth.value);
    }```
#

just an example snip

queen adder
#

.UpdateAllStat()

slender nymph
# rocky canyon i use DoTween

also PrimeTween is the sexy new tweening library on the block. allocation free, allegedly better performance, and still fairly easy to use

upbeat stirrup
#

would a private serialized variable be named _myVariable or myVariable?

rocky canyon
#

up to you..

#

myVariable is what i use..

#

becaues my local variables use the underscore

slender nymph
upbeat stirrup
rocky canyon
#

but consistency is the key

#

just stick to 1 convention and you'll be alright

queen adder
#

Me who is sticking to freestyle convention: UnityChanOops

rocky canyon
#

lol..

queen adder
#

freestyle whooooh

timber tide
#

underline is one too many extra keys to press

queen adder
#

yea i only mostly use underscore as variableseparator

#

    public static IEnumerable<T> Circle_GetAllComponent<T>(Vector3 position, float Radius, int layermask = -5)
        => Physics2D.OverlapCircleAll(position, Radius, layermask)
        .Select(x => x.GetComponent<T>());```
timber tide
#

makes more sense in python since it's more concept than actually enforced

#

and javascript, but javascript is bad

little oak
#

how can i add a child of a prefab into a transform variable in a game object?

amber spruce
timber tide
sacred egret
#

how to refrence a variable from another script and do the scripts have to be attached to a same object

slender nymph
sacred egret
#

so like this?

teal viper
#

What's the value thing for?

polar acorn
#

If not, then this should be a compile error and underlined in red

sacred egret
#

nope its supposed to be an integer

slender nymph
polar acorn
eternal falconBOT
polar acorn
#

So stuff like this shows up as errors

amber spruce
#

how can i tell when the dash stops?? so i can enable the sprite renderer again

polar acorn
#

How long is a dash

little oak
#

transform.getchild(index).gameObject

amber spruce
sterile hull
#

is coding usually for writing plugings?

polar acorn
polar acorn
eternal needle
amber spruce
eternal needle
amber spruce
#

im trying to make a cool dash effect and thought a cool effect would be have the person basically flicker in and out

polar acorn
amber spruce
sterile hull
polar acorn
eternal needle
amber spruce
sterile hull
sterile hull
amber spruce
teal viper
amber spruce
#

wont the decrese the distance though

teal viper
#

If you apply it for long enough, no.

amber spruce
#

so what just like have a coroutine apply the force multiple times?

teal viper
#

Are you applying it once currently?

amber spruce
#

yeah

teal viper
#

Preferably fixed update if you want it to be precise. But a coroutine might work as well.

queen adder
#

any experts in character movement know a good tutorial?

frosty hound
#

Experts presumably wouldn't be using tutorials. You should be asking the beginners. ๐Ÿ˜Œ

queen adder
#

any beginners have a tutorial for good 3rd person movement?

teal viper
#

As an "expert" I can say: google!๐Ÿ˜ฌ

spark galleon
#

!bugs

eternal falconBOT
#

๐Ÿชฒ To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

๐Ÿ“ If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click โ€˜Report a problem on this pageโ€™!

๐Ÿ’กIf your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

stuck palm
#

how can i fix this?>

stuck palm
wintry quarry
stuck palm
#

do i have to make a var for that too then

wintry quarry
#

It needs to be copied, modified, then copied back

stuck palm
slender nymph
#

for startRotation there is

#

just not main

stuck palm
#

am i doing this wrong ๐Ÿ˜ญ

slender nymph
#

assign to main.startRotationY not throwPuffs.main.startRotationY

slender nymph
#

yes

stuck palm
#

Okay tha k you !

potent nymph
#

playing with procedural mesh generation, and I was able to make a grid with some perlin noise for hills. The vertices that are in water are not displaced at all

#

I'm thinking about "hiding" the faces that are in the water, and I could do this by skipping creating a triangle when I loop over the grid

#

if I do that however, would that be a bad practice since I'll have a lot of extra vertices that are not assigned to any triangles?

wintry quarry
potent nymph
#

okay, that makes things really tricky then, since with a grid the vertex indices are ordered and predictable, which makes assigning triangles as simple as having two for loops, one for columns and rows

#

but if I remove vertices, the indices get messed up :(

wintry quarry
#

Shouldn't be too hard if you do it in a second pass

potent nymph
#

there's a way to do that? I thought I had to assign the length of the vertex array from the beginning

wintry quarry
#

Run your current code. Put every vertex that's in a triangle in a HashSet. Afterwards you make a new array from those vertices

#

You'll have to just map the old indices to the new ones for the triangles

potent nymph
#

interesting. I don't know what a HashSet is so I'll have to look that up, but thanks for the tip ๐Ÿ‘

pearl lodge
#

hey guys its been a while. I want to get back to game development. I want to take the snake game that I made and make it ONLINE multiplayer (currently I have local multiplayer). What is the best library/package to do this?

I've heard of NetCode. Is this the best one? or do you guys suggest anything else?

Thanks in advance.

wintry quarry
pearl lodge
frosty hound
#

Unity's netcode, photon and mirror

wintry quarry
#

Photon is a company that makes several frameworks btw

meager gust
#

check the origin of your model

#

if it's skewed off to the side, you'll need to fix that in blender or something

#

assuming that's what you mean

#

post a video of what's happening

#

when you click on your model, the box thing should be in the center of the model

#

for you, it looks like it's near the right arm. you'll have to fix that

slender nymph
#

your object is not centered on the parent that is being rotated

meager gust
#

or that

#

also if you're running this code in update, you don't need Time.fixedDeltaTime

#

change it to time.deltaTime

sour fulcrum
#

Is there a built in way to compare components and/or gameobjects from a prefab with the same one from a instance of that prefab?

#

eg.

PrefabAsset
    -GameObject Apple
        -MeshCollider
PrefabAssetInstance
    -GameObject Apple
        -MeshCollider

i wanna compare the meshcolliders and get a correct result

inland canopy
#

hello can anyone help me solve this error:
NullReferenceException: Object reference not set to an instance of an object
MouseDrag.OnMouseDrag () (at Assets/Scripts/MouseDrag.cs:24

slender nymph
calm coral
calm coral
slender nymph
#

yes

calm coral
slender nymph
inland canopy
nimble apex
#

my task is to generate server log files for last three game session if any error occured
1 game session : start the game (run) to closing the game

the file generate will be like

  • error1.txt
  • error2.txt
  • error3.txt sorta like this
#

i know how to obtain data and write files already, my worries are how to know this is the x times u opened the game

#

because how many time u opened the game, or nth game session is not recorded at all

teal viper
nimble apex
teal viper
#

For the client?

#

Or the server?

nimble apex
#

client app

teal viper
#

Ok, it would need to send some log in/out request and the server can keep track of each user session count.

nimble apex
#

i did come up with a solution, when the client started, i will do

int counter = PlayerPrefs.GetInt("nthsession");
    PlayerPrefs.SetInt("nthsession",counter++);```

maybe in game manager
#
public int nthsessionbase3 = counter/3 +1;```
teal viper
#

Storing it on the client side wouldn't be very reliable.

nimble apex
#

and using local data

teal viper
#

Okay

queen adder
#

Can we like grab the current active scene's yaml file to save the whole scene?

#

have anyone ever done a whole scene save system before?

rocky canyon
#
    private void HandleOrderRX(OrderRX orderRx)
    {
        float pitch = 1.0f;

        // Check if the orderRX is in our list
        if(order_rxs.Contains(orderRx))
        {
            orderRx.SetListeningForOrders(false);
            order_rxs.Remove(orderRx);
            pitch = .9f;
        }
        else
        {
            order_rxs.Add(orderRx);
            orderRx.SetListeningForOrders(true);
            pitch = 1.0f;
        }

        clickSounds.pitch = pitch;
        clickSounds.PlayOneShot(clickUnit);
    }```
not sure why this would error.
#

lol, hmmm nvm seems to have fixed itself.. i closed down my code editor and was gonna get 1 more screenshot of the error and I can't reproduce it again

gray gorge
#

Very noob question (smh my head):
I want to create a custom class MyButton that contains a string, KeyCode, Sprite, etc.
Next, in Unity, I want to assign all of these values in a [SerializeField] so that I can create an array of MyButton[].
Essentially, Iโ€™m getting

When what I want instead are empty boxes for me to fill in each instance variable for each button.

How do I do this? Or should I even do this at all (is this bad practice)?

#
    public string buttonName;
    public KeyCode keyCode;
    public Sprite buttonSprite;
    public Sprite buttonHeldSprite;```
rocky canyon
slender nymph
nimble apex
#
Directory.CreateDirectory($"{Application.persistentDataPath}/ErrorLogs");```

this will not give me an error if the folder is created right?
rocky canyon
nimble apex
#

its just do nothing?

slender nymph
nimble apex
#

nice

round scaffold
#

ive always wondered

#

if i make a class that inherits an interface

#

then i make another class that inherits from the first class

#

would the interface also be inherited?

nimble apex
#
  private void GenerateServerErrorLog(DateTime time, string code)
  {
    Directory.CreateDirectory($"{Application.persistentDataPath}/ErrorLogs");

    string path = $"{Application.persistentDataPath}/ErrorLogs/ServerLogs_{GameManager.Instance.nthErrorSession}.txt";

    //clear previous n-3th error logs 
    if (firstWrite)
    {
      File.WriteAllText(path,"");
      firstWrite = false;
    }

    //append all errors found in this game session
    using (StreamWriter sw = File.AppendText(path))
    {
      sw.WriteLine($"client server error found ! (code: {code}) >>> time : {time}");
    }
  }```
slender nymph
#

yes

nimble apex
#

finally got it done

round scaffold
#

hot

slender nymph
round scaffold
#

aighty

nimble apex
#

it doesnt add up the text tho

plush chasm
#

In C# is there a performance impact calling a method nested in another method? I used to use another language that had a pretty large performance impact to run a nested method so I've always been hesitant to nest methods in C#.

teal viper
#

Not enough to make difference in most cases.

#

Obviously, it's jumping pointers, so there is some overhead. But it's also possibly inlined by the compiler.

slender nymph
icy sluice
#

Whats going on in here

teal viper
#

I wouldn't bother worrying about it, especially if it means sacrificing readability or modularity.

north kiln
#

telling people you can start local coroutines lol

slender nymph
#

oh no

teal viper
#

Oh, I though they were talking about nesting calls, not definitions(local methods)

slender nymph
#

it is also possible i misinterpreted their question. but one of us is probably right

icy sluice
#

Whats problem with that?

plush chasm
#

I didn't explain completely clear my question was more about referencing stuff in a method from a method nested inside

#

I felt there was probably some crazy stuff going on to pull that off

icy sluice
#

You dont know how methods work?

gaunt ice
#

local method i think, not calling other methods from method

slender nymph
plush chasm
#

I mean like what boxfriend linked

#

yeah I know

gaunt ice
#

just push/pop stack and change the pc in low level

icy sluice
#

Its not local, it needs to be static float/int/double...

plush chasm
#

still messing around with that to get a more realistic example but so far seems like it isn't a big deal

slender nymph
icy sluice
#

Ofc it isnt, depends on user how they want their code to look

#

I mostly put methods when i need to do some large calculus constantly

plush chasm
#

I renamed the stuff already since it was a bit confusing lol

slender nymph
plush chasm
#

yeah, thanks everyone

slender nymph
north kiln
slender nymph
#

got the name through reflection

north kiln
#

I presume Unity's reflection caching stuff doesn't capture compiler-generated methods like those

#

I would say that's good to know, but the only reason to know is curiosity ๐Ÿ˜„

twin bison
#

Should a player health script call the game manager when its 0 or should it call the player controller and the player calls the game manager?

slender nymph
#

weren't you going to use an event for that? what happened to that?

shrewd swift
#

Hi, what good methods would you recommend to read a .csv file ?
For now i thought about using StreamReader

also, my goal is to read this csv to make a jagged array. But I dont need to read & make this array each time I play. I just want to "convert" the csv to an array once in a while when I update the csv.
What would be a good "script writer" so i could "write" the array in my code or in another script, to avoid read & make this array each time I play ?

twin bison
shrewd swift
twin bison
#

What about the health script calls the player controllers "Die" method and the player then invokes his "Died" event + additional stuff (eventually)? So only one event?

#

ah na then i have the problem that its not really reusable for enemy again, sorry I don't know which rabbit hole im going down there

slender nymph
# shrewd swift Hi, what good methods would you recommend to read a `.csv` file ? For now i thou...

unfortunately unity can't serialize a jagged array so you won't be able to just read the file and write its contents to a serialized field which would have been the most convenient option.
if you really wanted to avoid reading it at runtime (which if you just do once at startup really won't impact performance all that much) you could do something silly like use some editor code to read the file, then write some c# code to another file that includes creating the jagged array using the data from the file as hardcoded values.

there's probably some other ways you could do this at edit time but i can't think of any off the top of my head

slender nymph
#

you could have some method on your player controller that handles its death animation (if applicable), starts any other death effects, and then invokes its death event that your GameManager is subscribed to

shrewd swift
slender nymph
#

why. your data is already serialized as csv, right? so if your plan is to just deserialize it anyway just do it directly from that

twin bison
shrewd swift
#

so the csv is just the inputs to build the array

#

i can you give you an example if you want

twin bison
#

Oh *** my english - it sthould be "Mortal" not immortal ๐Ÿ˜„

slender nymph
shrewd swift
#

my man

slender nymph
shrewd swift
#

after some testing i realised that array can only have int as key, so i'll probably go with dictionnaries

twin bison
slender nymph
#

yep, or you could have kept using System.Action instead. this just allows you to subscribe to the event in the inspector

twin bison
#

When to choose one over the other?

slender nymph
fringe plover
#

!code

eternal falconBOT
fringe plover
#

Hello, i tried making 3D controlle, and it seem to work, but it always move at same axis..
I multiply input with Vector3.forwatd but still doesnt help..
https://gdl.space/funitehoyo.cs

shrewd swift
slender nymph
fringe plover
#

okay, thanks

bright zodiac
bright zodiac
#

I wonder if local methods actually do calvirt under the hood or just the regular call ๐Ÿค”

slender nymph
# fringe plover okay, thanks

oh and you weren't even using your input variable which is where you were actually multiplying your input by transform.forward and transform.right

fringe plover
#

UHH, i didnt saw that._. thanks

twin bison
pearl lodge
slender nymph
shrewd swift
#

lets says i got a list of elements with a % chance

how would I do a random, and select the element ?

wintry quarry
teal viper
shrewd swift
#

my goal is to retreive one, but i dont understand what you mean with or roll for every on of them

teal viper
#

Since you have more that 100% total there, I thought there is a chance to get all the items at the same time.

shrewd swift
#

i forgot to say that the number were used as an example

languid spire
shrewd swift
#

making multiple array of 100 elements is maybe to necessary ?

#

this would mean thousands of elements later on for me

languid spire
#

why would you need multiple arrays?

shrewd swift
#

because i am doing selection using probabilities and previous results
idk how to explain, but, here is a example of a table, there will be maybe 1 or 2 sub(and sub sub) tables for each cells

#

with this screen only, this gives me 100 * 5 elements in 6 arrays

languid spire
#

trivial if this is Enums of type byte its a miniscule memory usage

shrewd swift
#

i didnt decide yet if im doing enums or string, prob enum

languid spire
#

definitely enums, strings would be silly

shrewd swift
#

yes

languid spire
#

byte[100] * 6. Insignificant

shrewd swift
languid spire
#

yep, if you declare your Enum as type byte

shrewd swift
#

what is the meaning of byte[x]

#

curious

languid spire
#

it's an array of bytes being indexed by x

shrewd swift
#

ah okay, thought it was something else

shrewd swift
languid spire
#

public enum MyEnum : byte

shrewd swift
#

if an enum is type of byte, what does it change compared to regular enum ?

languid spire
#

a byte takes up 8 bits, if you do not declare a type the default is int which is 32 bits

#

so the array will take 25% of the memory

shrewd swift
#

okay, but for basic stuff nothing change with the synthax of use of MyEnum ?

#

because i suppose there are cases where using int is usefull

languid spire
#

of course not, the only difference is the number of entries the enum can have, if you use byte then that is 255

shrewd swift
#

oh

#

then its great for my case

#

ty for answering my questions

languid spire
#

the only time I use anything other than bytes for enums is if I want flags, then I use ulong to give me 64 of them

livid tundra
#

I have these three Polygon Collider 2D components representing weapons being swung at an enemy.
I want to detect when the capsule collider on the enemy intersects this.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;

public class PlayerAnimationTriggers : MonoBehaviour
{
    private Player player => GetComponentInParent<Player>();
    private ContactFilter2D filter = new ContactFilter2D().NoFilter();
    private PolygonCollider2D[] attackColliders => GetComponents<PolygonCollider2D>();

    private void AttackTrigger()
    {
        List<Collider2D> colliders = new List<Collider2D>();
        if (player.primaryAttackState.comboCounter == 0)
            Physics2D.OverlapCollider(attackColliders[0], filter, colliders);
        else if (player.primaryAttackState.comboCounter == 1)
            Physics2D.OverlapCollider(attackColliders[1], filter, colliders);
        else if (player.primaryAttackState.comboCounter == 2)
            Physics2D.OverlapCollider(attackColliders[2], filter, colliders);
        
        foreach (var hit in colliders)
        {
            if (hit.GetComponent<Enemy>() != null)
                hit.GetComponent<Enemy>().Damage();
        }
    }
}
#

OMG, THIS WORKS ๐Ÿ˜ณ

#

however...

#

I am concerned that Unity might be computing intersections of all 3 colliders with each other when an animation event triggers.
All colliders are set to "triggers", btw

#

maybe there's no reason to worry about that ๐Ÿค”

languid spire
livid tundra
#

the charater has a 3-hit combo and each sword swing leaves a different silhouette, hence a different collider

livid tundra
#

(with no incidence filter)

languid spire
livid tundra
languid spire
#

because that is the way you have coded it, it does what you tell it to do

livid tundra
#

I apologize for misunderstanding your earlier solution

livid tundra
#

Physics2D.OverlapCollider(attackColliders[0], filter, colliders); is below

#

you're telling me that just checking overlaps gets components from the GameObject?

obtuse cargo
#

Hey im an roblox studio dev and now im trying unity useing c# i feel like im the must dumbass ever i worked on sum for an hour then i didn t save it ;((

languid spire
#

and is executed every time you reference attackColliders

livid tundra
#

ok I do need to avoid that

#

what can I change to only do that once?

languid spire
#

exactly what I said before, move the lambda to Awake

livid tundra
languid spire
#

also as I said before, it should not be a lambda

livid tundra
#

I should do straight assignment in Awake?

languid spire
#
void Awake() { attackColliders = GetComponents<PolygonCollider2D>(); }
#

job done

livid tundra
#

ok

#

it's not mad at me for this

#

let's see how this runs

north kiln
#

(that's not a lambda, that's an expression-bodied property)

livid tundra
#

wow, this is running like greased-lightning!

arctic harbor
#

i'm trying to make some angled springs for a platformer. for some reason if the player jumps into the spring without any initial horizontal velocity, the spring won't apply any horizontal velocity either. ie i have a spring pointing up-right. if i just straight up into it, only my vertical velocity is changed. if i have a tiny amount of left/right velocity, then the spring will apply the right directed part of the velocity as well. i'm using Vector2 testVelocity = (Vector2)(transform.up * springPower); and other.GetComponent<Rigidbody2D>().velocity = testVelocity; where other is the player from OnTriggerEnter2D(Collider2D other). why might this be?

livid tundra
#

I am so surprised about two things still (and it's alright if you have better things to investigate)

  1. why the lambda expression is causing the variable to redefine itself every time (fundamentals failure on my part)
  2. why I can define an array without specifying its size and do assignment to it in Awake(). Is this because I don't know how many elements there are during definition or assignment?
north kiln
#

It's not a lambda expression

#

It's a property

livid tundra
#

well is it pulling from the components list every time?

#

re-executing its definition?

north kiln
#

Properties are just methods, so you're just calling a method and doing the work repeatedly

livid tundra
#

ah

#

this makes sense actually

#

the array question is dumber ._.

#

...er.

languid spire
#

the array question is simple, you declare the array, GetComponents defines it and returns the result

livid tundra
#

thank you

#

wow, I thought for sure I broke my tutorial

#

but I actually improved it

#

(with your help)

languid spire
#

lol

#

unfortunately, as with many tutorials, that is not difficult

livid tundra
# languid spire lol

trickiest part is anticipating what I should wait to see if he fixes later or what I should immediately improve myself

#

before it gets too coupled to other systems

#

(despite their best efforts not to)

#

this is a better-than-most tutorial imo

languid spire
#

remember the old saying
'In the land of the blind the one-eyed man is king'

arctic harbor
teal viper
eternal falconBOT
arctic harbor
teal viper
#

Ah, you're only setting the vertical velocity here

arctic harbor
#

it's facing up and right

teal viper
#

Then what I said earlier

arctic harbor
#

and that doesn't explain why it applies the horizontal velocity only if the player already had an initial horizontal velocity

arctic harbor
wintry quarry
languid spire
#

really you should not be doing this

other.GetComponent<Rigidbody2D>().velocity = testVelocity;

you should pass testVelocity to a component on the player and let that deal with it correctly

arctic harbor
#

how does one do that

teal viper
#

playerReference.DealWithIt(yeetVelocity)

languid spire
#

well if you have a playerMovement class, use that, add a method that will take the velocity as a parameter and integrate it with you current player velocity

arctic harbor
languid spire
#

single responsibility principle, break it and it will bite you in the arse every time

arctic harbor
#

by single responsibility here, do you mean that if i want to change the player's velocity, it should have a method to do it so anything else that wants to change the player's velocity will call that?

languid spire
#

yes, playermovement should only be changed by playermovement

arctic harbor
#

i'll keep that in mind, thanks. not sure if that particular bit would have mattered in this issue here. i had

        {
            rb.velocity = new Vector2(0, rb.velocity.y);
        }```
in PlayerController in FixedUpdate. my spring logic is in an OnTriggerEnter2D.
languid spire
#

it would have done because you could have seen in one class that different things were affecting eachother

arctic harbor
#

...it just dawned on me that if i wanted to set the velocity to zero after i was sufficiently slow enough i could have just checked the velocity itself rather than using an extra variable to check the previous position...whatever that's old code idk what i was thinking at the time. unless i actually did try that at the time and fsr it didn't work how i wanted Thonk

languid spire
#

!code

eternal falconBOT
arctic harbor
#

whoa

autumn plover
languid spire
autumn plover
#

Hi Guys,
I needed some help with my AR project. In my project I have a Sling Arm and a Ball, one button when pressed destroys the hinge joint between the Sling Arm and the Ball, and there is another Reset Button when pressed I want it to put the arms back in original position along with the ball and the hinge joint between the sling arm and the ball should be reset. Unfortunately if I destroy the hinge joint, I cannot create another hinge joint between the two objects. Does anyone have any way to overcome this issue?
I have provided my code below, if anyone finds a solution to this, could you ping me or DM me as I really need help and am stuck solving this issue since some time!
Thanks!

Code: https://gdl.space/xocoborasu.cs

languid spire
#

why are you adding llsteners in Update?

autumn plover
#

When I add the listeners to the start function and run the project, the buttons don't work for some reason.... I do not know why this happens

languid spire
#

well doing it in Update is a very bad idea so I guess you start with figuring that out

autumn plover
languid spire
#

yep,

        HingeJoint hingeToDestroy = Ball.GetComponent<HingeJoint>();
        if (hingeToDestroy != null)
        {
            Destroy(hingeToDestroy);
        }

        HingeJoint newHingeJoint = Ball.gameObject.AddComponent<HingeJoint>();

aint gonna work, you will need to wait 1 frame before creating a new joint because Destroy takes that long to run

autumn plover
livid tundra
#

I'm struggling to set the sprite renderer color parameter via ternary operator

#
sr.color = white ? sr.red : Sr.white;

When I try this, I get an error that says can't implicitly convert bool to color

frosty hound
#

What type is white?

languid spire
#

Color.red

#

also sr and Sr ?

livid tundra
# languid spire Color.white

sorry, I was uh...elsewhere when I typed that. This first line is what causes an error:

private void RedColorBlink()
{
    sr.color = Color.white ? Color.red : Color.white;
    if (sr.color != Color.white)
        sr.color = Color.white;
    else
        sr.color = Color.red;
}
#

the if/else worked fine

#

I thought a ternary operator would be nifty

#

sr := SpriteRenderer

languid spire
#
sr.color = (sr.color == Color.white) ?
#

it needs to evaluate to bool

livid tundra
#

oh, no kidding

#

I see thank you

#

@languid spire private void RedColorBlink() => sr.color = (sr.color == Color.white) ? Color.red : Color.white;
๐Ÿ˜„

#

or ๐Ÿ˜ฑ ?

languid spire
lone sable
#

Are there any free/decent Analytic options out there?

zinc warren
#
DirectoryNotFoundException: Could not find a part of the path 'C:\Users\patbr\Downloads\testingGame_Data\Resources\Worlds'.

im doing this to get a folder but when i build my project it gives me this error: DirectoryNotFoundException: Could not find a part of the path 'C:\Users\patbr\Downloads\testingGame_Data\Resources\Worlds'. How can i fix this?

languid spire
#

Missing Assets\ ???

cerulean quest
#

when i input something onto a function does it make a copy of the the thing, or does it take the orignal? cuz i am used to c++ where you put an & to indicate that you want to put the orignal copy into the functions

shrewd swift
#

~~i cant fix this issue, screen is located in a function

i dont even see how there is an issue, the var is delcared in same scope~~

forgot that i have to init with values

timber tide
cerulean quest
#

adding & gives me an error

timber tide
#

you don't use &

cerulean quest
#

yeah what do i use?

fossil drum
#

By default it's a copy, and if you want to reference it just use ref in the signature afaik.

fossil drum
#

In a method signature and in a method call, to pass an argument to a method by reference.

zinc warren
fossil drum
timber tide
#

right default behaviour is just passing the object without & as it's implied in c# if not value types

cerulean quest
#

i need to edit an array inside a function

fossil drum
#

Knowing the difference is indeed a good idea for C#, I agree with that.

timber tide
#

ref is useful when you do want to pass the value type in but not make a copy of it such that editing it inside of the method does not need to be passed back

cerulean quest
languid spire
charred spoke
cerulean quest
zinc warren
languid spire
slate gale
#

I'm trying to rotate my player towards a target in the Y-axis using lerping. This pretty much works, but sometimes it rotates the 'wrong' way, as in, it takes the longer rotation over the shortest rotation. E.g: if clockwise would be faster to rotate, sometimes it still picks counter-clockwise. Anyone got any hints for me to fix it?

player.localEulerAngles = new Vector3(0, Mathf.Lerp(player.localEulerAngles.y, playerTargetY, cameraTargetRotationSpeed * Time.deltaTime), 0);
zinc warren
languid spire
slate gale
#

so you recommend just using transform.rotation with new Quaternion()?

#

Quaternion.LookRotation doesn't rly work for me so I decided against that btw

languid spire
zinc warren
languid spire
fringe plover
#

Hi, Iโ€™m making 2D platofrmer, and I need help._.
To make movement Iโ€™m using this:
rb.velocity = new Vector2(move*speed, rb.velocity.y)
But when I tried to make dash mechanic or smth like this by adding X force it just ignored it, so, what should I do?

languid spire
#

Anyway you should be using persistentDataPath for runtime

#

or streamingAssets Path

zinc warren
# languid spire what? it just randomly decides to drop the Assets/ part?

well when i build it into my downloads folder it works and then when i create a folder in the downloads folder and move the files into there then it gives me the error DirectoryNotFoundException: Could not find a part of the path 'C:\Users\patbr\Downloads\New folder\Assets\Resources\Worlds'.

zinc warren
languid spire
#

use Path.Combine

slender cargo
#

Quick question really.... This is on a pre-fab which has a different name, how can I find the text UI which is within the pre-fab?

#

This is throwing an error

#

Or would an easier way be to find a game object with the name "PlayerIndicator"?

#

Although I will have 2 of them in the scene at the same time, so that Won't work

languid spire
#

GetComponentInChildren ?

#

are you sure you need Text not TMP_Text ?

slender cargo
slender cargo
#

This didn't work either

slender cargo
#

I was unaware that this existed.

zinc warren
stuck palm
#

How come if I use get component and an object doesn't have that component an error doesn't happen until I try to use that component

timber tide
#

because it returns null

charred spoke
#

Because thats just how it works

timber tide
#

I suggest just use TryGetComponent and check if it's null right then

charred spoke
#

TryGet returns a bool if the component is found so no need for a null check

timber tide
#

right right

slate gale
polar acorn
languid spire
languid spire
#

do you ever create one?

zinc warren
languid spire
#

The Worlds folder in the project is only accessible using the Unity Resources API, not the .Net File Api

polar acorn
sleek notch
#

how to freeze the camera to not going to z axis

polar acorn
dim halo
#

I added a collider to my object, but the bird still gets through it, I would appreciate any kind of help>>

languid spire
#

he's writing as well at runtime, that's a no-no

polar acorn
dim halo
#

ok so basically I was watching a tutorial, however, because of Im stupidity I forgot to add the part where he adds collision to the object

#

later on, I wanted to add by myself

#

I did add collusion2d

#

But the bird still gets throuh

#

gh

dim halo
polar acorn
dim halo
#

in the scene, I dont have it

polar acorn
#

Don't have what

dim halo
#

as you can see, in the seen I dont have the pipe image

polar acorn
#

So if your problem is that you aren't colliding with the pipe the answer is probably because you don't have a pipe

dim halo
#

I do have it in the gameplay

#

Can I call?

#

to be more specific

#

it spawns

#

like in the game of flappy bird

polar acorn
#

Okay so then how are you moving the object you've still never said

dim halo
#

i just wrote the stuff in the script

#

it spawns

#

also gets deleted

cosmic quail
# dim halo like in the game of flappy bird

if u dont want the bird going through the pipes, then you need a collider on both of them and a rigidbody on the bird, and you have to move the bird in the code with the rigidbody (not transform.position or translate)

dim halo
#

after it crosses the deadzone

dim halo
#

I did just add the collider to the pipe

#

nonetheless, the bird still gets through it

cosmic quail
polar acorn
dim halo
#

for the bird rigid body

#

it says none (rigidbody 2D)

polar acorn
eternal falconBOT
polar acorn
#

Are both objects at the same Z position

dim halo
#

I can see the z position of the pipe

#

However I cant see it for the bird

#

Furthermore, i cant add a component to it

#

usually in the bottom of the inspector scene

#

There is a box where I can add component

#

now there is none

cosmic quail
wintry quarry
dim halo
#

No, I clicked on the bird image next to the birdscript

polar acorn
dim halo
#

okay

fringe plover
#

i tried porting code from 3D, whats wrong?

dim halo
#

the inspector of the bird object

polar acorn
cosmic quail
polar acorn
dim halo
#

yes, the one next to the birdscript is the object

#

I clicked on that one

cosmic quail
lunar grove
#

Anyone why my serializable field is not outputting the Product from my script code

polar acorn
dim halo
#

Should I click on the birdscript?

polar acorn
#

These are assets

dim halo
#

wait

#

my bad

#

sorry

polar acorn
#

Open the object

dim halo
#

ok sorry

#

the left window

gusty sorrel
#

i have a vertical fuel tank, and an engine at the bottom connected by a fixed joint and an upward force is applied to the engine. for some reason the thing starts tilting to one side after lifting off and after a few seconds it flips over. anyone know why could this be?

rocky canyon
#

is the Center Of Gravity in the middle?

dim halo
lunar grove
#
public float characterGravity = 9.81f * 2f;

However serializable field shows 9.81 still

rocky canyon
#

Center of Gravity is calculated by the colliders

dim halo
#

bird object

rocky canyon
#

if they are offset to one side it will tilt

gusty sorrel
#

its a simple cylinder and cube at the bottom and they are perfectly aligned

languid spire
lunar grove
rocky canyon
#

are you sure they perfectly aligned? select both of em and check ur center pivot

polar acorn
# dim halo

Okay so it's at Z=0, and from your previous screenshots your pipes are not. Put the pipes at Z=0 as well

languid spire
polar acorn
lunar grove
#

from when I first put it into a serializable field

polar acorn
#

If the code overwrite the inspector every time the code changed the inspector would be worthless for assigning values

polar acorn
polar acorn
dim halo
#

ah ok

#

Ok I did change the z

polar acorn
dim halo
#

sorry

#

it is now identical with the birds (0)

gusty sorrel
lunar grove
#

thanks for the replies and help though!

#

Oh wait this si what you literally said lmao

gusty sorrel
dim halo
#

the bird stills gets through it

cosmic quail
dim halo
#

okay

#

Im so confused

#

I did add the collusion

#

to the pipes

#

the bird still gets throuh

#

gh

cosmic quail
# dim halo gh

maybe your collider is offset or something and its not actually on the pipe. if u click on ur pipe it should show a green outline for where the collider is. is it in the right place? and can you check the bird's collider as well?

dim halo
#

okay

cosmic quail
#

if u dont see it then u gotta click on "edit collider" maybe to see it

polar acorn
dim halo
#

i can move them

#

from the scene

#

FINALLY

#

YEEEEES

#

IT WORKS

#

thx @polar acorn @cosmic quail

#

appreciate the help

cosmic quail
slate gale
#

Oncollisionstay is a unity method you canโ€™t just call it

dim halo
#

I had to add it to the pipe clone

#

to both of them

#

the upper and bottom one

slate gale
#

Similar like void start update awake ontriggerenter etc

dim halo
#

nope

#

not the clone

cosmic quail
slate gale
#

Ait cool

dim halo
#

sorry i mean the top pipe and the bottom pipe

cosmic quail
#

ok

rocky canyon
#

yup yup, makes sense

novel dagger
#

not done tho

frail star
#

I'm sure it's something simple I'm missing , I have a float value that stays between 0 and 1. I try to add to the value while it's decrementing in a coroutine and It doesn't increase the value while it's decrementing

public void ModifyHappiness(float amount)
{
    currentHappiness = Mathf.Clamp(currentHappiness + amount, 0f, maxHappiness);

    OnHappinessChanged?.Invoke(currentHappiness);
}

private IEnumerator DecreaseHappinessOverTime(float durationInSeconds)
{
    float startTime = Time.time;
    float initialHappiness = currentHappiness;

    while (Time.time - startTime < durationInSeconds)
    {
        float elapsedTime = Time.time - startTime;
        float progress = elapsedTime / durationInSeconds;

        currentHappiness = Mathf.Lerp(initialHappiness, 0f, progress);

        yield return null;
    }

    // Ensure the final happiness rate is exactly 0
    currentHappiness = 0f;
}

// Used with ui Button Like this --> happinessButton.onClick.AddListener(() => ConsumeHappiness(.05f));
public void ConsumeHappiness(float happinessAmount)
{
    ModifyHappiness(happinessAmount);
}
polar acorn
frail star
polar acorn
frail star
polar acorn
#

You would need to either have the coroutine subtract an amount over however long it takes to reach 0, or you'd modify the time to reduce the drain rate

fringe kindle
#

How do I disable a collider for a few seconds after exiting it?

rich adder
#

coroutine is easiest

fringe kindle
#

It's so I don't go back into it after jumping off the vine

frail star
# polar acorn You would need to either have the coroutine subtract an _amount_ over however lo...
fringe kindle
frail star
swift crag
#

A coroutine lets you run code that "waits"

rich adder
#

Indeed.

#

eg

public Collider colider;
public float waitTime = 3f;
IEnumerator TimedEvent()
{
    colider.enabled = false;
    yield return new WaitForSeconds(waitTime);//wait 3 sec
    colider.enabled = true;//enable it
}```
fringe kindle
#

ahh

#

Cheers

rich adder
#

Note you need StartCoroutine to call it ๐Ÿ™‚

fringe kindle
#

Where abouts would I need to put it?

rich adder
frozen stream
#

so im making a auto scrolling platformer and I want the player to die if it gets to far to the left off screen, how would I get the camera's edges to place triggers right off screen?

polar acorn
frozen stream
#

yes, but how do I get the camera's view's edges (the edges of the screen) and make that into world coordinates for the colliders?

wintry quarry
#

I'd do it the other way around. Zoom the camera such that it fits the colliders.
Otherwise people with different aspect ratio screens are playing a different game

frozen stream
#

but if i knew the cameras edges, then the aspect wouldn't matter, because the colliders would always be at the edge?

desert elm
#

2D Raycasts should interact with this edge collider, right?

wintry quarry
frozen stream
#

@ripe shard I don't think I understand this documentation

desert elm
wintry quarry
#

this looks like it should all be in a loop

#

instead of 3 separate nested raycasts

desert elm
wintry quarry
#

I mean a loop instead of repeating code 3 times

desert elm
#

well, I need to measure the distance and multiply said distance
if the raycast is going through a specific area in the game

#

right- is there a way to make a tag selectable from the inspector?

swift crag
#

What are you trying to accomplish?

#

Not "shoot three raycasts"

wintry quarry
swift crag
#

what is this, logically, supposed to be doing?

wintry quarry
sleek notch
#

I would like to stop at 15 degrees but it won't stop anyway and also if elevation is 0??

wintry quarry
#

Debug.Log

polar acorn
sleek notch
#

It is. Because if I go up the number raise up

wintry quarry
#
Debug.Log(cann.transform.rotation.x);```
#

you will see

sleek notch
#

I did this to see it

sleek notch
#

I'm saying it raising up

eternal needle
#

What you see in inspector isnt what that value is

#

The inspector shows you euler angles

sleek notch
#

0.15

#

oh inspector

polar acorn
#

That's one component of the four-dimensional vector expressing a specific orientation

sleek notch
#

This is inspector somehow Y raising up and X is still

#

Wait sorry

#

Cannon. My bad the X is raising with cannon

wintry quarry
desert elm
# swift crag what is this, logically, supposed to be doing?

I want there to be a specific area in the game that is "harder" to see through, and I want to simulate this by measuring the distance between the target and whatever it wants to look at with a raycast
if the raycast enters/hits the collider of the specific field, then I want it to stop, and send out another raycast.
If it hits/reaches the target, then the distance will be tallied up, and the distance inside the area of the edge collider ( with the tag forest ) will be multiplied

if it instead hit the edge of the collider again, then I want it too tally up the distance with the multiplication, and repeat the function, now starting from where the second hit occured

sleek notch
#

Ok thanks it's working. I'll see tutorial about it

desert elm
#

changed the code

#

my main problem is that the first raycast doesn't appear to interact with the edge collider, even if I have this enabled

#

or hell, the raycast doesn't appear to interact with anything for that matter

#

can't even hit normal colliders

wintry quarry
# desert elm

If you have startPosition and endPosition then Raycast is overcomplicating things. You should use LineCast. It was made for that

#

Also you're drawing the ray with viewRange here but not considering viewRange in the raycast itself

desert elm
#

but I draw it with view range to reduce visual clutter

wintry quarry
#

otherwise the default raycast distance is infinite

desert elm
wintry quarry
wintry quarry
#

does that object have that tag?

desert elm
wintry quarry
#
if (hit) {
  Debug.Log($"Hit an object with tag {hit.collider.tag}");
}
else {
  Debug.Log("Hit nothing");
}```
desert elm
#

yes

wintry quarry
novel hemlock
wintry quarry
#

double click the canvas object in hierarchy

novel hemlock
desert elm
#

I found the problem, the raycast was starting inside the collider

#

I assume that this shouldn't be happening

buoyant knot
#

physics queries can be weird right at the boundary of the collider if you need high precision because then the little parameters make a difference

earnest tendon
#

im atempting to create a script that can access another script to give a knife object some stats but im running into this issue and i got no idea how to solve it

earnest tendon
#

oh

sage mirage
#

Hey, guys! I want to set a particle effect to my player, so whenever player transform changes to have the particle effect to the changed player position. How to do that?

wintry quarry
sage mirage
wintry quarry
sage mirage
wintry quarry
noble garnet
#

I do have a issue with my 3d game. when ever I turn left or right it will form a circle instead of going straight to left or right. Is there any solution?

timber tide
#

yes, don't rotate

desert elm
# desert elm I assume that this shouldn't be happening

so I have a memory leak- any ideas on why?
I know its because of recursion/repeating the method inside itself, but I see no reason why it would repeat itself so much that there would be a memory leak
in this case, it should only repeat 1.5 times

halcyon summit
#

Is there a best practise for where to store the level at which an item becomes unlocked? Does it belong in a Scriptable Object, in a dictionary, or maybe as a variable on the prefab of the item? Or just done to preference?

timber tide
#

Dictionary with the item/type reference and bool should be fine

swift crag
#

I would store unlocks as data separately from the item

shrewd swift
#

Hello guys, i got some questions regarding declaring and initializing lists.

When declaring the variable

List<float> somelist;

we can initialize its content :

List<float> somelist = new List<float>();
// (1) i suppose this creates an empty list

List<float> somelist = new List<float>(){
        10f,
        4.5f
    };
// (2) sets some values when init

but if i dont want to add some values right at the beginning, does doing some methods like varname.Add(item) error ? or will c# automatically construct a empty list then do the method ?

why would i do new List<float>() if i dont prefill ?

swift crag
#

how I'd do that is up in the air

#

it could just be a single list of item-level pairs, or a list of "UnlockInfo" scriptable objects

swift crag
#

They aren't fixed-size like an array is

shrewd swift
#

yes, they double each time we go above its limit right ?

swift crag
#

You need to construct the list so that it exists, though

swift crag
#
List<float> x;
x.Add(3);
#

This is bogus. x doesn't refer to a list.

#

it will be null

stuck palm
#

why isnt my particle system playing? its printing the print to the console, but i cant see any particles being played

swift crag
#

An empty list is very different from a list that doesn't exist

shrewd swift
#

ah okay, because sometimes i got no object references, i wondered why

so except if i SET the list, i have to construct it so its an actual list ?

swift crag
#

you should be doing transform.eulerAngles.x, etc.

swift crag
#

you could construct it in the field initializer, or construct it right before you use it

#

(and if it's serialized by unity, it'll be initialized to be an empty list, too)

shrewd swift
#

ok ty guys

swift crag
#
[SerializeField] List<int> foo;
List<int> bar = new();
List<int> baz;

void Start() {
  baz = new();
  foo.Add(1);
  bar.Add(2);
  baz.Add(3);
}
#

All three of these will behave correctly.

shrewd swift
#

i see

swift crag
shrewd swift
#

so [SerializeField] was the reason why sometimes it was throwing an error and sometimes no

swift crag
#

(log when you call Stop, basically)

shrewd swift
#

ty

swift crag
#

Sometimes I initialize the list myself anyway

#

It looks a bit weird to see a list that I appear to never construct

#

that's just personal preference, though

stuck palm
swift crag
#

(in that case, C# will construct an empty list as the object comes into existence, and then Unity will overwrite it)

swift crag
#

I don't remember the specifics off the top of my head, but I know there are different ways to draw them

#

Also, make sure you have 3D rotation enabled

stuck palm
swift crag
#

That'll do it -- the system was using the "Start Rotation" float field instead

shrewd swift
#

can I ask here a question regarding the usage of a unity package ? (not built in)

#

because its a code usage problem

stuck palm
#

idk whats happening here

wintry quarry
shrewd swift
#

ah okay

#

well i found out my issue

deft monolith
#

Hi! Having trouble wrapping my head around quaternions. I'm just trying to rotate my cube either 90+- degrees in the X or Z world axis. But when i first rotate X, and then rotate Z, its being rotated in the local Z axis instead of world Z axis. I dont know how to get it to use the world axis here. I know the issue but not the solution.

#

The GetRollRotationX/Z just returns -90 or +90 depending on direction.

wintry quarry
#

you can't take 1/3 or 2/3 of the euler angles and reuse them with some other angle. They come as a set of 3 or not at all

#

due to gimbal lock

#

You'd probably be better off not using them at all

deft monolith
#

Yeah.. Been trying to solve this for three hours now lol. Im aware of the transform.rotate method but giving it the correct data on how much to rotate per iteration is difficult

#

Yep im aware of gimbal lock, thats almost whats happening,

wintry quarry
#

the simplest option is usually:

Quaternion targetRotation = /* calculate target rotation as a quaternion here */
while (...) {
  // blah blah
  RotationObject.transform.rotation = Quaternion.RotateTowards(RotationObject.transform.rotation, targetRotation, Time.deltaTime * speedInAnglesPerSecond);
}```
#

e.g.
Quaternion targetRotation = RotationObject.transform.rotation * Quaternion.Euler(90, 0, 0); to do a rotation of 90 degrees on the x axis

deft monolith
#

Ah okay! I'll give that a shot, thanks ๐Ÿ™‚ I'll need to think about how to use my RotationCurve (animation curve) instead of the angles per second.

wintry quarry
#

instead of RotateTowards

#

if you know how to use it

stuck palm
#

@swift crag think i discovered the issue, put it in update and this is happening

polar acorn
stuck palm
#

its in this sort of pattern

polar acorn
#

So then yes it is stopped

buoyant knot
stuck palm
buoyant knot
#

quaternion multiplication is equivalent to applying one quaternionโ€™s rotation operator to another

polar acorn
stuck palm
buoyant knot
#

eg if you want to rotate by +90 in x, and then +90 in y, you cannot set new rotation to (90,90,0). Itโ€™s just incorrect, and the order of rotations matters

buoyant knot
#

youโ€™d want to take (+90 y rotation) * (+90 x rotation)

polar acorn
#

So you know what it is at that precise moment

stuck palm
stable ore
#

how to get rid of dis?

timber tide
#

speaking of gimble lock and quaternions, spent like a few hours debugging because I had to flip some quaternions from lefthand to right of my operator

#

and I still have no clue why

wintry quarry
stable ore
wintry quarry
#

VS...

stable ore
#

alr

polar acorn
stable ore
wintry quarry
polar acorn
timber tide
stable ore
stuck palm
#

i dont know why this particle system isnt playing, its filling all the requirements to start playing

desert elm
#

right so-

i assume that the memory leak is occuring due to the recursion- but I have no idea why that would happen. Is it possible that the second raycast is spawning inside an edge collider?

stuck palm
wintry quarry
#

just restart the editor

desert elm
#

oh okay-

#

good to know, thanks

polar acorn
polar acorn
#

And the particles are set to play on Awake, so what happens if you just disable this script entirely? Are the particles constantly playing?

stuck palm
polar acorn
#

If you select the particle system there should be a little preview window. Do you see them in that

polar acorn
stuck palm
polar acorn
#

Here's an idea, comment out the line that stops the particles, and add this in update:

if (!fast.isPlaying){
  Debug.Log($"{gameObject.name}'s particles are stopped!", this);
}

If this logs, then a different script is stopping the particles.

polar acorn
# stuck palm

Well, it's not stopping but isn't that white swoosh the particle you're looking for?

stuck palm
#

thats just a trail

polar acorn
#

Okay, so, since that debug isn't firing, then the particle system is playing. Select it in the hierarchy and see where the object actually is

polar acorn
# stuck palm

I don't see the transform gizmo for this, is it where you expect it should be?

stuck palm
polar acorn
stuck palm
polar acorn
#

Well, it seems to be playing constantly, nothing is stopping it, so my guess is it's just not visible from wherever you are looking at it

stuck palm
polar acorn
stuck palm
polar acorn
#

The angles and whatnot

stuck palm
#

lemme comment those out one sec

polar acorn
#

Try commenting those out for now and just play/pause based on velocity

stuck palm
polar acorn
stuck palm
desert elm
#

how do I make the scene show all layers?

polar acorn
#

They're collections of objects

desert elm
polar acorn
#

Also, if you can only see things on default that's a camera issue

#

The camera has a culling mask

desert elm
polar acorn
#

Which ones are UI and which ones are non-UI?

desert elm
sage mirage
#

Hey, guys! I have a question. Where we use BoxCollider2D and where the BoxCollider?

polar acorn
polar acorn
sage mirage
#

Why I am asking that because something happening when I am using BoxCollider2D on my 2D game and the player just falling down???

desert elm
sage mirage
#

Oh, ok!

#

Thanks!

desert elm
polar acorn
# desert elm

Hover over that box and double-press "F" on the keyboard

desert elm
#

in the rigid body

sage mirage
#

@polar acorn There is no problem to use BoxCollider on my 2D game right if I dont want to use the BoxCollider2D right?

desert elm
polar acorn
#

That is the only question

sage mirage
#

I don't know XD

polar acorn
#

if you're using 2D physics, BoxCollider2D

#

Otherwise, BoxCollider

#

You will never use both

sage mirage
#

How to understand which physics I am using ?

polar acorn
sage mirage
#

It is a 2D then I am using 2D right?

polar acorn
stuck palm
#

i think im just gonna forget about this stupid particle thing

polar acorn
# desert elm

Can you show the inspector of this object's parent?

sage mirage
#

Yes, I just got confused when you said which I am using you know.

desert elm
polar acorn
# desert elm

So, both of these have sprite renderers. A square and a circle. Did you want there to be two sprites?

desert elm
#

this is how I want it to look, but I need to change the layers of all the gameobjects to default

sage mirage
#

@polar acorn Hey! The same happening with Rigidbody?

#

Rigidbody2D doesn't have gravity option btw

polar acorn
sage mirage
#

Like to enable and disable

polar acorn
#

that is the only question

polar acorn
#

use the one for whichever one your project is

desert elm
#

its the eyes

#

thanks

sage mirage
#

@polar acorn You said before to enable and disable gravity. In 2D environment a Rigidbody2D doesn't have that option to enable and disable that's what I mean. So, how can I enable and disable any gravity? Do I have to use maybe the Rigidbody itself and not the 2D one?

polar acorn
queen adder
#

You would just set gravity scale to 0

polar acorn
#

If you want your guy not to fall over, lock the rotation

sage mirage
#

Oh it was the other guy

polar acorn
sage mirage
#

Sorry XD

#

@desert elm Why you said to disable gravity if there is no option for that in Rigidbody2D? Maybe you meant to use Rigidbody and not the 2D one like I said?

desert elm
sage mirage
#

Oh, you meant in code alright

sage mirage
tribal minnow
#

hello guys, im using the unity free assets third person controller on android. but the ui controllelr camera movement is way too fast. how can i slow it down ?

tacit birch
#

This is driving me crazy and I don't know how to fix this.
I have my Player set up using Spine and I've set up the SortingLayers correctly and everything. For some reason though when I MOVE the character slightly, the Children GameObjects that have SkeletonData seemingly duplicates the Player's Head sprite, causing it to overlap the eyes/hair/hat

It only seems to be happening whenever the animation is set, which is why i crossed out the line for the Start method (I accidentally had Head Untoggled in the video but you get the idea)
What am I doing wrong here?