#archived-code-general

1 messages ยท Page 12 of 1

tender thunder
#

Thank you so much

proper oyster
#

just a remind the ammount of data you can save to playerprefs is very limited

#

so saving images in there not the best idea

swift falcon
tender thunder
proper oyster
tender thunder
#

thanks for reminding, yeah i checked documents and it said it has a limit of 1mb for playerprefs, that's not really a good idea for the app that im building ๐Ÿ˜ฆ

leaden ice
#

Sounds like you described exactly how to do it yourself

tender thunder
swift falcon
#

also its the same directory in windows as Application.persistentDirectory

proper oyster
#

either this is correct or the documentation needs updating

swift falcon
#

idk why they used separate configurations for windows apps and windows store apps, i dont even know what the second type is

potent glade
#

I am going to use a toggle group : my question is is there a way to give it a method when I pick one of the toggles? OR do I have to define each toggle's on changed value method?

swift falcon
dense cloud
#

quick question,
Code objects means the instances of the classes of a script?
Something like

Vector3 vec = new Vector3(var x, var y, var z)
```from the Vector class would create a new vector instance
#

GameObject is every entity on a scene?

leaden ice
dense cloud
#

ah thanks man

leaden ice
#

Note that GameObjects also have a C# object representation

#

The GameObject class

dense cloud
#

oh yea I checked, all gameobjects on a scene are the instances of the gameobject class

#

correct me if I'm wrong

leaden ice
#

Also note structs like Vector3 are not classes

#

But they are objects in C#

dense cloud
dense cloud
potent glade
swift falcon
potent glade
faint terrace
#

anyone knows the location of UnityEngine.XR.Interaction.Toolkit dll ? im trying to reference it in my library

thin hollow
#

How do those [expunged] quaternions work? T_T I got code:

 arrowV.localRotation = vertDir == EThirdDir.Down ? quaternion.Euler(0,60,150) : quaternion.Euler(0,56,-42);

that setups the child's rotation, but it instead sets the rotation to (-180, 17.7469, 134.367) or (0, -31.436, 113.557). Neither is what I put into the function that I expected to exist specifically to spare developers from the horrors of quaternions...

weak nacelle
#

Every day is a new day to learn that I'm dumb xd

swift falcon
thin hollow
swift falcon
thin hollow
swift falcon
leaden solstice
main shuttle
#

Also, just setting them this way is not better or worse then just setting the EulerAngles. Doing math with rotations should always be done with Quaternions, otherwise you run the risk of Gimbal Locks, but just setting it doesn't matter either way.

#

But yeah, reading the docs, I think you use the quaternion.Euler lower case variant. That rotates differently then the big one.

thin hollow
thin hollow
#

That rotates differently then the big one.
I just... why would anybody set those functions like that...

main shuttle
# thin hollow > That rotates differently then the big one. I just... _why_ would anybody set t...

Euler(Single, Single, Single, RotationOrder)

Returns a quaternion constructed by first performing 3 rotations around the principal axes in a given order. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin. When the rotation order is known at compile time, it is recommended for performance reasons to use specific Euler rotation constructors such as EulerZXY(...).
At least 1 of the problems is that this one is in Radians. Not sure if the axis order is also different. Anyhow, the math library quaternion one is only useful for DOTS I think, never used it in MonoBehaviour Unity variant. DOTS need speed, so I think something along those lines they are different, but that's just guessing from me, or maybe it's managed vs unmanaged.

agile scarab
#

Anyone here familiar with Photon PUN? If so I am having a problem where OnRoomListUpdate() is never called even after someone creates a new room (and the lobby is joined beforehand) . Any help would be appreciated.

leaden solstice
#

Probably because Unity mathematics library is to match with hlsl mathematics which likely to use radian

leaden solstice
agile scarab
astral spindle
#

Is it possible to have functions in a loop somehow? Like i have an array that i want to loop through and then have and if statement. But since 3 all overlap and are all true i need to have some function.

main shuttle
astral spindle
main shuttle
astral spindle
#

okayy

#

so i have an array that takes values out of another array and counts how many values are repeated. The values from the first array are randomly generated numbers from 1 to 6.

#

there are 5 random numbers in the array total

#

so any time i want to use the numbers from the array that counts the repeated for an if statement id have to do if NumberArray[0] && NumberArray[1] ... and so on

#

so i made a for loop

#

that looks like this

#
        {```
#

i put the if statements in there

#

