#archived-code-general

1 messages · Page 349 of 1

lean sail
#

that suggestion to add some degrees isnt really accurate. if its an issue, that means your model isnt pointing the correct way. nanior only had to do it because their 2d object was facing upwards rather than to the side

#

the arrows are seemingly set to global space rather than local so i cant really tell if they are facing the right way

#

or im not sure what the arrows are even for, doesnt look to be aligned with the foot in the first image

pastel patio
gloomy helm
#

i made the arrows local

lean sail
#

yep arrows arent pointing correctly

pastel patio
#

Quaternion.LookRotation points the z axis towards the given direction

lean sail
#

wat, Quaternion.Euler has nothing to do with direction

pastel patio
#

Ooops

#

I mean Quaternion.LookRotation

gloomy helm
#

should i just re draw the spline idk if it will work

wide lily
#

hey quick question, im working in unity2d and i have a tilemap with a slope on it and want to find the normal vector of the slope using a raycast. The way i have it set up is so the slope tile has a custom physics object where its just a triangle. Is there a way i can get the normal or will i have to do something else? I tried this earlier and basically what happened is when i made a ray it would only return the correct normal if the ray was exactly on top of the edge of the slopes collider

pastel patio
#

Redrawing it is certainly cleaner

#

Also I never worked with splines, I'm just taking it as rigging

gloomy helm
#

bro ima just redraw if it dosent work im gonna just go sleep

gloomy helm
pastel patio
gloomy helm
#

any way thank you both Nanior and Bawsi for helping

wide lily
#

does anyone know

pastel patio
#

Np

wide lily
#

Please😁

pastel patio
wide lily
pastel patio
#

I think that circlecast does the trick too, if you prefer it

#

Not sure what you're trying to do there

wide lily
#

im trying to shoot a ray at the slope tile and get the normal vector of it

pastel patio
#

Wouldn't see why it'd not work, except if you by accident start from inside the collider for some reason

wide lily
#

yea thats what i was worried about

#

cuz the normal only is right when its like right on the edge

#

how do i set up the raycast so it stops when it hits the slope

pastel patio
#

What does right on the edge mean?

wide lily
#

like the edge of the collider

pastel patio
#

No idea why it doesn't work...

wide lily
#

i have the raycast set up so it goes a fixed distance is it possible its ending inside the collider

pastel patio
#

It doesn't sound like a layermask issue

pastel patio
wide lily
#

oh

pastel patio
#

It otherwise behaves like a normal raycast

wide lily
#

so how do you explain when i go to a precise distance away from the collider the raycast will work because its hitting the edge of the collider perfectly

#

it will return the correct normal*

pastel patio
#

Maybe you're just using the function wrongly

wide lily
#

I dont think im using it wrong cuz i drew the same ray with debug.drawray and its working perfectly

#

forgive me im not on my computer rn so i cant show exact code

pastel patio
#

Oh...

#

Eh, honestly, I can't help you rn

wide lily
#

Thats alright thanks for trying anyways

pastel patio
#

The only thing that comes to mind is that the function might have some mistakes, for the rest i don't see how this bug exists whatsoever

#

Np, bye Neuba

wide lily
#

Its just weird cuz the thing only works when im at a very precise distance away from the collider

wide lily
gray mural
#

Hey, is it possible to restrict specific Brushes on a chosen Tilemap? The Tilemap class is sealed.

craggy panther
#

Why don't Google Play services work for me?

    using GooglePlayGames;

    public void Start() {
      PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
    }

    internal void ProcessAuthentication(SignInStatus status) {
      if (status == SignInStatus.Success) {
        // Continue with Play Games Services
      } else {
        // Disable your integration with Play Games Services or show a login button
        // to ask users to sign-in. Clicking it should call
        // PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
      }
    }
}

I use this code but absolutely nothing happens in the game

lean sail
craggy panther
#

I thought that this cat allows the player to log into the account and the login window should appear in the game

raven ocean
#

I need help with my code. I keep getting this illusive Null Reference Error, and I have no idea what it really means nor how to fix it. I tried searching for answers and didn't find anything useful.

This is the main code I'm struggling with: https://gdl.space/aqumuculuv.cpp
My errors are in the image.
The code that I'm getting my bools from is this: https://gdl.space/oyojomafuk.cs

lean sail
prime vapor
#

Hello everyone!
I'm asking here cause I feel like I'm going to explode this is so frustrating.
I have a horizontal layout group with two text meshes and an image in the middle like in image 1.
I want to make it so that the rect adapts to the size of the text inside (as in image 2 to image 3).
I can't put content size fitters on the text since they're children of a layout group and it fs everything up.
Any Unity UI pros have a solution for this? I can't belive I'm having so much trouble with this

raven ocean
raven ocean
lean sail
leaden ice
#

Show your code

raven ocean
deft kindle
leaden ice
deft kindle
rancid hawk
#

I got that error

leaden ice
#

Or it's failing before getting to any logs

#

Make sure it's actually attached to an object in the scene

#

And add more logs at the beginning

rancid hawk
# rancid hawk I got that error
using System.Collections.Generic;
using UnityEngine;

