#💻┃code-beginner

1 messages · Page 167 of 1

rocky canyon
#

interesting... maybe it hides it from other scripts? i have no idea

#
using UnityEngine;

public class WaveManager : MonoBehaviour
{
    private static int numberOfWaves = 0;
    public GameObject zombiePrefab;

    void Start() => SpawnZombie();

    void SpawnZombie()
    {
        Instantiate(zombiePrefab, transform.position, Quaternion.identity);
        numberOfWaves++;
        Debug.Log("Wave " + numberOfWaves + " spawned!");
    }
}``` @grizzled pagoda
#

yea, i think i'd use a master script that u can count the waves on..

#

but events could be cool too.. u would subscribe to an event like (when u spawn a wave or w/e)
then anything subscribed (listeners) will fire off their respective functions when it happens..
this could do things like count.. or add to a number for example..

#

even when its not in the same class..

eternal needle
#

thats odd, i cant replicate the bug. That should be a compile error anyways so it should light up in the IDE. Maybe it is using a different Sound type

potent garnet
#

yea that's what i thought at first

#

that there was some ambigious reference when i used the name Sound

rocky canyon
#
 // UnityEvent to signal when a zombie is spawned
 public UnityEvent onZombieSpawned = new UnityEvent();

  void SpawnZombie()
    {
        Instantiate(zombiePrefab, transform.position, Quaternion.identity);

        onZombieSpawned.Invoke(); // invoke the event
    }```
```cs
using UnityEngine;
public class WaveCounter : MonoBehaviour
{
    private int waveCount = 0;
    public WaveManager waveManager;

    void OnEnable() => waveManager.onZombieSpawned.AddListener(IncrementWaveCount);

    void OnDisable() => waveManager.onZombieSpawned.RemoveListener(IncrementWaveCount);

    void IncrementWaveCount() => waveCount++;
}```
#

heres a boilerplate example of how using a unity event would work.. (altho im not super familiar with unity events just yet)

rich adder
#

Also zombie should just have event OnDied , that spawner subs to

rocky canyon
calm coral
#

I swear I have no f idea why, but it seems assembly definitions are to blame. I've had 2 folders with scripts and 2 assembly definitions, one pointing to another one, and suddenly when I deleted both assembly definitions everything started working when I build the game @wintry quarry@rare basin no errors, no exceptions, my Card class spawns properly, everything works fine after I build the game and it's all because of assembly definitions pepesadcat if I've had misconfigured assembly definitions then why did they work in play mode before building the game out?

#

I have no idea but this is what it is...

#

And definitely there was no issue with #if UNITY_EDITOR or my custom Auxiliary.cs class

wheat geyser
#

this

#

I don't usually do this, I actually just have a bunch of audio sources for each sound effect

#

don't like it but it's how it is

rocky canyon
#

that works, i usually use 1 source for each type of sound.. 1 source for all the gun sounds, 1 source for all the button clicks, etc

#

PlayOneShot() can play like 3 clips at a time or something

wheat geyser
#

ooh that's good

#

yeah that's a good way of doing it

rocky canyon
#

👍 keeps it pretty simple to debug and keep track of everything

wheat geyser
#

unity needs a better sound system honestly because it's not very intuitive

rocky canyon
#

eh, once u use it for a while it gets pretty intuitive

#

its when you introduce a mixer and multiple sources it does get a bit complicated

#

ohh and the way the spatial audio works.. (3d audio) getting the settings correct for the audio to fade when u walk away from it..

#

that bit took me a while to get going the way i wanted

wheat geyser
#

fw the mixers leave those alone

#

but the line setting up idk

#

I like fine tuning my sounds perfectly

#

so that does require having sources for each sound effect

#

i might try and make a sound engine and see how that goes

grizzled pagoda
calm coral
limpid warren
silk night
#

on all animations that should be interruptible by other animations

#

otherwise the animation can ONLY be exited at the set exit time

cosmic dagger
#

I copied the scripts and didn't have an error. I think they didn't save after adding the source line . . .

rocky canyon
limpid warren
cosmic dagger
#

One of them didn't have the source field . . .

rocky canyon
#

ahh yea makes sense.. ghost code

cosmic dagger
# wheat geyser this

I use SOs for sounds or an array of sounds an object will use, but I have a list of audio sources for each type of sound, similar to SpawnCampGames. It's much easier to use with an audio mixer (they're awesome when setup correctly) . . .

rocky canyon
#

how do u tune ur audio? @cosmic dagger ?

#

like do u keep the audiosources at 1 volume

#

and tune it down in the mixer?

#

thats the only problem i seem to have.. like where to start my audiosources volumes

cosmic dagger
#

Yep. All the audio sources at 1 by default . . .

wheat geyser
cosmic dagger
# rocky canyon thats the only problem i seem to have.. like where to start my audiosources volu...

@wheat geyser
So, e.g., I have an SFX audio source attached to the SFX mixer. Within that mixer are multiple audio mixer groups for different types of sounds: projectiles, footsteps, ambient, etc.

I set the volume for these groups in the audio mixer. So footsteps will be lower than projectiles, but the actual SFX mixer will come through at normal volume

This allows the user to still control the volume for music, SFX, dialogue, UI, etc., from the menu . . .

rocky canyon
#

thanks for the insight

minor spindle
rocky canyon
#

lol no flex, its more procrastination

minor spindle
#

the menu looks real sexy though

rocky canyon
#

thanks if u got any questions about it i'd be free to answer

#

but its basically a parallax mouse script and JSON save system in the backend

minor spindle
minor spindle
timber tide
#

it's not a fun rabbit hole

cosmic dagger
rocky canyon
#

back returns them to their original values.

#

(it saves to a json) so all i got to do is load up that data WHEN i get my mixers implemented

#

so far its just saving to the JSON.. I can view it, but theres no audio manipulation yet

rocky canyon
#

so i actually have 2 systems at work.. one is realtime, and monitors the sliders (updating the values as i slide)
and the other system stores teh data when i click the save button.. and will revert back to the original values if u dont save

#

gosh, its so messy

minor spindle
rocky canyon
#

i like showing off the pretty stuff..

minor spindle
#

My room can be in complete disarray and i'll be fine with it but please don't look at my code hahah

minor spindle
rocky canyon
#

but i hide behind most of my code. b/c even tho i understand it, its always messy and theres better ways

#

when i show the actual backend stuff

minor spindle
#

also I was stalking your itch.io and just had to point out you left this guy on read for 288 days kekwait

rocky canyon
#

lol, wasnt important to him or he woulda bugged me about it 😄

minor spindle
#

🤣 🤣

rocky canyon
#

plus i dont usually give out freebies for my projects to strangers

#

i worked hard on that.. (i would imagine) lol

minor spindle
#

especially not to people called Isaac_baguette

minor spindle
rocky canyon
#

i gotta get some more stuff on itch.. thanks for reminding me

rocky canyon
minor spindle
#

thats what i'm here for lmao 🤣

rocky canyon
#

