#archived-code-general

1 messages · Page 107 of 1

cold parrot
#

In unity it can make sense to make that interface an abstract class though since interface references can’t be serialized by unity

#

But you’d use it like an interface by convention

hearty sphinx
#

I can't remember exactly, but I got a problem when I used abstraction and solved it by using interface instead

#

Or vise versa

#

Can't really remember right now

cold parrot
hearty sphinx
#

I think it was that

#

What problems would I face if I just made Tile a class and included it as an object in other types ?

cold parrot
dense spear
#

hey guys!! I having some issue with a custom editor I made using the ui toolkit... so I am applying it on a scriptableObject script and when I click on one of the assets, I get this error:

The Error:

TypeLoadException: Could not load type 'EnumData.WildCardEvents' from assembly 'Assembly-CSharp'.
System.RuntimeTypeHandle.GetTypeByName (System.String typeName, System.Boolean throwOnError, System.Boolean ignoreCase, System.Boolean reflectionOnly, System.Threading.StackCrawlMark& stackMark, System.Boolean loadTypeFromPartialName) (at <890d6fe26e8c408ea64b353e791fafce>:0)

The Script:

    public override VisualElement CreateInspectorGUI()
    {
        Initialise();

        TreeSetup();
        
        return root;
    }

    public void Initialise()
    {
        EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
        root = new VisualElement();
        if(main_window_uxml == null || main_window_uss == null)
        {
            main_window_uxml =
                AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
                    "Assets/--DEBUG_AND_TESTING/Wildcard data asset/WildcardUI.uxml");
            main_window_uss =                 AssetDatabase.LoadAssetAtPath<StyleSheet>(
                "Assets/--DEBUG_AND_TESTING/Wildcard data asset/WildcardUI.uss");
        };
        
        main_window_uxml.CloneTree(root);
        
        _target = target as Wildcards_ScriptableObjects;
    }

I have an enum element in the editor which is "WildCardEvents" and its coming from a separate class called EnumData... I never had this issue before... I just discovered it this morning😐😐
Some guidance on this would be appreciated

lone umbra
#

I'm trying to draw a line between two UI elements (for a skill tree), I just cant get the position of the both UI elements right. Tried alot of things from Google but none seems to be working, when the debug it says the position of all the UIs are same (its not), what can I be doing wrong?

prime sinew
#

and what are you using to draw the line

lone umbra
#

I tried transform.position, rectTransform.position, rectTransform.rect.center and tried few other things things too like WorldToScreenSpace and stuff...

#

This is my line renderer

prime sinew
#

did you try.. rectTransform.anchoredPosition? @lone umbra

lone umbra
#

not sure, giving it a try

#

yeah just did, not working, shows all positions as 0, 0, 0

#

for all elements

prime sinew
#

can you show the inspector of the elements you're trying to draw the line between?

lone umbra
prime sinew
#

oh they're under layoutgroups..

lone umbra
#

they are in a Vertical Layout

#

yes

prime sinew
#

where are you getting the UI positions?

#

in Start? Awake?

lone umbra
#

well not in its own script, alot of things are getting called, drawing line is the last thing I'm doing, but it all starts from the Start of Game Manager

prime sinew
#

can you temporarily test this

#

basically make the Start a coroutine

#

and make it wait a frame

#

see if it says the position is something other than 0

#

yeah I just tested it. you need to wait a frame before the position or size of elements inside of a layoutgroup is actually correct

lone umbra
#

hmm thats not working for me, maybe because my items are dynamic? The script is spawning both the LayoutGroups and the items in them, so maybe I have to wait, after doing that?

prime sinew
#

maybe

#

you might need to use the forcerebuildlayout thing

#

i'm testing it on my end actually, but i havent worked with line renderer in a while, and having trouble getting it to draw

lone umbra
#

haha yeah, layout groups are so bad, some quality assets on store has that forcebuild added to their scripts I've noticed before

heady iris
#

is the problem that there's a one-frame delay before the layout group applies?

prime sinew
#

depends on what you mean by problem, haha

lone umbra
#

I think so, I've had alot of issues getting layoutgroups to act properly, specially if you are instantiating from code

prime sinew
#

it's kind of a quirk. it's weird

lone umbra
#

im waiting a whole sec still my points are same lol

prime sinew
#

i'm actually getting that issue too

heady iris
#

I've not had issues myself, hmm

prime sinew
#

it's different before I convert to world point

#

but after i convert, it's same

#

are you using a perspective or orthographic camera @lone umbra

heady iris
#

wait a sec

heady iris
#

are you using Camera.main.ScreenToWorldPoint

prime sinew
#

something about this, memxor. you need to add the z coordinate or something

heady iris
#

Z=0 -> every screen point is the same world point

prime sinew
#

yeah that

heady iris
prime sinew
#

it's got a nice interactive diagram in it

heady iris
#

ooh pretty diagram

prime sinew
#

yeah it's awesome

heady iris
#

it just needs an ortho camera example

lone umbra
#

but do we even need World Point? in this case?

prime sinew
lone umbra
#

Oh no, I made my own UI line renderer, it not Unity's Line Renderer

prime sinew
#

Ohhhhhhhh

heady iris
#

that works in the UI?

#

oh wait, duh, of course it does

#

because you called it the UI Line Renderer

lone umbra
#

Unity's Line Renderer Component doesn't work in the UI system... So, let's create one that does...

Interior Mapping Shader - https://www.youtube.com/watch?v=dUjNoIxQXAA
Photo Real Assets - https://www.youtube.com/watch?v=Y538_YYhC1A
Fixing Grid Layouts - https://www.youtube.com/watch?v=CGsEJToeXmA
-----------------------------------------------...

▶ Play video
heady iris
#

it better work in the UI lmao

prime sinew
#

well, i'm out of ideas. it's wacky perspective camera stuff

#

can't get the line to draw properly on my end

quaint crypt
#

I have a MonoBehavior script that subscribes to some actions of a ScriptableObject. Everything is fine, I press play, and when I stop the game view, I get an MissingReferenceException: The object of type 'MyScript' has been destroyed but you are still trying to access it. error.
Even though I don't destroy the game object anywhere. Is there a different object instance before I press play, and after the play mode ends?

PS: the error is shown after the event from the SO is fired again in the editor, meaning the script doesnt have access to the same isntance anymore i presume

thin aurora
#