public class CameraManager : MonoBehaviour
{
   public Transform target;
   public float cameraSpeed;
   
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
       transform.position = Vector3.Slerp(transform.position, new Vector3(target.position.x, target.position.y, transform.position.z), cameraSpeed); 
    }
}```
leaden ice
rancid hawk
#

Didnt get any useful help

deft kindle
simple egret
# rancid hawk Didnt get any useful help

target is destroyed but you still try to access it on CameraManager line 19, as the error says
Errors have stack traces, which describe where the execution was exactly when the exception occurred

leaden ice
deft kindle
hexed pecan
deft kindle
knotty sun
deft kindle
knotty sun
#

so you have the LogCat package installed?

deft kindle
knotty sun
#

that is the package you use for debugging problems in an android build at runtime

deft kindle
knotty sun
#

then I cannot help you further

limber onyx
#

i using dotween to roll obj, 180 degree, can i somehow controll the direction to roll? i mean clockwise or counterclockwise?

deft kindle
knotty sun
deft kindle
deft kindle
#

nvm

knotty sun
deft kindle
#

some 2024-07-13 14:50:24.475 32149 32256 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames

knotty sun
deft kindle
modest ether
#

is it only me or is the AR Foundation Documentation really bad?
Im trying to migrate a project to Unity 6 but some functions arent there anymore and I cant find any mention of a deprecation for these, not even from the Version where they were avaiable and then the next version where they are not its not even mentioned that they are removed or that it is a breaking change... 🙄

craggy panther
#

Why don't Google Play services work for me? I use this code but absolutely nothing happens in the game

gray mural
#

worldPosition is a Vector2. How is the GridLayout.WorldToCell method with a Vector3 as its parameter is used instead of my extension method with a Vector2 and can I correct it?

#

I understand that Vector2 can be implicitly converted to Vector3, but, I suppose, it should still use the one with Vector2 as the parameter

simple egret
#

Error message? Looks like the error targets what you pass to TryAddTileInternal() (wrong return type?), not the extension method

gray mural
#

The error would disappear if I could've used my extension method

simple egret
#

Force the usage by calling the static method directly and see if that solves it

dusk apex
#

Can you post the complete error from the console?

gray mural
#

The issue is not in the error

gray mural
#

Surely, the issue is resolved, when referencing it this way

TryAddTileInternal(TilemapExtension.WorldToCell(torsoTilemap, worldPosition));
gray mural
dusk apex
#

Not certain if that's the issue. Posting the error would tell us what's really happening rather than trying to solve an issue that isn't a factor.

simple egret
#

Overload resolution is pretty robust, I'm pretty sure it chooses the overload with the exact types first, before trying to make conversions in an attempt to use others

#

Post the full error and the full !code

tawny elkBOT
gray mural
dusk apex
#

Are there any other errors?

#

Looks like a false positive

gray mural
gray mural
simple egret
#

Please post the full code

gray mural
#
public bool TryAddTile(Vector2 worldPosition)
{
    if (Length == 0)
        return false;
        
    return TryAddTileInternal(torsoTilemap.WorldToCell(worldPosition));
}

private bool TryAddTileInternal(Vector2Int position) => 
    TryIncreaseLength(position - TailPos);

//
public static Vector2Int WorldToCell(this Tilemap tilemap, Vector2 worldPosition) =>
    (Vector2Int)tilemap.WorldToCell((Vector3)worldPosition);
dusk apex
#

I'm assuming the actual error is with Try add tile internal wanting a vector 2 and not your extension method refusing to implicitly convert types.

gray mural
#

It's not my extension method, because it's not even used here

dusk apex
#

Where you're trying to explicitly use your extension method that returns a vector 2 instead of resolving the error - xy problem.

gray mural
dusk apex
#

Either way, the error is on that line but isn't likely related to the extension method

gray mural
gray mural
#

Well, the method was implemented to remove the explicit Vector3Int to Vector2Int convention, but it seems, because of my extension method not being visible, I will have to do it anyway

simple egret
#

Checked out the spec, the overload resolution steps for extension methods come after the step with converting types. So it'll first convert your parameter to a Vector3Int before calling the instance method. Spec mentions return types are not taken in consideration when resolving overloads

deft kindle
#

I AM SO MAD RIGHT NOW I GET THIS EVERYTIME AND IT IS SETUP RIGHT I HAVE OCTUPLE CHECKED IT

Error PlayGamesServices[SignInAuthenticator] **** APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES
Error PlayGamesServices[SignInAuthenticator] **** DEVELOPER_ERROR
Error PlayGamesServices[SignInAuthenticator] **** This is usually caused by one of these reasons:
Error PlayGamesServices[SignInAuthenticator] **** (1) Your package name and certificate fingerprint do not match
Error PlayGamesServices[SignInAuthenticator] ****     the client ID you registered in Developer Console.
Error PlayGamesServices[SignInAuthenticator] **** (2) Your App ID was incorrectly entered.
Error PlayGamesServices[SignInAuthenticator] **** (3) Your game settings have not been published and you are 
Error PlayGamesServices[SignInAuthenticator] ****     trying to log in with an account that is not listed as
Error PlayGamesServices[SignInAuthenticator] ****     a test account.
Error PlayGamesServices[SignInAuthenticator] **** (4) A server auth code was requested, but an incorrect client
Error PlayGamesServices[SignInAuthenticator] ****     id was provided. The client id for server auth codes should
Error PlayGamesServices[SignInAuthenticator] ****     be the client id for the game server (not the android app).
deft meadow
#

Hi guys, I'm trying to make a grappling hook sort of mechanic. I followed along with a tutorial, but something is not functioning properly (my code is exactly the same, I've checked multiple times).

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

public class GrapplingVine : MonoBehaviour
{
    [SerializeField] private float grappleLength = 10f;
    [SerializeField] private LayerMask grappleLayer;
    [SerializeField] private LineRenderer rope;
    //[SerializeField] private Transform playerTransform;

    private Vector3 grapplePoint;
    private DistanceJoint2D joint;

    void Start()
    {
        joint = gameObject.GetComponent<DistanceJoint2D>();
        joint.enabled = false;
        rope.enabled = false;

        //playerTransform = gameObject.transform;
    }

    void Update()
    {
        if (Input.GetButtonUp("Fire2"))
        {
            RaycastHit2D hit = Physics2D.Raycast(
            origin: Camera.main.ScreenToWorldPoint(Input.mousePosition),
            //origin: playerTransform.position, 
            direction: Vector2.zero,
            distance: Mathf.Infinity, 
            layerMask: grappleLayer
            );

            if (hit.collider != null)
            {
                grapplePoint = hit.point;
                grapplePoint.z = 0;
                joint.connectedAnchor = grapplePoint;
                joint.enabled = true;
                joint.distance = grappleLength;
                rope.SetPosition(0, grapplePoint);
                rope.SetPosition(1, transform.position);
                rope.enabled = true;
            }
        }

        if (Input.GetButtonUp("Fire2"))
        {
            joint.enabled = false;
            rope.enabled = false;
        }

        if (rope.enabled == true)
        {
            rope.SetPosition(1, transform.position);
        }
    }
}
#

Any clear issues or plausible causes?

fleet gorge
#

to double check this is for 2d right?

deft meadow
#

correct

fleet gorge
#

well you need a direction if you want to get anywhere

#

why is your direction Vector2.zero?

deft meadow
#

For some reason the guy in the tutorial said 'we don't really need a direction so let's use for example vector2.zero' 🤷‍♂️
I found it weird as well

deft meadow
#

Welcome to the How To Make Any Game Mechanic Series. In this series, I take you step by step, to create viewer suggested game mechanics. If you have an idea for a future video, leave it in the comments bellow!

Episode GitHub: https://rb.gy/zhym6

My 2.5D Course: https://www.gamedev.tv/courses/unity-2-5d-turn-based-combat?coupon=action&ref=ztfi...

▶ Play video
rigid island
deft meadow
#

Mine doesn't do anything that happens in the video haha

rigid island
#

idk what "but something is not functioning properly" means

rigid island
deft meadow
#

it doesn't enable the distancejoint or the linerenderer

#

and when I do manually the linerender is in the correct place that i clicked, but the distancejoint pulls me far off the map

rigid island
#

maybe make a video of issue

deft meadow
#

The only thing that's different btw is that I'm using a cinemachine camera, but I was hoping that that wouldn't matter with the 'Camera.main.ScreenToWorldPoint(Input.mousePosition),' line since I figured cinemachine just overides the main cam

deft meadow
#

And yeah, clicking does disable the linerenderer, but it doesn't draw it for some reason

rigid island
deft meadow
#

the player

#

Oh damn

#

I had the first code block set to buttonup instead of down, so now the linerenderer and distancejoint do get activated, but the joint is still pulling me away 😓

#

So the code is looking like this now:

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

public class GrapplingVine : MonoBehaviour
{
    [SerializeField] private float grappleLength = 10f;
    [SerializeField] private LayerMask grappleLayer;
    [SerializeField] private LineRenderer rope;
    //[SerializeField] private Transform playerTransform;

    private Vector3 grapplePoint;
    private DistanceJoint2D joint;

    void Start()
    {
        joint = gameObject.GetComponent<DistanceJoint2D>();
        joint.enabled = false;
        rope.enabled = false;

        //playerTransform = gameObject.transform;
    }

    void Update()
    {
        if (Input.GetButtonDown("Fire2"))
        {
            RaycastHit2D hit = Physics2D.Raycast(
            origin: Camera.main.ScreenToWorldPoint(Input.mousePosition),
            //origin: playerTransform.position, 
            direction: Vector2.zero,
            distance: Mathf.Infinity, 
            layerMask: grappleLayer
            );

            if (hit.collider != null)
            {
                grapplePoint = hit.point;
                grapplePoint.z = 0;
                joint.connectedAnchor = grapplePoint;
                joint.enabled = true;
                joint.distance = grappleLength;
                rope.SetPosition(0, grapplePoint);
                rope.SetPosition(1, transform.position);
                rope.enabled = true;
            }
        }

        if (Input.GetButtonUp("Fire2"))
        {
            joint.enabled = false;
            rope.enabled = false;
        }

        if (rope.enabled == true)
        {
            rope.SetPosition(1, transform.position);
        }
    }
}
brisk marsh
#

welp, i think i've done it now

#

I've broke unity in a way I've never seen before

#

with System.Reflection....

#

ah wait

#

no it's just because I had my scripting system infinitely calling itself.

#

that would do it

#

hahahaha yessssssss

#

Auto-Syncing values via reflection woooork

craggy panther
deft kindle
craggy panther
deft kindle
craggy panther
craggy panther
#

I just have nothing happening in the game and no results in the console

#

In the test scene, manual authentication goes on forever

deft kindle
#

it works for me i just get a Google Play Error because i think the plugin is broken for me

craggy panther
#

Okay, thanks

deft kindle
craggy panther
#

I'm going to try now

deft kindle
craggy panther
deft kindle
craggy panther
#

Unfortunately, my console does not show any errors and nothing happens in the game

deft kindle
deft kindle
craggy panther
#

I don't know what to put in "token" and "error"

deft kindle
craggy panther
#

So I did everything right

#

I heard something about logcat

#

Like it produces more detailed reports

#

I'll have to try it tomorrow

deft kindle
craggy panther
#

Okok

rigid island
hot torrent
#

In here, the "Type" field is an enum. It renders properly in the very top at "Engine" but further down inside Menus>Submenus the "Type" just renders as an int. Why is that and how do i fix it?

#

Here's how a button looks.

lean sail
hot torrent
leaden ice
hot torrent
leaden ice
#

It says seven in this article but I believe the limit is 10 in newer versions

hot torrent
#

Ah, good to know.
I design my Debugging menu inside the inspector so i hope i won't run into this issue very fast :P

marsh mesa
#

is there any specific order in which OverlapCircleAll puts the colliders inside of the array it returns?

#

is it like, completely random, or closest to furthest, or smth else entirely

rigid island
marsh mesa
#

so its arbitrary? good to know, thanks

wide terrace
#

I think that's only for 3d. 2D OverlapCircleAll docs say

The Colliders in the returned array are sorted in order of increasing Z coordinate.

rigid island
#

yeah pretty sure it mentiones it in the dos

#

oh thats 2D

#

wops

marsh mesa
#

right, should've checked the documentation first

rigid island
#

didnt know it was different for 2D.

wide terrace
#

Nor I, until this moment 😉

marsh mesa
#

why z specifically i wonder

rigid island
#

makes sense

#

Z is depth

#

in 2D (unity)

wide terrace
#

But I guess it would still be arbitrary within the same z coord 🤷

rigid island
#

tru

marsh mesa
#

yeah i know, i guess thats a way to make it carry additional info in 2D

rigid island
#

if they're all on Z of 0 how do you know which one is closest to origin

lament island
#

I'm having an issue when trying to display a multi type list in the inspector where I retrieve a serialized reference to the list. The issue is that when i was using serializefield, the data was displaying on my custom inspector fine but now that I'm using serializereference, the data for each propertydrawer doesn't show up when pushed to the property is passed to my inspector GUI. Is there something I can do? I'll post the code here in a bit but has anyone come across an issue like this?

obtuse relic
#

I have been losing my mind over creating a screenshot system and I can not find anything helpful online.

This is supposed to enable a secondary camera, cam, that applies what it sees to a Texture. The main camera SHOULD continue rendering like normal while all of this goes on.
When the main camera is at a higher priority than the screenshot camera, the main camera's view is applied to the texture and the screenshot camera is ignored. If I have them at the same priority then the screenshot camera takes over and the screen obnoxiously flickers between the two cameras.

Is it possible to have the screenshot camera take a snapshot of its view without interrupting the main camera?

private IEnumerator TakeSnapshot() {

        yield return new WaitForSeconds(0.0625f);

        cam.enabled = true;
        
        yield return new WaitForEndOfFrame();

        var currentRT = RenderTexture.active;

        RenderTexture.active = cam.targetTexture;
        cam.Render();

        var rect = cam.pixelRect;
        int w = Mathf.RoundToInt(rect.width), h = Mathf.RoundToInt(rect.height);
        int trueSize = Mathf.RoundToInt(h * 0.75f);
        Texture2D snapshot = new Texture2D(trueSize, trueSize, TextureFormat.RGBA32, 0, false);
        int startX = (w - trueSize) / 2;
        int startY = (h - trueSize) / 2;
        snapshot.ReadPixels(new Rect(startX, startY, trueSize, trueSize), 0, 0);
        snapshot.Apply();

        int halfSize = Mathf.RoundToInt(trueSize * 0.5f);
        snapshot = GPUTextureScaler.Scaled(snapshot, halfSize, halfSize);

        OnScreenshot?.Invoke(this, new ScreenshotEventArgs { screenshot = snapshot });

        RenderTexture.active = currentRT;

        cam.enabled = false;
    }```
deep oyster
#

