#💻┃code-beginner

1 messages · Page 329 of 1

rich adder
#

and where are those grabbing that data from

polar acorn
#

Okay, and how do you intend to do that if you don't store the loaded data anywhere?

rich adder
#

wdym open with inspector ? so if inspector is closed it doesnt work?

polar acorn
#

If you want everyone on the team to get a drink you probably don't just pour the gatorade directly onto the floor

#

you'd need to put it in a cup

lost anvil
#

i dont know if its that alone but i had it open in runtime and it was working

polar acorn
lost anvil
#

if i had it closed it just didnt work lmao

polar acorn
#

Probably one that you intend to re-use somewhere

quasi rose
#

var

rich adder
lost anvil
#

no lol

quasi rose
rich adder
lost anvil
cinder crag
polar acorn
rich adder
polar acorn
#

You're still not storing anything

lost anvil
#

ive looked about already and noone has had this issue

#

surely its just my script

rich adder
#

are you doing this

cinder crag
#

sorry , brain is not workin 😭

quasi rose
#

what is SaveData?

rich adder
#

why did you replace ReadAllText

quasi rose
#

ah ignore me probably, im late.

rich adder
#

said earlier FromJson returns you the data

#

you changed wrong line

#

you're saying
Get this JSON string and try to make this object from it

#

this is the object you are attempting to make

polar acorn
#

FromJson returns an object from json. What do you want to do with that returned object

#

Where do you want to put it

cinder crag
#

i wanna load the returned object and im not sure where to put it

rich adder
polar acorn
polar acorn
cinder crag
polar acorn
cinder crag
#

yes

polar acorn
#

Can you tell me what variables you have on this object

cinder crag
#

on the SaveData object?

polar acorn
#

No, on the object this code is running on

cinder crag
#

well i have strings, ints , floats

polar acorn
#

List the variables on this object

#

Tell me what variables you have

rigid valve
#

when I am in conversation with npc I can still move my mouse any fix?

deft grail
cinder crag
polar acorn
polar acorn
quasi rose
polar acorn
rigid valve
#

this dialouge is playing func

polar acorn
rigid valve
#

simply locking cursor in centre

quasi rose
rigid valve
#

yes

quasi rose
#

yeah that's what you have your code as.

rigid valve
#

I am doingthat already

polar acorn
# rigid valve

Okay, try logging something in those functions to find out what order they're being called

quasi rose
#

If dialogue is playing, dont you want it locked, not unlocked?

rigid valve
cinder crag
quasi rose
polar acorn
quasi rose
pearl lodge
#

Does anyone know why this just opens and the closes? I works fine in the Unity Editor.

cinder crag
#

string , int and float

polar acorn
deft grail
polar acorn
#

You should look at the link I sent

short hazel
cinder crag
#

they are containers that hold data

cinder crag
cinder crag
#

im dumb

quasi rose
rigid valve
polar acorn
quasi rose
#

nice 🙂 well done!

#

so the name of the variable is ioc and it is of type string

#

you keep telling digi what types you have.

deft grail
polar acorn
polar acorn
# rigid valve

So it looks like the most recent one to run is unlocking

rigid valve
cinder crag
deft grail
rigid valve
#

I want the mouse to selct option rather than moving the player

polar acorn
rigid valve
polar acorn
#

I told you that wasn't it

#

What variables does the object running the code have

cinder crag
deft grail
polar acorn
#

What variables does this object have

cinder crag
#

SavaData and instance

polar acorn
short hazel
#

lol

#

How convenient, there is a SaveData

cinder crag
polar acorn
cinder crag
cinder crag
#

im sorry

short hazel
#

Then just load the JSON into that, and you're set

cinder crag
polar acorn
#

Sure, but you don't need to make a new local variable just set SaveData directly to the result of the function

#

It's not gonna break anything it's just unnecessary

cinder crag
#

it still doesnt load the data taht i saved

short hazel
#

Do you get (in the console) the log that's placed at the end of the function?

rigid valve
#

I have this reddish sky right now but I want to chnage it when player does ceratin task

short hazel
# cinder crag yep

How do you know it hasn't loaded the data shown here? What have you tried?

cinder crag
#

lemme showa vid

short hazel
#

This does not answer any of my two questions

#

And a video won't be useful, debugging is required

polar acorn
cinder crag
short hazel
#

It loads, the health goes back to 50 when you hit the Load button

#

You're probably not distributing the newly loaded values to all your other objects

#

The log messages on save and load show the same JSON payloads also

rigid valve
#

how do i chnage this lighting through cript

deft grail
rigid valve
#

yeah

deft grail
#

or every question you will ask here first

rigid valve
#

i tried google chatgpt all that

#

I dont think we can actually access this window though script

cinder crag
rigid valve
short hazel
rigid valve
#

and gave me this complex code

novel tusk
deft grail
rigid valve
#

like evry game has day night mech

#

all the answer I found so far are very complex

short hazel
#

Rotating the directional light in the scene doesn't work?

rigid valve
#

I want to chnage the theme like take it from dark to chill happy mood

#

thats why I wanna update the skyblock mateliar

polar acorn
short hazel
#

Yep that's the first result I hit too when searching for that

#

unity change skybox from script

summer stump
stuck palm
#

if i do get component audio source, will it always get the first one?

summer stump
#

It won't reliably get the right one

stuck palm
#

shite

#

how come?

polar acorn
summer stump
#

You should make a script and add them as fields

#

Get the script, and read the field

stuck palm
#

i thought there was a reason to order them correctly

stuck palm
polar acorn
#

It is for this reason you should probably not have multiples of the same component

#

why do you have so many audio sources on one object?

stuck palm
summer stump
#

One source is fine for as many clips as you want btw

cinder crag
short hazel
#

That shows the string contents, now verify the contents of the SaveData variable

#

And make sure they're identical to the JSON string

#

If there are differences, then deserialization failed

split dirge
#

hello is there channel where i can ask questions/help

short hazel
split dirge
#

yeah its about my unity script

deft grail
short hazel
#

Doesn't show anything, expand SaveData in the first screenshot and compare
You need to look into the contents of the deserialized class instance too

split dirge
#

so im making 3D game and im trying to create painting logic for the game. I need to to convert the hit position to pixel coordinates on the texture. Im trying to map the UV coordinates obtained from the hit position to the pixel coordinates, but as unity beginner I have been struggling with that for hours.

