#💻┃code-beginner

1 messages · Page 327 of 1

rich adder
#

why would camera have physics.

rocky canyon
#

i thought u have already moved it once tho?

chrome tide
crystal chasm
#

Maybe, just maybe resize the collider instead of moving the mesh.

rich adder
#

unless you had a physics body

#

Update() should be fine for camera rotation

chrome tide
# rich adder not really

ok. anyways, if i want the camera to be framerate-independent, then should i use FixedUpdate() or Time.DeltaTime ?

summer stump
chrome tide
rocky canyon
summer stump
rocky canyon
# rocky canyon

if ur animation is locking it on the Y so u can't move it downwards create a Container for it and move that down instead

rich adder
chrome tide
rich adder
#

also the two are not related (FixedUpdate . Time.deltaTime)

chrome tide
#

i will try doing both Update and LateUpdate, i'll see what works better for me

molten dock
#

is there a way to only pause one scene

hollow dawn
#

should i just restart the whole thing?

rich adder
#

there is no pause function

molten dock
#

yeah with time.timescale

rich adder
#

that only works for limited objects

molten dock
#

that is okay

rocky canyon
#

thats gonna change the timescale for everything..

rich adder
#

i think its a global setting , doubt u can do it per scene

#

you would have to do it individually, custom Constant

molten dock
#

so pause singular objects

rocky canyon
#

ya, could use a boolean in each script u want to pause.. for example

rich adder
#

is there specific reason you need to only pause one scene

rocky canyon
#
if(!paused){
//do all the logic u were already doing
}```
summer stump
rocky canyon
#

if its possible that is

molten dock
#

im having it load a new scene upon hit and then when that new scene is completed it goes back to the original

#

so i need the stuff in the scene i load out of to stay in place

#

am i wrong to think that unity probably should have added some scene.pause function or something

crystal chasm
#

You just need to save the position and velocity of all the objects, and the state of all your scripts, and then reload that.

molten dock
#

okay

crystal chasm
#

Or, don't load in a new scene, just do it on another layer of your existing scene.

molten dock
#

thank you

#

i think layer is a good idea for me cause i am not that good at coding to know how to do the other one

brittle isle
#

Making a pacing enemy detect bottomless pits

winter fractal
#

can someone help me about a raycast problem?

#

I dont know why, my enemy dont generate raycasts

winter fractal
#

sorry, I mean if this was the place for it xD

summer stump
winter fractal
#

I have that code

#

well, is part of the code

#

basically is a state machine for a fps enemy

#

when the enemy is searching, the idea is that it generates a raycast

rich adder
#

so did you check the Debug.DrawRay

winter fractal
#

yep

#

no sign of the array

rich adder
#

array ?

winter fractal
#

sorry

#

I mean raycast

rich adder
#

did you enable Gizmos in the Gameview

#

either script is not running or your ray doesn't have correct values

winter fractal
#

this option right?

rich adder
#

well yeah if you are observing it in scene view during playmode

#

otherwise in gameview it has its own toggle

#

move it outside of the If statement of ray

winter fractal
#

I think everything is alright

rich adder
#

defeats the whole point of debugging drawing a ray only if hits

winter fractal
#

oh thats right

#

just under raycasthit right?

rich adder
#

put it above the if statement

#

maybe the origin being wrong
0.5f
I think you want

Vector3 pos =myEnemy.transform.position;
pos.y += 0.5f;
var ray = new Ray(pos, myEnemy.transform.forward)```
winter fractal
#

ok

#

I see the raycast

#

is extremely far from the enemy

rich adder
#

where is it

winter fractal
#

wait, let me post an image

#

it will be clearer

rich adder
#

ok. your gameObject origin point is prob not where you think it is

winter fractal
#

shouldnt originate from the collider?

rich adder
#

transform.position doesn't use the collider

#

are you in local pivot mode

winter fractal
#

youre right

rich adder
#

also can barely tell whats going on in that image

winter fractal
#

sorry for the bad quality xD

#

Ill try to zoom more

#

or even post a video

molten dock
#

might need ray.position = transform.position

rich adder
winter fractal
#

I had it on center instead of pivot

#

but the problem remains

#

is extremely strange

rich adder
#

switching it from Local to Center is not the fix

#

its simply to view the true Pivot poiint

#

you have to show what myEnemy is

rocky canyon
#

that way when you use transform.position you know what position that is

#

i think [Pivot] [Local] should be the default setting

rich adder
#

yup been preaching it for years

rocky canyon
#

lol

winter fractal
#

my enemy is that small cube

rich adder
#

unity wont listen.

#

it confuses things for those who don't know those will create alignment problems later

winter fractal
#

myEnemy* sorry

#

the strange thibg is that, depending on how I move the camera

#

the ray cast move

rich adder
#

that cube is linked in the inspector for the field myEnemy ?

#

cause the forward doesn't match up if thats the ray being drawn

winter fractal
rich adder
#

the script you sent

#

has a field myEnemy

rocky canyon
#

myEnemy.transform.forward * 100f this should be drawing the debug ray directly on top of the blue axis

winter fractal
#

the enemyAI script

rich adder
winter fractal
#

enemyAI myEnemy;

#

is not calling

#

I'm terrible with the terminology sorry

rich adder
#

ok and show where you put that script enemyAi

#

no crop

rocky canyon
#

we need that to be an emoji

rich adder
#

make sure object full inspector is visible with hierarchy

winter fractal
#

ok

rich adder
winter fractal
#

jesus man

rocky canyon
#

its like no cap but no crop

rich adder
#

!nocrop

winter fractal
#

from your point of view guys is probably like talking to a gorilla xD

rocky canyon
#

lol, nah we're just being thorough

winter fractal
limber robin
#

Sorry if I'm interrupting something, hopefully this is an easy answer. I'm trying to get a bullet to pass through the player as if they don't exist. However the bullet still slows down when passing through the player. Why would this be and how can I fix it?

rich adder
limber robin
#

thats what I expected, but Im not sure how to fix it lol

slender nymph
#

physics step happens before OnCollisionXXX runs. why not just make the bullet a trigger instead?

rich adder
#

maybe layerbased on do it in the beginning

winter fractal
#

from a cenital point of view it seems that the raycast is originating from the cube

#

but it stills not collides with the player

rich adder
#

the direction is wrong though

#

transform.forward should be on blue

winter fractal
#

oh

rich adder
winter fractal
#

what is happening then, I'm starting ti hate these things xD

#

oh, nope

rich adder
winter fractal
#

got lost into the conversation

#

hahaha

#

thanks man xD

#

ill modify the script

rich adder
#

worth a shot lol

#

it might be grabbing Y as world pos and causing weird skew

winter fractal
#

I'm sorry (again), but in that code that you pass me should I just change the variables or copy paste?