didnt wanna get sued, for distributing it

minor spindle
#

Ahhh hahaah makes sense lmao, >inb4 adultswims lawsuit

#

should've called it the "Smif House, completely unrelated to the Smith House"

rocky canyon
#

fun fact on that, the inside of the house (on the show) doesnt match the outside of the house

#

thats why i quit on that project

cosmic dagger
rocky canyon
#

its one of those impossible spaces.. id have to do some closed doors (swap the environment out) kinda deals

rocky canyon
#

i just needed teh realtime stuff so the slider values would update while u drag the handles around

#

all the runtime stuff

#

but this is all there is to the actual save

cosmic dagger
rocky canyon
#

its probably my biggest time-sink

minor spindle
rocky canyon
#

🤣 probably my favorite (system) ive written

#

string TextField ftw

cosmic dagger
#

I'm trying to learn UI Toolkit. It's nice making custom editors and drawers, but I need to understand the code part

I'm trying to display the correct class based on the value of a field, but the class is either the base Stat or the derived Resource

I'm using SerializeReference for the first time, but I'm not sure if I create a new instance or specifically draw the correct property drawer . . .

shell sorrel
#

got to do it all manually

rocky canyon
#

i tried using that yesterday with a custom inspector type that.. that was supposed to show me a list of interfaces i was using

shell sorrel
#

make your own UI for it, and isntance objects manually

rocky canyon
#

but i couldnt get it to work correctly

cosmic dagger
#

I don't do crazy stuff either. I mainly just group fields or sliders and stuff together. I might create a tab for different fields to look at . . .

shell sorrel
#

i was using it to repersent nodes in a behaviour graph for a while, but ended up dropping it since it was ultra fragile to refactors

rocky canyon
#

and thats actually why i use the text field.. to print out the selected interfaces i have in my list

#

as i know no other way to expose it in the inspector

#
  public List<ISelect> selected = new List<ISelect>();```
#
  if(Physics.Raycast(ray,out hit,distanceOfRay))
        {
            focusedTransform = hit.transform; // not needed here (this is realtime raycast transform)

            if(hit.collider.TryGetComponent(out ISelect selectable))
            {
                scrollLock = true; // enable the scrollLock flag
                hold = true; // enable the hold flag
                drag = true; // enable the drag flag

                lastSelectable = selectable; // cache our selectable
                storedTransform = hit.transform; // cache our selectable's transform

                initialMousePosition = Input.mousePosition; // Store the initial mouse position when the drag starts
            }
            else
            {
                Instantiate(groundSelectPrefab,hit.point,Quaternion.identity);
                Debug.Log("We clicked something unselectable");
                lastSelectable = null;
            }
        }```
cosmic dagger
shell sorrel
#

yeah ended up repersenting my nodes with SO's instead and just using a abstract type

cosmic dagger
shell sorrel
#

them having guids for the types made them less fragile to stuff like renaming a type

cosmic dagger
shell sorrel
#

otherwise they worked fine, once i made UI and code for creating them

#

and i could clearly see in the yaml, they were stored in 1 blob at the end that included type information, then referenced elsewhere

rocky canyon
#

lol, im also wishywashy, i abuse the F2 button

shell sorrel
#

pretty sure if i bothered matt ellis rider would get support for refactoring them

cosmic dagger
#

Man, I keep forgetting to start using Rider. . .

minor spindle
#

Can yall point me in a direction to increase the visual aspects of my game?

north kiln
minor spindle
#

Apologies

#

No

rich adder
north kiln
#

The question is vague as hell

minor spindle
#

Yeah I get that but it's cause I have no idea what to ask, thats kinda the problem 😭

#

I dont know if I need shaders, lighting, post processing, or a combination of all lmao

north kiln
#

Figure out what you want to emulate and ask about that

paper rover
#

General question, does OnBecameVisible / OnBecameInvisible cause GC Alloc?

north kiln
#

If you're concerned about allocations, use the profiler

minor spindle
paper rover
#

after profiling, it seems like the function is causing alloc, must be something in the function then

cosmic dagger
north kiln
#

by default SerializeReference draws nothing if the value is null

#

If you assign a value, it will draw the property

cosmic dagger
north kiln
#

Unless you assigned it a value, it's null

shell sorrel
#

no

north kiln
#

it's serialized by reference

shell sorrel
#

null since its truely points to data elsewhere unlike serilziefield

#

you can have many things pointing to the exact same data with it

north kiln
#

...when it's not buggin' out

shell sorrel
#

yeah mentioned it breaks very easily, expecially to things like type name refactors

north kiln
#

You definitely have to learn the additional attribute: MovedFromAttribute

#

and use global find and replace a bunch

shell sorrel
#

yeah because it references regular types and not just components and so's

#

it has no guid to track for the types

north kiln
#

It's annoying that there's no attribute for renaming the type, just the field or the namespace/assembly

cosmic dagger
#

Okay, thanks. I'll test and, hopefully, figure this out when I get on the computer—I never used SerializeReference . . .

cosmic dagger
minor spindle
#

I'm having some trouble, with checking whether or not the goblin is airborne by using raycast

#

For some reason they get stuck though.. I'm guessing maybe the ray is being cast under the map?

minor spindle
rich adder
minor spindle
#

oVER HERE RIGHT,

#

oops caps

#

Yeah just did that

#

still same issue though

rich adder
#

what

#

I wanted to see pivot, this changes nothing in the game

minor spindle
#

I'm sorry I'm having difficulties understanding 😅

#

ah okay

#

U want to see where the pivot point is?

rich adder
#

so you're saying the Raycast is returning false then?

minor spindle
minor spindle
#

            bool isAirborne = !Physics.Raycast(transform.position, Vector3.down, 1f);

            if (isAirborne)
            {
                Animate(AnimationType.InAir);
            }

Despite my character being on the floor the code inside the if statement is being triggered

#

My guess is that the pivot point is under the map? since the floor is just a plane

rich adder
minor spindle
#

Okidoki, one moment

rich adder
minor spindle
eternal needle
#

doesnt this indicate that its working then? there is no collider because you did not hit anything

minor spindle
rich adder
#

what the floor collider look like

#

mesh collider?

#

maybe the ray is inside

eternal needle
#

use debug.drawray to visualize your raycasts. might just be that your raycast is starting inside the floor thus not hitting it

minor spindle
eternal needle
#

i start my raycast a little higher up, then just raycast that distance further

minor spindle
#

let me try one sec

rich adder
minor spindle
#

green gizmos are barely visible

#

too thin?

rich adder
#

should try printing the visual ray, but also I would try starting the character higher up in the beginning of the game

rich adder
#

that might def be starting inside

minor spindle
#

I could also just duplicate the floor

#

and put one underneath it

#

if it work it works type shi

rich adder
eternal needle
#

you could easily just test this by moving the goblin up and see if it works. takes 5 seconds

