#💻┃code-beginner

1 messages · Page 50 of 1

swift crag
#

those are two unrelated variables

#

sounds suspicious to me

solemn fractal
#

Hey guys, removed my camera, now added a new one.. and I had that in my code that is not working any more . how to fix that?

topaz mortar
#

then the function is not getting called, figure out why not

wintry quarry
#

wdym by "they did not work"?

dry tendon
#

Data is from the API response, gameData is from the Json file i've created

polar acorn
wintry quarry
#

No - put it in the spot where you are confused about the code running that you don't expect to run

mossy arrow
solemn fractal
wintry quarry
#

They didn't print?

#

Then the code you are looking at is not running at all.

mossy arrow
polar acorn
wintry quarry
mossy arrow
ivory saffron
#

reposted in general

mossy arrow
wintry quarry
mossy arrow
#

then 5 did not work

wintry quarry
#

what is 5?

#

Use !code to share code

eternal falconBOT
polar acorn
mossy arrow
wintry quarry
#

also put it OUTSIDE the if
and use a different label for each thing so you know what's what.

mossy arrow
#

this one did not run

mossy arrow
#

sadly i dont know what to put here

untold atlas
#

I've been making a platformer themed game built for the amazon fire tv, on a windows build the player spawns and everything but on the fire build the player doesn't spawn. Is there a better channel to ask this in?

wintry quarry
#

Typically you'd want to do it before but... should be fine

#

simpler/more readable though would be:

Debug.Log($"Current time is {currentTime}. Sunrise time is {gameData.SunriseTime}. Sunset time is {gameData.SunsetTime}");```
dry tendon
#

hmm, so clever...

#

i'm building the project, it should be ready in a few seconds

mossy arrow
mossy arrow
frosty hound
#

@mossy arrow Make a thread. Your hand-holding requirements always end up flooding these channels.

mossy arrow
polar acorn
dry tendon
mossy arrow
#

Fen said I dont know

#

PraetorBlue stop helping me after when he said to use Debug.Log

topaz mortar
frosty hound
polar acorn
polar acorn
eternal falconBOT
frosty hound
#

The fact you don't understand how debug logs work after you were supposedly using them (with help) 10 days ago just shows you're not actually committed to learning, and hoping someone will solve your issues.

mossy arrow
#

and it is still not working

untold atlas
#

I've been making a platformer themed game built for the amazon fire tv, on a windows build the player spawns and everything but on the fire build the player doesn't spawn.

mossy arrow
topaz mortar
dry tendon
dry tendon
#

I don't want to be awfull... but i would like to know how to fixe it and what's happenning...

swift crag
#

follow the logic that loads the file

#

make sure that it actually executes

terse raven
#

Hi again! I need some help. I'm making a 2D game. I'm trying to shoot a raycast, and find an object at THE END of the raycast not the first thing it hits. Is this a feature of unity? If so can someone help

warm lichen
#

Anyone know how to instantiate as a child of an object

short hazel
#

Instantiate can take a parent Transform for some of its overloads. Pass the object that needs to be the parent there

#

Two of them, the second and the last in this list

oblique torrent
#
random.NextInt64()

why am i getting an error on this? trying to move a csharp project to unity
it says Random does not contain a definition for NextInt64

short hazel
#

You need System.Random

#

Or using System; at the top

oblique torrent
#

🤔

short hazel
#

No, you're not

oblique torrent
short hazel
#

Oh, you might be actually

oblique torrent
#

sorry for sending an image of text lol

short hazel
#

But NextInt64 is only available for .NET6 and above

oblique torrent
#

does unity not support it then?

short hazel
#

Correct

oblique torrent
#

shi

short hazel
#

Unity's C# is over 10 years old

oblique torrent
#

if i use unitys own random class, will i be able to use a seed so that its consistent

#

like how i can do it with System.Random

short hazel
#

Not sure whether Unity's has one that can return a long (Int64)

oblique torrent
#

wha

#

since when was this a thing

short hazel
#

But you can generate two int and bit-shift one to construct a long lol

oblique torrent
#

i guess i can just combine two random int

#

yeah

#

lmao

#

i can do the seed thing right?

#

thanks for the help anyway

turbid path
#

how do i disable the auto code snippet suggestions?

#

i couldn't find out what they're called

north kiln
#

Presumably you can click the ... and go to the settings

#

but no idea, can't even tell what IDE this is

turbid path
#

vscode

#

hm theres not much there

north kiln
turbid path
#

Oh thanks!

#

looks exactly the same

warm lichen
short hazel
#

Trying to instantiate a copy of empty under Grid's parent?

north kiln
#

Did you want to parent to Grid, or Grid's parent?

short hazel
#

The former, Grid is the one to pass

warm lichen
short hazel
#

Okay so just pass Grid

warm lichen
#

pass?

short hazel
#

Yes, to the Instantiate method

#

Grid instead of Grid.parent

warm lichen
#

ohhh alright\

#

thanks man

#

worked this time

tardy forum
#

Hi people! WTF is happening here? I am trying to check it a generic constructor parameter called initial (which in this particular case is of type Collider2D) is null and set the HasValue flag accordignly and...well it simply doesn't work and I can't understand why. These are screenshots taken in debug mode immediately after the HasValue assignment.

#

I can't understand why HasValue results to be always true regardless

north kiln
#

Like, not the type you are passing, the type you have declared that you are passing

tardy forum
#

it's a <T> for the parameter declaration

oblique torrent
#

lol i had to combine 4 ints to get a ulong, becasue random.Next() returns a int which is signed, and i need a 64 bit ulong

#

very ugly code

north kiln
tardy forum
#

Exactly

north kiln
#

Hrm. No idea then. I thought it might be a Unity Null thing you're seeing, but if it's actually declared as a UnityEngine.Object subtype there should be no issue

short hazel
tardy forum
oblique torrent
short hazel
#

It has an overload for min and max value

oblique torrent
#

oh i didnt see that

#

thanks

short hazel
north kiln
#

Does the constraint actually matter to force it to use the Unity equality?

tardy forum
north kiln
#

I've not tested whether constraints cause that behaviour, or just the implemented type

short hazel
#

Should be able to check by hovering over the equality operation, if you can navigate to its definition and it's the one in UE.Object then you're probably fine

#

Hope they at least mitigate this when they'll switch to CoreCLR, with a static abstract interface that forces the implementation of operator ==, so you can actually constrain to the interface type and be sure UE.Object's override is called

tardy forum
#

It's something due to the parameter assignment maybe? But still I can't understand why the debugger says the result of the comparison is false and Unity still thinks it's true

north kiln
#

I just tested it and it looks like you do have to constrain the type

silk night
#

!code

eternal falconBOT
north kiln
tardy forum
#

Ok, can't try right away because the same thing is used somewhere else with an int

#

but anyway, I trust you

#

I'll think it throught tomorrow

#

Thank you guys

oblique torrent
#

theres no Span<T>.Sort() in unity? 😭

short hazel
#

Method is .NET5 and above only

oblique torrent
#

ill write a sorting method i guess

short hazel
#

Before asking, check the docs: search the method and scroll down to the "Applies to" section

buoyant knot
#

it’s really nice that Unity never updates to later versions of C# or dot Net. I think it would be super confusing if we suddenly got more tools to work with, and that everyone would hate that.

timber tide
#

no

#

gimmi parameterless constructors and field initializers already

#

for structs

verbal dome
#

File-scoped namespaces plz

swift crag
crystal cipher
#

hi does anyone know how to prevent date cheats?
please do not use php time servers.

north kiln
crystal cipher
#

but I had trouble using api call

rich adder
#

should be fairly straight forward

crystal cipher
#

oh alright, so the method I majorly tried is using a php server to get time,

#

but it got wrong because I kind of disliked it

#

because it doesn't work when internet connection is bad 😦

#

so I seeked for other methods, and thats

#

how it begun

#

Also I used
<?php

$datetime = date("Y-m-d\TH:i:s", time());
echo '{ "datetime": "'.$datetime.'" }';

?>
but the timezone was different

#

and it was unstable

#

so it went 500 sometimes

rich adder
crystal cipher
#

yes... kind of

#

there is a feature that it really matters

wintry quarry
# crystal cipher yes... kind of

if this is a networked/multiplyer game then the only real solution is to make sure whatever the player is trying to cheat to get is something that lives in a database / web application you operate

#

if it's a singleplayer/local game there's basically nothing you can do

eternal needle
eternal needle
twin bolt
#

!code

eternal falconBOT
twin bolt
#

Why does this script work on multiple items that are close, instead of one at a time? ```cs
RaycastHit hit;
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, maxPickupDistance, ~IgnoreMe))
{
if (hit.transform.tag == "Door")
{
Door = hit.transform.gameObject;

            if (Gamecontrols.GamePlay.Interact.WasPressedThisFrame() && Door.GetComponent<Outline>().OutlineColor == Color.white)
            {
                Door.GetComponent<Door>().enabled = true;
            }
        }
    }