rich adder
#

for both DrawRay n Raycast

winter fractal
#

again, a troglodyte question but honestly I'm therrible at programing

rich adder
#

well its easier to start with the basics instead of already doing raycasts and state machines lol

winter fractal
#

yea...

valid roost
#

does anyone have any idea on why this happens

winter fractal
#

I'm honestly trying to adapt but is difficult

slender nymph
rich adder
valid roost
#

i see..

winter fractal
#

man, I dont know where to paste it xD

rich adder
valid roost
limber robin
rich adder
winter fractal
#

like this¿

rich adder
#

well you have to use the variable now

#

also where is the red DrawRay

winter fractal
#

oh sorry I change it to blue before

rich adder
#

then it should not be nested inside Physics If statement

#

put above it like i said earlier

winter fractal
#

before the first if

#

got it

rich adder
#

also dont put the *100 inside the ray

#

that was myb, edited

winter fractal
#

Debug.DrawRay(ray.origin, ray.direction , Color.blue); like this?

winter fractal
#

but isnt this like in your code?

#

minus the *100

#

damn Im dumb

rich adder
#

looks fine

#

show result

winter fractal
#

there it is!

#

(change it to red again, seems clearer)

#

but I dont undertand

#

why it still dont detect the player?

#

I put the FPSController right in front of the ray and still nothing

#

the tag is correct

rich adder
#

you. already looked visually

#

now debug the hit

#

Debug.Log the raycast hit's collider name/tag etc

#

also did you put 100? cause that doesnt look like *100

winter fractal
#

well, I already have this

rich adder
winter fractal
#

that debugs if the raycast hits a collider

rich adder
#

you're still using the old incorrect one?

onyx tusk
#

it's debugger, black is a List<ChessVector/*(my custom class)*/>, why it can not work?

hollow dawn
#

how can I add first person animations? like when im standing still I want a idle animation to play,when walking I want a walking animation to play. all the videos I find are hard to understand cause they don't explain things properly and they edit the video and everything is too fast.

winter fractal
#

it works! @rich adder

#

how do i apply the *100 btw?

#

it smalls but works

#

jeje

rich adder
willow scroll
rich adder
#

btw .CompareTag("Player") is better than ==

winter fractal
rich adder
#

oh right make it longer if you mean length
forgot default is like 1 length

winter fractal
#

yea

#

sorry again for my terminology

slender nymph
willow scroll
#

There are quite a few overloads

rich adder
#

you can use length: and order wont matter

#

but other params will need i think

#

too bad

wintry quarry
willow scroll
wintry quarry
#

List doesn't use == to compare things

onyx tusk
#

no

wintry quarry
#

You need to implement Equals and HashCode

onyx tusk
wintry quarry
#

code row?

winter fractal
wintry quarry
#

What's a code row?

winter fractal
#

thanks a lot guys

rocky canyon
onyx tusk
short hazel
#

object notNull1 = null ?? v1
what?

willow scroll
rich adder
winter fractal
#

seems good in game

rocky canyon
rich adder
winter fractal
#

Im going to also apply it to the drawray

rich adder
rocky canyon
#
        private void OnDrawGizmos()
        {
            if(draw)
            {
                if(success)  Gizmos.color = rayHitColor;
                else  Gizmos.color = rayColor;
                Gizmos.DrawRay(transform.position,targetDir * rayDistance);
            }
        }```
#

i like to use OnDrawGizmo's function

#

or ...GizmosSelected()

#

then u can just use the same ray just as it is

#

(if u construct a ray for ur raycast, that is)

rich adder
willow scroll
rocky canyon
#

lol i knew it!

winter fractal
#

is ok thought, the lenght multiplier works fine in game

rocky canyon
rich adder
rocky canyon
willow scroll
rich adder
rocky canyon
#

how?

rich adder
#

😦

willow scroll
rocky canyon
#

ohhh

rich adder
#

i think you can let VS refactor it for you

rocky canyon
#

i let it build the switch.. thought it was good enuff haha

rich adder
#

ctrl + .

rocky canyon
rich adder
#

less lines = better code. amirite?
/s

winter fractal
#

also, want to ask, are there easy solutions in code to hide a mechanic until the player touch a special gameobject? Im making a small metroidvania and I know there are better solutions than having to set on and off 3 different character with 1, 2 or 3 mechanics

willow scroll
rich adder
winter fractal
#

lol, thats brilliant

rich adder
#

keep it simple

winter fractal
#

thx man

rocky canyon
#

apply that to everything from now

#

if u dont see it, turn it off 😄

#

performance gains!

rich adder
#

I used to have bools spammed everywhere

#

my inventory basically was a bunch of bools 😆

#

good times

winter fractal
#

my original plan was to just set off the character that unlock the ability and set on another character with that ability

#

but that is barbaric xD

rich adder
#

depends, if the character has to change much it might make sense to only switch visuals

winter fractal
#

(barbaric for a programmer, I butcher the sacred code of C# with my letters mind)

winter fractal
#

it will have like 2 o 3 power ups

crystal chasm
#

It's for an elevation model

rich adder
#

black mesa 2 ?

crystal chasm
#

GenerateElevationGrid(mesh, Resolution, new Vector3(-0.5f, 0.0f, -0.5f));

#

Black Mesa 2?

rich adder
#

yea just silly joke

crystal chasm
#

I see. It is not that. It's google earth as a mod for a flight simulation

#

But it only works at half the resolution it could

rich adder
#

Ohh cool so you're trying to modify the terrain

crystal chasm
#

I generated the terrain at runtime. I'm just trying to make the mesh a higher resolution

stuck palm
#

How can i convert a ModelImporterClipAnimation to an animation clip?

lost anvil
#

is there anything about this script to handle my game's AI i could improve? - i want a nice, neat, hopefully flexible script.

https://gdl.space/ofefigajig.cs

deft grail
#

!code

eternal falconBOT
proven canopy
#

Yes my bad sorry, didnt mean to send yet

rich adder
lost anvil
rich adder
#

also tbh
}
else
lookTarget = baseLookAt;

imo without {} it doesn't look as good

#

not a fan of doing that esp if its nested inside other if statements

lost anvil
#

👍

rich adder
summer stump
#

It's really a game changer when you get used to early returns

rich adder
#

so much cleaner without all the indents everywhere and {}'s

gritty parcel
#

sorry

sick ocean
#

My first code ^_^

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Windows;

public class PlayerScript : MonoBehaviour
{

    public float Speed = 0.006f;
    public float HSpeed = 0.009f;


    void Start()
    {
      

    }


    void Update()
    {
        // Player Movement 
        if (UnityEngine.Input.GetKey(KeyCode.A) || UnityEngine.Input.GetKey(KeyCode.LeftArrow))
        {
            transform.Translate(new Vector3(-Speed, 0, 0));
        }
        else if (UnityEngine.Input.GetKey(KeyCode.D) || UnityEngine.Input.GetKey(KeyCode.RightArrow))
        {
            transform.Translate(new Vector3(Speed, 0, 0));
        }
        if (UnityEngine.Input.GetKey(KeyCode.A) && (UnityEngine.Input.GetKey(KeyCode.LeftShift) || UnityEngine.Input.GetKey(KeyCode.LeftArrow) && (UnityEngine.Input.GetKey(KeyCode.LeftShift))))
        {
            transform.Translate(new Vector3(-HSpeed, 0, 0));
        }
        else if (UnityEngine.Input.GetKey(KeyCode.D) && (UnityEngine.Input.GetKey(KeyCode.LeftShift) || UnityEngine.Input.GetKey(KeyCode.RightArrow) && (UnityEngine.Input.GetKey(KeyCode.LeftShift))))
        {
            transform.Translate(new Vector3(HSpeed, 0, 0));
        }


    }
}```
deft grail
#

