#archived-code-general

1 messages · Page 115 of 1

halcyon steeple
#

okay, I'm a little bit into making this game and just realized today that saving is kind of important lmao

#

thanks

latent latch
#

What I do is keep unique data minimal, and construct stuff relative to what data you can read from in SOs

#

and instead save IDs to the SOs instead of the data itself

rotund burrow
#

i need to instantiate generic type with parameters. i use T t = (T)Activator.CreateInstance(typeof(T), parameters[]). idk what it is though and i need to run it a lot while it's supposed to be slow. should i just copy paste code instead?

simple egret
#

If T has always a parameterless constructor, then you can constrain your type where T : new(), then call new T() immediately. Not possible if you don't have a parameterless constructor

rotund burrow
#

i dont have it

simple egret
#

Pretty lame the new constraint is so basic, something like where T : new(int, string, whatever) would have been nice for some cases

sharp elm
#

Hey uh, quick question : is there a recommended way for unity to implement generic loading ?
By that I mean loading a player's custom resources, like images or additional textures

sharp elm
#

I'm thinking more of something like uh, a Mods or Resources folder directly inside of the game's installation folder, and the player just puts his files here :v

hexed pecan
sharp elm
hexed pecan
#

Haven't used steamingassets yet but I'm also interested if it can be used for user-created content

sharp elm
#

Ye that was my first solution

#

But I was wondering if Unity provided innate mod or "generic custom loading" support

#

Oh well

knotty sun
knotty sun
leaden ice
sharp elm
#

The Adressables package seems pretty complete for my need

fiery sandal
#

can someone suggest good article/post/video on managing component dependencies? I'm talking about moving from service locator to make prefabs more flexible and self-sustained so I for example, will not have to create the world in order for small UI component to work.

final kiln
#

im trying to create a main menu but im experiencing lots of issues with my script. https://pastebin.com/Fdz7VCQU

i want the saveSettingsButton to show up when changes to the 2 dropdowns are made and be hidden whenever i save the changes. however the button does not show up at all and im not quite sure why.
additinally, the confirmationPopup is supposed to show up if i made changes and i didnt save, it doesn't show up whatsoever just like the saveSettingsButton. is anything wrong with it? can anyone please help ive been at this for a couple hours now.

knotty sun
final kiln
#

how did i not realize

#

where exactly do i put it? just in the UpdateApplyButton() function?

#

because i dont wanna risk getting confused again

#

apparently that still isn't enough. im really confused

knotty sun
#

hey, you wrote the code

final kiln
#

i wouldn't be asking if i knew what i'm doing wrong

#

its my first day coding after taking a 1 year break

languid hound
#

How could I calculate the middle of two vectors? I don't know what to call it

Let's say I was making a throwable thing for VR and somebody was attempting to throw it. Obviously when your arm reaches the end of the throw its going to go down

#

If I calculated the velocity the object should be thrown at via current hand position - previous hand position

#

It would just go straight down

#

How could I make it so it takes the in-between of like the start and end vector I dunno

#

Or just make it not go down I suppose?

void basalt
#

@languid houndcurrentPosition - lastPosition will give you the current velocity

#

so I'm not sure what you're talking about

languid hound
#

I think I got the wording

#

What I want is the average of multiple vectors

void basalt
#

I don't think that's going to work.

#

Getting the velocity and applying it to the rigidbody on release is probably your best bet

languid hound
#

Yes but from my experience the issue is if you let go last minute the object will go down because its calculating the distance between your previous hand position and next one. What I want is to get the average between maybe 5 positions from a couple frames ago so its less jarring and could be more accurate even if not realistic

void basalt
#

averaging the last 5 vectors isn't the right solution.

#

Clearly something is going wrong in your code

languid hound
#

Games like Toss use it and get a really good result

simple egret
#

Getting an average vector is the exact same as getting an average of numbers. Sum them all, and divide by the item count

languid hound
#

Nothing is wrong to my knowledge its just

grabbedRigid.AddForce((currentPosition - prevFramePosition), ForceMode.Impulse)
void basalt
#

not force

#

current - previous is a velocity

#

velocity specifies movement over time

simple egret
#

Applying it as impulse (arg 2) is similar to setting the velocity directly, it just takes the mass in consideration

void basalt
#

VR is difficult in general. When picking items up, some people disable the rigidbody component and simply parent the gameobject to the hand

#

other people use control theory to write PIDs to change the velocity and angular velocity to match the orientation of the hand

#

so it all really depends on your setup

final kiln
#

s

#

so does no one know how to fix it?

smoky pike
#

My game has a camera that is automatically moving up at a fixed velocity. The camera also follows the player at the same time. The problem is that there is extra velocity added to the camera as it adjusts to keep the player in frame. How do i get rid of this extra velocity? Code to control camera movement:
targetPosition = new Vector3(player.transform.position.x,player.transform.position.y+velocityUp,-1); transform.position = Vector3.SmoothDamp(transform.position,targetPosition, ref velocity, smoothTime);

void basalt
smoky pike
#

it tries to smoothly follow the player

void basalt
#

Still not sure what the issue is

smoky pike
#

I have an velocity upwards on the camera at all times. If the player exits the view of the camera, the game is over. The problem is that when I move my player abruptly, the camera adds extra velocity upwards which I don't want. So the velocity in my game that is constant is 0.5f. Whenever the camera tries to adjust to ensure the player is in the center of the screen, the velocity upwards becomes 0.5f + some additional velocity

void basalt
#

You should simply move your camera using transform

#

not smoothdamp

swift comet
#

FYI the velocity increase because the distance increases between camera position and target position when player is moved forward rather than when player is standing still. So it lerps faster.

#

So what Burt said.

void basalt
#

The player should be the one trying to maintain a position inside of the screen

#

not the other way around

smoky pike
swift comet
#

Smooth damp them separately then

#

The x,z and Y coords

void basalt
#

I'm imagining a game like doodle jump or something

#

but yours might be different

smoky pike
#

yes

#

pretty much doodle jump or crossy roads

void basalt
#

whenever you need the camera to jump to a new position, you could lerp over time

#

is the camera ALWAYS moving up? Or just in sync with the player?

smoky pike
#

the player has to keep moving up to keep inside the camera's frame

void basalt
#

void Update() {
camera.transform.position += new Vector3(0, 0.01f * time.DeltaTime, 0);
}

#

slowly every frame

smoky pike
#

where targetPosition is the pos of the player?

void basalt
#

I mean yeah, that could work

#

as long as it's getting updated in sync with the player update

swift comet
#

I think that would look weird

void basalt
#

but then your player can never leave the camera

swift comet
#

if you snap camera to player

void basalt
#

and can never lose

smoky pike
#

hmmm

void basalt
#

Doodle jump, the camera moves with the player

#

if player doesn't move, camera doesn't move

#

but I believe the camera can never move down

#

it's been a long time since I've played that game

smoky pike
#

at all times

void basalt
#

alright yeah just move it upwards a little bit every frame then

#

that should solve your issue

smoky pike
void basalt
#

probably something like that yeah

swift comet
#

