#archived-code-advanced

1 messages ยท Page 173 of 1

undone coral
#

got it

#

have you investigated a pre-existing modding asset?

hallow cove
#

what's that?

drifting galleon
#

that makes no sense. you already have the materials in all other builds

hallow cove
#

no-

undone coral
#

try searching "mod" in the asset store

hallow cove
#

I need someone to be able to install the sdk, add their own materials and models

#

upload the map which I need to convert first somehow

#

and then someone can join by accessing it from the database

drifting galleon
hallow cove
#

so I need to learn how to use them

#

I need the user making the map to not have to do a lot of complicated stuff

#

just make the map and press a button

drifting galleon
#

what's your game dev experience

hallow cove
#

I've been donig it for 5 - 6 years and I can pretty much make a full game

undone coral
#

you can look at one to learn the whole workflow

hallow cove
#

however this is a lot of new stuff, including networking which I never got quite right

#

but I think I'm on the right track with taht

#

ok but can I use them to just, take everything in a scene, with materials, models used, everything, and just make them into addressables and then upload that?

#

that's all I need to know

#

are addressables usable for this?

#

ok they don't seem to be

quartz stratus
#

When calling UnitySendMessage(string gameObjectName, string methodName, string message) from a native iOS plugin, does anyone know if the third parameter, string message, is optional? I know it is when calling from a .jslib plugin, but I haven't tried it with an iOS plugin yet.

sly grove
#

I'd say... try it and see?

#

worst case scenario, just send an empty string

timber flame
#

No

shut citrus
#

I've been messing around with additional Display and have managed to achieve what I wanted using win10 user32 api stuff, avoiding actual Unity code. Now I am trying to render into a very large window (6400x2560) and using Display.SetRenderingResolution does not work, it get's clamped to 1920x1080. The one thing that hurt me the most, that this is completely undocumented.
https://docs.unity3d.com/ScriptReference/Display.SetRenderingResolution.html
It worked in the editor (the editor-windows dont have this clamp)
https://i.imgur.com/KrmYRmf.jpg

#

I'm wondering if there is any way to get aound this clamping behaviour?

river musk
#

I have a special walk animation I want to play when walking along a narrow platform. I use a trigger on the bottom of the player to find this narrow platform to start this walk. But I need the player to face the direction of the narrow platform. This is 3d game. The player can only move forward and backwards on this platform so they don't fall off. When they start to walk on this platform, like I said, I need the player to face the platform. I know how to cast a raycast, would this work somehow? Thanks.

undone coral
river musk
#

Is rayHit.normal the way to go?

undone coral
river musk
#

But it wont always be a box collider, it could be a meshcollider

undone coral
#

is the platform's direction platform.transform.forward?

#

you can do player.transform.forward = platform.transform.forward right?

river musk
quartz stratus
undone coral
undone coral
#

you can download the prime31 plugins to learn more about ios-unity plugin development

undone coral
quartz stratus
quartz stratus
undone coral
shut citrus
#

@undone coral my objective is to create an animated wallpaper that spans all 3 screens (or more). I can settle for single screens I guess, but if possible I want full expansion

undone coral
shut citrus
#

currently the only thing in my way is the resolution limitation. I want to have one window to interact with and one window as a wallpaper that shows everything without the controls

undone coral
#

when you say spans all 3 screens

shut citrus
#

this all works. but the resolution is just capped.

undone coral
#

what do you mean? a contiguous graphic?

shut citrus
#

yeah, I make one window that spans all 3 screens

undone coral
#

you can use a render texture on your camera to create a single contiguous image large enough for all the desktops, and then slice it into each respective view. or you can render each desktop separately, using its own camera, if you line up the cameras right

#

how are you putting an image onto the desktop?

shut citrus
#

so 6400x2560 for my personal setup. the window gets rendered behind the desktop icons

#

I'm actually using a asset (live wallpaper) and have modified it quite a bit

undone coral
#

okay

#

that's helpful

shut citrus
#

but this all works

undone coral
#

i heard you the first time

shut citrus
#

it's really just the resolution. I can't render it to that window

#

kk ๐Ÿ™‚

undone coral
#

so this asset, does it support multiple displays?

#

or did you modify it to do that?

shut citrus
#

splitting is a decent idea, but also means more draw-calls. the asset supports it, but only in the editor. it was never intended to do what I want

undone coral
#

okay

shut citrus
#

the asset is designed to place your main window in the background, not a secondary display

undone coral
#

so you modified the asset?

shut citrus
#

yes

undone coral
#

got it

shut citrus
#

well mostly repurposed some of the code

#

I wrote all the window management code myself

#

besides turning it into a wallpaper

undone coral
#

why would you use Display.SetRenderingResolution?

shut citrus
#

is there another option?

undone coral
#

why are you setting the resolution of a display?

#

what is the idea?

shut citrus
#

well the resolution of the large window was obviously wrong, so I tried to overwrite it

undone coral
#

okay

#

and it works in the editor

shut citrus
#

but it's probably wrong because of the same clamping mechanism that stops me from setting a higher resolution

undone coral
#

something works in the editor

shut citrus
#

yes. the editor windows allow super-sampling (I read that in a forum post)

undone coral
#

okay

#

that thread is also saying use a render texture

shut citrus
#

yeah, but the output to the screen is the problem

undone coral
#

i'm not sure why the displays are showing the wrong resolution

#

maybe try to use their real resolution

shut citrus
#

your splitting idea might work, but it's a horrible work-around for something that seems like an arbitrary limitation

#

I'm using post processing effects and the context width/height is clamped

#

or shows that it's clamped to 1920x1080

#

I guess the final option would be to start messing in Unity source-code, but that might be too much for me

undone coral
#

since i don't know how the asset really works it's hard to give good advice

shut citrus
#

it's like detectives work when you don't know why something does not work...

#

thanks a lot for your help, I was mainly wondering if I missed something obvious. looks like I am just at a dead end caused by this weird limitation

#

I really don't think the asset is even relevant in this context (only to understand what I am doing and why)

#

hmmm. what I have not tried is to use the main screen to resize for the full 3 screens. Not sure if Screen.SetResolution might have different limitations

royal burrow
#

Is there any other way to make dialogue narratives properly without using Ink?

undone coral
#

there's an asset that ships an Ink compatible UI

#

Dialogue System

ivory girder
#

anyone have a good example of localized controls in local multiplayer using the new input system? The issue I'm having is everything is working as intended (new players are spawning and moving) but every input moves all players. I think I messed something up because of the method I used (subscribing to events in onAwake();) It seems that my script is failing to add new distinct players and I'm not sure how to fix it since there aren't any tutorials I've found covering this method of input.

#

in awake im defining a new playerinputaction but this doesn't seem to matter, they're all still inexplicably tied together

#

I think the strategy might be to drop back to sending messages as opposed to bothering with subscription but I've been told the latter is more efficient

sly grove
#

for example if you're doing something like myPlayerInput.actions['MyActionMap/MyAction'].performed +=

sly grove
#

Actually using the PlayerInput is important so you can take advantage of all its nice local multiplayer features

#

such as automatic device binding etc

undone coral
#

do that

ivory girder
#

Alright, got it. Is there a good body of example code I could look at? clearly the tutorial I followed was doing it quick and dirty without multiplayer in mind

ivory girder
#

my awake method looks like this atm more or less

sly grove
# ivory girder

yeah you're completely ignoring the PLayerInput and all the joy it provides

#

you're using the generated C# class instead

#

which is great under normal circumstances, but not for local multiplayer

ivory girder
sly grove
#

using the PlayerInput

sly grove
undone coral
sly grove
royal burrow
#

Can someone please check these two codes? I made a system to switch between cameras to make cutscenes when a lever is activated. For some reason, when I use this script, on 3 cameras, in only one camera's case does the camera switch work. By switching, I mean main camera becoming inactive and other becoming active. In the case of other 2 cameras, they become active but main cam doesnt become inactive. This is the code for the lever that is activated.

//See update function

public class LeverScript : MonoBehaviour
{
    [SerializeField]
    ConsequenceCam ConCam;
    public bool isActivated=false;
    Animator anim;
    BoxCollider2D triggerArea;
    // Start is called before the first frame update
    void Start()
    {
        anim=GetComponent<Animator>();    
        triggerArea=GetComponent<BoxCollider2D>();    
    }

    void Update()
    {
        if(isActivated)
        {
            isActivated=false;
            if(ConCam)
            ConCam.ActivateCinematic=true;
            triggerArea.enabled=false;
        }
    }

    void OnTriggerStay2D(Collider2D col)
    {
        if(col.tag=="Player" && Input.GetKey("x"))
        {
            anim.SetBool("isActivated", true);
            isActivated=true;
        }
    }
}
#