stuck palm
split dirge
#
Debug.Log("Hit position: " + hit.point);

                    MeshFilter meshFilter = hit.collider.GetComponent<MeshFilter>();
                    if (meshFilter != null)
                    {
                        Mesh mesh = meshFilter.sharedMesh;
                        Vector2 uv = new Vector2(
                            Mathf.InverseLerp(mesh.bounds.min.x, mesh.bounds.max.x, localHitPoint.x),
                            Mathf.InverseLerp(mesh.bounds.min.y, mesh.bounds.max.y, localHitPoint.y)
                        );
                        Debug.Log("UV coordinates: (" + uv.x + ", " + uv.y + ")");

                        // Map UV coordinates to pixel coordinates on the texture
                        int x = Mathf.FloorToInt(uv.x * (texture.width - 1));
                        int y = Mathf.FloorToInt(uv.y * (texture.height - 1));
                        Debug.Log("Pixel coordinates: (" + x + ", " + y + ")");

                        // Paint on the texture at the calculated pixel coordinates
                        texture.SetPixel(x, y, Color.red);
                        texture.Apply();
#

My debug results look like this:

Hit position: (10.49, 2.99, -0.97)

UV coordinates: (0, 0.4130424)

Pixel coordinates: (0, 211)

#

x-coordinates are always 0 no matter what, i dont know if even the y-coordinate is correct

cinder crag
short hazel
#

Make sure you're looking at the values after SaveData = JsonUtility.FromJson<...>(...) is executed

#

If that line is yellow, it has not been executed yet

cinder crag
cinder crag
#

mbmb

#

this one is wrong as well

#

goddamit

#

here we go

#

they are both yellow

short hazel
#

Line 45 has not been executed yet as I said, so the values in the Autos window at the bottom are not up to date.

#

Execute to the next line (F10) and check again.

cinder crag
#

only the position is wrong but the rest seems to be true

#

to be correct*

short hazel
#

Can you read and understand what I'm writing??

cinder crag
#

yeah i can

short hazel
#

Doesn't seem like it

#

The line highlighted in yellow is the next executed statement, which means it has not been executed yet, so the JSON hasn't been read and put in the SaveData variable yet, so the values you see in the "Autos" window is not correct

#

Continue executing the debugger until line 45 has been executed, and check the "Autos" window again.

#

If the SaveData line disappears from the "Autos" window when you debug further, then you can hover your mouse over SaveData in the code directly to get a similar inspection tool.

cinder crag
#

okay they seem to match , the window above is SaveData var and the bottom is the debug.log line

toxic pine
#

i use this scriped for playing animations walk1 is a walking animation ,walk is a idle animation but when i pres a and d both at the same time it doesnt go back to the idle animation(walk): if (Input.GetKeyDown("d"))
{
Debug.Log("hi5");
transainimation.SetTrigger("walk1");
}
if (Input.GetKeyUp("d"))
{
Debug.Log("777");
transainimation.SetTrigger("walk");
}
if (Input.GetKeyDown("a"))
{
Debug.Log("hi");
transainimation.SetTrigger("walk1");
}
if (Input.GetKeyUp("a"))
{
Debug.Log("888");
transainimation.SetTrigger("walk");

short hazel
short hazel
#

No that's your JSON string

cinder crag
#

the text visualizer window

summer stump
short hazel
#

I want the contents of the SaveData variable directly, not its JSON representation through the dataString variable

cinder crag
#

oh u meant this

short hazel
#

Okay both match so the load is 100% successful

cinder crag
#

yep seems like it

short hazel
#

The issue is somewhere else

eternal falconBOT
short hazel
#

If you still have an issue of course

#

It's 1am and I work tomorrow, so somebody else will take the lead

toxic pine
regal bear
#

Hi, beginner coder here, i created a timer, every 1 sec is 1 min in the game, works fine. Did with InvokeRepeating("TimerFunction", 0f, 1f);, my timer function is a simple hour minute +- thing. Then in this function, i have an if segment, where i check if the time is between 6 and 19 hours, its daytime otherwise night. My question is how can i modify a player stat only in night? I tried there, but then my stat modified every 1 sec when the function triggers.

deft grail
regal bear
#

i created a custom class like this: gameTime = new GameTime(hour, minute, day); Its updated every ingame minute

deft grail
#

ok so then just check if gameTime is 19 or bigger and under 6

#

you could have a static variable which can be a bool or enum or something to hold the state of if its day/night or you can just check the time in your player and set the variable based of that

regal bear
#

i have an enum already for day and night, like this:

    void TimerFunction()
    {
        minute += 1;
        if (minute == maxMinutes)
        {
            minute = 0;
            hour += 1;
            if (hour == maxHours)
            {
                hour = 0;
                day += 1;
            }

        }

        if (hour < nightTime && hour >= dayTime)
        {
            partOfTheDay = enumOfTheDay.Day;
        }
        else
        {
            partOfTheDay = enumOfTheDay.Night;
        }
        ClockUpdate.instance.UpdateClockUI(hour, minute, day);

        PlayerStats.instance.decreaseStat();


    }

regal bear
#

ye i know i just didnt know what should i create for this

#

and i got ideas along the way

deft grail
#

but just check if(partOfTheDay == enumOfTheDay.Night) {speed = 5f;} or whatever

regal bear
#

i'll refraktor the whole game, now i just try to do my imagination, then think about code and problems

rich adder
regal bear
toxic pine
deft grail
#

or in this method especially

regal bear
#

Ooooh i see omg

deft grail
# regal bear Ooooh i see omg

you would have a GameObject definitley GameManager maybe you can have DayNightManager and one of them will hold variables for the time/state of day/ other things you need

regal bear
#

Yes i have a TimeManager

regal bear
cinder crag
# cinder crag yep seems like it

i mean it loads the data n such but the ammo doesnt change or the players position doesnt change to where he was in the save so im a bit confused on how i could set lets say the player position to the saved player position in SaveData

deft grail
regal bear
#

let me check what is static xd

#

oh i see okay

deft grail
rich adder
deft grail
regal bear
deft grail
regal bear
#

Okay, but in my player where should i check the day/night cycle? start? update? thats what i don't know every time haha

toxic pine
rich adder
#

do you need seconds changed? minutes ? etc. figure out how precise you want event time to be

deft grail
cinder crag
regal bear
rich adder
#

Invoke an event , then each script can listen for a specific time for example

#

thats how I do it

deft grail
#

thought so event would be good, i have no idea how it specifically works though so i cant help with that

regal bear
#

oh god im so bad at coding lol

#

thinking but still don't know what step should i do now

rich adder
#

if its a custom time I generally make a struct for it

regal bear
# rich adder if you have the clock setup?

yes i have a clock, i have a UI element that displays the current time, and day. then i have an if statement for changing an enum to day/night. but these are running in every second real time which is a minute ingame

regal bear
#

I can show you my TimeManager script, if interested. I know its a mess but everybody starts somehow 😄

eternal falconBOT
regal bear
toxic pine
#

btw do you know how to make the walk animation instantly stop when i stop pressing a or d because right now the animation finsihes before playing the idle animation

rich adder
#

oh man that site..

regal bear
#

I know its a mess i accept tips, but i just don't want to copy paste from someone from a page

#

w8 then i'll upload to other

rich adder
regal bear
rich adder
#

half the page on pastebin is wasted space on "Advertisement" window

regal bear
#

sorry i always used pastebin.. always like 2 times in my life

rich adder
#

all good

#

Oh.. you already have a GameTime class

lost hamlet
#

Same as Fandom

#

Which everyone loathes

rich adder
regal bear
deft grail
regal bear
rich adder
#

how is this legible or good css work?

lost hamlet
#

Looks fine on my side

#

Or is that on mobile

rich adder
#

I use vertical screens and prefer code be vertical

lost hamlet
#

Oh

#

Anyway it doesn't have highlighting

#

So yeah i too prefer literally anything else

deft grail
rich adder
rich adder
#

instead of doing
timeclass.hour == preferredHour
etc..

#

you can do timeClass.Time == customThingAtTime
actually you said you dont need specific minutes so ig it doesn't matter for full time, checking hour would be sufficent 😛

sharp scarab
#

I need help in VC. I am the worst game developer on earth. I need with C# - Unity - Multiplayer!! Please!

deft grail
sharp scarab
deft grail
sharp scarab
#

With the game developer stuff man

regal bear
#

good 😄 and where should and how write the check for day and night? i mean i already have that enum, and works, but where to change the stat? if i put on start its only run once, if i write on update, my stat change in every frame

sharp scarab
#

@deft grail Ill paypal u if u can help at this point g

regal bear
#

how can i even run a function only in every hour?

rich adder
#

make event

cinder crag
sharp scarab
#

crypto friendly too

regal bear
rigid valve
#

i want to give my player reward if they reacheed this end of the convo and do someother action if they reached the other end

deft grail
sharp scarab
rich adder
# regal bear sounds good

if you're new to event u can use UnityEvent which lets you plug in other scripts' methods to run through inspector. Much like Button component OnClick

deft grail
sharp scarab
#

I am the worst I said

#

Come VC I will show you, you ask too much for my shity game dev skills

deft grail
#

then dont do networking or hard stuff

sharp scarab
#

I have to for the diploma

#

😂

rich adder
#

record a video then and explain in the appropriate channel?

regal bear
sharp scarab
#

3 weeks into unity and now I am doing networking bullshit

sharp scarab
deft grail
sharp scarab
deft grail
rich adder
sharp scarab
#

Do you have a server for VC?

rich adder
#

there is no voice channel here no

sharp scarab
#

Ain't got time for money sleeper

rich adder
#

please stop spamming channel with unrelated nosense

deft grail
#

he left, great 👍

regal bear
#

so if i add a UnityEvent i can pass in the enum, and when it changes it fires?

rich adder
cinder crag
#

welp im lost , tried making the variables static but didnt work so im not sure how i can set the player health to the saved player health etc notlikethis

rigid valve
#

@rich adder can u check my ink issue

regal bear
rich adder
regal bear
rich adder
#

eg
public static event Action<DayNightEnum> TimeOfDayChanged

TimeOfDayChanged?.Invoke(currentEnumVar)```
#

here static would be acceptable since its a general time clock

#

this way anyone can do
TimeScript.TimeOfDayChanged += MethodToRun

regal bear
#

oh ye i remember i saw this in a video few days ago, but can't remember yes thats what i was looking for

cinder crag
# deft grail its not that difficult?

my SaveAndLoadSystem is a singleton so i cant get references , i was thinking of making a script that holds static variables and then set those , example set the static playerHealth variable to the non static playerhealth variable etc then set the static varaibles to the saved data variables , not sure if i explained it good sorry

deft grail
rich adder
rich adder
#

just link that to a method, again using a third party plugin while you're still learning is like juggling chainsaws while riding a bike

cinder crag
rich adder
regal bear
deft grail
#

why not

cinder crag
rich adder
regal bear
#

@rich adder yes, but wait where should i put TimeManager.TimeOfDayChanged += decreaseStat(); ?

rich adder
deft grail
rich adder
#

that need to know about the day change

regal bear
#

or just anywhere?

shell sorrel
#

OnEnable

#

or Start

rich adder
#

yes ideally inside OnEnable

#

and unsub in OnDisable to clean up

regal bear
#

okay i guess i'll just watch a tutorial video about events

rich adder
cinder crag
shell sorrel
#

the method you give it requires the correct signature so 1 arg of enumOfTheDay

deft grail
cinder crag
#

when i press the continue button it needs to load the saved data

deft grail
#

or have your player in this scene to and make it transfer to the next scene

cinder crag
deft grail
cinder crag
deft grail
cinder crag
deft grail
#

just do it when you get into the main scene

cinder crag
regal bear
rich adder
regal bear
#

where should i? 😄

rich adder
cinder crag
rich adder
regal bear
#

!code

eternal falconBOT
regal bear
#

i know thats the bad place for invoke, but idk anywhere else

rich adder
#

usually Time.deltaTime is ok

#

if (hour < nightTime && hour >= dayTime)
this should be inside when Hour switches +1

#

ideally the whole thing should be a method
line 80 to 90

#

instead of cramming it in 1 if statement

regal bear
#

like this?

rich adder
regal bear
#

okay it works, now i get the Night log in every hour

misty coral
#

Can someone help me with this problem

rich adder
misty coral
#

As you can see with the recording, I am trying to have the camera be rotated when the gun shoots, but this is also rotating the 180 degree limit I placed on the camera

regal bear
#

yes, i want something like my character fatigue goes down twice as fast at night

#

but only at night

misty coral
#

Like when I look up completely, I start looking backwards

#

how do I rotate the camera but keep the clamp conditions the same?

rich adder
#

or could store the previous state of time of day and if its the same dont invoke etc.

#

get creative!

#
 void checkDayCycle()
    {
        if (hour < nightTime && hour >= dayTime)
        {
            partOfTheDay = enumOfTheDay.Day;
        }
        else
        {
            partOfTheDay = enumOfTheDay.Night;
        }
TimeOfDayChanged?.Invoke(partOfTheDay);
    }```
you can do this to track both btw if you need to know if previous was day
regal bear
# rich adder get creative!

i think i was when i created this time manager. ofc its not ideal, names are bad etc, but i figure out the whole code 😄 Now i can't do this for like 2 3 hours ( i know sometime i'll struggle for a week or month) thats why i asked u guys 😄 Thanks for the help, i tought there is something that i can do easier than booleans

#

nice thanks

misty coral
#

so how can I rotate without changing the clamp position?

tiny hawk
#

Hey champs, I'm using the terrain system to spawn tree. On those trees, I have a script that supposed to disable the MeshRenderer on them, so the trees are invisible. The reason for this doing is because I want to spawn trees at the same location as game objects so I can use RayCast on them. Ray Cast isn't working on the Terrain system spawned trees.

Here is my script. It isn't make the trees invisible:

    private void Awake()
    {
        // Spawn this this tree on this current trees position while also using Fishnet to spawn the tree
        MeshRenderer[] meshRenderers = this.gameObject.GetComponentsInChildren<MeshRenderer>();

        Array.ForEach(meshRenderers, meshRenderer => meshRenderer.enabled = false);


        this.gameObject.GetComponent<Collider>().enabled = false;
    }
regal bear
misty coral
#

how do I rotate a camera without messing up a clamp I put on it

deft grail
#

and check also the meshRenderers if theres anything in it after making it

tiny hawk
#

Oh smart. Thanks!

misty coral
#

I have simplified the above code, but my essential problem is that I can't clamp it to the axis it was at initially, does anyone have any idea of how to do such a thing?

#

How can I rotate the camera, but the clamp remains on the same rotation as it is initially sent to?

#

i really dont understand how what Im doing is effecting the clamping whatsoever

#

because the -90 to 90 are a fixed possible rotation

tiny hawk
deft grail
tiny hawk
#

All except for the trees actually hiding

#

But when I drag and drop a tree in the scene editor, and disable the mesh renderer on the LODs, the tree does disappear

deft grail
tiny hawk
#

It doesn't pop up in the Hierarchy

timber tide
#

it bakes it into the terrain

#

actually it's been a minute since I'ved used it, but usually that's how the vegetation like grass works, but the trees may be different

tiny hawk
#

The terrain system has an array. I could look through that, but not throug the scene editor I think.

timber tide
#

Yeah, the idea is it removed the gameobject overhead, but they do become a single drawcall

tiny hawk
#

I'm not sure how to achieve RayCasting this one

#

Especially I want to know when my player hit the tree

timber tide
#

getting the exact tree you hit may be a little hard as it combines it all into larger mesh colliders

#

an idea is to get your hit ray position and then make some positional dictionaries to get the nearest tree from that hit

#

if you want individual colliders then you may just want to place the trees yourself

#

Actually I may be wrong about that. Does raycasting a tree not return any collider information that's not specific to the terrain?

tiny hawk
shrewd bison
#

public float horizontalMovement; (1, 0, 0);
public float verticalMovement = (0, 0, 1);

can someone tell me whats wrong with this and why when i put it with

horizontalMovement = Input.GetAxis("Horizontal");
verticalMovement = Input.GetAxis("Vertical");

it wont move up or left and right

deft grail
slender nymph
#

start by making sure that your !IDE is configured so it will underline the obvious errors in the code because there are several issues with the first two lines you shared

eternal falconBOT
shrewd bison
#

yeah it says there is but idk whats wrong with it would i use vector3 in replacement of the xyz?

deft grail
#

that makes no sense

#

a float is 1 number

shrewd bison
#

oh yeah

deft grail
#

and GetAxis also happens to return a float, which is 1 number

shrewd bison
#

good point

#

{
public float speed = 5.0f;

// Start is called before the first frame update
void Start()
{
    horizontalMovement = Input.GetAxis("Horizontal");
    verticalMovement = Input.GetAxis("Vertical");


   Vector3 movement = new Vector3 (horizontalMovement, 0, verticalMovement);
    transform.Translate(movement * speed * Time.deltaTime);
}

i changed it to this

deft grail
#

you are giving a value to nothing

shrewd bison
#

public float horizontalMovement;
public float verticalMovement;

#

i added those 2

deft grail
# eternal falcon

you need to do this FIRST, and follow a basic C#/Unity tutorial if you arent already

shrewd bison
#

Well I had done that and I was reusing the info from the unity programmer junior and now im stumped so imma just figure it out

#

oh i was right the code was correct i just had it in void start and not update

deft grail
shrewd bison
#

Lol

#

I just started coding td so im not really sure what most stuff is

deft grail
shrewd bison
#

alright i will

formal escarp
#

Sorry but why only one "||" is not valid meanwhile the others are?

deft grail
#

you have closed the if statement then trying to continue to put code after

deft grail
#

nvm you are

formal escarp
#

Yes.

formal escarp
#

Im trying to make it so it checks whenever you are pressing WASD to activate animations.

formal escarp
deft grail
formal escarp
deft grail
#

yeah its banned to avoid spam

formal escarp
#

The " if (x != 0 && x < 0)
{
sr.flipX = true;
}
else if (x != 0 && x > 0)
{
sr.flipX = false;
}" is not checking it already?

formal escarp
deft grail
#

that x != 0 on both is pointless anyway, since you are checking if tis > or < 0

formal escarp
#

oh wait you are right

shrewd bison
#

is there a place i can learn how to link animation and boolean parameters to my characters WASD movement

deft grail
#

same goes with any other components and stuff you want to do

shrewd bison
#

wheres the docs

#

!docs

eternal falconBOT
shrewd bison
#

private Animator animator;

// Start is called before the first frame update
void Start()
{
    animator = GetComponent<Animator>();
}

// Update is called once per frame
void Update()
{
    horizontalMovement = Input.GetAxis("Horizontal");
    verticalMovement = Input.GetAxis("Vertical");


    Vector3 movement = new Vector3(horizontalMovement, 0, verticalMovement);
    transform.Translate(movement * speed * Time.deltaTime);

    if (verticalMovement > 0)
    {
        animator.SetTrigger(WalkingUp);
    }
    else if (verticalMovement < 0)
        animator.SetTrigger(WalkingDown);
}

}

Ok so i have this and it doesnt work if I use animator.SetTrigger or animator.Play

eternal falconBOT
deft grail
#

use InlineCode if its small or the links if its big code

#

if your making directional movement you can use a blend tree if i think it was called? in the Animator to make it much easier

shrewd bison
#

what if its a 2.5d environment would it still work?

deft grail
#

it just sets the animation based of values

#

you can pass your horizontal and vertical inputs im pretty sure

misty coral
#

how can I rotate a camera in script without rotating the clamp attached to it

#

I want my camera to be moved up everytime I click, but when I do this, it also moves up the clamp

misty coral
#

yea

#

or

#

i mean

rich adder
#

what does that mean

misty coral
#

rotates it

#

rotates it

#

not "moves up"

#

mb

rich adder
#

show code cause I have no idea what you're talking about tbh

misty coral
misty coral
#

as you can see from the video

#

shooting the gun rotates my camera, but also the clamp

#

before I restart the game in the video, you can see the 180 degree clamp allows me to rotate all the way backwards

#

when I restart, you can see that it works as intended

#

not lettering me look upsidown behind me

#

the moveCam method is called somewhere else btw

rich adder
#

should clean this up first also whats with that random Quaternion.Euler doing nothing

misty coral
#

thats a great question, when I first started unity like a month ago i followed a basic fps cam tutorial, so it must of done that for some reason

shrewd bison
#

@deft grail So i did this and did the same type of thing that it told me to do and yet it doesnt work how i want it to

deft grail
shrewd bison
#

so it either just runs the walking down and doesnt change

misty coral
shrewd bison
#

or i turn it off and it runs idle

#

i want it to be linked to W A S D

misty coral
rich adder
#

why are you setting euler angles twice

deft grail
shrewd bison
#

Wym?

deft grail
#

it should be 2

#

for X and Y

misty coral
deft grail
shrewd bison
#

one sec

misty coral
rich adder
misty coral
# rich adder I use cinemachine

do you know of any way or reason why rotating in script instead of with mouse input would result in the clamp being rotated aswell?

rich adder
#

its all rotated in script

misty coral
shrewd bison
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class PlayerController : MonoBehaviour
{
    public float speed = 5.0f;
    public float horizontalMovement;
    public float verticalMovement;
    private Animator animator;

    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        horizontalMovement = Input.GetAxis("Horizontal");
        verticalMovement = Input.GetAxis("Vertical");


        Vector3 movement = new Vector3(horizontalMovement, 0, verticalMovement);
        transform.Translate(movement * speed * Time.deltaTime);


        animator.SetFloat("MoveX", horizontalMovement);
        animator.SetFloat("MoveZ", verticalMovement);
    }
        else if
        {
            // Reset parameters to zero to revert to idle state
            animator.SetFloat("MoveX", 0);
            animator.SetFloat("MoveZ", 0); 

    }
}
#