#

If two objects are close together it works on both.

#

Can raycast see two items at once?

teal viper
#

RaycastAll can

wintry quarry
twin bolt
silk night
# twin bolt Yes

Check if your key was pressed BEFORE you do the physics stuff, its very expensive to raycast every frame

silk night
#

Also there is better methods to check if you are looking at a door than to check for its outline color 😄

static cedar
sour fulcrum
#

It's the GetComponent that can hurt

summer stump
silk night
sour fulcrum
#

Oh forsure

summer stump
#

I would do a raycast every frame or every couple frames to show tooltips and key prompts for what you look at

#

And then do a trygetcomponent only when you press a key

teal viper
sour fulcrum
#

Oh frl?

#

I feel like the vibe i've consistently got online was very much not that haha

teal viper
#

Find functions might be heavier. But it all depends.

#

Get component just checks the list of components on the object. What is there to be heavy?

wintry quarry
raw hamlet
#

What is the best way to save variable data that needs to be accessed by a lot of scripts?

wintry quarry
raw hamlet
#

alr i will look into that

raw hamlet
sour fulcrum
#

What issue do you have with a Singleton?

silk night
raw hamlet
#

ok

oblique torrent
#

in the newer .net there is Span.Sort() though

#

which is what i was previously using

static cedar
#

Now that defeats the point of spans. UnityChanLOL

oblique torrent
#

¯_(ツ)_/¯

buoyant knot
#

isn’t a span like… an array the way arrays were always supposed to work?

zenith cypress
#

A span is just a slice of an array that is always stack-allocated. Also allows you to take a slice of an array to work on without making a new array, or needing to do loops with offsets. Example from the docs:

var array = new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
var slice = new Span<int>(array, 2, 5);
for (int ctr = 0; ctr < slice.Length; ctr++)
    slice[ctr] *= 2;

// The example displays the following output:
//      2  4  12  16  20  24  28  16  18  20
buoyant knot
#

i thought arrays come from C, where you have a literal pointer to a spot in memory, and direct the computer to go over however many bytes to access different parts of the array

#

which only makes sense with contiguous blocks of memory

zenith cypress
#

that's what an array is, yes

buoyant knot
#

in C#, arrays don’t need to be contiguous

#

at least i remember reading that, and thinking that is weird af

#

i can’t find anything on it rn

static cedar
brave compass
#

And NativeArray to Span. Span is a lower level array, that can reference any point in memory.

zenith cypress
#

I mean to say that the span itself is stack allocated, since it's a ref struct.

teal viper
buoyant knot
#

that’s good. I’d rather it be like that anyway

teal viper
#

There isn't really any way to implement an array differently.

#

There are linked lists, but they are not arrays

meager gust
#

structs will be stored contiguously and you'll make good use of the CPU cache

#

hopefully that clears it up

buoyant knot
#

oh. makes sense

static cedar
chrome crypt
#

How can I make a direct reference to an object without dragging it?

summer stump
mystic oxide
#

can somebody explain to me... its sortedlist

#

nvm figure it out catto

gaunt ice
#

Key is string and value is int

#

And you use index to access the values array which is ordered by key…

#

Ie it is “unordered” without considering key array

mystic oxide
#

ty, was really confused until i research about sortedlist

#

Should have using something else to store user data and their score, not using database (Mysql) yet, just messing around

fresh wing
#

How do I change this to 1 using a script? that function is imported from FadeInOut.cs, and I want to change the value from other script ()Sorry for bad english, if you confused just mention me}
FadeInOut.cs

using UnityEngine;
using UnityEngine.SceneManagement;

public class FadeInOut : MonoBehaviour
{
    public Animator animator;
    public int levelToLoad;
    // Start is called before the first frame update
    void Start()
    {
        animator = GameObject.FindWithTag("FadeUI").GetComponent<Animator>();
    }
    void Update()
    {

    }
    public void FadeToLevel(int levelIndex)
    {
        levelToLoad = levelIndex;
        animator.SetTrigger("FadeOut");
    }
    public void OnFadeComplete()
    {
        SceneManager.LoadScene(levelToLoad);
    }
}

Other Script

using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class OptionsManager : MonoBehaviour
{
    public OptionsDatabase optionsDB;
    public TMP_Text nameText;
    public Image artworkSpritePlace;
    public Button StartButton;
    private int selectorOption = 0;


    private void Start()
    {
        UpdateCharacter(selectorOption);
    }
    public void NextOption()
    {
        selectorOption++;
        if (selectorOption >= optionsDB.OptionsCount)
        {
            selectorOption = 0;
        }
        Debug.Log(selectorOption); Debug.Log(optionsDB.OptionsCount);
        UpdateCharacter(selectorOption);
    }
    public void BackOption()
    {
        selectorOption--;
        if (selectorOption <= 0)
        {
            selectorOption = optionsDB.OptionsCount - 1;
        }
        Debug.Log(selectorOption); Debug.Log(optionsDB.OptionsCount);
        UpdateCharacter(selectorOption);

    }
    private void UpdateCharacter(int selectedOption)
    {
        Character character = optionsDB.GetOption(selectedOption);
        artworkSpritePlace.sprite = character.LearningMaterialCover;
        nameText.text = character.LearningMaterialName;
        StartButton.enabled = character.enableStartButton;
        Debug.Log(StartButton.GetComponents<FadeInOut>());
    }
}
teal viper
fresh wing
#

NowI have another problem

#

How do I change a public variable from a script attached into a gameObject

teal viper
fresh wing
fresh wing
teal viper
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

fresh wing
fresh wing
teal viper
fresh wing
# teal viper What do you mean?

public GameObject FadeS;
private object anj;

    anj = FadeS.GetComponent<FadeInOut>();
    Debug.Log(anj.levelToLoad);

This will produce error

junior seal
#

I am quite literally losing my fucking mind rn oh my g a w d

teal viper
#

Let's start from reading the error and understanding it

junior seal
#