@signal moon @lean sail I promised to create an example save system (#💻┃code-beginner message), here it is.

https://github.com/PillowCoding/UnityExamples-SaveSystem
The project contains a SaveManager singleton that keeps track of saving and loading. There is a sample scene with a manager that spawns random squares, and also a script that displays buttons, which calls both the singleton and manager to do stuff. Note I spawn the squares in 3d context and not in UI context so it might be weird. I'll change that later.

The idea is that SaveManager is informed of the stuff to save, and it will keep track of these references. When you tell it to save, it will collect all data to save, and save your Json at a location where it will persist (by default this is %appdata%\LocalLow\<company name>\SaveSystemExample (company name is probably DefaultCompany)). The same thing is done for loading.

Please note I whipped this up in the free time I had in the past 3-4 hours, so it is definitely able to be improved.
Feel free to fork, watch, whatever, this repo. Stars are always appreciated, especially since I aim to make that account more active in the future.

lone umbra
#

And also do a null check while calling your action

#

action?.Invoke();

quaint crypt
heady iris
#

what are you subscribing to?

#

show your code.

quaint crypt
#

the error comes if I do anything in MapGenerator (AFTER the game has stopped; when the event is fired) related to the instance of the object (GetComponent, or gameObject.GetInstanceID() etc)

#

If I trigger a rebuild (by changing a script), everything works again, until I enter and exit play mode

#

it's like the instance that subscribed to the event doesn't exist anymore

#

and the subscription happens in the editor when the application is not running

lone umbra
# quaint crypt

why are you unsubscribing and subscribing again in the same place?

thin aurora
#

Unsubscribing when nothing exists will not do anything. If they already subscribed they now make sure that they don't subscribe twice

#

A better question would be; Why is this done in OnValidate and not OnEnable/OnDisable?

steep herald
#

Can we bake navmesh based on colliders rather than renderers w/o the navmeshsurface component from the public repo?

steep herald
#

@steady moat Uses renderers in 2021.3.10f1. Objects w/o renderers but colliders enabled are ignored

swift falcon
#

i have a Cube IN a Cube how would i find that Cube that is IN the cube in a script

#

like this

#

how would i acces the teleportPoint

#

and the script is in Shrine

#

isnt there a way to like do gameObject.Find

thin aurora
#

It being a child of a parent object makes no difference

#

If you got a reference to the Shrine object, you can also do shrine.transform.GetChild(0)

swift falcon
#

oooo

#

okay

#

that is what i was looking for

#

thanks

thin aurora
# swift falcon thanks

Just remember this gets the first child, so if you have multiple things in there it's not guaranteed you get what you want

#

There are other ways of doing it, though

heady iris
#

I dunno when that feature dropped (vs when they switched from the repo to a package in the registry)

swift falcon
thin aurora
# swift falcon is there a way to get that child but with a name instead of an index

I guess something like this:

// You can use the methods `First`, `FirstOrDefault`, `Single`, `SingleOrDefault` and `Where` here.
// Note all these have different outcomes.
var teleportPoint = shring.transform.SingleOrDefault(x => x.gameObject.name == "TeleportPoint");
if (teleportPoint == null)
{
  Debug.LogWarning("Teleport point was not found.");
}
heady iris
#

I think you should set this up in advance

thin aurora
#

There are a lot of ways to do this

heady iris
#

Assign these references in the inspector before the game even starts

swift falcon
steep herald
thin aurora
#

x would represent a child in this case

heady iris
thin aurora
swift falcon
#

ok

thin aurora
#

The latter two are variants of a delegate

steep herald
#

@heady iris I do have experimental packages enabled. Any idea what the package name is?

heady iris
#

Look at the documentation for the older versions of the AI Navigation package

#

Experimental packages aren’t “enabled”; they don’t show up in the Unity Registry until you manually install them

steep herald
#

Unless they've recently renamed something experimental packages

#

This was named experimental package for as long as they've allowed access to it

#

Until up to 2021

#

And sure this allowed unity to list them via the package manager

heady iris
#

Huh. Maybe I’m wrong, then!

#

Anyway, check the docs

quaint crypt
quaint crypt
#

but in the editor, not the actual app runtime

thin aurora
#

Hmmmm

#

I haven't worked a lot with editor specific stuff but I would assume there is a better way to do this

quaint crypt
#

well, i've somehow figured out what happens, but unsure how to solve it. in the editor, there is one instance of my GO that subscribes to those events. when I press play, the same instance persists during application run, but is destroyed at the end of play, and OnDestroy gets called. Then as soon as the editor loads up again, onvalidate is called again and it resubscribes again, but the old subscription is still there for a GO that was destroyed. problem is if I try unsubscribing during OnDestroy it doesn't seem to want to unsubscribe for some reason

signal moon
thin aurora
# signal moon I'll check it out in a second, also to the questions in <#497874004401586176>. n...
  1. GameManager is a singleton here. Look for spots in it where _instance and Instance are used, because these are the parts that involve the singleton here. To put it simple, a singleton is an instance of something that is expected to only exist once. Basically the same as static, but the singleton has more functionality (such as existing as a gameobject).
  2. You were using json with JSONUtility. This is very bad because it sucks really bad, and has a lot of limitations. Matter of fact, if I used it in the example project, I would get empty json back and it would not work. I use Newtonsoft instead, and this is actually added to your project by default with the latest LTS version. Perhaps they know JSONUtility sucks?
  3. You can view how I used my json in SaveManager. Look for JsonConvert and everything around it.

I also used JContainer, which is something special. This is something from Newtonsoft and if you deserialize something without giving a proper class to deserialize in (or in my case I used object which does the same thing), it will deserialize it into something that inherits from JContainer.
Depending on the type, it will be either:

  • JToken, for objects.
  • JArray, for collections.

Since you would want to support both, and since both inherit directly from JContainer, I used JContainer here.
You also got JToken, which JContainer inherits from. You can also use this.

#

It's quite a big topic, so I suggest you google what most of those things are. It's very (very!) useful to know how this stuff works.

#

Feel free to ask questions regarding the repo

signal moon
#

downloading 16f1 xD

thin aurora
#

You should be able to fork the repo and then open it in that version, but I never looked to deep if anything else is needed

quaint crypt
#

is there a way to hook into the creation of MonoBehavior GO's at editor time? clearly an object is created then as well. start / awake only execute on playtime.

quartz folio
glacial lion
#

my instantiated objects aren't showing up at runtime

#

they appear in the editor but they don't in the game view

#

oh my god nevermind i think i fixed it

#

the z axis was at like -311 i may be stupid

signal moon
#

also almost everything in the GameManager is gibberish to me

thin aurora
thin aurora
#

If you mean SaveManager, then I'm not sure what's so scary about a file that's 121 lines, because that's very small

signal moon
#

it's more the code in those 121 lines

thin aurora
#

Well, if something confuses you, you can ask me

#

I didn't comment that much because it's self explanatory really

signal moon
#

like I've used an interface once by just following a tutorial

#

what is TSaveable?

thin aurora
#
public void Register<TSaveable>(TSaveable saveable)
  where TSaveable : MonoBehaviour, ISaveable
{
  ...
}

This is a generic type parameter. the where part under it is related to it.
Basically I do not have a specific type to pass for saveable, because whatever must be saved must be both a MonoBehaviour and it must implement the ISaveable interface, By specifying a generic type parameter (which is the <TSaveable> part), I tell the method that it must somehow satisfy that, and you can then use that in the method (in my case I used it for the saveable parameter). You can also name it differently, but usually it is prefixed with T, and I considered this most informative).

#

saveable will also have all properties, fields and method that exist in MonoBehaviour. I don't really use it here except for saveable.Key which exists in ISaveable, and saveable.name which exists in MonoBehaviour.

#

This assures that whatever is added to the list in that method is valid. I could also just have object saveable as a parameter, but then there is no way to make sure that it is a MonoBehaviour, nor if it can save at all.

signal moon
#

but then you can only save monobehaviors

thin aurora
#

You could remove that constraint, I don't think I have any specific reason as to why only those are allowed, other than displaying the name of the object

#

Then the only constrain is ISaveable and you could change the method definition to public void Register(ISaveable saveable), because that all fits inline now and a Generic type parameter is not required.

#

I guess I did it because I don't see a specific reason why non-Monobehaviour instances should be saveable, but it really does not matter

signal moon
#
public class RecolorData
{
    public Texture2D InputTexture;
    public Material OutputMaterial;
    public List<Color> Colors;

    public void CreateMaterial()
    {
        //some code idk
    }
}

if I have this simple class and I want to save instances of this class in JSON, how would I go about it with this system

thin aurora
#

As it is right now, it expects a manager that implements ISaveable, and this should fill your RecolorData class when ToSaveable is called.

#

You then use Register from the SaveManager and register this manager so the SaveManager knows it has stuff to save

signal moon
#

it's just that I have no idea how to use it

thin aurora
#

Good luck figuring it out 😛

#

Saving data also has many ways of working, this is just something I came up with and whipped up real quick.
I mostly like it because the savemanager can keep track of what to save, and there's no need for events and all that

#

I only dislike the JContainer stuff, but oh well

swift falcon
#
NodeObjectTransform.GetComponent<MeshFilter>().mesh = Resources.Load<Mesh>("Cube.001");

makes the mesh filter a "None" and ofc makes the object invisible? this is how you change the mesh isnt it?

knotty sun
swift falcon
#

wasnt sure if the line was right or not with syntax

knotty sun
#

code is fine

swift falcon
#

I have a folder called 'Resources' with the mesh but not actually sure if that is how you set it up

knotty sun
#

screenshot the folder

swift falcon
knotty sun
#

looks ok, screenshot the inspector for Cube.001

hexed pecan
#

What kind of file is Cube.001?

swift falcon
hexed pecan
#

Unity treats 3D files as gameobjects

knotty sun
#

not a Mesh then

swift falcon
#

ah

#

does it need to be .obj?

hexed pecan
#

So you have to load it as a GO and get its MeshFilter.mesh

swift falcon
#

thank you

swift falcon
hexed pecan
#

Like what is your script

swift falcon
#

its just that the script doesnt change it

hexed pecan
#

What is your script though

swift falcon
#

for loading the asset?

#
public void GrabResource()
    {
        ResourceAmount-=1;
        if(ResourceAmount <= 0)
        {
            NodeObjectTransform.GetComponent<MeshFilter>().mesh = Resources.Load<Mesh>("Cube.001");
        }
        Debug.Log($"ResourceAmount: {ResourceAmount} Node: {NodeObjectTransform.name}");
    }

it was this

knotty sun
#

look at your code
you are saying Cube.001 is a Mesh so load it. But Cube.001 is not a mesh it is a GameObject

hexed pecan
#

Again, you need to Resources.Load the FBX as a GameObject

#

Then access the MeshFilter.mesh of that loaded GameObject

swift falcon
#

it's a gamejolt?

#

it says its a Mesh

#

gameobject* not gamejolt

hexed pecan
#

If its an FBX then unity treats it as a prefab

#

So a gameobject, yes

swift falcon
#

isnt the cube different from the actual fbx

hexed pecan
#

Yeah you actually need to access its children if im not mistaken

swift falcon
#

so me saying ""Cube.001"" it cant see that?

#

cuz the inspector of that obj says its mesh

hexed pecan
#

Load BrokenStone or whatever the root object is called

swift falcon
#

it doesnt look like a stone i know xdd

#

can you say "BrokenStoneResource/Cube.001"

#

ah nvm it worked anyway thanks

#

"BrokenStoneResource/Cube.001
would that work too or no

hexed pecan
swift falcon
#

and i thought i couldn't reference the stone thingy since it was a gameobject

#

so why did that work now lol

hexed pecan
#

You can reference GameObjects just like any other objects/assets

swift falcon
#

yeah but when we tried last time it didnt do anything

#

i just re imported it

#

lol

thick socket
#

Been coding for like 2h without being able to test...lets see how buggy this is lol

swift falcon
#

oh god

#

ya know (this is off topic) but i had a MySQL database and the trigger added a different record from a completely different database

#

how does that work lol

heady iris
#

boing

#

new emoji, nice

#

i thought this was an evangelion reference for a second

swift falcon
#

haha

thick socket
#

3 bugs down

#

idk how many more to go 😭

#

5 bugs

#

please let it stop lol

#

whats the best way to remove multiple Items from a list?

#

issue Im finding is if I do

itemVEList.RemoveAt(0);
#