Next code is for the cutscenes attached to a UI object as I animate this object to make the cutscene movie like.


//See playCinematic,endcinematic and update functions

public class ConsequenceCam : MonoBehaviour
{
    public bool ActivateCinematic;
    [SerializeField]
    float duration;
    [SerializeField]
    float destroyCamIn;
    [SerializeField]
    GameObject consequenceCam;
    [SerializeField]
    GameObject currentCam;
    Animator anim;

    void Start()
    {
        anim=GetComponent<Animator>();
        ActivateCinematic=false;
    }

    void PlayCinematic()
    {
        if(ActivateCinematic==true)
        {
            anim.Play("SequenceBegin");
            Invoke("EndCinematic",duration);
        }
    }
    void EndCinematic()
    {
        anim.Play("SequenceOver");
        ActivateCinematic=false;
        Destroy(gameObject,destroyCamIn);
        Destroy(consequenceCam,destroyCamIn);
    }

    void Update()
    {
        PlayCinematic();
        if(ActivateCinematic)
        {
        consequenceCam.SetActive(true);
        currentCam.SetActive(false);
        }
        else
        {
        consequenceCam.SetActive(false);
        currentCam.SetActive(true);
        }
    }

}
#

Ignore the destroyCamIn variable, I tried to fix it with that

hallow cove
#

All I know is Asset Bundles seem to be the best option and the right tool for the job

novel plinth
royal burrow
#

done

#

please help someone

spare pond
#

Hello. Can someone tell me how to do collision detection without CompareTag etc.. Maybe someone will mention a design pattern or practice?

I want to make next relations:

Player - Enemy
Player - Coin

Enemy - Coin
Enemy - Player

Coin - Enemy
Coin - Player

I don't want to make multiple if statements and describe each logic. Im trying to create some system which will just execute logic. Maybe State pattern will come handy?

granite viper
#

good way to do that is with interfaces

spare pond
#

But how to make comparing automatic? Create class which will compare, but how to automate this? Is it possible to avoid 100+ checks?

granite viper
#

yes it is possible

#

let's say you want to be able to collect the coin as the player

#

you add an interface to the coin called ICollectable. In that interface you define a method Collect( ICollector collector ). When the Player or whatever overlaps with the coin trigger, the player checks the interface and calls Collect on it. Maybe ICollector has an AddCoins method on it, and the coin calls that in its Collect method

spare pond
#

Let me expand my question to clarify

granite viper
#

that would be nice

spare pond
#

Enemy - Player = Reduce hp to player on collision and make him invulnerable for a period of time.
Enemy - Coin = Enemy AND Coin destroys on trigger
Player - Coin = Collect coin and destroy coin on trigger

In my personal case destroy means move it back to object pool of course ๐Ÿ˜„

granite viper
#

when you say disable, do you mean they both get destroyed

spare pond
#

At this moment its not that hard to describe every relation in if statements, but what when i want to add and add more?

granite viper
#

well, as a general rule it's not a good idea to try and design your system to handle every possible situation

granite viper
#

you will find yourself in paralysis by analysis very quickly

#

often best to just do it quick and dirty and refactor as necessary

spare pond
#

Yea but i making technical specification for applying a job ๐Ÿ˜„ and thought it would be nice if i ended up with something new

granite viper
#

ah

#

Add IPlayerDamage interface to the Enemy, and add ICollectable to the Coin

#

the player looks for both IPlayerDamage and ICollectable

#

the Enemy looks for ICollectable

#

when I say "looks for" I mean in a trigger/collision event

spare pond
#

So in the end you will always add this "looks for" by yourself

granite viper
#

yes, at some point some code has to be written so that things happen

hollow garden
#

lmaoo

spare pond
#

In my mind i was thinking about collision detection system which will somehow operate logic between collision types.

Lets say create CollisionType : ScriptableObject which will have collision name variable and somehow store collisions/triggers that will have some logic related

modest lintel
#

That basically sounds like a wrapper over the collision callbacks, which you would have to code anyway

granite viper
#

I feel like that system would get cumbersome fairly quickly

spare pond
#

and CollisionController : MonoBehaviour which will have CollisionType refernce with Callbacks that will automaticaly execute logic

granite viper
#

but yes, that is doable

#

and would work

#

it's more boilerplate

spare pond
#

Maybe something wrong with me but i want to avoid this same and infinite "looks for" things

modest lintel
#

you gotta look for a thing to do something to it ๐Ÿ˜‚

granite viper
#

I mean at the end of the day you'd have to look for the CollisionController in order to call the appropriate callbacks

#

otherwise how would you know the collisiontype

#

unless you encode that in a tag or sommin

spare pond
granite viper
#

yeah

#

otherwise how do you know what type you're colliding with

#

in order to execute the rules

spare pond
#

Not that hard i think. Before any callbacks just check if he has collisionController in order to communicate with that system

#

Anyways, big thank you @granite viper @modest lintel for conversation. Gonna find solutions on my problem on tech interview i guess XD

granite viper
#

my point was that you still have to "go look" for something

#

np

modest lintel
#

Goodluck!

proud atlas
#

Hello. How would I go about replicating the parent->child position relation through script?

What I mean is, that when you put a Cube into another Cube, its direction from the parent stays the same; all the time... (during rotation, during change of position, etc.)

Let's say I have two GameObjects (or 2 Vectors, to be more exact) and I want to "stick" one Vector to the other, like I explained.

Vector3 dir = volume.transform.position - examplePoint.transform.position;
examplePoint.transform.position = volume.transform.position + dir;

This is something I tried, it works fine, until I rotate the cube. At that point, it stays in the same position... which is understandable, I never say it should be exactly "in front of the cube", but I cannot rely on the fact, that it will always be in front of the cube, it can be behind, on the side, and so on.