can easily bring this code down to 3-5 lines which would make it a lot cleaner and nicer to read

sick ocean
#

Thanks ^_^

deft grail
#

and set its .velocity or use AddForce()

sick ocean
deft grail
rocky gale
#

https://hastebin.com/share/ilepizawuc.csharp how come when the katana hits an enemy it comes back fine but if it doesnt hit an enemy it just flies off into the distance

deft grail
rocky gale
wintry quarry
rocky gale
wintry quarry
onyx cove
#

Hello is it possible to put multiple collider in a procedural mesh ?

rocky gale
deft grail
wintry quarry
rocky gale
wintry quarry
#

because you cannot start a coroutine with Invoke

#

just start the coroutine

rocky gale
#

i did

#

but it does what i told you

wintry quarry
#

and put yield return new WaitForSeconds(time); as the first line

deft grail
wintry quarry
wintry quarry
#

it will start when you call StartCoroutine

#

Show the code

rocky gale
#

IEnumerator FollowHand()
{
yield return new WaitForSeconds(timeForKatanaToReturnAfterThrown);

    while (Vector3.Distance(transform.position, hand.position) > .2f)
    {
        returningSword = true;
        rb.velocity = (hand.position - transform.position) * returnForce;
        returnForce += Time.deltaTime * 5;
        transform.Rotate(returnSpinSpeed, 0, 0);
        yield return null;
    }

    CatchSword();
}
wintry quarry
#

ok but where did you call StartCoroutine

rocky gale
#

samw place as where invoke was

#

i replaced it

wintry quarry
#

then it will be fine

rocky gale
#

its not tho

wintry quarry
#

Add Debug.Logs to your code

#

Honestly you've made this quite overcomplex

#

and there's a lot of moving pieces

polar acorn
wintry quarry
#

Start adding log statements so you can figure out what's actually happening

wintry quarry
#

with logs

#

(and by showing the new code)

rocky gale
rocky gale
deft grail
rocky gale
#

where

deft grail
wintry quarry
#

show the code

rocky gale
wintry quarry
#

put a log right before the WaitForSeconds

#

and right after

#

like "Starting cooldown before following hand". and "Cooldown over, starting to follow hand now"

rocky gale
#

ok

rocky gale
polar acorn
# rocky gale https://hastebin.com/share/umejikahey.csharp

Okay, so, you throw the sword by giving it a force and starting up two timers. One spins the sword until it starts to return. The other waits some period of time before it returns.

Additionally, whenever this object collides with an enemy, you cancel any existing spins and returns, then start up another wait and return

rocky gale
wintry quarry
#

it's doing exactly what you tell it to do

#

so it sounds like you need separate functionality for when thrown vs when colliding

#

when it collides you want to start returning right away

#

when it's thrown, you want to start a cooldown, after which it returns right away

#

you can just add a parameter for how long to wait to the coroutine if you wish

#

that would be one simple way to do it

rocky gale
#

so i just change the cooldown to 0 if it collides

wintry quarry
#

you don't "change" the cooldown, you just pass in 0 as the parameter

rocky gale
#

yes

#

thats what i meant

wintry quarry
#

and pass in the normal cooldown in the other case

rocky gale
#

ok

rocky gale
sour patio
#

there really isn't a good place to ask this... but someone pushed changes to a scene that they shouldn't have and now unity is saying the file is confliceted when the good copy was recovered from stash. How is it even possible the stash file was changed? how do I get my copy of the scene back

#

(involving git)

dense mica
#

What strategies are advised for managing game object hierarchy during runtime? I've not really concerned myself it thus far, but after a while of using Instantiate()... the Scene Heirarchy is unusable with thousands of objects listed. I've been pondering if its at all useful or feasible to try and collect them under other objects, if only to make the Editor faster and for my own sanity. Do folks generally do that at some point? Or am I missing a design principle here that I should be using?

short hazel
sour patio
#

unity says that

#

not git

short hazel
#

Ah, yeah they might have the same unique identifier

deft grail
#

also what are you instantiating?

#

if its bullets or something you can use pooling

dense mica
#

Nah, not bullets. Say I have 32 doors on the map, 10 altars, 50 beds, a couple cabinets, and 150 NPCs.

#

I've not really paid much attention to where the objects end up. They are all tracked/managed by other objects. I could stash them under those manager objects. Just hadn't really thought about if its useful beyond keeping the Editor organized.

deft grail
dense mica
#

Yes, for example when loading the map from a JSON file to build it up

#

My current architecture is a reusable scene where the specifics of the map are all loaded dynamically from JSON files created with an editor I wrote.

deft grail
dense mica
#

Cool. That is what I figured. Just wanted to bounce it off someone 🙂 Thanks!

fierce shuttle
# dense mica What strategies are advised for managing game object hierarchy during runtime? ...

Maybe this might help: https://blog.unity.com/engine-platform/best-practices-from-the-spotlight-team-optimizing-the-hierarchy

In short, Unity will mark a GameObject as "dirty" if it, or any of its children have changes, such as position/scale/rotation changes, toggling the object on/off, so if you have a parent with 300 children, and you enable 1 of those chidren, 300 children + the parent get recalculated, even tho almost nothing changed

That said, for your own sanity, organizing objects under a parent can be helpful, or what some do is use a empty object and structure their hierarchy like

==== ENEMEIES ==== (Empty GameObject)
Enemy A (Prefab)
Enemy B (Prefab)
...
==== LIGHTS ==== (Empty GameObject)
...

Personally not a fan of that approach, but for compiling, if your objects ever change, and they dont really need to be a child of anything, its usually best to leave it in the root hierarchy with no parent, otherwise just keep the "dirty" in mind, and if its only for your own sanity, then organize it however is best for you to work, as it likely wont be the major bottleneck of performance, unless the child tree is VERY large