then the index of all the others I found is now off by1

prime sinew
#

Iterate through the list from the back with a reverse for loop

potent sleet
#

if you type forr in VS

#

should give you a snippet for reverse loop

thick socket
#

maybe 8th time is the charm 😭

wide terrace
thick socket
#

I'm having to remove some items to not break a sort and then adding bak in

#

9th time, Im sure this one is the charm

fervent furnace
#

interesting problem
i come up with a two pointer algorithm
first you need a O(1) lookup table to check if the index is "dirty" (needed to be removed)
a pointer goes from forward and a pointer goes from backward
if forward pointer meets dirty element, then decrease the backward pointer until it meets a non dirty element (now the lookup table mentioned on above for O(1) checking), remove as swap "back"
O(n) algorithm but ofc you need O(n) space

thick socket
#

I meant 10th time is the charm?

cosmic rain
plucky parrot
#

hello there, i am back and i am now trying the solution you provided, but i have a small issue with this, and that is, that when i exit the game (from the editor) i get these errors:
these come from this part of the code:

    async void Receive()
    {
        if (socket == null || socket.Available < 0) return;
        byte[] buffer = new byte[bufSize];

        // this line right here -- the above check is apparently not working
        await socket.ReceiveFromAsync(buffer, SocketFlags.None, epFrom);
        Debug.Log("Received: " + Encoding.UTF8.GetString(buffer));
    }

is there any way to check if it is disposed before accessing it? thank you very much!!

#

oh wait

#

i just noticed the < instead of <=

#

dang im an idiotXD

#

anyways it seems that correctly checking the Available property is enough

thick socket
#

Gotta love when the entire day just feels like you are doing bug fixes

swift falcon
#

my teacher wants me to use the GUI c# for the ui "canvas" and it feels painful

#

xD

#

it feels like a crappy thing to use

heady iris
#

you mean the immediate-mode stuff done in OnGUI?

swift falcon
#

yeah that

#

lol

#

i get its for debugging but it looks ugly lol

vestal summit
#

Yo!
I'm trying to make a system where whenever I hover on a UI a panel shows up and follows my mouse until I unhover the UI. But there's a problem. I tried to make the panel follow the mouse by doing this but it goes off the screen.

ionic path
#

is there an equivalent for the new input system for Input.GetAxisRaw() ?

quaint crypt
plucky parrot
#

how can I use that to read the values from the byte array got from the ReceiveFrom method?

#

oh wait i think i got it

#
        byte[] buffer = new byte[bufSize];
        BinaryWriter binWriter = new BinaryWriter(new MemoryStream());
        binWriter.Write(buffer);
        BinaryReader binReader = new BinaryReader(binWriter.BaseStream);
        byte packetType = binReader.ReadByte();
        switch (packetType)
        {
            case 0:
                // ... handle connection
                string name = binReader.ReadString();
                // ... etc
                break;
            case 1:
                // ... handle message
                string message = binReader.ReadString();
                // ... etc
                break;
            // ... etc
        }

can that be optimized? 🤔

dusk apex
#

Optimized or refactored? And is it an issue or are you simply wanting to prematurely optimize?

river kelp
#

I'm trying to disable a field in the inspector for my component depending on whether or not a checkbox is checked. As an example, think disabling the "movement speed" slider if the "moves" checkbox is off. I can't find the attributes to let me connect to fields like this though

#

But I see some unity standard components have this behavior

dusk apex
#

Custom Editor

river kelp
#

Ah so I can't just attributes

dusk apex
river kelp
#

Thanks

swift falcon
#

did unity ever support python?

plucky parrot
swift falcon
#

posting a video of the issue I had with my VR hand rotation.

            Quaternion rotation = controller.rotation * Quaternion.Inverse(transform.rotation);
            rotation.ToAngleAxis(out float rotationDegrees, out Vector3 rotationAxis);

            Vector3 angularVelocity = Vector3.ClampMagnitude(_angularSync * rotationAxis * Mathf.Deg2Rad, Mathf.Pow(rotationDegrees * Mathf.Deg2Rad, _angularPower) / Time.fixedDeltaTime);
            _rigidbody.angularVelocity = angularVelocity;

still no idea what's wrong with it

#

everything is fine but at 90 degrees on each axis the hand does a 360

#

OH

#

3 days later I found it

#

I attempted reversing the rotationDegrees if it has gone over 180 but I also needed to reverse the axis

            if (rotationDegrees > 180)
            {
                rotationDegrees = 360 - rotationDegrees;
                rotationAxis = -rotationAxis;
            }
#

now it works perfectly

void basalt
#

You're eventually going to need to write an actual RPC system to handle calling functions over a network.

#

You can do it very easily with reflection.

hexed pecan
junior vapor
#

hello, im struggling with ontriggerenter and ontriggerleave at the moment. I have included the script below but basically, i want to have abovePipe be set to false unless the player enters a specific collider and if they are in that collider, they can press r to rotate. Everything else in the script is working currently except for the fact that abovePipe is always true even when i first spawn in the scene and haven't entered the trigger. Is anyone able to help me figure out how to fix this?

public class rotate_script2 : MonoBehaviour
{
    public int rotateDegrees;
    public int rotateTarget1;
    public int rotateTarget2;
    public bool correctPosition = false;
    public GameObject pipe;
    public bool abovePipe = false;

    void OnTriggerEnter (Collider coll)
    {
        abovePipe = true;
    }

    void OnTriggerLeave (Collider coll)
    {
        abovePipe = false;
    }

    void Update()
    {
        if (abovePipe == true)
        {
            if (Input.GetKeyDown(KeyCode.R))
            {
                Debug.Log("WOW");
                transform.Rotate(0,rotateDegrees,0);

                float yRotation = pipe.transform.eulerAngles.y;

                //check whether the y angle of the game object's rotation vector is equal to the rotationTarget.
                if(rotateTarget1 == yRotation)
                {
                    correctPosition = true;
                }

                else 
                {
                    if(rotateTarget2 == yRotation)
                    {
                        correctPosition = true;
                    }

                    else
                    {
                        correctPosition = false;
                    }
                }
            }
        }
    }
}
#

(if this is the wrong channel, please direct me to the right place to ask this)

warped quartz
#

Did you put a debug log message in OnTriggerEnter? I'm guessing that it's being called and set constantly.

#

OnTriggerEnter will be called for any collision, so to set the flag you want you need to filter the collider you are colliding against to the type you want

junior vapor
#

yeah it's being called when the scene starts

junior vapor
#

if you are able to explain that is, if u cant its ok

warped quartz
#

You need to set something on the other collider that the other game object is attached to that will indicate it's the type of collider you care about. You can use a tag or a layer.

#

Then when you get the OnTriggerEnter you check for that tag or layer before setting your flag

junior vapor
#

right now i was planning on using the same script and attaching it to several objects

warped quartz
#

Ah so this script isn't attached to your player

junior vapor
#

no its on an object

warped quartz
#

It's attached to your objects, but accepts input.

#

You don't need to have multiple scripts then

#

The collider you are interested in is the one on your player.

#

So you need to add your player to a layer or add a tag to your player, then check for that.

junior vapor
#