It should be more like this?

 private void Update()
    {
        // Move camera up on the Y axis
        camera.transform.Translate(Vector3.up * moveSpeed * Time.deltaTime);

        // Center the camera on the player on the X axis
        Vector3 targetPosition = new Vector3(player.position.x, transform.position.y, transform.position.z);
        camera.transform.position = Vector3.Lerp(transform.position, targetPosition, lerpSpeed * Time.deltaTime);
    }
void basalt
#

As long as it works, it doesn't really matter

#

can't remember the last time I've used the Translate function

swift comet
#

I mean his previous one wont work correctly as it sets transform to concrete position of the player for X but Y is also based off player pos.

random cipher
#

woops

void basalt
#

You don't add unity to a game

#

you build a game ontop of unity

random cipher
#

I meant playfab

vagrant blade
#

@random cipher !collab

tawny elkBOT
random cipher
void basalt
#

Most people aren't going to design you a game for free

#

just gonna put that out there

#

not to mention there's probably thousands of gorilla tag clones in unity, based on how much I read about it in this chat

smoky pike
# void basalt probably something like that yeah

that works thank you for the help. only problem is if the player goes at the top of the screen, the camera accelerates really fast to the point where its near impossible for the player to stay on the screen even if the player keeps moving up

void basalt
#

@smoky pikeThe target position should be independent of the player

#

camera.transform.position += new Vector3(0, 0.5f * time.DeltaTime, 0);

#

If you want it to speed up/slow down based on where the player is, we could do that too

smoky pike
void basalt
#

can you send a video

swift comet
#

I will mention again. Maybe this

    {
        // Move camera up on the Y axis
        camera.transform.Translate(Vector3.up * moveSpeed * Time.deltaTime);

        // Center the camera on the player on the X axis
        Vector3 targetPosition = new Vector3(player.position.x, transform.position.y, transform.position.z);
        camera.transform.position = Vector3.Lerp(transform.position, targetPosition, lerpSpeed * Time.deltaTime);
    }
leaden ice
smoky pike
#

The rest doesn't affect the movement of the camera

void basalt
#

video please

#

of the game being jagged

leaden ice
#

we don't even know if it's in Update, FixedUpdate, etc

#

share your code

smoky pike
#

I'm not at my laptop right now, I'll send in a bit

void basalt
#

There just shouldn't be anything jagged about it

#

assuming that you're doing everything in Update() and not FixedUpdate()

smoky pike
#

Yes it's in Update()

leaden ice
#

camera movement generally should be in LateUpdate

#

as late as possible - certainly after everything else has moved

void basalt
#

It moves independently of everything else, so it's not going to matter in this scenario

#

the render still happens at the same time no matter what

leaden ice
#

targetPosition = new Vector3(player.transform.position.x, player.transform.position.y+velocityUp ,-1);
Seems it's moving relative to the player object

#

so reading the player's position before or after it moves this frame will make a visible difference.

#

(of course this depends when/how/where the player object moves)

smoky pike
#

The video is using that code

leaden ice
#

if you don't want that, why are you basing the movement on the player movement?

swift comet
#