dense mica
#

Oh huh, that is very interesting.

#

I wonder if anyone has made an Asset that allows organization of objects in a secondary tree/heirachy for easier debugging/editing, while still allowing for a performant existence. Given my target includes mobile, I would not want to incur the CPU hit of aggressively grouping objects it seems.

cosmic dagger
#

there's no real reason to group an object under a parent, unless it's applicable to its function . . .

vital hinge
#

can someone walk me through how I can add an online leaderboard system (I ve watched some videos but still cant figure it out but I think im close to the answer)

dense mica
summer stump
cosmic dagger
# molten dock what do you mean

when playing the game, no one sees the hierarchy. it's unnecessary to group objects that don't actually need grouping. e.g., bullets placed under a projectile GameObject, or enemies as children of an enemies GameObject

it's nice and easy to sift through while editing, but during gameplay, it not helpful. you can still use parenting if you move the objects locally. the biggest culprit is updating transform.position without knowing the consequences . . .

molten dock
#

are u saying before building a project that objects which are parented for organisation should be unparented

devout swift
#

Hey guys, I'm trying to use animator events to play sounds in my game. But it doesn't seem to work? I tried to have it when the method is executed it should tell me a Debug.Log("FootStep!!"); but it doesn't show.

summer stump
wintry quarry
cosmic dagger
molten dock
#

why not

dense mica
# molten dock why not

If you click and read the article that was posted, you'll see that it can kill game performance.

cosmic dagger
molten dock
#

i will read that

cosmic dagger
torn edge
#

Can someone explain to me how I could recreate the shooting that takes place in this video (2:27 - 3:00)? How are the bullets able to go over the enemies in a 2D game but not collide with them? Is it because of the z values of their position? Also how is the player able to control how high or low their bullets go? https://www.youtube.com/watch?v=OBTud6ujDDw

molten dock
#

Yes 🦧 😎

devout swift
wintry quarry
#

it is doing its own internal accounting of object positions and collision detection

torn edge
wintry quarry
torn edge
#

what

wintry quarry
#

it's really not that complicated here. Probably just a bunch of circle or square overlaps

torn edge
#

But like I can't I do by setting their z values differently

wintry quarry
#

Why not

torn edge
summer stump
wintry quarry
#

For two sphere's it's literally just checking if the distance is less than the sum of their radiuses

molten dock
#

so dat is reffering to not childing instantiations

#

i think anyway

#

good to know ty

torn edge
#

But I mean my game design teacher kinda told me to this

cosmic dagger
wintry quarry
summer stump
torn edge
torn edge
wintry quarry
summer stump
torn edge
#

Well I can't say that to them

molten dock
#

so what is incorrect about me saying to have them organised during development then unparent before building

devout swift
summer stump
molten dock
#

for optimisation like what the site says

rotund trail
#

Has anyone had any issues with cinemachine not following the player transform when "apply root motion" is checked on?

dense mica
# torn edge Well I can't say that to them

I recommend watching some tutorial videos to understand the basics of Unity, coding, setting up the project and doing some basic things in 2D. Expect to spend a couple days just watching and learning and then you'll have the foundations for trying to tackle something like this. Code Monkey's earlier videos deal mostly with 2D, explore many facets of game designs and systems, and although some might be more geared towards Unity 2020/21, are still highly applicable to 2022 LTS.

cosmic dagger
#

why parent in the first place?

molten dock
#

organisation

wintry quarry
cosmic dagger
#

but if you want to do the extra work, no one is stopping you . . .

summer stump
#

For other things, just don't parent them

devout swift
molten dock
#

i understand

torn edge
dense mica
# cosmic dagger why parent in the first place?

Just to give some insight, I have about a dozen Manager objects that contain very useful information for Runtime debug. I'm often inspecting them and their properties to track down bugs or just track metrics. If I'm trying to find them amongst 10,000 things in the hierarchy list its a bit of a pain. Not to mention the list itself can lag after some time. There are times I just want to come back after running for 10 hours and inspect a few random objects for integrity and so grouping is helpful in that case. In my case since everything is instantiated at runtime I can just have a flag to tell it to group for debug/test and ungroup when I go live. But its great to have learned of the performance implications so I can plan accordingly.

molten dock
#

long ass run

devout swift
wintry quarry
dense mica
#

I don't know what all "have it done" means per say... but a simple game-scene like that? Sure if you are a competent C# coder and have experience with Unity, that's probably a weekend game jam 20 hour project. If you are new to Unity/coding I'd say more like a month.

devout swift
wintry quarry
#

not sure

#

I'm not an expert on the Animator

molten dock
cosmic dagger
molten dock
#

you can watch the line go over the animation and make sure it goes past the event trigger

devout swift
devout swift
cosmic dagger
molten dock
#

would also just make sure that the void is set to activate from that trigger

devout swift
devout swift
cosmic dagger
#

by void they probably mean the function/method . . .

devout swift
cosmic dagger
# molten dock ye

void is just a return type, it's not relatable to a method. that's why the confusion . . .

molten dock
#

could you explain simpler fo me

devout swift
teal viper
molten dock
#

i am just talking about when you select the animation event and set it to activate the function contained in a void

molten dock
#

function as in whatever is in it

#

it be functioning

teal viper
summer stump
cosmic dagger
# devout swift Okay.

you have 5 messages from the console and 1 error, but only the error is displayed . . .

summer stump
#

The stuff inside is the body of the function (method)

molten dock
#

i see

devout swift
#

There's nothing else than that.

molten dock
#

isnt calling it a void just more direct or can that be confused with other things

summer stump
molten dock
#

public void

devout swift
cosmic dagger
summer stump
shrewd bison
#

is there anyone that can teach me the basics of c# use in unity?

molten dock
#

are there other types that dont return

devout swift
cosmic dagger
shrewd bison
summer stump
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

teal viper
shrewd bison
#

oh dang thanks @summer stump

molten dock
teal viper
devout swift
summer stump
#

They are ALL called methods

molten dock
#

oh i thought int was variable

#

what like everything is a method

cosmic dagger
summer stump
#

Public int isn't called anything, it is part of multiple things

teal viper
frigid sequoia
#

I want to do like this thing where enemies gradually change color when they get status effects like Freezing (turning blue gradually). Is that supposed to be like a custom shader or I can do simple script that adds a semitransparent layer of a given color on top of the material? Cause I am not sure at all on how to handle something like that

devout swift
teal viper
#

I'm not sure a preview window would trigger it correctly.

teal viper
devout swift
teal viper
#

Also, I'd remove the other debug logs for the time being as they're gonna make it more difficult to see the event message.

gray elk
#

Does anyone know how to fix this error? I'm working with WebGL and it won't give me the preview

teal viper
devout swift
gray elk
#