(for context, this is what the box is like out of play mode

junior vapor
#

after right?

warped quartz
#

It would be something like this in both enter and exit:

if (coll.gameObject.tag == "Player") {
  abovePipe = true;
}
#

You have to check that you are entering a collision with the player on enter before setting the flag, then again check that you are exiting a collision with the player on exit before resetting the flag.

junior vapor
#

okay that fixed so that it isnt always true, but now its not turning true at all lmfao

    void OnTriggerEnter (Collider coll)
    {
        if (coll.gameObject.tag == "Player")
        {
            abovePipe = true;
        }
    }

    void OnTriggerLeave (Collider coll)
    {
        if (coll.gameObject.tag == "Player")
        {
            abovePipe = false;
        }
    }
warped quartz
#

Do you have the tag set on your player GameObject?

junior vapor
#

yea

timid crater
#

Hello, how to detect that a button is being held down instead of a single tap in unity's new input system? ( Not the hold interaction)

junior vapor
finite coral
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

finite coral
#
float doesSpawn = Mathf.PerlinNoise(x + transform.position.x + chunkGen.seed, z + transform.position.z + chunkGen.seed);
                float whatSpawns = Mathf.PerlinNoise(x + transform.position.x + (chunkGen.seed * 5), z + transform.position.z + (chunkGen.seed * 3));
                whatSpawns = whatSpawns * chunkGen.trees.Length;
                whatSpawns = Mathf.RoundToInt(whatSpawns);
                GameObject current = Instantiate(chunkGen.trees[(int)whatSpawns], new Vector3(x * (128 / chunkGen.chunkResolution.x) + transform.position.x, y + transform.position.y, z * (128 / chunkGen.chunkResolution.y) + transform.position.z), Quaternion.identity);
                current.transform.parent = transform;

i have made this code that generates trees with my terrain generator but it generates so many and i dont know why

#

all my values are correct

primal wind
#

you're not checking if a tree should spawn or not, you're spawning them no matter what so it makes a grid of them

finite coral
#

yes right now it makes a grid of them im just getting the basics down so i can build on it later

craggy totem
#

hello, how can i assign this null. for example to script's GameObject ,thx

somber nacelle
#

wdym by "to script's GameObject"? that MyGarageCars class isn't a MonoBehaviour, is it?

craggy totem
#

yes it is monoBehaviour

leaden ice
craggy totem
#

and is it normal to left it null, at end i want to save this garage list to Json file but it always empty

somber nacelle
#

then you're doing it wrong. you should be using Instantiate or AddComponent to create instances of MonoBehaviours, you should not be calling its constructor

#

pretty sure you also can't serialize a monobehaviour to json

finite coral
finite coral
#
float doesSpawn = Mathf.PerlinNoise(x + transform.position.x + chunkGen.seed, z + transform.position.z + chunkGen.seed);
                if(doesSpawn > chunkGen.treeThreshold)
                {
                    float whatSpawns = Mathf.PerlinNoise(x + transform.position.x + (chunkGen.seed * 5), z + transform.position.z + (chunkGen.seed * 3));
                    whatSpawns = whatSpawns * chunkGen.trees.Length;
                    whatSpawns = Mathf.RoundToInt(whatSpawns);
                    GameObject current = Instantiate(chunkGen.trees[(int)whatSpawns], new Vector3(x * (128 / chunkGen.chunkResolution.x) + transform.position.x, y + transform.position.y, z * (128 / chunkGen.chunkResolution.y) + transform.position.z), Quaternion.identity);
                    current.transform.parent = transform;
                }

thats the code it shouldent be happening

craggy totem
hollow stone
#

Is it possible similarly how you can use [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] or [RuntimeInitializeOnLoadMethod] to reset values for statics, to have some registered method for SOs?

cerulean oak
#

is there any way to make an awake method trigger before another awake method? Both of them are on the same object, and will always be

#

however, if the ordering of the components is the way to do it, it doesnt feel like a great way

#

another option is just having a component that triggers the awake methods (no longer awake methods) instead of letting unity do it

#

(also yes im aware of awake/start, but I need awake)

somber nacelle
cerulean oak
#

yeah, I have like 4 layers of it

#

so start/awake is not enough

#

(is it bad design? maybe xd)

#

server auth -> database retrieving data -> data manager (local data)

#

then the rest of the app is initialized on the Start method, retrieving the data from the DataManager

heady iris
#

maybe you should use events instead

#

especially since I bet some of this stuff will take a non-trivial amount of time, and you wouldn't want to block the main thread

cerulean oak
#

yeah probably

tiny orbit
#

I am running into stack overflow issues, although my function does have an exit condition and is able to get very close to the exit before overflow occurs. Does Unity/C# have tail call optimization? Or does anyone have any general tips/ideas for avoiding stack overflow exceptions?

heady iris
#

I don't believe there's tail call optimization, no.

odd creek
#

if it's a recursive call, can you cache the results?

heady iris
#

dynamic programming time!

winged mortar
tiny orbit
#

I just had the function wait a frame every 10 calls and that seems to have solved the issue, i guess its able to clear some stuff off the stack?

tiny orbit
tiny orbit
odd creek
winged mortar
#

Alternatively

#

You could rewrite your recursion bit to use a while loop

#

And track the state manually

#

(make your own stack)

tiny orbit
#

the function is quite large, im afraid tracking manually or trying to cache the results would be a massive undertaking

heady iris
#

a stack frame is created when you call a function and the frame is destroyed when you exit the function

#

that's it

tiny orbit
#

why would waiting a frame stop the overflow from occuring then?

heady iris
#

some other factor is causing it

tiny orbit
#

ok, so lets say I know how many recursion calls im going to make, lets say 100. Is it possible for me to somehow split that up on the stack in segments?

#

or the first caller can never finish until all recursive calls are computed?

cursive gorge
#

How do I run a function from different object when object x is ontriggerenter

rain minnow
tiny orbit
#

Maybe i dont really need to be using recursion?
lets say there are global variables totalRecursiveCalls and recursiveCount and a function called FunctionA(bool firstTime).
FunctionA(bool firstTime) doesnt return any values.
If FunctionA() is being run for the firstTime, it will calulate totalRecursiveCalls and set recursiveCount = 0
The last bit of FunctionA() is:

FunctionA(false);
}```
Can I achieve this functionality without recursion? It seems the first call of FunctionA() should not need to remain on the stack, as it is not waiting for any return values from the recursive calls... It seems like there must be a way to do this but I am too dense to see it
wide terrace
#

I don't really understand what you're describing there... or how pre-calculating the number of recursive calls you'd need to make will change anything, if you're just going to go ahead and recurse that many times anyway? 🤔

wide terrace
# tiny orbit ok, so lets say I know how many recursion calls im going to make, lets say 100. ...

Just spitballing, but you might be able to move whatever logic and variables possible prior to/in between recursive calls to one or more separate methods, such that only the data needed to perform the recursive calls or return a value from it is present in the actual recursive method. In this manner, all of the supporting data would flick on and off the stack instead of hanging around and waiting for their respective recursive call's stack frame to pop... Not that I have any idea how that works with C# GC.

This only really seems like it might be a plausible solution if you're allocating massive amounts of memory per recursive call though - if the problem is more the amount of recursion, it's unlikely to change anything.

#

It still sounds like a greater rework may be the best solution

tiny orbit
#

I mean yeah, I reckon I could technically run 1 function to determine the “totalRecursionCount” and then just run a for loop which would loop that many times and run the function each time, but this wouldn’t reduce the size on the stack either… correct?

wide terrace
#

Assuming you only store the state required to get from one call to the next outside of the function in question, I would think it would, to the same effect as breaking up the recursive function into smaller supporting functions - generally just clearing all of the stuff off the stack between calls which was just used to calculate arguments or return values.

But that may or may not make a real difference, depending on how much persistent state you actually need... I'm finding it really difficult to think hypothetically - it's been a while since I've used much theory 😅

dusk apex
#

If there's a different issue, none of the above would help. But generally, you could avoid recursive call stacks by simply using a loop. Else, I'm assuming you're simply using too much or have got some undefined behavior causing it to not properly terminate.

tiny orbit
#

I am sure that it’s properly terminating, it’s just that when I have to run the function a lot of times it takes up a bunch of memory

wide terrace
dusk apex
#

And the code.

tiny orbit
#

I mean I could show the code but it’s thousands of lines

#

If the exact error would help I can do that as well but I was trying to simplify the problem by speaking theoretically

dusk apex
#

The recursive issue couldn't have been a thousand lines, could it?

dusk apex
dusk apex
#

Maybe figure out why it's happening rather than try to bandaid it.

tiny orbit
#

I want to be able to reduce the size I’m putting on the stack by breaking it up but I’m still unsure if that’s possible

dusk apex
#

Just to be clear, it won't matter if it's infinite or near infinite. I pray your stack eventually ends.

tiny orbit
#

No it’s about 100 calls

odd creek
#

Are those 100 calls all recursive? like call 1 cannot execute until call 100 does?

tiny orbit
#

No

tiny orbit
#

The very last thing call 1 does is call itself, but it doesn’t need any return values from that call

tiny orbit
odd creek
#

oh well that's still a recursive call lol

#

if you do it that way then call 1 will still be on the stack until call 2 finishes which will still be on until call 3 finishes etc

odd creek
#

why not just call the thing 100 times?

tiny orbit
odd creek
#

that way only one call will be on the stack at any given time

wet yacht
#

Hello, I'm trying to make a game where The player can move backward, forward, and jump in a 2D Space with an Orthographic camera.
I tried A lot of ways to make it work, but I always get to a dead-end, and I need help.

tiny orbit
dusk apex
#

It'd just be a loop, which has been mentioned multiple times now.

tiny orbit
dusk apex
tiny orbit
#

Ok cool

odd creek
#

implementing it depends on whether or not your stopping condition is dynamic

tiny orbit
#

No the stopping condition is determined during the first call

odd creek
#

okay then shouldn't be too bad

tiny orbit
#

Well it will be a little weird because I use IEnumerators to (in some circumstances) add pauses between calls, so the for loop will have to be in an IEnumerator but that shouldn’t be a problem…

shadow hearth
#

I’m having problem with my movement whenever the player rotates they start moving all across the place

somber nacelle
shadow hearth
#

Sorry

inner yarrow
#

This isn't a big deal as I don't require it, but is there anyway to initialize what the default for something like this is?
Material activeMat = Resources.Load<Material>("Assets/Materials/BatteryActiveMat.mat");

#

I am aware that I can just initialize it in awake or start, and that I can simply drag in the materials I want and make a prefab, but this would just be a bit nicer imo.

somber nacelle
#

well for one, Resources.Load won't work with that argument. the material would need to be inside of a folder named Resources which would be in the Assets folder, and you'd only include the path to the file omitting the base Resources/ folder and the extension.
but also no, you won't be able to assign it in a field initializer. you could serialize the field and assign it using Resources.Load in Reset() which would get the material and assign it to your field whenever you reset the component or add it to an object using the editor

spare spruce
#

hi everyone. I need help with a problem which solution i can't figure out, I have two gameobjects with the same script, that script has an if statement that should execute it's else if statement depending on the value of a public boolean, so when the public boolean is checked, the if statement executes and does thing 1, and when the public boolean is unchecked, the else if executes and does thing 2, and I want gameobject 1 to do thing 1 and gameobject 2 to do thing 2, but sometimes the if statement executes when it does not have to, and sometimes it works fine, and the same with the else if statement, how do i fix this?

lean sail
#

plus this seems more like a beginner question

#

this is also a #💻┃code-beginner but yes u do need the players location to have something look at the player..

tired ivy
#

mb

clever canopy
#

is it normal when you create new c# script and in visual studio it resets to miscellaneous files

cosmic rain
tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

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

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

swift falcon
#

When I run these event handlers it only prints the "nodeIndex" on every second click, so the first click it prints "someth clicked" empty, then it will print whatever was clicked, if i click something else it will say the last thing clicked and if i click again then it will say what i clicked then?

    private void NodeObject_TownHallClicked(object sender, EventArgs e)
    {
        Debug.Log("Hall Clicked: " + ResourceNodeIndex);
    }

    private void NodeObject_ToolShedClicked(object sender, EventArgs e)
    {
        Debug.Log("Shed Clicked: " + ResourceNodeIndex);
    }

    private void NodeObject_StoneResourceClicked(object sender, EventArgs e)
    {
        Debug.Log("Rock Clicked: " + ResourceNodeIndex);
    }
#

I feel like I've done something stupid lmao

swift falcon
#

(fixed for now)

restive dirge
#

Hi guys when i try to export my project to android studio "libil2cpp.so" file is going missing in the jniLibs folder, as a result the build is crashing anyone faced similar issue , and does any one have any solution for this?

cosmic rain
restive dirge
#

build is crashing

cosmic rain
#

Im not 100% sure but is it even supposed to be included in the build?

restive dirge
cosmic rain
#

Do you have the C++ workload installed in visual studio workloads? I know it's needed for normal IL2CPP builds, but perhaps it's also required for export to android studio

restive dirge
cosmic rain
#

Also, what do you have the scripting backend set to in unity?

restive dirge
#

its il2cpp

knotty sun
#

I'm a little confused, what do you mean by 'export my project to Android studio'? As far as I am aware there is no such functionality

restive dirge
knotty sun
#

As I said, there is no such functionality to do that in Unity

restive dirge
#

There is, you can export you projects in android platform

#

and you can open them in android studio

knotty sun
#

show me

restive dirge
#

@knotty sun

cosmic rain
#

I've never used it myself, but it has its uses.

restive dirge
#

yes

knotty sun
#

I stand corrected, you learn something every day. I've never even noticed that option, I just build the apk and load that into AS

clever leaf
#

Hey, I can see that Easy Save 3 is on sale. Has anyone used it and can say if its worth it? Because from the documentation it just does not seem like its worth the price to me. Does it simply work like it can dump entire gameobjects/prefabs into a file?

cosmic rain
knotty sun
#

@restive dirge It looks like in 2020 Unity does not create the il2cpp.so. It outputs a complete source project so you have to build the .so yourself

restive dirge
#

yeah

#

am on research doing so , currently dont know to build .so will try to find it out

knotty sun
restive dirge
#

ok will try that 👍

#

thanks man

knotty sun
#

np. it is odd behaviour, i dont know why they changed this from 2019

dapper sparrow
#

hello ! Is the "instantiate" command also duplicates the 2D texture of the object and preserves its UV coordinates so that when I setpixel on the original object, the texture of the new one does not change?

knotty sun
#

I think you will find that although the Material is instanced the underlying Texture is not

cosmic rain
spring basin
#

Hello, how do you people fetch the current time and cache for hourly rewards and what not? I do not want to record the local time as it could be tampered with, so are there any APIs that you use the record the current timestamp? I was previously using a plugin which used http://worldclockapi.com/api/json/est/now but it no longer seems to be working. Any ideas?

winged mortar
#

Above can still be tampered with

#

You need some form of user authentication + a database that tracks when they last requested their rewards

old nymph
#

Hi, I'd like to ask is there any way to increase a rigidbody moving speed without affecting its destination? I'm shooting projectiles to input mouse position using projectile motion, everything is nice, the angle, the curve,... but not the speed, I want to move faster or slower.

ashen yoke
#

physical projectiles fall at fixed rate defined by gravity, if you change velocity you overshoot undershoot the only way to compensate for that while using physics is to adjust the aim

old nymph
#

I guess I need to find other methods to shoot projectile to achieve it. Thanks 😄

ashen yoke
#

you could write some formula to compensate for speed adjustments, but i dont know how complex that would be

cosmic rain
#

Changing gravity is another option.

ashen yoke
#

true

stuck glacier
#

where can i find unity documentation for the new input system? specifically for InputSystem.SetDeviceUsage?

old plinth
#

I make games that use a console, like Stardew Valley or Minecraft servers, but Unity doesn't bring up the C# console when I run my project, so how can I get it to do so? This question was asked earlier in another channel, but I switched channels, so I apologize for that!

knotty sun
old plinth
# knotty sun what do you even mean by 'C# Console'?

Hi, first of all thanks for your interest in my question, by C# console I was referring to the exe file that comes out at build time after creating a project in Visual Studio or Rider with Console Project in the .Net Core or .Net Framework tab.

knotty sun
#

that is not a 'C# Console', that is just a standard Windows command line window

old plinth
knotty sun
#

you don't. Unity builds a Windows program, they dont have a CLI

old plinth
knotty sun
#

is there a way? Yes, but you need a deep understandig of the Windows OS and the Win32 API

old plinth
knotty sun
#

you could certainly do that but, again, you would need an understanding of the Win32APi to achieve it

old plinth
#

Thank you, that was helpful enough, I appreciate your time!

paper hull
#

I know this may sound stupid but does anyone know how to round double to the nearest whole number?

next crescent
#

Might be a weird workaround:
Mathf.RoundToInt((float) myVariable)

#

This converts it to a float first, then rounds it

paper hull
#

Tyvm, I saw a similar solution on google but I didn't understand what it did so I didn't wanna risk trying it lmao

knotty sun
paper hull
#

I did look on google, however it was all mumbo jumbo to me, I'm very new to unity, so I'm used to basic C#

knotty sun
#

this is basic c#

paper hull
#

Mathf wasn't in what I learned but alr

quartz folio
#

Math still exists, and is more suited to what you asked, doubles

paper hull
#

How would I access it, because when I tried to use math functions it says math is not defined

quartz folio
#

Same way you access anything else

knotty sun
strange pine
#

heyoo, so I'm in the process of creating some stores in my game and want to be able to edit the inventories easily, would this be achievable as a JSON in the resources folder?

leaden ice
#

and are these needing to be editable at edit time, or runtime?

strange pine
#

edit time, never ever run time

leaden ice
#

JSON works (as TextAssets)
Or you can use ScriptableObjects

strange pine
strange pine
leaden ice
#

you just do like:

public TextAsset MyJsonFile; // assign in inspector

void Example() {
  string json = MyJsonFile.text;
  MyClass data = JsonUtility.FromJson<MyClass>(json);
}```
strange pine
#