minor spindle
rich adder
#
 Debug.DrawRay(transform.position, Vector3.down * 1, Color.red, 1);
        if (hit.collider == null) return;
        Debug.Log(hit.collider);```
minor spindle
rich adder
#

the log should not be in if statement

eternal needle
#

also, duplicating the floor is probably one of the most random "solutions" ive heard. Just move the goblin, or move the start of the ray up

minor spindle
minor spindle
grizzled pagoda
#

hi idk why but i can drag my script in but it wont let me select the function inside the script

eternal needle
grizzled pagoda
#

oh

eternal needle
minor spindle
#

Thanks 🙏🏼

eternal needle
grizzled pagoda
#

for some reason even though this image is above the button in the hierarchy its not showing above it

north kiln
minor spindle
grizzled pagoda
minor spindle
#

I'm a novice but dont coroutine's usually use IEnumerator?

potent nymph
#

I have the following code here online which sets a timer which works fine

        time -= Time.deltaTime;
        int minutes = Mathf.FloorToInt(time / 60);
        int seconds = Mathf.FloorToInt(time - minutes * 60);

        text.text = string.Format("{0:0}:{1:00}", minutes, seconds);

However, I'd like to include milliseconds, but I can't figure out how sting.Format works

rich adder
#

why not just use TimeSpan?

potent nymph
#

I didn't know that's a thing

#

is that a unity thing?

rich adder
rich adder
# potent nymph I didn't know that's a thing
private TimeSpan timerDuration = TimeSpan.FromSeconds(5);
    private TimeSpan currentTime;
    private void Awake() => currentTime = timerDuration;
    void Update()
    {
        if (currentTime.TotalSeconds > 0)
        {
            currentTime -= TimeSpan.FromSeconds(Time.deltaTime);
            string timerText = string.Format($"{currentTime.Minutes:D2}:{currentTime.Seconds:D2}.{currentTime.Milliseconds:D3}");
            Debug.Log("Time remaining: " + timerText);
        }
        else
        {
            Debug.Log("Timer has reached zero!");
        }
    }```
https://learn.microsoft.com/en-us/dotnet/api/system.timespan?view=net-8.0
potent nymph
#

I was able to get a little bit working actually

#
        time -= Time.deltaTime;
        TimeSpan t = TimeSpan.FromSeconds(time);

        text.text = string.Format("{0:0}:{1:00}:{2:00}", t.Minutes, t.Seconds, t.Milliseconds);
#

but I still don't know how string.Format works and am just doing random things (like idk what D2 or D3 means)

#

also, milliseconds shows up in 3 digits, when I only want it to be formatted as 0:00:00

rich adder
#

put D2 then 🙂

potent nymph
#

that didn't work either

#

well I wrote it like this, I don't know if I did it right

text.text = string.Format("{0:0}:{1:00}:{2:D2}", t.Minutes, t.Seconds, t.Milliseconds);
rich adder
#

$"{t.Minutes:D2}:{t.Seconds:D2}.{t.Milliseconds/10:D2}");

potent nymph
north kiln
rich adder
#

true 😅 late night oversight

true pasture
#

how do I use screenpointtoray with a different cursor size. Like I want to increase the size of the raycast from the camera.

north kiln
#

screenpointtoray has nothing to do with interacting with the scene, it returns a ray, you choose what to do with it.
Use a SphereCast, or multiple raycasts

true pasture
#

well i want to cast what im clicking on just with a larger circle cast

rich adder
#

then use the mentioned methods, rays are lines they dont have width just length

true pasture
#

no i understand those methods

#

I dont understand how I can cast them without screentoworldpoint

north kiln
#

There is nothing wrong with ScreenPointToRay

true pasture
#

should i just do a sphere cast on my cursor with 100000000 depth (like this isnt making sense)

rich adder
#

they have direction ray same as raycast

north kiln
#

No? Just use a spherecast with the radius you care about

true pasture
#

spherecast where?

north kiln
#

down the ray you are getting?

true pasture
#

oh do you mean the spot where screentoworld point hits?

rich adder
#

Youre still using ScreenPointToRay

true pasture
#

yeah thats what i mean

rich adder
#

it returns a ray and you pass it to spherecast

true pasture
#

okay ill try that thanks both

grizzled pagoda
#

the zombie floats after colliding with my wallnut

rocky canyon
#

well u never click the zombie.. but im guessing they're set up similar to the player.. does it have a rigidbody?

#

does the rigidbody also not have gravity?

grizzled pagoda
#

yep they both dont have gravity

rocky canyon
#

thats why it float away.

grizzled pagoda
rich adder
#

and Y position is not locked

rocky canyon
#

ya just do that ☝️

cobalt creek
#

how would i capture event when person clicks the dropdown button to expand dropdown? there is drop down onValueChanged but that is for when you click an option different from the previous one

teal viper
sonic dome
#

guys ik this is not the channel to ask this but can anyone tell me if there is an alternative to #⛰️┃terrain-3d cuz i never get help there

prisma silo
#

how can i go about rotating a 3d gameobject towards the mouse position. I have done this in 2d but cant seem to find a way to make it in 3d

cobalt creek
teal viper
prisma silo
#

to "look at" the mouse position

sonic dome
cobalt creek
teal viper
#

Or the button uses a different overlapping image.

prisma silo
queen adder
#

Hey all.
So in my unity project i want to spawn an object at a random position. The player must then click on that object to collect their reward.

My issue is now, i can get an object to randomly spawn but i cant get it to click.
I have made it a button but it still wont click.

How can i make this object clickable?
I have tried googling but they only showing me how to make an object spawn on mouse click. I dont want that. I want the object to spawn which i have done, then i want the player to click on that object which will then pop up a panel with the reward they have received.

And help would be greatly appreciated.

teal viper
queen adder
teal viper
#

That doesn't answer any single one of my questions....

prisma silo
eternal needle
prisma silo
#

lol im so dumb

teal viper
queen adder
teal viper
#

What component renders it?

#

Because there's an Image component and a SpriteRenderer component.

sonic dome
#

show me the code

queen adder
# teal viper Image? Or Sprite?

Well i drew this 💩 in paint.
Then i added it to my assets.
Then there are 3 ways i can add it. I can drag that image i made into my hierarchy and it shows up on my screen, i then resize it and make it a prefab. My pet then poops it out every few minutes. But still cant click on it even if i add a button component.
I also tried making a image by creating UI -> image. But also cant click it when it spawns.
I tried making a button by UI -> button. But it also wont click when spawned

#

Im not sure whats going on.
How would i go about spawning an object with a button on it instead of a ui element?

sonic dome
#

make another float variable

prisma silo
# sonic dome show me the code
public GameObject body;
float mouseX = Input.GetAxisRaw("Mouse X") * mouseSens;
float mouseY = Input.GetAxisRaw("Mouse Y");
mouseY += mouseX;
body.transform.rotation = Quaternion.Euler(0, mouseY, 0)
sonic dome
#

and do it in that

#

private float rotation

rotation += mouseX;

prisma silo
#

alright

sonic dome
#

body.transform.rotation = Quaternion.Euler(0, rotation, 0)

#

