#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 420 of 1

sharp abyss
#

The pbject I put that script on right?

#

Not the one it collided

rich adder
#

You can put it on either object that collide/trigger with eachother

#

up to you

sharp abyss
#

I was trying to check if rightleg or leftleg collided in the same script thats why I asked

rich adder
#

what are you trying to do exactly

#

wdym " rightleg or leftleg collided in the same scrip"

#

are you trying to ignore collisions between the two ?

sharp abyss
#

No

#

If the right leg collides a bool will turn true , if left leg collides other bool will turn ture

rich adder
#

gotcha

sharp abyss
#

But I wanted to check that in their parent gameobject

#

Because I have a script about walking in parent

#

Would this work in that case?

rich adder
#

iirc inside the parent object you have no way to determine which one called the collision

#

only the rigidbody of those colliders

#

or the collider hit

#

if you put script on each leg then send a message into a parent script, you can probably do that

sharp abyss
#

That came like the long way to me thats why I tried something different

#

Thx ๐Ÿ˜Š

limber bear
#

How do i assign?

limber bear
rough shore
#

hi

#

anyone can help me with my problem ๐Ÿ˜…

rich adder
#

you still haven't posted the problem

#

don't ask to ask

rich adder
rough shore
cosmic dagger
#

jn

rich adder
#

are you using the VSCode one

cosmic dagger
#

'?j"

#

kk

#

kkkkkkk

#

k
K"k

rich adder
#

are you ok Random lol

rough shore
rich adder
eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

rich adder
#

follow this link

spiral glen
#

anyone know why DelayStart isn't activating and instead it's just spamming "start"

eternal falconBOT
rich adder
#

!screenshots

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

rich adder
#

that is also not how you call a coroutine (look at the 3 dots on the method, Visual studio is trying to help you)

spiral glen
#

oh damn

polar acorn
spiral glen
#

wdym it's I spelt it right?

rich adder
spiral glen
#

apparantly there's no objects

queen adder
rough shore
rich adder
spiral glen
#

oh I thought I put less than
I am a fool, I know nothing, I take the role of a silly clown.

polar acorn
rich adder
#

they're missing brackets it should be lighting up like a xmas tree

rough shore
#

i don't have an 'input box' to choose objects?

rich adder
#

ideally to configure their ide

rich adder
polar acorn
queen adder
#

shouldnt be that bad if the missing bracket is on the last

rich adder
queen adder
#

but yea, c# dont care

queen adder
eternal falconBOT
rough shore
rich adder
polar acorn
queen adder
#

well, vsc is smart enough to consider them inside

rough shore
#

but i have download the unity extension

rich adder
queen adder
#

oh tf they dont lol

polar acorn
eternal falconBOT
rich adder
cobalt atlas
#

I made a Capsule in unity 3D. I then rotated it on the Z axis by 90 degrees. what I want to do is point the Y local axis green arrow of the game object towards another game object. how can I do that in the code

polar acorn
rich adder
#

||transform.up = (target - myPos).normalized||

cobalt atlas
cobalt atlas
spiral glen
#

anyone know why when I move objects in the editor they only go a fixed distance?

#

like I drag a cube and it goes x=1, x=2, x=3 when I'm trying to do x=1.5

spiral glen
#

wrong chat mb

rich adder
spiral glen
#

thanks

fierce geode
#

Does GetComponentInChildren work if the children arent enabled?

static condor
#

Heya, does anybody have any pointers on why my windowed fullscreen (borderless) has the same exact behavior as exclusive fullscreen? Are there any issues with changing between them at runtime? Windowed and exclusive fullscreen work perfectly though
My code:

public void OnScreenModeChange(int index)
    {
        switch (index)
        {
            case 0: // Fullscreen (Exclusive)
                Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, FullScreenMode.ExclusiveFullScreen);
                break;
            case 1: // Windowed Fullscreen (Borderless)
                Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, FullScreenMode.FullScreenWindow);
                break;
            case 2: // Windowed
                Screen.SetResolution(1280, 720, FullScreenMode.Windowed);
                break;
        }
}
eternal needle
# static condor Yes sir

are you sure they're functioning the exact same, and just to be clear you're testing in a build right? im fairly certain one of them should be quicker for switching with alt-tab

static condor
#

It might be working and I am just not noticing the difference haha

#

but it feels the exact same

eternal needle
#

Not entirely sure how to link an exact reply from the unity forums, but the comment from Ryiah

static condor
#

So real exclusive fullscreen doesn't exist with directx 12, so I'll just not include it as a feature in my game

eternal needle
#

i gotta test in my game too because i included it as a setting ๐Ÿ˜…

static condor
#

nice find on the thread thumbs thanks dude

eternal needle
#

its weird because I do recall other games having these options, now i know at least it doesnt matter if i choose it

drowsy oriole
#

how do i make it so that i can get a component from a gameobject script and make it a string on the script im working o

eternal needle
drowsy oriole
#

I am making a tag based game and im new to scripting so i put "tags = GetPlayerTags.playertags" with a public gameobject GetPlayerTags at the start

eternal needle
#

or just directly drag in the script rather than storing a game object, so you dont need get component at all

wintry quarry
eternal needle
#

99% sure its a gorilla tag mod or clone

drowsy oriole
wintry quarry
#

What do you mean by tag

rich adder
drowsy oriole
wintry quarry
#

Like tag youre it?

drowsy oriole
#

omg

eternal needle
# drowsy oriole mod

modding discussions arent allowed in the server, so you'll need to ask in the games server/modding server if they have one

drowsy oriole
rich adder
#

before modding you should probably learn how to read an API

wintry quarry
drowsy oriole
#

im not mod

wintry quarry
#

!learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

drowsy oriole
#

modding

#

i have less than 30 minutes not 750 hours

rich adder
#

alr anyway start from beginnning

drowsy oriole
#

CAN SOMEONE JUST HELP ME plzzzzzzzz

rich adder
rich adder
drowsy oriole
#

just tell me what to type instead plzzz

rich adder
wintry quarry
drowsy oriole
rich adder
drowsy oriole
#

I need to grab a component from a script in a gameobject how do I put that oin "tags = GetPlayerTags.playertags" dosent work bc its not right

rich adder
#

yes you can't write random stuff and expect it to work

eternal needle
drowsy oriole
#

im blockin this kid

eternal needle
# drowsy oriole im blockin this kid

Go ahead, im the only one thats probably given you resources for help. Its not like this is the first time you've spammed and begged for help with the most basic of c#

summer stump
#

Bawsi has given you the answer
Like the actual, exactly what you need to do answer

rich adder
eternal needle
#

To be fair, they are a child so i dont really expect more

summer stump
#

Terrified of the day my daughter is a 12 year old, like they are.
Hopefully they won't act like they do, but ๐Ÿคทโ€โ™‚๏ธ

rich adder
#

yeah but common sense and matters should exist early... my nephew is young he certainly dont act this way

teal viper
cosmic dagger
#

rolls up sleeves . . .

queen adder
# drowsy oriole im blockin this kid

People are saying this to you because they are more experienced than you, and know that new people most of the time start too big instead of simple cube and spheres games. You're trying to mod a multiplayer game which is even harder

cosmic dagger
drowsy oriole
#

how do i make something happens when a string says aspecific word or number

frosty hound
#

Drop the tantrum

#

You have to define the rules of what you consider to be a specific word or number. Does casing matter, does it just have to contain the words/numbers, or be exact.

drowsy oriole
#

2htwht?

#

what?

drowsy oriole
summer stump
#

Ah, a string. Read that wrong

drowsy oriole
#

yea

summer stump
#