Thanks, using circlecast to detect angle is easier than the hack way I was doing lol. Can you explain the second part again about detecting corners?

dark sparrow
#

Saving and loading player data in a multiplayer game, I want to save from the server and load from the client, any advice from experienced people ? I used to use sql in a www request, any better options ?

sonic bone
# obtuse relic I have been losing my mind over creating a screenshot system and I can not find ...

you can do it more simply like this

void SaveCameraView(Camera cam)
{
    RenderTexture screenTexture = new RenderTexture(Screen.width, Screen.height, 16);
    cam.targetTexture = screenTexture;
    RenderTexture.active = screenTexture;
    cam.Render();

    Texture2D renderedTexture = new Texture2D(Screen.width, Screen.height);
    renderedTexture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
    RenderTexture.active = null;

    byte[] byteArray = renderedTexture.EncodeToPNG();
    System.IO.File.WriteAllBytes(Application.dataPath + "/cameracapture.png", byteArray);
}
cosmic rain
spark stirrup
#

What could be causing this? it shouldn't be my movement script, i've tried 2 of them and they both do this:

lean sail
spark stirrup
lean sail
#

I could take a wild guess and say its the movement script, because thats the only script im aware of here

spark stirrup
#

I can provide my movement script if you'd like (the problem is the slight camera jitter)

rigid island
#

it looks like a mistmatch between how you turn the camera vs how you move

spark stirrup
#

The terrain camera has it's rendering off, it's just something required by the asset I downloaded

spark stirrup
rigid island
#

idk ur mixing MovePosition with addforce which is already sus

#

also rotating in Update with a rigidbody

#

should show the setup for player, like the inspector n colliders. is camera child of player?

spark stirrup
rigid island
#

why is the Z -8 units away from the center

#

and X on 5

spark stirrup
#

Thats what it automatically set it as because my player is a cylinder with a box collider

vagrant hawk
#

Hey um I had an error trying to build a vr game can anyone help?

rigid island
spark stirrup
rigid island
#

I see

#

i think i know whats happening

spark stirrup
#

whats your idea

rigid island
#

is it just when you are moving or when standing still and rotating?

spark stirrup
#

its only when moving/falling

rigid island
#

did you try moving with AddForce / Velocity instead of MovePosition

#

I think collision/gravity might be fighting each other with the moveposition

spark stirrup
#

Yes, that's what I tried initially

rigid island
#

btw besides Impulse , any interactions with rigidbody should be done in FixedUpdate

#

that includes rotation

spark stirrup
#

I know, I should probably move it into there, but i tried that a little bit and that was still causing it

rigid island
#

idk do you really need it to be a rigidbody ?

#

why not just use a simple character controller

#

this is hella wrong btw mouseSensitivity * Time.deltaTime;

#

never apply time.deltaTime to MouseInputs

#

mouse is already framerate-independent

spark stirrup
#

I don't think I need it to be a rigidbody, I could probably change it

rigid island
#

pretty much plug n play with a few tweaks

#

what you have already should work, i would just try it with a cc instead. Replace the rb.AddForce with cc.Move

rigid island
rigid island
rigid island
#

the code is bad but i dont see why it would crash unity

#

many things wrong

#

did you see the first link i sent, cc should be moved in Update just fine so move all that back to update if you use cc

#

jump is wrong

spark stirrup
#

I'll try the other one

rigid island
#

cc.Move(cc.transform.position + transform.TransformDirection(moveAmount) * Time.fixedDeltaTime);
can just be
cc.Move(transform.TransformDirection(moveAmount) * moveSpeed * Time.deltaTime)

spark stirrup
rigid island
#

well now ur using a third person movement style also no need to put in LateUpdate for camera, update should be fine since cc moves in Update and its parented

knotty sun
runic swift
#

how can i update it?

#

in real time

#

i tried refresh in unity didnt work

#

reimporting is very annoying

#

just to change stuff

knotty sun
#

remove the component and then add it back

runic swift
#

thats the only fix?

knotty sun
#

yes

runic swift
#

thanks !

leaden solstice
knotty sun
runic swift
#

can someone help me remove this thing from rider its so annoying

#

the yellow lines under

leaden solstice
#

What does it say

runic swift
wide terrace
#

Ah that's actually super nice

runic swift
#

first time using rider

#

btw

#

came from vscode

leaden solstice
wide terrace
#

Multiply your floats in paranthesis before multiplying them with the vector

leaden solstice
# runic swift

Well it wants you to multiply speed and deltaTime first.. then vector

#

But you can turn it off

runic swift
#

its good for optimizing it seems

runic swift
lean sail
#

does rider not have a quick action which will refactor this for you?

quartz folio
#

yes you should be able to alt-enter and fix it

leaden solstice
#

Options are there if you press lightbulb

quartz folio
#

There is no reason to turn this one off, you should just fix your code. However you can turn the severity down if you want

runic swift
#

its kinda hard

quartz folio
#

just alt enter and fix it?

runic swift
#

i did

#

nothing happens

leaden solstice
#

Mine is ctrl+.

#

Different per what keymap you use

spark stirrup
quartz folio
runic swift
#

fixed it

#

thanks

hard estuary
unique flower
#

i was doing this thing and now unity is creating a work space for 8 min

gray mural
#

When checking for the current KeyCode inside of the Editor.OnSceneGUI method in a custom Editor, pressing Control only renders after making a change, e.g. moving the scene around.
Is there any way to force it to render when I need to?

Debug.Log($"{Event.current.keyCode}; this: {target.name};");
#

SceneView.RepaintAll() does not seem to work

#

Alright, my bad. I was checking for Control, Event.current.modifiers should be used

#

Although, I'm not sure why keyCode displays as Control after changes made, if it should refer to modifiers

daring cove
#

Hey,

How to get the image that the current camera rendered and how access a given pixel in it?

sonic bone
gray mural
daring cove
daring cove
#

I dont need the depth buffer I need the color buffer

sonic bone
daring cove
#

Hmm, I'm not looking to take a screenshot I'm looking to detect a moving object via image contrast.

sonic bone
#

My bad

#

So basically you want a color buffer of whatever the camera is rendering.

daring cove
#

Exactly that

gray mural
daring cove
#

Texture2D.ReadPixels seems like its what im looking for.
But is there a way to copy a small sample only
a 256x256 sample of the screen grab

#

definitely don't need a Full HD or 4K image for this

knotty sun
#

then you can sample a block of the array

daring cove
#

Hmm, I still need to call ReadPixels to get the data to copy from

knotty sun
#

or just itterate over the RawData array

daring cove
#

In the documentation sample they are taking the pixels from a material on a gameobject
I need the pixels from the screen.

        var texture = new Texture2D(128, 128, TextureFormat.RGBA32, false);
        GetComponent<Renderer>().material.mainTexture = texture;

        // RGBA32 texture format data layout exactly matches Color32 struct
        var data = texture.GetRawTextureData<Color32>();
knotty sun
daring cove
#
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
    Texture2D frame = new Texture2D(256, 256, TextureFormat.RGBA32, false);
}

How would I go about copying the render texture in to the Texture2D?
src contains no method called GetRawTextureData

knotty sun
#

Did you even bother looking at the RenderTexture documentation

daring cove
#
        private void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            RenderTexture prev = RenderTexture.active;

            RenderTexture.active = src;

            Texture2D tex = new Texture2D(256, 256, TextureFormat.RGBA32, false);
            byte[] data = tex.GetRawTextureData();

            RenderTexture.active = prev;
        }
gray mural
#

In a custom Editor, is there any way to "focus" on it, so that most Unity shortcuts are ignored? For example, E shouldn't focus on Rotate Tool, and Shift + D shouldn't close the Inspector.

daring cove
#

Now I assume that when I call tex.GetRawTextureData
it gets the raw pixels values from the src RenderTexture

knotty sun
#

How do you figure that? There is absolutely no relationship between tex and src

daring cove
#

If I do

tex.ReadPixels(new Rect(0, 0, src.width, src.height), 0, 0);

Its gonna copy the whole color buffer and I'm going to copy way too much data off the GPU

#

And all that is gonna get garbage collected after. So its gonna be mega expensive

#

Dont exactly know what you mean GetRawTextureData returning a pointer to an byte array
That method returns a NativeArray<Color32> in this use case

swift falcon
#

I am having trouble doing this recoil thing:

    private void Update()
    {
        //Other code...

        //Need to somehow lerp the code below, here, since Lerp needs to be called constantly
    }
    public void DoRecoil()
    {
        //Other code...

        //xRot & yRot are the cameras mouse inputs [---> (Input.GetAxis("Mouse X/Y") <---]

        cam.xRot -= Random.Range(minXRecoil, maxXRecoil);
        cam.yRot -= Random.Range(min_YRecoil, max_YRecoil);
    }

I need to lerp the camera recoil, because it looks too rough and snappy without it obviously
I am not changing the camera rotation directly, because either the player cant move the camera, or theres strange tilts, so im doing recoil by manipulating the camera's mouse inputs, this seems to be a good approach

But I cant just Lerp(camera mouse input, recoiled mouse input value, speed) because that will force the camera to always look at the recoiled position, AKA cant move the camera freely

I dont know what to do at this point

daring cove
# knotty sun How do you figure that? There is absolutely no relationship between tex and src

Heres the whole method with comments explaining what I assume its doing

        private void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            // backup previous render texture
            RenderTexture prev = RenderTexture.active;
            // set "src" RenderTexture as current RenderTexture
            RenderTexture.active = src;
            // Create sample texture 256x256
            Texture2D tex = new Texture2D(256, 256, TextureFormat.RGBA32, false);
            // Texture2d.ReadPixels reads from RenderTexture.active and copies from GPU
            tex.ReadPixels(new Rect(0, 0, src.width, src.height), 0, 0, false);
            // restore previous RenderTexture
            RenderTexture.active = prev;

            // Get raw pixels values from CPU
            NativeArray<Color32> data = tex.GetRawTextureData<Color32>();

            // dstOffset??? count??? how to use these?
            Buffer.BlockCopy(data, 0 << 2, data, 3 << 2, 4 << 2);
            // data is now ready
            // ... do stuff
        }