volume is the parent
examplePoint is the "child" (not literally, but its behaviour must be as if it was a child of volume.

Thank you

sand wraith
#

I am facing a weird problem.
I have two scripts XYZ.cs and ABC.cs.
Both are on same game object.
I am trying to access ABC from XYZ.
But it's returning null.
I tried getcomponent<ABC>() and dropping the object in inspector to script.
I tried everything I could but don't understand why this is happening.
Can anyone tell why this is happening?

umbral trail
#

how do you know ABC is on the object?

sand wraith
#

I have added both as components via inspector

#

On same game object

fathom flare
#

I am trying to make an API listener in unity WebGL, how would yall do that?

#

I made one but i hope to get more info how u would do it

novel meteor
hollow garden
#

therefore it is trying to access a field in your class called main

novel meteor
#

oh holly shiet! im so dumb lmao

hollow garden
#

lmao

novel meteor
#

thank you!

hollow garden
#

np

modest lintel
#

show code

kindred tusk
#

Could somebody advise on this error:

#

In this case the file and the class name do match

#

This is the file:
CommandEventConfig.cs

using UnityEngine;

namespace EffortStar {
  [CreateAssetMenu(menuName = nameof(EffortStar) + "/" + nameof(CommandEventConfig))]
  public class CommandEventConfig : BaseEvent<
    CommandEventInfo,
    CommandEventConfig,
    ICommandEventFilter,
    ICommandEventEffect
  > { }

  public struct CommandEventInfo {
    public Actor Actor;
    public Command Command;
    public CombatContext Context;

    public CommandEventInfo(
      Actor actor,
      Command command,
      CombatContext context
    ) {
      Actor = actor;
      Command = command;
      Context = context;
    }
  }

  public interface ICommandEventFilter : IEventFilter<CommandEventInfo> { }
  public interface ICommandEventEffect : IEventEffect<CommandEventInfo> { }
}
urban warren
#

And screen shot of file with name?

kindred tusk
#

hmm....

#

Something funny is going on

urban warren
#

Seems like it should work. Maybe try creating a new file? Maybe it cached something funny?

kindred tusk
#

I'll try deleting scriptassemblies

fresh salmon
#

Yeah it's likely Unity lost track, re-create the script

kindred tusk
#

haha, yes. reloading script assemblies:

#

the object is now busted

#

Thanks!

urban warren
proud atlas
#

Thanks a lot

hallow cove
#

hey so, I figured out how to use Asset Bundles

#

problem is

#

I have to select the asset and then trigger the function

#

is there any way I can tell it to get an asset at a certain location and convert it

#

instead of taking the selection

shut citrus
#

@undone coral I managed to solve the problem I was having with screen resolution. I can use the main screen to stretch over 3 screens no problem and the resolution is perfect. It just does not work with a secondary screen.
Now I have a new issue. I need to switch cameras from one display to the next. This works fine by simply changing the targetDisplay. The problem I am facing is that the all my Canvas UI no longer works (it renders fine, but I can no longer click anything). I've tried removing and adding the cameras a frame later + changing the render mode, but this does not help.

#

oh damn... Canvas also has a targetDisplay value.

quartz stratus
#

Is there an attribute that I can assign to a method that informs the compiler that the method will be called from outside the project? I have a method being called via UnitySendMessage from a native iOS script. Ideally, I can mark it so my IDE knows it's being used.

sly grove
undone coral
#

it's unity's version of usedimplicitly

#

there's also something related to il2cpp

#

that marks it as something that should never be stripped

#

you don't distribute il2cpp precompiled libraries though

#

so it's unusual to mark methods this way unless they are access by plugins

#

maybe it's in the AOT namespace

crystal oxide
#

Does anyone know how i can change values of a mask in a shader while in runtime?

undone coral
#

in a shader graph?

#

using something as a mask?

crystal oxide
#

Well i have never made a shader, this shader is made by the person who does the graphics and now i have to change the values during runtime

#

This is what i got, i gotta change the BlackMask Offset

drifting galleon
#

then set the appropriate property

crystal oxide
#

How i do that?

drifting galleon
crystal oxide
#

That is the thing, this shader is not on a certain object

#

We have it on the forward renderer

undone coral
drifting galleon
crystal oxide
#

how ya mean?

drifting galleon
#

urp?

crystal oxide
#

yes

drifting galleon
#

ok i don't understand. when you blit, you blit with a material for this purpose. so you still should have access to the material

crystal oxide
#

Is there a certain way i should do the reference to it in the other script?

drifting galleon
#

what other script?

crystal oxide
#

Where i change the value of Blackmask Offset

#

Well try to change it atleast

drifting galleon
#

? what? that's a monobehaviour

crystal oxide
#

Ok i guess i am trying this wrong

drifting galleon
#

you want it as fullscreen pass right?

crystal oxide
#

What i am trying to do is, at a certain time in the game i need it to change, planned to just call a function then

#

Basically yes, its a vhs filter

drifting galleon
#

you can only do fullscreen passes with ScriptableRenderFeature / ScriptableRenderPass

crystal oxide
#

Do i just change monobehaviour to it? It wont register it if i do

drifting galleon
#

what do you mean?

slow fox
#

Don't mean to spam, but anyone know about scripting LineRenderer in a way that doesn't lag behind the object it's starting from?
#archived-code-general message

thick spire
#

Hey guys, how does getpixels work?

#

When I try to do GetPixels(gameobject.position.x, 0)

#

It has an offest

#

offset for different devices

#

But when I do GetPixels(400, 0)

#

it gives me the exact correct colour

#

How goes GetPixels read the texture?

#

compared to reading say world space coordinates?

austere jewel
#

GetPixels returns an array of pixels in a pixel area, that's it

thick spire
#

So when I have my cursor on the specific part of the texture, it should give me the exact colour of where my mouse is

austere jewel
#

What texture

thick spire
#

It's a chromatic texture

#

I cant show mine because its a custom one which im not allowed to show

#

but it looks like this

austere jewel
#

It's it on a 3D object or what

thick spire
#

Its on a ui object

#

I read some forums where it said you have to make some form of calculation to get the exact pixel

austere jewel
#

Then you need to convert your cursor position into the space of that rect, and then use that to sample into the space of the texture

thick spire
austere jewel
#

The rest would have to be manual

thick spire
austere jewel
#

I mean converting from local space to pixel space

austere jewel
#

That could do it, I've never used it before

latent moss
#

Hi,
i am trying to register Event Handler that calls a function with args.
I had this to call the function:

itemSlot.RegisterCallback<PointerDownEvent>(OnPointerDown);

According to unity docs, it is possible to register event with args:
https://docs.unity3d.com/ScriptReference/UIElements.CallbackEventHandler.RegisterCallback.html

So i tried to apply args:

slotName = "itemSlot1";
itemSlot.RegisterCallback<PointerDownEvent,string>(OnPointerDown(),slotName);

slotName is a string i want to pass into the "OnPointerDown" function, but no matter what variation i try, i always get errors.

austere jewel
#

Don't call your callback

#

The function is a parameter, adding brackets to it calls it and then you're passing the return value to the method (presumably void)

#

Compare the two pieces of code you posted if you're missing it

latent moss
#

Thank you, i get what you mean, i corrected it, but it still doesnt pass the arg "slotName"

newSlot.RegisterCallback<PointerDownEvent,string>(OnPointerDown,slotName);
#

i thought this is the way that docs suggest, but i have an error (i will screenshot it, but must change languae of my IDE first)

#

Cannot change debugging language to english in stupid vscode, as it adapts from system.

This is my code

austere jewel
#

Your method needs to take the correct arguments

#

Can you use your IDE to generate an overload

#

By pressing alt-enter on the error

latent moss
#

i changed the arg in method as you told me to:

#

The overload thing, i will try now

austere jewel
latent moss
#

The error is gone, i thank you very much ๐Ÿ™‚

vocal idol
#

Not sure if i should consider this "advanced". Is this ok to post here? I'm really desperate ๐Ÿ˜

I'm trying to stop the character (Polygon Collider 2D) from moving through a wall (Tilemap Collider 2D).

1 var hitResults = new RaycastHit2D[10];
2 var hitX = collider.Cast(new Vector2(desiredX, 0), bodyFilter, hitResults);
3 //var test = new Collider2D[10];
4 //hitX = collider.OverlapCollider(bodyFilter, test);
5 if (hitX == 0)
6 {
7     transform.Translate(desiredX, 0, 0);
8 }

Why does the character not stop moving horizontally when I run the code like this? I proved the character can collide with the wall because it does stop moving horizontally when I uncomment the two lines (3&4).

wary quail
#

Anyone have any fun tips on how I might want to program this to make the debris spiral around? Essentially its a magnetic gravity gun - I break the rocks, I can lift and suck them in

#

but it might be fun to have them spiral around one another

#

vortex like

#

I suppose I could have some sort of check that sees if they're close to the center, otherwise it pushed them in a direction (up down left right)

elder dome
tight willow
#

does anyone have a good water tutorial or script i can look at?

covert anchor
tight willow
#

Ik u answered it was j i didnt get anything from reading the code that exist in that github

covert anchor
austere jewel
#

This is not an advanced code question. Provide more context in the original channel you posted in so people can actually provide meaningful help

undone coral
sinful pecan
#

messing around with some recursive stuff, is there a way to tell c#/unity there is a limited amount of iterations so it doesn't try to allocate infinite memory?

public class EcoSystem
{
    public Vector2 position;
    public float radius;
    public EcoSystem[] children = new EcoSystem[7];
}
```still happens when i don't use the array as a member and use new in the constructor
i'm guessing it's just a terrible idea to use classes and constructors for this in the first place? haha
agile yoke
#

Nothing necessarily wrong with using classes for it like this, but you need to just not call new EcoSystems[7] anymore when you're at an object that doesn't actually have children anymore

austere jewel
#

Only serialising this would be a problem

sinful pecan
#

that's what i tried, if(iterations <= 0) return; at the start of the constructor and only initializing new "selves" after that, but seems like it still still doesn't like that

austere jewel
#

The array has 7 null values in it, there's no infinite loop unless you're always initialising the indices

agile yoke
sinful pecan
#
public class EcoSystem
{
    public Vector2 position;
    public float radius;
    public EcoSystem(int iterations, float radius_, Vector2 position_)
    {
        EcoTrack.Track();
        if (iterations <= 0) return;
        //EcoSystem[] children = new EcoSystem[7];
        radius = radius_;
        position = position_;
        EcoSystem one = new EcoSystem(iterations - 1, radius / 3, position);
        for (int i = 0; i < 6; i++)
        {
            float angleRad = (60 * i) * Mathf.Deg2Rad;
            Vector2 childPos = position + new Vector2(radius * (2.0f / 3.0f) * Mathf.Cos(angleRad), radius * (2.0f / 3.0f) * Mathf.Sin(angleRad));
            EcoSystem six = new EcoSystem(iterations - 1, radius / 3, childPos);
        }
        GameObject circle = Utils.DrawCircle(radius, World.me.matUnlitColor, Color.cyan);
        circle.transform.position = position;
    }
}```it's still not happy ![LUL](https://cdn.discordapp.com/emojis/368438793310699522.webp?size=128 "LUL") 
https://i.imgur.com/uAnaHdy.png
#

i think i just need to change my approach

formal urchin
#

hi someone can help me to fix these errors ? it's strange because just jump out sometimes and sometimes no, i think that is a editor bug but i dont know

sinful pecan
quartz stratus
formal urchin
little egret
#

Hi, I've not posted much on this server before, so I don't know if this is the correct place for this, but here goes.

I'd like to combine multiple animation curves into one, so that the width curves from several line renderers can be used for one continuous line. The same goes for colour gradients, but right now I'm focused on getting widths working correctly. Here's what I have so far, I'm aware its a little hard to understand, so sorry about that. If anyone knows a good way to achieve this, please let me know as soon as you can.
Also, I'm not sure if the tangents and weights work correctly, so that's something to bear in mind.

_width = new AnimationCurve(); // Create a new curve
for (int i = 0; i < _lineParts.Length; i++) // Loop through all LineRenderData scriptable objects containing width data
{
    LineRenderData renderData = _lineParts[i].RenderData; // Cache current render data
    for (int j = i > 1 ? 1 : 0; j < renderData.Width.length; j++) // Loop through each keyframe in the cached render data's width curve. This ignores the first keyframe from subsequent frames, to avoid overlap, this is something I'm not sure how to mitigate
    {
        float time = i * (1f / _lineParts.Length) + j * (1f / lineData.Width.length); // Get time value, this is what I'm struggling with, I'm not good at math. :(
        _width.AddKey(new Keyframe
        (
            Mathf.Clamp01(time),
            Mathf.Clamp01(renderData.Width.keys[j].value),
            renderData.Width.keys[j].inTangent,
            renderData.Width.keys[j].outTangent,
            renderData.Width.keys[j].inWeight,
            renderData.Width.keys[j].outWeight
        ));
    }
}

_lineRenderer.widthCurve = _width;
wanton hound
#

Hey anyone know how to look if every element of a list is equal

#

`public List<int> A = new List<int>();
public List<int> B = new List<int>();

If(A == B)
//statement true`

#

Will this do the trick or is there something else?

umbral trail
#

A.SequenceEqual(B)

wanton hound
#

Thx man I will try

#

1 more thing

#

How do I make a rpg defense system like diablo 2?

lavish ridge
wanton hound
#

I mean when In diablo if enemy ever hits you even if you have 300 defense while the enemy has damage btw 12-24 the player always takes damage it does not subtracts it from the defense instead makes a chance to block that determines if it is true player takes 0 damage if false player takes a random btw min/max of enemy?

#

Anyone has an idea how?

compact ingot
wanton hound
#

How?

compact ingot
wanton hound
#

I mean a little snippet

#

What is meant by this quick RIP?

#

Huh

#

Rest in peace?

lavish ridge
#

your question is more suited for the channel he pinged

wanton hound
#

Hey I am not a beginner, if u guys think so I will look into this myself and get a good output!

flint sage
#

The answer is math

#

How to implement that math is probably quite trivial

regal olive
#

for some reason transform.InverseTransformDirection() isnt working correctly

here is the code: ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class localVel : MonoBehaviour
{
Rigidbody rb; // <- OBJECT NEEDS RIGIDBODY COMPONENT

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

// Update is called once per frame
void FixedUpdate()
{
    var locVel = transform.InverseTransformDirection(rb.velocity);
    locVel.y += 1f;
    rb.velocity = transform.TransformDirection(locVel);
}

}

when used on an object parented to a rotating object, it gets added velocity in the direction the parent is rotating
this should **not** be happening
the **reason** it **shouldn't** be happening is because `locVel` should be a **velocity** vector in **local space**.
`        locVel.y += 1f;` should accelerate `locVel` in the **`y-axis`**.
instead, what i am observing is acceleration in the `y-axis` **and the `z-axis`**.
sand rampart
#

Hey in here, I'm looking to implement an algorithm that can visualize a tech tree for me. The tech tree is in essence a directed acyclic graph, and I've been looking into layered graph drawing as a solution, but I can't find any resources that explain how to implement in a more approachable way. Anyone who can point me in the right direction, perchance?
I've found some potential research papers on the subject, but would like to see if I can't find something more approachable before I spend a good bunch of hours trying to follow the papers.

sinful pecan
proud gust
#

What would be a good approach for snapping/aligning instantiated objects with another surface?
As a start, aligning spawned objects with the ground plane for instance

granite viper
#

grab surface normal, align object up with surface normal

proud gust
#

Raycasting to the bottom + 1/2 vertical bounds offset?

granite viper
#

yes, by raycasting

proud gust
#

Okay, figured that one, but I don't know how to get the proper offset

granite viper
proud gust
#

But how do I account for rotations?

#

Ah bounds is always world space right?

granite viper
#

you'd want to get the mesh bounds

#

sharedMesh.bounds

#

that is local space

proud gust
#

Okay

#

So I'd have to account for rotations as well

granite viper
#

no

#

because if you have the normal and hit position (assuming the object's pivot is at its bounds center), you'd place the object at hitPosition + normal * bounds.size.y * 0.5f

#

you will need to account for rotation to align the object's rotation with the surface, yes

#

but positioning doesn't require it

#

if you can guarantee that the object pivot is at the base, it gets real easy

#

since you can put the object at the hit position

proud gust
#

I see. That's fine, I'm not sure if I need to account for rotation then, positioning should be enough

#

Yeah, but I can't guarantee that unfortunately

granite viper
#

if you don't care about the rotation of the object itself yes

proud gust
#

Thanks for the hints, I'll try it

proud gust
#

@granite viper Works great, thanks again!

thick spire
#

Hi guys, I have a question how to read texture coordinates from mouse position

#

So if I put my mouse cursor on a specific part of the texture, it should give me that exact colour of the area on that texture

#

I need to get the texture coordinate on a UI image

granite viper
#

@thick spire first step is to get the relative position of the cursor over the image

#

then you can convert that into a pixel position, then you can use GetPixel on the texture

#

assuming it's readable

undone coral
#

getting the relative position of a cursor over the image is arcane

#

the ui image isn't a piece of geometry, it doesn't have UVs, it has some sense of a local space but not one that is easy to understand

undone coral
undone coral
undone coral
regal olive
#
#

im trying to replicate this

#

it does not use kinematic
or at least i reckon it doesnt

thick spire
granite viper
#

if you have an x/y relative to the image (meaning that 0 is the left side and 1 is the right side), then the pixel position is Mathf.RoundToInt( x / image.width )

#

and same for y

thick spire
# granite viper if you have an x/y relative to the image (meaning that 0 is the left side and 1 ...
granite viper
#

that works

thick spire
granite viper
#

I don't know what ScreenPointToLocalPointInRectangle returns

modest lintel
#

a point

granite viper
#

but in either case you can convert it to be in 0-1

granite viper
#

so there

thick spire
#

XD

thick spire
granite viper
#

no

#

again, I don't know what type of coordinates
(๐Ÿ˜’ @modest lintel) localpointinrectangle returns

#

so if you can answer that for me I can tell you what to do next

thick spire
#

I have this rectangle

#

Like someting like this which i cant actually show

#

Its a child gameobject

#

it has a ui image texture

granite viper
#

can you just implement LocalPointInRectangle and tell me what it is returning for that gameobject

thick spire
#

Wait let me see that functio

#

wait

granite viper
#

waiting

thick spire
#

it returns

#

-347

thick spire
#

My code

granite viper
#

that's weird

#

can you sample it at the four corners of the rect

#

roughly speaking

thick spire
#

Ok

thick spire
frank peak
#

how performant is an inverse lerp? pretty solid?

granite viper
#

yeah it's fine

thick spire
granite viper
#

it's just a simple math expression

frank peak
#

okay good

#

Im looking at few different formulas and inverse lerp seems to be the simplest for my needs

granite viper
#

@thick spire do you know how big the image is

thick spire
#

width and height

granite viper
#

how big is the recttransform it's on

thick spire
granite viper
#

ok

#

looks like localpoint gives you a position that is relative to the center

#

so you're going to want to do something like

var localX = sampledX + rectTransform.width / 2;
var uvX = localX / rectTransform.width;
#

same for y

thick spire
#

I see

#

do I then input that into getpixel?

granite viper
#

uvX is a value from 0-1 (hopefully)

undone coral
# thick spire

create individual images and add pointer click handlers for them

granite viper
#

so now you multiple uvX by the image width

#

and round it to the nearest int

#

that is your pixel coordinate

thick spire
#

its custom made

#

so i cant really use any other assets

undone coral
#

is it 5 swatches of color?

thick spire
#

like all the colours on a rainbow but mashed together

undone coral
#

use capture screenshot then

#

and sample it

#

it will be faster and simpler than this

#

using a canvas scaler, for example, makes doing the arithmetic much harder

#

there are many pitfalls

#

@thick spire so trust me, use capture screenshot

thick spire
#

So your saying this right

undone coral
#

yes

#

these guys also have an eyedropper tool

#

for $20

stiff violet
#

Is it impossible to use the new unity analytics on WebGL? Seems like core initialization and authentication relies on System.Threading and I see no way around that

thick spire
#

i have to work with company asset

remote pumice
#

Hey, did somebody mess around with writing Lexers/Parsers before?

I feel like I understood the concepts, tokenization ->syntactical analysis/building AST->semantic analysis,

What's confusing me is, that almost all examples I've seen would tokenize into something that already has a meaning, for example
i have an idea would be tokenized as SUBJECT (i), VERB (have) and OBJECT (an idea),
while my brain is telling me that they should all be STRING and it's the Parsers job to give that sequence of tokens a meaning by trying to parse that STRING into a verb, subject etc depending on the grammars expectations

Any advice and/or recommendations? I've read and watched around 10 different videos and talks, if you have a really good >read<, feel free to share it, but I'm mainly looking for personal experiences!

for anyone interested, the Unity-Context is that I'm making some form of developer command system, i already have a working, easy to extend version, but I'm trying to rewrite it with a proper Lexer/Parser, for learning purposes and eventually easier extendability of the command syntax and possible features?!

sly grove
#

I've written lexxers and parsers for programming languages but natural languages are an entirely different beast

remote pumice
#

It's for a programming language like syntax

flint sage
#

If your input allows you to parse while tokenizing then go ahead, it'll be faster

#

But might not be possible once your syntax becomes more complex

sly grove
#

For example you cannot simply infer the verbness or nounness of a word from the word itself, as many can be Both with depending on context

remote pumice
#

I took the example with the natural language because I found it easier to understand what's bothering me in the tokenization examples

sly grove
#

Ok if it's not actually natural language it's easier

granite viper
#

the lexer understands the individual symbols that make up the language

remote pumice
#

Cause I find it nonsense that tokenizer knows, for example, what a STATEMENT would be, it would know STRING OPEN STRING CLOSE in my opinion

#

And parser would know it's a Statement and creating a node for the AST

granite viper
#

the parser understands how those lexer tokens get combined together into context

#

in other words the difference between a lexer and a parser is semantics

regal olive
#

Do you guys know if it would be possible to export a character from a Unity scene to FBX format at runtime in a compiled Unity project via code?
I was toying with the idea of making a character creator that allows users to export their characters but I am not sure how feasable is this via code.

granite viper
#

a lexer understands how to convert a string into tokens, a parser understands how to convert tokens into code (in the abstract sense)

#

@regal olive should be possible, would need to write or find an FBX serializer

#

I don't think unity has one

#

built-in, that is

flint sage
remote pumice
# flint sage If your input allows you to parse while tokenizing then go ahead, it'll be faste...

I know that modern parsers do the tokenization "on the fly", also I've seen examples of "functional" parsing where the tokenization process was skipped entirely by parsing in a recursive way, where the only parser you'd use would be a, example, 'commandParser' that would then call further parsers like nameParser and argumentParser which, again, call more parsers, for example stringParser which would go to letterOrDigitParser and so on, that's quite elegant but too confusing for me at the moment

I'd like to completely separate them from each other

thick spire
granite viper
#

yay

thick spire
#

Omg yes

#

now

regal olive
thick spire
#

uvx i mean

flint sage
granite viper
#

@thick spire yes

#

uvX * textureWidth

thick spire
#

or the rect transform width?

regal olive
#

I see

granite viper
#

@thick spire the width of the texture

remote pumice
#

basically what I'm wondering, in my context

Should I tokenize something like Command, Arguments etc, or rather String and then let the Parser check

  • what am I expecting, grammar wise? (Would be Command first)

  • is there a matching Command for String?

  • more work

  • create Command Node for AST

granite viper
#

I would probably err towards the former

#

if you can identify it in the context of the lexer, it makes your parser work easier

remote pumice
#

True! What I thought about, is multiple lexing stages, if that makes any sense

#

Like in the first stage, 1+1 would be NUM OP NUM

#

and the second would replace that with EXPR
Parser would then check if EXPR is a fit for the expected grammar

#

hope the abbreviations are clear XD

#

that would make
command(Blabla).do()
from
STRING OPEN STRING CLOSE DOT STRING OPEN CLOSE
in the first stage into
COMMAND ARGUMENTS CHAIN
in the second stage

#

Something like a primitive Lexer that can have more concrete lexers in connection with a parser on top of it, if that makes any sense?! ๐Ÿคทโ€โ™‚๏ธ ๐Ÿค”

#

Also, I would, for example, in the first stage tokenize + etc as PLUS or SPECIAL because at this stage the Lexer wouldn't know if it's in a mathematical context

#

Anyways, I'll just continue experimenting, thx for your Inputs!

thick spire
#

Thank you so much!

granite viper
#

woot

regal olive
tardy lynx
#

hey, i'm having troubles with converting my mouse position the mesh vertex in the world

#

i'm not sure why but it has a small offset to the real world

#
    private void Update()
    {
        if(Input.GetMouseButton(0))
        {
            Vector2 mousePos = Input.mousePosition;
            Vector3 worldMousePos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, cam.nearClipPlane ));
            mapGen.Dig(worldMousePos, digRadius);
        }
#
    public void Dig (Vector3 mousePos,int brushRange)
    {

        int digX = Mathf.RoundToInt(mousePos.x* mapDetail);
        int digY =Mathf.RoundToInt(mousePos.y* mapDetail);
        test.transform.position = new Vector2(digX, digY);
        if (digX>=0&&digX<width*map.Count-1&&digY >= 0 && digY< height*map.Count-1)
        {
            int _chunkIndex =Mathf.FloorToInt(digX / width);
            Vector2 _chunkPos =new Vector2( _chunkIndex*(width-1)*(1/mapDetail),0);



            for(int i=0;i<brushRange;i++)
            {
                for (int j = 0; j < brushRange; j++)
                {
                    if((digX - _chunkIndex * width - 1 + i)>=0 &&(digY + 1 - j)>=0&& (digX - _chunkIndex * width - 1 + i) < width && (digY + 1 - j) <height)
                    {
                        map[_chunkIndex][digX - _chunkIndex * width - 1 + i, digY + 1 - j] = 0;
                    }


                }

            }
            UpdateMesh(_chunkIndex,_chunkPos,meshGen[_chunkIndex]);
        }

    }
#

what happens is that when my player camera is at world origin, the vertex index that i get from digX and digY is correct, but the further i go to the right in the world , the bigger the gap between my mouse and the vertex index is

regal olive
#

idk what a mesh vertex even is

versed pewter
tardy lynx
#

yep it is

regal olive
#

so tha means i have to produce a clone of unity's physics engine just to apply a force in local space?
that sounds extremely inefficient

undone coral
#

the former isn't going to help you with the latter

#

try spelling out the exact rules of what you want to do, in plain english, and it'll be apparent that to program it, you will not be using information about the transforms most of the time

regal olive
#

i'll make some mockup in Blender

undone coral
undone coral
#

just in terms of turning it into programmable rules you have to write it out

#

getting better at this stuff means using words

#

so for example, from that video

#

the rules are: when an object enters this bounding region, it experiences a force opposite of the normal of some ground plane "A" in it. when it is stationary against that ground plane, it continues to experience that force "A". when something collides with it, it stops experiencing force "A".

#

do you see how that doesn't really have anything to do with local space or transforms?

#

it's an illusion, based on the sequence of things that really happened, of "local physics"

regal olive
#

so i do have to produce a clone of unity's physics engine just to add a single attribute
Man

undone coral
#

it's not a clone of unity's physics engine

#

i think it comes down to understand what it means for something to be "attached" to something else in real physical terms

#

it will help you understand that doing what is in your image

#

requires calculating a force / change in velocity to create the illusion of something being "attached"

#

and nothing else

regal olive
undone coral
#

in the real world, you would achieve that illusion using a rigid object / attachment like a nail

regal olive
#

the only time its worked has been with using kinemtics

undone coral
#

right which is why you probably should get the asset

regal olive
#

which i shouldnt have to do

#

and by "using kinematics" i mean writing a physics engine with that one extra attribute
which sounds extremely inefiicient

undone coral
#

okay i think you'll figure it out ๐Ÿ™‚

#

you should watch this guillermo del toro short called Geometria

#

you remind me a lot of the kid in that movie

regal olive
#

lol

regal olive
#

accel seems to worrk correctly for first 2 timesteps, then breaks at 3rd timestep.

#

seems proportional to rotation of parent (rotation spd increased from 1 -> 5)

#

and ofc when rotation spd is 360, it does not break

sly grove
regal olive
#

i just tried ordering scripts
this did not work

sly grove
#

Yep, AddForce

#

or AddRelativeForce

#

ForceMode.Acceleration for simulating gravity

regal olive
#

what i get is this

sly grove
#

You did it wrong then

regal olive
#

almost as if its adding to the previous force in world space

sly grove
#

Yes forces are in world space

regal olive
sly grove
#

Unless you use AddRelativeForce then it's in the local space of the body

regal olive
sly grove
#

I don't understand what you mean

#

Can you explain what you're doing

#

Your picture is unclear

regal olive
sly grove
#

Meaning what

#

Back up

#

What is happening in your game

#

What are you trying to do

regal olive
# sly grove What are you trying to do

Hey guys!
Just a quick demo of the Local Physics grid using my Aurora MR
Most of the commentary will be in the annotations for this one!

Want to become a Star Citizen?
Enlist now! - https://www.robertsspaceindustries.com/enlist?referral=STAR-RN46-L2CJ

STAR-RN46-L2CJ - Use My Referral Code for 5000 Bonus UEC

System Specs
Intel Core i7 4790K...

โ–ถ Play video
#

forces calculated in local space
stay in local space

sly grove
#

You'd have to use multi scene physics or something

regal olive
sly grove
#

To separate the two physics simulatons

regal olive
sly grove
#

Or use a custom physics engine

regal olive
#

ive only seen physics scenes used to predict paths of objects, not to achieve different physics simulations in the same timestep

sly grove
#

It can be used for all kinds of things

regal olive
#

ive read the docs

#

Provides options for 2D and 3D local physics.

sly grove
#

That's how you use multi scene physics

regal olive
regal olive
#

there arent many examples to follow

#

only demos

sly grove
#

When you do difficult and unusual things sometimes you have to blaze your own trail

mighty cliff
#

Hey Guys, so i have a MAJOR game breaking problem with my automated system.
Essentially I have a system which chooses targets based on meeting a condition, and when your characters bar is full (read: ATB Bar), it performs the aciton on the target.
Now I started to implementing dying and reviving which removes/adds from the dead/alive list. It seems to be that the problem is that, in the course of someone being revived/died AFTER the vondition check for the action is performed, suddenly now the target is null and i hit the red error
Anyone know what I should do?

#

for context its a JRPG game system and each character ha this automated mode, so i think because theyre all separate, its causing the system break

sly grove
mighty cliff
#

no no removing form list

#

lemme grab the other stuff

sly grove
#

But idk you really need to examine which line the error is on and figure out which thing is null

mighty cliff
#

its the chosen target

sly grove
#

It's the same as any NRE

mighty cliff
#

so heres the check

#

Basically, in the first screenshot, you can see the TryTacticTargets(i), which finds which enemy is eligible for the action, then if your bar is full, do it, otherwise you go to the elseif() stuff. the break is at the elseif, where the ChosenTarget is null

#

i think its because theres a couple of instances (player heroes) doing this and someone is either dying/reviving and being removed from that list which checks target eligibility so by the time you get to the elseif(), the guy essentially vanished

#

so trying to figure out how to resolve it. like do i do the check later or something?

ruby lichen
#

I am having a problem with rigidbody2d gravity physics being super slow.
the camera size is set to a massive number. this makes the camera huge. a normal sized sprite is basically invisible on the camera so all the sprites are also huge. for some reason this causes gravity to be incredibly slow as the sprites have to cover a much larger distance as the ground is in terms of unity distance much further away
I am not allowed to change the size of the sprites or the camera size which is scaled dynamically based on the screen size. So I need a way to dynamically compensate for the large and changing scale of the scene which is dynamically generated from the scripts to make gravity work properly

sly grove
#

Changing the size of the sprites is the right answer though

#

And zooming in the camera

ruby lichen
#

i cant change either the sprites or the camera size, i need a way to compensate by changing the units of the scene or scale the gravity of the scene in a consistent way

sly grove
#

Why can't you change them

ruby lichen
#

not my part of the project, don't have permission

sly grove
#

What's not your part of the project

ruby lichen
#

the way the camera stuff and art works

sly grove
#

Also if that's the case, you talk to the person whose job is that part of the project

#

Anyway surely you can change the import settings of the sprites

#

You don't have to change the images themselves

ruby lichen
#

don't have time to change all that and a lot of things are dependent on it so i just need a physics based solution

#

the camera is required to be based on the screen height

#

so the sprites have to be the size they are

sly grove
#

It would be so much easier and faster to change the sprite import settings than some insane gravity manipulation code

ruby lichen
#

it would. but i can't

#

which i already stated

#

right now i am just setting the physics2d.gravity to -9.81f * screenHeight/4 to compensate because that is not really the solution i want

sand rampart
sand rampart
ruby lichen
#

Does anyone know how to compensate for my camera being scaled by the screen resolution as it breaks all velocity and gravity physics and my raycasts dont reach the right distances either? is there a way to make the world points scale with the camera?

regal olive
#

How to change the gravity of my scene?

fresh salmon
#

Not an advanced question
Not a code question
This can be done from the physics settings

fresh salmon
#

What's the type of scenePredictionPhysics

regal olive
#

for a new physics scene

regal olive
#

how to change g

fresh salmon
#

You have the answer in this screenshot, but that's for an entire scene

fresh salmon
#

I don't think it's possible

regal olive
fresh salmon
#

If these are not present in the docs, they're either read-only or not accessible, or not defined

fresh salmon
#

I don't know

regal olive
fresh salmon
#

Read what it says

regal olive
fresh salmon
#

Read what it says

#

Don't spam it

regal olive
#
Physics.autoSimulation = false;```
regal olive
#

how to parent scene to game objet

shadow seal
#

What?

drifting galleon
#

what?

tough tulip
regal olive
regal olive
#

How feasible is to make a script that would export everything inside a Unity scene as Unitypackage at runtime?

I was thinking about hiering a freelancer for that.

drifting galleon
delicate vapor
#

yeah, my bad just didn't know where to ask here or code-beginner channel

#

I need a roadmap to be a professional unity developer, instead of just watching random youtube tutorials for years now

drifting galleon
delicate vapor
drifting galleon
regal olive
regal olive
#

thy are used to separate physics simulations which isnt rly what im looking for

#

im looking for an option to make some of Physics attributes shuch as gravity local

#

or rotate a physics scene

#

idk

jovial totem
#

So. Say I had books in my game that has text and pictures. What would be the simplest way to display the book in-game? Is there a markdown plugin that allows images? Or should the books just be an HTML document that is opened using some sort of in-game browser which iirc exists

drifting galleon
jovial totem
sly grove
regal olive
sly grove
#

You're hoping for a quick and dirty solution, but it doesn't exist

regal olive
#

ik one way but you dont even need a physics scene for it
it involves using a proxy platform to calculate physics
you can do that without a physics scene, you just have to make sure the proxy system cannot interact with the master, which you can easily do by separating the rigidbodies from the master to use as proxy

drifting galleon
drifting galleon
sly grove
#

He wants not just local gravity but local momentum etc

#

It's not tenable with the basic system

drifting galleon
sly grove
#

It means if you shake the snow globe, it doesn't affect the snow insidy

regal olive
#

ye

sly grove
#

Two totally separate simulations

regal olive
drifting galleon
regal olive
#

you cant parent physics scenes to gameObjects

#

so how am i supposed to rotate it

regal olive
remote pumice
# regal olive ok but how do i rotate it

I may be wrong, I didn't mess around with PhysicsScenes, but I'd say you can't rotate it, a Scene doesn't have a position or rotation by itself, it's contents have positions/rotations.
That's my guess, i don't know if it's correct.
You could google for "Unity3D rotate PhysicsScene" or take a look at the Documentation if that functionality exists

regal olive
#

ive been on this case of physics scenes for a few hours now

#

i havent seen anything of the sort

#

๐Ÿค”

remote pumice
regal olive
#

i dont see why this is so difficult to implement

#

@sly grove doyou have any ideas

remote pumice
regal olive
#

default gravity is global not just for individual scenes but for entire projects
so ig there is nothing i can do about that

remote pumice
#

Did you try googling "Unity3D Custom Physics System"? Pretty sure you did, but still asking, I'm getting curious about this topic

remote pumice
regal olive
#

i was just wondering if that was the only way

#

custom physics seems to be the only way

#

it just seems extremely inefficient

#

i mean think about it

#

a clone of unity's physics engine, just to some make some of its attributes local

remote pumice
#

If you're not working with additive scenes, it's pretty straight forward, no need to "clone Unity's physics engine", just a simple assignment to a property when scene is loaded/unloaded

regal olive
#

physics scenes dont seem to offer anything that could possibly help solve the issue

#

other than being slightly more organised
the only thing ive seen physics scenes used for it

  • predicting physics
  • rigidbody collision groups
    nothing to do with local gravity/momentum
remote pumice
# regal olive wdym?

I still don't know if I so understand your end goal or why you're wanting to have a different physics system, but, again, let's say you're always having a single scene loaded, not multiple ones

regal olive
#

i sent a video of the effect um trying toa cheive

remote pumice
#

You'd just have
Physics.gravity = customGravity in your Awake and Physics.gravity = defaultGravity in OnDestroy

remote pumice
#

Looks like you just want your gravity to be another direction

regal olive
#

a physics subscene

#

that can be translated in a scene

#

without any effect on the object inside the subscene

#

the issue is that i dont know hwo to trnasform a subscene

remote pumice
#

That's pretty well manageable by setting Physics.gravity i think, but you'd have to handle the upwards direction of affected GameObjects yourself ๐Ÿค”

#

Anyways, I'm just continuing to make guesses without real knowledge of the subject, I'll stop cluttering this channel and hope that somebody with actual experience can guide you

regal olive
#

a subscene is not even transformable

#

gravity is global to all subscenes

#

why is this niche so underdevloped

#

not just in unity

#

in most game engines

shadow seal
#

I mean is it not as simple as having a trigger area, and OnTriggerEnter make gravity a high number, OnTriggerExit make it a lower number?

#

That's what I got from that video, it's just a trigger area where you'd set gravity higher on an object inside it

lavish lotus
#

That's what you need. Ditch the Unity gravity and make your own on all objects. I've done so on my player to be able to walk sideways on walls if I please.

modern patio
#

Anyone's unity hard freeze if you compile code while the visual studio debugger is attached?

regal olive
#

i dont want to apply custom gravity

#

more like

#

i want to transform a physics group of objects without the objects being affected by the transformations

frank ferry
atomic maple
#

hi hmm anyone know, how in PropertyDrawer to get a values from List, example for int i can do property.FindPropertyRelative("MagicNumber").intValue;

sage radish
regal olive
#

this is ridiculous

#

im not buying it

#

im not going to use a kinematic physics engine just to make a single attribute local
until ive exhausted all other possible options

#

@sly grove PhysicsScene can separate simulations but it cannot produce local simulations

#

im pretty sure

sly grove
# regal olive other than being slightly more organised the only thing ive seen physics scenes ...

apply your imagination to this... local physics simulation is perfectly achievable with it. But like most things in game development, you might have to use a little smoke/mirrors to achieve it. It's not going to just work out of the box how you want. You may need to simulate the physics "elsewhere" and apply the simulation results from "elsewhere" to the local motion of the objects in your ship for example

regal olive
#

the Proxy method

sly grove
#

yes

regal olive
#

thats the particular method im trying to avoid

sly grove
#

that's how i'd approach it

regal olive
#

bc its less efficient

#

than simulating physics

sly grove
#

less efficient than what?

regal olive
#

also

sly grove
#

The nonexistent thing

regal olive
#

it can be done without PhysicsScene

#

PhysicsScene just makes it more organised

sly grove
#

so why are you here asking us if you know what to do

regal olive
sly grove
#

clearly not

regal olive
#

oof

#

well, physics scenes will help with organisation a ton

#

you can keep all the proxies in a single coordinate without them interacting with each other

#

but its still less efficient than flat out physics calculation

#

Man

atomic maple
regal olive
#

im not sure about the validity of this statement tho

#

"Proxies are less efficient than Physics Calculation"

#

only one way to find out

atomic maple
#

so can i somehow cast property.FindPropertyRelative("IntList"). to a List<strings> or something like that

#

cuz this way i have to reacreate new list by itering with GetArrayElementAtIndex(index).intValue

regal olive
# sly grove so why are you here asking us if you know what to do

https://youtu.be/eQt7TwCr6ao?t=334 this is one of the biggest issues with proxies
Jittering caused by changing of physics calculation from global -> proxy

I finally decided to tackle some of the more complex issues I was having with multiplayer, and this is how it went...
Join the community on Discord: https://tomweiland.net/discord

Previous devlog: https://youtu.be/RmmLmc34O-U
Devlogs playlist: https://www.youtube.com/playlist?list=PLXkn83W0QkfmQI9lUzi--TxJaOFYIN7Q4

Further reading about client...

โ–ถ Play video
atomic maple
regal olive
#

i cant imagine making a sea game

#

and multiplayer

warm fulcrum
#

This is... mildly appropriate to the channel but does anyone know why the com.unity.nuget.newtonsoft-json package just doesn't work? It doesn't seem to add references to the solution and as a result does not compile

upbeat plaza
#

I just have a quick question. I'm just trying to press "D" and have unity Debug Log the letter "D", but it seems that depending on my framerate, Unity sometimes has a major delay or even skips the key press altogether. How can I mitigate this?

#

Basically I've got input lag. idk if it's an advanced issue or not, but this causes major problems like the player continuing to move when I let go of input

compact ingot
upbeat plaza
#

It's in regular Update() and I've commented out everything aside from the Debug Log statement. I would post my code but it seems this server doesn't want me to

#

If I press D when the screen is small, it happens almost instantly. When I press it on Maximise play, it takes up to a full second or sometimes does nothing

upbeat plaza
#

thank you

#

Actually that's a bit too partial

#

That's got the whole statement

compact ingot
#

that doesnt compile

upbeat plaza
#

It's missing the last }

#

sorry one second

compact ingot
#

where and how do you set STATE?

upbeat plaza
#

It's set in public and it's always set to 1. Nothing affects it currently

compact ingot
#

show code

upbeat plaza
#

What part of it?

compact ingot
#

all of it

upbeat plaza
#

Oh one sec

compact ingot
#

that code does not produce any input lag

upbeat plaza
#

Yeah it doesn't seem like it should. But on my end it's lagging

compact ingot
#

you are probably looking for the source of the problem in the wrong place

#

this code only manifests the issue, it is probably completely unrelated to the cause of it

upbeat plaza
#

Any chance my computer is just too weak?

#

It's a Macbook Pro with a uh
1.4 GHz Quad-Core Intel Core i5 Processor

compact ingot
#

too weak for what?

#

you aren't doing anything yet from the looks of it.

#

what frame rate do you get in the editor in playmode?

upbeat plaza
#

Where do I see that? Is there a stats button?

compact ingot
upbeat plaza
#

Yeah I fluctuate in the 80s and 90s

#

In Maximise it drops to the 30s

#

I'm sure I can find out how to optimise this, even if I just have a corrupt OS or something - but really I just wanted to know if there was a way to reliably do input that isn't affected by framerate. Because even if it runs well on my system I don't want the game literally glitching up at low framerates

#

nvm disregard I'll stagger into the winds and figure this out on my own after I take a walk

regal olive
#

@sly grove yh so after a while i finaly done it

#

it is messing with the velocity attributes a little but thats expected

upper mica
#

Hey does anyone know how I can fully restart my game? If I just do SceneManager.LoadScene(0); it will unload all active scenes and load my title screen... but when I load back into the other scenes, everything is broken, because serialized references in all my scripts are pointing to the old destroyed references from the unloaded scenes.

I tried manually unloading scenes with SceneManager.UnloadSceneAsync(scene, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects); but this did not solve the issue. I am stumped here, and every single google answer is the simple LoadScene method

jovial totem
#

How do I have multiple projects share code? Do I make my own package and host it somewhere?

undone coral
#

@jovial totem put it on github as a private package. you can develop it with a file:../Sibling-Directory path and change it to a git:... path when it's in good shape

undone coral
upper mica
#

wat. how do you make a large game and not use scenes

undone coral
#

nested prefabs have obsoleted scenes for all but extremely few cases

upper mica
#

first I've ever heard of this

undone coral
#

i say it a lot. search my name + scenes

#

you'll see

upper mica
#

ok... does anyone else say this, or is it just you?

undone coral
#

in 2022, with the industrial and publisher game development shops i know, they don't use scenes

upper mica
#

also, how are you supposed to do operations that rely on objects being finished loading in a prefab?
with scenes, you can subscribe to SceneManager.SceneLoaded

undone coral
#

you can use scenes or addressables for the narrow purpose of loading prefabs, but i wouldn't organize my game logically around them

#

besides, there's no game anyone is developing here that needs loading

#

only stuff that 100% will always be glitchy because it's too big for any computer, or 100% too small to matter

upper mica
#

Ive managed to iron out all bugs to do with scenes so far. This restarting thing is the first I've run in to that I cant figure out

undone coral
#

thats a lot of people's experience

#

"I do XYZ... and now W doesn't work at all with scenes"

#

it was never viable to rely on scenes to restart your game

#

nor to organize it from menus to levels or whatever

upper mica
#

appearantly not

#

thats why im trying to find a different solution

undone coral
#

sorry.

#

it's just how it goes

upper mica
#

yea, I dont believe that

#

considering you're the only person i've ever heard this opinion from

somber tendon
jovial totem
undone coral
undone coral
upper mica
#

I have gone through that thought process already, and no, I cannot load everything up front

undone coral
#

try building to standalone player

#

and see what happens

upbeat plaza
#

those are my stats

undone coral
#

yeah i'm surprised it works so poorly

upbeat plaza
#

Yeah idk what the issue is. I mean, my disk is kind of full - I've only got 9 GB left of storage on it

#

But doesn't this mean that if someone has a slow computer, the game will glitch up when they try to play it? In most games I play, the game simply lags. But here, it's like only the input is lagging, and that's causing major issues

somber tendon
#

It might be not the input that lags, but the debug.log itself, try making a text on screen and change the text based on your input

upbeat plaza
somber tendon
#

also, iirc there's a setting in macbook called "Slowkey" or something that delay the input, you might want to check it out if it's enabled

upbeat plaza
#

what

#

what kind of setting is that lol

#

where is it?

somber tendon
undone coral
upbeat plaza
#

Alright that wasn't the issue but thanks for letting me know about that because that was kind of funny

undone coral
#

maybe start with a fps example

#

like use an example project or an asset

#

or whatever it is you want to do

upbeat plaza
#

I'm almost positive it's a performance issue, because another person on this forum confirmed there was nothing wrong with my code and the response time gets faster and slower when I'm in maximise mode or not

somber tendon
undone coral
#

try a different project for now, see if anything opens on your computer

upbeat plaza
#

I'll do that

#

Yeah my hardware must be messed up or something. I made a new unity project with a scene that doesn't even have a camera in it- just an empty game object with this script attached to it:
https://gdl.space/erezogihep.cpp
And I'm still getting a little bit of lag

#

And its URP

jovial totem
remote pumice
#

Hey, can somebody enlighten me? I'm in a very weird situation with the Substring method.

I am extracting tokens out of a text. When there is only a single token in that text, Substring works fine, but any further calls throws me an ArgumentOutOfRangeException for unknown reason. I am definitely not mutating the string throughout my process.
I've tested with

Debug.Log(end <= text.Length);
var substring = text.Substring(0, end);

The Debug.Log gives me true in the Console Window, but the method call is still throwing an AOOR ๐Ÿค”

I can almost guarantee the error isn't on my side of the code, i have written my own GetSubstring method with 6 lines of code, passing it the same values as the original one, and it works perfectly, and I'm fine with using that instead, but I'm still curious to why that Exception would be thrown

Any ideas?

rotund dagger
#

I want to do whatever this video does

#

It explains what the code does quite clearly but it doesn't give any hint on how to code it

#

Can someone guide me to some tutorial that's on the same topic?

#

i.e. changing colors of the same objects via shader, with the help of GPU instancing, making it possible that all same meshes w/ different colors can be drawn in one batch

sly grove
alpine kindle
#

Hey guys is it true that you cant serialize references to scriptable objects?

#

If so how does the engine do it when you assign them from the inspector?

undone coral
#

it works like all the other unity packages

undone coral
alpine kindle
#

Nah using BinaryFormatters

#

I guess unity does use json though right? Or YAML

austere jewel
#

๐Ÿšจ Binary Formatter Alarm ๐Ÿšจ

alpine kindle
#

Haha i got the warning last week lol

undone coral
#

vary the color based on this node

alpine kindle
#

That JSON would be safer if the data structures were redefined

austere jewel
#

Unity uses YAML, and its serializer doesn't behave like other serializers you'll see

alpine kindle
#

Hmm I take it this means that I can't do this just because Unity does it ๐Ÿ˜ฆ

austere jewel
#

purely because it's got awareness of the C++ side of the engine that nothing else can see

alpine kindle
#

Ahh

austere jewel
#

Yes. If you want to serialize something for runtime you probably should avoid Unity Object types

alpine kindle
#

So say I want to store a list of starting units for the sake of saving a game and my units are defined by scriptable objects. Is my only option to store a list of those SO somewhere and serialize an index?

undone coral
#

if you need an X to later read an X, write it however is intuitive to you. then, if you need field X.Y, write field X.Y

#

in an hour everything will work because your game isn't complicated enough to benefit from generic serialization

#

even if you had 100 fields to deal with it'll take you 5 minutes to write the serialization and deserialization code

#

and maybe a total of an hour over the lifetime of the game to maintain it

alpine kindle
#

Yeah but I imagine there are risks here if those scriptable objects change

undone coral
#

your choices are thing that doesn't work versus thing that does

#

so what if they change

#

big deal. you know how to deal with it

#

just roll with it

#

it'll add up to an infinitesimally small amount of time

alpine kindle
#

Wdym? You'd have different values for the units that were loaded from the save and the ones that were created at runtime

undone coral
#

binary formatter won't work in that situation anyway

#

you need to TextWriter.WriteLine at this stage, or create a "data transfer object" (the correct answer)

#

create a "plain old csharp" class that works with JSONUtility to represent the save file

#

then copy the data you need to save into that class instance

#

write it to a file using JSONUtility.ToJSON

#

later, to load the save, use JSONUtility.FromJSON

#

then copy fields / objects from that simple class into your scriptable objects or whatever you have going on in your game

#

does that make sense? @alpine kindle

alpine kindle
#

Yeah but it's not really the issue I'm having, the BinaryFormater works in general it's specifically these scriptable objects that I need a solution for. I would have the same issue with text serialization

undone coral
alpine kindle
#

Yeah worst comes to worst i'll just go with the list. I feel like this is smt Unity should have a solution for though

jovial totem
jovial totem
# undone coral hmm it will compile

oh, i guess I need to make an asmdef file? ill figure out how to do that. Also, can I make unity make a csproj file for me so I can use Omnisharp

undone coral
#

for it to compile

#

carefully read the docs there

austere jewel
#

Packages do need assembly definitions too

undone coral
#

you will need to create a package.json in the com.... directory

#

yes it's all in the docs

jovial totem
undone coral
#

you'll figure it out!

jovial totem
#

oh, do I have to name the file com.slashscreen.openworldcommon

undone coral
#

it expects a version if you put the contents in a Packages folder

jovial totem
#

folder*

undone coral
#

all sorts of stuff are glitched

#

carefully read the docs

jovial totem
#

This was done by the package manager

#

hm

#
{
    "name": "com.slashscreen.openworldcommon",
    "version" : "1.0.0"
}
#

I did this

jovial totem
rotund dagger
#

I'm playing around and trying to learn about GPU instancing. Here I have a scene where I generate 10,000 balls in the scene, and for every 0.5 seconds, I randomize every ball's color.

#

Could someone explain to me, why is it slower when I tick the box before "Enable GPU Instancing" in this case?

jovial totem
jovial totem
#

alright, i made an asmdef and now it's giving me compiler errors which is good. Now I have to figure out how to get Omnisharp to work

#

next question: how can I include a dependency for my package that is a package that is added to Assets so it isn't included in the manifest? Im trying to use YamlDotNet

novel plinth
#

quite a broad of a topic, so yeah, you must do your own research on this

upper mica
#

Hey, I am looking to change the processor of on a binding in an InputAction, in an InputActionMap

one of these classes must have a method for changing the processors at runtime... anyone know where?

#

oh wait, maybe I can write a custom processor

undone coral
#

not the legacy render pipeline

#

use the geometry index i talked about...

#

if you want to render 10,000 multicolored balls used vfx graph

upper mica
#

omfg I think I finally fixed this issue

if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            InputActionMap playerMap = inputActions.FindActionMap("Player");
            InputAction ui_Navigate = playerMap?.FindAction("UI_Navigate");
            InputBinding leftStickWebGLOverride = ui_Navigate.bindings[0];
            leftStickWebGLOverride.overrideProcessors = "invertVector2(invertX=false,invertY=true)";
            ui_Navigate.ApplyBindingOverride(0, leftStickWebGLOverride);
        }```

might be a cleaner way to do this, but this works so...
#

also fixed my issue of references breaking on scene reloads.... turns out it was entirely due to static reference and events not being cleared. I changed a bunch of things that were unnecessarily static to non-static, and made sure to null out all my events OnDisable or OnDestroy

somber swift
crystal wasp