So Im trying to make code that executes a win condition. I'm currently in college and we did this in class and it works perfectly. I basically copied the code from class into my project and it doesnt work for some reason. Almost everything is the same logic wise and I am genuinely so confused. ```public class GameManager : MonoBehaviour
{
public void UpdateGameGoal(int amount)
{
enemiesRemaining += amount;

  if(enemiesRemaining <= 0)
  {
      door.DoOpenDoor();
      ExitDoorCondition();
  }

}
}

public class TempEnemy : MonoBehaviour, IDamage
{
void Start()
{
GameManager.instance.UpdateGameGoal(1);
}

public void takeDamage(int dmg)
{
    StartCoroutine(FlashRed());
    Hp -= dmg;

    if (Hp <= 0)
    {
        Destroy(gameObject);
        Debug.Log("Die object Die");
        GameManager.instance.UpdateGameGoal(-1); //This code gives me an error. If I remove it, everything is fine but I need this here
    }
}```
fresh wing
tall delta
#

enemiesRemaining -= amount; maybe? or du you pass in a negative value when calling UpdateGameGoal()?

keen dew
teal viper
junior seal
teal viper
teal viper
junior seal
teal viper
#

Also "because it's not an instance" really doesn't justify anything.😅

junior seal
#

what do you mean by instance

#

wait im getting my terminology mixed up i thought you meant interface 😭

fresh wing
# teal viper Let's start from reading the error.

Assets\UI\Selection\OptionsManager.cs(46,23): error CS1061: 'object' does not contain a definition for 'levelToLoad' and no accessible extension method 'levelToLoad' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

I though c# is the same as JS so i tried getting the value of levelToLoad from its keys 😭

teal viper
junior seal
#

yes it has a static instance field my bad lol

keen dew
teal viper
junior seal
#

bc it gets destroyed-

#

like its supposed to

keen dew
#

Why is the gamemanager supposed to get destroyed?

junior seal
#

no the object

#

hold on im so confused

keen dew
#

Ok, so do you have a gamemanager in the scene?

teal viper
junior seal
fresh wing
junior seal
#

ok so i added the manager into the scene and its doing the same thing. when i shoot the enemy down to 0 hp, the enemy gets destroyed and its supposed to update the game goal

#

but its just throwing an error, the same one

teal viper
teal viper
junior seal
#

It works in my other project just fine but not in my personal one.

fresh wing
#

public GameObject FadeS;
private object anj;
anj = FadeS.GetComponent<FadeInOut>();
Debug.Log(anj.levelToLoad);

gaunt ice
#

You should learn c# basic first…

junior seal
fresh wing
teal viper
gaunt ice
#

Js hides the concept of variable type

teal viper
#

And you really should listen to my previous tip.@junior seal

junior seal
junior seal
#

i didnt see that. my bad

gaunt ice
#

Where do you set the “instance” of game manager

teal viper
#

Based on the shared code, it doesn't even exist.🤷‍♂️

junior seal
#

can i share pictures?

teal viper
#

Yes, but not if it's code...

static bay
teal viper
#

!code

eternal falconBOT
junior seal
keen dew
#

When you get the error, pause the game, select the game manager in the hierarchy and take a screenshot of the whole editor with the console visible~

#

scratch that. Just show the entire error message

#

I'm guessing the error comes from the GameManager method

junior seal
#

i figured that out

#

thats why the error is that

keen dew
#

If it's deleted it won't throw that error

junior seal
#

ignore that its not being deleted

keen dew
#

The line number doesn't match but I'm guessing line 28 in your actual code is door.DoOpenDoor();

teal viper
#

Probably not sharing the whole up to date code again😅

junior seal
#

yes tf i am

#

im not an idiot dude

teal viper
#

Okay, then make sure that there are no compile errors

junior seal
#

i just didnt look at the scene stuff right

junior seal
teal viper
#
        enemiesRemaining += amount;

Can't possibly throw that error.

junior seal
#

well its telling me that??

teal viper
#

Take a screenshot of the whole console window

keen dew
junior seal
#

its line 28 in my enemy code

#

bc it references the instance

keen dew
#

That's irrelevant

#

What's on line 28 of GameManager.cs?

teal viper
junior seal
#

enemiesRemaining += amount;

#

yup

teal viper
#

Not possible. Make sure the updated code is compiled properly.

junior seal
teal viper
#

How did you do that?

junior seal
#

im telling you when i delete line 30 my Temp Enemy code that error doesnt happen

teal viper
#

Are here to argue or accept help?

junior seal
# teal viper Are here to argue or accept help?

listen dude im here to get help but youre being a dick and not listening to what the fuck im saying. youve been insinuating that im stupid and cant understand basic fucking english. thats just fucking rude. Ive been trying to tell you that I have done this EXACT SAME THING before and it worked perfectly but RIGHT NOW it is not working for some ungodly reason.

#

Now can you please stop treating me like im a 4 year old who cant understand what youre talking about?

teal viper
#

I don't know what you've imagined, but not once have I called you any of the words that you mentioned.

junior seal
#

basically saying im stupid

#

im not here to argue. Im frustrated as fuck so Im sorry but I dont like being talked down to

teal viper
#

Lol what? How is that related? If I want to call someone stupid I would say that directly.

#

Anyways, if you don't want to provide the relevant information, I'm not sure we'll be able to proceed anywhere.

gaunt ice
#

You call a method that can cause NRE doesn’t mean the action of “calling the method” give you NRE but some codes inside that method give you NRE, so delete the call of method is ofc remove the NRE, you dont even execute the code (inside that method) which causes NRE
Btw log if the instance is null and the door is null first

junior seal
#

Again, im frustrated as I have been in the hospital all damn day, and now i have to do this and im getting talked down to, so yea im sorry dude. im trying my best. im sorry if my best isnt good enough but i thought this was a beginner friendly channel

#

considering the name

fossil drum
#

Well, a NRE is impossible on that line 28.

teal viper
#

Im not expecting anything extraordinary. Just to share relevant info without saying stuff like "I checked million times".

junior seal
#

Okay well what is it exactly that i must show?

#

the whole console window?

teal viper
#

Start from showing the console with the error. The whole window.

junior seal
#

okay

teal viper
#

Okay. Now find the script file in your project window, select it and take a screenshot of the inspector.

junior seal
teal viper
#

Counting the lines manually, it seems like it's different from what you've shared previously.

gaunt ice
#

Screenshot you code in ide including the line number next time

junior seal
#

dunno why, thats exactly what i have

junior seal
teal viper
#

Now you can do that.

junior seal
#

okay

gaunt ice
#

You can screenshot your code if someone ask you to do !code

eternal falconBOT
teal viper
#

You didn't save the file

junior seal
#

ah shit thought i did

gaunt ice
#

I remember the rule is stated somewhere but i forgot…

solemn fractal
#

Hey guys, I have an object that is the enemy and it contains a Circle colider. If i want with code while 1 enemy is approaching other to detect that the other one is there and maintain distance, can I apply another collider and make it bigger to do the check or need to be all in code?

junior seal
teal viper
# junior seal

Yep. Now it makes sense.
Now, what can be null on that line?

junior seal
#

bc the other is a function

teal viper
#

Yes.

#

Where do you assign the door reference?

junior seal
#

up top line 13

#

am i doing that wrong?

teal viper
#

Yes. That's a declaration of the variable. Not assignment/initialization.

#

You say "this thing is going to point at some door" basically. But you never assign any specific door to it.

junior seal
#

okay well how do i assign that to a specific door in my scene

teal viper
#

Many ways. You could use one of the Find methods. Or pass the door reference from somewhere else(the door itself for example).

junior seal
#

im not very familiar with doing that so do you have any resources or advice?

fossil drum
teal viper
#

That's to this specific issue, but I suggest going over some C# basics too.

junior seal
#

oki thank you

golden ermine
#

Can someone help me with this, I have thirst bar and hunger bar and it goes down troughout the time and when it reaches 0 it will take ur health slowly but when u pickup some food it will give you amount depends on food or water u picked up but problem is as u can see in screenshot i give it an exact value but when hunger is still high like for example 80 and i add 50 to it it will be 130 and max is 100 so can someone help me add amount that will add up to 100 if it is left more than 50? This is script for thirstbar and hungerbar and screenshot is in player script:https://hastebin.com/share/omoqoxoqez.csharp

languid spire
#

do the same for thirst

languid spire
#

what do you think?

golden ermine
#

its good but what should i change here

languid spire
#

nothing

static bay
#

Well

golden ermine
#

so now it should work

languid spire
#

do you not understand the code I wrote?

static bay
#

Is this all in the player script in something like OnTriggerEnter?

languid spire
vale mountain
#
    {
        this.grounded = Physics.CheckSphere(groundCheck.position, groundRadius, ground);

        this.Look();
    }

    private void Look()
    {
        float axis = Input.GetAxis("Mouse X") * this.sensitivity * Time.fixedDeltaTime * this.sensMultiplier;
        float single = Input.GetAxis("Mouse Y") * this.sensitivity * Time.fixedDeltaTime * this.sensMultiplier;

        Quaternion quaternion = this.cam.transform.localRotation;

        this.desiredX = quaternion.eulerAngles.y + axis;

        this.xRotation -= single;

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

        this.cam.localRotation = Quaternion.Euler(this.xRotation, this.desiredX, 0);
        transform.localRotation = Quaternion.Euler(0f, this.desiredX, 0f);
    }``` why is this choppy? its a first person camera rotation based on mouse thing
golden ermine
static bay
languid spire
#

this is wrong

golden ermine
languid spire
#

yes

golden ermine
languid spire
#

_hunger -= Time.deltaTime * hungerSpeedMultiplier;
or
hunger += -(Time.deltaTime * hungerSpeedMultiplier);

keen dew
#

The setter should be

set { if (value < 100f) _hunger = value; else _hunger = 100f; }
golden ermine
#

_HUNGER

#

_hunger

keen dew
#

ya

#

The setter overrides the = operator, not the += operator

languid spire
#

no, you need to check the result of the add

keen dew
golden ermine
#

now it works thanks

static bay
golden ermine
#

sure

static bay
golden ermine
static bay
#
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.gameObject.tag == "Pickup")
        {
            pickupSfx.Play();
        }
        if (collision.gameObject.tag == "PickupHeal")
        {
            healSfx.Play();
        }
        if (collision.gameObject.tag == "PickupHunger")
        {
            playerUI.hunger += 50;
            eatSfx.Play();
        }
        if (collision.gameObject.tag == "PickupMidHunger")
        {
            playerUI.hunger += 35;
            eatSfx.Play();
        }
        if (collision.gameObject.tag == "PickupLessHunger")
        {
            playerUI.hunger += 20;
            eatSfx.Play();
        }
        if (collision.gameObject.tag == "PickupThirst")
        {
            playerUI.thirst += 50;
            drinkSfx.Play();
        }
        if (collision.gameObject.tag == "PickupLessThirst")
        {
            playerUI.thirst += 20;
            drinkSfx.Play();
        }
        if (collision.gameObject.CompareTag("Wood"))
        {
            woodSfx.Play();
            playerUI.woodCount++;
        }
    }```
Ok so in this method I see you're checking what the player collides with and doing things based on the item, right?
golden ermine
#

yes

#

stuff that gives lover thirst it will be PickupLessThirst

#

and so on

static bay
# golden ermine yes

What if you flipped it around? Have the item check for collision against the player. Then the item makes changes to the player (increases/decreases hunger etc).

#

You wouldn't need to create a tag for each item.

golden ermine
#

yea you are right that would be easier

vale mountain
#
    {
        this.grounded = Physics.CheckSphere(groundCheck.position, groundRadius, ground);

        this.Look();
    }

    private void Look()
    {
        float axis = Input.GetAxis("Mouse X") * this.sensitivity * Time.fixedDeltaTime * this.sensMultiplier;
        float single = Input.GetAxis("Mouse Y") * this.sensitivity * Time.fixedDeltaTime * this.sensMultiplier;

        Quaternion quaternion = this.cam.transform.localRotation;

        this.desiredX = quaternion.eulerAngles.y + axis;

        this.xRotation -= single;

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

        this.cam.localRotation = Quaternion.Euler(this.xRotation, this.desiredX, 0);
        transform.localRotation = Quaternion.Euler(0f, this.desiredX, 0f);
    }``` why is this choppy? its a first person camera rotation based on mouse thing