Where is the string coming from? Are you converting it FROM an int?
If not, you gotta parse it
It it is, skip the string and check the value

drowsy oriole
#

no

#

how do i parse it?

summer stump
drowsy oriole
#

Ty this helped so much

rustic valve
#

help, suddenly I cant change the rotation and scale of a child object while the game is running, in this case the sprite is a child of the player

queen adder
mint remnant
#

I got a camera attached to a player object in 3D and using this:
cameraTransform.position += cameraTransform.forward * scroll * 1000 * scrollSpeed * Time.deltaTime;
to scroll the camera in and out from the player's look direction. How would I clamp it from going through the player?

rustic valve
#

It only has this script, and yesterday used to work just fine, today I havent touched it but it stopped to work
(Quaternion newRotation = Quaternion.Euler(0, 180, 0);
Sprite.transform.localRotation = newRotation;)

queen adder
eternal falconBOT
cosmic dagger
rustic valve
cosmic dagger
rustic valve
#

oop sorry

mint remnant
cosmic dagger
rustic valve
queen adder
raw token
#

I believe that would only limit the speed and not the actual position, no?

mint remnant
#

but wouldn't that allow me to like scroll out, but then not back in due to clamping the input part?

queen adder
#

I think it should work, try it

queen adder
#

Sorry for being so vague im unsure how to explain it properly

#

But yeah since its using position, it wouldnt be accurate

rustic valve
queen adder
#

I did something similar to this in my own game so im trying to remember

raw token
#

@mint remnant you mentioned that you had "attached a camera to the player" - by that, do you mean that the camera Game Object a child of the Player Game Object?

mint remnant
#

yea, that didn't really do much, I think what @cosmic dagger suggested might be along my best options

queen adder
#

Yeah mb for bad advice

mint remnant
raw token
mint remnant
#

a compicating factor is I also have code that allows mouse movement to rotate the camera, but I may have to re-think scrolling with the rotating as that can make it so the scroll vector might not be aiming in a constant direction

rustic valve
#

why i can't rotate a object when I hit play, it only has Sprite Renderer and animator

#

omg i found the error, it was the animator "Apply root motion"

thorn lake
#

Which channel would be best for an extremely simple GitHub Desktop question?

