#💻┃code-beginner

1 messages · Page 473 of 1

polar acorn
#

then you can worry about filtering your collisions to determine which things you want it to do that with

orchid kite
#

ya but its doing what i want like when it colliders with a 2d collider the hit is true and circle collider of the banana is disabled

#

i was gonna add gameObject.SetActive(false); but like its doing the flicker thing i think cuz of the monkey problem

#

i will use an if statment to remove the monkey

orchid kite
#

thank mr dig

terse spindle
#

hello guys
I want to make an active ragdoll character, I want it to be like human fall flat
should I make it move the hips and legs follow the hip, taking steps if hip is too far from the leg
or should I blend animated and physical characters

#

or something else

verbal dome
#

I do active ragdolls by having an invisible, animated character, and then the actual character that uses configurable joints to try and replicate the animated character

#

Not a beginner subject though... Unless you find some really handy asset for it

steep rose
# terse spindle hello guys I want to make an active ragdoll character, I want it to be like huma...

active ragdolls are tricky, you would get a lot out of this video
https://www.youtube.com/watch?v=HF-cp6yW3Iw

This is all I learned while making active ragdolls in Unity. I hope you find it useful or, at least, interesting :D

The actual tutorial: https://bit.ly/3lKsfk2
Github repository: https://bit.ly/2VxnU98

----- Social -----

Twitter: https://twitter.com/sergioabreu_g


Ambient Generative Music by Alex Bainter [generative.fm]

-...

▶ Play video
abstract copper
#

So I have method to crouch and when you crouch it makes player local scale half, howcan I avoid to scale items player holds when he crouches, items are added to a hand transform which is a child of player

verbal dome
#

Avoid scaling the parent. Maybe only scale a separate child that has the character's visuals, if necessary

abstract copper
#

i guess i could just move the camera down as i dont need him to like go trough spaces

#

its mostly for ease of access to items on ground

steep rose
#

instead of scaling the parent you can adjust the size of the collider and adjust playermodel via animations or scaling (if its a primitive shape)

#

so it wont scale your items

hollow forum
#

how can i check if an object is colliding with the ground

#

so far i have this

#
    if (Input.GetMouseButtonDown(0))
    {

        if (displacement.magnitude < maxDistance)
        {
            power = displacement.magnitude / maxPower;

            rb.velocity = -Camera.main.ScreenToWorldPoint(Input.mousePosition) * power;

        }
        else
        {
            rb.velocity = -Camera.main.ScreenToWorldPoint(Input.mousePosition);

        }
}```
#

but it doesnt seem to be working

#

the radius of the object is 0.16

orchid kite
#

guys i hv one final little issue with the banana throw when my monkey faces right the banana moves right however when i turn the monkey left the banana only flips but does not change direction


    public void SetDirection(float _direction)
    {
        broke = 0;
        direction = _direction;
        hit = false;
        circleCollider.enabled = true;
        gameObject.SetActive(true);

        float localScaleX = transform.localScale.x;

        if (Mathf.Sign(localScaleX) != direction)
            transform.localScale = new Vector3(-localScaleX, transform.localScale.y, transform.localScale.z);
    }

wintry quarry
orchid kite
#

alr gimme a moment

wintry quarry
orchid kite
#

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

public class BananaThrow : MonoBehaviour
{
    [SerializeField] private float speed;
    private bool hit;
    [SerializeField] private CircleCollider2D circleCollider; 
    private float direction;
    private float broke;

    private void Awake()
    {
        circleCollider = GetComponent<CircleCollider2D>();
    }

    private void Update()
    {
        if (hit) return;
        float movementSpeed = speed * Time.deltaTime;
        transform.Translate(movementSpeed, 0, 0);

        broke += Time.deltaTime;
        if (broke > 100) gameObject.SetActive(false);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            Debug.Log("Banana hit the monkey, continuing movement.");
            return;  
        }

        hit = true;
        circleCollider.enabled = false;
        gameObject.SetActive(false);
        Debug.Log($"Banana hit: {collision.gameObject.name}");
    }

    public void SetDirection(float _direction)
    {
        broke = 0;
        direction = _direction;
        hit = false;
        circleCollider.enabled = true;
        gameObject.SetActive(true);

        float localScaleX = transform.localScale.x;

        if (Mathf.Sign(localScaleX) != direction)
            transform.localScale = new Vector3(-localScaleX, transform.localScale.y, transform.localScale.z);
    }

    private void Deactivate()
    {
        gameObject.SetActive(false);
    }
}

wintry quarry
#

is this script on the banana prefab or something?

#

I don't understand

steep rose
#

seems like its just 1 gameobject in the scene

orchid kite
#

its just an object with 10 clones of it hidden in the hieracrhy no prefab

#

object pooling

hollow forum
wintry quarry
#

Because you're using a 3D raycast here

hollow forum
#

2d

steep rose
wintry quarry
#

Physics2D.Raycast

steep rose
hollow forum
#

lmao

#

that simple

steep rose
#

keep in mind transform.translate ignores collisions as well

wintry quarry
#

Well Translate works in local space by default

#

so I think inverting the scale should actually do it

hollow forum
steep rose
#

just a test

hollow forum
# hollow forum my raycast is still returning true even tho my gameobject is up in the air
{

    Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    displacement = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;


    if (Physics2D.Raycast(transform.position, Vector2.down, 0.1f)) {

        Debug.Log("true");
        if (Input.GetMouseButtonDown(0))
        {

            if (displacement.magnitude < maxDistance)
            {
                power = displacement.magnitude / maxPower;

                rb.velocity = -Camera.main.ScreenToWorldPoint(Input.mousePosition) * power;

            }
            else
            {
                rb.velocity = -Camera.main.ScreenToWorldPoint(Input.mousePosition);

            }
        }
    } else
    {
        Debug.Log("false");
    }
}```
steep rose
#

do you have a layermask for the ground?

#

right now the raycast is just hitting whatever

hollow forum
#

i looked it up and changed a setting and now it returns true for first 3 frames then returns false

hollow forum
steep rose
hollow forum
#

how?

steep rose
#

this is the documentation for it

hollow forum
#

so if i set the ground to the ground layer

#

then add a layermask for that in the raycast

steep rose
#

it will only hit ground

hollow forum
#

ok ill try

#

if (Physics2D.Raycast(transform.position, Vector2.down, LayerMask.GetMask("Ground")))

#

ive done this

steep rose
#

try it

hollow forum
#

it doesnt work

#

it still returns true even if the object is levitating

verbal dome
#

You put layerMask where it expects distance

hollow forum
#

i did you are correct

steep rose
#

i would make distance a float

hollow forum
#

cheers

#