fossil drum
vale mountain
#

oh yeah

#

lmao

vale mountain
static bay
# golden ermine yea you are right that would be easier

Here's what I would suggest:

  • Give the player methods like "Eat" and "Drink" and "CollectWood". These methods take in a float and update those stats based on the value given. They can even update the UI here.
  • Create separate scripts for "HungerPickup", "ThirstPickup" and "WoodPickup" that check for collision against the player and call one of those methods. You can give those scripts a public float called "hungerValue"/"thirstValue"/"woodValue" so you can set the amount they give in the Inspector as opposed to needing conditions for all the different types of pickups.
vale mountain
#

actually its worse than before now

fossil drum
vale mountain
#

im just writing what i remember it being like

#

but i changed it to normal deltaTime then back to fixedDeltaTime and now its working so that was weird

static bay
# golden ermine thank youu

just for clarity, for Eating you could do this on the player class.

public float currentHunger;

public void Eat(float hungerValue)
{
    currentHunter += hungerValue;
    currentHunter = Mathf.Clamp(currentHunger, 0f, 100f);

    playerUI.hunger = currentHunger;
    eatSfx.Play();
}
#

Do this for Drink and Wood collecting as well.

#

and for the pickup you can just do

public float hungerValue;

public void OnTriggerEnter2D(Collider2D collision)
{
    PlayerMovement player = collision.GetComponent<PlayerMovement>();
    if(player != null)
    {
        player.Eat(hungerValue);
    }
}
stark bronze
#

how would one go about moving an object along a 2d line driven by a float? 0- bottom corner, 1 top corner

#

the line being a bezier curve

teal viper
#

It's not a just a "line" it's a curved line

#

You'd use bezier curves like you mentioned

static bay
teal viper
#

I think there's a package for working with bezier (and maybe other) curvres

solemn fractal
#

Hi Friends. I am using this code here to detect and make sure the enemies dont get too close together and overlap.. but if I stay in the same position they eventually overlap each other.. anyways to prevent that? thank you !!

#
        // Find all nearby enemies within the detection radius.
        Collider2D[] nearbyEnemies = Physics2D.OverlapCircleAll(transform.position, detectionRadius);
        
        foreach (Collider2D enemyCollider in nearbyEnemies)
        {
            if (enemyCollider.CompareTag("Enemy") && enemyCollider != this.gameObject)
            {
                // Calculate the direction to the nearby enemy.
                Vector2 direction = enemyCollider.transform.position - transform.position;
                
                // If they are too close, move away from the other enemy.
                if (direction.magnitude < avoidanceDistance)
                {
                    // Move away from the other enemy.
                    Vector2 avoidanceDirection = -direction.normalized;
                    transform.Translate(avoidanceDirection * Time.deltaTime);
                }
            }
        }
    }