cosmic rain
daring cove
cosmic rain
daring cove
cosmic rain
cosmic rain
daring cove
cosmic rain
#

I don't see them doing anything with colors though.
And the intention of your code is still not clear

daring cove
cosmic rain
#

What are you gonna do with that data. Can't you use the tex after ReadPixels as is?

daring cove
#

Thats why I am a bit confused.
I asked if I can sample a smaller part of the image so that I wouldn't need to copy whole image.
For the image contrast I just need a low resolution version of it.

#

Just a 256x256 sample of the whole source RenderTexture

cosmic rain
#

If you want a smaller version of the render texture, you'll need to downsample it.

#

If you want to sample a smaller region from the whole texture, then ReadPixels would work

daring cove
#

Yes, how to do that though?
because this copies whole screen

tex.ReadPixels(new Rect(0, 0, src.width, src.height), 0, 0, false);
cosmic rain
#

use the width and height that you want to sample.

daring cove
#
tex.ReadPixels(new Rect(704, 284, 256, 256));

would copy a 256x256 sample from the center of a 1920x1080 screen

cosmic rain
#

Yeah, something like that

daring cove
#

I could make a ScreenManager of some kind and copy the whole screen every frame and store in a Texture2D and then sample it later

#

But I don't know how ReadPixels works. If I am sampling a 1920x1080 area in to a 256x256 texture 2D is it automatically gonna downsample?

cosmic rain
#

No, it shouldn't downsample from what I understand.
But you said here that it does? Or is that not what you meant??

because this copies whole screen
daring cove
#

I meant I only need to downsample the whole screen in to a 256x256 texture without copying the entire screen

cosmic rain
#

The whole screen resized to 256? or a 256 part of the screen?

daring cove
#

whole screen resized to 256

cosmic rain
#

As I said multiple times already

daring cove
#

I dont want to transfer the whole screen from the GPU that will take ages is there a way to sample into a 256x256 directly?

#

Problem I have is not wheter if its possible to downsize it, no.
Its getting only the amount of data that is necessary

cosmic rain
#
  1. I think you exaggerate about "ages".
  2. If you really want to, you can down sample the texture to a 256 texture using a copy shader, and then read the downsampled texture.
cosmic rain
#

I'm pretty sure the "slow" here is not even the amount of data, but just the fact of copying. It shouldn't matter much for a modern hardware to copy 1mb vs 100mb of data from the GPU as long as it's done in one operation.

spark osprey
#

Hello can anyone help me with unity editor download

#

I am getting the problem of install failed validation failed can help me

daring cove
cosmic rain
daring cove
#

So if I store a reference in the class as a field the massive buffer wont get garbage collected?

knotty sun
cosmic rain
daring cove
knotty sun
narrow crater
#

hey was looking for some advice. im trying to build a pc/vr game and i wanted to have a check box to enable and disable vr. everything ive found looking online has been very general and niche.

sonic bone
#

@daring cove bro I don't think this server is to spoonfeed you answers rather help you solve the problem. Also my advice is to listen to @knotty sun He has helped me many times in the past and trust me it helps in the long run.

cosmic rain
narrow crater
#

supposedly its possible.
i found this script while looking through some forms

#

`XRPluginManagementSettings.cs
using System;
using UnityEditor;
using UnityEditor.XR.Management;
using UnityEditor.XR.Management.Metadata;
using UnityEngine;

namespace FrameSynthesis.XR
{
// ref. https://docs.unity3d.com/Packages/com.unity.xr.management@4.1/manual/EndUser.html
public static class XRPluginManagementSettings
{
public enum Plugin
{
OpenXR,
Oculus,
OpenVR
}

    public static void EnablePlugin(BuildTargetGroup buildTargetGroup, Plugin plugin)
    {
        var buildTargetSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);
        var pluginsSettings = buildTargetSettings.AssignedSettings;
        var success = XRPackageMetadataStore.AssignLoader(pluginsSettings, GetLoaderName(plugin), buildTargetGroup);
        if (success)
        {
            Debug.Log($"XR Plug-in Management: Enabled {plugin} plugin on {buildTargetGroup}");
        }
    }

    public static void DisablePlugin(BuildTargetGroup buildTargetGroup, Plugin plugin)
    {
        var buildTargetSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);
        var pluginsSettings = buildTargetSettings.AssignedSettings;
        var success = XRPackageMetadataStore.RemoveLoader(pluginsSettings, GetLoaderName(plugin), buildTargetGroup);
        if (success)
        {
            Debug.Log($"XR Plug-in Management: Disabled {plugin} plugin on {buildTargetGroup}");
        }
    }

    static string GetLoaderName(Plugin plugin) => plugin switch
    {
        Plugin.OpenXR => "UnityEngine.XR.OpenXR.OpenXRLoader",
        Plugin.Oculus => "Unity.XR.Oculus.OculusLoader",
        Plugin.OpenVR => "Unity.XR.OpenVR.OpenVRLoader",
        _ => throw new NotImplementedException()
    };
}

}
`

#

but im not sure how to implement it. like do i have both the main cam and the xr rig in the same place? do i put it on a button or a toggle? stuff like that lol. im willing to learn but this just feels very hidden away lol

knotty sun
knotty sun
tawny elkBOT
narrow crater
#

wait so if i wanted to make it to where pc players and vr players can play together, is that not possible?

narrow crater
knotty sun
cosmic rain
knotty sun
narrow crater
# knotty sun this is VERY non trivial

is it cool if i keep coming back for advice? im still pretty new to unity. but i have a lot of experince in other lanuages. this is just my first attempt at somthing a little more pro LOL

knotty sun
serene stag
narrow crater
knotty sun
narrow crater
#

so if i could get some idea of where i need to be looking for some idea on how to make the builds and where to do so?

narrow crater
#

wait so that means i have to make two .exe files of my game? one with vr and one without?

narrow crater
#

so would it be best to seperate it into 2 projects?

#

in your opinion

cosmic rain
narrow crater
cosmic rain
knotty sun
narrow crater
cosmic rain
#

Maybe start with a non vr game then

narrow crater
#

ive had this in the idea stage for way too long and ive finnaly had the motivation to just do it.

cosmic rain
narrow crater
rotund burrow
#

Hi. in 3D, what's the best way to make a wall check? I will need wall normal (slope). Is there a better way then casting rays?

cosmic rain
rotund burrow
cosmic rain
#

Why do you need the normal on exit?

#

I don't think you should be using the normal to identify the wall anyway

rotund burrow
#

well i could do a separate layer for walls

#

but then there could be problems if we're colliding with a non plane object

#

cause the normal can change

cosmic rain
#

Layer, tag or object comparison

#

Unless your whole level is one mesh

knotty sun
rotund burrow
#

yeah i guess i will have to do that

marsh mesa
#

lel

#

yeah, i already figured it out! thanks tho

ionic meadow
#

I just want to confirm one thing:
are
transform.Translate(Vector3.up * speed * Time.deltaTime, Space.World)
and
transform.position += Vector3.up * speed * Time.deltaTime
the same?

I'm aware of Space.Self and Space.World, i just want to know if there's any other difference between directly setting an objects position vs using Translate in world space

gray mural
ionic meadow
#

ah yes, sorry

gray mural
# ionic meadow ah yes, sorry

You can have a look the Translate method. It uses position's set, when the world space is chosen

if (relativeTo == Space.World)
{
    position += translation;
}
else
{
    position += TransformDirection(translation);
}
ionic meadow
#

thanks!

gray mural
#

Is there any way to properly figure out what mouse button is pressed in the Editor?

Event.button describes which mouse button was pressed
0 means left mouse button, 1 means right mouse button, 2 means middle mouse button

I thought it would be better to make an enum out of it, but it's an integer.
So, perhaps, no mouse button pressed may be -1? No, it's 0 too.

According to Unity, checking for no button pressed should be done with

e.button == 0 && e.isMouse

But isMouse returns true not just when being held, but also when moved, which means e.isMouse being false doesn't necessarily mean no button is being held.

#

I wish Unity's Input system would be usable in the Editor instead of Events

gray mural
hexed pecan
gray mural
#

I suppose, I may consider changing a newly created variable by checking for MouseDown and MouseUp, but I wonder how accurate this is going to be, because these events may get lost when exiting the custom Editor

#

Alright, this seems fine

public enum MouseButton
{
    None,
    Left,
    Right,
    Middle
}

if (evt.type == EventType.MouseDown)
    _currButton = (MouseButton)(evt.button + 1);

else if (evt.type == EventType.MouseUp)
    _currButton = MouseButton.None;
ruby raft
#

is this smart or dumb

dense estuary
ruby raft
#

👍

dusky lake
# ruby raft is this smart or dumb

this works until you have other things that can have an effect on the movespeed like enemies slowing you, then you want to establish base vars for "movementSpeed", "runSpeed", etc, and recalculate the "currentSpeed" whenever something changes your movespeed, but for your case right now its perfectly fine

ruby raft
#

thanks!

thin hollow
#

I wonder if there's a better way to check if a list of objects have reference to a specific game object among them than doing a foreach with a bool?

  /// <summary>
  /// Force-add an object as a potential target
  /// </summary>
  /// <param name="quietly">new target won't have maxed out freshness</param>
  public void InjectTarget(DynamicObject actor, bool quietly = false)
  {
      if (actor == null) return;

      bool contains = false;
      foreach (AITargetObjectReference knownActor in potentialTargets)
      {
          if (knownActor.reference == actor)
          {
              contains = true;
              break;
          }
      }
      if (!contains)
      {
          AITargetObjectReference item = new(actor, quietly?5:11);
          potentialTargets.Add(item);
      }
  }
somber nacelle
#

list.Contains

#

or rather list.Any would be more appropriate since you're checking a field on objects in your list

dense estuary
#