yes it is

steep rose
#

problem solved?

hollow forum
#

yes thank you

steep rose
#

neato burrito
if you would want to !learn more about unity and its quirks you can click the link below to start

eternal falconBOT
#

:teacher: Unity Learn ↗

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

flat fossil
#

Okay, so I'm making a 8-directional character controller

#

problem is that the diagonal movement is off

#

here's the simple code im using currently

#

as a visual example, the character starts up here

languid spire
#

describe 'off'. Also why fixedDeltaTime in Update?

flat fossil
#

and then he winds up here when moving diagonally, which is not lined up with the tiles at all

languid spire
#

off course not, do you know Pythagoras?

flat fossil
#

as for the fixedDeltaTime - I've got no clue. I followed a tutorial

#

Yes, I've watched those videos on how to fix the diagonal in theory but I have no idea how to apply it practically

terse spindle
#

Vector2.normalized

flat fossil
#

give me a second, I'll try

terse spindle
#

or is it normalize

#

I dont remember

willow scroll
terse spindle
#

okay

verbal dome
#

Can't you just half your y movement?

meager sinew
#

public class GameUIHandler : MonoBehaviour
{
    [SerializeField] private Sprite[] _healthBarSprites;
    private Sprite _currentHealthBarSprite;

    [SerializeField] private CharacterManager _characterManager;
    private int _playerHealth;

    [SerializeField] private float _scaleChange;
    [SerializeField] private int _sizeChangeDelay;

    public Slider _staminaBar;

    [SerializeField] private CharacterMovement _characterMovement;
    #region HealthBar Sprite
    public void ChangeHealthBarSprite()
    {
        _playerHealth = _characterManager._playerHealth;

        Debug.Log(_playerHealth);

        for (int i = 0; i < _healthBarSprites.Length; i++)
        {
            if (i == _playerHealth)
            {
                _currentHealthBarSprite = _healthBarSprites[i];
                gameObject.GetComponent<Image>().sprite = _currentHealthBarSprite;
            }
        }

        if (_playerHealth == 0)
        {
            SceneManager.LoadScene("DeathScene");
        }
    }
    #endregion

    #region Stamina Bar

    private void Start()
    {
        _characterMovement._currentStamina = _characterMovement._maxStamina;
        _staminaBar.maxValue = _characterMovement._maxStamina;
        _staminaBar.value = _characterMovement._maxStamina;
    }