it didnt work

deft grail
#

this makes no sense

shrewd bison
#

Yeah thats the code

#

why doesnt it make sence

#

sense

deft grail
misty coral
#

i cant be modifying the transform, which the clamp is based on

#

I need to modify verticalRotation

#

which simiulates a vertical input

shrewd bison
#

oh wait one sec

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class PlayerController : MonoBehaviour
{
    public float speed = 5.0f;
    public float horizontalMovement;
    public float verticalMovement;
    private Animator animator;

    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        horizontalMovement = Input.GetAxis("Horizontal");
        verticalMovement = Input.GetAxis("Vertical");


        Vector3 movement = new Vector3(horizontalMovement, 0, verticalMovement);
 
        if (movement != Vector3.zero) 
        {
            
            transform.Translate(movement * speed * Time.deltaTime);

           
            animator.SetFloat("MoveX", horizontalMovement);
            animator.SetFloat("MoveZ", verticalMovement);
        }
        else
        {
            animator.SetFloat("MoveX", 0);
            animator.SetFloat("MoveZ", 0);
        }
    }
}
deft grail
shrewd bison
#

They dont play

deft grail
magic panther
#

I have a problem that probably needs more evaluation in order to understand.

I am making a sokoban game as my first one, and so far I made the player move with WASD by 1 full object size. All walls and the player are scale 1, and there will be offgrid objects, so immediatelly, we can't store X and Y positions as variables of each object.