last line

prisma silo
#

ok

prisma silo
sonic dome
#

yes

teal viper
#

It is possible to make it work both with a ui Image component and a non ui SpriteRender component, so you need to decide which one suits you better.

sonic dome
#

almost there

#

let me cook

#

can u show me the complete code?

prisma silo
#

sure

#
public Rigidbody rb;
public float moveSpeed = 10f;

Vector3 PlayerMovementInput;
public GameObject body;
private float rotation;

public float mouseSens;
void Update()
{
    PlayerMovementInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));

    float mouseX = Input.GetAxisRaw("Mouse X") * mouseSens;
    float mouseY = Input.GetAxisRaw("Mouse Y");

    rotation += mouseX;

    body.transform.rotation = Quaternion.Euler(0, rotation, 0);
}

private void FixedUpdate()
{
    Vector3 MoveVector = transform.TransformDirection(PlayerMovementInput) * moveSpeed;
    rb.velocity = new Vector3(MoveVector.x, rb.velocity.y, MoveVector.z);
}

#

working on an isometric game

sonic dome
#

i think the approach is wrong we r rotating it with mouse input i think we need to make it so that it looks towards the mouse

#

let me see

#
public GameObject player;
void Update()
{
    Vector3 mouse = Input.mousePosition;
    Vector3 mouseWorld = Camera.main.ScreenToWorldPoint(new Vector3( mouse.x, mouse.y, player.transform.position.y));
    Vector3 forward = mouseWorld - player.transform.position;
    player.transform.rotation = Quaternion.LookRotation(forward, Vector3.up);
}
#

something like this

#

wait this might also have a problem

timber tide
#

that should be fine

#

if you want to do it by look rotation

#

but this would be instant and not lerped

prisma silo
sonic dome
livid tundra
#

I need to have the zero vector as a default parameter and I want my function to be as uncluttered as possible to do this

#

this does NOT work:

public void SetupClone(Transform _newTransform, float _cloneDuration, float _alphaFadeDuration, bool _canAttack, Vector3 _offset = Vector3.zero)
{...}
timber tide
#

well, I guess it comes down to how the character should behave if quickly changing rotation from say angle 0 to 180

livid tundra
#

that last one, the offset, is a new update to this function and if we don't want an offset, I'd like it to just be the zero vector

eternal needle
livid tundra
#

if there's a way to do this without an "if" statement in the function, I'd like to know

prisma silo
#

also im trying to rotate a children of the player gameobject

livid tundra
#
Error    CS1736    Default parameter value for '_offset' must be a compile-time constant    Assembly-CSharp    D:\Unity\RPG Alexdev Course\Assets\Scripts\Skills\Controllers\Clone_Skill_Controller.cs    36    Active
sonic dome
gaunt ice
#

vec3.zero is not compile time constant

livid tundra
#

Vector3's have no compile time constants

gaunt ice
#

it is static readonly (or something similar to this) iirc

north kiln
livid tundra
#

Shirly, there must be a workaround 🤔

north kiln
#

Either use default, or just make an overload

sonic dome
# prisma silo also im trying to rotate a children of the player gameobject
float CameraDistance = Camera.main.transform.position.y - transform.position.y;
Vector3 WorldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
WorldPoint.z = CameraDistance;

float AngleRad = Mathf.Atan2(WorldPoint.y - transform.position.y, WorldPoint.x - transform.position.x);
float AngleDeg = (180 / Mathf.PI) * AngleRad;

Body.rotation = AngleDeg;

i found this online try this one

livid tundra
#

what will 'default' do?

north kiln
#

also, use a standard naming convention for parameter names... not whatever this is

timber tide
north kiln
livid tundra
#

all of this guy's parameters are named like that in the tutorial and it's actually almost 40 hours long 👀

#

I'm in too deep

north kiln
#

Who on earth is it? Because in no world do C# method parameters start with underscores

livid tundra
north kiln
eternal needle
#

which is worse cause iirc default rotation is an invalid Quaternion

prisma silo
sonic dome
livid tundra
timber tide
# prisma silo sure

honestly consider getting this to work this way instead of casting because mapping x/y should work to map out your forward direction

north kiln
livid tundra
#

so SetupRunSpeed(float _runSpeed){...} could take on float runSpeed as an argument

north kiln
#

That's just backwards though

eternal needle
#

there is no case where you need _ in the parameter, even if you have a duplicate name.

    float something = 4;
    void Test(float something)
    {
        this.something = something;
    }

this exists

sonic dome
livid tundra
#

when I do new Vector3(), is that the zero vector by default?

#

because that is working as a default parameter

north kiln
#

numerical value types are initialized as 0

livid tundra
livid tundra
#

(0,0,0)?

#

seems that way, since each element is a float

#

thank you

prisma silo
north kiln
#

(see Using a Plane if that was unclear)

#

and provide a plane at head-height aligned with the ground

tame girder
#

Hii, i have a problem here. so i have a variable or attributes money that was a float and started from 0. and i have a funct when clicked a button it will be +0.001 how can i make it? i already make like this but its wrong public void Clicked()
{
float money = ++0.001;
}

#

is it money += 0.0001; or what

eternal needle
#

your float should also end with f

tame girder
#

ooh alright i forgot the f my bad

livid tundra
eternal needle
#

vertx suggested it 😅

prisma silo
#

ok so i found a really good solution that works to my problem found this on the internet

Vector3 mouse = Input.mousePosition;
Ray castPoint = Camera.main.ScreenPointToRay(mouse);
RaycastHit hit;
if(Physics.Raycast(castPoint,out hit, Mathf.Infinity, ~playerLayer))
{
    Vector3 playerHeight = new Vector3(hit.point.x, this.transform.position.y, hit.point.z);

    Vector3 hitPoint = new Vector3(hit.point.x, hit.point.y, hit.point.z);

    float length = Vector3.Distance(playerHeight,hitPoint);

    var deg = 30;

    var rad = deg * Mathf.Deg2Rad;

    float hypote = length / (Mathf.Sin(rad));

    float distanceFromCam = hit.distance;

    if(this.transform.position.y > hit.point.y)
    {
        requiredHitPoint = castPoint.GetPoint(distanceFromCam - hypote);
    }else if (this.transform.position.y < hit.point.y)
    {
        requiredHitPoint = castPoint.GetPoint(distanceFromCam + hypote);
    }
    else
    {
        requiredHitPoint = castPoint.GetPoint(distanceFromCam);
    }
}
    thing.position = hitPoint;

which just puts a gameObject to the mouse position by using raycast then i made it so my player/the player's children looks towards that gameObject like this,

Vector3 thingPos = new Vector3(thing.position.x,body.position.y,thing.position.z);
body.LookAt(thingPos);
north kiln
#

what on earth was wrong with my simple solution

prisma silo
#

thanks tho

#

aight im dipping from here

eternal needle
#

thats an interesting way to declare hitPoint as well

north kiln
#

Insane to cast against geometry only to do trig against a virtual plane vs just using the plane

#