thanking thee 🙂

heady iris
#

oh neat, I wasn't aware of TextAsset

heady iris
swift falcon
#

If I am changing the speed of time, how do I get the correct time between frames?

#

deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
I am using this but I feel it is wrong

prime sinew
swift falcon
#

Yeh

#

I am trying to create and FPS thing but I am pretty sure it's not working when I speed things up

prime sinew
#

the time between frames doesnt change though, i think...

#

let me check

swift falcon
#

My logic might be wrong somewhere else

prime sinew
#

oh it is

#

when you say correct time

#

do you mean the deltaTime at timescale 1?

#

or the deltaTime after you changed the time scale

swift falcon
#

at timescale 1

prime sinew
#

is there a unscaledDeltaTime?

swift falcon
#

Oh smart, thank you

#

Good job I noticed this because part of my module was comparing the FPS with dots on and off

#

And the FPS was lower than it was supposed to be because it scaled by time

#

So basically at 2 times speed it was halving the fps 😅

#

I was also averaging my FPS faster so from 0.5 seconds to every 0.055 seconds o-o which was costly

#

It's insane how much of a performance boost it gives

unreal temple
#

does anyone know how to resolve this?

#

ah nvm, deleting scriptassemblies fixed it

mystic ferry
#

might seem like a dumb question but is there any reason why you would use the builtin methods for moving an object like MoveTowards or Lerp if you have a tweening library? or will a tweening library cover all your needs for moving something?'

#

like does it make sense for an AI like a boss to use tweening to move around?

steady moat
#

You usually use constant speed.

lethal plank
#

what if i trained bot for a year
will it be the hardest bot?

steady moat
#

Or some modification of speed that does not follow tweening logic.

steady moat
potent sleet
steady moat
#

In almost every form of learning possible

lethal plank
#

how can i train it shooting like player?

potent sleet
lethal plank
#

oh

#

damn i cant get rid of it

steady moat
#

Do not use Machine Learning.

#

Use standard AI method

lethal plank
#

oh

#

alright

#

thanks

jagged coyote
#

I need some help with the particle system. I want to create some 3D particles but directly from C#. I am trying to copy the mesh from a primitive to the mesh the particles are supposed to use, but it doesn't seem to be working. The code is quite large so I will post it in a thread

rugged storm
#

yo this is my code, https://gdl.space/solaqocahi.cs
I'm having an issue where the Packet that runs MatchCheck (which is the one defined as startPacket in the method) doesn't end up being included in the matchedPackets list, when it reaches the LaunchNewGroup() method

thick socket
#

would closing these improve performance of VS?

#

its a little laggy for me

floral crescent
#

how do i write this to work because these lines are obsolete

UnityWebRequestMultimedia.GetMovieTexture(path))

and