teal viper
static bay
solemn fractal
#

they have it already but with is trigger on because if I shoot with my player

#

they die

#

and dessapear

fossil drum
#

Or just use an actual collider like I said in #💻┃unity-talk. But you could indeed fix this mathematically.

static bay
solemn fractal
#

oh i thought both had to have the trigger..

static bay
#

nah

#

I can't remember the specifics but at least one of them just needs a rigidbody for the trigger to go off

solemn fractal
#

yeah i unticked the is trigger to off and still works when i shoot them. BUT, they still overlap. Maybe I should increase the size of the collider? I mean its a collider they should not overlap it.

static bay
#

if you're moving them with transform.Translate they'll overlap

#

Translate is like a teleportation

solemn fractal
#

ohhh.. what other way to move them if not with translate?

static bay
#

if you want physics interactions you're going to need a rigidbody, and you'll be moving it with rigidbody.velocity or rigidbody.MovePosition or rigidbody.AddForce

solemn fractal
#

got it, thank you I will have a loot into this

fossil drum
#

Make sure you use the 2D version and not the 3D version, they are different.

solemn fractal
#

got it

#

will try here to change it to that instead of using the translate

#

rigidbody takes the form of the sprite?

static bay
#

no

solemn fractal
#

hmm ok.

static bay
#

well I'm not sure what you mean by "takes the form of"

solemn fractal
#

actually didnt make sense my question, nevermind 😄

#

ok as it is now its working but it is moving very slow.

#

How can I change the speed? I know it would be in the MoveDirection

#

variable, but I am not sure, maybe put at the end *2

#

or somethying like that?

fossil drum
#

You can just multiply the vector by some arbitrary number. Now you have a MoveDirection vector with length 1, multiplying it to something is fine.

solemn fractal
#

Tried like that Vector3 MoveDirection = _player.transform.position * 5 - transform.position * 5 ; or this Vector3 MoveDirection = (_player.transform.position - transform.position) * 5;

#

none worked, what Am I doing wrong?

slender nymph
#

you're multiplying before you normalize

gaunt ice
#

do you know what is normalize?

solemn fractal
#

I read it on documentation but still didnt understand it

#

fully to be honest

#

can I do it like that? rb.velocity = MoveDirection * 5 * Time.deltaTime;

#

or i dont need time.deltatime in rb ?

gaunt ice
#

it will set the magnitude of your vector to be one

slender nymph
#

don't multiply it by deltaTime

#

velocity is already expressed in units per second

solemn fractal
#

So delta time is more used to translate ?

#

ahh ok

#

working now. Thank you very much !

fossil drum
slender nymph
solemn fractal
#

got it

#

well actually i thought it was working like that but it is not yet

slender nymph
#

that should work just fine

solemn fractal
#

I am sorry my mistake i had it serialized fiel

#

and was trying to change it on code again

#

and not on the inspector

#

now works changing on inspector

#

Even tho now using rb.velocity they still overlap

#

not as much maybe

static bay
#

increase the size of the collider then

solemn fractal
#

but them when I shoot the anemy it will check the collision for the bullet way before it should

#

maybe do like Micro jackson said

#

use a child and put a collider on it to check for the bullet impact

#

would work right?

fossil drum
#

What I don't understand is why the 2 need to be a different size. They are circles, it should work fine with it being the same size.

solemn fractal
#

but the prob is that they are overlaping if I use the same size as the sprite

#

using translate or rb.velocity

#

both ways to move

fossil drum
#

Then that is the problem, colliders can not overlap and you need to figure out why it does that.

#

Is the collider still a trigger on the Enemy?

#

Do you still have Translation code somewhere for the Enemy?

solemn fractal
#

enemy the trigger is set to off

#

no i dont have any other translation code on the enemy anymore

fossil drum
#

You sure your not using the 3D collider?

solemn fractal
#

yes I am sure

#

so using a child with a bigger collider just to try and avoid that would fix as you said no?

fossil drum
#

Perhaps, I don't understand why it doesn't work now. Maybe you get the exact same problem you have.

solemn fractal
#

hmm ok i will review my code again shortly and let u know if I figured it out 😄

#

just finishing some work stuff

fossil drum
#

Good luck, going to nom some lunch UnityChanThumbsUp

solemn fractal
#

enjoy ur meal

#

well here at the end of this code snippet I still have translate to move away from each other.. could it be the prob? tried to change it to rb.velocity but didnt work its breaking and they are not moving even very far away from each other.

faint tulip
merry spade
#

I want to move the camera with my mouse ingame that my mouse keeps staying on the same object but the camera moves faster in the other direction why is this?

            if(Input.GetMouseButtonDown(2))
            {
                currX = 0;
                currY = 0;
                lastX = 0;
                lastY = 0;
            }

            if(Input.GetMouseButton(2))
            {
                print("Mousebutton");

                currX = Input.mousePosition.x;
                currY = Input.mousePosition.y;
                if (lastX == 0)
                {
                    lastX = currX;
                    lastY = currY;
                }
                if (currX - lastX  > 0)
                {
                    transform.Translate(Vector3.right * (currX - lastX) , Space.World);
                }
                else if (currX - lastX < 0)
                {
                    transform.Translate(Vector3.left * -(currX - lastX), Space.World);
                }
                if(currY - lastY > 0)
                {
                    transform.Translate(Vector3.forward * (currY - lastY), Space.World);
                    
                }
                else if(currY - lastY < 0)
                {
                    transform.Translate(Vector3.back * -(currY - lastY) , Space.World);
                }

                lastX = currX;
                lastY = currY;
            }
#

(its in an update loop)

solemn fractal
#

its not with my player

#

its overlap enemy with enemy

#

the prob

faint tulip
merry spade
merry spade
solemn fractal
#

ah sorry

eager elm
faint tulip
#

i wrote it down like this though

    float moveDistance = movementSpeed * Time.deltaTime;
    float playerRadius = 7f;
    float playerHeight = 2f;
    bool canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, movementDirection, moveDistance);
    //if statement to make it move
    if (canMove)
    {
        transform.position += movementDirection *  moveDistance;
    }
dusky finch
#

i have thos code to try and prevent things from going off the grid but it for some reason doesnt work but after going back in the grid and out on the other side then back then it works

#

i can take a video too if that helps, just need a recommendation on a program

eager elm
sudden tulip
#

anyone worked with configurable joints? I'm dealing with a problem when setting the target rotation. I got some code from ml-agent walker joint controller, though it seem the forces applied have no effect. Are there common mistakes when using them or should i share code? Thank you!

dusky finch
eager elm
#

show your code

reef patio
#

these errors keep popping up in the console and i can't run the game

dusky finch
reef patio
#

"An error occurred while resolving packages:
One or more packages could not be added to the local file system:
com.unity.settings-manager: EINVAL: invalid argument, futime

#

"Library\PackageCache\com.unity.testtools.codecoverage@1.2.4\Editor\CoveragePreferences.cs(31,19): error CS0246: The type or namespace name 'Settings' could not be found (are you missing a using directive or an assembly reference?)

"

#

does anyone know to fix it?

dusky finch
#

i dont have to put f behind the 1 do i?

reef patio
#

theirs a whole list when i just started as a junior programmer