The problem is, that the collider recognizes a wall if I try to move towards one if the player and the wall share an axis, or a neighbouring one. You can see roughly how the detections work, and that obviously is not what we want.

Here's the code so far. This is the only script in the game so far, as the walls only have a box collider their exact size each. https://hastebin.com/share/pejunemibe.csharp

I'd do that later, but the way I'd like blocking to work is so crates are a possibility. I'd like each object that has a collider to have a function that is executed when something is attempting a push/interaction with it. With walls, nothing happens, so you are blocked if one is in the way. This means the function tells whatever tried to push it that it cannot do that. This way, crates work like this: Player attempts to move into crate -> crate checks for walls in the way -> if there's a wall, it can't move, if there isn't, it moves. -> if there is another box in the way, ask it if it can move, and repeat the process until a definitive response is given. We can use overrides for the function or something.

The previous block of text was a suggestion for if someone has time for that right now. But, really, all I need is for someone to explain what's wrong with my collision detection, and how I can fix it.

Here's also a pic of both the player and the wall objects.

shrewd bison
#

@deft grail

deft grail
shrewd bison
#

Ohhh

deft grail
#

thats not how you set the value of a blend tree

shrewd bison
#

i made it x and z

#

Should it be x and y?

deft grail
#

maybe

#

try it