DownloadHandlerMovieTexture.GetContent(unityWebRequest);

it suggests using csharp VideoPlayer instead but im not sure how to do this

    IEnumerable LoadVideo(string path)
    {
        using (UnityWebRequest unityWebRequest = UnityWebRequestMultimedia.GetMovieTexture(path))
        {
            yield return unityWebRequest.SendWebRequest();

            if (unityWebRequest.result == UnityWebRequest.Result.ConnectionError)
            {
                Debug.Log(unityWebRequest.error);
            }
            else
            {
                var unityWebRequestVideo = DownloadHandlerMovieTexture.GetContent(unityWebRequest);
                videoPlayer.clip = unityWebRequestVideo;
            }
        }
    }
#

i am trying to load a video from the file explorer

#

does anyone know a way to do this

flint sierra
#

Any tips on PropertyDrawer formatting? For the STruct I've turned into a Property Drawer when I have an array of the struct to show in Unity Editor properties of that struct overlap with other elements of the array

thick socket
#

wow this is actually stupid

#

VS2019 has no lag when using it

#

VS2022 now has like 200ms lag when using it 😭

steady moat
thick socket
thick socket
#

Is there a way to make Unity reload script assemblies either ONLY when I start the game, or in the background when I save in VS?

teal mica
teal mica
steady moat
thick socket
#

where it only refreshes when i click play, or just refreshes in background when saving in VS

thick socket
# steady moat

that should make it so when you change and save code in VS...that it doesn't reload
"reload script assemblies" when you tab back?

steady moat
#

I use CTRL-R to then refresh

#

You can make code to call the function AssetDatabase.Refresh whenever you want otherwise.

thick socket
#

big sad

#

it still makes me wait for reload script assemblies with that setting set like that

#

ooh, just found this from 2 days ago

#

lets hope it fixes it

#

"Visual Studio: Tools -> Options -> Tools for Unity -> Refresh Unity's AssetDatabase on save: False"

#

still doesn't do crap

#

darn

steady moat
#

It works from my side. Enabling and disabling the settings behave as intended.

thick socket
#

Im guessing you aren't in the 2022 version

steady moat
#

True, I am in 2021

#

But, the user did not report if it was working in 2021, so I would not think it is actually an issue due to version.

thick socket
#

I should have left my project in 2021 😦

teal mica
#

hmm it's true

#

reload assemblies seems to occur no matter what

#

I can't get it to stop on 2022 either

thick socket
#

does this setting do anything for you?

#

doesn't seem to do anything for me

teal mica
thick socket
#

F

steady moat
#

You can also test it in 2021, and if it actually does work in 2021 and not in 2022 it would be easy to make a bug report.

latent latch
#

They have a discord

#

devs active on it too which is nice

rain crater
#

Hey, how can I modify terrain height from script, to align with some planes I have? I am generating a path along a spline, and i'd like to align the terrain to it somehow.

elfin tree
#

Is there a way a could stretch only the edges of a sprite?
In other words the middle would keep 1:1 aspect ratio while the edges could be stretch by a percentage.

heady iris
#

sounds like 9-slicing

#

although that doesn't stretch, just repeat

lost wave
#

What causes a referenced item to disappear in the script in the inspector during play mode. The item is an animator, its a component of the item the script is on, its [SerializeField] private Animator animator; I drag it in the script and when I push play to test is disappears and I get a reference null error. I tried changing it to public Animator animator, same thing. I tried Animator animator and then got it in awake. etc. etc. I have also deleted the item, and started over.

mossy snow
#

something is destroying your Animator

prime sinew
#

With a GetComponent or something

lost wave
#

no, there is no start or awake, just update and the variables

prime sinew
lost wave
#

destroyed in the inspector, no, just loosed the refrence

ionic socket
#
            {
                Debug.Log($"{(influenceChange[kvp] < 0 ? "" : "+")}{influenceChange[kvp]} {kvp.faction} Influence in {kvp.country}"); 
                Game.current.gameState.influence[kvp.country][kvp.faction] += influenceChange[kvp];
                kvp.country.InfluenceChangeEvent?.Invoke(kvp.faction, influenceChange[kvp]); 
            }

This foreach through a tuple-keyed dictionary is causing a "at least one item must implement IComparable" exception. The options as I see them are: 1) add IComparable to either Faction or Country (for no other purpose than to resolve the error), 2) create a struct holding faction and country and replace the tuple-as-key 3) rewrite the foreach so that no IComparable is needed. Which of those options are the best approach and is there another way to solve this issue?

lost wave
#

normally when i get this, its because i forgot to call it in Awake, so I reconfigured the script and it still does it.

prime sinew
lost wave
#

public class WeaponWheelController : MonoBehaviour
{
[SerializeField] private Animator animator;
public Image selectedItem;
public Sprite noImage;
public static int weaponID;

    private bool weaponWheelSelected = false;

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Tab))
        {
            weaponWheelSelected = !weaponWheelSelected;
        }

        if(weaponWheelSelected)
        {
            animator.SetBool("OpenWeaponWheel", true);
        }
        else
        {
            animator.SetBool("OpenWeaponWheel", false);
        }

        switch (weaponID)
        {
            case 0: //Nothing
                selectedItem.sprite = noImage;
                break;
        }

        switch (weaponID)
        {
            case 1: //Knife
                selectedItem.sprite = noImage;
                break;
        }

        switch (weaponID)
        {
            case 2: //bow
                selectedItem.sprite = noImage;
                break;
        }

        switch (weaponID)
        {
            case 3: //water
                selectedItem.sprite = noImage;
                break;
        }

        switch (weaponID)
        {
            case 4: //food
                selectedItem.sprite = noImage;
                break;
        }

        switch (weaponID)
        {
            case 5: //inventory
                selectedItem.sprite = noImage;
                break;
        }

    }
}
prime sinew
#

And you only have one of this script in the scene?

lost wave
#

yes, there is another animator on a child of this, but it has its own script

#

its done in the same way, and does not disappear

spark flower
#

hey so i have this code where i set a refrence, but in the inspector it tells me type mismatch, altho the type IS a match

prime sinew
#

Really not sure then. Sorry

lost wave
#

damn it. lol, im stumped too

spark flower
lost wave
#

i do appreciate your time though.

spark flower
#

why does it give me type mismatch?

prime sinew
lost wave
#

one is weapon wheel and the other is the weapon wheel button, i made sure i did not have the same one in both

prime sinew
spark flower
#

no

lost wave
#

I deleted the game object and rebuilt it, added the animator and the script etc etc.

prime sinew
#

Isolate it

lost wave
#

will, do. Thanks again

hexed pecan
elfin tree
#

Hey, so I tried asking ChatGPT to make code stretch the edges of sprite, while keeping the center unchanged.

After a few extra instructions it came up with this.

private void V1() {
            // Define the slice positions (normalized values ranging from 0 to 1)
            var sliceBorders = new Vector4(0.1f, 0.1f, 0.9f, 0.9f);

            // Calculate the slice sizes based on the sprite's dimensions
            var spriteSize = new Vector2(_spriteToSlice.texture.width, _spriteToSlice.texture.height);
            var sliceSizes = new Vector2(spriteSize.x * (sliceBorders.z - sliceBorders.x),
                spriteSize.y * (sliceBorders.w - sliceBorders.y));

            // Calculate the slice offsets based on the sprite's dimensions
            var sliceOffsets = new Vector2(spriteSize.x * sliceBorders.x, spriteSize.y * sliceBorders.y);

            // Calculate the scaled edge sizes
            var scaledEdgeSizes = sliceSizes * edgeScaleFactor;

            // Calculate the final slice sizes by combining the scaled edge sizes and original center sizes
            var finalSliceSizes = new Vector2(scaledEdgeSizes.x + sliceSizes.x * (1 - edgeScaleFactor),
                scaledEdgeSizes.y + sliceSizes.y * (1 - edgeScaleFactor));

            // Create the sliced sprite
            var slicedSprite = Sprite.Create(_spriteToSlice.texture, new Rect(sliceOffsets, finalSliceSizes),
                new Vector2(0.5f, 0.5f), _spriteToSlice.pixelsPerUnit);

            // Assign the sliced sprite to the SpriteRenderer component
            GetComponent<SpriteRenderer>().sprite = slicedSprite;
        }

Only thing is, it only seems to remove the edges, not add them back. The first few lines seems ok, thoughts on what's wrong or is there just a limitation when it comes to making a sprite from multiple?

Thanks!

hexed pecan
#

@spark flower dont store references to scene objects on a SO

#

SO asset, that is

spark flower
#

this is outside of playmode

hexed pecan
#

Ok what I said is still true

#

What are you expecting it to show? That object is already destroyed

spark flower
#

which part exactly

hexed pecan
prime sinew
lost wave
#

i had to take take care of some other stuff at work. Ill get it here in a bit or later tonight.

spark flower
hexed pecan
spark flower
#

but the code works

#

after that code i access the ball thru the so

hexed pecan
#

Does the asset say Mismatch when youre playing and not even changing scenes?

spark flower
#

i dont change scenes, like i sayd the ball is in the scene and at that point it says mismatch

#

when the ball is not in the scene it just says missing

lost wave
#

@prime sinew it did it in another scene.

prime sinew
lost wave
#

yep,

hexed pecan
spark flower
#

yes, playmode

prime sinew
lost wave
#

@prime sinew guess its time to start fresh.

hexed pecan
prime sinew
#