Only one benefit/drawback, if you weren't hovering a collider, it doesn't look in that direction

cerulean quest
#

why is there no mesh being rendered when i run this code

// mesh variables.
    Mesh mesh;
    Vector3[] RoomVertices;
    int[] RoomTriangles;

    // room information.
    Vector3 FirstPoint, SecondPoint;

    // this function takes the two defining points and defines the vertices and triangles for the room mesh.
    void CreateRoomMesh( //Vector3 Point1, Vector3 Point2
                         )
    {
        RoomVertices = new Vector3[]
        {
            // i will replace the 0s with point1 and the 1s with point2 later.
        // bottom vertices
            new Vector3 ( 0 , 0 , 0 ),
            new Vector3 ( 1 , 0 , 0 ),
            new Vector3 ( 0 , 1 , 0 ),
            new Vector3 ( 1 , 1 , 0 ),

        // top vertices
            new Vector3 ( 0 , 0 , 1 ),
            new Vector3 ( 1 , 0 , 1 ),
            new Vector3 ( 0 , 1 , 1 ),
            new Vector3 ( 1 , 1 , 1 ),
        };

        RoomTriangles = new int[]
        {
        // floor
            1, 3, 2,    2, 3, 4,
        // ceilling
            5, 6, 7,    7, 6, 8,

        // east (positive X) wall
            2, 4, 8,    8, 6, 2,
        // north (positive Y) wall
            4, 3, 7,    7, 8, 4,
        // west (negitive X) wall
            3, 1, 5,    5, 7, 3,
        // south (negitive Y) wall
            1, 2, 6,    6, 5, 1
        };
        Debug.Log("mesh vertices are cooked");
    }
    void UpdateMesh()
    {
        mesh.Clear();
        mesh.vertices = RoomVertices;
        mesh.triangles = RoomTriangles;

        Debug.Log("it should be updated now");
    }

    void Start()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;

        CreateRoomMesh();
        UpdateMesh();
    }
#

when i inspect the mesh thats inside the mesh filter this is what it shows me

north kiln
cerulean quest
#

it did error

north kiln
#

indices start at 0, not 1

cerulean quest
#

so this is uselss now

#

i have to subtract 1 from each of them

north kiln
#

yes

cerulean quest
#

nooooooo...

timber tide
#

write a script that deducts it all for you

north kiln
#

Which you can do with IDE trickery with a good plugin

cerulean quest
north kiln
#

If you use Rider I recommend String Manipulation

timber tide
#

as much as I hate working with microsoft excel, it's good at dealing with problems like this ahaha

cerulean quest
#

bro procedural generation is already brain melting enough i dont think i have any brain juice left to learn how to make a script that deducts 1 from a list of numbers

ivory bobcat
timber tide
#

parsers are fun

#

could probably just throw it into chatgpt and it'll spew it out for ya

north kiln
#
RoomTriangles = new int[]
{
    // floor
    0, 2, 1,    1, 2, 3,
    // ceilling
    4, 5, 6,    6, 5, 7,

    // east (positive X) wall
    1, 3, 7,    7, 5, 1,
    // north (positive Y) wall
    3, 2, 6,    6, 7, 3,
    // west (negitive X) wall
    2, 0, 4,    4, 6, 2,
    // south (negitive Y) wall
    0, 1, 5,    5, 4, 0
};
cerulean quest
#

wait what

north kiln
cerulean quest
#

how did you only select ,

north kiln
#

JetBrains Rider

cerulean quest
#

oh well too late i already did it manually

north kiln
timber tide
#

pay2win

cerulean quest
cerulean quest
north kiln
#

Probably because you just posted a single character, which is a bad way of communicating

north kiln
#

You can type $ just fine

cerulean quest
ivory bobcat
cerulean quest
#

CUBE CUBE CUBE

north kiln
#

Yes, it costs money, students can get it for free, and the early access program is free while it's running (it just started again)

cerulean quest
cerulean quest
nimble apex
#

im studying a very complex code, what is the ref here :

function(ref .... , ref,,,,)
teal viper
#

Passes the variable by reference

languid spire
#

ref is used to pass a value type parameter by reference instead of by value

cerulean quest
#

aka doesnt create a clone inside the functions

#

with the same vvalue

nimble apex
#

im looking at a chaotic system, not function, and that system is hooked onto a custom library

#

in fact i dont even know where to start

teal viper
#

If it has parenthesis after indentifier, it's a function/method. Or a constructor.

#

Or a delegate(but that's basically a method/function)

nimble apex
#

to be very simple, im in charge of fixing one of the function in this chaotic system

it is a function to draw icons of a grid

#

by nature, it is a normal void function

abstract finch
#

generally do you want to put the true condition in an if else statement first?

nimble apex
#

4 yrs of coding i still cant get used to if ternaries lol

#

it depends tho

languid spire
abstract finch
languid spire
#

because that is how the statement is evaluated

teal viper
#

I assume what they're trying to ask is wether the should do it as in their code or !IsCasting ?...

languid spire
#

condition ? if true : if false

flat slate
#

How do I check whether a collision occurs right at the start?

languid spire
#

then I would say which is more readable or more likely

cinder spruce
# languid spire condition ? if true : if false

Hey Steve how are you? We talked yesterday you remember? I understood what the problem is but i couldn't solve it anyway, can you help me? It drives me crazy. It's a very crucial mechanic of the game and i need to finish the project in 2 days

teal viper
flat slate
#

okay

cinder spruce
languid spire
#

but you didn't do what I said

cinder spruce
languid spire
#

coz you did it wrong

#

lets make a thread

nimble apex
#

how to optimize, without changing the library function

#

cuz im strictly warned not to change one single bit of the library

languid spire
#

what are the ref values after the method is called ?

gaunt ice
#

get rid of string, but you cant do that
the left is to use own parser without any split() or regex \d+ since you already know the format

nimble apex
#

man its doing delta updates

#

damn

languid spire
#

there is just not enough information there but maybe something like

List<Vector2Int> vectors
...
vectors.Add(new Vector2Int(int.Parse(coord[0,0]),int.Parse(coord[0,1])));
gaunt ice
#

oh did i misunderstand the format?

[["123","456"]] or [["{{123,456}}"]]
#

then you just access the color by corrdinate

nimble apex
#

the right one and the upper graph has additional functions

#

so its using a model class to contain the info

#

instead of string[,]

#

bruh its far comlicated than i thought actually

#

i think just keep it this way for now

#

thx guys

hollow zenith
#

Do enum count as "class"? I can't create a class in Unity as "class already exists"

#

I have enum called that

languid spire
hollow zenith
#

alright thx

grizzled hull
#

hello, I followed a tutorial to make my character jump in 2D, then to make him jump only once. Even after following the tutorial, my character continues to jump endlessly, can you help me?

slender nymph
#

most likely your OverlapArea is detecting your player's collider because you aren't using a LayerMask

#

also !code

eternal falconBOT
grizzled hull
#

What is a layerMask ?

rare basin
#

such a google question

gusty ibex
#

Anyone know if you can anchor 2 views together?

E.g.
<A> END anchored to <B> start. With an offset of 10 for spacing.
So if I move <A> up or down, <B> mirrors the layout changes to A + the 10 spacing.

I've seen arrows in videos about this, but the video doesn't mention anchoring to other views. Only anchoring to corners and then everything else is offset.

Is there any way (Ideally in GUI) to anchor views together?

amber veldt
#

Hey guys, weird question but maybe you have the answer.

I'm following some tutorials on aiming, I have a crosshair with a sphere at the target point (where it's going to land)