It just crashed my Unity so I'm unable to check that but I will see if i can track any more down

molten dock
#

your error might be stopping the code from running

teal viper
teal viper
# gray elk

Read the warning. It's probably related to the issue.

#

Or not. Share the first error details.

gray elk
teal viper
devout swift
gray elk
teal viper
molten dock
teal viper
eternal falconBOT
teal viper
summer stump
molten dock
#

does it not vary in unity

summer stump
#

Or yeah, the microsoft c# manual is peak

summer stump
molten dock
#

okay ty

summer stump
#

Unity is a c# api. It has methods ON TOP of c#

#

It doesn't change anything with c# itself

gray elk
#

i tried doing the ```cs
// Your code here

but it only let me send as this because it was too much text
molten dock
#

you are cooked

gray elk
#

I'm using the KinematicCharacterController from the Unity Asset store, and I need to use it for my assignment so the fact its not working is a huge problem notlikethis

molten dock
#

erm

#

put the error in google

gray elk
#

i have
i also talked to my TA about it and he has no idea either
google just kind of says 'yeah that certainly is an error that exists'

molten dock
#

i was shown a good amount of unity forum stuff

gray elk
#

thats what we're trying to work off of right now yeah
i just meant there wasnt one end all be all answer unfortunately

summer stump
#

Look at the "large code blocks" section...

gray elk
summer stump
#

Better than having to download the file

gray elk
#

Oh i thought i was doing something wrong and it was supposed to show up as multiple lines my bad notlikethis

summer stump
molten dock
#

i was shown a code box wut

gray elk
summer stump
gray elk
#

gotcha

summer stump
#

A large portion of the resident helpers here are on mobile

molten dock
#

mentions what line it has a problem with after each error message

#

check those out

gray elk
#

I managed to figure it out (for now at least); completely had to restart though. It was an issue with my folder organization I believe

#

which is why the errors were so odd I assume

magic panther
#

real quick, will this work?

wintry quarry
#

what are you trying to do?

magic panther
#

collisions with box collider objects

wintry quarry
#

BoxCast doesn't do collisions

#

it just tells you if there are objects in the path of the cast box

magic panther
#

damn

#

yes, that's what I meant

#

you won't move if something's in the way

#

I'll show the full script so far

#

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

public class Player : MonoBehaviour {

    private Vector3 lastMoveDir = new Vector3(0, 0, 0);

    private float playerSize = 2;

    private void Update() {
        Vector2 inputVector = new Vector2(0, 0);

        if (Input.GetKeyDown(KeyCode.W)) {
            inputVector.y -= 1;
        }
        if (Input.GetKeyDown(KeyCode.S)) {
            inputVector.y += 1;
        }
        if (Input.GetKeyDown(KeyCode.A)) {
            inputVector.x += 1;
        }
        if (Input.GetKeyDown(KeyCode.D)) {
            inputVector.x -= 1;
        }

        inputVector.x *= playerSize;
        inputVector.y *= playerSize;

        Vector3 moveDir = new Vector3(inputVector.x, 0f, inputVector.y);
        bool canMove = !Physics.BoxCast(transform.position + moveDir, new Vector3(playerSize, playerSize, playerSize), moveDir);

        if (canMove) {
            if (moveDir != Vector3.zero) {
                lastMoveDir = moveDir;
            }

            transform.position += moveDir;

            transform.forward = lastMoveDir;
        }
    }
}

wintry quarry
#
  1. Your first parameter is wrong, it should just be the current position
  2. This shouldn't really just be a yes or no
#

You should be looking for the distance you can move

#

which the boxcast will tell you in the RaycastHit (when you use a form that gives you one)

magic panther
#

I probably don't understand what you mean, but it's locked to 1 space at a time, it's a grid based game

wintry quarry
#

Oh I see

#

this is wrong though:
transform.position + moveDir

#

but really]

#

if you have a grid based game

#

why are you using physics at all??

magic panther
#

to check if something's in the way

wintry quarry
#

You should just have a dictionary or a 2D array storing what's in all the grid coordinates

#

then all you do is see if something is in the grid coordinate you want to move to

#

much cleaner, more efficient, more logical

magic panther
#

idk

brittle isle
#

Hello! I'm making a 2D platformer and I'm trying to make this Hammer Brother-like enemy.. It walks back and forth a limited distance, always faces the player to throw projectiles their way, and must move away from bottomless pits. Right now, though, it doesn't do the latter. It only detects them when walking off. https://hatebin.com/vgeqlwqeyd

magic panther
wintry quarry
# magic panther idk

Anyway what you have will work but you need to change this:
!Physics.BoxCast(transform.position + moveDir, new Vector3(playerSize, playerSize, playerSize), moveDir);

magic panther
#

like fences

wintry quarry
#

to this:
!Physics.BoxCast(transform.position, new Vector3(playerSize, playerSize, playerSize), moveDir);

magic panther
#

bool canMove = !Physics.BoxCast(transform.position, new Vector3(playerSize, playerSize, playerSize), moveDir);

#

like this?

wintry quarry
# magic panther like fences

that's definitely still representable in a graph data structure but you're a beginner so you'll end up using physics no matter what I say

#

yes

magic panther
#

also is there a way to shorthand a vector3 with all the same arguments passed?

wintry quarry
#

or just store the size as a Vector3 in the first place

magic panther
#

let me test

#

what the hell

wintry quarry
#

really you should just do a CheckBox in the spot you want to move to

#

not a BoxCast

magic panther
#

will that work the same?

#

rn it's bumping into air

#

no wait wait

#

my bad

#

divide by 2, forgot that

hallow sun
#

rn it only checks for pit if you are further than move distance

magic panther
#

look

#

it's telling me all of these spots are walls

wintry quarry
#

what's telling you that

#

Btw you're not using a layer mask or antthing right now

#

so it will likely consider the player itself an obstacle

magic panther
hallow sun
#

This part:

if (canFlip && ...)
{
    if (DetectBottomlessPit())
    {
        ...
    }
}```
Should perhaps be like:
```c#
else if (canFlip && ...)
{
    //Make it an else, since there's no need to check this if you already flipped because of a wall
}
else if (DetectBottomlessPit())
{
    ...
}
wintry quarry
#

also since you're using a box exactly the size of these things it's finicky

wintry quarry
#

maybe use a slightly smaller box

#

or just use a CheckSphere that's small in the desired grid space

magic panther
#

let's use the checkbox like you told me

wintry quarry
#

use a smaller box for it

magic panther
#

if I look in the direction of a wall that shares an axis with me, it doesn't move

#

I noticed

queen adder
#

If i have 2 separate assemblies, can there be two classes (one in either of them) with the same name and namespace?

#

Or is this an error?

magic panther
#

it was indeed overlap

hallow sun
#

You need to move the boxCenter based on which way you're moving.
Right now, it will always return false unless you're already in a pit, because it detects the floor it's standing on.

restive bone
#

Hey y'all, there's a project I've been wanting to do for a while and I think Unity might be the easiest way to do it. I've never really programmed before save for a quick Python course, so I'm not really sure what I'm doing. What should I know before getting started? I want to make a VR application to do some simple things.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

restive bone
#

Thank you

acoustic arch
#

for a card battling game when a card uses one of their abilities, should the card have a method and affects the other cards in battle? or pass along fields to a method within the battle runtime which already contains all the effected cards

slender nymph
#

you start the coroutine before the pool has been set up so the dictionary is null

slate haven
#

so how do i deal with that

slender nymph
#

set up the pool inside of Awake instead of Start and it will not be null at the time you access it

slender nymph
#

yes

slate haven
#

oh thank you @slender nymph, its fixed

slender nymph
#

also why do you assign op using FindObjectOfType then reassign it using the singleton's instance variable if it is not null?

slate haven
#

i was earlier trying to fix this same issue, so I tried doing this

#

i can remove it now

slender nymph
#

you can also use the instance variable to assign it in Start instead of using FindObjectOfType. it being a singleton is supposed to give easy access to it without using any of the Find methods

slate haven
#

yes

acoustic arch
slender nymph
#

several years of experience

acoustic arch
#

do you create games?

#

i can tell

slate haven
#
    {
        if (!poolDictionary.ContainsKey(tag))
       {
           Debug.LogWarning(tag + " Doesnt exist");
           Debug.Log("TAG:" + tag);
           return null;
        }

        Debug.Log("TAG:" + tag);
        GameObject objectToSpawn = poolDictionary[tag].Dequeue();
        objectToSpawn.transform.position = position;
        objectToSpawn.transform.rotation = Quaternion.identity;
        objectToSpawn.SetActive(true);

        poolDictionary[tag].Enqueue(objectToSpawn);
        
       return objectToSpawn;

    }```