(Don't think that uses code I provided maybe mentioned me by mistake)

smoky pike
#

While the camera is moving up

leaden ice
#

well if the player is moving fast

#

the camera will need to move fast to catch it

#

there's no way around that

smoky pike
#

Maybe I'm implementing this incorrectly because Crossy roads uses a different algorithm

#

I'm trying to copy the camera movement but Im not sure

void basalt
#

crossy road and doodle jump are two different games

#

with two completely different camera behaviors

stark glen
#

Hey does anyone know how the spherecast works in code? Like how do you make that by scratch?

stark glen
stark glen
#

Thank you, sweeps would typically work but I am using a mathmatical sphere and not a sphere made of points?

#

It doesn't look like anything else here talks about sphere casts

void basalt
#

mathmatical sphere and not a sphere made of points?

#

pretty sure these are the same thing

stark glen
#

no mine is a vector point and a radius. Not a polygon mesh

void basalt
#

What do you need a custom solution for?

stark glen
#

I thought that maybe I could use a standard raycast and"inflate" the mesh to get the reverse effect and then extrapolate

stark glen
void basalt
#

this is the unity discord

#

not the blender discord

#

two different languages as well

stark glen
#

yes I am aware, but the code concepts are the same

#

concepts span farther than programs specific languages

#

if I can figure out how unity did it, ir unreal even, then I can translate to blender

#

its ok mate, no worries, ill look somewhere else

#

thank you for helping

void basalt
#

I wouldn't know

#

someone else will probably come along

twin hull
#

@stark glen unity just calls PhysX engine, you're more likely to find an answer by looking at ECS physics

stark glen
void basalt
#

and probably way heavier

stark glen
stark glen
#

its all about trying to make something that works first and then optimizing it

#

I appreciate your guy's help!

void basalt
#

I find it suspicious that blender doesn't have casting solutions built in

stark glen
#

I am working in geometry nodes and they only provide the standard raycast. Any other method needs to be built by hand still

twin hull
#

@stark glen why not make the simulation in unity instead?

stark glen
#

since I am mainly a programmer I tend to look at how to make things in unity or unreal and then I transfer the concept to blender

twin hull
#

yeah well good luck, i remember an ECS tutorial building a physics system from ground up so that might help

stark glen
shrewd plume
#

Good night everyone! Could someone help me find what could be happening with this light maps? This dots on the wall weren´t supposed to be visible or even baked in the light maps, because they are far from the the point light range, does someone knows any fix for this?

#

I´ve tested and they are coming from the candle lights for some reason

shrewd plume
#

Sorry, I´ll question there!

austere tiger
#

For a building menu in my project I need to render a bunch of game object prefabs as images in the UI. What is the best way to go about this?

potent sleet
#

RenderTexture

potent sleet
# austere tiger Ok great, thanks

doesn't need to be a new scene btw
it can be same scene if you make the 2nd camera only render a specific layer and set to Depth only

magic venture
#

Can someone help me?

void basalt
#

with graphics or something

magic venture
void basalt
#

Yes, it is pretty hard to understand when nobody knows what an interactable light tower generator does

magic venture
void basalt
#

alright man good luck

magic venture
void basalt
#

alright

magic venture
void basalt
#

Ah, an electrical generator with floodlights attached to it

#

was that so hard?

#

you still haven't said what you want it to do

leaden ice
#

Animations

magic venture
magic venture
edgy ether
#

i dont really know how to ask this so i'm just going to shoot my question...

magic venture
edgy ether
#

i have some materials and textures that are created via script, but because they are created in script, they do not show up at all in the heiarchy/project tabs. is there a way i can grab and move them elsewhere? (i tend to do temporary adjustments while in playmode to understand what i am doing.)

void basalt
#

@magic ventureI've found the easiest way to do this is to use an interface, like IClickable or something

#

that way you can do a single raycast, check if the object has IClickable using GetComponent, then run the code you need

#

easy "Press Use" system

edgy ether
#

i figured i could just just make the textures outside of script, but i really want to know if this is possible

#

because like, if you make some game objects in script, they appear in heiarchy. but other stuff such as render texture, or materials, don't pop up anywhere?

magic venture
#

I don't get your point.

void basalt
magic venture
#

I mean that I actually have the whole thing working like buttons and that but I only need to make the pole to extend.

#

Idk how to make the pole to extend like a real LTU does.

void basalt
#

modify the scale of it

leaden ice
void basalt
#

or that

leaden ice
#

!learn

tawny elkBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

leaden ice
#

They have animator tutorials

magic venture
# void basalt modify the scale of it

But there are two problems, the texture tilling and that I just want it to move towards an specific position and after doing so the next section to come up too.

magic venture
#

I tried playing the animation backwards but the -1 parameter doesn't works via script only in the editor.

void basalt
#

because I'm pretty sure you can set an animator to backwards speed in code

magic venture
void basalt
#

you need to post code if you want help

magic venture
#

I know that I need a variable for the gameobjects but idk how to continue it cuz I want to be able and select as many sections as I want so idk how to make the script that compatible.

void basalt
#

You should be in the beginner section.

magic venture
void basalt
#

I'm not being an asshole, but nobodies going to sit here and program features for your game

#

You've got to learn at least the basics.

magic venture
#

I just don't know how to implement this of the multiple sections extending thing.

void basalt
grim smelt
#

hey guys, any idea how i can improve my code for a missile to track a player? this is what i have right now

        Vector3 dest = _player.position;
        Vector3 orig = _missile.position;
        Vector3 diff = dest - orig;
        _missile.MoveRotation(Quaternion.LookRotation(diff));
        _missile.AddRelativeForce(0f, 0f, 55 * Time.deltaTime, ForceMode.VelocityChange);
#

the missile just keeps overshooting and having to turn around though

#

also tried implementing a velocity limiter which helps a bit but not much```cs
Vector3 preSpdLim = _missile.velocity;
var spdLim = new Vector3(
SpdLim(preSpdLim.x),
SpdLim(preSpdLim.y),
SpdLim(preSpdLim.z));
_missile.velocity = spdLim;

[...]

private float SpdLim(float spd) => spd >= 0 ? Math.Min(spd, MaxSpd) : Math.Max(spd, MinSpd);
cosmic rain
cosmic rain
#

(0, 0, 55)

#

You should use a variable defined elsewhere(probably the inspector?) instead

#

I'm also a bit sceptical about multiplying it with delta time.

void basalt
#

and they miss a lot

#

It would be more realistic to fire a bunch of dumb missiles at the target, where only like 5-10% of them are actually expected to hit

#

Haven't looked much at your code either, but the missile should be tracking a predicted target at the interception point

#

rather than following the ass of the aircraft

cosmic rain
#

Real missiles explode if they're about to miss the target.

void basalt
#

right

grim smelt
void basalt
grim smelt
#

also its not really supposed to me a "missile", more of a homing projectile

void basalt
#

firing at something flying in the air?

grim smelt
#

because theres this weird restriction in my assignment where i cant have anything resembling current weaponry

#

e.g. missiles

void basalt
#

yeah you'll still want to estimate the point of interception

#

and track that

grim smelt
#

yeah

void basalt
#

it's easier than you think

grim smelt
void basalt
#

exactly

#

something like that

grim smelt
#

cool, ill give it a try :)

grim smelt
void basalt
#

detect in a radius

#

and make it explode

grim smelt
#

although i guess i could .GetComponent<TargetHp>() and decrease the target's HP from the missile

void basalt
#

real missiles have shrapnel like a grenade, for scenarios like this

grim smelt
#

its just that the current code detects if the target touches a missile (from Target.cs)

#

maybe i'll redo that piece of code, i think its worth it lol :p

#

anyways, thanks!

hollow pelican
#

Hey, I have question about Collider2D.
I have a case when the colliders are not working when objects move fast. I searched on Unity forum, saw that it was issue reported since 2016 (or so) and now I am using 2022.2.20.
I have this video here to show the case: https://www.youtube.com/watch?v=dzwvdDDqYWk

cosmic rain
grim smelt
#

i was just gonna store the minimum recorded distance to the target

grand roost
#

hi I am having trouble getting a gravity working on my player. I am using character controller not rigid body could someone help me in a vc or something maybe or is that not allowed here

grim smelt
#

and if the current distance is greater than the minimum recorded distance, explode

void basalt
#

not move

#

it calculates the gravity automatically

grim smelt
grim smelt
#

alr ty!

quartz folio
#

The very first underline should make it pretty apparent

quaint rock
#

look at your braces

grand roost
#

found it

#

thanks

grand roost
void basalt
#

or your character controller's in-built collider isn't configured properly

#

or you have a ton of force downwards causing your character to clip through the floor

grand roost
#

this is on the floor

void basalt
#

read what I said

#

you also shouldn't have a box collider and mesh collider on the same object

grand roost
#

should i get rid of one of them and if so which one

void basalt
#

get rid of mesh

#

I doubt that's going to fix the issue

#

your character controller should also not have a collider

grand roost
#

I dont have a collider in it

void basalt
#

because the collider would be on your player.

#

not in your code.

grand roost
void basalt
#

is it slowly falling through the floor?

#

Can you see it while it happens?

grand roost
#

I watch it fall through when i press play

void basalt
#

make sure the floor has a green outline

grand roost
#

it starts where i have it but it just falls through the floor and keeps going

void basalt
#

the green outline is the collider

#

make sure it's at the correct size

leaden ice
void basalt
#

already solved that

grand roost
leaden ice
grand roost
#

cuz in the editor its red outline

void basalt
#

editor

leaden ice
#

Where is it

grand roost
leaden ice
#

This is what the box collider gizmo should look like

#

it's a green wireframe

void basalt
#

In the newer versions of unity the gizmos are so fucked

#

they don't show up half the time

#

they only show up for me if I disable them, then re-enable all of them

leaden ice
# grand roost

your object scale is 20/1/20 and the box collider size if 10/2.2/10 so it's going to be absolutely massive

#

200x200

grand roost
leaden ice
#

most of what options?

#

no ignore that script

grand roost
#

oh

leaden ice
#

just look at the green box in the scene view

#

just showing what it looks like is all

grand roost
leaden ice
#

whatever size you want

grand roost
#

1? because then its the same as the plane

void basalt
#

@grand roostIt should encapsulate your floor.

#

that's the size you want.

leaden ice
fluid lily
#

If I have a rigid body as a child object, is there a way to have the physics local so I can move the parent around without messing up forces.

void basalt
#

you can't parent physics bodies

leaden ice
#

Sort of like a "snowglobe" concept

grand roost
#

no green outline ?

fluid lily
leaden ice
#

in the center of the plane

grand roost
#

Oh

#

i see it now

#

I still fall through tho

#

should i record whats happening

void basalt
#

no, you should resize the collider

grand roost
#

i did now and it is lined up kind of

#

like where i want it to fall

#

its on there

void basalt
#

record your player falling through the green collider

#

please

#

If it actually is falling through, then you probably screwed up your physics layers

leaden ice
# grand roost

can you also show the inspectors of the "Cylinder" and "Main Camera" objects?

grand roost
void basalt
#

The video showed pretty much nothing useful

leaden ice
#

that will make it not a solid object

#

uncheck that

grand roost
#

still doesnt work

#

same thing is happenign

void basalt
#

open your player in the inspector

#

and show the character controller collider gizmos

#

there should be another green mesh around it

grand roost
void basalt
#

scene view plz

#

with the green around the player

grand roost
leaden ice
#

oh yeah haha

#

your mesh is way off

grand roost
#

there is no green around the player its omly on the box

leaden ice
#

the cylinder child is positoned at like 4, 6, 0

#

it should really be like 0,0,0

#

so it lines up with the capsule

grand roost
#

should it be at wherever my Player is or at 0,0,0

void basalt
#

No

#

It should encapsule your player

leaden ice
grand roost
#

wait theyre at 0,0,0

#

yeah sorry

leaden ice
# grand roost

press Z in the editor so you can get your tool handle position at the pivot

#

rather than center

#

center is confusing you

grand roost
#

i am now not falling

#

wait

#

it worked i think

grim smelt
#

is there a built-in method to get a sum of velocity vectors?

grand roost
#

thank you

grim smelt
#

in other words, find magnitude of the velocity vector given a Vector3

grim smelt
void basalt
#

@grim smeltvector.magnitude

grim smelt
#

thought i had to do some pythagoras theorem stuff

leaden ice
grim smelt
#

thanks

#

i was gonna start doing the math manually lol

leaden ice
#

I mean you even had the term correct

#

all you had to do was start typing it / check the properties 😉

grim smelt
#

haha

leaden ice
grim smelt
#

sum of vectors would just be matrix summation right?

void basalt
#

If you're that dead-set on doing it yourself, make yourself a little library

grim smelt
#

or whatever it called

void basalt
#

rather than doing it all by hand

leaden ice
grim smelt
leaden ice
#

oh wait that is matrix summation

#

so yes

grim smelt
leaden ice
twin hull
#

or +=

leaden ice
#

a += b is just a short way of writing a = a + b

#

it's still just +

twin hull
#

yup

#

it's worth checking out how they did the override just in case you need to do that to your own structs and stuff

ebon sluice
#

having a problem where the grounded check does not register properly when at the very edge of a platform even though its the same size as the boxcollider
i've had this bug since day 1 and havent been able to fix it
code: https://gdl.space/dovemaxage.c#

#

size for the boxcollider is 0.9 and the size for the grounded check is also 0.9 if not very slightly bigger

cosmic rain
ebon sluice
#

which is annoying because this is one of the most annoying bugs in the game

#

maybe there is something wrong with my code? i dunno

lean sail
#

How is that a unity issue, you seem to have just said what the issue is and why its inconsistent

ebon sluice
#

im stumped

cosmic rain
lean sail
#

Unless you intended to say that the ground check is larger than what you're asking it to be.

ebon sluice
#

i worded this weirdly

#

here

potent sleet
lean sail
#

That image fully looks like the player should be on the ground though

ebon sluice
#

i have no idea why even though its literally bigger than the collider

lean sail
#

Add a debug to draw the resulting box

cosmic rain
#

Ok, so it doesn't detect it

ebon sluice
cosmic rain
#

Yep, you just need to debug it.

lean sail
#

I dont remember the exact name it's like Gizmos.DrawWireBox?

cosmic rain
#

Nothing about it should be unity's bug.

ebon sluice
#

red is the grounded check

#

its literally larger than it

lean sail
#

How are u making this red area

cosmic rain
ebon sluice
#

the thin green lines are the box collider

#

the grounded check is literally larger than the box collider

#

or atleast

cosmic rain
ebon sluice
#

grounded size

#

if that's what you were asking

cosmic rain
#

What about scaling?

lean sail
#

I see 2 different numbers right there..

ebon sluice
#

yea the box size is larger than the collider

lean sail
#

I'm so confused on what the actual issue is

potent sleet
#

same tbh

lean sail
#

IsGrounded is false when it shouldnt be?

cosmic rain
ebon sluice
ebon sluice
#

its located on the player

potent sleet
#

also boxcast moves in a direction each cast idk if u want that or overlapbox instead

cosmic rain
#

And all the parents in the hierarchy

ebon sluice
#

the player is the parent

lean sail
#

I assume you would want overlap box too

ebon sluice
#

its just the script on the player

cosmic rain
ebon sluice
#

yes

#

which is why im so confused here

cosmic rain
#

All of the parents and the object itself have the default scale?

ebon sluice
#

yes

#

ill try using a different way to check grounded

cosmic rain
#

Okay. Try debugging the value of the box collider width and the box size variable before drawing the gizmos.

lean sail
#

I dont think the box cast would be affected by object scale

#

That sounds horrible if it's the case

ebon sluice
#

the grounded check is larger so why wouldnt it work

cosmic rain
#

Hmm

lean sail
#

Idk why we talking about the size of the object lol, something else is definitely the issue

ebon sluice
#

i can try using contactfilter

potent sleet
#

use overlapbox instead:)

ebon sluice
#

or that

lean sail
#

Casts work slightly differently in 2d and 3d so I dont think it's the same issue as 3d would have

#

Though u can just try overlap box anyways. No reason to really cast the box if it doesnt move

cosmic rain
#

Wait

potent sleet
#

a possibility also if its inside the collider iirc it doesn't detect it

cosmic rain
#

So the visualizationis correct!!!

#

Goddamit, you got me thinking that the gizmos sizes don't correspond to the numeric values!

#

Or do they...
?

lean sail
potent sleet
#

is it? i barely use 2D tbh. always doing 3D colliders with sprites when I do 2d 😛

lean sail
#

ive never used 2d, i just learned it cause 90% of the people here make 2d for some reason

potent sleet
#

unity is great for 2D not other engines like it

#

coming from game maker 7

twin hull
lean sail
#

quite the contrary for me, i have all the time because im avoiding implementing netcode for gameobjects

twin hull
#

why that specifically?

lean sail
#

its scary

#

rather fine tune my configurable joints for the next 10 hours

latent latch
#

netcode is easy

#

you just get your mate to do it for you

twin hull
#

@lean sail yeah but neither gets the game closer to release lol

lean sail
#

my game is relatively simple fortunately so theres a lot of stuff i can skip like most animations. Been coding for like 1 month and i think at this point i pretty much have all the working parts, its multiplayer/level design thats left. Pretty huge tasks but still

#

UI is a lot simpler than I thought

twin hull
#

for simple cases, sure.

latent latch
#

I dont understand where people get the patience for level design. Having to add little doodads all over the place is ugh

twin hull
#

they don't lol

lean sail
#

my patience is that I dont want to work in corporate for the rest of my life

twin hull
#

that's why procgen/roguelike is so popular

#

i'm still sitting in empty area because i dread actually working on that part

grim smelt
#

so, my missiles work now :D

#

currently i have a static image that displays on the canvas showing the position of a fired missile

#

its just a basic arrow like this

#

how can i rotate it to represent the missile velocity direction?

twin hull
#

@grim smelt #💻┃code-beginner . maybe even chatGPT or google, it's not a good idea to ask questions before giving a honest attempt at solving the problem.

lean sail
#

yea that one is pretty trivial for this channel, especially since i assume thats 2D

grim smelt
#

i wasnt sure which channel to ask it in lol

grim smelt
#

im not really sure where to start 😅

twin hull
#

quaternions :> everything related to rotation involves them :>

grim smelt
#

yep, thats definitely going on my list of "ways to rapidly disassemble brain"

twin hull
lean sail
#

you dont even really need quaternions for this, im sure euler angles would also be fine

#

although yea rotations are stored in quaternions

grim smelt
twin hull
#

@lean sail mate

lean sail
#

I know that quaternions have a euler angles field lol

grim smelt
lean sail
#

but that doesnt mean quaternions and euler angles are the same thing

twin hull
#

it's not a field, it's a method to translate euler to a quaternion and back

lean sail
#

yes i know that, which is why i said euler angles would also be fine

twin hull
#

i think AngleAxis is more appropriate for 2d anyway

lean sail
#

its just a way of saying a class has it, without really specifying what "it" is

twin hull
quartz folio
#

No, a member is what you describe

#

.eulerAngles is a property (and properties when compiled are just methods)

grim smelt
#

so i guess the first step would be to convert the absolute Vector3 (velocity) of the object to a Vector2 on-screen (in the current camera)?

#

not sure how quaternions would help with that

#

i guess i *could* take the WorldToScreenPoint at two points in time

twin hull
#

you want to rotate something, therefore you need to use quaternion.

grim smelt
#

and then find the angle between the two and set that to the icon rotation angle

grim smelt
lean sail
#

hm thats weird, ive always heard it called a field. maybe its more related to other languages, or just commonly used in place or member

lean sail
grim smelt
#

and if the missile is travelling to the bottom-left in this perspective the icon would be rotated 225 degrees right (or 135 degrees left)

#

this isnt the direction the missile is pointing though

#

this is the direction of its velocity vector

lean sail
#

so if the missle is pointing up but travelling down, you want to point down?

grim smelt
lean sail
#

you should be able to just use the velocity then

grim smelt
#

the only thing that matters is its velocity

#

so yes

#

how would RotateTowards help with this?

#

im not trying to rotate the missile between two orientations or anything

lean sail
#

dont think it would

grim smelt
#

oh

lean sail
#

uh i am really forgetting my linear algebra, i think cross product just be fine?

grim smelt
#

sorry, rotate what?

#

but why would i need to rotate the rocket

#

its not like it would change anything, it'd still be travelling in the same direction

lean sail
#

you can maybe use LookAt actually

grim smelt
#

you know what im just gonna make a round/symmetrical icon

#

so i dont need to worry about directionality

grim smelt
lean sail
#

this might just be hacky i dont know if this is a proper solution but try
transform.LookAt(transform.position + rb.velocity);

#

assuming its a rigidbody

#

u can just ignore the y or z component if u dont want the icon to rotate on those axis

grim smelt
#

alr, thanks

lean sail
#

might take some experimenting if this works lol

#

i just forgot all my linear algebra

grim smelt
lean sail
grim smelt
#

i mean i know what the method does

lean sail
#

basically point the image towards the velocity

grim smelt
#

i just dont get why we're passing it the argument we're passing

grim smelt
lean sail
#

giving it the transform.position as an offset so that the icon can be anywhere on the screen and not pointing at (0, 0, 0) constantly or like (1, 0, 0)
So you can imagine the velocity vector as starting from the middle of the icon

#

just imagine a line pointing out of the icon, that is the velocity. Your icon should rotate but probably ignore the x, y, or z axis. I dont know anything about 2D so i dont know which axis it is. though thatll be an easy experiment

grim smelt
#

ah, i see

#

that makes more sense, ty!

grim smelt
lean sail
#

nah u shouldnt have needed that at all

grim smelt
#

ah ok

lean sail
#

unless u want your icon to depend on something else

grim smelt
#

i see

steep prism
#

is there a way for me to force limit available ram, like you can with the framerate?

ashen yoke
steep prism
#

but what I am making needs to be able to run on devices with limited ram, wouldn't that then bring the question on how I can test with limited ram?

ashen yoke
#

you can observe the ram usage with profiler, Graphy, you can test on such devices or you can in theory test it on vm with limited mem

steep prism
#

alright, thanks

raven basalt
#

My original unity project had 3 cubes in it. However, when I committed it to github and redownloaded it from github, the unity project no longer had the 3 cubes, and had the following error in the console “[03:11:57] Rebuilding Library because the asset database could not be found”

For context, this was the gitignore file that was used

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
thin aurora
#

Note the first bunch of ignores have changed

#

maybe that is the issue

#

Where were those files located anyway?

raven basalt
#

I believe I used that version of gitignore too before, but Im pretty sure there was still an error

cosmic rain
#

Did you save the scene before commiting?

ashen yoke
#

that is correct behavior

lean sail
#

assets shouldve been pushed to git though

ashen yoke
#

but your cubes yes you probably just didnt save changes

raven basalt
#

I saved the changes in unity, and commited and pushed the changes

cosmic rain
#

Is that a screenshot from the past?😅

ashen yoke
#

can you find the scene file in the commit

raven basalt
thin aurora
#

Can you please share what the folder path was where your cubes were located

raven basalt
ashen yoke
#

can you find the scene file in the commit

thin aurora
#

So we can actually confirm it's not a gitignore issue

cosmic rain
raven basalt
ashen yoke
#

can you find the scene file in the commit?

thin aurora
lean sail
#

at least i assume thats what they did, thats what i did to test how it works in my first week

raven basalt
thin aurora
#

🤦

cosmic rain
ashen yoke
#

can you find the scene file in the commit?

thin aurora
#

Find the scene file

ashen yoke
#

where?

#

in the commit

#

commit <-------------------- SampleScene

raven basalt
plush sparrow
#

unity netcode client host connecting only in the same computer and not in other devices

ashen yoke
#

damn i love helping people

cosmic rain
river tangle
#

Hello everyone, please can someone help to achieve these looping effect❓

lean sail
thin aurora
#

The problem is that people ask 10 useless questions to a problem that is incredibly simple to debug

cosmic rain
#

The problem is that the problem was not explained properly.

thin aurora
#

Wrong gitignore? Check if the folder was related to the ignored files that were caused.

#

Not the problem? Go make a change to the scene and check if git picks that

lean sail
#

it was explained pretty clearly to me at least

thin aurora
#

It does? You simply didn't save

raven basalt
cosmic rain
thin aurora
#

The question was pretty clear, but the help certainly wasn't

#

Which is pretty rude to say, but it's pretty easy to debug the issue, and it's straight up ignored because of the cluster of messages

quartz folio
#

The git question is also not a code question

twin hull
#

@river tangle screenwrap or platforms?

river tangle
# lean sail What have u tried so far?

Tried to use two cameras for that, but I don't know if i need to instantiate the object from one side to another, or to move the map, then switch camera.. I 😵‍💫

quartz folio
old laurel
#

ok sorry, i didnt know that channel exists, imma just copy paste this question tho

river tangle
twin hull
#

@river tangle it's a common thing with endless runners so it's easier to search for that than to explain

river tangle
plush sparrow
#

can we use netcode to connect devices that are not in the same local network?

twin hull
#

parallax is completely unrelated

river tangle
cosmic rain
plush sparrow
river tangle
twin hull
#

literally anything that is related.
either "teleport" player or chunks of map, nothing that should be hard to google. maybe you'll even find a better way there.

cosmic rain
# plush sparrow not recommended? use miror pun2 then?

Photon works through a relay afaik. That's why it's not entirely free(the free tier is useless in production). I don't think mirror provides a relay service by default, so you'll need to use a third party services for that. Unity provides a relay service that you can integrate with Netcode easily iirc.

plush sparrow
#

can i dm you?

cosmic rain
earnest gazelle
#

Each building, item, etc. has different components
To load/save games with different type of items/buildings, which approach do you prefer?
One data component to pack all required data in all components of that gameobject
Each component handles data by itself
Also, it is suitable to use component based approach to get/store data of components for each item, building, etc.?

 public class ModuleData
    {
        public Dictionary<Type, IComponentData> Components;

        public T GetComponent<T>() where T : class, IComponentData, new()
        {
            if (Components.TryGetValue(typeof(T), out var componentData))
            {
                return componentData as T;
            }

            componentData = new T();
            Components.Add(typeof(T), componentData);
            return (T)componentData;
        }
    }
 public interface IComponentData
    {
    }

    public class ModuleComponentData1 : IComponentData
    {
        public int Data;
        public String Id;
    }

    public class ModuleComponentData2 : IComponentData
    {
        public float3 Rotation;
        public float3 Pos;
    }

    public class ModuleComponent1 : MonoBehaviour, IDataPersistence
    {
        public void LoadData(WorldPersistentData data)
        {
            var componentData = data.Modules[gameObject.GetInstanceID()].GetComponent<ModuleComponentData1>();
            //componentData.Data
            //componentData.Id
        }

        public void SaveData(WorldPersistentData data)
        {
            var componentData = data.Modules[gameObject.GetInstanceID()].GetComponent<ModuleComponentData1>();
            componentData.Data = 21;
            componentData.Id = "Hello";
        }
    }
building data
    component1 (data1)
    component2 (data2)
    component3 (data3)
clever drum
#

hey uh

#

i know c# and c but im not sure where to get started with unity

lean sail
ashen yoke
clever drum
#

any good places to go to?

thin aurora
#

Might be useful, who knows. It collects save data from components that are registered to save basically.

lean sail
tawny elkBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

clever drum
lean sail
thin aurora
#

I assume whatever loads and saves exists when you call this manager

thin aurora
#

I suppose it's not as bad when you consider this would be a problem either way, and you should use proper managers

lean sail
#

I mean its not bad, I think its very usable for the current game state like time of day/inventory/character equipment

#

A separate file for items that need to save at irregular times is probably ideal on top of that

thin aurora
#

It definitely is fixable though, I just didn't bother doing so since this was more meant as an example and not a solution

thin aurora
#

I could add that to the readme

lean sail
#

i was actually looking at yours when thinking of how to make my save system. I realized my saving would be very different though as im pretty much only saving what levels the user beat and what hat they have on lol

#

So mine just saves 1 file per class that needs it, and the key is just
string Key => GetType().Name; to get the name of the file

#

thanks for making that example still

clever drum
earnest gazelle
# lean sail you might have to specify a little more what you mean "component based approach"

I mean I can put all data of different components in one place and then save/load them.
For example in runtime, a building with type Building1 has three components, each component has its own runtime data. I can create a specific component to handle data.

The second approach I said component based approach, I mean I can create a dictionary with key gameobject instance and value a list of component data.

latent latch
#

I use the component thing and it works fine, especially when throwing together weapons with different modifications

ashen yoke
#

sounds overengineered in the wrong places

lean sail
#

i definitely wouldnt try to save a gameobject itself

#

even if it was the key

earnest gazelle
latent latch
#

yeah, break it down into SO data/GUIDs and paste it all together

#

oh, if it's runtime then im not too sure

ashen yoke
#

if you are serializing a game object hierarchy you have to care about

  • root it
  • internal component id
  • prefab link id
    the data could be just a game object serialization context, where for each serialized component you create a dictionary of string/string in case of json, and pass it to the serialization callbacks,
    but the ids, what to pass, should be handled externally by your save system
#
public void SaveData(ComponentSerializationContext data)
        {
            data[nameof(Data)] = 21;
            data[nameof(Name)] = "Hello";
        }
#

here you dont need pods, you can straight up write into container

cosmic ermine
#

my first time messing around with assembly definitions, and I'm getting a bunch of errors in visual studio now, but none in the unity console... Am I doing something wrong?

ashen yoke
#

mapping/resolving all that will be done by system, references also will be converted by it

#

and post load linking

earnest gazelle
#

It is runtime data

ashen yoke
#

so? you dont have references on runtime?

earnest gazelle
#

Prefabs? serialization context?!

hexed pecan
ashen yoke
#

dramatic, but what exactly am i failing to convey?

cosmic rain
cosmic ermine
hexed pecan
#

Do the regen proj files

cosmic ermine
earnest gazelle
ashen yoke
#

first one requires boilerplate, which does exactly the same and has the same problems

cosmic ermine
ashen yoke
#

because when you will be serializing your componentData object your serializer will still map the property to a string

#

with all the typical problems from that, like backwards compatibility of data

cosmic rain
cosmic ermine
#

ok yup regenerating the project files fixed it, thanks a ton!

ashen yoke
#

but in the second case you can add specific cases for upgrades

void Load(data)
{
  if(data.version < 4)
    this.SomeInt = data["SomeInt"];
  else
    this.SomeInt = data["DifferentNameInt"];
}
#

well you can use attributes and whatnot for your pods but you are still creating boilerplate

thin aurora
#

This will properly generate a csproj then.

earnest gazelle
#

You say it is better to save data as a dictionary like <string,object>

ashen yoke
#

it is simpler, solves the issue, is fast as it doesnt involve reflection

earnest gazelle
#

(PropertyName, Value)

ashen yoke
#

if you delegate this job to serializer lib, it will reflect your pod

#

with a dict it will just directly dump its values into the file

thin aurora
earnest gazelle
#

It has to keep types as well, so the bigger size

ashen yoke
#

you can even use some forward serializer like odin if you dont care for human readability

#

can be complicated but if you later decide to swap serializer, you dont need to change anything else in the codebase

#

all the Save/Load will still use the same SerializationContext or whatever api

#

but if you want to rely on serializer specific attributes in your pods, you are in for a massive refactoring

earnest gazelle
earnest gazelle
thin aurora
#

IDK how boxing works with ExpandoObject but if it's prevented then yes, it does work as an alternative

#

That said, it's terrible to use

ashen yoke
thin aurora
#

But still better if you don't want to create a wrapper

earnest gazelle
# ashen yoke component based what?

For each gameobject with different components.

 public void LoadData(WorldPersistentData data)
        {
            var componentData = data.Modules[gameObject.GetInstanceID()].GetComponent<ModuleComponentData1>(); // here
        }

        public void SaveData(WorldPersistentData data)
        {
            var componentData = data.Modules[gameObject.GetInstanceID()].GetComponent<ModuleComponentData1>(); // here

        }
#

Keep data for each component separately

ashen yoke
#

i dont understand why do you need this

earnest gazelle
#

Because maybe different components have same property name in your approach!

ashen yoke
#

im bad at explaining

#
class GameObjectSerializationContext
{
    public int id;
    public List<ComponentSerializationContext> components = new();
}
class ComponentSerializationContext
{
    public int localId;
    public Type type;
    public Dictionary<string,string> data;
}
class SomeComp : MonoBleghvior
{
    public Save(ComponentSerializationContext ctx) ..
    public Load(ComponentSerializationContext ctx) ..
}
#

which ComponentSerializationContext to feed into Save() will be handled by SaveSystem

earnest gazelle
thin aurora
#

You need to explicitly define an id here

ashen yoke
#

that approach should be multi phased btw for reference resolution

#

because on load , first all the gameObject/components should be constructed

thin aurora
#

So that's a way to do this

ashen yoke
#

then you do another pass that converts serialized references between them into actual references, and invoke the Load second time with special flag

earnest gazelle
cosmic ermine
#

just got this warning, is it anything to be concerned about?

earnest gazelle
ashen yoke
#

instance id is meaningless

#

i dont know a single use case for it

#

maybe networking

thin aurora
#

It's unique in the runtime context, so it makes sense to use it here

earnest gazelle
#

The code above was raw I know it was wrong, you are right.

thin aurora
#

It becomes useless if it's more than that

ashen yoke
#

to map serialized references within a single session between clients

earnest gazelle
#

The keys are guid of that element, not instance id.
I have guid for each asset.

simple ridge
#

HI everyone, I was wondering if anyone could see anything wrong with some code:

private IEnumerator Animate()
{
    // Set All Points To Invisable
    foreach (CosmeticBall ball in _cosmeticBalls) ball.SetOpacity(0);
    
    // Iterate Over points lighting up the first point 
    float timeElapsed = 0;
    while (timeElapsed < PropagationDuration + TrailLength)
    {
        int points = _pointObjects.Count;
        for (int i = 0; i < points; i++)
        {
            float weight = Mathf.InverseLerp(0, points, i);
            float x = timeElapsed - (PropagationDuration * weight);
            _cosmeticBalls[i].SetOpacity((x) switch
            {
                { } value when (value < 0) => 0,
                _ => Mathf.Lerp(FadeAlpha, 1f, EvaluateCustomWeibull(x * (1f / TrailLength)))
            });
        }
        
        timeElapsed += Time.deltaTime;
        yield return null;
    }
}

This seems code is meant to take in a trajectory of of a ball and then slowly make it opaque as if it was moving down the trajectory with a semi transparent tail. This seems to work completely fine on my PC but my team is saying that the trajectory lights up imidiatly for them. This has been tested on 4 different PC's including my own, and only mine seems to work. Is there a reason that coutines would behave differently between devices? And specifically is there something in this code that would cause that? To me this seems pretty straight forward and I'm not doing anything overly complicated so I wouldn't have though so.

lean sail
#

the code will run the same on each pc. Its stuff like framerate where variations start to occur.
Also maybe u have a SerializeField value set to be something u didnt push

ashen yoke
#

some assets in a folder named Temp,
this ```cs
(x) switch
{

in the lambda can be unsopported on their installs if some language features werent enabled but you would get errors
simple ridge
lean sail
#

On your pc, try pulling the project to a separate location and run it from there

ashen yoke
#

add asserts/logs for every variable and push, ask to give you logs back

simple ridge
#

I'll give that a try, see if I get the error still

lean sail
#

that way none of your current project settings are used

earnest gazelle
knotty sun
chilly beacon
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding;
using Unity.VisualScripting;

public class EnemyMovement : MonoBehaviour
{
    public Transform target;
    public float speed = 10f;
    public float nextWaypointDistance = 3f;

    Path path;
    Rigidbody2D rb;
    Seeker seeker;

    int currentWayPoint = 0;
    bool reachedEndOfPath = false;
    void Start()
    {
        foreach (Transform enemy in transform)
        {
            seeker = enemy.GetComponent<Seeker>();
            rb = enemy.GetComponent<Rigidbody2D>();

            if (!rb)
            {
                rb = enemy.gameObject.AddComponent<Rigidbody2D>();
                //rb.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
                rb.gravityScale = 0f;
                rb.freezeRotation = true;
            }
            if (!seeker) 
            {
                seeker = enemy.gameObject.AddComponent<Seeker>();
            }

            seeker.StartPath(rb.position, target.position, OnPathComplete);
        }
    }

    void OnPathComplete(Path p)
    {
        if (!p.error)
        {
            path = p;
            currentWayPoint = 0;
        }
    }
    void FixedUpdate()
    {
        if (path == null)
            return;

        if (currentWayPoint >= path.vectorPath.Count)
        {
            reachedEndOfPath = true;
            return;
        }
        else
        {
            reachedEndOfPath = false;
        }

        Vector2 direction = ((Vector2)path.vectorPath[currentWayPoint] - rb.position).normalized;
        Vector2 force = direction * speed * Time.deltaTime;

        rb.AddForce(force);
        float distance = Vector2.Distance(rb.position, path.vectorPath[currentWayPoint]);
        
        if (distance < nextWaypointDistance)
        {
            currentWayPoint++;
        }
    }
}
#

can someone tell me why my enemy isnt following the player i have added the correct

#

and it doesnt seem to work

ashen yoke
#

@chilly beacon wait for p.IsDone()

#

wait its a callback nvm

#

log p.CompleteState

#

remove deltaTime from force

chilly beacon
ashen yoke
#

exactly

#

thats why you dont need it when you apply force with forceadd

chilly beacon
#

o kwait

chilly beacon
#

no change the enemy doesnt move

ashen yoke
#

sufficient force value?

chilly beacon
ashen yoke
#

crank it up

chilly beacon
#

still no change

#

the enemy doesnt move

ashen yoke
#

alright, do you know how to use the debugger?

chilly beacon
#

i have dont anything on the pathfinder a* component

ashen yoke
#

no graphs

chilly beacon
#

and unity

fervent furnace
#

is there any friction?
if not setting velocity maybe better....when reach the point then set the velocity to zero and set a new 2d velocity vector

chilly beacon
ashen yoke
#

Astar.Scan

chilly beacon
#

just click scan button?

ashen yoke
#

in code

#

when you done generating the map

#

first create the graph in editor

#

doesnt matter if its empty

chilly beacon
#

ok

#

then

ashen yoke
#

then call AstarPath.active.Scan(); at runtime

chilly beacon
#

but how

ashen yoke
#

map gen editor?

#

you wrote it right?

chilly beacon
#

yeah

#

the gen works smooth

ashen yoke
#

and you dont know where your generation ends?

chilly beacon
#

i know where it ends

#

but do i scan the tilemap?

ashen yoke
#

i dont know what you should do to make it work with 2d

#

setup a test case in editor

#

learn how it works with tilemaps

chilly beacon
#

hm

ashen yoke
#

make it work on a separate simple test case first, then transfer that to actual game code

chilly beacon
#

i mean the graph is bascally there for a guide that this places are not where the enemy can walkthrough

#

right?

ashen yoke
#

graph is there to compute the path

#

no graph no path

chilly beacon
#

ooo

ashen yoke
#

yes enemy can follow the player without a graph, but you wont be using path

#

just direct movement with transform

chilly beacon
#

hm

#

ok let me try somethig

earnest gazelle
ashen yoke
#

if its a voxel you should only store position + voxel type int, and it should probably be chunked, and SOA

earnest gazelle
# ashen yoke i dont understand

It has other properties as well, like level (for liquids), etc.
It is chunk based, yes and 1d array voxels (it is 3d originally)

earnest gazelle
#

Because we use MessagePack lib to serialize/deserialize data, in MessagePack you can serialize data by name or key id
My colleague says use key id for each property, so it does not depend on property name

#
 [MessagePackObject]
    public class PersistentData
    {
        [Key(0)] public int Field1;
        [Key(1)] public float Field2;
    }
ashen yoke
#

yeah nah

#
public class Chunk
{
    public int[] type;
    public int[] waterLevel;
    public float[] damage;
}
earnest gazelle
#

Voxel is struct

earnest gazelle
ashen yoke
#

my opinion is dont use AOS use SOA

#

for both serialization and game code

earnest gazelle
#

My question is about the prior argument about backward compatibility

#

if a property name changes

ashen yoke
#

nah its still the same, for serialization you will get massive gains if you dont have to serialize each voxel separately

earnest gazelle
#

I say if I serialize/deseirliaze them as key ids, it is solved

ashen yoke
#

you directly writing each property as a massive array

#

which means that if you use any library that resolves prop types and has abstractions you will be saving cycles because you just dont resolve anything you are directly writing arrays in place

fervent furnace
#

Use AOS or SOA should be depended by the use case
For those data that needed to be used at the same time i will group them into a struct

ashen yoke
#

yes

earnest gazelle
#

My problem assign keys or names?

 [Key(0)] public int Field1;
 [Key("field1")] public int Field1;
#

and because it has added an abstract layer to serialize/deseriliaze data, saving data as <propertyName,object> is logical still?

ashen yoke
#

with attributes you can solve any backwards compatibility issue, just create new ones, slap them all over

#

but it defeats the purpose of what i was proposing earlier

chilly beacon
#

@ashen yoke so i added the

#

asther scan on my gen code

#

and i also changed up the enemy script a little bit

#

but it still doesnt work the enemy doesnt move

#

no reaction from the red buddy

crude umbra
#

Hi all, Screen.dpi returns a float of the screen's DPI (as you'd expect), but according to the Unity docs, on android devices it returns "densityDpi which is a logical bucket that contains a range of DPI values". What type is a logical bucket? An array? A list? I don't have an android device to test on, and have no clue what type this returns.

prime sinew
#

if you click on the thing that says this forum thread

#

then click on the hyperlinked densityDpi

#

you'll find that

heady iris
#

ah, so it's an enum

#

and each enum value is an actual dpi value

warm stratus
#

Hey, someone knows why it s blur?

heady iris
#

Looks like you're using the legacy Dropdown component

#

Are you using any TextMeshPro components?

warm stratus
#

legacy

heady iris
#

You'll want to use TextMeshPro. The legacy Text components behave very poorly when scaled up.

warm stratus
#

ok thks i try

#

it works thks

heady iris
#

If you've written any code that works with the dropdown, it'll need to be changed to work with the TextMeshPro dropdown

#

it's a separate component

warm stratus
#

ahh

#

it dont work with Text textZone; ?

crude umbra
heady iris
#

TMP_Text is the type for referring to TextMeshPro text elements. You will probably want TMP_Dropdown here, though, since that's the component that runs the dropdown

#

both of these are namespaced under TMPro

warm stratus
#

ok i try something

#

@heady iris

#
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class TranslateText : MonoBehaviour
{
    //refs
    private TextMeshPro textZone;

    //const
    [SerializeField] private string textName = "None";

    private void Awake()
    {
        textZone = GetComponent<TextMeshPro>();
    }

    public void ChangeText(LangagesManager _langagesManager)
    {
        textZone.text = _langagesManager.GetText(textName);
    }
}
heady iris
#

This is not how you should use a dropdown. You need to configure it with a list of choices.

warm stratus
#

that first for a textMeshPro

heady iris
#

Oh, I misunderstood

#

That works, yes

#

er

#

TMP_Text, not TextMeshPro

warm stratus
#

no it don t work

#

ah ok

#

perfect thks

static matrix
#

this wasn't doing this before, anyone have any ideas why?????

#

(Click the image for expand)

quartz folio
#

where is the code question

static matrix
#

im, sorry, where should I ask this then???

quartz folio
static matrix
#

oki

#

sorry this is just so weird

wild nebula
#

How do you guys remove lag from first prefab instantiation

leaden ice
#

There shouldn't be any

wild nebula
#

Strangely it does

leaden ice
#

Use the profiler to see why

wild nebula
#

You're right its 90% editor loop

#

Huh hmm

leaden ice
#

likely not a concern then

heady iris
#

ye

frail meteor
#

I'm triyng to use the Oculus VR lipsyinc plugin for Unity on a WEBGL build but it doesnt work.
Can somebody please help me figuring out why? It worked fine in the editor.

quartz folio
#

Does it support WebGL?

#

Doesn't look like it.

frail meteor
timid crater
#

Hello, How to move a UI element placed next to a Text, as the text expands? like there are more characters being added into that text and it overlaps the UI element next to it

quartz folio
heady iris
#

indeed: you can solve this with no code.

timid crater
#

I have tried, that's why I'm asking it in code channels..

#

Doesn't work*

#

If y'all know a non-coding way, I'd be grateful

heady iris
timid crater
#

Watch me come back here because there won't be a non-coding solution

heady iris
#

?

misty reef
#

Hi! Does anyone know why I can't unsubscribe this event from the Unity EventBus class that handles visual scripting events? The 'OnEventRecived' keeps getting called even if I destroy the object the script is attached to. Thank you

protected delegate void OnEventRecivedDelegate(string id);
protected OnEventRecivedDelegate EventRecived;

public override void Start()
{
    EventBus.Register<string>(EventsType.EventRaised, id=> EventRecived(id));

    EventRecived = new OnEventRecivedDelegate((id) => OnEventRecived(id));

}
public override void OnDestroy()
{
    EventBus.Unregister(EventsType.EventRaised, EventRecived);
}
thin aurora
#

Subscribing/unsubscribing work by reference so you can't unsubscribe something that is subscribed as an anonymous delegate, because the compiler has no clue it's related to anything since it's not bound to the same reference.

#

You need to pass an actual method because that will be the same reference.

leaden ice
#

then unsubscribing will work properly because you will have subscribed and unsubscribed the same delegate

#

Pretty sure you can just do this too:

EventBus.Register<string>(EventsType.EventRaised, OnEventRecived));
EventBus.Unregister(EventsType.EventRaised, OnEventRecived);```
#

your lambda isn't doing anything in particular so you might as well just directly register your method

heady iris
#

I'd expect it to be the same reference...

thin aurora
#

No, then it's the same reference