hazy folio
#

are rigidbodies a good way of keeping tight platformer controls?

eager elm
dusky finch
#

I'll give it a try

delicate portal
#

Hey why is there no skybox in my game? The light is strange too, I'm using HDRP

slender nymph
#

this is a code channel

delicate portal
#

Ah sure

long lily
#

hi! has anyone built on a mac? I am stuggling to build on a mac

slender nymph
#

this is still a code channel.

long lily
north kiln
#

Then post them, we are not mind readers

long lily
long lily
teal viper
#

Seems like missing the C libraries/compiler.

#

Might be wrong though.😅

long lily
teal viper
long lily
teal viper
#

Then not sure. I'm not really a Mac person.

long lily
queen adder
#

Hello! I have to survey 20 people for an assignment about AI programming: https://forms.gle/MwwmmUMg16HitJTU9
It would be kind of you can fill in the form for me, thanks!

teal viper
#

I don't think there's the right place...

winged owl
#

Does anyone know how to make camera tilt when turning left or right?

swift crag
#

I presume you're building on a mac for macOS, but that also could be an x86 macbook or an ARM macbook

#

I see that it's complaining about the Burst compiler failing to run.

vale blade
#

I'm trying to auto-scroll my scroll view content to the bottom of the scroll view after I add a message to it, but I can't seem to get it working.

#

I tried referencing the ScrollRect and setting it's verticalNormalizedPosition to 0

#

I also tried setting the Scrollbar's value to 0

gaunt ice
#

is the content rect change its size?

long lily
swift crag
#

Does a Mono build work?

vale blade
# gaunt ice is the content rect change its size?

Oh it seems to work if I wrap it in a coroutine like so.

 public void PassPhrase(DialoguePhrase phrase)
{
    AddMessage(phrase);
    StartCoroutine(ScrollToBottom());
}

public IEnumerator ScrollToBottom()
{
    yield return null;
    ScrollView.verticalNormalizedPosition = 0;
}

So I guess I have to wait a frame first? That seems odd though, the Message GO is already instantiated by that point. Is there not a better work-around?

long lily
fossil drum
vale blade
vale blade
gaunt ice
#

i remember vertical layout group+content size filter need one frame to update itself, but i am not quite sure

verbal dome
gaunt ice
#

idk if this applied to all the ui elements

vale blade
fossil drum
#

Perhaps try in LateUpdate? If it updates everything in Update that should work is my guess.

vale blade
#

unless I start checking for content updates each frame but that seems even more wasteful haha

verbal dome
vale blade
slender nymph
#

!code

eternal falconBOT
sudden tulip
#

SetTargetRotation is the function used basically, i do se the values changing in the inspector though the joint doesn t seem to move. (I had values for spring and damper). Though, changing the target angular velocity works, but it is a hard method for an AI to control his limbs properly.

verbal dome
sudden tulip
verbal dome
#

Looks like your code is changing Slerp Drive but the joint is using X and YZ instead of slerp

#

I mean the Rotation Drive Mode

sudden tulip
#

so should i change it to slerp?

verbal dome
#

That's what your code seems to be using, yes

sudden tulip
#

nothing's changed

verbal dome
#

A lot of things could be wrong, configurablejoints are pretty complex

#

Start by posting your code correctly, see !code

eternal falconBOT
long lily
eager elm
sudden tulip
verbal dome
#

And obv make sure the rigidbody (or its connected body) is not kinematic

verbal dome
sudden tulip
long lily
sudden tulip
#

i do change the force and the target rotation each frame

verbal dome
#

Why is it still using X and YZ

sudden tulip
#

also with slerp it doesnt move

verbal dome
#

That wont work if your Angular X Drive and Angular YZ Drive have no zero spring

eager elm
sudden tulip
#

still nothing

#

strange i cannot assign a true 'Use acceleration' on the joint drive

harsh owl
#

im trying to tilt my mesh when steering left / right and when i stop steering it tilts to normal again

if(Input.GetKeyDown(KeyCode.D))
{
    current_Mesh_Rot = mesh.rotation.eulerAngles.x;
    
    if(current_Mesh_Rot < 15f)
    {
        current_Mesh_Rot += 0.125f;
    }
}
else
{
    if(current_Mesh_Rot  > 0)
    {
        current_Mesh_Rot -= 0.25f;
    }
}

somehow this does nothing

long lily
swift crag
swift crag
#

but I've definitely seen the mac mono option on my PC

dusky finch
#

so for some reason its off by a super low value

long lily
long lily
swift crag
#

IL2CPP can give better performance.

#

But Mono is still a lot better than no game :p

#

I'm not sure if you can build for both ARM and x86 from a PC. I haven't thought about that.

verbal dome
#

Like crank it up to 50 to see if it does anything

long lily
swift crag
#

i'm not sure how you "installed" the burst compiler

#

do you mean you installed the Burst package?

#

visual basic is definitely irrelevant here

#

I already had the XCode command line tools installed, so perhaps those are necessary for building games.

sudden tulip
#

now it works

#

thank you so much

long lily
swift crag
#

If Burst is not a dependency of a package you've installed, and you have no code that uses Burst, then there's no reason to install the package

swift crag
#

rather than as part of XCode

#

Some systems require these to be installed, so that they have a compiler to work with

verbal dome
swift crag
#

I am looking at the manual and don't see any mention of this

long lily
swift crag
#

You should not need to change any settings, no. It's Unity's job to translate your project into a working program.

swift crag
#

I set up this laptop a while ago

swift crag
# long lily

the first error seems odd -- the one warning that -macosx_version_min has been renamed to -macos_version_min

#

I would suggest making a brand-new project and seeing if you can build it

swift crag
long lily
sudden tulip
# verbal dome Awesome

also i looked now through some meta values. I tested with these values on my own setup and my character is totally disabling

swift crag
#

I have gone back and forth between Mac and PC in both directions several times

#

By default, there should be no reason for a project you created on one platform to fail to build on another platform

#

It is possible to add stuff that will fail on some platforms (e.g. if you start depending on native libraries)

solemn fractal
#

Hey guys.. is there a way to place that on update, and make it happen only 1 time? and never happen again?

finite star
solemn fractal
#

make sense ty

verbal dome
sudden tulip
#

they used very low masses, maybe 20 times smaller

#

that's strange

#

and joints mass scales are 1

verbal dome
#

And a position spring/maximum force in the tens of thousands? 🤔 Sounds a bit off but idk

sudden tulip
#

🤷‍♂️

verbal dome
#

Ragdolls take a ton of tweaking. My advice is to make a ScriptableObject that holds basic settings that you can adjust while playing for easy tweaking+debugging

solemn fractal
finite star
#

Do you mean that you need it to happen for an extended period of time and then turn off?

verbal dome
#

It helped me finally get the active ragdolls working decently

buoyant knot
#

that sounds correct

solemn fractal
#

i am trying to create a system for an infinity map but trying to invent one as I just find comples stuff in the internet

#

and that I dont understand

buoyant knot
#

you mean like minecraft?

solemn fractal
#

no

#

2d game like halls of torment

#

or vampire survivors

buoyant knot
#

what do you mean by infinity map?

sudden tulip
solemn fractal
#

check out on google or youtube the game vampire survivors or halls of torment

#

u can walk infinty to where ever

#

and the floor is there always

buoyant knot
#

i still don’t understand

solemn fractal
#

😦

buoyant knot
#

you mean the map is a toroid? so it’s one space that repeats if you walk into the edges?