shrewd bison
#

Doesnt work still

deft grail
#

show the logs again now

shrewd bison
#

logs are fine

deft grail
#

show the code where you put the logs

magic panther
shrewd bison
#
        if (movement != Vector3.zero) 
        {


            Debug.Log($"Movement: Horizontal={horizontalMovement} Vertical={verticalMovement}");


            transform.Translate(movement * speed * Time.deltaTime);

           
            animator.SetFloat("MoveX", horizontalMovement);
            animator.SetFloat("MoveY", verticalMovement);
        }
        else
        {

            Debug.Log("Character is idle");


            animator.SetFloat("MoveX", 0);
            animator.SetFloat("MoveY", 0);
        }
    }
}
deft grail
#

i think the problem actually is it requires a 1 or a 0?
have you tried holding your keys for a longer time or using GetAxisRaw instead

shrewd bison
#

Yeah it gets to 0 and 1 quick

#

but when it reaches that it doesnt work

deft grail
#

log the animator floats

#

after you set them

shrewd bison
#

like this?

#

or log every float

deft grail
#

show what you did, and get rid of the movement log as its flooding the console

shrewd bison
#

show the debug log code?

deft grail
#

yeah

shrewd bison
#

Debug.Log("Animator Parameters Reset: MoveX=0, MoveY=0");

deft grail
#

log the float after you set the float

shrewd bison
#

Like i did with movement?

deft grail
#

yeah, but log the animator float

shrewd bison
formal escarp
#

(I really dont like how his console is red even tho its not an error)

deft grail
#

just to make sure, what does the code for the log look like

deft grail
#

you can make it any colour

shrewd bison
#

Debug.Log($"Animator Parameters: MoveX={horizontalMovement}, MoveY={verticalMovement}");

deft grail
shrewd bison
#

oh ok

#

And for Y?

#

or

deft grail
#

yeah

formal escarp
#

!code

eternal falconBOT
shrewd bison
#

bro what i type in the thing it replacess the code and doesnt add

#

why

deft grail
shrewd bison
#

ty

shrewd bison
deft grail
#

ok so that looks like it should be working?

#

have you actually setup your animations correctly

formal escarp
#
     if (Physics.Raycast(castPosition, -transform.up, out hit, Mathf.Infinity, terrainLayer))
        {

            if (hit.collider != null)
            {
                Vector3 movePosition = transform.position;
                movePosition.y = hit.point.y + DistanceGround;
                transform.position = movePosition;
                Anim.SetBool("isRunning", true);
            }
            else
            {
                Anim.SetBool("isRunning", false);
            }
        }

        float x = Input.GetAxis("Horizontal");
        float y = Input.GetAxis("Vertical");
        Vector3 moveDirection = new Vector3(x, 0, y);
        rb.velocity = moveDirection * speed;

        if ( x < 0)
        {
            sr.flipX = true;
        }
        else if ( x > 0)
        {
            sr.flipX = false;
        }

Im having some trouble with the Anim.SetBool. I have an empty object which has this script attached. And it lets me move around, the problem i have is that when i move it plays both animations at the same time. There´s 1 Player on top of each other. One that does the Idle and one that Walks. And im not sure what to do 💀 i can share also screenshoots of my animator. I have the transition from Idle to Run with bools.

shrewd bison
#

how would they be incorrects

deft grail
deft grail
wild rivet
#

how do i add movement to my platformer?

deft grail
#

then set its .velocity or .AddForce

formal escarp
#

If i delete the child object everything breaks.

deft grail
shrewd bison
#

i did*

deft grail
rich adder
shrewd bison
#

ik

deft grail
# shrewd bison i did*

then it should work idk, record a video showing you playing the game and the animator on the side

formal escarp
shrewd bison
deft grail
shrewd bison
#

alright

deft grail
# shrewd bison

is the Sprite 0011 your player? does this hold the script and animator and stuff?

shrewd bison
#

no

#

toast is

deft grail
#

screenshot the entire inspector of both sprite and toast

shrewd bison
#

well ill have to tomorrow as im getting off bc i got school 😛

magic panther
shrewd bison
#

can you dm me or sum

deft grail
shrewd bison
#

alr

rocky canyon
#

if i have a static method enclosed in a namespace do i need the using statement to access it?

astral falcon
stuck crest
#

hello guys

#

event isnt invoking what do i do

#

its null for some reason

#

i subcribed for it in another script

#

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