I am currently trying to make sort of worm procedural animation. But I have an issue where instead of the objects following each other, they seem to be swapping sides of the main part. https://hastebin.com/share/wodumihodu.csharp. Here is a video of the issue: https://streamable.com/pa18e6

Watch "Replay 2024-07-14 15-43-28" on Streamable.

▶ Play video
thin hollow
# somber nacelle list.Contains

The problem is that the list if of AITargetObjectReference, a class containing relevant information about potential targets AI can sense (see or hear), while I want to check if any of those targets points to a specific DynamicObject component of a GameObject.

somber nacelle
#

read literally the next message i sent

#

of course any of those methods would just loop over the list anyway so it's really up to you whether you actually change it

torn pendant
#
from pyngrok import ngrok

port = 5004
ngrok.set_auth_token("my ngrok auth token")
public_url = ngrok.connect(port)
print(f"Public URL: {public_url}")

!mlagents-learn --force``` anyone know why this doesn't work or should I use something else, I'm trying to use mlagents in google colab. I have all dependencies installed
torn pendant
#

yeah but does anyone know

dense estuary
dense estuary
thin hollow
# somber nacelle read literally the *next* message i sent

Ah, sorry. How do I use it, exactly? Something like this? I've found this whole "from where" structure in Ms docs about .Any, but I'm unsure how .Any is useful in this situation, seems like it should return, well, "any" non-empty reference?

contains = (from knownActor in potentialTargets where knownActor.reference == actor select knownActor.reference) != null;
somber nacelle
#

did you look at the docs for the method?

thin hollow
somber nacelle
#

yes

thin hollow
#

Well it does says that it only checks if the element exists, not whether it matches anything specific.

true if the source sequence contains any elements; otherwise, false.

somber nacelle
#

if only there were more than one overload. since the scroll wheel doesn't exist we'll never know if that is the case

ebon leaf
#

how can I have multiple colliders in a gameobject or in seperate children gameobjects and detect seperate collisions to do seperate tasks like a left side collider, rightside collider, etc

rigid island
#

just use physics queries

#

maybe use colliders just to set their sizes, depending what you're doing with them

#

You could potentially put them on different gameobjects, and use same script with an enum to tell which side you are calling from, but thats way more work than just using physics queries

ebon leaf
rigid island
#

nahh

#

use stuff in the Physics class

#

like Physics.SphereCast etc

#

you can also do raycasts but they're thin so it depends what ur doing

ebon leaf
rigid island
#

yea those are physics queries

#

overlap though doesn't give certain info casts do , like Raycast hit

#

just collider, if thats ok with you then yeah overlap works

ebon leaf
#

yea overlap doesnt really give info i was gonna ask about that

#

so like something like sphere cast

#

would i be able to see it in unity real time

#

kinda like how i can see a box collider's collision area and edit it in the editor not just in code

rigid island
#

you can see it in realtime yes

rigid island
hexed pecan
ebon leaf
hexed pecan
#

It's not something you give a name to

ebon leaf
hexed pecan
#

OverlapCollider is not an object, it's a function you call

ebon leaf
hexed pecan
#

Which I thought was your initial question

hexed pecan
ebon leaf
#

bet bet, thx alot 👍

hexed pecan
#

Since you are working in 2D it is slightly different

#

OnCollisionEnter2D>Collision2D>collider/otherCollider

#

I think otherCollider is the "self" collider 🤔 I just remember the naming being a bit misleading in 2D

ebon leaf
#

im not to good at finding what im looking for in the documentation but i found this while looking for it and it doesnt feel like using the other.gameobject identitfy which collider has been hit

hexed pecan
#

That is OnTriggerEnter2D

topaz sapphire
#

Hey fellas, whats more optimal for a tank like set up (multiple weapons at different points on the player)?
A single script that flags when to fire attatched to the main object, finding each weapon within holders? OR
Many scripts looking for flags under the input script that handle everything?

ebon leaf
hexed pecan
#

With triggers there is really no way to identify which self collider was hit unless they are on separate objects with separate components that has OnTriggerEnter
And if the colliders share the same rigidbody then I think the message ks sent to the rigidbody object, not the collider

#

What is the functionality you are trying to make here?

topaz sapphire
grim bay
#

Hello, i am doing an constant checking on my player's state and change it's animation based on the current state it's in. However i feel very insecure and feel (i am sure) that this code is bad, could someone tell me how to improve?

https://gdl.space/setadiwobo.cs

topaz sapphire
ebon leaf
grim bay
#

I can try to send in another link, wait

topaz sapphire
#

charactercontroller.isgrounded :DDDD

topaz sapphire
wide terrace
simple egret
#

gdl.space is safe.

hexed pecan
wide terrace
ebon leaf
grim bay
#

I'm looking for another site

simple egret
#

No you're good, the one you have is fine

hexed pecan
grim bay
ebon leaf
neon pine
#

Hello, can you send me a code to open and close the door in my Unity game by pressing the E key?

topaz sapphire
hexed pecan
ebon leaf
hexed pecan
#

And then calling OverlapCollider with each collider as a parameter (separately)

ebon leaf
#

that could work

#

ill try that out and let you know how it goes 🙂

#

thx again

neon pine
#

ok ty

topaz sapphire
#

dawg dont let him figure it out himself

rigid island
simple egret
dense estuary
simple egret
#

They will most likely just copy-paste the thing without reading it, and return complaining that "it doesn't work" because their object setup is different.
That is usually why we don't do handouts like these, but help with existing code instead

topaz sapphire
#

hands on learnign is the best

rigid island
#

no need to spam a big ass message when you can use pastelink websites..

simple egret
#

And yeah chatgpt code is even less ideal lol

topaz sapphire
#

by every study

grim bay
rigid island
#

just giving someone the whole code goes against the philosophy of the server..

simple egret
#

For a reason... it's decompiled/ripped, isn't it

topaz sapphire
#

how about you just dont post it?
the dude joined to ask for code, not programming a thing as if were just an AI tool for him to use
I dont think anyone like that deserves any help

grim bay
#

Won't happen again sadok

topaz sapphire
#

too much love'll killa ya

#

this isnt optimal is it?

#

any better alternatives?

#

its a general use case for multi flag case for a tank

rigid island
#

use an array

primal raptor
#

Hello I am making aparty game similar to mario party, in the game each round being a random map, a random gamemode and a random modifier

#

Does anyone know a tutorial or any documentation to make this system work?

topaz sapphire
rigid island
#

you have to learn how to break down these systems and build them yourself

grim bay
primal raptor
rigid island
wide terrace
# topaz sapphire oh fr?

fr. Now if I want to make a suggestion that you should change something in that code, I either have to very verbosely describe the change and where to apply it, or create an example by manually transcribing all of the relevant code in the image by hand. If I want to test some portion of your code myself, then I must type it all out.

Demonstrating like a contextual error message with an image makes sense. But sharing code that way is just an unnecessary obstacle for anyone who might want to address the issue... In this specific case, it also means interested parties must grapple with a wacky non-monospace font 😅

topaz sapphire
wide terrace
topaz sapphire
#

if you aint progamming in the terraria font you aint progamming good

soft shard
# primal raptor Hello I am making aparty game similar to mario party, in the game each round bei...

If this is a multiplayer thing, depending on how you store your data for maps, game modes, modifiers etc, you could give them an ID such as through a database or a persistent ScriptableObject list that does not change between clients, the host could randomize the index selection and send those indexies over the network - thats one solution that comes to mind, but it would also assume your data can be stored in a list/database structure

primal raptor
runic island
#

I've got a strange bug that I can't seem to figure out.

I'm making my own player movement script, and everything works fine, including that if I hold space, my character automatically jumps when they hit the floor again. (As intended).

What's not intended is that occasionally my player jumps 2-3x as high as other times while I hold spacebar. It's incredibly inconsistent. Any ideas?

Here's my script so far: https://pastebin.com/geNJDwMC

lean sail
topaz sapphire
#

yeah

primal raptor
topaz sapphire
#

add a cooldown to jumping

#

even if it is .1 seconds @runic island

rigid island
#

if you are just starting out start small

topaz sapphire
soft shard
lean sail
rigid island
#

couch coop/vs will be ok. Networking you will struggle if you can't even start this system tbh

primal raptor
#

Thx alot

rigid island
#

but yeah def look into the new input system cause you can easily swap out controls scheme

topaz sapphire
#

yeah its a little more complicated but its worth it

lean sail
# primal raptor Ye this is the best idea rn

Debatable, depending on what the end goal is. It sounds like you arent even sure yourself.
You really wont have a good time trying to go from couch coop to online multiplayer.

#

You should define what you want first. Couch coop still isnt as simple as just singleplayer

topaz sapphire
primal raptor
lean sail
#

That's fine and all, I'm just saying you should define what you really want in it. Like is the end goal to be making multiplayer games?

#

If so, and you want this game to be multiplayer then you'll have to start with that immediately. Multiplayer is not something you consider after

primal raptor
#

Do know any simple tutorial for making a muliplayer game I can start with?

topaz sapphire
rigid island
#

simple and multiplayer don't go together lol

lean sail
#

And similarly there arent many tutorials because most of the youtubers cant do it themselves

ashen oyster
#

So I'm trying to path trace triangles, I'm currently having this weird issue where the side that should be casting shadows is not, and instead the reverse is true, how could this happen? I've tried reversing some normals, didn't work, just made the face unlit if it was lit from the correct side and had no influence on the shadows. If you need any specific code please tell me. I'm just first seeing if this is a common known issue haha

soft shard
primal raptor
#

Is it any good?

rigid island
lean sail
# primal raptor Is it any good?

havent tried it myself, i only used ngo. Im sure the concepts are similar but ngo is newer (i think). At least when i was trying it a few months ago it was being updated pretty frequently

lone bone
#

Unexpected GridLayout Behavior

soft shard
# primal raptor Is it any good?

I have used Photon and they are actually a suit of services, such as Photon Fusion, Photon Quantum, Photon Unity Networking (or PUN, which I assume is the one you are referring to) - I would say PUN is the "simplest" to work with when it comes to multiplayer, but its also technically "outdated" (still usable and has support just doesnt get updates like NGO, Fusion and other solutions), so its often suggested to use Fusion as the alternative to PUN specifically - also keep in mind with any multiplayer solution, you may need to buy a subscription to what is referred to as "CCU"s, being the max number of players that can connect and play your multiplayer game, for Photon they offer 20 CCU for free to test and develop with, then when you are ready to release you can upgrade to 100 CCU for a monthly fee, or more CCU for a monthly fee if needed, they also support something called a "burst" where you have a influx of more players than your plan supports temporarily (you can imagine if you released a big update for your game when the sever only supports 100 players, and the update brings in 130 players, you dont want to kick those 30 players out so you kind of allow them at a cost per-player that goes over 100, in this example youd be paying a few cents each for those 30 players, ontop of your monthly cost for the 100 subscription), not sure if "Burst" is specific to Photon though, havnt used NGO myself

normal ingot
#

can somone explain why unity exports like this? meta developer hub is not uploading it and keeps throwing api errors.

oblique spoke
normal ingot
#

ive never seen that

#

where is monobleedingedge

rigid island
#

D3D12 is prob for direct X 12

normal ingot
cosmic rain
normal ingot
lean sail
#

did you export using IL2CPP?

normal ingot
lean sail
#

check the scripting backend

normal ingot
lean sail
#

then yea u arent gonna have a MonoBleedingEdge if you dont use Mono

cosmic rain
normal ingot
#

ill try

silent tapir
#

How would I rotate a ui element like an image, with a text in it, but the text always stays at 0 degrees instead of rotating with the image (thats what I want) how could I do that?

rigid island
next quiver
#

i have a canvas based menu in my game. the items in the menu are represented as images that I can move around with mouse click. When I import the menu to start working in the game, the image no longer moves around with the mouse. No reference or errors of any sort. Wanted to see if anybody knows whats going on in case its a common issue. Already checked sorting layers and canvas render modes

silent tapir
silent tapir
rigid island
#

I never said detach it from inventory item

#

do you know what having a common parent means?

mental solar
#

Returning to this.
If anybody wants to migrate their OnMouse... events with 2D colliders to the new Input System, this should be "enough":
https://pastebin.com/kxbCCn7q
rename void OnMouse...() to public void OnRaycastMouse...() and inherit from the interface, then call UpdateMouseInput(); once per frame in some singleton.
It's horrible but it does the job.

#

felt rude to me to essentially solve the problem but not give away the solution

somber nacelle
#

but that's not even necessary when you can just use the already existing interfaces from the EventSystem. all that requires is the EventSystem in the scene and a PhysicsRaycaster2D on the camera

mental solar
#

the game has overlapping canvases which were "eating" the raycasts so I had to do it myself

#

the Unity's eventsystem + physicsraycaster2d might work if you don't do funky stuff with multiple canvases + depth in a single scene, but if you want the real "og" legacy raycast behavior - you must resort to Physics2D.GetRayIntersection for some unknown reason

dense estuary
somber nacelle
mental solar
# somber nacelle that sounds like something you should report as a bug tbh

perhaps, but in that conversation we ultimately decided that the OnMouse messages do some cursed eldritch legacy stuff that nobody knows how it works, and the new eventsystem + physicsraycaster setup just didn't work with the way this game handles canvases and cameras. so my goal was to replicate this legacy behavior somehow

#

and that worked, lol

quartz folio
quartz folio
#
- parent.GetChild(i).transform.position = transform.position + (direction * -radius);
+ parent.GetChild(i).transform.position = parent.GetChild(i - 1).transform.position + (direction * -radius);
dense estuary
quartz folio
#

it would help if you cached the transforms within the loop if you access them multiple times. It's much easier when you name things Transform thisChild = parent.GetChild(i); and Transform previousChild = parent.GetChild(i - 1); for example. Makes it easier to spot things out of place

simple saffron
#

Trying to build something similar to CS2s reactive smoke, and I'm starting with just getting voxel smoke working, but I'm finding that using 3D textures isn't very performant. Are there any other methods I should look into?

#

I feel I should also say that I do not know how to write shaders myself at all, and if this kinda thing is going to be impossible to do without shaders doing the heavy lifting, at least for the generation of the smoke (not the rendering, I'm happy to compromise on the actual rendering), then pls let me know that

raven orbit
#

how do i improve my code without tutorials, i havent really gotten on unity much ive made three simple scripts in total but i want to change that

raven orbit
#

thank you!

hot ledge
#

Is there any way to use #pragma surface surf StandardDefaultGI and #pragma surface surf Lambert vertex:vert together?

lofty field
#

The following snip of script works with the 4 separate buttons.. but I want to use one button a + to use instead of four buttons just be able to press on the particular area of the + do do the same up down left right functions. i want the blank one to be normal state and the rest are up down.. etc... Any suggestions how to do this?

`// Button states
private bool leftButtonPressed;
private bool rightButtonPressed;
private bool jumpButtonPressed;
private bool downButtonPressed;