I'm using a raycast for that, so when I'm rotating my character too fast, the sphere does not follow perfectly and takes some time to go there.

Is there a solution to fix this issue?

https://www.youtube.com/watch?v=FbM4CkqtOuA&t=1365s here is the reference video, 17min30ish

💬 How to make a Third Person Shooter Controller in Unity!
✅ Get the Project Files https://unitycodemonkey.com/video.php?v=FbM4CkqtOuA
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundle

00:00 Third Person Sho...

▶ Play video
rare basin
stuck palm
#

can you do "foreach" on a dictionary? or is there an equivalent?

#

guess u cant

slender nymph
#

yes you can

stuck palm
#

or right

#

oh right*

#

just read an article

#

i tried to do it wrong

late jolt
#

Can someone help me to fix this? i have try anything but is still error

cosmic dagger
slender nymph
stuck palm
#

figured it out

slender nymph
cosmic dagger
late jolt
slender nymph
#

active meaning not disabled in the scene

slender nymph
#

well you need to ensure that your navmeshagent is on the navmesh at the time you call the SetDestination method

slender nymph
#

place it on the navmesh . . .

late jolt
cosmic dagger
cosmic dagger
rare basin
slender nymph
#

well we also know absolutely nothing about their setup (except that they are using an older version that tutorials will likely cover) since they didn't deem it worthy enough to share so we can really only speculate

rare basin
#

yup

stuck palm
#

why isnt this working?

rare basin
#

could not cast or convert string to Level

stuck palm
#

yes i am aware

#

but why couldnt it do that?

rare basin
#

because Level is a class probably

#

and string is a string

stuck palm
#

relevant images

rare basin
#

!code

eternal falconBOT
cosmic dagger
rare basin
stuck palm
cosmic dagger
slender nymph
rare basin
#

but i have my own serialized dictionary

#

so maybe the normal Dictionary doesnt work

slender nymph
rare basin
#
 SaveManager.LoadClass<GenericDictionary<ChuckwagonType, int>>(GameSaveManager.Instance.currentSaveSlot.ToString(), SaveType.CHUCKWAGON_LEVEL);

    public static T LoadClass<T>(string ID, SaveType saveType) where T : class
    {
        string keyString = GetSaveName(ID, saveType);

        if (!HasKey(keyString)) return default(T);

        string loadedJson = (string)savedFormatedData[keyString];
        return JsonUtility.FromJson<T>(loadedJson);
    }
cosmic dagger
# stuck palm

You need to split the values and keys of the dictionary into two lists and save those lists. When deserializing, create the dictionary using both lists . . .

rare basin
cosmic dagger
rare basin
#

you can edit it in the inspector + save it/load it via json

stuck palm
#

thats a real bitch

cosmic dagger
stuck palm
#

thanks guys

#

i thought adding the [serializable] thing would fix that issue but ig not

rare basin
#

nope

stuck palm
#

is it because "level" is a SO?

rare basin
#

scriptable objects are serialized, actually everything that shows up in the unity inspector is serialized

stuck palm
#

okay

#

well i guess i'll have to do the split method then

#

thanks chat

rare basin
#

or you can make a workaround

#

like a monobehaviour class containing 2 lists or sth

slender nymph
#

except you aren't even using jsonutility, you're using json.net which can serialize dictionaries

slender nymph
stuck palm
#

oh right

#

so what the hell

#

its weird cus

#

its serialising it fine

#

but it cant deserialise it

slender nymph
#

the issue is likely how you are serializing it. but why are you serializing a ScriptableObject in the first place?

stuck palm
#

i guess its only serialising the name

rare basin
#

well you cannot really "save" scriptable objects

stuck palm
rare basin
#

if you are trying to save SO into a json

#

then "load" it

#

it wont work with SO

languid spire
rare basin
#

im talking about built-in SO not some assets lol

shell sorrel
#

scriptableobject is meant to be a custom asset type, its just kinda over complicating things to use for runtime saves

rare basin
#

ow its your asset

#

what does it do? @languid spire

shell sorrel
#

when you can simple serilize out any data structure without the overhead and complication

rare basin
#

if it will work with saving/loading it via json then im buying it right now lol

languid spire
#

what is says, saves and loads So data at runtime, makes SO's mutable

shell sorrel
cosmic dagger
rare basin
slender nymph
rare basin
#

what you could do is a Dictionary<LevelEnum, LevelStats>

#

and save that

languid spire
#

yes

rare basin
#

and have a different Dictionary<LevelEnum, Level>

#

so you load the Dictionary<LevelEnum, LevelStats> with JSON, then get proper Level frmo the 2nd dictionary

shell sorrel
#

question if this is for save data why do you want the SO in the first place? is this for just refernecing it, or is this for defaults?

rare basin
rare basin
#

and it works perfectly

stuck palm
#

level just works well in game to easily make new level data where i can just change values on the fly

stuck palm
#

i mean like on what class

rare basin
#

idk up to you, in some kind of SavedLevelManager

stuck palm
rare basin
#

make a enum LevelEnum, fill it with entries like LEVEL_1, LEVEL_2
make a Dictionary<LevelEnum, LevelStats> - this will be the one you save/load with JSON

stuck palm
#

yeah i think i got it

rare basin
#

and make a Dictionary<LevelEnum, Level> where you have all the levels assigned

#

and then you can work with it

stuck palm
shell sorrel
#

well you access the data in both using the same key

#

if you really wanted to link them could just fake it with a Getter

stuck palm
#

yeah okay i get it now, thank you

#

working on it now

shell sorrel
#

So like LevelStats could have a getter that does a lookup into the dict with levels

stuck palm
#

then i can make the final dictionary using those two

rare basin
#

not needed really

#

why?

#

i mean you could after you load the saved json

#

if it's easier for you

stuck palm
rare basin
#

yea sure then you can make <Level, LevelStats>

stuck palm
#

its needed for some logic i have going on

rare basin
#

and work with it

stuck palm
#

awesome

rare basin
#

i still encourage you a lot

stuck palm
#

thanks i have an idea in my head on what to do now

rare basin
#

to make a serializable dictionary

#

so you can fill dictionary keys/values

#

in the inspector

#

it's game changer

stuck palm
#

i dont understand, cus the dictionary is being serialised into a json

rare basin
#

this is a dictionary

#

<int, bool>

#

and i can add keys, change values etc

stuck palm
#

is this like a paid asset

rare basin
#