public class SelectedCounterScript : MonoBehaviour
{
    [SerializeField] private GameObject visualCounter;
    [SerializeField] private ClearCounter clearCounter;

    private void Start()
    {
        Player.Instance.OnSelectedCounterChange += Instance_OnSelectedCounterChange;
    }

    private void Instance_OnSelectedCounterChange(object sender, Player.SelectedCounterChangeEventArgs e)
    {
        Debug.Log(e.selectedCounter);
        if (e.selectedCounter == clearCounter)
        {
           visualCounter.SetActive(true);
        }else
        {
            visualCounter.SetActive(false);
        }
    }
}
cosmic dagger
eternal falconBOT
stuck crest
astral falcon
#

You can throw a ? before .Invoke() to check if its null

stuck crest
#

so i did a null check

eternal needle
#

that means its not subscribed to by the time that you invoke the event

stuck crest
#

but how i subscribed in a start function

eternal needle
#

first thing to check is add a debug to see if Start even runs in that script. maybe its disabled. maybe you also have 2 instances of the player, you only have a static reference to it but theres no guarantee the reference doesnt get overwritten when 2 exist

stuck crest
#

hmm why doesnt start work tho

cosmic dagger
#

is the GameObject active?

eternal needle
#

is the object or script disabled?

cosmic dagger
#

does the GameObject have the script attached to it?

stuck crest
#

oh lol

#

thank you guys

#

its working now

#

i thot i added it

#

but i forgot maybe

misty coral
#

How can I do this with slerp or rotateTowards

#

i dont want it to rotate instantly

#

i want it to be more gradual

astral falcon
misty coral
#

How do I combine both of those commands into one line?

misty coral
#

I know how to use lerp and slerp, but idk how convey that specific direction I want into a singular slerp command

astral falcon
#

You create a new rotation with the offset and lerp to it

rigid valve
#

what am I missing here?

slender nymph
#

the fact that Update will not run if the object is disabled

#

also !code

eternal falconBOT
misty coral
#

I want to copy the cam transform, but when I execute the code it seems to be actually altering the orginal cam transgform

rigid valve
slender nymph
rigid valve
#

I did fix that part

slender nymph
#

okay so where are you calling that method

rigid valve
#

right here

#

evrything is working just this method isnt

slender nymph
#

what is BindExternalFunction?

#

or i guess more specifically, is this delegate being invoked off of the main thread?

rigid valve
slender nymph
#

that's not a helpful response because idk what that is supposed to mean

rigid valve
#

ink its used to make dialouges

#

I used that to kknow the charcter reached the end of convo

misty coral
slender nymph
#

okay and are you certain you are calling that method on the object in your scene and not perhaps a prefab or some other object?

#

you can also try logging some useful info like what you are calling CheckActivation on instead of that super useless "Hyy" log which tells you almost nothing

rigid valve
slender nymph
#

prefabs do not exist in the scene. so tell me how you can tell that isn't working

summer stump
# misty coral

I dunno what is going on, but that lerp is the EXACT same as writing transform.rotation = camTemp.transform.rotation

1 means return the second value. 0 means the first.

rigid valve
misty coral
slender nymph
misty coral
#

I made cam a Quaternion

#

and I do this in update

#

every frame

#

is there a better way

#

I can do this

rigid valve
slender nymph
#

the function is doing exactly what you've told it to do because you are calling it on a prefab which does not exist in the scene and therefore never had its Awake method called

rigid valve
#

So I'll need to do it for each tree seperately

#

?

slender nymph
#

yes

#

or use an event that all of those objects subscribe to

rigid valve
#

and I updated the code a bit

#

but this is still not working

astral falcon
#

Do you get any logs to check, what code is not being executed?

cosmic mural
#

i have a door object with two images for when its closed and when its open, how can i change the sprite of an object in a script attached to a different object

astral falcon
gilded kiln
#

Why I don't find in my packet manager the Lightwheight RP ?

#

I'm in 2022.3 version

astral falcon
gilded kiln
astral falcon
#

LightweightRP is an older renderpipeline, wonder how you connected this now to the 2D Lights. So what do you need actually? 2d lighting? or the renderpipeline?

gilded kiln
#

2D lighting

astral falcon
gilded kiln
#

Thx you so much for this quick help

astral falcon
static dawn
#

hi guys, i got a little bit confuse

#

does create too much text material variants affects apk build size significantly?

#

thx a lot

misty socket
static dawn
#

i often create text material like this when i want custom some new text style