public Button LeftButton;
public Button RightButton;
public Button JumpButton;
public Button DownButton;

private void Awake()
{
camera = Camera.main;
rigidbody = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();

// Set up button listeners with EventTriggers
AddEventTrigger(LeftButton, () => leftButtonPressed = true, EventTriggerType.PointerDown);
AddEventTrigger(LeftButton, () => leftButtonPressed = false, EventTriggerType.PointerUp);
AddEventTrigger(RightButton, () => rightButtonPressed = true, EventTriggerType.PointerDown);
AddEventTrigger(RightButton, () => rightButtonPressed = false, EventTriggerType.PointerUp);
AddEventTrigger(JumpButton, () => jumpButtonPressed = true, EventTriggerType.PointerDown);
AddEventTrigger(JumpButton, () => jumpButtonPressed = false, EventTriggerType.PointerUp);
AddEventTrigger(DownButton, () => downButtonPressed = true, EventTriggerType.PointerDown);
AddEventTrigger(DownButton, () => downButtonPressed = false, EventTriggerType.PointerUp);

}`

#

didnt realize the images would show up so large

neon yarrow
#

Learning some dots and going over some open source code for reference.

I see method ending with the following

if(aNativeList.IsCreated)
  return;

What is the purpose of this? My understanding is that IsCreated here is only checking for memory allocation. Is this some sort of fail-safe to garbage collection?

Context: aNativeList is a parameter being passed to a static function.

lofty field
tepid charm
#

is this too high? I've read it shouldn't be higher than like 10-20

tidal nebula
#

Hello can some one help in monetization actuall i cant put ads in my game i tried all ways possible i saw documentations videos etc but still couldnt do it if someone has done it before plz help me DM me thankyou !

lofty field
tidal nebula
#

that is a great idea but all together i cant add any ad in my game

lofty field
#

google mobile ads, but i havent done it myself

tidal nebula
#

i followed all tutorials got the ad button screen but the ad never started nor were showed on the unity dashboard

lofty field
tidal nebula
lofty field
cosmic rain
tepid charm
#

it's from the VS code metrics

cosmic rain
#

Worrying in what sense?

tepid charm
#

well idk it just seems extremely high compared to what it "should" be, but this project isn't very big and it's pretty easy to maintain for me atm

lofty field
tepid charm
#

but I'm seeing that anything above 50 is supposed to be like extremely urgent critical danger type stuff

cosmic rain
tepid charm
#

well it's general maintainability I guess?

tidal nebula
tepid charm
#

but alright, I just wanted to know if this is something to watch out for

lofty field
tepid charm
#

thanks

cosmic rain
tepid charm
#

ok yeah should be fine then

tepid charm
lofty field
tepid charm
#

idk not that many

#

it's a bit over 5000 lines in total atm

cosmic rain
#

That's quite a lot for a C# script imho

tepid charm
#

no no the entire solution

#

I've got like 60-70 scripts or smth I haven't counted

lofty field
tepid charm
#

not really

#

I mean a lot of it is still being built out and not properly refactored but that's fine

lofty field
tepid charm
#

VS code metrics

cosmic rain
tepid charm
#

oh so that's how it works?

#

I see

#

it's just that there's no option to calculate it for a single class or whatever

cosmic rain
#

It defines the amount of paths in your code. Obviously, the more code you have, the more paths you will have.

tepid charm
#

yeahhh ok makes sense

#

I was just being dumb then lol

cosmic rain
#

Honestly, I don't think that metric is applicable to gamedev at all. Games would have complexity several levels higher than many other types of programs, so there's probably no point looking at that metric.

neon yarrow
#
World.GetOrCreateSystem<EndInitializationEntityCommandBufferSystem>();

Used to return a EntityCommandBufferSystem and now it returns a SystemHandle instead which does not appear to have a method to access the BufferSystem. How am I supposed to get access to it now?

For context, this is being called from SystemBase

spark stirrup
#

For some reason, if I try to break a block underneath myself the game thinks I immediately looked away from the block and stops breaking it:
https://gdl.space/iwezozepuy.java

lavish lance
#

can someone help me pleae

#

im making axe system

#

collider use ontriggerstay

#

how can i make sure tree i cut using axe doesnt get chop more than once

#

since i want time frame for when can cut tree

#

like if its 0.2, when i click there is 0,2 seconds of detecting tree

#

i fugered that out, just need help with not hiting same tree twice or more

sleek radish
#

I didn't find any answer on my questions: why managers in unity are bad/good? I've heard something like "Managers are actually good if you avoid creating god objects", can someone tell the truth?

lavish lance
#

scripts like GameManager, and UIManageR?

sleek radish
#

Yeah

lavish lance
#

also, what is a god object

sleek radish
#

I should've post it to code-beginner, but whatever

lavish lance
#

well

#

i think

#

u should use managers

#

it keeps code neat

#

for example

#

in a game with a menu, u want to be using like a UIManager

#

it keeps everything orgaised, and has all the references in 1 script

#

game managers are also good for handling things that dont really have a name

#

or have a name that doesnt describe itself well

cosmic rain
cosmic rain
sleek radish
cosmic rain
sleek radish
#

That's still doesn't answers my question: are managers actually bad?

wide dock
#

If you make them bad, they'll be bad, as simple as that

#

Managers exist to manage something

somber nacelle
#

there is no one size fits all answer to this. "managers" are just a tool, and like any other tool you must use the appropriate one to solve an issue. if you use a tool that is not appropriate for what you are doing then it can be "bad". so use the right tool to get the job done.

cosmic rain
sleek radish
#

Alright, thank y'all

lean sail
somber nacelle
#

don't crosspost. there are no collab posts allowed here (bot seems to be dead so it isn't linking the embed with links where you can post collab requests)

cold parrot
weak spruce
hexed pecan
#
        Vector2 spawnPosition = center + new Vector2(Random.Range(-xRange, xRange), Random.Range(-zRange, zRange));

You are using a Vector2 as the spawn position so it will only randomize X and Y

#

Don't you want X and Z?

#

So it would be Vector3(..., 0, ...)

weak spruce
#

i need only x and z positions not y

hexed pecan
#

Yes, and a Vector2 doesn't have a Z coordinate

#

The second parameter is Y

#

You should be using Vector3's all the way here

#

With the Y set to 0

weak spruce
#

i did it and it worked thanks!

loud rapids
#

hey, yesterday was the first time i've ever used classes in programming, so this is probably a stupid question, but i couldn't find anything online, so...
say you make a class and then make an instance of that class. how do you identify that class (to say, add it to a list, or change some of it's variables)?

vagrant blade
#

This is a #💻┃code-beginner question.

You store it in a variable like anything else.

MyClass myInstance = new MyClass();
myInstance.Health = 100;
MyList.Add (myInstance);
loud rapids
#

alright great, mb about the channel

versed loom
#

is there any othe way of doing a factory where u get a type and return a new class?

internal sealed class TestFactory
    {
        private static readonly Dictionary<Type, Type> typeMap = new()
        {
            { typeof(bool), typeof(BoolConstantField) },
            { typeof(float), typeof(FloatConstantField) }
        };
        
        public static VisualElement Create1<T>()
        {
            if (typeMap.TryGetValue(typeof(T), out Type fieldType))
                return (VisualElement)Activator.CreateInstance(fieldType);

            return null;
        }
        
        public static VisualElement Create2<T>()
        {
            if (typeof(T) == typeof(BoolConstantField))
                return new BoolConstantField();
            
            if (typeof(T) == typeof(FloatConstantField))
                return new FloatConstantField();
            
            return null;
        }
    }```