Restart unity. Turn it off and on haha

#

If you do figure it out, do share if you remember

#

I'm out of ideas

lost wave
#

will do.

spark flower
#

ok

amber heart
#

How do I add a comment/summary to a Monobehavior to show in the inspector

lean sail
#

do u mean a tooltip?

amber heart
lean sail
#

You can probably use [TextArea] then

latent latch
#

something like that?

steady moat
#

Maybe there is solution like Odin that implements it.

amber heart
latent latch
#

[TextArea], [ToolTip], [Header] I think are all of them

#

Naughtyattributes has some more flavor text boxes

amber heart
#

That might me what I'm looking for

latent latch
#

There's some more options in there

amber heart
#

Docs is loading super slow for me...

#

Or just bad internet

#

Eh, nvm it's not necessary atm

lost wave
#

@prime sinew I went back in and deleted the animation controller and rebuilt it. I then created a new script and copied and pasted the old one in. I changed it to Animator anim; and called it in awake and.......yea, its working. thanks again for at least trying to help. have a great day

lapis pelican
#

Hi! which method to use to save the data when exiting the game on the Android platform in the format newtonsoft.json?

mental pumice
#
public class Enemy : MonoBehaviour
{
    [SerializeField] private int moneyPerEnemy = 10;
    [SerializeField] private TextMeshProUGUI moneyText;
    private int totalMoney;
    void Update()
    {
        UpdateMoneyText();
    }

    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Bullet"))
        {
            AddMoney(moneyPerEnemy);
        }
    }


    private void AddMoney(int amount)
    {
        totalMoney += amount;

        UpdateMoneyText();
        Debug.Log("Added " + amount + " to player's money.");
    }

    private void UpdateMoneyText()
    {
        moneyText.text = totalMoney.ToString();
    }
}

hello guys, in this script i have a problem that even if the enemy collide with the bullet the TextMeshPro not changing why?

steady moat
#

And, you should not make your enemy control your UI.

#

If you have multiple enemies, you gonna be screw.

mental pumice
#

2.idk

#

3.yes

#

4.yes

#

5.yes

steady moat
#

Do you have multiple enemy ?

mental pumice
#

yes

steady moat
#

Then it is obvious why it is not working

#

You have at least one enemy that set the value to 0 because it has not been incremented

#

An easy fix would be to make the variable static BUT, and I insist, you should restructure your code.

#

A player has money
An enemy contact a bullet that is own by a player
The player that owns the bullet earn money (the amount the enemy is valued at)
When the player gains money, it notifies the UI to be updated.

#

If your game has no notion of Player, you could replace Player by GameManager.

rough crescent
#
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{

    Weapon currentweapon;


    void Start()
    {
        currentweapon = new Weapon1();
        currentweapon.Attack();
    }
}

public class Weapon
{

}

public class Weapon1 : Weapon
{
    public void Attack()
    {

    }
}

public class Weapon2 : Weapon
{
    public void Attack()
    {

    }
}

public class Weapon2 : Weapon
{
    public void Attack()
    {

    }
}```



^ can someone help implement something like this? i think the code is pretty self explanatory for what i'm trying to create here but if you want a better explanation let me know
in the way that it is right now the currentweapon.Attack() is giving an error, i know that's the wrong way of writing it i'm trying to figure out what'd be the best way of writing that
leaden ice
#

also if you want an abstract method in a class, the class itself must be abstract

fleet furnace
leaden ice
#

Also when sharing, please don't just say "an error". It is much better to share the actual error

lean sail
#

you also have 2 Weapon2 classes

leaden ice
#

I see you've crossposted

#

do not crosspost here, it's against the server rules

rough crescent
#

i figured

rough crescent
#

thanks for the answers tho appreciate it

leaden ice
#

Sure but without saying what the error is it could be almost anything

#

so we won't be able to give good answers

oblique basalt
#
if(hit.transform.gameObject.GetComponent<UnitBehaviour>() != null) unitType = SelectionType.UNITS;

Instead of checking whether the gameobject has UnitBehaviour attached to it, I want to see if the gameobject has any subtype of UnitBehaviour on it. (ie MinerBehaviour or BuilderBehaviour as they both inherit from UnitBehaviour)

leaden ice
#

however if you want to check that, you should use TryGetComponent rather than GetComponent, for simpler code:

#
if (hit.transform.TryGetComponent(out UnitBehaviour _)) {
  unitType = SelectionType.UNITS:
}```
oblique basalt
#

why do i need the out UnitBehaviour _ section. also unless im being silly my original code doesnt seem to work. will double check that everything else is okay tho

wide terrace
leaden ice
#

It is inferring the generic type argument from there - and it's also spitting the component out there but you're ignoring it hence the discard variable name _

#

if you want to use the variable, give it a name:

if (hit.transform.TryGetComponent(out UnitBehaviour ub)) {
  ub.DoSomething();
}```
oblique basalt
#

in this case since you dont need the arguement at all, is it not better to just use TryGetComponent<UnitBehaviour>() ?

leaden ice
#

since that's not what the method signature is

wide terrace
#

Though apparently you can pass null?

TryGetComponent<UnitBehaviour>(null);

🤔

#

Oh no that doesn't work

leaden ice
#

it needs an out param

oblique basalt
#

i see

wide terrace
#

The docs mention null as a possible argument, but don't elaborate on that 😕

oblique basalt
#

alright well im currently in extreme pain becuase of how poorly my code is laid out and i cant be bothered to go through it all and fix it so ill try this again tomorrow, thanks for the help @leaden ice and @wide terrace

wide terrace
#

I was mostly just here to muddy the waters 👍

Good luck

oblique basalt
rugged storm
#

Hi this is a script from a Meteos clone im making. https://gdl.space/solaqocahi.cs
I'm having an issue where the Packet that runs MatchCheck (which is the one defined as startPacket in the method) doesn't end up being included in the matchedPackets list, when it reaches the LaunchNewGroup() method

cursive gorge
#

If there is an nvidia gpu as the gpu, does it make sense to do some operations with the cuda toolkit and optimize it?

fleet furnace
cursive gorge
#

As far as I know, with the cuda toolkit, it was making to run mathematical operations and functions in c# and other languages ​​with gpu processing power.

fleet furnace
cursive gorge
void basalt
#

at an insane level

#

your CPU has SIMD capabilities that most developers don't take advantage of

cursive gorge
#

If I learn to use multi-threading with the System.Threading library, is the performance worth it?

void basalt
#

If you have to ask, then probably not

cursive gorge
#

hmm

void basalt
#

If you don't do it right, you'll make it slower than single threaded.

#

Most tasks don't require a whole ass dedicated core

mental oriole
#

why does my image color turn transparent when changing color It should just be orange

 public Color orange;

 healtBar.color = orange;```
void basalt
#

so it's defaulting to transparent I guess

mental oriole
mental oriole
haughty spire
#

Hey, is there maybe anyone that can help me?
I want that my player follows automaticly a path, but with just points, he dont going very smooth trough the Curves. So i installed the path Creator. But now he follows a path, but he doesnt collide with the ground or anything else. Does anyone knows how to fix this? Or is there a better method out there for following a path

winged dagger
cobalt wave
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

winged dagger
#

@cobalt wave

cobalt wave
#

first of all

#

don't sample inputs in FixedUpdate

#

it's inconsistent for that

void basalt
#

it breaks the simulation.

cobalt wave
#

it doesn't break it but don't expect any rotational forces to translate

void basalt
#

meant position, not rotation

cobalt wave
#

@winged dagger did you even drag the script onto a gameobject in the scene

#

this feels like you heavily just copy pasted the code without understanding a single thing about it

winged dagger
#

@cobalt wave yes

void basalt
#

@winged daggerThere's really no reason to be scaling by deltaTime in fixedupdate

winged dagger
#

yes i copied from the website that was showing the inctructions for that project

cobalt wave
#

yea, if you are gonna do deltaTime scaling use fixedDeltaTime

void basalt
#

still, no reason for it here

winged dagger
#

its the official unity website so its nothinhg with the code

cobalt wave
cobalt wave
#

did you hit play?

winged dagger
#

yes i hit play

cobalt wave
#

there could be so many things that you did wrong, you need to narrow it down for us

winged dagger
#

i added tht script to the component as well

void basalt
#

I mean, what's the problem?

#

All you did was paste code. Not explain what's not working

winged dagger
#

my character is not moving

void basalt
#

probably because you're moving it in the animator callback for whatever reason

#

Your character also isn't going to collide with walls using MovePosition

cobalt wave
#

it will collide but it will be clip in and out

#

and everything in that script is viable tbh

#

nothing should make it not work

#

this really comes down to what you did in the editor

void basalt
#

his animator callback is the reason it's most likely not working

#

you shouldn't move simulation objects like that anyways

winged dagger
#

this is how my screen looks

void basalt
#

That doesn't help anyone

#

I just told you why your code isn't working

winged dagger
#

can you point out specifically what i should remove or change in my code

void basalt
#

already did about 3 times

#

If you can't figure it out, then perhaps it's time to learn C# instead of just blindly copying things from chatGPT

winged dagger
#

na i am doing it for school

#

i dont actually want to learn code

void basalt
#

lol

winged dagger
#

this is my first time using unity

void basalt
#

If you don't want to learn code, then there's really no reason to be here

warm wren
#

Then why do a programming related course ?

void basalt
#