    public void UseStamina()
    {

        if(_characterMovement._currentStamina - _characterMovement._staminaUse >= 0)
        {
            _characterMovement._currentStamina -= _characterMovement._staminaUse;
            _staminaBar.value = _characterMovement._currentStamina;
        }
        else
        {
            Debug.Log("Not Enough Stamina");
        }
    }```

Can someone help me i have this error:
verbal dome
#

Your tile width seems twice higher than the height

meager sinew
willow scroll
languid spire
languid spire
verbal dome
meager sinew
willow scroll
verbal dome
#

Type t:charactermovement in the scene hierarchy search bar to search by type

meager sinew
#

oh i do

#

thank you

flat fossil
hollow forum
#

is there a way to raycast in all directions but one

rich adder
willow scroll
polar acorn
rich adder
#

put the directions you want in an array and loop through them

willow scroll
#

And ruin your performance, assuming you want to iteract through infinity directions minus one

verbal dome
flat fossil
willow scroll
eternal falconBOT
verbal dome
#

I don't think their issue is the normalization/clamping, although that should be fixed too (so you don't walk faster diagonally)

rich adder
willow scroll
rich adder
#

there was an old VS 2019 theme like that
but the missing "References" headers looks sus

verbal dome
#

The tiles are twice wider than their height. So I think you should just * 0.5f your vertical velocity @flat fossil

willow scroll
hollow forum
#

but with rigidbodies it doesnt bounce off walls

#

so that is my next venture

verbal dome
hollow forum
#

i thought of doing raycasts left right and down and if velocity is not equal to zero it bounces up with 87% of the original velocity

verbal dome
#

I think they are moving along the red line now, while it should be the blue line

flat fossil
#

Yes!

verbal dome
#

Ambiguous

willow scroll
verbal dome
#

The blue line in the image I posted does go diagonally, but not 45 degrees

flat fossil
hollow forum
#

but it just doesnt act how i want it to

#

i also tried seperately to change the velocity by multiplying the x by -0.87 but that also didnt work

wintry quarry
lapis frigate
#

I have a problem, I created an inventory system and an add item button for a test that adds an item to the inventory, I tried to code it that way that if another item from the same type enters the inventory the items should stuck, but instead I can only add 1 item and when I press the button again nothing happens, any help?

rich adder
eternal falconBOT
lapis frigate
lapis frigate
#

any help? Im pretty much lost

rich adder
#

start adding some logs and debug it

lapis frigate
#

tbh I dont know how to debug

steep rose
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

that should've been one of the first things to learn before doing an Inventory

steep rose
#

debugging is the absolute basics of unity

#

you must learn it

rich adder
lapis frigate
#

hmm I guess thats right

steep rose
#

isnt that one of the if not the first things you learn while coding in unity?

rich adder
#

this should've been one of the first lines you wrote in unity

steep rose
#

and its the most important

rich adder
#

should be pinned tbh

willow scroll
#

@lapis frigate A few days ago you asked why getComponent didn't work. I am not sure whether I've sent you [this link](#💻┃code-beginner message) that time, but you really should have a look at it

dawn steppe
#

just for organization should you apply components urself in the editor or in script directly with getcomponent?

steep rose
#

you could do either

rich adder
#

I like my scripts to be clear on what references they have assigned etc. I prefer Serialize inspector when possible

steep rose
#

depends on how you arrange it

scenic saffron
#

I was getting this message for no reason after i deleted a canvas every time I Jumped, i fixed it by changing canvas to a game object, but i still would like to know why that happened

rich adder
scenic saffron
rich adder
#

well it was trying to remove it but didn't

#

so stuck in a loop ig , try remove, can't , jump try to remove can't etc

scenic saffron
#

I mean after i deleted the canvas every time i Jumped it told me that I cant remove the canvas but Jumping and removing are not connected in any way and the script that deletes the canvas was also part of the canvas, so a removed script told me that cant remove a already removed Canvas every time i did something completely un related

polar acorn
#

So, more likely, you never intended to connect them, but did

rich adder
#

You still have referenced Canvas anyway, deleted or not

#

so its probably an internal message

strong wren
#

can u theoretically make a game with only 1 script?

#

like have EVERYTHING in just one massive script

strong wren
#

lol

#

well i know what i have to do later

#

would be pretty funny

rich adder
#

you can't use Two monobehaviour in one script though

rich adder
#

brain rot

scenic saffron
#

the video has 2.5m views so if you upload a video of you doing a game in just one script you will get (2500000 / x lines of code) views

languid spire
fathom bramble
#

Does anyone ever get this error specifically from webgl builds?

rich adder
fathom bramble
#

the windows build doesn't throw this exception, only webgl

rich adder
#

did you do Build n Run

languid spire
fathom bramble
rich adder
rich adder
#

check your unity if anything like that came up when you switched to webgl

#

try another browser or incognito mode

#

Chrome cache will sometimes cause a mismatch when loading the wasm of a project build. Clearing your cache often fixes the issue, and is why it worked in Incogneto mode.

languid spire
rich adder
languid spire
rich adder
#

Yeah console apps reminds how nice it is to have a GUI or engine to make stuff go pow pow 🤩

fathom bramble
#

rebuilding the game to see if any error comes in the unity console window

#

running in incognito did not help

rich adder
#

doesnt seem code related

#

did you try

The first thing to do when getting a cryptic error that has those “wasm-function[xxyy]” lines on it is to change in the Project Build Settings “Debug Symbols: Embedded”, and then repro the error again.
That will give a human-readable call stack that can then help point towards the source of the exception.

fathom bramble
orchid kite
#

Hey guys i need some help

I have this monkey throwing bananas and well when the monkey if facing right the banana is thrown normally however i want the monkey to throw the banana left when it faces the left side however the banana itself just flips over and continues moving in the right direction any help to fix this?

https://gdl.space/vefevujuco.cs

rich adder
lunar kelp
#

How do you use OOP in unity?

rich adder
lunar kelp
rich adder
#

so you have to also think about that

#

monobehaviour is a component

#

decide when your object should be just a POCO or a Gameobject MB

charred spoke
#

A better question would be what do you want to achieve

rich adder
#

so yeah delete MB if you dont need to be a component

fathom bramble
#

@rich adder I'm not sure if this is helpful but

#

in the console window, the error seems to start

#

right when I try to post data to a php server

#

(the leaderboard)

#

does maybe webgl not mesh well with that sort of thing?

rich adder
#

typically you would get a CORS issue but doesn't seem like it, seems like something might be going wrong on your code itself ? are are you using a UnityWebRequest ?

fathom bramble
#

Nothing should be wrong with the code, the windows build works perfectly

#

however I did get an interesting message just now

rich adder
#

whats the stacktrace on that

#

is ScriptableSingleton your thing ? I never heard of it

#

oh nvm its a unity class, hmm its a Editor only class so no idea what happen there

languid spire
#

yes, but it's editor only, should not be in a build

fathom bramble
#

This error only seems to happen in the build where I try to post to my php server

rich adder
rich adder
languid spire
fathom bramble
fathom bramble
#

it just crashes

fathom bramble
eternal falconBOT
#
📝 Logs

Documentation

Editor logs

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

Unity Hub

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

rich adder
#

ops they dont have player log here, click the link

fathom bramble
languid spire
#

but it can also be if you use Invoke or a coroutine with a string argument

fathom bramble
languid spire
fathom bramble
languid spire
strong wren
#

how do i check the names of gameobjects thru code?

#

im using a raycast for interactable gameobjects and i was thinking to check the gameobjects name

languid spire
#

a gameObject has a name property

strong wren
#

i can check for tags but idk if thats the best way

strong wren
fathom bramble
#

I wish the article said what menu to open to get there

#

can't find it anywhere

languid spire
strong wren
languid spire
#

look at what is wrong with the code you just posted

strong wren
#

theres no CompareName

strong wren
#

nvm

#

im a braindead person and im ok with it

#

i was right i just needed the extra = and rto remove the brackets

#

not my fault i was dropped as a baby

fathom bramble
#

if (gameObject.name == "smith") {}

strong wren
rich adder
fathom bramble
#

I use tags tbh

rich adder
#

better but still bad imo

fathom bramble
rich adder
#

strings are not very good

fathom bramble
#

Not sure what the better unity-way is to do it

rich adder
#

they are not type-safe

rich adder
rocky canyon
#

this trygets all the way

fathom bramble
#

If that's invoking a try-catch inside it, seems rather expensive for a simple compare check

rocky canyon
#

eh? ive been told for 3 years now.. thats the beetter way than to compare strings

fathom bramble
#

try-catch makes a copy of your entire call stack. I tend to avoid it unless I think the app will crash due to it

rich adder
#

its a simple null check

#

null checks are cheap

fathom bramble
#

Oh

rich adder
#

its like wiriting
var player = collision.collider.GetComponent<Player>()
if(player != null)
and get component is relatively performant

rocky canyon
#
   if(hit.collider.transform.TryGetComponent(out IInteractable interactable))
            {
                cachedInteractable = hit.collider.gameObject;``` u can use it different ways too.. i like to use em for Interfaces
willow scroll
# fathom bramble Oh

Every method with Try assigns the internal method to the out parameter and returns true is it's not null, as was shown above

fathom bramble
#

Lowering stripping level didn't work. This is such a weirddddd error. I mean I guess webgl isn't totally necessary but would have been nice to have it on itch.io

#

maybe I'll focus on windows for now

rich adder
#

wat is the code doing can you show the function that posts to leaderboard

fathom bramble
#

yeah sure it's just basic code using the .net http library

#

one sec

languid spire
# fathom bramble

So you should really use UnityWebRequest (I thought you had been asked ths already) HttpClient does not work on WebGL

rich adder
#

ahh yes def go with UnityWebRequest

#

had no idea HTTPClient even worked in unity

fathom bramble
#

no reason it shouldn't, it's just a .NET lib like anything else. I wonder why webgl hates it though

languid spire
fathom bramble
languid spire
#

the whole library is async, not just the bit you use

fathom bramble
#

Hmm, okay, kinda lame. I'll keep that in mind for future builds if I want to keep supporting webgl

#

thanks for the help

languid spire
fathom bramble
#

webgl was just a nice to have

languid spire
#

I'm guessing Unity 7

#

so not soon

austere bronze
# fathom bramble
public const string PlayerTag = "Player";

Also if you wan't to compare tags, you can define const string in a related class. If you need to change it, you can change from one place.

rich adder
#

a bit better with using consts , but I would still opt for components

#

consts are good where strings can't be avoided
good example is
Animator.StringToHash you still need the animation to be a String.

strong wren
#

i have some shop keepers and i tought using their names would be better then tags

polar acorn
#

Why not just have different data on the different shopkeeper objects, then you don't need to check anything at all

strong wren
#

huh

rich adder
#

^ ShopKeeper should be a component

#

then it doesnt matter which one you grab cause they all have their own stuff

strong wren
rich adder
#

yes , anything that sits on a gameobject is a component..

strong wren
#

yeah i know but i was thinking of just checking the names of the gameobjects that my raycast is hitting

#

then if u press E it opens up their shop i already implimented that

#

anyways so im having an issue with the raycast lol

rich adder
strong wren
#

it isnt following the player it just stands at the spawn locaiton of the player

rich adder
#

if(hit.collider.TryGetComponent(out ShopKeep shopKeeper)
shopeKeeper.Interact()

strong wren
#

its just like 3 buttons anyways

rich adder
eternal falconBOT
strong wren
strong wren
rich adder
#

they all have the same script "ShopKeeper"

strong wren
#

how would it know the differnt beetween shopkeepers

rich adder
#

based on the data on them?

strong wren
#

idk its alot easier to check the tags

rich adder
#

easier doesnt mean good

strong wren
#

its not like i have 10, i barely have 3

rich adder
#

you could even put a "ShopKeeperName" string if you really wanted to print a name or something, but why would a name change anything in the logic.

strong wren
#

how is that "better"

#

i mean yeah, it would be better if i have alot of shop keepers sure but i have 3 and its all simple

#

the last method i was using it was thru colliders lol

rich adder
strong wren
#

if im a trigger colllider with that tag then it does this etc, but i need to make it easier for smth

strong wren
rich adder
#

use a component designed to be a shop keeper is a lot better than checking a name then doing what?

rich adder
strong wren
rich adder
strong wren
#

and so are the variables

rich adder
#

the money the shop keeper has?

#

whats about its items

strong wren
#

uhm i think u expect an actual good shopkeeper from me

#

that aintt gonna happen

rich adder
#

well thats why i was suggesting better but you seem to think its better cause its easier to check names on each shopkeepr 🤷‍♂️

strong wren
#

or a button that increases my health count

#

etc

strong wren
#

il look into it later, now why is my ray cast not following the player?
if (Physics.Raycast(RayCastGameObject.transform.localPosition, transform.forward, out RaycastHit Hit, 100, Interactable))

rich adder
#

"my boat already floats with duct tape covering the holes, I dont need a new raft"

strong wren
#

exactly

polar acorn
strong wren
#

ok

rich adder
strong wren
#

oh its the location from where the raycast starts

polar acorn
#

For example:

Debug.Log($"Hello, I am {shopKeeper.name}, and I sell {shopKeeper.inventory} for {shopKeeper.prices}");
rich adder
strong wren
#

yes it parents it

#

its a child of the thing that already moves i mean

rich adder
#

did u use the Physics Debugger to check where the ray is

strong wren
rich adder
#

show the line

strong wren
#

the line of code or the gizmo line

rich adder
#

drawline is wrong usually if you're doing ray

rich adder
strong wren
#

Gizmos.DrawLine(RayCastGameObject.transform.localPosition, transform.forward * 20);

rich adder
#

the second spot expect a position, you're passing a direction

#

Gizmos.DrawRay(RayCastGameObject.transform.localPosition, transform.forward * 20);

rich adder
strong wren
rich adder
#

yes now you should be able to see the proper debug

strong wren
#

yep still same issue

rich adder
strong wren
#

red line is the gizmo

polar acorn
rich adder
strong wren
rich adder
rich adder
strong wren
rich adder
strong wren
#

how

rich adder
#

topleft corner scene view

polar acorn
# strong wren what

Change your inspector gizmo to "Local", select the object that has your Gizmo code on it, then show the transform gizmo that appears for it

strong wren
#

oh im on local

polar acorn
#

Okay, that's good. Now, select the object that has your draw gizmo code on it, and show where the arrows are

rich adder
strong wren
undone ledge
#

how would I make a rigidbody rotate around the centre of another rigidbody instead of the centre of itself?

strong wren
polar acorn
strong wren
#

kinda wierd on how the line goes a lil bit behind

strong wren
polar acorn
#

Well, you're starting it at the position of a different object

strong wren
polar acorn
rich adder
strong wren
#

it looks like it draws a line from the middle to the player

polar acorn
rich adder
#

noshit

undone ledge
rich adder
#

its 0,1,-0.06

#

change localPosition to .position

strong wren
#

thats cool

strong wren
strong wren
solar torrent
#

I made a ui and on the ui there is a text loop lik a news thing which is at the bottom but whn the second loop comes it spawnes like faw back idk whats wrong and also when i change cameras to the ui the loop stops

rich adder
#

we have 25% of the problem here

solar torrent
#

ok bet

#

how do i send it in like a text thingie

polar acorn
#

!code

eternal falconBOT
solar torrent
#

'''cs

#

oh wait mb

#

wait bro can i ask a huge favour can i just call you

#

I'm new to pc

rich adder
solar torrent
dense willow
#

Does anyone know how to manipulate two Unity UI elements on Vector2 without something weird happening? I'm trying to place a UI element next to another by first puttin it in the middle of it and then sutracting it's x placement by half the width, but instead it goes like -1000 on the x axis

rich adder
dense willow
solar torrent
#

brother that aint ai code that was actually my own i just got emo and ask Chat gtp to help

#

idk wth I'm doing worng

rich adder
solar torrent
#

ok but it is not but like pllllllsssss do you see what is wrong

rich adder
#

i told you how I would do it

#

Reset the position of the transform instead

solar torrent
#

ok

#

bettt

rich adder
#

all you need is to track 2 positions

solar torrent
#

of what though

#

newsss is the canvas

#

and Newss is the text

rich adder
#

which one is the moving text

solar torrent
#

this guyyy

rich adder
#

man you should use proper names like NewsCanvas NewsText so you can tell whats what

solar torrent
#

has the script

steep rose
rich adder
solar torrent
#

how do i show i vid

rich adder
#

record with OBS or something, then send it over as mp4. or use streamable.com

solar torrent
#

o0o00o0o sussy baka i fixed i forgot the GetComm

#

but the other one still does not work where i chage the cameres it stop

#

i will send vid

steep rose
open summit
#

My game is build but crashes when it connects to multiplayer through photon. its a android game for quest 2 so i have the logs
(i have reinstall unity and rebuilt the libary folder)

java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: JNI GetStringUTFChars called with pending exception java.lang.StackOverflowError: stack size 1038KB
java_vm_ext.cc:579] at java.lang.Class java.lang.Object.getClass() (Object.java:74)
java_vm_ext.cc:579] at java.lang.String java.lang.Throwable.toString() (Throwable.java:491)
java_vm_ext.cc:579] at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
java_vm_ext.cc:579] at boolean com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(com.unity3d.player.UnityPlayer) ((null):-1)
java_vm_ext.cc:579] at boolean com.unity3d.player.UnityPlayer$D$a.handleMessage(android.os.Message) ((null):-1)
java_vm_ext.cc:579] at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
java_vm_ext.cc:579] at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:214)
java_vm_ext.cc:579] at void android.os.Looper.loop() (Looper.java:304)
java_vm_ext.cc:579] at void com.unity3d.player.UnityPlayer$D.run() ((null):-1)
java_vm_ext.cc:579]
java_vm_ext.cc:579] in call to GetStringUTFChars
java_vm_ext.cc:579] from boolean com.unity3d.player.UnityPlayer.nativeRender()```
dense willow
solar torrent
open summit
solar torrent
#

until i chagned cameras

steep rose
dense willow
steep rose
steep rose
solar torrent
#

i just dont want to loose you

dense willow
#

I have an idea of how that would go, but I don't want to jump into it without knowing exactly how to do it

rocky canyon
#

well thats how u learn..

dense willow
#

True, but I want to know what exactly

#

Like, how exactly to do it

slender nymph
#

here, this should help you figure it out: add == +

solar torrent
#

BOXXXXX

#

help me please i send a vid idk whats wrong

#

.... dont leave me now ........

slender nymph
solar torrent
#

heheh sorry

dense willow
slender nymph
#

i'm saying that to add an offset you literally just use the + operator. if that is too much for you, then perhaps you should start smaller and do the beginner courses in the pins

solar torrent
#

were in the operator

static wasp
dense willow
static wasp
slender nymph
slender nymph
dense willow
steep rose
eternal falconBOT
#

:teacher: Unity Learn ↗

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

steep rose
#

but a hint would be +, adding an position by a vector2

undone ledge
dense willow
steep rose
#

yup!

#

cameraUI.position = OtherUI.position + new vector2(X,Y);, X and Y are floats to adjust in the inspector.

dense willow
steep rose
#

it only requires 2 floats

#

not 3

slender nymph
#

that is 2 floats. the problem is they need to use a Vector3 not a Vector2 for the offset

dense willow
#

I see

slender nymph
#

because transform.position is a Vector3 which means only a Vector3 can be added to it

static wasp
#

is OnCollisionStay(Collision collision) better in this situation?

    void OnCollisionEnter(Collision collision)
    {
        if (Physics.Raycast(transform.position, Vector3.down, out hit, 1.5f))
        {
            is_jumping = false;
        }
    }
steep rose
#

then use a vector3 my bad 😅

#

didnt know that was like that

slender nymph
static wasp
slender nymph
#

lol no

static wasp
#

ok ig

slender nymph
#

raycasts are incredibly cheap

dense willow
steep rose
#

in playmode then copy the position back in scene mode

dense willow
#

My issue is that it's turning the position into some crazy number

steep rose
#

what object is the first photo?

dense willow
#

I'll show you full screenshot

steep rose
#

looks fine?

dense willow
#

So, in the beginning, it sits at about Position X of -60. But if I tell it to do that in code, it goes to Pos X of 14400 As shown here:

dense willow
#

Here's the code for it

steep rose
rocky canyon
#

rectTransform.anchoredPosition = new Vector2(-63.4, 26f); try

dense willow
#

Alright

#

Holy crap that worked

dense willow
#

I knew the fix was probably simple, but I was so confused

rocky canyon
#

yea rect transforms a bit odd

dense willow
#

So why does it do that with regular position of rect transform?

steep rose
#

well that works

dense willow
rocky canyon
dense willow
rocky canyon
#

soo - 144400 or w/e is how far the UI element is from the origin of the world

slender nymph
rocky canyon
#

(placed on the big ole canvas gizmo thats offcenter of the gameworld)

dense willow
steep rose
#

i guess use anchor position for UI stuff 😅

rocky canyon
#

rectTransform.anchoredPosition: This property sets the position of the UI element relative to its parent’s anchor points.

dense willow
#

Lets try it

rocky canyon
#

should sure 👍

dense willow
#

Works better than before. Now my only issue is that the play button and the cursor rect position are different for some reason

steep rose
#

what is the issue with this?

dense willow
#

I actually figured out another way to go around this, but I'm just confused why the rect transform position between the cursor and the play button are different

#

Like, they're both in the middle, but their rect transform positions are completely different

steep rose
#

the buttons are a child of a different object entirely

#

you can add the mouseUI with it to make them the same

#

if you want

dense willow
#

Alright, but it's okay since I got my main problem solved. Thank you all yobaman

rich adder
dense willow
#

yeah, but the scaling shouldn't really effect it's position. And they both share the same canvas

rich adder
dense willow
#

True indeed, but these two objects are on the same canvas

open summit
#

im making a vr game and i added a computer with a mouse to it, but right now im doing it by hard coding the position the mouse has to be on the canvas to click on a certain object is there a way to find out what element the mouse is pressing on without this horrible trash

eternal falconBOT
open summit
#

kinda just wanna know if there is a name for like an approach to this problem i dont know of

#

and yes i know the code is bad thats why im trying to clean it

rich adder
#

these magic numbers look like implosion waiting to happen

open summit
#

yes

#

i dont want to deal with them anymore since i want to add more stuff

rich adder
#

are you using a world canvas?

open summit
#

yes

#

but also

#

uh the worst way

#

i have a seperate camera

#

rendering ui only

#

just so i can put it on the screen with a render texture

#

so that it gives that curved crt screen effect

rich adder
#

but whats wrong with the cursor rn

open summit
#

no it works im just asking what the better way to do it is instead of hard coding the positions of things on screen

rich adder
#

from my understanding VR doesnt have overlay canvases ?

ionic zephyr
#

Is there any way to organize variables "separating " them in the inspector via code?

rich adder
#

just dont use magic numbers, create actual variables with meaning to those numbers

open summit
#

theres no way to tell what the fake cursor is on?

rich adder
open summit
#

like i think with a real cursor theres like a screen to world thing

ionic zephyr
rich adder
open summit
#

ok, never tryed that before, will try now

rich adder
#

idk the virtual cursor thing makes it tricky

#

since your'e not moving the hardware cursor, I think EventSystem.RaycastAll relies on that

frank flare
#

array length is Array.Length right?
I would test it myself but launching unready unity script is painful

rich adder
open summit
rich adder
open summit
#

think so

rich adder
#

maybe you can Modify the InputModule to use the virtual cursors position

open summit
rich adder
#

also uncheck Raycast target on it

open summit
#

ok

rich adder
#

you dont want ur cursor to be a raycast target blocking other UI

glass bobcat
#

any suggestions on how to make my character’s legs not move at the same time (im trying out procedural animation)

trim finch
#

uh... how i use clamp?

deft grail
trim finch
#

sorry but, wym? where i put this C

deft grail
trim finch
#

oh, thank you

rich adder
#

this is the wrong class

#

you want Mathf lowercase f

trim finch
#

yeah, just saw it is different the F being capitalized or not

rich adder
#

yeah MathF is a system class, it doesn't have Clamp

trim finch
#

one thing i like about gamemaker and im not finding in unity is: when i click with the middle mouse button on a function or whatever it is, is opens the documentation of that thing on the browser, there is any button i can do something like that? it would be soo good

#

(im coming from gamemaker, so im a bit confused)

rich adder
trim finch
#

there is any extension or something on visual studio that allows that?

rich adder
#

you can try CTRL+ALT+M, then CTRL H

trim finch
#

lemme try brb

#

it doesnt work the ctrl alt m

rich adder
#

yeah sorry that thread is old, it should tell you if you go under Environment -> Keyboard search for Unity

frank flare
#

I'm not sure, for checking rigidbody I should use if (hitColliders[i].TryGetComponent<Rigidbody>() == item1) or what?

frank flare
#

basically this

rich adder
#

well thats not how you write TryGetComponent

#

where is the out

frank flare
#

ah

rich adder
frank flare
#

I thought it would be used to attempt to get component

rich adder
frank flare
#

if I use getcomponent rigidbody on a collider that doesn't have rigidbody will it fail?

rich adder
#

shouldn't
why not just use try get tho

frank flare
#

ok

frank flare
rich adder
#

also you're comparing a bool to a rigidbody ?

#

idk how thats not erroring

frank flare
#

why it wouldn't assign to the itemtoattach above? (since it's gray it wouldn't be assigned I assume)

lethal meadow
#

how would I make my character float in water

frank flare
rich adder
rich adder
#

I personally prefer early return patterns, I would usually do
if(!collider.TryGetComponent(out itemToAttach) continue; //continue skips the rest of loop
if(itemToAttach != item1) continue ;
//do other stuff

#

nesting so many if braces gets unreadable sometimes

queen adder
#

what was the vertx debug tool that draws shapes again?

#

anyone know?

queen adder
#

thanks

static wasp
#

how do i make a random item generator from a list

#

instead of doing a random number index

#

or is that not possible?

queen adder
#

get random number, select that from list, what's the problem with that?

static wasp
queen adder
#

not really

static wasp
#

k thanks

frank flare
#
bool item1_is_touching = false;
        for (int i = 0; i < hitColliders.Length; i++)
        {
            if (!item1.TryGetComponent(out Rigidbody hasRigidbody)) continue;
            Rigidbody hitRb = hitColliders[i].GetComponent<Rigidbody>();
            if(hitRb != item1) continue;

            item1_is_touching = true;
        }
rich adder
#

hasRigidbody is the result

frank flare
queen adder
#

the out returns something

rich adder
#

yes but if its true, meaning it found the component, it puts it into out

#

pretty sure I mentioned it before

frank flare
#
bool item1_is_touching = false;
        for (int i = 0; i < hitColliders.Length; i++)
        {
            if (!item1.TryGetComponent(out Rigidbody hitRb)) continue;
            if(hitRb != item1) continue;

            item1_is_touching = true;
        }
#

so I just do it like that

rich adder
#

yup

#

wait

#

item1.TryGetComponent should be hitColliders[i].TryGetComponent

static wasp
#

how do i compare 2 different Vector3s

rich adder
#

well depends ig what you comparing

static wasp
polar acorn
static wasp
#

their value

rich adder
#

yes but how close they are or

polar acorn
static wasp
#

imma send the code

rocky canyon
#

this.transform.position == that.transform.position;

static wasp
#
        if ((Mathf.Abs(transform.position - player1.transform.position)) > (Mathf.Max(transform.position - player2.transform.position, transform.position - player3.transform.position)))
        {
            nearest_player = "Player1";
        }
rocky canyon
#

approximately

polar acorn
#

I can't make heads or tails of what you're trying to do here. What is the actual thing you're checking for?

rich adder
#

yes Im confused

#

also you need a loop myg, players should be an array

static wasp
#

this line is comparing the distances of the transform.position and the player1.transform.position with the other distances

polar acorn
rich adder
#

I dont see how it gets you nearest here

static wasp
rich adder
polar acorn
rocky canyon
#

out outputs the Distance.. (1) number

static wasp
rocky canyon
#

if that number is < than a threshold u supply u could basically assume its in the same spot

static wasp
rich adder
#
Transform GetNearestPlayer(Vector3 point)
{
    Transform nearestPlayer = null;
    float minDistance = Mathf.Infinity;

    foreach (Transform player in players)
    {
        float distance = Vector3.Distance(point, player.position);
        if (distance < minDistance)
        {
            minDistance = distance;
            nearestPlayer = player;
        }
    }
    return nearestPlayer;
}```
`[SerializeField] Transform[] players`
rich adder
static wasp
mint remnant
#

pretty basic c# code, with a sprinkling of math

rich adder
# static wasp almost all of it

lets say you want the nearest player from some other object, you just do
Transform nearestPlayer = GetNearestPlayer(targetPoint.position);

#

the rest of the code is simple maths

static wasp
#

i don't understand the math part of it

rocky canyon
#

set nearest player to nulll make sure its not assigned to any other
set minDistance to infinity
each player run distance setting the newest lowest value to minDistance..
finally return the lowest player / b/c of lowest distance

rich adder
rocky canyon
#

its basically a get lowest number loop

rich adder
#

foreach is looping through all players (checking each one as player)

static wasp
#

is foreach a for loop, (i haven't used for loops yet in C#)

rocky canyon
#

its basically for loop w/ the length already set

rich adder
#

its similiar to forloop but you loop through the objects instead of using iterator, and its not mutable

rocky canyon
#

new int[] myIntArray[3] <--- foreach will run 3 times

static wasp
rocky canyon
#

exposes a private variable in the inspector

rich adder
static wasp
#

k thanks

rich adder
#

similiar to how public shows everything in the inspector

#

but keeps it nice and private 🕵️

static wasp
rich adder
static wasp
#

oh ok

#

thanks

rich adder
#

self protect (or if you're with a team , its like saying dont change this from anywhere else but this script)

young smelt
#

Please how do I fix this:

Your advertising ID declaration in Play Console says that your app uses advertising ID. A manifest file in one of your active artifacts doesn't include the com.google.android.gms.permission.AD_ID permission.

If you don't include this permission in your manifest file, your advertising identifier will be zeroed out. This may break your advertising and analytics use cases, and cause loss of revenue. Learn more

You can remove these errors by updating your advertising ID declaration

Apps that target Android 13 (API 33) without the AD_ID permission will have their advertising identifier zeroed out. This may impact advertising and analytics use-cases. Learn more

young smelt
#

ok

static wasp
#

this is the code for the script

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

public class Enemies : MonoBehaviour
{
    public int enemy_health = 100;
    public GameObject player1;
    public GameObject player2;
    public GameObject player3;
    public Transform[] characters_selected_list_Vector3 = { player1 , player2, player3 };
    public string nearest_player = "Player1";
    private int random_number = Random.Range(0, 3);

    void Start()
    {
        
    }

    void Update()
    {
        if (enemy_health <= 0)
        {
            Destroy(gameObject);
        }

        
    }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Bullet")
        {
            enemy_health -= 10;
        }
    }

    Transform GetNearestPlayer(Vector3 point)
    {
        Transform nearestPlayer = null;
        float minDistance = Mathf.Infinity;

        foreach (Transform player in characters_selected_list_Vector3)
        {
            float distance = Vector3.Distance(point, player.position);
            if (distance < minDistance)
            {
                minDistance = distance;
                nearestPlayer = player;
            }
        }
        return nearestPlayer;
    }
}
cosmic dagger
eternal needle
cosmic dagger
#

you have to initialize or assign the field characters_selected_list_Vector3 in a method . . .

eternal needle
#

you can populate the array in Awake

static wasp
eternal needle
cosmic dagger
static wasp
#

why does it tell me that i need to put a closing bracket even though i put it

#

this is the error: Assets\Scripts\People\Enemies.cs(16,6): error CS1513: } expected

#

this is the Awake part

    void Awake()
    {
        public Transform[] characters_selected_list_Vector3 = { player1 , player2, player3 };
    }
eternal needle
static wasp
rich adder
#

is your IDE not configured ?

#

also this variable name is crazy characters_selected_list_Vector3

static wasp
cosmic dagger
#

if not, then you need to configure your !ide . . .

eternal falconBOT
rich adder
#

also that array was meant to replace player1, player2, player3

static wasp
#

lemme configure it rq

static wasp
rich adder
#

or Unity -> Preferences if you're on mac

static wasp
#

Visual Studio Editor has been updating for 5 minutes

static wasp
rich adder
static wasp
rich adder
static wasp
#

it has unity on the side

rich adder
static wasp
rich adder
#

if its showing you the meta then you did not do it correctly

rich adder
rich adder
# static wasp what's meta?

.meta files are meta files unity uses to keep track of assets so all the connected objects and their component etc

static wasp
#

what do i do

rich adder
# static wasp what do i do

first of all , did you do the part about package manager, did you verify the version of Visual Studio Editor package, and screenshot your external tools page

#

close vscode in the meantime

static wasp
#

wait

#

i have another vs code window with python on it

#

is that why?

rich adder
#

not if you double clicked the script from unity editor

#

it should not affect other windows

rich adder
#

i have 3 different vscode with diff languages

steel mauve
#

Different vs code profiles?

rich adder
rich adder
rich adder
static wasp
rich adder
#

did you read the guide at all or skimmed through it?

static wasp
rich adder
#

it should be the one with the Visual Studio Code version

static wasp
#

do i restart unity?

rich adder
#

you have compile errors

#

its probably why it can't refresh

static wasp
#

so what do i do

rich adder
#

temporarily comment out the script

#

public class YourScriptWithError : MonoBehaviour
{
    /*
    //codee etc. 
    */
}```
#

use /* to start the comment portion and */ closes it

static wasp
rich adder
#

good enough

#

save it and let it compile

static wasp
#

i selected the new one in external tools and re-opened vs code by double clicking on the script and i got this

#

and i looks the same as before

#

also it gave this warning
Project path contains special characters, which can be an issue when opening Visual Studio
UnityEngine.Debug:LogWarning (object)

rich adder
#

well does it ? thats no good not just for visual studio

static wasp
rich adder
static wasp
rich adder
#

External tools, close vsc (all the windows)

#

make sure it shows the vscode version, Regen, open script from unity

rich adder
rich adder
# static wasp yes

check the Output window in vscode does it say anything about SDK missing & and what does Terminal window say

static wasp
rich adder
#

probably

rich adder
static wasp
rocky canyon
static wasp
#

which one do i pick

rich adder
#

it usually autoselects it when you open script from unity

#

devkit i think

static wasp
#
IdeBenefitsSource: Failed to fetch entitlements. Error: 'Error: Request to https://api.subscriptions.visualstudio.microsoft.com/Me/Entitlements/IDEBenefits?api-version=2023-03-26&caller=vscode failed with status code: 401 and response ""'
#

this is what it says

rich adder
#

nah this is probably related to not logging into devkit

#

try the c# one, close Vsc and open script again if you must, it will reset

#

or .net install tool, one of this

static wasp
#
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\1eb67383"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 4:19:30 AM] [Program] Language server initialized```
#

don't mind the 4:20 am xd

rich adder
#

looks promising

#

do you not have Solution Explorer in the Explorer window

rocky canyon
#

nav's right it should be set to auto-detect

static wasp
rich adder
#

why does your project have multiple solutions.. close vscode, delete all .sln and .proj files in your root project

#

Regen project files again

rocky canyon
#

this .. and u got a notification on ur extensions panel

rich adder
# rocky canyon

should also say Assembly at the bottom + Devkit logo with C#in hexagon

rich adder
static wasp
#

do i move to recycle bin

rich adder
#

lets make a thread maybe so we dont flood this

static wasp
#

xd

#

VS Code Unity Extension Problem

hollow zenith
#

Hey, how can I use Dictionary TryToGetValue out and parse it at the same time?

#

        int w, h, x, y, z;
        if(properties.TryGetValue("w", out Int32.Parse())
#

Before I moved it to dictionary, I used a list:

        int w = Int32.Parse(properties[0]);
#

Is that possible? Is there a way to include a default value?

hollow zenith
#

Whats &&?

rich adder
#

if (properties.TryGetValue("w", out string wValue) && int.TryParse(wValue, out w))

hollow zenith
#

Is there a way to negate this whole statement? I.e. if there is no value in dictionary then I would assign a default value or do nothing?

#

Ideally I'd not even use if statement here

#
int w = 100;
int h = 100;

//try parse
rich adder
#

int w = properties.TryGetValue("w", out string wValue) && int.TryParse(wValue, out int parsedW) ? parsedW : 100;

hollow zenith
#

Thanks, that works too 😄

karmic field
#

Hey, I'm having a very weird issue with a script I've written just... not running. I can't seem to figure out why it's happening. I've written a script called "Inspect" that takes in an animator and two textures. Using OnMouseEnter the script is supposed to play an animation state called "Inspect" on the animator and then change the cursor to a different design. It works only on one object in the scene... Like, only one object and nothing else that I apply the script to, even if it's the only copy of the script in the scene at any given time.

I've also added a Debug.Log statement in the code but the only time that statement gets fired is when the OnMouseEnter event happens for the one object in the scene where the script works. As far as I can tell, there's nothing that should prevent multiple copies of the script from running in the scene at once.

Am I doing something wrong, or am I going insane?

The first screenshot shows the intended behavior on the object in the scene where it works. The second one shows the Inspector for that object. The third screenshot shows what's happening to the second object along with the inspector. Not sure if there's a particular place I should post the code or if I can just use a Discord code block. It's not super long.

Unity Version: 2022.3.41f1
Platform: Windows

eternal falconBOT
rich adder
karmic field
rich adder
#

can I see the collider of the phone in scene view, also the table collider

karmic field
rich adder
#

i wonder if anything else is blocking it

#

hmm i don't miss OnMouseEnter at all lol no way to debug it properly like drawing rays, hitinfo

karmic field
rich adder
#

Raycast

#

this way you can actually print what its hitting at that moment

karmic field
#

The other weird thing is that multiple scripts in the scene are all using OnMouseEnter so it's weird that this is the only thing that's not working.

karmic field
#

Or a piece of example code?

karmic field
#

I'll have to look into that!

rich adder
#
[SerializeField] private LayerMask inspectableLayers;
[SerializeField] private float maxDistance = 100;
 void Upate()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out var hitInfo, maxDistance, inspectableLayers))
            Debug.Log($"Hit {hitInfo.collider.name}!");
    }```
karmic field
nimble apex
#

im optimizing a loading mechanism inside my app , this mechanism is to download game images (as png), store it to local , and then read/use it in code

the flow that i want it to be is like this:

//write
server => png downloaded as bytes (websocket.dlhandler.data) => 
File.WriteAllBytes("TEH PATH", webRequest.downloadHandler.data);

//read
texture.LoadImage(File.ReadAllBytes(filePath));```
rich adder
#

but yeah its the ones from the unity layers

karmic field
rich adder
#

only thing I would recommend so far is using async File.WriteAllBytesAsync

#

IO operations are already slow as is :\

nimble apex
# rich adder what is the question?

this is the "write" function , the write part in my post

the call back here needs the file that i written , as texture2D
because this is an async function with web request stuff, i want to ask if i create a texture here with

new Texture2D(...);
texture2D.loadimage

callback(texture2D);```

will it be expensive?
#

the callback is actually a function , its the "read" part

rich adder
#

loading from filedisk you mean?

#

if you're coroutine should be ok I guess, i always do my IO /net operations on async

karmic field
rich adder
karmic field
rich adder
#

there are tools to simulate such slowdowns

rich adder
#

is the script on a gameobject?.
Check the Console window, screenshot it in playmode

rich adder
#

you dont want multiple rays for same thing

nimble apex
# rich adder loading from filedisk you mean?
  1. download from server , as bytes

  2. write as file from bytes

  3. create a new texture2D() container

  4. fill in the data with texture2D.loadImage

  5. parse in callbacks

my question is , after optimization, i added step 3 and 4 here, will it be expensive? if this function also need to "download stuff from servers"

i dont want a sudden heap of usage in particular function, should i move 3 and 4 to somewhere else?

#

its just distribution of workloads

karmic field
rich adder
nimble apex
#

nice

#

then i think it should be fine

#

ty👍

rich adder
#

goodluck 🫡

nimble apex
#
        String folder = Path.GetDirectoryName(savePath);
        if (!Directory.Exists(folder))
        {
            DirectoryInfo di = Directory.CreateDirectory(folder);
        }

        Texture2D convertedResource = new Texture2D(1, 1);
        convertedResource.LoadImage(webRequest.downloadHandler.data);

        if (!savePath.Contains("blur"))
        {
            File.WriteAllBytes(savePath, webRequest.downloadHandler.data);
        }
        else
        {
            convertedResource = BlurTexture(convertedResource); //warning: pixel data manipulation will cause heavy RAM usage
        }

        callback(true, convertedResource);```
rich adder
#

so its not going to 0.1f in the blend tree?

glad wagon
#

0.1 means the characater is moving?

rich adder
glad wagon
#

is -1,0 and 1

rich adder
#

so why you write 0.1f for input.x

glad wagon
#

idk, is wrong...

rich adder
#

pass that value

glad wagon
#

for both sides

rich adder
#

wdym both sides?

#

walking forward animation only goes forward

glad wagon
#

yes, but I want it to play when it is rotating

rich adder
#

right so thats input.x value

glad wagon
#

but how can I add this to the code?

#

if I change y for x the walk animation only plays when rotate

rich adder
#

you need both

glad wagon
#

it worked with this, but now the reverse walk animation is not playing

static wasp
#

unrelated, but, when you are pasting code write `‎`` cs in the begginning

#

and `‎`` in the end

#

i accidentally put a space between them

#

!code

eternal falconBOT
rich adder
#

better yet use links when its a large code like class

static wasp
glad wagon
rich adder
#

"Ai" strikes again..

glad wagon
#

yeah, sorry for that, but I have no other option rn

#

I know it can be offensive for real programmers 😂

rich adder
#

its just that its only doing you harm since you dont seem to understand what you're pasting in

#

without using ai /google, do you know what mathf.abs is doing?

glad wagon
#

I'm like, hit or miss

glad wagon
static wasp
#

using AI is fine (only a small part tho)

#

but you have to understand what the AI wrote

#

and understand why it works

glad wagon
#

I understand some little things

static wasp
#

you can ask AI to explain it if you don't understand btw

glad wagon
#

AI is giving some other soutions that don't make too much sense

#

like, add parameters to the blend tree, but the blend tree only accept one parameter

static wasp
#

xd

#

could have gotten a more clear image, but yes, that is how absolute value works

charred spoke
static wasp
#

but to be fair, when i was using AI, it was some really basic stuff

#

AI is terrible at complex code

glad wagon
#

I thought making a guy walk around while standing still would be something simple for AI

rich adder
charred spoke
#

But it does not explain anything you can literally tell the gpt that what it said is wrong and it will spit out a new series of grammatically correct words that fit the context. You simply got lucky that the series of words you got spit at you were in fact in line with the truth

static wasp
rich adder
#

indeed chance / got lucky

glad wagon
rich adder
#

at least it took you 70% quicker than most

glad wagon