solemn fractal
#

yes

#

exactly

verbal dome
buoyant knot
#

yeah, so that means you want a toroidal topology

#

so what is the issue?

long lily
buoyant knot
#

i think to make a toroidal space in 2D, you need to define teleporting at the edges

solemn fractal
# buoyant knot so what is the issue?

well I dont know how to do it.. i need that who ever the player walks.. Y or X it will have map or spawn a new one so I will always have somewhere to go infinitly

buoyant knot
#

i might even do something dumb, like making 8 copies in the map in the grid around

solemn fractal
#

and make it appear when u reach a part.. well its a way to do it but if I want to walk 2h non stop

buoyant knot
#

and if one of the copies fully enters the main area, teleport all the copies around to stay at the grid

#

what I’m saying is basically 9x the cost, but it would be simple and work

#

maybe just 4 copies for up/down/left/right. This way the screen wrapping works right

long lily
swift crag
#

Yes. Those might be architecture or OS specific

solemn fractal
subtle yacht
#

Hi, I have an issue on my game. I tried to change my player to a new GameObject. I added all the component he needed but when I setup this GameObject into my RoomManager to make him spawn, it can move but it flies and I don't know how to affect gravity correctly. I'm using PhotonNetwork idk if it's important but I use it

long lily
verbal dome
#

Gravity should be on by default in a rigidbody

#

And how are you moving the player, show code

#

It's possible that your ground check is also hitting the player's collider. Make sure you configure its layermask properly

long lily
subtle yacht
verbal dome
#

I don't see you flying upwards here

#

Just not falling

#

First check that your grounded bool is what it should be

summer stump
subtle yacht
#

It's because the spawnpoint is already upwards and there is a invisible roof.
But if i spawn on the ground i'm flying to the ceiling

verbal dome
#

Maybe that is triggering your ground check

subtle yacht
#

I'll sent you another video from my last GameObject and it works perfectly

verbal dome
#

Why not just answer my clarifying questions

#

Debug.Log or otherwise check that your grounded bool is false when you are in the air

#

If it is true, then you know that the problem is with the ground check

subtle yacht
#

Sorry but idk how to verify this

verbal dome
#

Debug.Log("Grounded: " + grounded)

#

That's how you print a value

#

Or add [SerializeField] to grounded so it shows in the inspector