I want to create a method like this which deactivates the gameobject using SetActive(False). But How do I approach it? Do I have to remove it from the queue and add it again like here? Also Should the method have a return type or not?
#
    {
        if (!poolDictionary.ContainsKey(tag))
        {
            return null;
        }

        GameObject objectToRemove = poolDictionary[tag].Dequeue();
        objectToRemove.SetActive(false);

        poolDictionary[tag].Enqueue(objectToRemove);

        return objectToRemove;
    }```

I did this, is this correct?
cosmic dagger
slate haven
#

im using both

#

queue and dictionary

slender nymph
#

what why

slate haven
#

im using dictionary but applying operations of a queue

#

dequeue and enqueue

#

i watched the brackeys tutorial on object pooling

slender nymph
#

i am almost 100% sure that brackeys did not have a dictionary of queues for his pool

cosmic dagger
#

okay, so a Dictionary<string, Queue<GameObject>?

slender nymph
#

and with your current setup, you aren't even guaranteed to get an active object with the way you are going about it

slender nymph
#

prove it. show both your code and link the tutorial

slate haven
#

alr

#

Get Skillshare: http://skl.sh/brackeys2

Speed up your game by setting up Object Pooling in Unity!

● Singleton Pattern: http://wiki.unity3d.com/index.php/Singleton
● Generic Unity Object Pooler: https://github.com/Rfrixy/Generic-Unity-Object-Pooler
● EZ Object Pools: https://assetstore.unity.com/packages/tools/ez-object-pools-28002

❤️ Donate: ...

▶ Play video
slender nymph
#

before i even bother watching that, i'm going to go ahead and guess that brackeys has an objectpool class and has a dictionary of those. and the object pools themselves have the queues because that's really all an object pool needs to be

#

oh no. i was wrong. and yet i'm not surprised that his object pool is hot garbage

slate haven
#

wdym

slender nymph
#

also unity has its own built in ObjectPool<T> class now

slate haven
#

oh

#

i didnt know that

slender nymph
# slate haven wdym

i mean it sucks. the logic makes little sense because you dequeue an object when it spawns, then enqueue it again for some reason? why is the active object still in the pool

slate haven
#

u add it back

slender nymph
#

you put it back in the pool when you are done with it

slate haven
#

so u mean it really doenst help with the frame drops im getting?

slender nymph
#

what happens if you are using a bunch of objects and suddenly start reusing them while those objects are still in use

slender nymph
slate haven
#

i was using simple create destroy of many items earlier. And I was getting framedrops. Now I did this object pooling approach, but im still getting performance dips

cosmic dagger
cosmic dagger
#

huh, what is void??

slate haven
#

making it a non-returnable

#

why would i need it to return something anyways

#
    {
        if (poolDictionary.ContainsKey(tag))
        {
            GameObject objectToRemove = poolDictionary[tag].Dequeue();
            objectToRemove.SetActive(false);

            poolDictionary[tag].Enqueue(objectToRemove);

        }


        }

    }```
slender nymph
#

it's called a method not a void. void is the return type for a method that returns nothing

slate haven
#

making it void

cosmic dagger
slate haven
#

is it in the code that im doing something wrong or just a naming convention

cosmic dagger
slate haven
#

i just want to deactivate a gameObject when its meant to be destroyed

cosmic dagger
#

and since the code within the method does retrieve an object from the pool (when it's not supposed to), it seems the name confused you as well . . .

slate haven
#
    {
        if (poolDictionary.ContainsKey(tag))
        {
            GameObject objectToRemove = poolDictionary[tag].Dequeue();
            objectToRemove.SetActive(false);

            poolDictionary[tag].Enqueue(objectToRemove);

        }


        }

    }```

that seems correct?
cosmic dagger
slate haven
#

i mean, earlier i used to destroy them

#

but it was causing me performance dip

#

so now i want to change my architecture

#

so that i dont have to destroy or create them

#

about the creation part, I already set up the code

#

Im just working on deactivating it now

#

the moment it was meant to be destroyed earlier, it should be just deactivated now

#

then put back in the queue

#

for reuse afterwards

cosmic dagger
#

the GameObjects that are spawned need a reference to the object pool they belong to. then you can add them back to the pool without searching through the dictionary . . .

slate haven
#

they already have a reference as```