no i made this myself

stuck palm
#

i can probably find a serializable dictionary online

rare basin
#

you can use

#

GenericDictionary

#

from github

#

it's free license iirc

stuck palm
#

does it take very long?

#

to implement

rare basin
#

no its easy

stuck palm
#

might as well do it now then

rare basin
#

use the GenericDictionary from github

#

and all you need to do then is to just replace

#

all Dictionary<> to GenericDictionary<>

#

it's honestly a game changer, saving tons of time

stuck palm
rare basin
#

for example this is a `GenericDictionary<BalistaEnum, GenericDictionary<int, bool>>

#

so i have a dict inside a dict

#

so for example i can check if FIRE balista level 1 is unlocked

#

this way

stuck palm
#

would i still have to do the enum method by doing this?

rare basin
#

and esaily motidy it

#

yes, it is not related to your ScriptableObject problem

stuck palm
#

okay

rare basin
#

you cannot save it via json

stuck palm
#

do u have a link for the generic dictionary? i cant find it

rare basin
#

copy the Editor and Scripts folder

stuck palm
#

okay, thanks

barren violet
#

I’m late to the party, but why a generic dictionary and not just a dictionary?

stuck palm
#

and i only have to make Dictionary into GenericDictionary? it all still works the same/

rare basin
stuck palm
#

but if it works hey

stuck palm
#

im happy either wa

rare basin
#

which kinda changes the look of it

#

the default GenericDictioanry looks kinda different

#

but does the job still

rare basin
rare basin
#

no, serialized dictionaries

#

editable in the inspector

#

odin is great too 😄

stuck palm
#

okay 😄 thanks working with it now

#

serialisable dictionary thing is gonna make the enum method a lot easier

rare basin
#

yea i cba doing the enum method

#

and fill the dictionaries

#

with code 😄

stuck palm
rare basin
pliant oyster
#

Where do I put the Time.deltaTime in my bullet shoot code? My bullets shoot slower when my character moved than when my character is still.
(Please answer directly, I have a mental disability and struggle with non-direct instructions)
https://hatebin.com/qpetiqjwrc

#

I'm still testing it, which is why there's only a code for "Level 0"

barren violet
#

The code looks like it just instantiates the bullets, this code isn’t responsible for the bullets movement?

pliant oyster
#

Oh thank you, let me post the other one. For some reason the movement is in a separate script...

rare basin
#

why are you calculating frames?

pliant oyster
gaunt ice
#

your fire rate is frame rate dependent

#

you should make it time dependent

pliant oyster
#

How do I do that? I'm guessing I have to change the frameNormal++; to something else? I tried changing it to frameNormal += Time.deltaTime; but it didn't seem to work. It spawned no bullets.

rare basin
#

why are you calculating the frames anyway?

neon fractal
#

!code

eternal falconBOT
pliant oyster
#

To make it so the player only shoots once every 16 frames. Because a level up should half it to 8, and another level up should shorten it to 4.

rare basin
#

instead making it frame rate dependand

#

what is palyer A runs 60 frames per second

#

and player B runs 120 frames per second?

#

palyer B shoots more bullets in 1 second than player A

#

doubt it is intended behaviour

gaunt ice
#
public int fireRate=100;//100 rounds per second
public float coolDown=1f/fireRate;//around 0.01s per shoot
public float idk_how_to_name_it=0;
idk_how_to_name_it-=dt;//eg if dt=0.03s, you should shoot three bullets
while(idk_how_to_name_it>=0){//note that you need a while loop since the fireRate is larger than fps=60
  shoot();
  idk_how_to_name_it+=coolDown;
}
stuck palm
#

i dont understand why im getting this error if im nullchecking? the error is on the highlighted line

pliant oyster
rare basin
#

is not added to the dictionary

stuck palm
#

how do i check if a key is present in a dictionary?

#

i thought thats what i was checking

rare basin
#

.Contains()

stuck palm
rare basin
#

yea sorry

pliant oyster
slender nymph
rare basin
shell sorrel
stuck palm
#

how do i delete a file from the editor? i've got a save file somewhere and idk where it is and its messing with my code since i changed the values

gaunt ice
#

dictionary has a method called trygetvalue

#

btw the indexer allows you to set the value even no such key

rare basin
#

depends where you saved it

stuck palm
cosmic dagger
pliant oyster
#

Real quick question, I keep switching them in my head, in C#, is it if (... and ...) or if (... && ...) for an if that needs both to be true?

pliant oyster
#

Thank you!

rich adder
pastel pollen
#

Is it safe to have nested foreach over the same IEnumerator IEnumerable?

brave compass
swift crag
#

An IEnumerable is something that can give you an IEnumerator!

stuck palm
#
public void MapData(Level level, LevelStats ls)
    {
        if (loadedSave.savedLevelData.ContainsKey(enumLvlDict[level]))
        {
            loadedSave.savedLevelData.Add(enumLvlDict[level], ls);
        }
        else
        {
            loadedSave.savedLevelData[enumLvlDict[level]] = ls; 
        }
    }

how do i fix this? something is already in this

rare basin
#

to a dictionary

wintry quarry
rare basin
#

if it contains a key, you cant add the same key again

rare basin
#

loadedSave.savedLevelData[enumLvlDict[level]] = ls; just this is enough

wintry quarry
#

then use the myDict[key] = value; syntax

#

.Add specifically will throw an exception for a duplicate

#

The indexer does not, it overwrites.

stuck palm
#

cant belive that works by itself

amber nimbus
#

If I have mutiple classes with the Update() method which classes code runs first? Is there a way to find out?

wintry quarry
amber nimbus
#

Aight thanks :d

wintry quarry
#

It can even change from platform to platform

undone rampart
stuck palm
#

@rare basin finally got the save file working thanks to your system 😄

stuck palm
#

How could I make a little beep play when i hover over a button/select a button? I feel like it would be tedious to give every button a script to play a noise when hovered or selected

rich adder
stuck palm
#

I could just make a script actually, I don't have too many buttons in my game

restive bay
#

I'm trying to reference a script to reuse variables but it won't allow me to drag the script into the inspector to give that script access. Hopefully I explained that properly.

modern pecan
#

hey this might not fit in here but i downloaded unity hub but when i try to open it it shows my mouse that its loading but then it just doesnt open up

restive bay
modern pecan
#

where do i end the task?

restive bay
modern pecan
#

no siree

#

i typed in Unity Hub

#

nothing

restive bay
modern pecan
#

oh man i tried that

#

10 times by now

restive bay
#

Or right click and try to run it as administrator

modern pecan
#

i tried that too

restive bay
#

This might be a dumb question but did you restart your pc?

modern pecan
#

nothing

#

ehm

#

no

restive bay
#

Wouldn't hurt to try it

modern pecan
#

alright

#

im back ima try now

#

and it wont work.

verbal dome
swift crag
#

!logs

eternal falconBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

modern pecan
#

alr

swift crag
#

There is probably an error at the end of the log file.

modern pecan
#

how do i look at em?

swift crag
#

I forget the exact name of the log file -- let me go look..

swift crag
#

I presume you're on Windows

modern pecan
#

yh

swift crag
#

If you paste this into the Run dialog, an Explorer window will open in the right directory

#

%UserProfile%\AppData\Roaming\UnityHub\logs

modern pecan
#

what now?

swift crag
#

open the log file and look towards the end of it

#

that's generally where an error will be

modern pecan
#

and how is a error?

#

how does it look like

swift crag
#

literally the word "error" appearing in the logs

modern pecan
#

nope

#

not anywhere

swift crag
#

also, this isn't actually a code problem, so you should ask about this in #💻┃unity-talk

modern pecan
#

yh i did but nobody responded

#

anyways i didnt find anything

polar acorn
modern pecan
#

that says

#

"error"

modern pecan
#

no errors

timid hinge
#

hi guys i have a question im vreating a game 2d roguelike and i want to spawn anemies on the map anyone can help me ?

#

i have this map

#

how generate random map everytime i want

frosty hound
#

How did you generate that one?

nimble scaffold
#

I need urgent help.... In all my unity scenes most of the things turned pink(magenta) idk why and I also tried to convert materials to urp but it's also not working

timid hinge
fossil drum
nimble scaffold
rare basin
frosty hound
frosty hound
rare basin
#

for example make a ButtonElement prefab, which contains well - a button, and when you want to some kind of scripts to that button you only need to add it to the prefab @stuck palm

timid hinge
#

but the question is how can i place items and enemies in the map?

rare basin
#

same with Text components, imagine you have 1000 text elements in your game and suddenly you want to change a font, you can do it with just replacing the font in a TextElement prefab instead of going to each element

fossil drum
stuck palm
#

how would u check if a button has been highlighted?

#

or selected

frosty hound
rare basin
#
    public void OnPointerEnter(PointerEventData eventData)
    {
       //play UI button hover so, switch graphics to "selected" or "highlighted" etc
    }
#

you also have OnPointerExit so you can switch back the graphics

stuck palm
timid hinge
rare basin
fossil drum
stuck palm
#

right

#

okay thanks

swift crag
#

you implement IPointerEnterHandler on a MonoBehaviour

nimble scaffold
#

No errors in logs

#

It changed within a second

swift crag
frosty hound
frosty hound
#

You can't afford me

swift crag
#

that would be an extremely expensive way to use google

timid hinge
#

how much ?

frosty hound
#

But if you're interested in hiring someone. You can post on !collab

eternal falconBOT
swift crag
#

i think you should just try the most basic thing that works

stuck palm
timid hinge
#

so your not good?

#

i qustion because i have money but i need the best here

eternal falconBOT
swift crag
#

i think you need to do your homework

rare basin
#

200$/hour and you can have me for 8h per day

timid hinge
#

i need the best

rare basin
#

for 200$ i will be average, for 500$/hour i will be the best

frosty hound
#

@timid hinge Again, go to the forums to post for jobs. This isn't the place.

swift crag
#

this is borderline spam

frosty hound
#

Also I suggest your change your trolling pronouns before you get kicked from this server as well.

swift crag
#

sigh

polar acorn
# swift crag sigh

They always have to show it off. Like those poison dart frogs that use the brightest most conspicuous colors

neon fractal
rare basin
#

you are Lerping wrong

#

this is not how you lerp

#

last parameter in Lerp is interpolationPoint, between min and max value

#

timeElapsed / lerpDuration

#

not changeSpeed * Time.deltaTime

neon fractal
#

I'll try it.

safe root
#

What's the website so i can send code?

rare basin
#

!code

eternal falconBOT
safe root
#

Thank you

swift crag
#

it's just going to make the speed of change framerate-dependent

echo matrix
#

Hey, is there a better way to have multiple animation curves in a script? I want to call different kind of curves for specific use cases. ATM i have a serializefield for every single curve. I was searching for something like a curvelist (if this is even a thing)

#

i need 10-20 curves and it makes the component and code really ugly

rare basin
#

Dictionary<ColorEnum, AnimationCurve>

languid spire
#

make an array or List

swift crag
rare basin
#

then you can access each curve by its color

swift crag
#

They're probably just fighting each other

rare basin
#

animationCurves[CurveEnum.GREEN]

#

etc

swift crag
#

You should be changing where a single two-bone IK constraint is trying to go

echo matrix
#

thats sounds exactly like what i have been looking for thanl you

neon fractal
swift crag
#

note that you need an addon to have serializable dictionaries

#

you can also just make a list of structs that hold an enum value and an animation curve

#

then build a dictionary out of that when the game starts

rare basin
#

@echo matrix

public GenericDictionary<ColorEnum, AnimationCurve> animationCurves;
swift crag
rare basin
#

then animationCurves[GREEN] gives you the curve assigned to green key etc

swift crag
#

They're all going to be fighting over where the arm goes

echo matrix
#

What does Enum mean?

rare basin
echo matrix
#

ok

wintry quarry
neon fractal
wintry quarry
#

basically a fancy way of having "named numbers"

rare basin
#

thinking process shortcut ofc

celest spoke
neon fractal
wintry quarry
swift crag
echo matrix
rare basin
#

not built-in in Unity

echo matrix
#

what do i need to get for it?

rare basin
rare basin
#

there should be some free on assetstore aswell

rare basin
#

on the slime

#

also what is your timeScale?

celest spoke
rare basin
#

also you don't need the enemy != null check again, since you aer already checking that

rare basin
celest spoke
#

sorry here

rare basin
#

and what is your timeScale?

celest spoke
#

timescale? O.o

rare basin
#

nevermind, it's not 0

#

are you not overriding enemy velocity anywhere else?

celest spoke
#

nope

stuck palm
#

why are my buttons not working when i hover over them with the mouse? only works with the up and down arrows on thge keyboard. the sliders work fine tho for some rason

rare basin
#

noting else on top of that UI that could block it?

stuck palm
celest spoke
#

i have my update as FixedUpdate @rare basin maybe that is something thats causing it?

stuck palm
#

anything that is rendered on top doesnt have a raycaster on it so it cant block it

rare basin
#

just to be sure

stuck palm
rare basin
#

disable it aswell

#

the UI Canvas

#

also, if you in runtime make a new button on that object

stuck palm
#

nothing happens

rare basin
#

is it interactable?

stuck palm
#

i dont understand cus the sliders work fine

#

so nothing is blocking them

#

its just the buttons

rare basin
#

right click pause menu -> ui->button

#

does the button work then?

stuck palm
#

i'll try one sec

stuck palm
rare basin
#

yup

#

something wrong with the button setup

#

show the hierarchy of that button

#

and that button component

#

you probably disabled the image component

#

so there is nothing that can "catch" the raycast

stuck palm
#

i havent disabled the image

#

and these buttons are basically exactly the same on the home screen and t hey work fine

rare basin
#

i guess just make new buttons then, hard to say what broke

stuck palm
#

so idk whats up with that