if [NumberArray[i] {

main shuttle
tawny jewel
#

so for a while now noone was able to solve that, could someone take a look and try to think of any solution? ive been checking code over and over again and the only solution i see is to somehow change time.deltatime on the second script, tho every attempt of mine to do so failed
link to my original message in #๐Ÿ’ปโ”ƒcode-beginner #๐Ÿ’ปโ”ƒcode-beginner message
more info and my screen records are in the thread

#

id be very thankful if someone could help lmao

main shuttle
#
for(int i = 0; i < 6; i++)
{
  if [NumberArray[i] {

Please post it this way, it's way easier to read.

astral spindle
#

okayy

main shuttle
#

cs on the same line as the backticks
Anyhow,

if [NumberArray[i] {

Doesn't make much sense.

#

But maybe you weren't done yet.

quiet steeple
swift falcon
tawny jewel
tawny jewel
tawny jewel
#

yea i suppose that would definitely make sense. could you roughly tell me how can i do that?

swift falcon
#

make a list, check if the farthest obstacle shorter than a definite distance, if yes spawn new on at x offset

#

oh and i suggest you move the player and not the obstacles

tawny jewel
#

i figured it would be much easier to move the pipes instead, pretty sure original floppy bird is based on that design

tawny jewel
astral spindle
swift falcon
astral spindle
#

ok so

astral spindle
astral spindle
#

inside i then had an if statement

#

but like i explained

#

if (NumberArray[i] == 2) {

#

and

#

if (NumberArray[i] == 3) {

#

overlap

#

if (NumberArray[i] == 2 && NumberArray[i] == 3) {

#

or the other way around

#

im not quite sure how to explain

leaden ice
#

use a for loop

#

to go through the numbers

#

and check if they're equal however you want

astral spindle
#

i am using a for loop

vague slate
#

Any idea why calling GetValidProperties causes stack overflow?

        private static IEnumerable<PropertyInfo> _except;

        private static IEnumerable<PropertyInfo> Except => _except ??= GetExcept();

        private static IEnumerable<PropertyInfo> GetExcept()
        {
            foreach (var propertyInfo in GetValidProperties(typeof(SystemBase)))
            {
                yield return propertyInfo;
            }
        }

        public static IEnumerable<PropertyInfo> GetValidProperties(Type type)
        {
            foreach (var propertyInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Public).Except(Except))
            {
                if (propertyInfo.CanRead) yield return propertyInfo;
            }
        }
leaden ice
#

infinite recursion

vague slate
#

oh yeah

#

I just realised

#

damn

#

bruh, inherited properties aren't the same as properties on base types

#

hmmm

glossy wadi
#

is there a way to get the navmesh system to work on a sphere? If I add a navmesh surface to a sphere normally, it just covers the top and not it's entire surface. I have zero experience with Unity's navmesh, so I may be missing something obvious

lucid valley
leaden ice
glossy wadi
#

Is there some other tool that would work on spheres? I don't have the coding knowledge to implement that myself

lucid valley
#
private void Tally()
{
    var tally = new dictionary<int, int>();

    for(int i = 0; i < NumberArray.length; i++)
    {
        var number = NumberArray[i];
        
        if(tally.TryGetValue(number, out var tallyValue))
        {
            //I think you can do that, otherwise you'll need to set it back to the dictionary
            tallyValue++;
        }
        else
        {
          tally[number] = 1;
        }
    }
}
lucid valley
#

ah, i always forget

#
private void Tally()
{
    var tally = new dictionary<int, int>();

    for(int i = 0; i < NumberArray.length; i++)
    {
        var number = NumberArray[i];
        
        if(tally.TryGetValue(number, out var tallyValue))
        {
            tally[number] = tallyValue++;
        }
        else
        {
          tally[number] = 1;
        }
    }
}
leaden ice
#

I'd do this somewhat simpler way:

int currVal = tally.GetValueOrDefault(number);
tally[number] = currVal + 1;```
lucid valley
#

true

swift falcon
#

anyone know how i can fix unity using visual studio instead of vscode whenever i restart the project

pulsar ivy
#

Edit > preferences > external tools, then there should be a drop-down at the top

vague slate
#

hmm.
So when I create Delegate from PropertyGetter, can I cast it to Action<object> type?
Assuming Property is not object type

#

I'm talking about this as example

                var kek = propertyProvider.GetType().GetProperty("Kek", BindingFlags.Instance | BindingFlags.Public)
                    .GetGetMethod().CreateDelegate();
leaden solstice
vague slate
#

๐Ÿค”

#

sooo, not really

#

damn

#

I need to convert unknown Property Getter to delegate or maybe some other semi-fast alternative

leaden solstice
vague slate
#

yes

#

I need for both

#

I'm fine with boxing

#

it'll be boxed anyway

leaden solstice
#

You may just make a lambda that calls PropertyInfo.GetValue

vague slate
#

but property info is way too slow

#

damn

leaden solstice
#

Or do Delegate.DynamicInvoke , both are slow

vague slate
#

delegate is not as slow

#

maybe I can somehow

#

split into two

#

hmm

leaden solstice
#

DynamicInvoke is slow ๐Ÿ˜›

vague slate
#

what delegate type would be for value types?

leaden solstice
#

The exact Func<T> type

vague slate
#

๐Ÿฅฒ

leaden solstice
#

Make your method return object ๐Ÿ˜„

vague slate
#

that's the point though

#

I'm doing anti boilerplate work

#

where I want to return any type, because it'll use ToString anyway

leaden solstice
#

Then make a Func<T> then make a wrapper Func<string> that calls ToString on it

vague slate
#

but I don't know T

#

and if I can't do that for value types dynamically

leaden solstice
#

Do MakeGenericType

vague slate
#

where can I find this one?

leaden solstice
#

From typeof(Func<>)

unreal temple
#

can sum1 help me fix thsi code?

hidden compass
#

๐Ÿ‘€ ๐Ÿ”ฅ

hidden compass
flint gyro
#

My eyes are burning

#

Bro is more psychotic than a light mode user

vague slate
#

too much reflection ๐Ÿ˜…

#

all right, I guess propertyInfo it is

leaden solstice
#

Your properties can be stripped out too FYI

vague slate
#

nah, it's more about JIT which involves creating generic types

#

anyways, I don't have control over stripping of my properties either

leaden solstice
#

If you use Func<int> somewhere in code you can make that type

vague slate
#

which is kinda sad

vague slate
#

I hope PropertyInfo.GetValue is fine with Il2cpp

#

So far this works

            var property = typeof(MainMenuPresentation).GetProperty(nameof(MainMenuPresentation.Lul),
                BindingFlags.Instance | BindingFlags.Public);
            var result = property.GetValue(new MainMenuPresentation());
#

in editor at least

main shuttle
# astral spindle if (NumberArray[i] == 2 && NumberArray[i] == 3) {

Yeah had to go home and make dinner.
But still, this doesn't make much sense. This line can never be true. NumberArray[i] can't be 2 and 3 at the same time.
It seems you simply want to count duplicates, and there are a bunch of examples of that online for C#. So I don't know what to do with this question.

leaden solstice
vague slate
#

but I'm annoyed to make a build, cause due to some new version of WASL, building little webGL apps takes literally 30 mins

vague slate
#

it doesn't use user code

astral spindle
leaden solstice
fair shell
#

Hello im trying to implement portals using brackeys smooth portal video but it looks like his PortalCamera script is outdated and isn't working as intended.

using UnityEngine;

namespace DefaultNamespace
{
    public class PortalCamera : MonoBehaviour
    {
        public Transform playerCamera;
        public Transform portal;
        public Transform portal2;

        void LateUpdate() {
            Vector3 playerOffsetFromPortal = playerCamera.position - portal2.position;
            transform.position = portal.position + playerOffsetFromPortal;


            float angularDifferenceBetweenPortalRotations = Quaternion.Angle(portal.rotation, portal2.rotation);

            Quaternion portalRotationalDifference = Quaternion.AngleAxis(angularDifferenceBetweenPortalRotations, Vector3.up);
            Vector3 newCameraDirection = portalRotationalDifference * playerCamera.forward;
            transform.rotation = Quaternion.LookRotation(newCameraDirection, Vector3.up);
        }
    }
}

Using this script right now makes the portal camera erratic and i not experienced enough to know how to fix it.

main shuttle
swift falcon
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test_hover : MonoBehaviour
{
    Rigidbody hb;
    public float mult;
    public float moveForce;
    public float turnTorque;
    
    void Start()
    {
        hb = GetComponent<Rigidbody>();
    }

    public Transform[] anchors = new Transform[4];
    public RaycastHit[] hits = new RaycastHit[4];

    void FixedUpdate()
    {
        hb.AddForce(Input.GetAxis("Vertical") * moveForce * transform.forward);
        hb.AddTorque(Input.GetAxis("Horizontal") * turnTorque * transform.up);

        for (int i = 0; i < 4; i++)
            ApplyF(anchors[i], hits[i]);



    }

    void Update()
    {
    }

    void ApplyF(Transform anchor, RaycastHit hit)
    {
        if (Physics.Raycast(anchor.position, -anchor.up, out hit))
        {
            float force = 0;
            force = Mathf.Abs(1 / (hit.point.y - anchor.position.y));
            hb.AddForceAtPosition(transform.up * force * mult, anchor.position, ForceMode.Acceleration);
        }
    }
}

I am trying a hoverboard script but for some reason it doesnt move when I try to

#

Could someone help

fair shell
#

values going crazy until it says infinity lol

main shuttle
#

I have a feeling the problem is not this script. This all seems valid code.

#

You can disable this one, and run the game again, it's should still freak out.

fair shell
main shuttle
# fair shell

Hmm, you are moving PlayerView, which is under Player it seems. Are you sure that's correct from the tutorial?

unreal temple
vague slate
#

it gets really stuck on linking phase

#

I barely have any assets anyway

#

only uxml practically

unreal temple
vague slate
#

nah, don't think it's related

fair shell
unreal temple
#

Went from 20 to 5 minutes

vague slate
#

older wasl version made builds in just 5 mins yeah

unreal temple
vague slate
#

but UI toolkit clicks didn't work

#

with that older version

unreal temple
#

Ah you're using toolkit at runtime? I heard it wasn't ready.

vague slate
#

it is since 2021

#

๐Ÿ˜…

#

but Unity did smth wrong with webGL compiler in 2022.2

unreal temple
#

I know it's possible, I thought maybe it wasn't quite good though to rely on. I'm looking forward to the workflow when it's feature complete.

vague slate
#

I never used uGUI, only UI Toolkit

#

and I like it

#

it's very close to web ui, so I just use the same good practices

unreal temple
vague slate
#

it's also cool that it's written in UXML, which is very similiar to XAML used in many .net UI solutions

unreal temple
#

Yeah I'm a web dev too. I have been wishing for html in unity for years.

main shuttle
# fair shell well that is the player camera its how he does it

Okay, well the setup is strange.
You have the PortalCamera script on the camera from the portal.
And you do:

transform.position = portal.position + playerOffsetFromPortal;

Which positions the camera to the camera + playerOffsetFromPortal, teleporting the thing further.
And I feel you do this on all camera's. Teleporting the whole scene to infinity.
transform.position and portal.position is the same if you did not catch that.

vague slate
#

I'm no web dev though ๐Ÿ˜…

unreal temple
#

Even if you don't know it

#

Provided it doesn't have terrible issues, which is my fear haha

vague slate
#

well anyways, I literally wrote desktop application using UI Toolkit and it worked better than Microsoft's MAUI version ๐Ÿคฃ

#

40 mb ram with Unity vs 70 mb ram on MAUI

fair shell
unreal temple
vague slate
main shuttle
#

The whole portal system teleports with you

#

Ahh I get what you mean now. The only thing is the camera teleporting away, not the portal mesh itself.

#

But the cause is still the same.

#

Your portal is the same as transform in your script.

transform.position = portal.position + playerOffsetFromPortal;
#

So you always add playerOffsetFromPortal to the position, every frame.

fair shell
#

ok

#

ill try other solutions out

main shuttle
#

This wasn't in Brackeys tutorial as far as I can remember.

fair shell
#

i think i misunderstood the video and what he put in the transform variables

astral spindle
#
 else if (NumberArray[0] == 2 && NumberArray[1] == 2 || 
         NumberArray[1] == 2 && NumberArray[2] == 2 ||
         NumberArray[2] == 2 && NumberArray[3] == 2 ||
         NumberArray[3] == 2 && NumberArray[4] == 2 || 
         NumberArray[4] == 2 && NumberArray[5] == 2 ||

         NumberArray[0] == 2 && NumberArray[5] == 2 || 
         NumberArray[1] == 2 && NumberArray[4] == 2 ||
         NumberArray[0] == 2 && NumberArray[2] == 2 ||
         NumberArray[1] == 2 && NumberArray[3] == 2 || 
         NumberArray[3] == 2 && NumberArray[5] == 2 || 

         NumberArray[2] == 2 && NumberArray[4] == 2 || 
         NumberArray[0] == 2 && NumberArray[4] == 2 ||
         NumberArray[1] == 2 && NumberArray[5] == 2 ||
         NumberArray[0] == 2 && NumberArray[3] == 2 || 
         NumberArray[2] == 2 && NumberArray[5] == 2 

         ) { 

would this cause any problems like lag? i know it can be done more efficiently i just couldnt figure out how. it works like this. But does this cause problems? Its in a for loop.

main shuttle
#

Also depending on how many thousands of else if's you programmed. But with an array of 5 it should all work.

#

This won't scale at all though.

astral spindle
#

no this is the only way i have like this. the other ones are WAY more efficient.

astral spindle
potent sleet
astral spindle
#

oh ok sorry

#

didnt know i wasnt allowed

main shuttle
potent sleet
#

a reason why crossposting is in the rules ๐Ÿ˜…

unreal temple
astral spindle
unreal temple
#

Lol

unreal temple
#

I love the idea that this is advanced code

#

The problem with your code is not efficiency

astral spindle
#

i know its not just wanted to make sure people saw it since ive been confused for like 3 hours

unreal temple
#

This server has tens of thousands of users, it will be seen

astral spindle
#

Okay! thanks for the help again โค๏ธ

swift falcon
#
        _layerMask = 1 << LayerMask.NameToLayer("Default");
        _layerMask = ~_layerMask;
#

what does ~ mean

swift falcon
#

oh so the first line is "detect default layer" and the second line makes it "detect everything except default layer" ?

leaden solstice
swift falcon
#

oh is that new

leaden solstice
#

I don't think so?

obtuse spade
#

Hey! Wondered if there was a dynamic way to instance a custom object from assets? I'm trying to spawn this from code:
https://assetstore.unity.com/packages/tools/particles-effects/v-light-volumetric-lights-2037
So far I've created it through editor: GameObject --> Create Other --> (V-Light type). However it doesn't seem possible to add it to prefabs for some reason, only scenes. So now I want to instance it at runtime from script. Any idea where to start?

Use the V-Light Volumetric Lights tool for your next project. Find this and more particle & effect tools on the Unity Asset Store.

devout solstice
buoyant crane
#

oh were you just looking at var1 = ~var1?

dull magnet
#

Hope it's ok to bump this. Any ideas?

nimble mulch
#

hi

#

anyone can review why this not working?

#
using UnityEngine;
using UnityEditor;

public class PlayerSpawnerMethod : EditorWindow
{
    private GameObject playerSpawnerPrefab;
    private GameObject[] spawnPoints;

    [MenuItem("Window/Player Spawner")]
    public static void ShowWindow()
    {
        GetWindow<PlayerSpawnerMethod>();
    }

    private void OnGUI()
    {
        playerSpawnerPrefab = EditorGUILayout.ObjectField("Player Spawner Prefab:", playerSpawnerPrefab, typeof(GameObject), false) as GameObject;
        spawnPoints = EditorGUILayout.ObjectField("Spawn Points:", spawnPoints, typeof(GameObject), true, null) as GameObject[]; <-- ERROR

        if (GUILayout.Button("Create Player Spawner"))
        {
            if (playerSpawnerPrefab == null)
            {
                EditorUtility.DisplayDialog("Error", "Please select a Player Spawner prefab", "OK");
                return;
            }

            GameObject playerSpawner = Instantiate(playerSpawnerPrefab);
            playerSpawner.GetComponent<PlayerSpawner>().spawnPoints = spawnPoints;
            Vector3 mousePosition = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition).origin;
            playerSpawner.transform.position = mousePosition;
            Selection.activeGameObject = playerSpawner;
        }
    }
}
#

the args is incorrect by view of vs studio

leaden ice
#

read your error messages

nimble mulch
#

i tried fix but i stuck in convert GameObject[] to GameObject

leaden ice
quaint rock
tired aspen
#
public class Tetris : MonoBehaviour
{
    PlayerMovement playerMovementScript;
    PickUpController pickUpControllerScript;

    public Camera camera;
    public GameObject startMenu;
    public GameObject allUi;

    private bool gameOn = false;

    private void Awake()
    {
        playerMovementScript = GameObject.FindObjectOfType<PlayerMovement>();
        pickUpControllerScript = GameObject.FindObjectOfType<PickUpController>();
    }

    void Update()
    {
        if(gameOn == true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                // Create a ray from the camera through the mouse pointer in Visual Studio, ScreenPointToRay is shown as incorrect and unity sends                  // the error below
                Ray ray = camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hitInfo;

                if (Physics.Raycast(ray, out hitInfo))
                {
                    Button hitButton = hitInfo.collider.GetComponent<Button>();
                    if (hitButton != null)
                    {
                        hitButton.onClick.Invoke();
                    }
                }
            }
        }
    }
}

'Camera' does not contain a definition for 'ScreenPointToRay' and no accessible extension method 'ScreenPointToRay' accepting a first argument of type 'Camera' could be found (are you missing a using directive or an assembly reference?)

I want to send out a ray cast through the mouse pointer in 3D.

somber nacelle
#

you created your own class called Camera so it is trying to use that, you need to either put that class into a namespace so that unity doesn't get them confused or just use a different name for that class

leaden ice
tired aspen
#

thx boxfriend and PraetorBlue

clever bridge
#

Hello, I am continuing my puzzle game of triangles. I have an empty object with a script on it that creates a group of triangles. each grouping creates a random amount of triangles, 1 to 6. When certain groups of triangles are created, they aren't centered, and I don't know how to center them

#

for example the grouping on the right is not centered, and I tried using the bounds of each triangle to determine a min and max x and y and tried to place them according to the min and max x and y, but it's not working

clever spade
clever bridge
#

they are separate objects

#

I'm trying to get the average of their sprite renderer bounds, and that's not working

past pier
#

Hey,

So I'm new to the broader C#/.NET ecosystem and I'm surprised to find that the popular cache implementations all seem to store the objects internally as non-generic Ojbects. While Unity doesn't seem to provide it's own cache implementation.

  • Wouldn't for example using Microsoft's MemoryCache cause a painful performance penalty for this very reason (due to constant wrapping)?
  • Is there a cache implementation that is somewhat "favored" among Unity developers?
  • I ofc am not supposed to write my own, am I? ๐Ÿ˜‰ (unfortunately I need a time based eviction policy)
leaden ice
past pier
#

I'm doing a metric @#$!-ton of raycasts to draw a world grid (inside different floors of buildings as well) that moves in a radius around the player.

lucid valley
#

Also i don't think we have access to MemoryCache? or am i wrong does mono have it? Ah framework has it, but not standard

leaden ice
#

Also yes a lot of .NET stuff isn't really suitable for game development because it allocates too much garbage

past pier
#

Haven't played it, but judging on the screenshot - something like that, yes.

past pier
leaden ice
#

Hard to say because I'm not sure exactly what the visual effect you're looking for is

past pier
#

This is the moment I should mention I'm working on a mod, and not sure all options are therefore viable to me.

#

I already achieved the "visual effect", can screenshot. The problem is now making the solution performant ๐Ÿ˜‰

leaden ice
past pier
leaden ice
#

Are you sure it's worth caching them? If you use RaycastCommand/Job System you can do quite a few raycasts per frame without an issue

past pier
#

I'm also considering the Job System (or a combination of that with the cache).

leaden ice
past pier
#

The problem is the grid you see can be as much as 32x32 tiles.

#

I did ๐Ÿ˜‰

leaden ice
#

So what's the slow part, doing the raycasts? Or something else

#

rendering for example

past pier
#

Already fixed the obvious bottlenecks from the profiler.

#

Still doing erm... up to 8k casts per frame.

quartz folio
#

Is there a reason this is not done in a shader?

leaden ice
#

Presumably lack of access to physics information in the shader I'd guess?

#

I see this is a Valheim mod :p

past pier
quartz folio
#

Is the geometry not okay, the physics colliders are required?

past pier
leaden ice
quartz folio
#

You definitely should be using RaycastCommand if you are doing this though

past pier
#

I think both of you are correct yes.

leaden ice
#

The processing after the raycasts could potentially be jobified as well, depending on what it is.

past pier
#

I was hoping I'm going to be able to make the performance "good enough" as is with a cache slapped on top in the next release. And then improve it via the job system in the next-next release.

past pier
#

So at different X and Z coordinates you will need to execute a different number of raycasts.

#

It's not always say "two hits per tile" (that's actually the best case scenario.

#

Does this sound like something that the Job System should handle well?

leaden ice
#

or what a "tile" is in this context

past pier
#

Sure.

#

I can provide sufficient context ๐Ÿ˜‰

#

This functionality visualizes the world grid as is. So (0, 0) will be an intersection point of the render lines so will (1, 0) and so on. I by definition know all the x, and z coordinates around the player (basically all full integer coordinates around the player in an 8m radius).

#

The difficult bits is the height.

#

Altitude. Whatever ๐Ÿ˜‰

#

When you stand on the roof - the grid needs to be imposed over it.
When you stand on the second floor - it needs to be imposed over the second floor (but respectful of tables, and other pieces that are on top of the floor on which you can put items on).

#

So I'm basically firing a raycast from the sky diagonal to the ground and drilling through these layers trying to figure out what constitutes as the floor from the players perspective.

#

And I'm doing that for every intersection point ("tile" as I called it previously) in the radius of the player.

leaden ice
#

definitely doable in the job system, and much faster too

past pier
#

I imagined I'm going to have to group the raycasts in stages and queue them up in the job system. So in the first wave I would have say 1k raycasts, so in the second, then say 500 in the third, and then a long tale. Where my existing code would need to become aware of these waves and glue them together.

leaden ice
#

why the waves/stages?

past pier
#

If this interpretation is correct - that sounds as it should be much more efficient than my current sequential approach, but also much more difficult to write (hence why I intended to postpone this to a future release).

past pier
# leaden ice why the waves/stages?

Imagine you're on the 0th floor of a 2 story building. I'm casting a ray from space (first wave) and I hit the roof. Okay so we have our first potential "floor". But can we do better? I do another raycast from the previous position. If that hits - we have another potential floor. Now to oversimplify a bit - I'm checking which of these is closer to the player. If it turns out the previous "floor" is closer - no point drilling further - since next levels will only be further away. And we repeat in a loop (next waves) until either that happens (next cast further away than the previous) or until we hit "terrain" layer.

#

For different X and Z coordinates there might be a different number of casts required (in fact I guarantee it). Sometimes there will be a roof with no floors underneath it. Sometimes there will be furniture inbetween. And such.

#

So.

#

The best case scenario from my perspective is if I were able to wrap this whole logic per every "tile" as a single command.

leaden ice
past pier
#

So I kinda have to overshot by definition.

leaden ice
#

Isn't the player's foot + 1cm sufficient?

past pier
#

Lemme fetch a simple screenshot.

leaden ice
#

Anyway to start with I'd probaby just hardcode something like 5-10 batches and schedule them all. You might be surprised at how fast the job system is going to be here

past pier
#

See the "half floor"?

leaden ice
#

The job system lets you schedule a job depending on the results of another job. You can schedule the whole process with a set number of iterations from the get-go

past pier
#

Again - sounds terrifically performant and terrifyingly difficult to implement this logic in "batches" (if I'm not getting the wrong impression of the job system - which I very probably am).

indigo gull
#

Does anyone know a method for checking if a line goes through a rectangular prism? The prism would be aligned by the 3 global axes, with the minx, miny, minz, maxx and so on

leaden ice
#

You might have to interleave these jobs with RaycastCommand jobs but that doesn't increase the complexity all that much

#

just another couple of lines in that loop

past pier
#

Well it does seem like the way to go... Any reading material on the Job System that you would recommend to get me going?

leaden ice
#

hmmm good question... trying to remember how I learned to use it ๐Ÿคฃ

past pier
#

Ok. Thanks Man. Worst case scenario I'll blame it all on you, when my source code inevitably crashes and burns ๐Ÿ˜‰

autumn flume
#

The suffering of game design

dull magnet
#

Ahoi, I have an abstract class that implements this method:

public virtual void SetParentGrid(BaseGrid parentGrid)
{
    ParentGrid = parentGrid;
}

I want to override this in a derived class with a more specific type of grid that is derived from BaseGrid.

public override void SetParentGrid(HorizontalGrid parentGrid)
{
    base.SetParentGrid(parentGrid);
}

Compiler Error CS0115: no suitable method found to override
I guess the compiler doesn't know on its own that BaseGrid is substitutable with HorizontalGrid. Was wondering if there's a type safe way to define this.

magic fossil
#

Hiya! Have a question on the UI Toolkit, might just need some clarification on how it works. I'm following this UI Example from Unity: https://docs.unity3d.com/Manual/UIE-HowTo-CreateRuntimeUI.html. In the example, Unity has a MainView.cs script that sets up the List Controller during the OnEnable callback. I want to set up the List Controller later on, after OnEnable, from a keystroke or item selection.

However, it seems that the input keystroke or item selection must occur 2x for Unity to actually create the list items - it sets up the ListController and runs the ExecuteCharacterList methods, but no list items are populated until the second trigger. Any ideas why this could be case?
Here's a paste of the updated MainView.cs class. Everything else from the example is unchanged.
https://gdl.space/ahezufevet.cs

leaden ice
#

Ok silly quaternion question. If I want to do the equivalent of InverseTransformDirection but with only a Quaternion instead of a Transform. Basically "If an object's rotation was this Quaternion, what would be the local direction corresponding to the input world direction? Would this be correct?

public static Vector3 InverseTransformDirection(Quaternion rot, Vector3 inWorldDir) {
  Quaternion inv = Quaternion.Inverse(rot);
  return inv * inWorldDir;
}```
leaden ice
#

don't override

#

just make a new overload

#

but really

#

there's no point to this

#

what's the point to this

dull magnet
leaden ice
#

is this what you want?

dull magnet
leaden ice
#

that's what the generic type constraint is for: where T : BaseGrid

dull magnet
#

nice, thanks

edgy nexus
#

I try to install MLAgent and I'm now to the step of installing the torch program, do anyone know which version of torch is supported right now. Because I couldn't find any information in the docs

leaden ice
# edgy nexus I try to install MLAgent and I'm now to the step of installing the torch program...
GitHub

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement ...

#

pip3 install torch~=1.7.1

swift falcon
#

why does fps change depending on what I have selected in the Scene? It ranges from 200 to 1k

leaden ice
swift falcon
#

oh

leaden ice
#

more or less for different inspectors

swift falcon
#

aight, makes sense. ty

unreal temple
#

That's how I've done it in the past

#

May be the same as inverse

leaden ice
rustic rain
#

how can i turn a vector 2 into an angle to rotate an object by? i want to use the vector 2 movement of my player to turn into an angle for my particles to go the opposite direction in

unreal temple
leaden ice
#

particles.right = -moveDirection;

rustic rain
#

oh thank you

orchid surge
#

Hey, I'm working on a project that requires a lot of scripting per level, stuff like: "enemies from this spawner killed -> open door and resume auto scrolling.", "player entered this zone -> spawn enemies", "room entered -> augment camera behavior while inside.", etc. These things are simple enough to implement on their own, but before I waste more time, I want to know what I can do to minimize fiddling and room for error in the inspector, as I will be wiring up a lot of events. I am especially worried about the need to change trigger setups and breaking things across the game, which I have done at least a couple times already.

I started with something like this https://youtu.be/bMuTsAma4tk where I have abstract Trigger and Action classes. This works alright, but it has some shortcomings when I want to "toggle" an action. And I would love to replace inheritance with interfaces, but unity doesn't really support that. And Unity events take a lot of clicks to edit, so I'm not keen on them right now.

This is a bit of a ramble as I'm organizing my thoughts. I haven't decided if a better core approach exists, or if I only need to refine what I have. But does anyone have thoughts on this open-ended generic action/trigger problem? What have you done to tackle it for yourself?

leaden ice
#

More modular reusable components

#

Take Unity's EventTrigger component as an example.

It's an alternative to implementing the event interfaces in your script

#

Instead of making your script implement an interface, you just throw an EventTrigger down and hook up the events in the inspector

#

This is easily doable with a moderate understanding of UnityEvent

#

You can use C# events instead of UnityEvent too

#

You just have to subscribe in code that's all

rustic rain
#

how do i enable emission of a particle system in code?

late lion
leaden solstice
orchid surge
#

I agree on your points. This is largely how the best iteration of the system works, but I didn't think to separate the event trigger out to be its own component. That sounds promising. Inheritance was the primary issue I had with the system and that should solve it.

leaden ice
leaden solstice
#

Yeah looks correct for me

leaden ice
late lion
#

I always forget what order to use when transforming world rotation to local, but in this case, there's nothing else you can use Inverse with and that's the only order you can multiply a Vector3 and a Quaternion, so...

rustic rain
leaden solstice
#

Should be Q * inverse(Q) == inverse(Q) * Q == identity

leaden solstice
orchid surge
swift falcon
#

I have a small doubt. So I want to take the transform of an object and update it by making adding a value to the z coordinte. What is the c# code for that?

#

Does anyone know how to fix the issue Unity won't save my preference for External Script editor and I have to manually select it every time I open my project.

magic fossil
leaden ice
#

or

transform.Translate(0, 0, amount, Space.World);``` (or Space.Local if that's what you want)
rustic rain
#

how do i make the particles relative to the world instead of the player? the way the emission wroks looks very un natural

leaden ice
rustic rain
#

i found it never mind

#

thank you

leaden solstice
dull magnet
# leaden ice ```cs class GridHandler<T> where T : BaseGrid { T ParentGrid; public vo...

Seems to work well with some modifications

public abstract class Entity {
    public BaseGrid ParentGrid { get; private set; }
    public void SetParentGrid<T>(T parentGrid) where T : BaseGrid
    {
        ParentGrid = parentGrid;
    }
}
public class Wall : Entity {
    public new void SetParentGrid<T>(T parentGrid) where T : HorizontalGrid
    {
        base.SetParentGrid(parentGrid);
    }
}
public class Structure : Entity { }

Structure structure = new();
Wall wall = new();
HorizontalGrid hGrid = new HorizontalGrid();
VerticalGrid vGrid = new VerticalGrid();

structure.SetParentGrid(hGrid); // Good
structure.SetParentGrid(vGrid); // Good
wall.SetParentGrid(hGrid); // Good
wall.SetParentGrid(vGrid); // Throws an error at compile time just like I wanted

Maybe the context makes somewhat more sense now. Anyways, thanks again. You helped me out a few times now @leaden ice ๐Ÿ™‚

rustic rain
tawny jewel
#

i have a floppy bird and i want my powerup to always appear right between two pipes, how can i do that

leaden ice
tawny jewel
#

i have them spawned on timer, i dont suppose that would work unless id somehow time it perfectly

edgy nexus
#

I'm trying to install torch for MLAgent, but when I typed the command:
https://download.pytorch.org/whl/torch_stable.html
I get this:

ERROR: Could not find a version that satisfies the requirement torch==1.7.1 (from versions: none)
ERROR: No matching distribution found for torch==1.7.1```

But in every docs I have seen, none of them talk about this issue, did anyone had the same?
unreal temple
tawny jewel
#

alright

frigid anvil
#

Computers can manage a much finer grain timing than humans can notice; if youโ€™re off a pixel one way or another, humans almost never can notice anyway.

tawny jewel
#

thats a fair point

tawny jewel
short venture
#

Does anyone know how to program a randomly generated dungeon

#

Or should i just use an asset?

tawny jewel
#

random spawns for powerups ofc

frigid anvil
formal coral
#

Anyone know why I'm getting this error, even though my Action's parameters match up with my functions parameters?

frigid anvil
formal coral
leaden ice
formal coral
#

what should I use to upload it

leaden ice
#

make sure you saved changes too

formal coral
#

since Ima have to send 2 whole scripts

formal coral
#

nvm im dumb

#

your right

#

I had to update all lmao

short venture
frigid anvil
#

I really love procedural generation (I own all the related assets from the asset store) even though I know it's a crutch on game design. It's just too much fun.

fleet fern
#

I've been having this issue where a tilemap that I've made doesn't apply the Tilemap collider to it, despite having it exist on the object. It showed up randomly a couple of days ago, but doesn't anymore for seemingly no reason. Is this something to do with versions of Unity, or something else?

#

Additionally, any project I make/open with tilemap colliders doesn't actually apply the colliders to them either

lost dragon
#

can someone help me understand why i get this error

UnassignedReferenceException: The variable UseItem of Selection has not been assigned.
You probably need to assign the UseItem variable of the Selection script in the inspector.

using UnityEngine;
using UnityEngine.UI;

public class Selection : MonoBehaviour
{
    public ItemInformation Item;

    //Create to reference later
    Text Name;
    Text Description;
    Text Amount;
    public GameObject UseItem;

    // Start is called before the first frame update
    void Start()
    {
        Name = GameObject.Find("Name").GetComponent<UnityEngine.UI.Text>();
        Description = GameObject.Find("Description").GetComponent<UnityEngine.UI.Text>();
        // Find the "Amount" GameObject from the scene and use its Text Component.
        Amount = GameObject.Find("Amount").GetComponent<UnityEngine.UI.Text>();

        Name.enabled = false;
        Description.enabled = false;
        Amount.enabled = false;
        UseItem.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
    }

    void OnMouseDown()
    {
        if (gameObject.tag == "Item")
        {
            Name.enabled = true;
            Description.enabled = true;
            Amount.enabled = true;
            UseItem.SetActive(true);


            Name.text = Item.ItemName;
            Description.text = Item.ItemDescription;
            // Change the Amount text box
            Amount.text = "x " + Item.HeldAmount.ToString();
        }
        else
        {
            Name.enabled = false;
            Description.enabled = false;
            Amount.enabled = false;
            UseItem.SetActive(false);
        }
    }
}
somber nacelle
lost dragon
#

sorry hit enter early before i had added the code, The issue is that the SetActive(false) works but it causes issues whenever the SetActive(true) is used. i assume its because the object is inactive

somber nacelle
#

did you actually drag the object into the slot on the inspector?

lost dragon
#

Yes, object is set in inspector and sorry i meant, that the UseItem.SetActive(true) works without giving an error, but setactive false gives the error.

somber nacelle
#

either you didn't actually drag it in or you have more than one copy of this component in the scene where one (or more) of them do not have the object assigned

lost dragon
frigid anvil
somber nacelle
# lost dragon

when you get this error in Play mode type t:Selection into the hierarchy search bar and screenshot what it shows

lost dragon
swift python
#

anyone good with keywordrecognizer? I am trying to debug and find a solution, but I am at loss. I generate a keyword list at the start of the game and I just debug logged it. Basically you can see here in the first image that he has created a keyword "seven". On the second picture he throws a keywordnotfoundexception. I dont understand why.

formal coral
#

https://gdl.space/dajimexito.cpp

I keep on getting this error in my code on the given line 41 (i put the code involved in this error in the link), and I don't know how to fix it. It also tells me that it is "outside of bounds of the array" when it is a list. I make sure to check that the Length of each list is the same, and they are, so idk what to do

somber nacelle
#

which is line 77

#

oh nevermind, i see you commented it

#

perkLevelsText[i] is likely giving the error, are you sure it has the same number of elements as perkText

formal coral
#

Oh it seems that the array i created in the inspector was reset

#

yeah thats why

swift python
#

here is my code to my problem

frigid anvil
swift python
#

i didnt want to paste what is in my opinion not influencing the problem

#

its alot else

#

anyway. yes other words are recognized

#

i didnt debug exactly the other words, but i can see in the game that it works and i get "correct" etc

#

for the math tasks i solve

#

im using sth like this

#

its also different every time i restart the game

hollow cosmos
#

is there a commonly accepted way to know when a nav mesh agent is at its destination? im getting inconsistent results when i google

bonus points if i can wait on it via a custom yield instruction, but if i can get a boolean for is done, then i can do the rest

frigid anvil
swift python
#

yes exactly! that is my experience. I didnt investigate entirely which words, but i had the word "two" not being recognized

#

what could cause this? its like he is deleting sth fromt he dictionary?

#

maybe its this: actions[speech.text].Invoke();

Im not exactly sure what I was thinking when i put it in there?

#

idk what it does tbh. i was following a tutorial and experimenting with my lack of knowledge to make things work the way i want them to

frigid anvil
swift python
#

thats the thing. I didnt implement any actions. Basically i am makign a game where you pick up cubes and get math tasks that you can solve with voice recognition. I looked up on the internet and found a tutorial on "keywordrecognizer". The guy explained it with a cube moving according to actions. But all i neded was that i have a dictionary of words that are just numbers, so that the voice recognition only recognizes numbers and if he does find the number spoken to be the solution you get extra seconds

#

so i programmed it in the weirdest way possible and it worked for me

#

but now im just realizing that he occasionally throws these exceptions and you basically say the correct solution but he cant find it in the dictionary of numbers

#

later on now (the tutorial didnt speak about it), i found in the documents of windows speech also a "dictation" function that basically just listens to all your speaking, but that one doesnt seem to be the better choice either because that one listens rather for sentences

#

so yea. its a messy programming but it did what its supposed to. its just these exceptions i want to fix

#

i was thinking of maybe adding the exceptions to the dictionary but i am seeing that you have to create the "keywordrecognizer" dictionary at the start and cant really add to it after? at least thats what im thinking

frigid anvil
swift python
#

oh that is simple. i found a library called "humanizer" and i use their function to translate integers into words

#

so that i can create a dictionary of strings of numbers that i can use for my voice recognition to compare to

#

1 = "one"

#

and if i say "one" i can check that against the dictioanry

frigid anvil
#

I figured, but I find it fascinating that it adds the behavior to int. Anyway, why don't you catch the error, and interrogate keywordRecognizer.Keywords to see if it's in the list?

thorn hearth
swift python
#

i dont know how to. im a beginner in coding. XD @frigid anvil i tried a few things but its always saying it doesnt work in the context and i dont know how to write it down

#

i started with the try catch but then i dont know where to put it and how to write the try

leaden solstice
swift python
leaden solstice
swift python
#

actions[speech.text].Invoke();

#

this i really think. i was starting to change the code lines

#

i think it was this at the line. i will retry the game hold on

frigid anvil
leaden solstice
swift python
#

hold on weird nough he gave me correct for "thirty"

#

but threw the exception

plucky karma
#

What is Actions? Is it a dictionary collection?

swift python
hollow cosmos
plucky karma
#

What datatype is actions @swift python ?

swift python
#

dicitonary

#

i will try and remove that line and see what happens

plucky karma
# swift python

This means that the dictionary list you created doesn't have a key value. You should test it first to make sure the key exist, before executing the call...
Try if( actions.TryGetValue(key, out action) ) action.Invoke();

swift python
#

yea i think that might be the issue, im creatin a dictionary of strings with no "key"

plucky karma
#

I would avoid using string as a key, instead use enum or some other datatype constraint to avoid potential user mistakes.

frigid anvil
#

In this case, the string is coming from the keyword recognizer, so it's kind of an arbitrary thing... I think what you actually want to do is check that the string is equal to the .ToWords(...) of the answer to the math problem. Or something like that.

swift python
#

yea i just removed the line and i get no exceptions anymroe

swift python
#

i think so the issue why sometimes you had to say it more times was either the exceptions or the confidence level

#

now it works okay. thanks a bunch guys!

#

another short question maybe you can help me figure it out faster. I want to "collect" the math tasks in an array. basically every time i touch a cube i will have one displayed at the top and the others be collected in the right box, every time i touch another cube and i didnt finish answering my last question

#

how do i make a 4x2 array ?

#

i want it to look like this [[2+3, 5], [2+0, 2] , ..]

#

first index is the task and the second is the solution

#

i want to discard any cube that is touched after the array is full, i dont want an endless array. i think 4x2 is fine

#

or 2x4

frigid anvil
#

I mean...you could do a Dictionary for that, but you could also create a struct like this:

public struct Pair
{
    public string Problem;
    public string Answer;
}

and then an array of that, like this:

        Pair[] p = new Pair[4];
        p[0] = new Pair();
        p[0].Problem = "1+2";
        p[0].Answer = "3";
swift python
#

ah perfect, thanks a bunch!!!! i will try this out ๐Ÿ˜„

#

my head is fuming and i cant think anymore ๐Ÿ˜ฆ

#

how can i delete the first element of the struct and move everyone up? And how can I add to the stack ? I think i can come up with the latter by just doing a bunch of if statements. if [0] not null, if [1] not null, etc. but the first question im not sure

safe knoll
leaden ice
#

Stack<Pair>

#

or Queue or List if you want those

swift python
#

because i want a fixed size. I will try and see if i can also make them fixed and use the functions

#

thanks @safe knoll @leaden ice

frigid anvil
#

Essentially you can just check the Count() (I think) of the object before adding anything to it, and disallowing it if it's 4, with a nice 'You can't take on any more problems!' message.

swift python
#

true!

#

why didnt i think of that omg.

#

i should go to sleep thanks!!

plucky karma
#

So you don't have to remind yourself what exactly the data in array[2] is used for?

#

Also gives you power to grow in class size too!

rain minnow
#

Or, hear me out . . . use an array . . . ๐Ÿ˜‚

frigid anvil
rain minnow
frigid anvil
rain minnow
#

But it was a joke/jab towards Meta . . .

compact verge
#

Hey I would appreciate some help with setting up a navmesh. I'm trying to build a navmesh at runtime using Navmesh Components, but it isn't generating.

This github page (https://github.com/Unity-Technologies/NavMeshComponents) says that Navmesh Components is now a part of the unity AI Navigation package. I've tried importing the package and using that, and also importing this legacy version with no use. I've also followed multiple youtube tutorials (which are always about the legacy version) and they didn't help either. I'm happy to provide any necessary info / screenshots if anyone needs any. Thanks in advance

GitHub

High Level API Components for Runtime NavMesh Building - GitHub - Unity-Technologies/NavMeshComponents: High Level API Components for Runtime NavMesh Building

frigid anvil
compact verge
#

What is A*?

#

I'm generating a navmesh for a procedually generated dungeon with set bounds, so something like that could work

frigid anvil
# compact verge What is A*?

https://arongranberg.com/astar/ The A* Pathfinding Project. It was one of the first assets I bought; there's a free version, but I don't know if it does on-the-fly stuff.

Yeah, that's exactly what I did it for. I was writing maze-generation-algorithms in C# and wanted a character to walk the maze to the treasure.

compact verge
frigid anvil
# compact verge It works with multiple agents right?

Interesting question; yes, in that I've flooded a zone with robots and had them walk around obstacles using it. They were all the same kind of agent, but different individual actors, so while I'm confident it can handle multiple agents, I've not done it with a variety of different ones all configured differently.

compact verge
#

Thanks for the suggestion but $100 is a bit out of my price range currently. I may want to buy it if there is no other option, but first I would like to see if I could get NavMeshComponents to work.

polar marten
#

maybe start with an example somewhere

compact verge
#

I can't find any with the updated package

#

I have navmeshsurface components attached to each floor object, but when I generate the dungeon again the navmesh doesn't update

#

If I were to hit bake, then randomlyi generate the dungeon again and play the game, it will keep the same navmesh as when I hit bake

#

Which causes the agents to move through walls, and create invisible bounds

warm wren
compact verge
#

And how do I do that?

frigid anvil
warm wren
compact verge
#

I can't manually press bake while the game is in play mode

compact verge
#

Yes

#

It uses the outdated package and didn't work

frigid anvil
#

I figured; just a shot in the dark.

compact verge
#

NavMeshComponents seems to simple to do; just make it so that every object that has a navmeshsurface attached to it generates a navmesh on top of it

#

But seems like you need some extra steps beyond that

#

Or the package just doesn't work

warm wren
compact verge
#

I've installed the outdated package before and followed all steps of that tutorial and it still didn't work

frigid anvil
#

Okay, so...you have the navmeshsurfaces for everything, and then you loop over all of the surfaces, and call BuildNavMesh() on each of them, right?

compact verge
#

I think I'll install the outdated one and get back to you

#

But yes I've done that before

#

I'll try again just to make sure

frigid anvil
compact verge
#

I think that may be the problem

#

Also, what should I include for the first argument, "Build settings"?

frigid anvil
#

There's a link, but it looks like it's a struct with a ton of public members that you can set to behave how you want.

compact verge
#

@frigid anvil Thank you SO much for the help, I finally fixed this issue

#

The navmesh now works as expected

frigid anvil
#

Nice! With the latest version? I'm poking at it myself with a simple two-floor-tile mesh, and it's almost there...

pine coral
#

So im using a bluetooth module to connect an arduino to unity with an asset in the unity store, although I am having trouble reading the data being sent to unity the function that reads messages is

    IEnumerator VehicleMovement() {
        while (BTHelper.isConnected()) {
            if (BTHelper.Read() != "")
                Debug.Log(BTHelper.Read());
            if (BTHelper.ReadBytes() != null)
                Debug.Log(BTHelper.ReadBytes());
                
            yield return null;
        }
    }
```When I dont have the if statements, and just run the debugs, they are just blank/null (I added the bytes just to see if that was the issue)
frigid anvil
#

@compact verge My code looks like this:

    void Start()
    {
        GameObject baseFloor = new GameObject("floor");
        GameObject floor1 = Instantiate(floor, baseFloor.transform);
        GameObject floor2 = Instantiate(floor, baseFloor.transform);
        floor2.transform.Translate(new Vector3(-10, 0, 0));

        List<NavMeshBuildSource> results = new List<NavMeshBuildSource>();
        List<NavMeshBuildMarkup> empty = new List<NavMeshBuildMarkup>();
        NavMeshBuilder.CollectSources(baseFloor.transform,
            LayerMask.GetMask("Default"),
            NavMeshCollectGeometry.RenderMeshes,
            0,
            empty,
            results);
        NavMeshBuildSettings buildSettings = new NavMeshBuildSettings();
        buildSettings.agentRadius = 0.5f;
        
        NavMeshData data = NavMeshBuilder.BuildNavMeshData(buildSettings,
            results,
            fullBounds(baseFloor.transform),
            Vector3.zero, Quaternion.identity);
        Debug.Log(data);
        NavMesh.AddNavMeshData(data);
    }

and it appears to do the right thing. In this case floor is a prefab of a simple plane, the default size. fullBounds reads like this:

    private Bounds fullBounds(Transform root)
    {
        Bounds result = new Bounds();
        foreach (Transform t in root.GetComponentsInChildren<Transform>())
        {
            Renderer r = t.GetComponent<Renderer>();
            if (r != null)
            {
                result.Encapsulate(r.bounds);
            }
        }

        return result;
    }
compact verge
compact verge
#

Oh I can't send it

#

I need nitro

#

:/

frigid anvil
# compact verge :/

If it's too big, use a pastebin or the equivalent. I was mostly curious if it came out roughly the same as what I did.

compact verge
frigid anvil
#

Yeah, pretty similar. I should try tweaking my old A* code to use the stock navmesh instead, like that, and see if it works. 'Course A* includes stuff like, 'If I put this obstacle here, will there still be a path to the endpoint for an agent?', which is helpful. I'm sure there's a way to do that with the stock stuff, though. tl;dr I rely on assets too much. ๐Ÿ™‚

Congrats on getting it working!

compact verge
#

Thanks :)

pine coral
frigid anvil
# pine coral Could someone try and help out? Im not sure on what the issue is

Unfortunately, at least for myself, I have no Bluetooth knowledge, so all I could offer is stock debugging practices. I presume it is connected, so that if() passes. You're talking about getting bytes from it, but is there a helper that tells you if there are bytes to be actually read? In other words, are you possibly reading bytes when it's not gotten anything, and so your data comes back empty?

And if that's the case, are you confident it's sending the data you need/expect at all? What other mechanisms do you have to read Bluetooth data from your hardware project, to validate that it's sending stuff in the first place?

void basalt
#

@pine coralHook your arduino up to the arduino debugger. Are the bytes coming through?

pine coral
#

I was gonna try to just use serial ports instead of bluetooth, but for some reason, im having alot of issues with getting System.IO.Ports installed and to work

pine coral
void basalt
#

So how are you receiving on your computer?

#

bluetooth module?

pine coral
#

Yes, im using a unity asset from the asset store to connect to the module directly, it works with sending data easily, just reading it for some reason it is giving me some issues

void basalt
#

@pine coralWhen I dont have the if statements, and just run the debugs, they are just blank/null What do you mean by this

#

what if statements are you removing

frigid anvil
void basalt
#

That's what I was thinking

pine coral
void basalt
#

You might want to start debugging your computer's actual bluetooth module

pine coral
#

Well, it can send the data using the same concept, so im assuming it works, just for reading it, it isn't exactly giving me the direct data

#

Because it can connect to my computer and I have used it a little bit in the past, just instead of tring to send data, I want to receive it

void basalt
#

can you try sending bluetooth data from your phone to your computer? Like audio or something?

#

not in unity, just in some generic music player

pine coral
void basalt
#

I'm not talking about your phone to arduino

#

I'm talking about phone to computer

#

There's no point debugging code if your module is bricked

#

this is the first step

#

Just because it can send data, doesn't mean it can receive it. Something could be broken inside your module.

frigid anvil
#

@pine coral Okay, so... If I'm reading BTHelper right, you have to give it an OnDataReceived method (and other similar ones). Can you pastebin your code someplace? (And yes, what Burt is saying is critical. Can you get any Bluetooth to talk to your computer, just to make sure your BT module is functional to receive in the first place; it's just eliminating variables.)

pine coral
#

I tried using the OnDataRecieved as well, and nothing came through, but im not sure if that was correct, but give me a second to upload my full code then I can also check the bluetooth thing burt mentioned

#

https://hastebin.com/uqareciloh.csharp
Ignore the using System.IO.Ports for now, I was having issues getting that to work, thats why I went with the bluetooth method because I thought it would be easier

#

@frigid anvil @void basalt I just checked, I could send a file from my phone to my computer through bluetooth

void basalt
#

@pine coralLink to documentation please

pine coral
#

Of the asset im using?

void basalt
#

yes

pine coral
#

Its a pdf, if you are fine with me sending that

void basalt
#

If its a link then yeah

#

just send it

pine coral
#

It isn't the best documented

void basalt
#

is this the asset page?

pine coral
#

Yes

void basalt
#

This plugin only requires .NET 4.x framework

#

did you heed this warning?

pine coral
#

I should already be on one

frigid anvil
void basalt
#

@pine coralWhat data do you need to send from arduino to computer?

pine coral
#

But I could test that

pine coral
void basalt
#

But what is your end goal

real anvil
#

Anyone know how to asynchronously convert a byte array to a texture2d? Loading it pauses the render thread if it's big enough

pine coral
#

Basically sending data through a joystick module (and 2 button modules) on the arduino from the arduino, to unity through the bluetooth module

void basalt
#

yeah

#

I would do serial

#

not bluetooth

#

serial is pretty native. Bluetooth isn't

#

I've gotten serial working in C# between computer and arduino. It's not too difficult

pine coral
#

I was thinking of serial, but when I tried to set up the System.IO.Ports, it gave me an error when trying to download it and I couldn;t figure it out

void basalt
#

You shouldn't need to download anything

frigid anvil
void basalt
#

serial is native in C#

#

I have no idea if this actually works with unity

#

my tests were not in unity

pine coral
#

From the things online about how to do it, I need System.IO.Ports, but I dont have that for some reason

frigid anvil
#

Probably because it's not on .NET 7.0, or at least might not have the Platform Extensions. (It's been a bit; I'm not sure what the latest .NET for Unity is.)

void basalt
#

Yeah that would probably be why

pine coral
#

Would it hurt if I went on a lower .NET for this?

void basalt
#

It wouldn't do anything useful

#

@pine coralBtw your joystick should work with unity

#

like why not just plug it into your computer

pine coral
#

Well ultimately, its for a scholarship im working on, where they want you to connect arduino to unity so

#

I would much rather just go through my computer directly

pine coral
#

The only issue is, that also needs the System.IO.Port library

void basalt
#

Somehow they get System.IO.Ports to work

#

yeah

pine coral
#

I can try and download it and show you my error and see if you can help figure something out

void basalt
#

On different forums, it says you just need to set your api compatibility level to 4.x

#

and then ports will work

pine coral
#

Because my original plan was to go for serialport, get that working, and if I had time to go with bluetooth, but its causing to many issues, so atp, I just want to get serialport working, but I have no clue how to get the port library

void basalt
#

yes

#

go into your settings

#

tell me what your current compatibility level is

pine coral
#

Version control?

void basalt
#

Its in the player tab

pine coral
void basalt
#

Do .net framework

#

the only other option

#

then try ports again

#

it should work this time

frigid anvil
#

It will. You might have to close your IDE, and re-open it once Unity has done all the work of updating it. I just tried that.

pine coral
#

Ah yea, its working now

void basalt
#

yeah, just do serial

#

bluetooth is such a pain in the ass

#

not worth the trouble

frigid anvil
#

I mean it'd be fun, but not if you've got a scholarship thing riding on it.

pine coral
#

Yea

#

I was gonna go with serialfirst, get that done, and if I have time, try bluetooth

void basalt
#

I assume you know how to read bytes into primitives and vice versa?

#

since you will need that knowledge

pine coral
#

I don't fully know about bytes, since the bluetooth also allows for string data to be sent, although I should probably learn that as well

void basalt
#

basically most data types in c# are 4 bytes

#

a byte is 8 bits

#

c# has the byte type

#

if you want to turn your bytes into an integer, float, etc you can simply cast

#

you can also bit shift

#

you absolutely do not want to work with strings for this

#

lucky for you, when reading stuff from serial, the data is already in byte form

#

int _myNewInt = (int)_fourByteArray

pine coral
#

Ah alright

#

I can look into that more, but im gonna get the serial method to work at least for now before doing research and getting side tracked

harsh niche
#

I have a question in regards to null checks. I understand null propagation/null coalescing bypasses the equality check. However this still implies that if the C# reference itself references null, even if it a UnityEngine.Object, should return true.

#

You can see here that when rb has never been assigned yet that rb is null is false. How is this possible?

#

If rb was assigned, then Destroy() was called on rb, the C++ instance would be removed but the "C# handler instance/reference" will remain until all references point to null at which point there is nothing to check anyway.

pine coral
main shuttle
#

It's fake null, is you do .Equals(null) it would have the check if its either really null or fake null, as far as I know.
Not really sure why that is. Might even be a #archived-code-advanced question.

void basalt
frigid anvil
#

Dump out the list of available ports?

pine coral
void basalt
#

yeah

#

you shouldn't be reading from arduino IDE

#

and from C# at the same time

#

that will get you errors

harsh niche
void basalt
#

You shouldn't need to have arduino IDE opened at all. Your microcontroller should be running itself

frigid anvil
pine coral
#

Yea I can run that real quick, I closed the ide and it got rid of the error, so it might have fixed it, I just need to adjust my code now for it to read serial

void basalt
#

Do com3

#

that's what your arduino is using

frigid anvil
harsh niche
#

It should change it. And if it still returns false I will throw my PC out of the window

pine coral
#

Yea I think my issue was just having the arduino IDE opened as well, forgot to close it since I was messing with that code earlier

void basalt
#

If you want, you can also send data back to the arduino, and hook up a motor to make the joystick vibrate when you're shooting something

#

that would be fun

harsh niche
#

Does this have to do with serialization? Thonk

pine coral
# void basalt that would be fun

Yea I could, although it wants me to kinda just control a virtual vehicle using external inputs from an arduino (why, no clue), so I was just using a joystick for basic movements, then buttons for turning but im just getting my code to work now for the buttons and do the rest tomorrow

harsh niche
#

The weird thing is that when I compile, enter playmode, it returns true false but when I exit playmode and enter it again it's true true. (This is also due to the fact that I have domain reloads turned off, although this should technically only apply to statics but I also have the reload scene disabled and this seems like it is influenced by the serialization side of things)

void basalt
#

@pine coralThey didn't want you to have a pedal and steering wheel setup instead?

tender thunder
#

Hi everyone I wanna know how I can populate a dropdown list with the contents of a folder. Can anyone give me clues to where to start?

pine coral
# void basalt <@618313239171694604>They didn't want you to have a pedal and steering wheel set...

Technically, they said make a vehicle in unity, have an external input (controlled by an arduino) then have the arduino talk to unity, so I could have done that, but I was doing it wrong for like 3 weeks and im really short on time to do any of that fancy fun stuff for the scholarship, but its something I could do after just for fun (the way the scholarship was worded was hella weird tbh, me and 3 other of my friends all got confused on specifically what they wanted)

harsh niche
frigid anvil
tender thunder
harsh niche
harsh niche
#
void Update() //Just so that a field of the return value from the getter is assigned and called in Update
{
  Rb.velocity = Vector3.zero 
}```
pine coral
#

@void basalt now that I think of it, do you think me changing that .NET Framework may have also been a factor on the Bluetooth not properly reading? I'll stick with serial until I get it fully working, but just curious on your opinion

void basalt
pine coral
#

Well, I thought it was for VS, not unity

#

Which that is on me

void basalt
#

Regardless, I still wouldn't use bluetooth

#

one more failure point for when you're giving your presentation

#

but its up to you

pine coral
vague tundra
#

Is anyone familiar with reducing coil whine in the Scene view?

vague tundra
#

When panning in scene view, my computer starts making a whining sound. Apparently it's likely coil whine

void basalt
#

Yeah

#

thats not a unity problem

#

thats a computer problem

vague tundra
#

It only occurs inside of Unity

void basalt
#

I find that hard to believe

vague tundra
#

Specifically, only when panning the camera

void basalt
#

unity isn't going to make your computer make weird noises

vague tundra
#

Please let me know if anyone ever has any solutions

void basalt
#

no

#

because there is no solution

#

other than fixing your hardware

#

unity can't just magically make your computer make a noise because it wants to

#

its not possible, and it's dumb to think that

vague tundra
#

You seem unreasonably negative so I'm going to block you

void basalt
#

LMAO

#

"I dont like the answer you gave me so I'm going to block you"

#

sounds pretty much right

harsh niche
# void basalt its not possible, and it's dumb to think that

Pretty sure Unity has perfected motherboard sounds till the point it can make it seem like your fan is making loud noises. Not because the motherboard detects high temperatures due to expensive draw calls but because Unity has a special "PC noise" driver. These are some Unity basics I would expect you to know

void basalt
harsh niche
#

Enough joking around. @vague tundra What Burt said is 99.99% the case. Probably what is happening is that panning in the scene view incurs expensive draw calls that increase the temperature of your hardware. Your motherboard detects this and starts spinning the fans faster

vague tundra
#

It isn't the fans

void basalt
#

this isn't something you fix by switching settings

harsh niche
#

Sorry I dont know what that is, let me consult wikipedia real quick LUL

void basalt
#

that last comment

#

not meant to you @harsh niche

#

meant to the kid who blocked me for giving him advice

vague tundra
#

Anyway, if someone actually knows, please ping me

void basalt
#

LMAO

main shuttle
#

And if you are going to look at coil whine from something without a coil, you are going to search a whole long while.

void basalt
#

GPUs have issues with coil whine

#

the fact that it happens during draw calls is also an indicator

harsh niche
#

It could also come from the inductor coils in his PSU

void basalt
#

It could be anything hardware related, but he doesn't want that answer

vague tundra
void basalt
somber nacelle
# vague tundra recommended channel?

you know coil whine isn't really something to worry about, right? it's also not an issue with the software as it is literally the hardware vibrating at a frequency that you just happen to be able to hear. it is not indicative of any issue and can potentially happen at any load on the GPU/other hardware

void basalt
#

If my card is under RMA you can be damn sure I'm returning it for coil whine

main shuttle
woeful leaf
#

But in this case what Jackson said yeah

void basalt
#

This isn't even a topic for unity

#

its not a unity problem

void basalt
#

apparently theres an option somewhere to turn it off. Sarcasm in case anyone is wondering.

low hinge
#

<@&502884371011731486>

harsh niche
#

Hey whilst we are already derailed anybody know what's going on with what I posted in #archived-code-advanced ? ๐Ÿ˜…

woeful leaf
#

This derailed very quickly indeed

craggy totem
#

Guys, what is better for Low end Mobile device ? -

  1. To have 7 scripts with --- transform.LookAt(camera) --- in Update (30fps) and 1 DrawCalll
    VS
  2. 14 DrawCalls and no scripts
    spend 2 days on shader. and don't know if it even more performant
    Thank you.
harsh niche
#

?

#

If the drawcall is drawing a black screen the lookat will probably be more expensive

somber nacelle
void basalt
#

@craggy totemThere's math happening in transform.LookAt(camera). It's not free.

#

At this point I don't think it matters and I think you're heavily micro-optimizing

#

You even said that you couldn't find a difference on PC

craggy totem
#

1 min i'll show what i meant

main shuttle
#

You could also profile the game remotely on your android.
Also, saying 1 drawcall doesn't mean much. 10 drawcalls for 10 cubes can be more performant then 1 drawcall, if the 1 drawcall is a whole static lowpoly city. (just an example, don't know if 10 or 2 or 100)
So in my opinion, there is no valid answer to your question, you just need to profile it.

woeful leaf
#

The performance here is about the icons. right?

woeful leaf
woeful leaf
#

(Imo it's probably not worth your time)

spark flower
#

Stages = new Dictionary<string, ItemHolder[]>();
when i do this, it will drop whatever dictionary it had and create a new one right? no memory leak

woeful leaf
#

DannyWebbie is writing a whole essay in the meanwhile

oblique spoke
woeful leaf
void basalt
#

@oblique spokeThe only reason I was an ass is because I gave him solid advice and he acts like an asshole about it

#

regardless, I'm over it

woeful leaf
void basalt
#

alright

#

let's let this die

#

thanks

vague tundra
woeful leaf
vague tundra
#

Used it before I posted, thanks(:

low ledge
#

I want to await a task that moves a gameobject's transform from point A to point B
is there any nice way of doing this or will i have to conjure up something nasty using Update

swift falcon
#

How to delete a normal class instance like this? bool is supposed to be SerializeField

void basalt
#

@swift falconYou can't delete classes in C#

#

memory is managed for you

#

just take the object out of storage containers and stop referencing it

#

C# will pile up unused objects, and delete them for you

#

If you TRULY want to deal with unmanaged code and delete objects on demand, I think you can do that in C#, but it's tricky

swift falcon
#

I see, I dont think Ill need that method anyway soon though

#

Im fine knowing I dont need to bother these stuff. But if performance will greatly improve, I'll bite it then :>

void basalt
delicate flax
# vague tundra When panning in scene view, my computer starts making a whining sound. Apparentl...

@vague tundra
Whatโ€™s happening here is that while in the editor the scene view is capped at 30fps while not panning/updating. But during panning the scene view redraw rate is uncapped. Because of this, often if the scene is โ€˜simpleโ€™ enough (compared to your hardware) the editor fps can spike from 30 to 200/2000 rather easily, this then puts strain on the gpu and in turn can cause coilwhine.

You could argue itโ€™s a Unity problem, or a hardware problem, whoโ€™s at fault isnโ€™t really interesting. As for a fix, what I did was limit the max fps for unity.exe in the Nvidia control panel. Iโ€™ve heard that some people are running a custom editor script that limits the fps as well, but I have to experience that.

void basalt
#

@delicate flaxHis question was already answered about 10 times now

#

I think he's good

woeful leaf
#

Might do something

void basalt
#

@woeful leafDoesn't delete the object internally

#

I'm almost certain

woeful leaf
#

I suppose yeah

#

I'm not certain, I don't know how the whole GC system exactly works

#

But it could be of use if you want more "explicit" removal

void basalt
#

@woeful leaf"IDisposable does not 'call' the GC, it just 'marks' an object as destroyable."

woeful leaf
#

ยฏ_(ใƒ„)_/ยฏ

void basalt
#

quoting from stackoverflow

woeful leaf
#

It tells the GC it can be picked up though, right?

void basalt
#

If it meets the criteria, probably

#

if you still hold a reference to an object, it's probably not going to destroy that object. If you call that reference it's going to not be good

#

C# is pretty much idiot proof

frigid anvil
woeful leaf
#

If you call that reference it's going to not be good
I imagine IDisposable would override that

swift falcon
#

how i can remove android support in my unity editor?

woeful leaf
void basalt
#

for probably a few frames

#

or more

woeful leaf
#

Probably, yes

#

I'd think that the next GC cycle or so would pick it up

#

But it'd not instantly vaporise it, no

void basalt
#

Not if the object is sitting in a data container somewhere

woeful leaf
#

ยฏ_(ใƒ„)_/ยฏ

#

Again, I don't know the GC well enough to traverse this topic that much

rain saffron
#

Anyone able to help me work this out? (Grid based vehicle physics/general parent coding concept)

Scenario 1: I have a frame with a starting point (parent), any additions I make to it will be children of either the parent or the previous addition. When a break is applied the first segment of the "loose" part will become its own parent. Easy enough to make/code.

Scenario 2. Same idea, except this time the frame connects at two points. I don't know how to go about this as technically any child can be the parent (using a parent/child system anyways).

Scenario 3. Same as 2, this time (assuming 2 has been solved), how would you handle breaks that completely sever the child piece? You'd need to allocate a new parent, but aside from picking one randomly how would you do it?

I'm sure there's an existing solution, but I can't find one. Games that come to mind are Cosmoteer, and Banjo Kazooie: Nuts & Bolts.

Red = original parent, green = frame, blue = break

thin aurora
void basalt
#

Not a good idea to be calling GC.Collect() whenever. That's a huge recipe for lagspikes

#

source: I've done it

thin aurora
#

Hence why there's no real reason to do it

#

But you know, it's there

woeful leaf
#

Have you attempted solutions for it?

#

Or are you just asking for advice before implementing it

rain saffron
#

Severed pieces need to become their own entity, which I can do since clearing a child's parent makes it it's own parent inherently. The problem I'm having is when there are multiple connection points, making it really hard to think about when it comes to the examples I gave

#

I feel like the normal parent/child system won't work here at all. But I don't know of any other methods related to this

woeful leaf
frigid anvil
#

I mean...I'd imagine it as a particularly stiff rope. Essentially using linked nodes. There's a part of the rope that is between the break and the parent, and part of the rope that is between the break and the end of the rope. In the second case, nothing actually changes, because the parent is still the parent of both sides. The other two cases have a breakpoint that's clear, and anything on that side could become the parent.

#

If you have hinges at the corners, then scenario 2 just disconnects the two sides, and the rest of the hinges swing freely. But if there aren't hinges, the 'break' doesn't actually...do anything, afaict.

rain saffron
woeful leaf
#

Is it not?

#

Is every side it's own entitty

rain saffron
#

Ya

#

Gah this is hard to explain. I think what I'm asking is: how do you make each piece know what it's directly connected to?

woeful leaf
#

So the orange would all be children of the red

frigid anvil
fervent moon
#

So I am using the Oculus Integration SDK. I need to lock the position of the camera as I am using a 360 video, so I have unchecked the Use position tracking on OVR manager which works perfectly, however, the root position of the controllers is still moving based on the movement of my head, any ideas how to lock the root position of the controllers?

golden vessel
#

Hey, how should I go about making a value type a reference type? I want to change one color32 and that several sprite renderer change their color to that color32.

rain saffron
#

Joints look useful for the actual physics, but not the (I'm just going to call them connections from now on) connections part. I've just had an idea though, one sec

thin aurora
#

You will need to wrap it in a class

#

Or your sprite renderers need to subscribe to an event

#

So you trigger that and give the new color

#

You otherwise can't reference a value type in your case

frigid anvil
#

You could wrap it in a property; it won't do precisely what you're asking for, but it would provide some of the features you might want, I think?

thin aurora
#

If Unity is smart enough to get the value from the property again, then that works too

golden vessel
#

Yeah I know that I wouldn't change the type itself, I was looking for some workaround

thin aurora
#

Not sure if Unity has change tracking like that

#

I would advice using an event though

golden vessel
#

Thanks, I was thinking initially about using a class, how would that work exactly? like rend.color = myClass.color?

#

Since the class is a reference type, the color would change if I change the one from the class, is that correct?

thin aurora
#

I think so

main shuttle
frigid anvil
fervent moon
#

that won't work for me, i have locked the camera position but need the controllers not be affected by the position of my head movement

fervent moon
#

ok, thx

golden vessel
#

I'll think about it, thanks for the info ๐Ÿ™‚

rain saffron
#

(forgive my crude paint drawings)

-Each piece will have a list of connections.
-When a piece is added, add a connection between it and the piece it's being attached to.
-Since it's grid-based, check the remaining sides for valid connections to other parts. If any add to connections.
-When a break occurs, check the all the removed part's connections independently and all their connections. If there's more than one distinct group, separate them and designate a new parent from the initial connections.

I think this will work, but coding the grid part might be irritating when it comes to multi-block parts :S

golden vessel
#

Is that a Factorio conveyor belt problem?

#

I was curious thinking about how it works

#

Also your paint skills are sick

rain saffron
#

Basically, I have floating belts that will fall if broken. The issue I'm having is when they have multiple connection points

#

But this will extend to vehicles as well so I want to do it properly

golden vessel
#

Forgive me if I'm mistaken cos I didn't read everything, but in Factorio the belts have a direction, do you have that?

woeful leaf
rain saffron
#

I've not played MC in years, don't remember scaffold?

rain saffron
golden vessel
#

I meant that when you construct it, you give it a direction

rain saffron
#

Oh yea that's just a simple rotation, same as Factorio

golden vessel
#

Cos the way I'd do it, is that each belts have a direction, if there's another belt in that direction, and that belts direction is the same (or 90ยฐ for turns), the object on it can go to the second belt. I'm not sure using physics is necessary at all.

#

Then each belts have a vector of items which are initially empty, and when stuff gets on it, you put it the item to the last place in the vector, and each frame*objectPerSec you move it to the n-1.

#

Just a thought tho you do you

rain saffron
terse venture
#

Hi, Im currently instantiating a prefab:
GameObject FireBall = Instantiate(fireball, transform.position, Quaternion.identity);
Im then trying to remove that FireBall in a script on that fireball after it explodes.
Destroy(gameObject);
This does not work. I have researched about it and have found that you need to be destroying the instance of the PreFab, but im not to sure on how to do this, especially as the destroying is handled by a separate script to the one instantiating it.

#

I think you would need to be destroying FireBall (the instantiated one)
Destroy(FireBall);
But i cannot do this from the fireball script

lucid valley
#
Im then trying to remove that FireBall in a script on that fireball after it explodes.
Destroy(gameObject);

This would be the correct way. So we'll need to see your code to see why its failing

#

Have you debugged and checked that destroy line is running when it should?

#

sorry i didnt use the reply, so i'll ping just in case you arent looking here @terse venture

terse venture
terse venture
lucid valley
#

no console errors?

#

if not then it's very strange if that debug.log is firing but the destroy isnt happening

terse venture
terse venture
mental rover
terse venture
#

It should just work.

lucid valley
lucid valley
#

so thats not the issue

terse venture
#

this also didnt work

rain saffron
#

Just for sanity, try this.gameObject

#

Oh lol

terse venture
#

IM SO CONFUSED

rain saffron
terse venture
#

it just suddenly started working

#

bruh