static dawn
topaz mortar
#
        public async Task SavePlayerInfo(IExecutionContext context, IGameApiClient gameApiClient, string key, object value)
        {
            try
            {
                Dictionary<string, object> playerData = new Dictionary<string, object>
                {
                    { "playerName", "Pascal" },
                };
                _ = await gameApiClient.CloudSaveData.SetProtectedItemAsync(context, context.AccessToken, context.ProjectId,
                    context.PlayerId, new SetItemBody("playerData", playerData));```
~~I'm getting back an error: Unauthorized
I'm running this on my C# Cloud Code Module on UGS, the docs mention nothing about having to authorize~~
#

It worked fine with SetItemAsync but SetProtectedItemAsync returns error Unauthorized

twilit dirge
#

What would be the best way to handle seasonal tilemaps? Essentially replacing all the tilemaps and swap it with another spritesheet that's recolored

topaz mortar
#

nvm figured it out, just need to use context.ServiceToken instead

deft grail
twilit dirge
#

I read somewhere you can do it with shaders? but unfortunately there's no tutorials or anything

twilit dirge
#

is a TileBase another way to refer to a tileset?

twilit dirge
#

yeah im looking at that rn

#

but it says A tile

burnt vapor
keen needle
#

I want to make a script that calculates the trajectory of a bullet before firing. I can't find any answer that works for me. I want to calculate where it is going to land giving the initial speed of the bullet and the direction in which it is launched. But I need to be able to get the vector3 from the point where it would fall.

cinder spruce
#

Hello, there's a one milisecond delay when i call the method which sets the attack sword animation trigger

 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         Attack();

         // Check if an enemy is within range, in front of the player, and facing the player
         if (IsEnemyInAttackRange() && IsFacingEnemy())
         {
             // Damage the enemy
             DamageEnemy();
         }
     }
 }

void Attack()
{
    // Set the "Attack" trigger parameter in the Animator to activate the attack animation
    swordAnimator.SetTrigger("Attack");
}
#

How can i eliminate that?

gaunt ice
#

i think all you can do is to simulate it and find the hit point by physics system
there is no formula to do that, all formulas you can find online doesnt work since they dont know how your "world look like"

deft grail
cinder spruce
#

you think it's not the code?

deft grail
#

because it shouldnt be delayed

burnt vapor
#

I'm sure ChatGPT wrote proper code for you

#

When in doubt, maybe actually learn writing it yourself

deft grail
#

yeah ChatGPT is just overkill at this point, everyone using it and no one learning

#

it should only be used for actually complex stuff if you need help with it

cinder spruce
burnt vapor
#

This is a beginner coding channel. We don't help people that require help with AI generated code because that means you are too lazy to learn it yourself. "Lack of time" is not an excuse.

deft grail
#

@topaz mortar stop

topaz mortar
#

pretty sure a 1ms delay is undetectable?

cinder spruce
burnt vapor
#

I don't think an argument is needed here. AI code is very much frowned upon, so don't be surprised if you don't receive any help.

astral falcon
astral falcon
cinder spruce
astral falcon
#

So you can decide to continue discussing the hint on the conduct or just keep going with your issue. Im out for the first one

cinder spruce
#

Okay i don't wanna drag that argument but it says unverified AI generated response which means don't post AI generated code which you don't have any idea what it is. It wasn't the case here

astral falcon
#

Well, still keeps dragging.

cinder spruce
astral falcon
ionic plank
#

Hey guys i have a problem with my gameover i think

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Gameover.ShowGameOverScreen (System.String deathType) (at Assets/Script/Game/Gameover.cs:20)
Death.DeathHandler (System.String deathType) (at Assets/Script/Game/Death.cs:38)
Death.OnCollisionEnter2D (UnityEngine.Collision2D collision) (at Assets/Script/Game/Death.cs:17)

Can someone help me ?

deft grail
#

and what the problem is

ionic plank
#

I am a very beginner so it's new for me everything

deft grail
astral falcon
ionic plank
#

I pretty sure that i never destroy it ...

deft grail
ionic plank
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using TMPro;
public class Gameover : MonoBehaviour
{
    public GameObject gameOverScreen;
    [SerializeField] TextMeshProUGUI timerText;
    float timespend = 0;
    // Start is called before the first frame update
    void Awake()
    {
        gameOverScreen.SetActive(false);
        Death.OnPlayerDeath += ShowGameOverScreen;
    }
    void ShowGameOverScreen(string deathType)
    {
        gameOverScreen.SetActive(true);
        Time.timeScale = 0f;
    }

    void Update()
    {
        timespend += Time.deltaTime;
        int minutes = Mathf.FloorToInt(timespend / 60);
        int seconds = Mathf.FloorToInt(timespend % 60);
        int milliseconds = Mathf.FloorToInt((timespend * 1000) % 1000);
        string timeElapsed = string.Format("Temps écoulé : {0}:{1:00}:{2:000}", minutes, seconds, milliseconds);
        string totalTime = "1:30:000";
        string formattedText = timeElapsed + " / " + totalTime;
        timerText.text = formattedText;

        if (Input.touchCount > 0)
        {
            gameOverScreen.SetActive(false);
            Time.timeScale = 1f;
        }
    }

    void OnDestroy()
    {
        gameOverScreen.SetActive(false);
    }
}

#

This is my game over scrypt

ionic plank
#

gameOverScreen.SetActive(true);

deft grail
#

show the Death script

ionic plank
#

do you know a better way to show my code ?

deft grail
#

!code

eternal falconBOT
ionic plank
deft grail
#

do the other script as well

astral falcon
#

You are registering on an event and never unregister from it

ionic plank
languid spire
ionic plank
#

Yes because i want the user to touch the screen to set the timescale to 1 again

astral falcon
#

So, if you debug log your gameOverScreen. Is that returning null?

languid spire
#

but I told you Update does not run, so how do you think that is going to happen?

ionic plank
#

cause i have a timer and i want to stop it when the gameoverscreen apear

languid spire
#

not if Update is not running it won't

ionic plank
languid spire
#

because the timescale is not being set to zero due to your missing reference exception

astral falcon
#

Forget what I just wrote 😄

languid spire
#

when timescale is 0 Update does not run

astral falcon
#

Thats true, but should nt we fix the first problem first? 😄

ionic plank
astral falcon
# ionic plank I'm trying to do it XD

Nah, that was for steve and my wrong assumption of update. But yeh, back to your issue. Can you please debug log your gameOverScreen above line 20?

ionic plank
#

The name 'gameoverScreen' does not exist in the current context

astral falcon
#

yeah... brain.Start(); please

#

check your spelling

#

and !vs just to be safe 😉

#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

languid spire
#

Also can you screenshot your hierarchy showing the object with the Gameover script

ionic plank
ionic plank
languid spire
astral falcon
#

thats why I posted the tutorial on how to setup visual studio, if your ide did not autocomplete it for you

ionic plank
#

Canvas

languid spire
#

Ok, I see Gameover has an OnDestroy method, which means if it is Destroyed then all of it's children are Destroyed as well

ionic plank
astral falcon
# ionic plank Do i need to unregister from the event ?

yep, you always should in OnDisable and register with OnEnable. Imagine you register to the event and destroy that script/Gameobject that has been registered. That will result in a missing reference inside your events subscriber list

ionic plank
#

so i need to use -= ?

#

to unregister

swift crag
#

Correct.

#

Doing this in OnEnable and OnDisable is a pretty safe default.

willow scroll
# ionic plank so i need to use `-=` ?

Say, you have the 1st class, which calls the event, and 2nd one, which subscribes to it.
If the 2nd class lives longer than the 1st one, you'll definitely have to unsubscribe it from the 1st class' event, for the 1st class not to call the event for the 2nd one, which has already been destroyed.
If the 1st class lives longer than the 2nd one, you don't necessarily have to unsubscribe the event, but it's usually a better practice.

#

And the subscription and unsubscription are usualy done in the OnEnable and OnDisable methods respectively

ionic plank
#

i'll try this

onyx tusk
#

how 2 make dragging for 3d object? (i need constant y & it's already known)

languid spire
onyx tusk
languid spire
#

well if you googled Unity IPointer, then read the documentation, you would know

onyx tusk
languid spire
#

iirc OnMouse methods do not work with 3D objects, IPointer interfaces do

onyx tusk
#

they work, i all project made with it

astral falcon
#

yep, mouse methods work with the collider

languid spire
#

wait OnMouse only works with triggers

onyx tusk
#

idk, i know only what OnMouse doesn't work with objects on canvas

#

even with colliders (yes, i really added collider 2 it)

elder raptor
#

Is there any way I can run a function when a Serializable Public Variable's value is changed? For example, if I have a float tat goes from 0 to 1 and has a slider in the inspector, the moment I change the value of the float in the inspector, I want to assign that value to another variable in another script.

elder raptor
#

I also saw something called OnValidate() will that work too?

onyx tusk
onyx tusk
#

may work

elder raptor
#

Yeah will try that instead as get and set just makes the code longer

#

Yeah it worked perfectly, thank god.

cinder crag
#

good lord , im stuck here , so im saving and loading the saved data but i wanna set lets say the player position to the saved player position or player health to the saved player health but im not sure how i can do that without using references since my SaveAndLoadingSystem script is a singleton and there is the Load method which is when i wanna set the health or player position to the saved data ones and im not sure how to do it without needing references

onyx tusk
cinder crag
onyx tusk
#

for example, i making chess & in file i have moves for figures

#

& i load it by foreach(Match i in Regex.Matches(fileInString, "pattern")

gaunt ice
#

impossible
you must reference the player object to change it value (idk how to change the data of some objects that you have no idea where they are) but your save and load system can use the existing player reference in other object eg game manager

onyx tusk
#

& i checking what is this move type, coded in letter, directionX, directionY coded by ints (int.Parse("120") = 120), & type of move coded by symbol or 2

#

about situations where you know where is a symbols in string from 1 of edges, you can just i[index]

topaz mortar
#
        {
            var playerData = await CloudSaveService.Instance.Data.Player.LoadAsync(new HashSet<string> { "playerData" }, new LoadOptions(new ProtectedReadAccessClassOptions()));
            Unity.Services.CloudSave.Models.Item testItem = playerData["playerData"];
            Debug.Log(testItem);
            Debug.Log(testItem.Key);
            Debug.Log(testItem.Value);
        }```
testItem.Value is Unity.Services.CloudSave.Internal.Http.JsonObject
How do I access or deserialize that? Or whatever I'm supposed to do with this to get my stored value?

I've been going through the docs for two days, but can't figure it out.
chrome tide
#

Here i have this code, it's for a Monster AI which walks blindly when not hearing anything, but chases the loudest audio source once it's too loud: https://pastebin.com/TW4xtbgu
The problem is that when the loudestSource is changing position (for an example: it's a player), the script doesn't update loudestSource position, so the agent is going to the last known position of the loudestSource, and then it just stays here, waiting for the player to stop making noise, so it return to the Roaming state.

teal viper
chrome tide
#

oh wait, i think i know why it doesnt work.

mystic dawn
#

Hey there people! can anyone help me try to understand how to add multiple jumps in my 2d player script?

basically i have this script with jumpbuffering and coyote time set and working fine, but i really can't think of a way to add multiple jumps with all these, i've tried implementing it but with poor results, does anyone have some advice?

chrome tide
teal viper
#

Ah, I see you have something similar with remainingJumps. Is it not working?

Also, share the !code properly.

eternal falconBOT
mystic dawn
#

i did so but it really does not work i can't really think of where to place the check in my script, i have a variable remaining jumps but it's not working where i placed it

mystic dawn
mystic dawn
#

yeah it's not working i don't really know where to put the check tbh

teal viper
teal viper
#

Use debug logs or the debugger to debug important information to understand what's going on

mystic dawn
molten dock
#

chung

stoic glen
#

How can I rotate the security camera that it faces into the right direction?
I thought about using the normal vector, but I don't know how to implement it.
I use a raycast for the position

gilded kiln
#

Hi can someone help me it's a problem with no f*cking reason to happen, juste two GO that i can't use SetActive() on them for no reason

wintry quarry
mystic dawn
#

i was thinking maybe completely removing jumpBuffering as it's pretty much a form of "extra jump" but im not sure

wintry quarry
stoic glen
wintry quarry
# stoic glen

you'd have to show the gizmos for the object's local axes

#

so we know which way the mesh is facing

gilded kiln
#

if i can

wintry quarry
#

but likely either your code isn't running, or you are referencing the wrong objects

stoic glen
wintry quarry
gilded kiln
#
float direction = moveScript.moveDirection;
    GameObject sideToActivate = (direction > 0) ? rightSide : leftSide;

    if (sideToActivate != null && isAttacking == true)
    {
        rightSide.SetActive(sideToActivate == rightSide);
        leftSide.SetActive(sideToActivate == leftSide);
        if (sideToActivate == rightSide)
        {
            glowAttackEffectright.SetActive(true);
            Debug.Log("glowAttackEffectRight");
        }
       else
        {
            glowAttackEffectright.SetActive(false);
            Debug.Log("PKSASEDESACTIVEPTN");
        }
        if (sideToActivate == leftSide)
        {
            glowAttackEffectleft.SetActive(true);
        }
        else
        {
            glowAttackEffectleft.SetActive(false);
        }
    }```
wintry quarry
#

but if that's the case then you basically want:

camera.transform.rotation = Quaternion.LookRotation(surfaceNormal, Vector3.up);```
gilded kiln
#

The effectsglow aren't working but the rightSide and left are working

wintry quarry
#

Debug.Log around each SetActive call would help

gilded kiln
wintry quarry
gilded kiln
#

But it's not help me

wintry quarry
gilded kiln
#

Now i can't maybe later

#

bcs i leave

stoic glen
#

How is select which camera is selected at startup?

wintry quarry
#

What do you mean by "selected"?

stoic glen
#

When I have 2 cameras in a scene, when the game is started which camera is on the screen

wintry quarry
#

The order in which they're drawn is determined by their depth

stoic glen
#

Is there an UI element that shows the depth

wintry quarry
#

UI element?

#

it's in the inspector if that's what you mean

stoic glen
#

Thx

summer shard
#

yo is there a way to like make dictionaries in inspector? like i want to make messages in ui, i don't want to make 5 scroll views and want to make it procedural, i could make an array of string but i'd have to add either "Me: " or "[User's name]: " to each message and i could misspell something so i want to make like a dropdown to choose a user and a message they sent, is there a way to do it?

#

i think there was something like that in line renderer?

#

yea, sum like that but with enum and string

summer shard
wintry quarry
#

There's only one kind of struct

summer shard
#

ohhh

molten dock
#

how do i have transform.lookat not apply to upward and downward rotation

wintry quarry
#
Vector3 lookTarget = whatever;
lookTarget.y = transform.position.y;
transform.LookAt(lookTarget);```
e.g.^
summer shard
wintry quarry
summer shard
#

okay it shows up in the inspector, thanks

main karma
#

hello! I'm trying to make a 3D platform system for my player (I'm using a character controller) and I do not know how do I handle the collision between the player and the platform, I tried parenting the player to the platform and unparenting it when he jumps off, which work's fine if the platform only moves in horizontal axis, but vertical movement is still very janky whenever the platform moves faster than the player can jump

#

Any tips or good practices that I should be doing?

#

also whenver the player is on a platform and a different platform hits the player it just goes through him, which is an issue

hollow dawn
#

guys. how do I make it so when pressing shift my player runs and the run animation plays and when letting go the run animation stops? right now when I let go of shift my player still runs

atomic yew
#

Hello everyone, I have a question. I'm almost done with my game, but can I find the game registration, login and settings parts in Unity Asset or should I prepare it myself? If there is an asset you know and it is good, that would be great. I would finish the game at least 2-3 days early.

atomic yew
marble coral
# main karma Any tips or good practices that I should be doing?

There is a bunch of solutions to that and (as always...) it depends on your implementation and gameplay goals, I suggest checking out some YouTube tutorials on "moving platforms" in Unity. I personally haven't had this problem when developing because I was using physics-based movement (HexaBody)

main karma
marble coral
# main karma I looked over a bunch of stuff, but I can't find many 3D resources

https://forum.unity.com/threads/player-stick-to-moving-platform-two-ways-solution.345086/
Here are 2 example solutions
Just Google it, there is about 10 YouTube tutorials and multiple forum and reddit posts with solutions

And it also depends on how you move your player, for example, when jumping off, you should add velocity of the platform to your player because that's how physics work

molten dock
#

is there a name for when you put an if bool == true in your if statement and then put bool = false within the if statement

#

to make it only occur once

rich adder
summer stump
#

Not that I know of

rich adder
#

idk what u mean

wintry quarry
#

unless you put it in a loop

summer stump
#

They mean
if (thing == true) thing = false;

#

Then never set it true again