chilly surge
#

You can have a ConstantField<T> and Create<T> would use reflection to find a matching one.

#

It's all tradeoff though, with that approach you lose the explicit relationship.

versed loom
chilly surge
#

Loops through all classes and check each class to see if it's inherited from ConstantField<T>.

languid hound
#

Is there any way to have physics queries detect colliders they start in?

#

Oh
There's Physics.queriesHitBackfaces but it's not really what I want. I was kind of hoping for a way to do it on a singular raycast

delicate zinc
#

I'm working on a game that utilizes an Alternative Controller, we're using Tanks for the players to move around.

These tanks can only move and rotate, we do not have plans on making the turret itself rotate due to the limitations of the controller.

I've been trying to find a video or some source where i can understand/adapt how to make a realistic controller for this tank. The alternative controller has two switches, where one controls the left track and the other controls the right track. as such, i need to code a movement controller that works like how a tank moves (IE: Accelerating one track and going reverse ont he other causes the tank to rotate in place)

#

if anyone has any good videos that describes what i want i'd appreciate it. Keep in mind we do not want the player to use one stick to move forwards and backwards, and one stick to rotate in place, i already coded that but my supervisor said that wasnt what they needed

hexed pecan
languid hound
# hexed pecan You can use OverlapSphere with a small radius for this

This was an approach I was pretty happy with but would you have any suggestions for detecting when it's about to collide any sooner?
What I mean is the sphere was like 0.05 in radius so the spherecast was 0.049 (and then it got pushed back by 0.05)
The issue this created was you would be able to put the sphere in an object a tiny bit (by 0.001) and then it would teleport back by 0.001 to correct itself

#

My brain hasn't been on today I don't know what's going on

hexed pecan
#

I'm not exactly sure what you mean, what is the issue vs. the behaviour you want

#

Showing code would be helpful too

#

Do you want to calculate depenetration or not?

languid hound
#

I already have hold on

#

This is what I have so far

using System.Collections;
using System.Collections.Generic;
using UnityEditor.PackageManager;
using UnityEngine;

public class CollisionTest : MonoBehaviour
{
    public Transform target;
    private Vector3 lastPos;
    public float sphereRadius;
    public float precision;
    public LayerMask layersToCollideWith;

    void Start()
    {
        lastPos = transform.position;
    }

    void Update()
    {
        transform.position = target.position;

        Vector3 dir = transform.position - lastPos;
        float distance = dir.magnitude;

        if (distance > 0)
        {
            if (Physics.SphereCast(lastPos, precision, dir.normalized, out RaycastHit hitInfo, distance, layersToCollideWith))
            {
                transform.position = hitInfo.point + hitInfo.normal * sphereRadius;
            }
        }

        lastPos = transform.position;
    }
}

precision = 0.049f
sphereRadius = 0.05f

#

I'll get a vid of what I mean but a bit more exaggerated

languid hound
#

I was thinking I could maybe wrap the positioning SphereCast in a SphereCast that's the same radius as the sphere

#

I don't know if I explained that well

#

That didn't work

hexed pecan
#

I still fail to see what the issue is sorry

languid hound
#

If you look super closely you can see the sphere pentrating the cube a small bit then jumping back

gray mural
#

Hey, is there any way to recognise when Event.modifiers and Event.keyCode don't make sense, or do I have to check it on my own?
For example, it may return Control as a modifier and LeftControl as a key, so a key binding Control + LeftControl, which doesn't make sense. The same goes for Alt + RightAlt etc.

Also, I wonder why Windows is displayed as Command + LeftApple.

languid hound
#

Okay I don't think my approach is exactly perfect

#

I think I'm gonna have to rely less on a smaller SphereCast creating the friction and more creating it myself with something like ProjectOnPlane

spare island
#

usually when i see modifiers implemented into a keybinding system, they use a drop down for the modifier

#

though of course the trade-off of that is you can't stack modifiers like shift + ctrl

#

but unless you're making a sim game, if you need more than 1 modifier for all of the inputs in your game you probably should consolidate

gray mural
spare island
gray mural
hushed cloud
#

Is there any method in Unity that works like LookAt but allows us to specify which of the transform's axes to use in place of the forward axis?

hushed cloud
spare island
hushed cloud
#

Can't use another component for this

#

FromToRotation might be what I need

astral sky
#

Does physics really not have Spherecasts or Sphere overlaps?

#

Or am I missing something?

hexed pecan
#

Are you using Physics2D though?

astral sky
#

No, this is 3D

hexed pecan
hexed pecan
#

Maybe you are looking at Unity.Physics?

#

Yep

hushed cloud
hexed pecan
astral sky
#

There's a Collider cast, but that seems like... too generic? like using a mesh collider or something?

#

Yes

hexed pecan
#

I haven't used that Physics package yet but I think you would just pass in a SphereCollider as an argument, no?

#

For ColliderCast

versed marsh
#

Does anyone know if there is a way to disable to shortcut Ctrl+W? It closes the current window and its super annoying when making a first person game. The shortcut doesnt exist in the Shortcuts tab in unity either so i have no clue why it does that

astral sky
#

Hmmm Collider seems to be directly the type Collider instead of ICollider which SphereCollider implements, this is rather confusing, but I'm just looking through the manual right now

#

Maybe it's just that its this generic

hexed pecan
#

Yeah, but I'm not sure why you need it to be less generic

#

In regular unity the different casts all ultimately return a RaycastHit anyway

astral sky
#

By "generic" I mean that there's a single "collider cast" query instead of having a specialized spherecasting method

hexed pecan
#

I know what you mean

astral sky
#

Also since I'm talking about casting is there anything about camera casting? That's something I do use and I really don't see a comparison anywhere? Or I guess I can just manually convert the ScreenPointToRay Ray result to a Unity.Physics Ray?

#

What worries me is the physics though..

#

I guess I'd have to do two raycasts, one to get the ray from the screen point and another to get the hit in my physics world

#

Unless anybody knows better?