public Dictionary<string, Queue<GameObject>> poolDictionary;```

#

It has the tag string

cosmic dagger
magic panther
#

@wintry quarry so what line of code do you suggest could work as a collision detector

#

without physics involved

#

the player has no collider

slate haven
magic panther
#

it likely will later on, but then I'll be good enough for a code refactor

topaz mortar
#

What do I use to call the UGS Rest API from Unity?
Also I want to call it from my UGS C# Cloud Code Module, can I use it there too (this is not inside of Unity)

rich adder
#

you can call functions with c# through that

#

Oh nvm you wrote REST

topaz mortar
#

going through the docs, just found an example, it was hidden somewhere 😛

topaz mortar
#

nvm it's also in the docs 😮

pure kite
#

when using transform.lookat, the worldup parameter doesn't allow me to use a y axis, I need the capsule to be standing upright like in the 5th screenshot, however I'm only able to rotate it on a 2d axis, which doesn't let me stand the capsule upright. Variables on bottom of every screenshot. How would I solve this? without using transform.rotate on another line since that causes it to flip around when moving past the target on the x or y axis

#

this is the only code that modifies the rotation of the capsule

wintry quarry
#

If you don't want him laying down he'll need to be looking at something at his own y height

pure kite
#

I can’t just point the y axis at the target instead of the z?

wintry quarry
#

You can, but not by using transform.LookAt

#

transform.up = targetPos - transform.position;

pure kite
#

Ok thanks

magic panther
charred spoke
#

You cant have collision detection without a collider

willow scroll
magic panther
magic panther
willow scroll
magic panther
#

one sec i gotta find it

charred spoke
#

In the context of your grid based movement Praetor already pretty much told you what is the best approach

magic panther
#

movement works, not walls

magic panther
willow scroll
#

Can be also simplified to

bool canMove = !Physics.BoxCast(transform.position, Vector3.one * playerSize, moveDir);
#

What else do you want to implement for your collisions?

magic panther
#

one sec

#

sorry for being on and off rn, a lot happening at home

magic panther
#

there's a big issue with this

#

which I do not understand as I'm a complete beginner

#

all these

#

you are unable to move at any distance on these axis in these directions

#

as if the boxcast was infinitely long

#

and hitting corners

#

which I kinda fixed by scaling the boxcast size down

#

but the axis issue persisted

magic panther
#

@willow scroll only thing that comes to my head is that it goes on without limit and it's too big

willow scroll
#

How do you move them?

#

Please, show the code

magic panther
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

    private Vector3 lastMoveDir = new Vector3(0, 0, 0);

    private float playerSize = 2;

    private void Update() {
        Vector2 inputVector = new Vector2(0, 0);

        if (Input.GetKeyDown(KeyCode.W)) {
            inputVector.y -= 1;
        }
        if (Input.GetKeyDown(KeyCode.S)) {
            inputVector.y += 1;
        }
        if (Input.GetKeyDown(KeyCode.A)) {
            inputVector.x += 1;
        }
        if (Input.GetKeyDown(KeyCode.D)) {
            inputVector.x -= 1;
        }

        inputVector.x *= playerSize;
        inputVector.y *= playerSize;

        Vector3 moveDir = new Vector3(inputVector.x, 0f, inputVector.y);
        bool canMove = !Physics.BoxCast(transform.position, Vector3.one * playerSize, moveDir);

        if (canMove) {
            if (moveDir != Vector3.zero) {
                lastMoveDir = moveDir;
            }

            transform.position += moveDir;

            transform.forward = lastMoveDir;
        }
    }
}
#

all code so far

#

you control the player

#

walls are a prefab model and box collider of precisely the player size

willow scroll
#

Please, consider using a site to share big code blocks !code

eternal falconBOT
willow scroll
#

As I have previously mentioned, it doesn't allow you to move if your Box cast touches any Colliders

#

Additionaly, you don't use Time.deltaTime. Perhaps you don't know when you should use it?

magic panther
#

it moves 1 grid space at a time

#

when you press it's a full block size move

#

grid based everything, at least most mechanics

willow scroll
#

Oh, exactly

#

I haven't mentioned you were checking for ButtonDown

#

Then deltaTime is not required

magic panther
#

after the collider crap I plan to add a quick animation where instead of instantly moving the movement is split into 10 frames. I probably will yap about it here as well

willow scroll
#

Also consider checking for the inputVector not being (0, 0) after the calculations

magic panther
#

I can debug log it, where do you need it?

willow scroll
magic panther
willow scroll
#

You may want to debug the BoxCast's out RaycastHit hitInfo if you're wondering what your object is colliding with

topaz mortar
#
public async Task SavePlayerInfo(IExecutionContext context, IGameApiClient gameApiClient, string key, object value)```
IExecutionContext is, as far as I understand, dependency injection to get info about the current call
Is this something I need to include when I call the function from my game client? How?
willow scroll
#

The float playerSize is also to 2, so your Box's size in the world space is (4, 4, 4)

magic panther
#

all box collider

magic panther
willow scroll
#

If your boxes are 1x1, the Box looks approximately like this

willow scroll
#

Are you intending on moving your character just when it doesn't collide with the other objects?

magic panther
#

I checked, any distance

magic panther
willow scroll
rotund egret
magic panther
#

if something with a collider blocks the way we can't move, otherwise, check a bunch of other stuff, like if the hit object is a box

#

I mean crate

#

other blocks are planned

willow scroll
magic panther
#

wh

willow scroll
magic panther
#

is this really necessary to make the collisions work?

willow scroll
willow scroll
magic panther
#

idk, didn't get there yet

willow scroll
willow scroll
#

They're created for this.

magic panther
#

just a way to ask the collided object "Can I go?" and it responds by checking some stuff

magic panther
#

I also need to go in 5 mins

willow scroll
#

They should change the boolean canMove, which is not local

#
OnCollisionEnter -> canMove = false;

OnCollisionExit -> canMove = true;
#

It's so that these methods trigger every time your Collider collides with others, so you'll, probably, have to store all the Colliders in a list in the OnCollisionEnter and remove them in the OnCollisioExit

magic panther
#

I don't really have any more time right now. Can we do this in like 22 hours from now? 8 am for me, idk about you. In the meantime I'll try to plan out as much as I can and then we re-write the code to make everything work. I can't really do later than 8 am, but after 5 am is ok. How's that?

#

It won't take long

#

like 10 minutes if I'm not braindead then

willow scroll
magic panther
#

What time is it for you right now?

#

I'm gone for a day and night after 9 am tomorrow, so I can talk at 12am the day after tomorrow

willow scroll
magic panther
#

ok

willow scroll
#

I would consider having 2 methods: OnCollisionEnter and OnCollisionExit.
The OnCollisionEnter should add the objects collided to a list if they pass some sort of check, so are the objects you need. The OnCollisionExit should remove these objects from the list, as the collision disappears.
When you move your object, you want to check for your list, let's call it collisions, being empty. If it's not, the character cannot move.

private void Update()
{
    bool canMove = collisions.Count == 0;

    // ...
}

private void OnCollisionEnter(Collision collision)
{
    if (CheckForAnything())
    {
        collisions.Add(collision);
    }
}

private void OnCollisionExit(Collision collision)
{
    collisions.Remove(collision);
}
magic panther
#

thanks a ton anyways, see you later

willow scroll
rich egret
#