subtle yacht
#
    private void OnTriggerStay(Collider other)
    {
        Debug.Log("Grounded: " + grounded);
        grounded = true;
    }```
verbal dome
#

Do it in the start of FixedUpdate

subtle yacht
#

okk

subtle yacht
verbal dome
#

People will help you here in this channel if they can

subtle yacht
#

oh ok sorry

silk night
#

How expensive is the NavMeshAgent.SetDestination function? Assuming i have 100 enemies that follow the player, do i want them to update that once a frame or should I stagger it? Was thinking about not updating it till the player has moved a certain distance

rich adder
#

is that only components you have ?

verbal dome
#

Very similiar looking issue to Julien's issue above. Might be for different reasons tho

#

Make sure you aren't colliding with your sword's collider

rich adder
#

root motion on animator might have somethin to do with it?

verbal dome
#

Yeah could be

rich adder
#

try it with it unchecked?

swift crag
#

I had an issue where an enemy couldn't move at all if there was not a path all the way to the player

#

It looks like it was taking more than one frame to calculate the path in this situation

#

but since I kept demanding that it calculate a new path, it never finished...

rich adder
#

it work or no?

eternal needle
rich adder
#

you tried without player movement

#

find out whats causing it first

#

not much to go on from wat I see lol

subtle yacht
#

I fix my problem, it was the animator

#

I removed the Animator and the GameObject stopped flying

#

try to create a new animator

dry tendon
#

is there any component i can add to the game object to be able to change its alfa on an animation to make a fade out? Just like canvasGroup for canvas

rich adder
dry tendon
#

So, is there any way to change alfa to this both parent children sprites?

#

And if its possible in just one animation...

#

like what i'm doing with this canavs...

#

But with a sprite

rich adder
buoyant knot
#

I would maybe even try GetComponentsInChildren<SpriteRenderer>() or <Image> or whatever

swift crag
#

this is an animation, so it's more restrictive

buoyant knot
#

but you won’t be able to do this easily without code, i think

#

he used a spriterenderer

swift crag
#

I'd just make your own CanvasGroup-y component

#

Make a component that holds a list of sprite renderers

rich adder
#

you should be able to add both alphas in one animation i think

swift crag
#

It sets their alpha every frame

buoyant knot
#

spriterenderer has a .color set property you can work with to set alpha

swift crag
#

Now you can just animate the...SpriteGroup, I guess

dry tendon
buoyant knot
#

either way, you will want some simple code for this. I do this all the time for debugging, and it takes like 1-2 lines at a time

rich adder
#

doing it with code is better

buoyant knot
#

if you change SpriteRenderer’s .color, it will change for the animation too

buoyant knot
#

that makes it super simple

#

in debugging, I normally add a line in debugging to see a bool:
if (TryGetComponent(out SpriteRenderer s)) s.color = myBool ? Color.white : color.red;

#

toss that in an update loop, and it becomes super easy to see what things have certain bools active

#

in your case, GetComponentsInChildren<SpriteRenderer>() in Awake()/Start(), then set them as needed

green copper
#

is fixedUpdate an appropriate place to call movement force functions, or it force * time.deltatime superior in some way?

rich adder
#

impulses are fine not in fixedupdate tho

green copper
#

thanks

#

so many old books and tutorials say update() and time.deltaTime and it seemed odd

rich adder
#

for rigidbody ?

#

its wrong then

vale blade
#

so I tend to just always use time.deltaTime

green copper
#

What's fixedDeltaTime?

rich adder
#

you should not use time.deltaTime on rigidbody at all

vale blade
eternal needle
#

time.deltaTime is fixedDeltaTime in fixedupdate

rich adder
vale blade
#

hence just use time.deltatime everywhere so you don't accidentally start using fixeddeltatime outside of fixedupdate.

verbal dome
vale blade
verbal dome
#

Im saying you shouldnt use delta time here at all

vale blade
#

I'm not saying use it in ForceMode.Force, just generally when you reference a deltaTime somewhere, there's really no need to use fixedDeltaTime anywhere, as anything that involves the fixed delta time should be done in FixedUpdate anyway.

verbal dome
#

I see your point, it's a style choice

vale blade
#

At least, I haven't ever ran into a situation where I needed access to fixedDeltaTime outside FixedUpdate. I have however accidentally used fixedDeltaTime in Update in the past, so why bother with the possibility of making that mistake in the future :p

green copper
#

So, just to clarify, because there is some debate apparently;

Will this work without any wierd framerate based problems on the slow school computers I need to present this project on?

#

because I know if I put this block in Update it would act wierd without integrating time.DeltaTime

verbal dome
#

Again, AddForce multiplies the value with fixedDeltaTime by default, so you shouldnt use it with forces

vale blade
green copper
#

Thank you

rich adder
# green copper Thank you

also is your IDE configured or is just the theme like that, your methods should be yellow default ?

green copper
#

This is all default theming, I'm pretty sure

#

never configured it since it worked for me

rich adder
#

do you see suggestions . you don't get intellisense ?

green copper
#

yeah, the auto suggestions and stuff works fine with all the unity functions

rich adder
#

huh thats weird..

vale blade
#

try

#

!ide

eternal falconBOT
green copper
#

it is visual studio 2017, if that matters

green copper
#

it's the version I had installed for a c++ course a couple years ago and never needed to change

rich adder
#

you should upgrade to 2022

green copper
#

huh yeah that is a few more suggestions

rich adder
#

its wayyyy better

green copper
#

what's different?

rich adder
#

faster. it has intellicode

#

64 bit app

#

many other stuff

green copper
#

what's intellicode?

green copper
#

that sounds like corpo speak for ChatGPT integration

rich adder
#

nah gpt is garbage in comparison

#

its just AI that works off your own code, probably a little help from github pilot

polar acorn
#

The difference is whether it's trained on the entire internet or on specifically your own codebase

#

Still no replacement for actually knowing what you're doing

#

but at least if there's any mistakes in it they're your own mistakes in the first place

rich adder
#

yup. just makes some things a bit easier to TAB

green copper
#

so I can do stuff like ask questions like "What's the syntax for player input" because I always forget because I need to do it exactly once per project?

rich adder
#

nahh its not a prompt tool

green copper
#

okay, that's good

rich adder
#

you staart typing certain logic it almost finishes the method for you

#

well suggests it

#

its just convenience nothing intrusive

polar acorn
green copper
#

Okay that's actually really helpful

#

sold

rich adder
#

VS gang

polar acorn
#

It's important to note: We don't have an irrational hatred of AI coding, it's just that ChatGPT is specifically bad at code because it's meant to be a language model. It speaks, it doesn't code. Purpose-built AI code assistance is perfectly viable

green copper
#

oh, definitely

#

I occasionally use it, just because sometimes the question is "what's the name of this method" and it's faster than wading through tutorials amd/or bothering someone here, and it's usually right

#

but I'd never trust it with anything important I couldn't verify in less than two minutes

rich adder
#

I just ask it menial tasks like a secretary

#

never code tho

#

"Give me a list of 50 names, comma separated"

#

bam

vale blade
#

i like having it autofill methods for me

rich adder
#

interesting, what does Rider use for intellicode?

vale blade
#

this is copilot

green copper
#

what's the horizontal equivalent of transform.up?

rich adder
#

transform.right?

green copper
#

I was right I just capitalized it

#

ugh

#

thx

solemn fractal
#

Hey guys, if I want to get access to something in a child like the ExperienceGet here how do I do it?

#

_player.child.transform.position? something like that?

vale blade
#

transform.GetChild()

#

goes by index

verbal dome
solemn fractal
#

and if I have a collider in the child.. and I want to do a check for the collider of the child?

vale blade
#

transform.Find() goes by name

#

or do what osmal said

verbal dome
vale blade
#

or just use GetComponentInChildren<T>() on the parent if there's only one type of collider as a child.

unreal phoenix
verbal dome
#

transform is the parent

vale blade
#

so if there's a BoxCollider on ExperienceGet just do transform.GetComponentInChildren<BoxCollider>() on the Player transform

solemn fractal
vale blade
verbal dome
solemn fractal
verbal dome
solemn fractal
#

What I need is something like.. if something gets into the child colission area, do something.

vale blade
#

well, are we speaking of a trigger or a collider? if there's just one collider on the object altogether, just use OnTriggerEnter or OnCollisionEnter

#

if there's a child component with a collider the collision events gets passed to the parent.

solemn fractal
#

I mean a colider set with IsTrigger on.. So when something enter inside the collider of the child.. something happen

vale blade
#

so if your hierarchy looks like

player (no colliders)
  - collider (box collider set to trigger)

then you can just use OnTriggerEnter on the player

solemn fractal
#

i have a collider also on the player .. but the collider on the player is for other stuff and the collider in the child will be to attrac or collect EXP but that area of experience collection needs to be way bigger than the player area that is why i created a child to contrl that

jade elk
#

is there a channel to request services?

rich adder
eternal falconBOT
vale blade
jade elk
#

I don’t believe that is seen often, is there a more widely seen place to post listings? perhaps Reddit?

vale blade
#

if the player has a trigger too, then you can comparetag

jade elk
#

or another discord server?

solemn fractal
# vale blade if the player has a collider, and the child has a trigger, then that would still...

Sorry, i am confused. So, the player has a collider. This collider is to check if an enemy hit the player be it with something or just touching the player. and the child has another collider with a way bigger area that will check if it collides with experience on the floor far from the player to fetch it. So What I need is to say on trigger enter from the child do something and not from the player.

#

So imagine I want a on trigger enter to do something for the player and one for the child. both with dif logic.. that is what I need but trying to search here still cant find an answer 😛

verbal dome
unreal phoenix
solemn fractal
#

that is what Chatgpt told me

verbal dome
#

Or you mean you need to detect if the parent or the child trigger was hit?

verbal dome
polar acorn
unreal phoenix
#

no

verbal dome
#

AFAIK theres no way to detect which trigger collider in the receiving object was hit

#

So you would need a separate object instead of a child

unreal phoenix
#

That's why you need to scripts or a way to sub to them individually

solemn fractal
unreal phoenix
#

I think that they already have a child GO in the player

solemn fractal
#

when the child collider touches the exp i need to get it

verbal dome
#

Are you reading my answers?

#

Put the second collider on a separate object, not a child

solemn fractal
#

Sure I am

#

ohhhh

unreal phoenix
verbal dome
#

Otherwise you have no way of distinguishing between them

vale blade
#

@solemn fractal

private void OnCollisionEnter(Collision other)
{
    Debug.Log(transform.name + " collided with " + other.transform.name);
}

private void OnTriggerEnter(Collider other)
{
    Debug.Log(other.transform.name + " entered trigger of " + transform.name);
}
solemn fractal
#

but if its another object and not a child.. how can I make both have the same position always? I will need to put iton the update method to check that all the time?

verbal dome
#

Or maybe put them both under an empty parent and move that parent instead 🤔

#

Both are valid options

solemn fractal
#

hahaha damn, i thought that would be easier.. but well thank you

unreal phoenix
#

Why not just have the second collider be on a child game object to the player?

vale blade
verbal dome
#

The player has a rigidbody right?

unreal phoenix
#

I don't think a child GO with a collider sends any events to the parent

#

RB or not

verbal dome
#

It does though.

unreal phoenix
#

Well then

verbal dome
#

The object with the rb will receive the events, thats it

polar acorn
#

Why not just have the OnTriggerEnter event be on the XP, then it can very easily use GetComponentInParent to get the player object and call a function on it

#

Don't put the OnTriggerEnter on the player, put it on the thing you collide with

#

If the XP hits a trigger that isn't that one, the GetComponentInParent will fail and you can just not do anything with it

vale blade
# verbal dome Because the OnCollision/OnTrigger event will be sent to the object that has the ...

I wrote a workaround for that here, but I think @solemn fractal will be good with the setup I showed in my gif.
https://stackoverflow.com/questions/69741488/how-to-know-which-collider-triggered-the-call-to-ontriggerenter-in-unity-on-a-g

solemn fractal
unreal phoenix
#

That's probably best. write an XP script to add it's value to what it collides with

verbal dome
#

Which is what I did when I needed a proximity trigger collider around my player that has a rigidbody

vale blade
#

yeah fair that solution was mostly because i needed a lot of different child colliders which all indicated different parts of a boss

verbal dome
#

Dont get me wrong - your solution could be handy in some situations

vale blade
#

the hierarchy is also a bit better but I would suggest Pedro to just stick with a simpler soluton like putting both a trigger and a collider on the same object

verbal dome