devout nimbus
#
private void Awake() {
        if (requiredItemType != ItemType.Any) {
            OnSlotUpdated = new UnityEvent<ItemType>();
            Debug.Log("Initializing event on slot");  <-- logs properly
        }
    }
 public void UpdateUISlot(InventorySlot slot) {
        Debug.Log("Updating ui slot");
        if (OnSlotUpdated != null) {
            OnSlotUpdated.Invoke(requiredItemType);
            Debug.Log("Event is invoked");  <-- logs properly
        }

//other script
private void Start() {
        inventorySlotUI.OnSlotUpdated.AddListener(EquipmentUpdated);
        if (inventorySlotUI.OnSlotUpdated.GetPersistentEventCount() > 0) Debug.Log("Added event successfully"); <--- doesnt log
    }

    private void EquipmentUpdated(ItemType type) {
        Debug.Log($"Equipment Slot changed for: {type}");  <-- doesnt log

The event is not being subscribed to
This was working before I switched scenes. I verified the reference im using the add a listener to the event is correct. I feel like im missing something obvious and just need a fresh pair of eyes.

hexed pecan
leaden ice
#

You know that listeners you add with AddListener are NOT persistent listeners, yes?

neon yarrow
devout nimbus
#

The other script attempts to see the persistent listeners in the start method

devout nimbus
leaden ice
leaden ice
devout nimbus
#

Got it thank you for that. The event is also being triggered and never unsubscribed as well

leaden ice
#

Or you are calling Invoke on the wrong instance

devout nimbus
#
        Debug.Log("Updating ui slot");
        if (OnSlotUpdated != null) {
            OnSlotUpdated.Invoke(requiredItemType);
            Debug.Log("Event is invoked");  <-- logs properly
        }```
i am calling it here, it is logging event is invoked as well
leaden ice
#

possibly it's being invoked on the wrong instance then

devout nimbus
#

The reference should be correct I have verified multiple times

leaden ice
#

how have you verified

devout nimbus
#

Dragging and dropping it by hand. Ill do it by code as well now

#

the scripts exist on the same gameobject

leaden ice
#

Here's a better way to verify @devout nimbus

 public void UpdateUISlot(InventorySlot slot) {
        Debug.Log("Invoking event on instance " + GetInstanceID());```
```cs
        inventorySlotUI.OnSlotUpdated.AddListener(EquipmentUpdated);
        Debug.Log("Added listener to instance " + inventorySlotUI.GetInstanceID());```
#

make sure the instance IDs are the same

devout nimbus
#

Thank you I will try that, busy atm but I will soon

devout nimbus
shell scarab
#

Any way to force unity to render at whatever resolution I want? I can't use dynamic resolution as a bug is affecting me where I can't have a custom full screen pass render feature enabled at the same time as the dynamic resolution not being at (1, 1).

silent tapir
#

why does it have a background?

shell scarab
shell scarab
#

try using ARGB32 or whatever it is. Also, you didn't answer how you're viewing that image

shell scarab
#

pretty sure that renders gray for invisible pixels

silent tapir
#

am I blind?

#

I don't see it

#

@shell scarab

shell scarab
#

no I think you're fine don't worry, i see it (named differently, I always forget the names of those color formats), but I think it's just that windows image viewer renders gray like that where there's invisible pixels. Like, what's it suppose to put there??

silent tapir
shell scarab
#

@silent tapir are you using HDRP or URP

shell scarab
#

in your render pipeline asset, what's your color buffer format set to?

#

@silent tapir

silent tapir
#

let me check

shell scarab
#

in that dropdown choose one that has alpha then try

shell scarab
silent tapir
#

still doesn't work tho

shell scarab
#

one more thing to try.

Set the color format of the render texture to R16G16B16A16_SFLOAT In the render settings, make sure depth texture is on. Set the camera to have a solid color, then set the alpha of that color to 0.

#

@silent tapir

#

if that doesn't work then I'm out of ideas, you may need to make a shader to remove the background.

spice swift
#

Anyone know of a way to "invert" the colliders for a 2d tilemap? I have tried adding a surrounding box collider 2d to my tilemap and then using a composite 2d collider with difference as the composite operation on both colliders but it does not seem to work at all when set to polygons mode rather than outline (the colliders just disappear in the scene view?)
SOLVED: I had to change the composite order of the Tilemap2d collider so that it was higher than my box collider

vale bridge
#

Struct packing exists, what about class packing? Is that a thing?

cosmic rain
thick dune
#

Hello fellow humans,

Perhaps you may be able and willing to assist in my issue. I am working on a function to zoom in or out on an image based on the center point of 2 fingers touching the screen on an android device.

I can set the pivot to the point between the fingers and adjust my gameObject's scale based on the distance between the fingers however, it seems that when I set the pivot through code, it also moves my gameObject's transform away from the enter of my canvas.

Do you know how to scale a gameObject on a canvas with the scaling based on certain coordinates without the gameObject actually moving around on the canvas?

Thank you for your time.

severe onyx
#

hey all, is there anyway to programmatically add new agentTypes for the NavMeshSurface component baking? I know I can define it using the editor, but i would like to programmatically create agentTypes so i can loop through and re-bake terrains during the runtime.

loud zenith
#

Hi all, I'm updating my iOS game and I think new updates require Apple Privacy Manifest file be present in the app.

I was reading the docs regarding this and I found that Unity adds a manifest file by itself. I've verified that the third-party plugins I use have also included their own manifest files. So my question is, should I also include my own manifest file now?

Suppose I'm using PlayerPrefs. Unity has already handled it in their own manifest file, so my understanding is that I don't need to do anything since in the final privacy manifest file in the IPA everything is merged. Am I right?

thick dune
# loud zenith Hi all, I'm updating my iOS game and I think new updates require Apple Privacy M...

If Unity really does add an Apple Privacy Manifest then it should be alright but you should check your files for that manifest. It sounds like it might be similar to the Android Permissions and the ridiculous requirements of the Google Play store that are added automatically.

In fact, you're just altogether better off contacting Unity, Apple and a lawyer about all of this as opposed to a bunch of nobodies on a messaging application.

loud zenith
# thick dune If Unity really does add an Apple Privacy Manifest then it should be alright but...

If Unity really does add an Apple Privacy Manifest then it should be alright but you should check your files for that manifest.

They are saying that they do add the manifest file for the UnityFramework.
https://forum.unity.com/threads/apple-privacy-manifest-updates-for-unity-engine.1529026/

solid sinew
#

Is there any way for me to subscribe to an event from all instances of a class or get the instance from a static event? I don't want to have to subscribe to each instance's event manually, but I also need a reference to the instance that invoked the event. Currently, I'm using a static event that just sends the instance as the first parameter, but I'm just wondering if there are any other ways to do it.

thick dune
lean sail
#

If sending in the instance as a parameter is a problem, you could also subscribe to the event using an anonymous method

leaden ice
somber sigil
#

I have a board with Piece prefab Instantiated to fill the board. now i want them to have an idle animation which plays every x seconds. but the issue is this animation should play in sync for all gameobjects and still keep on playing if another animation plays in between at the x time given. Also no reference to these gameobjects. Can anyone lend a good approach to tackle this?

lean sail
# somber sigil I have a board with Piece prefab Instantiated to fill the board. now i want them...

parts of this are very unclear

still keep on playing if another animation plays in between at the x time given
Are you trying to play 2 animations at once? Or do you mean another animation on a separate object? Even with the latter, its still unclear how this affects anything. You should show your code
no reference to these gameobjects
why? get the reference then or have them all reference some script managing the animation timings.

somber sigil
# lean sail parts of this are very unclear > still keep on playing if another animation play...

Actually i figured it out a while ago. I have a prefab which plays the same animation , only issue was when i enable the prefabs at different time, it would caused the overall animation to go out of sync of course. now i simple play the animation in a loop while having a transparent sprite which i just swap in place of enabling. Also no reference to the gameobjects since they are like 100 in number and some of them are grouped to different list. Anyways thanks for the reply.

somber sigil
#

oh interesting I'll have a look thanks

lone zealot
#

hi. does anyone know how to handle localization for numbers? I want to eventually convert the int into a string that's localized by the Unity's localization system

#

in case relevant, here's the full context. the LocalizeStringEvent is a built-in component that has a StringReference and gives us a nice inspector for subscribing string properties to listen to this (TMP_Text.text for example)

lone zealot
#

only solution that comes to my mind is creating a new entry for integers, passing in an integer variable alone, and then set it from the code using

var variable = localizeStringEvent.StringReference[variableName] as IntVariable;
Assert.IsNotNull(variable, $"variable \"{variableName}\" was not an integer");
variable.Value = amount;

but come on 🥲

dusky lake
swift falcon
#

Finally solved it!

opaque ledge
#

is there a way to detect an intersect between an overlapbox and a raycast?

cosmic rain
opaque ledge
cosmic rain
lean sail
opaque ledge
cosmic rain
#

Wdym by "isn't enough". Can you clarify?

#

And what would be enough then?

lean sail
opaque ledge
#

it was mostly just the interest of doing a collision system which is not the default one. By "isn't enough" i was referring to the colliders only having the OnEnter, OnExit and onStay function. i tried using an overlapbox (and raycasts for bullets) but as it turns out its not possible

cosmic rain
lean sail
#

Yea idk it's hard to really say anything because it sounds like 2 things
1: you arent familiar with how physics works in unity (thus the overlapbox being used in the first place)
2: want extra functions because of number 1

#

When theres something concrete you actually need to solve, then worry about adding functionality. But having no game mechanic you're trying to achieve and just wanting more functionality for the sake of it isnt a good combination

mossy oyster
inland canopy
#

I have a weird bug in my unity editor. I want to delete my prefab and if I hit delete, it reappears after 1 second. The prafab isn't commited to unity version control yet, and I haven't removed any folder, just duplicated this prefab as a backup from another prefab, but now i can't delete the backup prefab. Is there any solution for this?

leaden ice
inland canopy
#

sorry yes, i mean that

leaden ice
#

There's no reason the asset should be reappearing automatically. That sounds like the result of some external program. For example OneDrive, or Google Drive, or DropBox or something along those lines.

inland canopy
#

i use only unity version control, the folder also haven't been opened in any third party application 😦

#

i restarted windows, but i still can't delete it, the delete works for other prefabs

somber nebula
#

I have a game that needs every effect to be unique, and I want like 50 of them. A "Subject" NPC has a list of effects applied, and this is changes in-game with random effects. What is the best way to store these effects? I had an abstract BaseEffect class and then derived classes for each effect, but since the base class is abstract I can't have an array of that

#

ScriptableObjects wouldn't (to my knowledge) let me have the custom ApplyEffect logic for each separate effect unless I had a new scriptable object type for each effect, which would get cluttered fast and seems kind of useless

silent tapir
#

How can I make some borders not thicker than eachother its annoying, idk how to fix it, resolution scaling maybe?

cold parrot
gray mural
#

Yeah, Unity doesn't do it nicely

hard estuary
gray mural
#

You may also consider adding the pixel perfect camera, according to your game

cold parrot
serene stag
#

Is it really possible to make a native app for different gaming apk builds.

#

Single native app downloading different gaming apk resources and opening them.

lofty summit
#

is there a way to have visual studio analyze and correct my tags? 🤔
I mean, unity has a list of tags but I have to write a string... I could make a typo... isn't there an enum somewhere or something?

#

(is there a better tagging alternative?)

wide terrace
#

There is no enum, no - tags kind of suck in general. I think there is an undocumented/unsupported internal collection, but best not to rely on it.

Scripts themselves can act as a tag alternative though

lone zealot
chilly surge
lone zealot