!code

eternal falconBOT
rich egret
#

My goal is to make the child be in the parent position when it is created, but for some reason it is always created in position 0,0,0!

https://gdl.space/ikehehinod.cs

rich egret
languid spire
#

Well your script has no debugging in it so how do you know it is 0,0,0

gray elk
#

My goal is to create a jump animation when the space key is pressed, but every tutorial ive tried following is just confusing me more or ruins my code somehow

I have a walk and idle animation atm and those work fine

This is what I have so far

https://gdl.space/varupaceyo.cs

raw wadi
#

is there any guide on how can I convert vertex data stored in UInt8/UInt32 to Vector3, Vector4,etc ?

sour harness
#

hello

#

How do I access a bool from another script
Note: the object that is trying to get the bool only spawns when game starts

#

I need to use the bool in a IF statement

languid spire
languid spire
sour harness
#

found it.

raw wadi
languid spire
#

you cannot deserialize something without knowing how it was serialized in the first place

regal bear
#

Hello, im making my first game, 2D topdown game. I used tilemaps to create a room, then to put down furnitures i use tilemaps too (idk if its good practice or not) my question is, i used the custom physic shape on my interiors, but somehow can i delete collider from one tile? If i delete the shape, tilemap collider auto generates back one.

raw wadi
# languid spire Never gonna work without knowing EXACTLY how it has been optimized

I'm guessing they packed float2 (dropping one dimension of the normal and tangents) at half precision into 32 bits and probably packed the byte arrays at half precision too but not sure because the dev who optimized this files is no more
Actually I also got the same mesh with the deserialized data, isn't there a way I can try different methods until and I get the values in the optimized form and get the method which was used to optimize the mesh

languid spire
onyx tusk
#

how 2 get all objects that have component from static component method?

raw wadi
languid spire
sour harness
#

How can an object that doesn't exist in the scene get a bool from another script (the object spawns when the game starts)

summer shard
#

where do i put question on how to disable this without disabling gizmos

willow scroll
sour harness
#

I googled them and my brain doesn't understand anything

#

I just started learning unity yesterday, give me a break

languid spire
eternal falconBOT
#

:teacher: Unity Learn ↗

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

silver cobalt
#

Could someone help me with my enemy ai behaviour tree:

Im currently facing a problem. the patroling and the Attacking of the player works as intended. The chasing of the player seems to work fine as well. but the enemy cant chase the player breadcrumbs. My player instantiates bread crumbs every .3 seconds. and wheneever the player isnt in line of sight with the player it should chase the bread crumb. but instead of chasing the breadCrumbs of the player it chases the player even though it should be chasing the breadcrumb.

https://appp.me/kMD9ki

summer shard
willow scroll
dapper egret
#

Im not sure if someone can answer this but is the best practice when trying to find a specific spawned player prefab for example player 6 in a multiplayer sense but it couls vary depending on scene

willow scroll
willow scroll
#

I see, you have already been answered there. There was no need in cross-posting.

onyx tusk
#

how 2 get all objects that have component from static component method?

willow scroll
onyx tusk
willow scroll
onyx tusk
#

no, material

#

color is enum, not something with fields like r, g & b

rich egret
willow scroll
raw wadi
onyx tusk
#

What from this do i need?

willow scroll
onyx tusk
willow scroll
onyx tusk
#

i already have loaded array of materials

willow scroll
#

Yeah, so you want to set the object's material.

onyx tusk
willow scroll
languid spire
willow scroll
regal bear
#

Hi, i set TransparencySortMode to 0 1 0, for my 2d topdown game, but my character goes behind an object before i reach it. If i go to a chair too close from under, its swap behind the chair, and my legs still showing. Whats wrong?

onyx tusk
spiral narwhal
#

How do I prevent two or more systems that manipulate delta time from interfering with one another?

willow scroll
onyx tusk
willow scroll
onyx tusk
willow scroll
#

This's the type

onyx tusk
willow scroll
#

The same as if you're accessing Rigidbody.velocity

#

You should have a variable of type Rigidbody

#
[SerializeField] private Rigidbody _rigidbody;
onyx tusk
#

you mean, that it will be executed 2 all objects that have ANY component?

willow scroll
fluid haven
#

Hello, i have a question to a project i am working on, I need to store and edit .txt files in a cloud, I am currently developing an app where you can track like your worktime and stuff but everytime I try to store data, i get an path sharing violation error, can anyone help me with that?

willow scroll
#

If multiple objects have your script, it will change the material on all of them

willow scroll
fluid haven
#

Yes, but its like quit a long code, can i post it here?

willow scroll
eternal falconBOT
onyx tusk
willow scroll
#

And you don't have to access multiple graphics.

#

The Graphic can be gotten with the GetComponent method, as normal components

willow scroll
#

Please, show the error, including the line.

onyx tusk
willow scroll
#

Graphics is Unity's interface for drawing stuff

onyx tusk
willow scroll
onyx tusk
willow scroll
summer shard
#

can someone help me "fix my bobbing"

void HandleBobbing() {
    if (!canMove) return;
    if (Mathf.Abs(_rb.velocity.x) > 0.1f || Mathf.Abs(_rb.velocity.z) > 0.1f) {
        _bobTimer += Time.deltaTime * (isSprinting ? sprintBobSpeed : walkBobSpeed);
        cameraHolder.localPosition = new Vector3(
            cameraHolder.localPosition.x,
            _defaultCameraY + Mathf.Sin(_bobTimer) * (isSprinting ? sprintBobAmount : walkBobAmount),
            cameraHolder.localPosition.z
            );
    }
    else {
        cameraHolder.localPosition = new Vector3(cameraHolder.localPosition.x, _defaultCameraY,
            cameraHolder.localPosition.z);
    }
}

the object that is attached to the camera holder "jumps" whenever i change movement while walking, like from a to d or d to a and so on

onyx tusk
burnt vapor
willow scroll
burnt vapor
#

So you most likely need to unlock it first, or wait a moment before you read the file

summer shard
burnt vapor
#

This, annoyingly, can also be caused by an antivirus trying to scan the file you wrote

#

@fluid haven ^

burnt vapor
#

Hence the cause I mentioned

#

I don't see where GetEntrysCount is called though

fluid haven
burnt vapor
#

You do have another method ExportEntriesToTextFile which is also async

#

My guess is that this one has it open

onyx tusk
# summer shard what are you trying to do

i'm tryimg 2 explain, that materials can be changed without UnityEngine.UI & i need 2 change material for all objects that have my component when i set a velue to static field

fluid haven
burnt vapor
#

Or put CloudSaveService.Instance.Data.LoadAsync before you open the file stream and hold the data in memory

#

So the async code is not happening whilst the stream is open

#

IDK if this is the root cause but it's worth a shot

fluid haven