nobody is going to write your school assignment for you

#

and it's dumb that you would think that

nova magnet
#

guys

#

i tried fixing the pickup code

#

now it cannot equip

#

i can drop

#

but i cant equip

cobalt wave
#

elaborate

nova magnet
#

so i tried to code it

#

before it worked, but it came at the wrong side

#

now it doesn't even work at all.

warm wren
tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

hidden compass
#

I can't seem to figure out why my plugin is not loading for android.. I have gotten it working for nearly everything else so far but for android I'm getting a dllnotfoundexception

small lodge
#

so im making a car controller in unity and have everything set up but when i press play the cars wheels move out like this:

i know what part is causing the problem, its this code:
but im not sure why its doing that. can anyone help?

nova magnet
#

guys?

void basalt
#

@small lodgeI've had this issue before

#

your wheels origin isn't centered

#

you need to fix it in blender

#

when you click on the wheel, the transform should be right in the middle

small lodge
#

oh lmao

#

how would i make it centered

void basalt
#

blender

#

can't help you beyond that

small lodge
#

yeah im in bleder

#

oh

#

ok thanks tho

void basalt
#

It should be pretty straightforward

#

unfortunately I'm not an artist

midnight sun
#

Is there any reason why code isn't being ran correctly in a build for the quest 2? In editor it looks just fine though.

#

Basically I'm just copying the mesh of an object to another however it does not show up in the build.

leaden ice
#

Usually differences in a build are from script execution order differences or framerate dependent code

midnight sun
#
// Setup a clone of the held object
if(clone.gameObject == null)
{
    // Create object and components
    clone.gameObject = new GameObject("Clone");
    clone.filter = clone.gameObject.AddComponent<MeshFilter>();
    clone.renderer = clone.gameObject.AddComponent<MeshRenderer>();

    // Copy values to the cloned object
    clone.filter.mesh = heldObject.GetComponent<MeshFilter>().sharedMesh;
    clone.renderer.material = material;
    clone.transform.SetParent(transform);
    clone.transform.SetPositionAndRotation(transform.position, transform.rotation);
    clone.transform.localScale = heldObject.transform.localScale;
}

Clone refers to a struct containing information about a gameobject and acts as a hologram of a held object.

#

This is called while the held object is within a trigger using OnTriggerStay.

prime sinew
hidden compass
void basalt
#

If it's written in native, then it's probably doing something android doesn't support

hidden compass
main imp
#

would anyone know how fix this? apologies but i think expressions fall into the coding?

ionic path
#

for the cinemachine virtual camera, how do you change the Follow Override with code?

potent sleet
cosmic rain
tawny elkBOT
nova magnet
#

now guys

#

how do i only disable the firing and reloading part of the code of the gun when it is not parented to the player?

lean sail
nova magnet
nova magnet
cosmic rain
lean sail
nova magnet
lean sail
#

your guns right now are dependent on the user input, when its functionality should be called when the player presses to fire it. This would also allow u to have other things like an enemy fire the same gun

lean sail
#

right now u would have to either disable this script, or have an if statement constantly checking if its parented to the player to determine if its running. By having the player fire the gun instead, its just one check to see if the player even has a gun

#

"use a function" doesnt mean anything, im saying call the guns functionality from the player

hidden compass
ionic socket
#

is there a way to do a chain .Intersect on n number of lists? I have a list-of-lists and I want to get the elements that are common to all of them. Is there something in Linq that does this for more than just two given lists?

fervent furnace
#

hashtable?

wide terrace
ionic socket
#

weirdly I've gotta cast the interect back to List<> instead of IEnumerable but whatever I guess.

wide terrace
ionic socket
#

oh.. the base type here is abstract so it has to have a real type.

wide terrace
#

oh hmm 🤔

ionic socket
#

it's no biggie, it's only because I'm trying to create the initial list with a concrete entry

elder palm
#

I have an error pop saying a reference is null, the game pauses on the error, and in the inspector the reference is visibly not null. I am also 100% certain its the only instance of the script in the scene, checked by code.

lean sail
#

likely a #💻┃code-beginner but show code in there because its not possible to help you without more info

#

best i can say is you have a null reference, and its not where u think it is

elder palm
#

an error freezes the game and I can see the references set when its paused

lean sail
#

this barely shows me anything, if its corruption then try making this in a new scene and slowly add everything from your old scene until the same error happens. If it does not happen, then its either a unity bug or you missed adding something very small

thin aurora
jolly karma
#

Can some1 help me with IK foot placement?

latent latch
#

If you have a direction and a distance then you can get a position, so perhaps using lerp or MoveTowards is what you're looking for.

loud wharf
vagrant ocean
#

so i need a little help with my code, im trying to make a fps-character. it worked fine but when i added the wallrunn features it kinda broke down and i dont have any gravity anymore (im just static floating)

thin aurora
tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

visual flax
#

anyone have an idea for a vr game

main token
#

Hi, does anyone know if it's possible to merge multiple colliders? I have a script that merges all children objects' meshes into a unified mesh, and I would like to save some time by not having to reapply every collider. thanks.

hybrid relic
#

Fixed it i was missing discord.RunCallbacks();

cold parrot
main token
#

not sure how well that performance deficit translates into the real world tho

grand urchin
#

why doesnt this work? it looks like it should:

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

public class collide : MonoBehaviour
{
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("lazer"))
        {
            Debug.Log("You got hit!");
        }
        if (other.CompareTag("food"))
        {
            Destroy(other.gameObject);
            Debug.Log("Points! +1");
        }
    }
}
main token
quartz folio
cold parrot
main token
#

they are cubes, but they are often intercepted by doors in between, which needs to be passed through

#

so you end up having to place 5+ colliders for every room in the building

cold parrot
#

how many boxes would that be in total?

main token
#

god I don't even wanna think about it

#

probably like 50-70

#

and I have 5 levels

cold parrot
#

for the whole level?

main token
#

yeah

cold parrot
#

i'd say don't even worry about it

#

thats nothing

main token
#

so mesh colliders should be fine then?

cold parrot
#

a mesh collider will probably be worse, performance wise

cold parrot
#

but even mesh colliders wont cause issue (most likely)

#

or put another way, if either the mesh or box collider approach will cause performance issues on your target platform you need to rethink your design anyway, neither of them will likely fundamentally change your performance if your levels are too big or too dynamic on a large scale

#

in general, the physics engine is very good at only evaluating collisions in the local space that your are performing actions in, so if you avoid any collision checks in areas of the level that aren't observed by the player, you can improve your performance drastically (assuming large levels that are only partially visible)

main token
cold parrot
#

is it a mobile project?

main token
#

nah, pc

cold parrot
#

then you are most likely fine

sonic stream
#

would someone know how to make a movement system like this?,i tried many ways but couldn't get it to work my latest try was

private void SetRotation()
    {
        transform.Rotate(Vector3.forward,_input.MoveX * Time.fixedDeltaTime * _speed.Value);
        _rigidBody.rotation = Mathf.Clamp(_rigidBody.rotation, _minRot, _maxRot);
    }
broken nest
sonic stream
broken nest
sonic stream
knotty sun
#

to start with you never modify the transform and the rigidbody, you need to chose one or the other

broken nest
# sonic stream yes

Steve is correct. To know which one to use, you need to consider whether or not you intend to use physics in your controller.

sonic stream
broken nest
#

OK, then you'll want to use the rigidbody and not manipulate the transform directly

sonic stream
#
private void SetRotation()
    {
        _rigidBody.MoveRotation(_rigidBody.rotation + _input.MoveX * _speed.Value * Time.fixedDeltaTime);
        _rigidBody.rotation = Mathf.Clamp(_rigidBody.rotation, _minRot, _maxRot);
    }
#

should this work?

broken nest
#

is the clamp intended to set hard limits on how far you can rotate?

sonic stream
#

about 45 degrees

sonic stream
broken nest
pastel bluff
#

I'm trying to hit this object here with a raycast

#

it's a curved plane, but it's not being detected

#

if I create a plane with the same size, it detects

#

normals are fine, and I tried shooting the rays from both directions just in case

#

it works when I add a mesh collider with the same mesh

#

any clue on how to do it without the collider? I can hit other solid objects just fine, but curved planes are being a problem

broken nest
# sonic stream coasting?

like after you release the turn button. do you want it to stop rotating instantly or have some "driftiness" to it?

sonic stream
#

the controls are inverted,the input action asset controls are right but rotating turns it in the opposite intended direction,even in the editor

#

wait

#

right is -45 degress,when it should be 45

broken nest
sonic stream
broken nest
broken nest
static matrix
#

When I set objects to hide for a long time in the editor, I can't unhide them. Anyone know why? Fixes after a restart

broken nest
# sonic stream 0 is positive,right?

Haha, mathematicians have been trying to figure that out for centuries. But I'm sure that's not what you mean. In what sense do mean 0 is positive?

sonic stream
#

z specifically

broken nest
#

I see, you mean is 0 Z rotation forward?

sonic stream
buoyant crane
broken nest
#

well. In your game, when you say "forward" you mean "up", right?

sonic stream
buoyant crane
#

i can see that you are rotating the parent, but not too sure whether the sprite is on a child of the parent or something

sonic stream
sonic stream
sonic stream
buoyant crane
#

couldnt tell they were primitives 😅

buoyant crane
#

wait i misunderstood the question

sonic stream
broken nest
sonic stream
broken nest
broken nest