Mainly I just learned how to use the repository for my first time and I'm wanting a better explanation of what "Fetch Origin" means than what I'm seeing online. Also once you publish a project to GitHub does it continue to update as you make changes in GitHub Desktop? Or do you need to repeatedly republish it to GitHub? (Is that what a push is, isn't it?)

Online I'm seeing Fetch Origin to mean that it "fetches" data rather than "pulling" it into your code, but idk what data they mean or whn/why I would ever use Fetch Origin.

TLDR: When would you use "Fetch Origin" and why? Is it only for group (and not solo) projects?

mint remnant
#

it's been a while, but you have to remember you have a local repository and the one on gitHub, you can commit changes to local, but then I think only on a push does it update the gitHub one

eternal needle
mint remnant
#

also compare to git rebase

eternal needle
# thorn lake Which channel would be best for an extremely simple GitHub Desktop question? M...

Also once you publish a project to GitHub does it continue to update as you make changes in GitHub Desktop? Or do you need to repeatedly republish it to GitHub? (Is that what a push is, isn't it?)
It only updates what you push to it. With github desktop its really just a matter of pressing 2 buttons but in reality you're adding the changes, commiting them along with a message describing the commit, then pushing them to the repo. You can commit many times before pushing, but this would only be local (on your computer, not shown on github)

bright grail
#

i have a rq question so I'm making a Game manager to help keep track of the game state and to do so i need to change states based off of if all the enemies were killed so i put all enemies spawned in a list and checks when it hits 0 to change to state 2 but then in state 2 there saved to the same list and when that hits 0 it keep repeating so I'm wonder should i create a bool to check if the state in currently is the next one or should i just make a list for each new state?

eternal needle
bright grail
#

i have a rq question so I'm making a Game manager to help keep track of the game state, However to do so i need to change states based off of if all the enemies were killed. so i put all enemies spawned in a list and checks when the list hits 0 to change the state to the next one. Then in state_2 All the enemies are saved to the same list as in the first one. so when that hits 0 it keep repeating. so I'm wonder should i create a bool to check if the state in currently is the next one or should i just make a list for each new state? here code if needed https://gdl.space/ujiyurexux.cs

eternal needle
mint remnant
#

not really part of your question, but you shouldn't if check a 2nd state if you checked one already. Switch to and if else tree or even better use a switch case scenario

bright grail
mint remnant
#

you might want to include in this statement if (SpawnedEnemys_1.Count == 0) something like && GameState == GameState.Whater

bright grail
#

ok thank you ill try that out

mint remnant
#

the main concept of a state machine is it has defined states and you can only move from one state to another, so let the state machine do the transitions, and draw out a state machine diagram to make sure you stick to it in code

bright grail
#

ok thank you sorry still trying to make this first game totally alone

eternal needle
eternal needle
fierce geode
#

Is there a delay between setting a variable and being able to use it?

eternal needle
bright grail
#

im kinda following one but again this game is totally different, and im making one on my own this time to get more of a feel for it.

mint remnant
#

if you're doing multi-threading you could set a variable and another thread might change it before the next line

eternal needle
bright grail
#

yea im prolly gonna do that now that you bring it up

next bolt
#

https://gdl.space/paniyofuzu.rb I'm making an animator but i need a way to make it so when the player stops pressing WASD respectivly it sets the bools to false and floats to 0. Any ideas?

#

btw its in update

mint remnant
#

Input.getkeyup?

fierce geode
next bolt
bright grail
next bolt
bright grail
#

ok so your issue is when you stop pressing keys you want it to set all of the bools to false and floats to 0?

next bolt
#

correct

bright grail
#

does your character face 4 different ways?

next bolt
#

yes

#

but once i say click S it keeps that boolean as true

fierce geode
#

Also just realized that it's wrong to be setting velocity directly.. which is what I've been doing for most of my projects.... whoops

bright grail
fierce geode
#

I heard it was a bad practice to set velocity directly.

next bolt
eternal needle
next bolt
#

thank you

bright grail
ivory bobcat
next bolt
#

Omg youโ€™re so fuckin right thank u bro

ivory bobcat
#

For example: modifying velocity-y every frame but wondering why gravity isn't working properly - same applies for directional forces being applied to the object.

limber bear
#

Why doesnt this work together?

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

public class PlayerController : MonoBehaviour
{
    public float moveSpeed = 5.0f;          
    public float mouseSensitivity = 100.0f; 
    

    private float horizontalRotation = 0.0f; 

    void Start()
    {
        
        Cursor.lockState = CursorLockMode.Locked;

    }

    void Update()
    {
        
        Vector3 movement = Vector3.zero;
        findObjectOfType<grounddetection>().Getbevegelse();

        if (Input.GetKey(KeyCode.W))
        {
            movement += transform.forward;
        }
        if (Input.GetKey(KeyCode.S))
        {
            movement -= transform.forward;
        }
        if (Input.GetKey(KeyCode.A))
        {
            movement -= transform.right;
        }
        if (Input.GetKey(KeyCode.D))
        {
            movement += transform.right;
        }
        if (Input.GetKeyDown(KeyCode.Space) && (isColliding==true))
        {
            GetComponent<Rigidbody>().AddForce(Vector3.up * 300);
        }

        transform.position += movement.normalized * moveSpeed * Time.deltaTime;

        
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        

        
        horizontalRotation += mouseX;
        
        transform.localRotation = Quaternion.Euler(0, horizontalRotation, 0);

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

public class grounddetection : MonoBehaviour
{
    public bool isColliding = false; 

    
    void OnCollisionEnter(Collision collision)
    {
        isColliding = true;
            
        
    }

    
    void OnCollisionExit(Collision collision)
    {
        
        isColliding = false;
            
        
    }

    void Getbevegelse()
    {
        return isColliding;
    }
} ```
eternal needle
eternal falconBOT
limber bear
#

ohh sorry

#

here the errors

mint remnant
#

findObjectOfType<grounddetection>().Getbevegelse(); guessing it failed to find that object

eternal needle
eternal falconBOT
mint remnant
#

yea something really wonky, if you're getting win32 compile errors

eternal needle
#

theres just basic c# mistakes, misspelled function name and also 2 of those errors seem to be in different scripts

limber bear
#

ohh okay. il try to figure it out

#

tnx for the help

tepid summit
#

anybody know if/how i can save data from my scene into a file with a script

mint remnant
#

if it's small data maybe look at playerprefs

tepid summit
#

ah ok

#

ty my friend

echo hamlet
#

I know this is stupid but I can't figure how to get the velocity.

fierce geode
#

is there a way to make all boxcolliders visible in scene?

mint remnant
#

BocColliders is an option in Gizmos drop down

burnt vapor
#

Regardless of size, PlayerPrefs should be considered a temporary solution

copper horizon
#

hi guys need help regarding ads, i have tested the ads it is working but after build the real ads are not showing what to do??

stiff birch
#

IIRC there is an autoplay option in the PS that you should disable and then you control it from your behaviour so that you can start, pause or stop the playback whenever you want.

wispy finch
eternal needle
stiff birch
glossy turtle
#

by changing the start delay timer using script.

eternal needle
#

Assuming they get back to us on if my interpretation was correct

split dragon
#

Hi. I've been trying to solve my problem over the Internet for an hour now: I want to use void onMouseEnter, but it doesn't work at all. I've already simplified everything to Debug.Log(), but it still doesn't work. On the Internet, I saw that I needed to change the Input System to New or Both (New does not work and set Both - as they said on the Internet). I'm already tired of all this. How to solve this?

eternal needle
glossy turtle
split dragon
glossy turtle
split dragon
#

In 2 photos there is a cube that has a box collider.

stiff birch
# split dragon

I don't see it on screen but I suppose your Quest script is attached to this same cube ?

split dragon
#

And, you need to attach a script to the object itself, not to the camera... Thank you. I'm sorry I was dumb.

glossy turtle
stiff birch
#

It's alright, that's how you learn ^^

elder raptor
#

I have an issue here that when the parent object turns 180 in y, the aimObject gets flipped. How can I fix this?

 Vector2 direction = GetJoystickDirection();
 if (direction != Vector2.zero)
 {
     float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
     aimObject.transform.localRotation = Quaternion.Euler(0, 0, angle);
     // Flip character based on aiming direction
     if ((angle > 90 && angle < 270) || (angle < -90 && angle > -270))
     {
         transform.rotation = Quaternion.Euler(0, 180, 0);
         aimObject.transform.localRotation = Quaternion.Euler(0, 0, -angle);
     }
     else
     {
         transform.rotation = Quaternion.Euler(0, 0, 0);
     }
 }
eternal needle
elder raptor
#

I just changed it to .rotation

#

It doesn't rotate tho, I think the Y Rotation is wrong

eternal needle
elder raptor
#

Yeah, it is running. I changed the code to this as I though if I can just flip it 180 when the entire parent flips, it might work. But for some reason, the value becomes -180?

if (isAimingWithButton)
{
    Vector2 direction = GetJoystickDirection();
    if (direction != Vector2.zero)
    {
        int num = 1;
        int xValue = 0;
        if(transform.rotation.y == 180f)
        {
            num = -1;
            xValue = 180;
        }
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        aimObject.transform.rotation = Quaternion.Euler(xValue, 0, angle * num);
        // Flip character based on aiming direction
        if ((angle > 90 && angle < 270) || (angle < -90 && angle > -270))
        {
            transform.rotation = Quaternion.Euler(0, 180, 0);
            //aimObject.transform.localRotation = Quaternion.Euler(0, 0, -angle);
        }
        else
        {
            transform.rotation = Quaternion.Euler(0, 0, 0);
        }
    }

    }
ivory saffron
#

In my game I need to change the player's gravity a lot. It is affected by player's jump and some status effects, for example. I want the changes to stack together. I have a list gravityMultipliers, where i add and remove them during the game. The gravity is then multiplied by each of them. Is this a good approach?

eternal needle
elder raptor
#

It is pointing to the correct side, I mean, it's vertically flipped though, the gun becomes upside down

eternal needle
eternal needle
#

Dont crosspost, read the server rules

elder raptor
#

Facing Right vs Facing Left

#

This is the only issue I have ๐Ÿ˜” The Arm with Gun is a child of the Player Object

eternal needle
#

I feel like you could just use LookAt here though not sure how 2d works myself. Or even like Quaternion.LookRotation

elder raptor
#

I fixed it

hallow acorn
#

hey how can i switch my scenes in code? i have the using directive but sceneManager.LoadScene() doesnt work

languid spire
#

SceneManager.LoadScene("Loading");

#

where Loading is the name of the scene

hallow acorn
#

"SceneManager"does not contain a definition for "LoadScene"

languid spire
#

then you have the wrong using

hallow acorn
#

using UnityEngine.SceneManagement

languid spire
#

do you have your own script called SceneManager ?

hallow acorn
#

no

languid spire
#

in that case it should work

tidal kiln
#

try UnityEngine.SceneManagement.SceneManager.LoadScene()

hallow acorn
#

i just have a script called UI where all functions are contained used for buttons

hallow acorn
hallow acorn
languid spire
tidal kiln
#

then something is wrong with yourproject

hallow acorn
tidal kiln
#

you probably dont have it configured properly

languid spire
#

it will tell you a bit more than that

hallow acorn
#

no it doesnt

tidal kiln
#

which ide are you using

languid spire
hallow acorn
#

thats weird i just have class SceneManager

hallow acorn
languid spire
#

then you DO have your own SceneManager class

tidal kiln
#

what are you typing in

#

visual studio, vs code, rider

hallow acorn
#

visual studio

hallow acorn
tidal kiln
#

its not configured then

hallow acorn
#

probably bc of my assets from the asset store

tidal kiln
#

go in your project settings and set visual studio as your ide

tidal kiln
#

in visual studio open the sln file

#

instead of the folder

hallow acorn
#

i dont like this

tidal kiln
#

that shouldnt be the issue

tidal kiln
hallow acorn
#

but it doesnt

tidal kiln
#

so do what i said

#

open the sln file

hallow acorn
#

can i rename a script if i change the class in the code too?

tidal kiln
#

just go to class name and press ctrl+r twice

#

it will rename the file too

languid spire
hallow acorn
tidal kiln
#

can you show whats in that file

#

it shouldnt be able to override the unity scenemanager

#

should be in a different namespace

hallow acorn
tidal kiln
#

i think you didnt write what we told you correctly or something

languid spire
tidal kiln
#

what we wrote should work

languid spire
hallow acorn
languid spire
hallow acorn
languid spire
#

I would send a message to the asset publisher btw, to inform them to put their code into a namespace

#

or report the asset on the Asset Store as that is now a requirement for ALL assets

hallow acorn
#

ok

#

sent it

summer pilot
#

Trying to make a simple FOV slider, but am getting the error "MissingComponentException: There is no 'Camera' attached to the "PlayerController" game object, but a script is trying to access it."

I have my FOV script applied to my PlayerController GameObject, and the image provided is the way I have my player put together.

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

public class FOV : MonoBehaviour
{
    public Camera PlayerCamera;
    public float playerFOV = 60f;

    void Start()
    {
        PlayerCamera = GetComponent<Camera>();
    }

    void Update()
    {
        PlayerCamera.fieldOfView = playerFOV;
    }

    public void fovSlider(float zoom)
    {
        playerFOV = zoom;
    }
}
modest dust
#

Isn't the camera on the child object FirstPersonCamera?

#

And since it's a child then just drag it into the field in the inspector, no need for extra code if the component is accessible from the get go

wintry quarry
tough lagoon
summer pilot
#

camera fov is finally working like it was before (sitting at 60 normally), but when i use the slider its not updating the actual camera's FOV. any ideas?

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

public class FOV : MonoBehaviour
{
    Camera maincamera;
    public float playerFOV;
    public float minFOV = 60f;
    public float maxFOV = 90f;

    void Start()
    {
        maincamera = GetComponent<Camera>();//sets the Main Camera as the variable
        playerFOV = maincamera.fieldOfView;//sets playerFOV variable to the Main Camera's current FOV
    }

    public void fovSlider(float zoom)
    {
        maincamera.fieldOfView = playerFOV;
        playerFOV = zoom;
    }
}
glossy turtle
#

use Update or FixedUpdate.

languid spire
#

lol,

        maincamera.fieldOfView = playerFOV;
        playerFOV = zoom;

wrong way round?

summer pilot
#
public class FOV : MonoBehaviour
{
    public Camera playerCamera;
    public float playerFOV;
    public float minFOV = 60f;
    public float maxFOV = 90f;

    void Start()
    {
        //playerCamera = GetComponent<Camera>();//sets the Main Camera as the variable
        playerFOV = playerCamera.fieldOfView;//sets playerFOV variable to the Main Camera's current FOV
    }
    void Update()
    {
        playerCamera.fieldOfView = playerFOV;
    }
    public void fovSlider(float fov)
    {
        playerFOV = fov;
    }
}
#

idk anymore, this wont work

#

it just seems like its not linking to the slider and i dont understand how to fix it

glossy turtle
#

did you applied that method on the slider.

summer pilot
#

yup

hallow acorn
#

hey how can i add a little delay in my code?

eager spindle
broken cargo
summer pilot
#

i have a min of 60, max of 90, and the player's current fov which is changed

broken cargo
# summer pilot how

Under the method name there is 60 clearly visible. It means it will always fire the method with 60 as a parameter

summer pilot
#

because nothing im doing is linking to that value and idk how to access it

#

i want to link the value, to the slider component's value

broken cargo
#

Look in the methods dropdown, there should be the same method option in dynamic section (the top one)

summer pilot
#

all this time

#

it was because

#

i didn't select the dynamic option

#

that i had no idea

#

even exited

wanton canyon
#

hello. trying to get a random # from 1-100, but getting error "cannot declare variable of static type 'random'"

glossy turtle
#

do this playerCamera.fieldOfView = slider.value;

broken cargo
summer pilot
ivory bobcat
#

You would not be able to create a new instance of Unity Random, if intending to.

wanton canyon
cosmic dagger
cosmic dagger
ivory bobcat
wanton canyon
#

yes

eager elm
wintry quarry
wanton canyon
#

no errors, thank you!!!

ivory bobcat
#

Reminder that you would call that line whenever you need a random value and not just assign a variable a random default value.

summer pilot
#

what is the difference between
public static bool & public bool?

burnt vapor
solar arrow
#

static public List<string> characterDatas = new List<string>();

static public void ResetData(){
characterDatas.Clear();

}

why is this method doesnt work?
it doesnt show any error but it wont delete the list

cosmic dagger
eternal falconBOT
cosmic dagger
cosmic dagger
solar arrow
cosmic dagger
#

also, is there another class that adds to the list? it is static, giving any (outside) class access to it . . .

cosmic dagger
solar arrow
#

the data length supposed to be shorter but it doesnt

cosmic dagger
solar arrow
#

all of them are worked except the clear function

cosmic dagger
#

log the size of the list after Clear . . .

solar arrow
cosmic dagger
#

where is the log "Data length 85" called? smth is populating the list after you clear it . . .

solar arrow
#

but it wont show 0 on my other method

solar arrow
# cosmic dagger where is the log "Data length 85" called? smth is populating the list after you ...
IEnumerator SetCharacterData(){

        List<string> datas = GetCharacterData();
        Debug.Log("Data length " + datas.Count);
        

        for (int i = 0; i < datas.Count; i++){

            if(!WhatsAppConverter.IsReady()){
                StartCoroutine(WaitForFileReady());
                datas.Clear();
                break;
            }
            
            yield return new WaitForSeconds(3f);
            
            if(datas[i][..1] == "1"){
                SetCharacterText(1, datas[i][1..]);
                BubbleChat1.SetActive(true);
                BubbleChat2.SetActive(false);
            } else {
                SetCharacterText(2, datas[i][1..]);
                BubbleChat1.SetActive(false);
                BubbleChat2.SetActive(true);
            }


            //Debug.Log(datas[i][1..]);
        }
    }

    List<string> GetCharacterData(){

        return WhatsAppConverter.characterDatas;
    }

it comes from here

#

i think i know why

cosmic dagger
solar arrow
#

because i get the datas from characterDatas

cosmic dagger
solar arrow
#

other than that theres no more

cosmic dagger
lone sable
#

Using the new UI system I'm noticing the following is being called twice.

public void UI_Cancel(InputAction.CallbackContext context) {
  //If Pressed
  if (context.performed) {
    Debug.Log("called twice?");
  }
}

I'm kinda confused why this happening as I assumed perform should only happen once no?

stiff birch
lone sable
#

This is using the new InputSystem. So no.

solar arrow
#

also the Add function is for characterDatas

stiff birch
solar arrow
lone sable
stiff birch
cosmic dagger
solar arrow
#

wait

#

oh my

#

yea i found it why

#
readonly static List<string> lines = new();
    public static void OnSuccess(string fileContent){
        
        string[] fileLines = fileContent.Split(new string[] { "\n" }, StringSplitOptions.None);
        
        lines.Clear();
        for(int i = 1; i <= 50; i++){
            lines.Add(fileLines[i]);
        }

        WhatsAppConverter.ReadString(lines);
    }

this is the method i use to set characterDatas, its because i dont Clear() this one so it adds other too

#

@cosmic dagger tysm for the help dude

cosmic dagger
covert timber
#

Hello, is there any way to have these arrows for public int variables? I would like to increment a seed variable 1 by 1 with a button press in the inspector frame

eager spindle
#

youll have to make an editor script for that
alternatively you can use the Range macro which isnt the same thing but is a slider

cosmic dagger
eager spindle
#

also you can drag the field anyway by default

cosmic dagger
#

instead of the arrows, a simple custom inspector would have two actual buttons: one the increments, one that decrements . . .

covert timber
open harbor
#

Can someone help me? I have camera and I want to make "cutscene" like for example you click an button and the camera will rotate 90 degrees in an animation how could I do that?

manic void
#

i'm making an inventory system for a 3d unity project. right now i'm trying to add a drag and drop system to the items but it doesn't work.. I only have debug.logs right now and nothing shows up in the console

DragDrop - https://hst.sh/cufazifuva.cpp
ItemSlot - https://hst.sh/movubemodo.csharp

i've read forums talking about adding a StandaloneInputModule to the event system but because im using new InputSystem i need to use a InputSystemUIInputModule. I've added a canvas group to the item, made sure the canvas has a GraphicRaycaster. I also did an Event System debugger - https://hst.sh/musobofono.cpp and still nothing shows up in console. when i click on the item absolutely nothing happens

eager spindle
open harbor
#

Oh thanks for that I didn't know but that doesn't fix my problem since I want an smooth animation do you have some suggestions how to make that?

#

I think I heard about some animator thing in unity

#

Also yes I already have my button and everything

#

Just I need the smooth camera animation

round hollow
#

Hey am complete beginner and doesn't understand the c of c# and not even unity what steps should I do to learn all

open harbor
#

I would recommend this video try to make the game with the person it helped me the basic a LOT!
https://youtu.be/XtQMytORBmM?si=7T7wYExyOpXA1Y4v

๐Ÿ”ด Get bonus content by supporting Game Makerโ€™s Toolkit - https://gamemakerstoolkit.com/support/ ๐Ÿ”ด

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...

โ–ถ Play video
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

open harbor
#

Yea that's also a thing but I prefer videos over an documentations.

round hollow
#

Cause for the Script thing I don't understand even the c of code

cosmic dagger
verbal dome
#

I gotta say that the GMTK video is pretty decent for beginners too

cosmic dagger
open harbor
#

I know I know but Im just talking about mine preferences

#

It's all fine to use learn unity

round hollow
open harbor
sturdy grail
#

Hi - firstly please direct me if I should be posting this request for help elsewhere? I have not used the Official Unity Doiscord and cannot seem to find a HELP forum... Here is my dilemma, I have bee trying to post my most recent Jr. Programmer module (debugTheApp) as evidence of completion. It askes me to "Add a link to your WebGL project" However, when I sut-n-paste the link on my unity play page i get a pink pop-up that states "project_unsupported_url" I am unsure what to do. And i cannot complete the module and proceed to the final quiz unless I can paste a viable link. Good Grief. I have searched High & Low for help but to no avail. Please advise and/or redirect. Thank you.

summer stump
open harbor
#

I know how to code and I'm just lazy so I use ai but of cource I edit it and I don't use it for everything

languid spire
open harbor
#

As I said I use it for simple thing that I'm just lazy to code and I'm sure that ai will know

#

It works for me

#

!blender

eternal falconBOT
open harbor
#

I just need blender server

silver flicker
#

Hey, super beginner question here, I've made a movement script that takes RawAxis for horizontal and vertical (top-down game) and I am now making an attack system. My problem is that I need to somehow keep the last inputs of my movement, so if the player has most previously moved up and left at the same time, I need unity to remember that that was the last input and give that direction. How would I do this?

willow scroll
silver flicker
#

I have it saved as a moveAxis, and whenever I let go of a key, the value placed on the vector2 is gone, how do i keep the value?

willow scroll
silver flicker
#

How could a coroutine be used?

broken cargo
silver flicker
broken cargo
willow scroll
# silver flicker How could a coroutine be used?

When the direction is selected, start a Coroutine with this direction as a parameter, which moves the player in specific intervals. Once the direction is changed, the Coroutine has to be reset.
Note that depending on your game, this thing may be better to implement in Update.

silver flicker
#

How intensive are coroutines? Would I want to be running one every time the player moves?

willow scroll
#

I even have this for you, if required

cosmic dagger
willow scroll
polar acorn
willow scroll
#

Actually, this kind of thing is better to be implemented with Update

#

Just store the previous direction, and move the player in Update, even if there is no current direction

silver flicker
willow scroll
#

Once it gets changed, also update the previous direction

#

Although, it should be called current direction, this way

#
if (direction != _moveDir && direction != Vector2.zero)
    _moveDir = direction;

Move(_moveDir);
silver flicker
#

Ok, I think I see, so when the direction changes, the previous direction store will change. I can then use this store as a kind of constant when direction is 0

willow scroll
#

Right

silver flicker
#

Thank you!

willow scroll
#

Either check for _moveDir being Vector2.zero in Update or directly in the Move method

silver flicker
#

Ok, got it yeah

uncut dune
#

how would I check for each particle in a particle effect the particle death

late burrow
#

how stuff like json dont get confused by strings that contain symbols like {}

raw token
late burrow
#

for the string inside json?

raw token
#
{
  "foobar": "{there's no way for this to be parsed as json unless you explicitly do so}"
}
polar acorn
raw token
late burrow
#

oh right i meant "

raw token
#

If the character is escaped within the string, e.g. \", then it's still considered as part of a string

late burrow
#

yes but if i use variable then i cant add \

polar acorn
#

You can escape an escape character

wintry quarry
#

json doesn't have variables

raw token
#

If your string value already contains " I believe the serializer handles escaping it for you

late burrow
#

so json has no way of erroring out from using these symbols

wintry quarry
polar acorn
raw token
#

I suppose it sort of depends on if you're using them properly... Like I could write bad syntax by hand

polar acorn
#
{
  value: "asdfasdf""
}

This is invalid for example

#

mismatched quotes

wintry quarry
#

json, by the way, is by far the simplest popular text based data format there is. It's something like 1000x less complex than YAML and much less complex than XML

late burrow
#

yes it can error by hand but it wont error by code right

polar acorn
wintry quarry
#

code can do anything

polar acorn
#

Garbage in, garbage out

late burrow
#

just purely from inputting string

#

to the json serializer

#

or deserializer whatever

wintry quarry
polar acorn
#

If you tell it to write bad json, it'll write bad json

late burrow
#

so i do need to treat strings in some way

#

like converting them to base64

wintry quarry
#

for what purpose

polar acorn
#

Do you want them to be base64?

late burrow
#

i want them to not error from any kind of string input

wintry quarry
# late burrow to the json serializer

If you're asking if Unity's Json serializer will produce invalid Json with JsonUtility.ToJson, the answer is no, unless there's some bug in their code

wintry quarry
polar acorn
late burrow
#

or erase some symbols in conversion

wintry quarry
#

show an example of what you mean

late burrow
wintry quarry
#

if you mean using JsonUtility.ToJson(someObjectWithAStringField) no it will not cause an error no matter what the data in the string field is

late burrow
#

and it wont get erased

wintry quarry
#

JsonUtility.ToJson will add the appropriate escape characters as needed

polar acorn
#

Honestly you could have checked this faster than this whole back and forth where you don't ever mention what you are trying to accomplish and we need to play detective. Just write code that generates JSON, give it whatever nonsense you want it to, and check if it outputs valid JSON

steep rose
#

what does JsonUtility.toJson() do? im a bit uneducated with that side of unity ๐Ÿ˜…

raw token
wintry quarry
polar acorn
steep rose
#

wow

#

information

#

all at once

wintry quarry
steep rose
#

good to know

#

ty

uncut dune
#
void IteratingOverParticles()
    {
        int particleCount = _particleSystem.GetParticles(particles);
        for (int i = 0; i < particleCount; i++)
        {
            float particleTimeLeft = particles[i].remainingLifetime;
            if (particleTimeLeft <= 0.2f && particleTimeLeft > 0)
            {
                SplashBlood(particles[i].position, particles[i].startColor);
                particles[i].remainingLifetime = -1;
            }
        }
    }

why does this dont make the particles stop spawning stuff, they keep spawning

#

for now Im using a quare for the blood just for testing

#

as you can see its not manny particles and each one has its own trail of squares

wintry quarry
#

it looks to be trying to reduce the lifetime of existing particles

uncut dune
uncut dune
#

yah that makes sense

#

basically I am just trying to find which ones have already spawned a splash of blood

#

I thought by making their remaining lifetime smaller than zero and had a check would work

uncut dune
wintry quarry
#

what are you trying to do

uncut dune
#

Ive got all of it done except they dont stop spawning objects even if I make their remaining lifetime less than 0

wintry quarry
#

another particle?

uncut dune
#

right now it just has a sprite renderer to it

wintry quarry
#

what's it for

#

blood spatter?

uncut dune
wintry quarry
#

You should use a particle subemitter instead

#

it can be set to emit a particle on particle death, or on collision for example

uncut dune
wintry quarry
uncut dune
#

or do I need to keep it

#

and just clean the scene when I get outta there

wintry quarry
#

the subemitter is part of the particle system

uncut dune
#

I was gonna use something like this

wintry quarry
#

Read the subemitter doc

uncut dune
copper horizon
#

need your help

#

when i try is check in changes it tell me changeset has been deleted

#

waht to do?

slender nymph
copper horizon
#

thanks

uncut dune
wintry quarry
marsh zinc
#

Hello everyone, i have been learning Unity for a couple of weeks on my free time and i just stumbled upon this problem, i never had it before, the thing is i am trying to use those walls as a limit to my player movement instead of just making the user stop at some specific position, for that i created a couple of walls that use a box collider which i thought it was enough but aparently my collision are not working right, anyone knows what could be the issue?
I added some picures so you can see the properties of my gameobjects

Also here is the code i use for moving my character:

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

public class EnemyX : MonoBehaviour
{
ย  ย  public float speed;
ย  ย  private Rigidbody enemyRb;
ย  ย  private GameObject playerGoal;

// Start is called before the first frame update
ย  ย  void Start()
ย  ย  {
ย  ย  ย  ย  enemyRb = GetComponent<Rigidbody>();
ย  ย  ย  ย  playerGoal = GameObject.Find("/Goals/Player Goal");
ย  ย  }

// Update is called once per frame
ย  ย  void Update()
ย  ย  {
ย  ย  ย  ย  // Set enemy direction towards player goal and move there
ย  ย  ย  ย  Vector3 lookDirection = (playerGoal.transform.position - transform.position).normalized;
ย  ย  ย  ย  enemyRb.AddForce(lookDirection * speed * Time.deltaTime);

}

private void OnCollisionEnter(Collision other)
ย  ย  {
ย  ย  ย  ย  // If enemy collides with either goal, destroy it
ย  ย  ย  ย  if (other.gameObject.name == "Enemy Goal")
ย  ย  ย  ย  {
ย  ย  ย  ย  ย  ย  Destroy(gameObject);
ย  ย  ย  ย  }
ย  ย  ย  ย  else if (other.gameObject.name == "Player Goal")
ย  ย  ย  ย  {
ย  ย  ย  ย  ย  ย  Destroy(gameObject);
ย  ย  ย  ย  }

}

}
Here is a link to a gif showing what the problem looks like
https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExbnF0NGt3NTNlaXlnam03cjNpYjIyMmUwOGZtOTQzNmwxbzhxZGlyMCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/gGqJM6bzs9XXcbAUnn/giphy.gif

steep rose
#

is there any way to find the direction of a rigidbodies movement?

slender nymph
#

it's velocity is both the speed and direction

#

assuming you are actually moving it with physics

steep rose
#

i just need the direction from it

#

and yes im moving it with physics

slender nymph
#

then use its velocity

eternal falconBOT
rich adder
#

also you should def look into changing this super fragile line of code GameObject.Find("/Goals/Player Goal");

#

at minimum use tags..

marsh zinc
#

Is it a bad way of looking for gameobjects?

steep rose
#

thank you

half egret
marsh zinc
#

Do you have any recommendation on which method i should use instead of that one?

#

The tutorial i am following uses that one so i just used that one

rich adder
half egret
#

If you're following the tutorial, then it's fine, just follow it. But storing a reference is usually much better.

#

Since it's called on Start once, it's not too bad but

#

Something to consider

rich adder
#

not only that..if the name changes somehow the whole thing breaks

half egret
#

If you wind up using it everywhere you'll find a lot of slowdown

steep rose
raw token
#

That looks like one of the units from the JPP - I believe it improves upon the approach down the line

half egret
#

Yeah, that's what I expected from a tutorial

rich adder
half egret
#

Just follow it as they'll probably iterate and explain down the line

marsh zinc
#

I dont remmeber the name of the instructor

half egret
final kestrel
#

Hi. https://hatebin.com/vbqrpdyplk I am trying a save load system on this inventory. I can save the list with item ids and types. Then I get the items from my database on load. It works fine on the inspector. But the display is not working correct. I am not sure If i should call AddItem or not

half egret
#

Sure you have to do it once, but it's annoying

rich adder
marsh zinc
#

Thank you for your advice guys! Im sure it will be usefull in the future

obsidian shoal
#

why is it working for him and not me

steep rose
#

i would use print()

#

personally

broken cargo
rich adder
obsidian shoal
steep rose
#

easier

rich adder
eternal falconBOT
obsidian shoal
rich adder
near wadi
#

!code @obsidian shoal

eternal falconBOT
obsidian shoal
polar acorn
rich adder
# steep rose easier

you cannot use print outside of monobehaiors , also you cannot pass int he context aka the object that called it

steep rose
#

still

languid spire
half egret
obsidian shoal
#

second day using unity and cs

broken cargo
steep rose
#

everyone starts somewhere, and i still suck at it ๐Ÿฅฒ

near wadi
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

obsidian shoal
#

i will give it a try

languid spire
rich adder
obsidian shoal
#

jesus Christ what have i started

rich adder
broken cargo
slender nymph
#

that's exactly what it is doing

obsidian shoal
rich adder
broken cargo
polar acorn
#

Debug.Log takes in an optional parameter for which object to highlight in the inspector when you click the log. Print cannot do that

steep rose
#

mass war just started

#

over print and debug.log()

polar acorn
#

If you don't use the parameter, they are the same

broken cargo
rich adder
#

you're correct

#

it was nonsense

polar acorn
#

Yes, there's no reason to suggest swapping one for the other

rich adder
#

more important OP get their IDE configured first and foremost

polar acorn
#

it's purely preference unless you're using the context parameter

rich adder
#

or you need to Debug.Log outside of MB

slender nymph
#

there's also never a need to switch from using Debug.Log to print. that's just a ridiculous suggestion

broken cargo
#

yeah. It's easier to use debug.Log then to keep track of MonoBehaviours

rich adder
#

i used to use print just because it was faster to type

cosmic dagger
manic void
#

i'm making an inventory system for a 3d unity project. right now i'm trying to add a drag and drop system to the items but it doesn't work.. I only have debug.logs right now and nothing shows up in the console

DragDrop - https://hst.sh/cufazifuva.cpp
ItemSlot - https://hst.sh/movubemodo.csharp

i've read forums talking about adding a StandaloneInputModule to the event system but because im using new InputSystem i need to use a InputSystemUIInputModule. I've added a canvas group to the item, made sure the canvas has a GraphicRaycaster. I also did an Event System debugger - https://hst.sh/musobofono.cpp and still nothing shows up in console. when i click on the item absolutely nothing happens

spiral glen
#

transform.position = Vector2.MoveTowards(kitty.transform.position,bean.transform.position,1f);
anyone know how to make the "movetowards" function move smoother instead of blocky-esc (constant movement instead of teleporting 1f towards it)

#

like any tips or tricks or just completely different functions

raw token
spiral glen
rich adder
#

did you look at the example in the docs?

#

always RTFM first ๐Ÿ™‚

spiral glen
#

what';s that

#

rtfm

rich adder
#

Read the Fucking Manual ๐Ÿ˜›

spiral glen
#

ah

#

yeah i did read that

#

it also did just basic number feet

obsidian shoal
#

YOU ARE THE BEST MAN IN THE WORLD

#

I LOVE THIS

#

๐Ÿ˜™

spiral glen
#

it still isn't constant movement for some reason

#

wait a sec I'm dumb

#

nvm he's still teleporting

wintry quarry
spiral glen
#
    {
        time += Time.deltaTime;
        if (hungry == 1)
        {
            foreach (GameObject i in beanArray)
            {
                if (Vector2.Distance(kitty.transform.position, i.transform.position) < minDist)
                {
                minDist = Vector2.Distance(kitty.transform.position, i.transform.position);
                bean = i;
                }
            }
            Debug.Log(minDist + " " + bean);
            hungry = 0;
        transform.position = Vector2.MoveTowards(kitty.transform.position,bean.transform.position,1 * time);
        minDist = 9999;
        }
    }```
wintry quarry
#

None of this makes sense to me

spiral glen
#

the kitty object is teleporting

#

darn

polar acorn
wintry quarry
#
transform.position = Vector2.MoveTowards(kitty.transform.position,bean.transform.position,1 * time);```
you're moving a completely different object than the one that is used as the start position here
#

kitty.transform is not the same as transform

polar acorn
#

Yeah, like, a lot of this makes no sense

wintry quarry
#

also yeah the thing with time makes no sense

rich adder
#

tell me you never clicked the example link

spiral glen
rich adder
#

even in the example step is never increased

wintry quarry
spiral glen
#

but isn't 1 a speed

wintry quarry
#

sure

#

then put 1 there

spiral glen
#

it is there tho

polar acorn
wintry quarry
#

Time.deltaTime * 1

wintry quarry
#

You're doing 1 * time, which is not the same as 1 * Time.deltaTime

rich adder
polar acorn
spiral glen
#

oh

polar acorn
#

meaning that you'll move 1 unit after playing for 1 second. After one minute, you're moving 60 units per frame

#

and so on

wintry quarry
#

and then you're doing time += Time.deltaTime; which is just.... ????????

#

this is like, making a timer

spiral glen
#

mb

drowsy oriole
#

How would I add a nickname to OnTriggerEnter

wintry quarry
#

Wdym by "add a nickname"?

drowsy oriole
#

Like how Private void bans

mint remnant
#

#define NEW_NAME OnTriggerEnter

wintry quarry
drowsy oriole
#

private void "bans" name is bans

wintry quarry
#

ok..?

#

what does that have to do with nicknames

#

what's a "nickname"? in this context?

drowsy oriole
#

private void OnTriggerEnter () how do I add a name to that

wintry quarry
#

It has a name

#

"OnTriggerEnter"

drowsy oriole
#

Ik but I need to have 2 in my script one with a tag and another without

wintry quarry
#

you can only have one OnTriggerEnter

#

Why would you need two?

drowsy oriole
#

private void OnTriggerEnter (Collider other)
If(other.transform.CompareTag = bannedlol)

#

Ignore the tag

summer stump
drowsy oriole
summer stump
#

If tag do thing
If not do other thing

summer stump
drowsy oriole
#

Oh i see let me try

mint remnant
#

Why does Unity allow for so much use of magic strings? Seems rather detriemtal to good code practices

polar acorn
#

How would you expect any programming language to not "Allow for" magic strings?

#

That's the responsibility of the programmer

raw token
#

I don't think I'm aware of any framework or language which actively discourages magic strings

polar acorn
#

Literally any language that compares strings by value "allows for magic strings"

ionic zephyr
#

why cant I view a public List of Arrays?

mint remnant
#

I'm not saying the language shouldn't allow for it, suggesting for example get rid of the Tag concept

eternal needle
polar acorn
polar acorn
#

Tags are by no means necessary, you can avoid them entirely without losing any functionality. Layers are different, but layers also have helper functions to de-magic them

mint remnant
#

Then my question becomes why did they put the concept in in the first place

eternal needle
#

Honestly the tag system isnt even bad. Theres just not a major use for it in most cases

polar acorn
summer stump
jaunty smelt
#

Hey does anyone know how I can go from one yarn to the next?

raw token
#

You should see the 40 year old C codebase I work with for a day job... I can't rationally retcon any of the decisions they made ๐Ÿฅฒ

ionic zephyr
polar acorn
jaunty smelt
#

Dialogue

polar acorn
rich adder
#

Yarn Spinneri thnk

ionic zephyr
jaunty smelt
#

Yarnspinner

polar acorn
rich adder
mint remnant
#

where do you new it up at?

polar acorn
#

where do you actually create a list to store there

raw token
ionic zephyr
polar acorn
mint remnant
#

yes

polar acorn
#

where do you do that

summer stump
rich adder
ionic zephyr
mint remnant
#

if you don't new the list up, the .Add() will try to add to null

rich adder
polar acorn
polar acorn
#

as I said before, nested collections cannot be serialized

ionic zephyr
#

okay, makes sense

final kestrel
polar acorn
sand otter
#

I want to have all my walls having the same sized texture throughout, but because it's a maze, there are many different lengths and widths for walls. The tiling system makes the texture stretch differently between walls. Is there any way to have them all be the same size throughout the different walls?

wintry quarry
final kestrel
polar acorn
wintry quarry
obsidian shoal
#

is 1 the smallest float number?

#

besides 0

frosty hound
#

No?

obsidian shoal
#

0.5 or .5 dont work

frosty hound
#

Floats supports decimals, so the smallest number is one closest to 0 you can get with the size of a float

#

You need to append f to floats in C#

#

0.5f

rancid quail
frosty hound
#

Otherwise, it is considered to be the type Double, which isn't the same.

obsidian shoal
rancid quail
# rancid quail

How can i make so the DontDestroyOnLoad Objects stay there also when i leave play mode?

frosty hound
#

You can't, it's a runtime thing.

raw token
#

Ah neat - I never knew there was a constant for that

rich adder
#

a scriptable object might work too ๐Ÿค”

rancid quail
#

I need to put the objects inside of this script, which is in another scene than the object

wintry quarry
rancid quail
#

The Objects would load in with DontDestroyOnLoad, does that work?

wintry quarry
#

you won't be able to reference things in the editor if they're in a different scene

rich adder
#

you can open multiple scenes too btw, you just can't reference between those scene objects

final kestrel
edgy prism
#

Hello I have a bottom menu im using to identify which panel of a screen is in focus, im using 6 dividers that represent 5 gaps (one for each screen), and want to position the dividers equally spaced with the exception that the currently focused panels dividers occupy a larger space. I've been defeated by the maths so a push in the right direction would be greatly appreciated.

private void AdjustDividers()
    {
        Debug.Log($"{selectedPanelIndex}");
        float canvasWidth = viewportWidth;
        float indicatorWidth = selectedIndicator.rect.width;

        dividers[0].anchoredPosition = new Vector2(-canvasWidth / 2 + dividers[0].rect.width / 2, dividers[0].anchoredPosition.y);
        dividers[dividers.Length - 1].anchoredPosition = new Vector2(canvasWidth / 2 - dividers[dividers.Length - 1].rect.width / 2, dividers[dividers.Length - 1].anchoredPosition.y);

        float availableWidth = canvasWidth - (dividers[0].rect.width + dividers[dividers.Length - 1].rect.width);
        float baseSpacing = availableWidth / (dividers.Length - 2); // -2 because we are distributing space among gaps excluding the first and last dividers

        // Position the middle dividers equally spaced
        for (int i = 1; i < dividers.Length - 1; i++)
        {
            RectTransform divider = dividers[i];
            float xPos = -canvasWidth / 2 + dividers[0].rect.width + (i - 1) * baseSpacing + divider.rect.width / 2;
            divider.anchoredPosition = new Vector2(xPos, divider.anchoredPosition.y);
        }

        if (selectedPanelIndex >= 1 && selectedPanelIndex <= dividers.Length - 3)
        {
            dividers[selectedPanelIndex].anchoredPosition += new Vector2(-indicatorWidth / 2, 0);
            dividers[selectedPanelIndex + 1].anchoredPosition += new Vector2(indicatorWidth / 2, 0);
        }
    }
wintry quarry
final kestrel
#

debugger stopped sorry a minute

#

this is the sprite and the newItem.Image.

wintry quarry
#

the UI Image

#

image

final kestrel
#

I do not understand why it throws me objet not set to instance

wintry quarry
#

That's why I'm asking you to check it

final kestrel
#

Do you mean check here?

wintry quarry
#

in the debugger

#

the image variable

late kelp
#

hello, do you guys have any ideea why is the code giving me the object referince not set to an instance or object?

wintry quarry
#

look at the indicated line

final kestrel
#

The breakpoint does not work while debugging. I mean does not stop at the image variable.

late kelp
#

28 is the line

#

but idk what is wrong

wintry quarry
late kelp
#

interaction_text.text = selectionTransform.GetComponent<InteractableObject>().GetItemName(); this one

wintry quarry
#

all you have to do is mouse over image (off screen to the left)

wintry quarry
final kestrel
polar acorn
wintry quarry
#

BTW there's no good reason to have two separate variables

late kelp
#

oh ok i will change it, thx

final kestrel
raw token
#

You might enable the debugger's "break on error" function and let it run in order to find the specific instance/iteration which is responsible for the error

final kestrel
#

Could it be something to do with my InventoryManager? I can send the code link again

wintry quarry
#

there is a null reference being accessed on the line indicated

#

log all the references on that line

#

see which one is null

final kestrel
#
public void InitializeItem(Item newItem){
        item = newItem;
        image.sprite = newItem.image;
        Debug.Log(image.sprite);
    }

It says checkmark here. I think it is not null

polar acorn
#

Log image and newItem

late kelp
#

i had a TMP_Text

wintry quarry
#

much simpler, and doesn't let you mess up the types.

late kelp
#

i just change in unity the TMP text with normal text and it works fine

wintry quarry
#

I know

#

I'm telling you how to simplify it and make it better though

late kelp
#

ok, i will do it

final kestrel
#
 public void InitializeItem(Item newItem){

        Debug.Log($" New Item is {newItem}");
        Debug.Log($"Image is {image}");
        item = newItem;
        image.sprite = newItem.image;
        
    }

Its like this now

late kelp
#

or at least i will try

polar acorn
final kestrel
#

Yes I am calling Initialize item.

#

On my inventory manager

polar acorn
#

And you're passing it a null somewhere

final kestrel
polar acorn
final kestrel
#

When I call AddItem on button click. I see that they get added to the Container. When I load the data I also see the container gets loaded thoguh

wintry quarry
final kestrel
# wintry quarry More Debug.Logs can identify this issue
public void LoadData(GameData data)
    {
        Debug.Log("Loaded");
        Container = data.items;
        
        for (int i = 0; i < data.items.Count; i++)
        {
            //I can get the data set here without a problem.
            Container[i].item = database.GetItem[Container[i].Id];
            for (int x = 0; x < Container.Count; x++)
            {
                Debug.Log($"Container has {Container[x].item} these");
                AddItem(Container[x].item);
            }
            //TODO I just need to find a way to SpawnItems. Items that I get from the Database after loading.
        }

    }

The last log before AddItem prints nothing

wintry quarry
summer shard
#

how can i detect when a specific script was added (or rather it's gameobject was instantiated) in the whole game, not just single gameobject

wintry quarry
summer shard
#

okayy, thanks

wintry quarry
final kestrel
#

So the first item gets loaded correctly because its Container[0], Second does not get loaded cos its [1] and null

wintry quarry
#

yes because data.items[1].item is null

final kestrel
#

Hm weird though. I can see them getting added and loaded in the inspector.

raw token
#

If you have (or might possibly accidentally have) multiple InventoryManager instances, you may want to chuck a gameObject into the context argument of the Debug.Log() call, just to make sure that the component you are looking at in the inspector is the one which is responsible for the error

wintry quarry
#

Seems to me:

            Container[i].item = database.GetItem[Container[i].Id];
            for (int x = 0; x < Container.Count; x++)
            {
                Debug.Log($"Container has {Container[x].item} these");
                AddItem(Container[x].item);
            }```
You'[re accessing the items before tyhey're populated
#

that second loop is looking ahead

#

before the itemsa re assigned

final kestrel
#

Well. I am clearing the Container onapplicationquit too

final kestrel
summer shard
wintry quarry
#

Why is the second loop inside the first?

wintry quarry
final kestrel
#

I have no idea. I will try it

summer shard
wintry quarry
#

initialize yourself in Awake

#

Do stuff that depends on other things being initialized in Start

#

otherwise you get a possible order of operations error

#

e.g. this is running before the Awake on ObjectivesController

summer shard
#

so this?

    private void Start() {
        ObjectivesController.instance.addObjective(this);
    }
wintry quarry
#

yes

summer shard
#

okay it works, thanks

final kestrel
#

Yeah like for example I have item 1 and item 2 in my slot. I save and expect Item 1 and Item 2 on my first 2 slot on load. It loads the first two. Then puts them again respectively filling all my slots

trail harbor
#

Where is this Muse Animator ? How do I enable/find it

quick fractal
#

How would I go about checking if a specific transforms rotation is inbetween a set of constraints and do something based on that? This is about as far as I got

#

I'm more asking how I would define the constraint if that makes sense

polar acorn
quick fractal
#

Is it not the arrows x rotation value?

polar acorn
#

Quaternions are 4D Normalized Complex Vectors

#

It's one component of that value

#

Unless you have a PhD in math it probably means absolutely nothing to you

quick fractal
polar acorn
#

If you want the rotation in degrees in 3D space, that's transform.eulerAngles

languid spire
quick fractal
languid spire
quick fractal
#

Do you know of any visual examples? They tend to make a bit more sense to me ๐Ÿ˜…

languid spire
#

no, but what I said is not complex

quick fractal
#

Telling me it isn't complex isn't all that helpful if It still doesn't make sense to begin with, but thank you for the base. I'll try and do some digging and see what I can throw together ๐Ÿ˜„

languid spire
#

well, what doesn't make sense?

rocky canyon
languid spire
#

this is rotation we are talking about

rocky canyon
#

same diff.. vector3 an all

polar acorn
rocky canyon
#

or use some of the euler functions.

languid spire
#
Vector3 rotation = Vector3.zero;
...
Update() {
   rotation.x += 10;
   rotation.x = Mathf.Clamp(rotation.x,-90, 90);
   transform.rotatation = Quaternion.Euler(rotation);

@quick fractal

rocky canyon
#
        Vector3 currentRotation = transform.eulerAngles;
        currentRotation.x = newXAngle;
        transform.eulerAngles = currentRotation;```
quick fractal
# languid spire well, what doesn't make sense?

Two main things I'd imagine, specifically defining what the angle is. If I explained the general concept a bit more It might help;

I'm trying to make an arrow rain type skill for a VR game, it would trigger by shooting up into the air between say, 30 & -30 degrees in the air it would trigger. Defining the 30 to -30 limit and comparing the current arrows rotation is the bit I'm pretty confused about.

Sorry if the skill is kind of redundant info ๐Ÿ˜…

final kestrel
rocky canyon
#

lloll.. i'd just use one of the many rotation methods unity already has..

final kestrel