#archived-code-general

1 messages ยท Page 164 of 1

ashen yoke
#

unity ones, burst, collections etc

main shuttle
#

This is your first error that Steam is not correctly configured, and you should have that file somewhere in that folder it seems. Assuming your stack overflow comes from the Steam problem I would start fixing that.

delicate fulcrum
#

it doesnt

ashen yoke
#

thats just the first error, the oom happens after some native allocators do stuff

delicate fulcrum
#

i get the same steam thing on mono

#

i just need to get rid of that dumb allocator bug

ashen yoke
#

did you update packages?

delicate fulcrum
#

what would change from mono to il2cpp though

ashen yoke
#

the way code compiles

main shuttle
#

Stripping levels are sometimes a problem, but I never seen an error like this from stripping.

ashen yoke
#

they design native collections/allocators, it works for mono, fails in il2cpp because of bugs, they fix it in package, breaks again later because of unity version il2cpp compiler changes, they update packages and fix bug in il2cpp, repeat

main shuttle
#

Anyhow, a few idea's, but make a backup first:
update the packages
make a new empty scene and build only that
Make a new empty project and build only that
That way you could see if its a package problem, a problem in your scene, or a problem in your Unity.
Maybe even make a development build, auto attach the debugger and hope you see where it gets the stack overflow from, not sure if that will work.

late nymph
#

if I have public int i and make it adjustable, and use the script on two different objects, can they both have different values for i or will they be the same?

late nymph
#

alright thanks ๐Ÿ‘

delicate fulcrum
#

wtf i ran it in a memory profiler and it worked

#

ok now it crashed

#

but still

ashen yoke
#

you slowed the leak

delicate fulcrum
#

this is really weird

regal flame
#

<@&502884371011731486>

sleek bough
#

!ban 845796106092412929 porn

tawny elkBOT
#

dynoSuccess dever_#0 was banned.

regal flame
#

thnx, sorry for the ping

main shuttle
hexed sparrow
#

In this specific case ensuring com.unity.entities is updated to version 1.0.11 and restarting the editor fixed it.

whole dawn
#

Hi,

I would like to make a transformation between two coordinate system. I have the coordinate of the green dot in left square and all points with red triangles. I heard about homogeneous transformation, but how do you do that in Unity ?

late nymph
#

how do I get a variable from a script on a gameobject which is "collider" in void OnTriggerEnter2D(Collider2D, collider)

whole dawn
#

collider.gameObject.GetComponent<>()

I suppose ?

late nymph
#

alright I'll try, thanks

wintry crescent
#

Wait no

wintry crescent
#

This assumes both white square/coordinate objects are the same in scale. If they differ in scale, idk. Probably some matrix math, way over my head.

wintry crescent
# whole dawn I do a remap for that

Then it should work, let me know if it does. Just remember to take the local coords relative to the left square and plug them into TransformPoint on the transform on the right square.

calm crest
#

What would be the best way to interact with objects with an animation? I've been thinking of some ways and one that might work is by having the interact animation on the player with the object, when the player is a child object of that object to interact with. In this case I'm trying to do this with a door that will trigger an animation on the player to open it. I need to use this while additively loading another scene since my game is in a style that blends between them.

rigid island
elfin herald
#

Hi all, i have a basic player set up with a rocket launcher, which is a prefab. The rocket is also a prefab, and is setup as a child of the launcher. Everything seems fine until I enter play mode and look around with the player, at which point the rotation for the child prefab bugs out. For horizontal looking around the entire player is rotated, while for up / down only the "tiltobject" object is rotated. The scale for all of the prefabs is 1.

whole dawn
calm crest
#

Not always being a child object of the door just when the animation is played

calm crest
#

Why? Because I need to make the animation lol so wouldn't it be easier to set it as a child before playing that animation

late nymph
#

hmm, I'm thinking that you would have the door have coords, getcomponent of those and implement it into the animation.

#

I am a noob though, probably a better way to do it

calm crest
#

I was only thinking of it like this because I'm using it to change levels

#

It's only a 1 way

whole dawn
elfin herald
whole dawn
#

The second image is when tilt is rotated right ?

elfin herald
#

if any of the parent objects get rotated, that child object also rotates but not by the same amount, for some reason the rotation of the child is being altered when it shouldnt

#

also seems to happen for position, example:

#

Ok, i tried it again and it only seems to be that particular prefab that does it, probably a code issue idk

#

ok, it was a rigidbody with iskinematic set to true that caused this

#

ok, so new question

#

How can I keep a child object, that has a rigidbody on it (iskinematic = true) in the same position relative to the parent when the parent moves?

#

(parent doesn't have an rb)

#

found solution, I just had to do nvm this didnt work lol

shy knoll
#

my player gets stuck when dashing into walls (Warning: messy code because im a beginner)

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

public class Dash_ : MonoBehaviour
{

// Dasht gerade?
public bool dasht_gereade;
public float ZeitSeitLetztemDash;
public float DashReloadZeit;

// Wie Weit ist der dash?
public float Dash_weite;

private void PerformDash()
{
    dasht_gereade = true;

    float dashDirection = sr.flipX ? -1f : 1f;
    rb.velocity = new Vector2(dashDirection * Dash_weite, rb.velocity.y);
    ZeitSeitLetztemDash = 0f;
    Invoke("StopDashing", 0.2f); 
}


private void StopDashing()
{
    dasht_gereade = false;
}

}

elfin herald
shy knoll
#

i send one

#

ok here is it

#

private void PerformDash()
{
dasht_gereade = true;

    float dashDirection = sr.flipX ? -1f : 1f;
    rb.velocity = new Vector2(dashDirection * Dash_weite, rb.velocity.y);
    ZeitSeitLetztemDash = 0f;
    Invoke("StopDashing", 0.3f); 
}


private void StopDashing()
{
    dasht_gereade = false;
}
elfin herald
idle harness
#

Why Unity Engine Treats warnnings as Errors

main shuttle
#

warnings are yellow, errors are red

idle harness
#

Then Can you explain

#

this

elfin herald
#

that's not a warning, despite it using the word

#

can we see the code?

leaden ice
#

I. kinda think this must be a bug recently introduced

main shuttle
#

You have a crap ton of warnings in your scripts, probably at the bottom of that stack trace is an error.

leaden ice
#

I've seen this a couple times now

#

but that does look like it should be a warning

fervent furnace
#

hide inherit component should be warning
weird

main shuttle
#

I would have expected this to be all different warnings instead.

leaden ice
#

in fact that "error" appears to be many different warnings piled into one?

#

strange

idle harness
#

Yes

main shuttle
#

Yeah, I would have expected ~12 different warnings + your error.

idle harness
#

and I also edited that damn code 10 hours ago

fervent furnace
#

there is an error CS8805 in the middle

idle harness
#

and I played that 20 mins ago

leaden ice
#

that is a real error

#

not sure why it's combined with warnings

fervent furnace
#

but the error and warning are grouped to one message, maybe editor bugs

elfin herald
#

just post the code on line 13 or whatever so we can see if its actually the issue or not

idle harness
#

i cant see stacktace of that cs8805

rancid frost
#

How to do this?
I want to prevent gameobject from disabling

leaden ice
#

just don[t disable it in the first place

elfin herald
idle harness
#

It is just warning

leaden ice
idle harness
#

yes

leaden ice
#

but the top level statements thing is elsewhere

rancid frost
idle harness
#

I dont know where it is

leaden ice
#

it's unfortunately not showing a filename/line number

elfin herald
#

name is a reserved keyword afaik

fervent furnace
#

the CS8805 error even does not specific which line and file

leaden ice
elfin herald
#

and so is camera

leaden ice
#

they are used by Component though

#

so this will hide them

#

hence the warning

idle harness
#
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
{
    
}

public class PhaseHandler : MonoBehaviour
{
    struct Dialog
    {
        bool isAllyDialog;
        string name;
        string description;
        float removetime;

        public Dialog(bool isAllyDialog, string name, string description, float removetime)
        {
            this.isAllyDialog = isAllyDialog;
            this.name = name;
            this.description = description;
            this.removetime = removetime;
        }

        void DisplayDialogs()
        {

        }
    }


    public List<int> phasePoint;
    public GameObject MissionDescription;
    public GameObject MissionIndicator; // ๋ฏธ์…˜ ์ง„์ฒ™๋„ ํ‘œ์‹œํ•  ๊ณณ

    [Header("Do not edit")]
    public int currentPhase = 0;
    public int currentPhaseIndicator = 0;

    Dialog dialog1 = new Dialog(true, "Commands HQ", "์•ˆ๋…•ํ•˜์„ธ์š”, ๋‹น์‹ ์ด ๋ฏธ์…˜ 2์—์„œ ๋ณด๋Š” 1๋ฒˆ์งธ ๋Œ€์‚ฌ์ž…๋‹ˆ๋‹ค.", 2f);
    Dialog dialog2 = new Dialog(true, "Commands HQ", "์•ˆ๋…•ํ•˜์„ธ์š”, ๋‹น์‹ ์ด ๋ฏธ์…˜ 2์—์„œ ๋ณด๋Š” 2๋ฒˆ์งธ ๋Œ€์‚ฌ์ž…๋‹ˆ๋‹ค.", 2f);
    Dialog dialog3 = new Dialog(true, "Commands HQ", "์•ˆ๋…•ํ•˜์„ธ์š”, ๋‹น์‹ ์ด ๋ฏธ์…˜ 2์—์„œ ๋ณด๋Š” 3๋ฒˆ์งธ ๋Œ€์‚ฌ์ž…๋‹ˆ๋‹ค.", 2f);
    Dialog dialog4 = new Dialog(true, "Commands HQ", "์•ˆ๋…•ํ•˜์„ธ์š”, ๋‹น์‹ ์ด ๋ฏธ์…˜ 2์—์„œ ๋ณด๋Š” 4๋ฒˆ์งธ ๋Œ€์‚ฌ์ž…๋‹ˆ๋‹ค.", 2f);
    Dialog dialog5 = new Dialog(true, "Commands HQ", "์•ˆ๋…•ํ•˜์„ธ์š”, ๋‹น์‹ ์ด ๋ฏธ์…˜ 2์—์„œ ๋ณด๋Š” 5๋ฒˆ์งธ ๋Œ€์‚ฌ์ž…๋‹ˆ๋‹ค.", 2f);

    // ํŽ˜์ด์ฆˆ ๊ฐœ์ˆ˜๋Š” ๋ฐฐ์—ด์˜ ๊ธธ์ด =.Count
    // ํŽ˜์ด์ฆˆ ํด๋ฆฌ์–ด๊นŒ์ง€ ํ•„์š”ํ•œ ์ง„์ฒ™๋„๋Š” ๋ฐฐ์—ด ์† ๊ฐ’


    // Start is called before the first frame update
    void Start()
    {   
        currentPhase = 0;
        currentPhaseIndicator = phasePoint[currentPhase];
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if(phasePoint[currentPhase] == 0)
        {
            currentPhase++;
            //next Phase
        }

        UpdateIndicator();
    }

    void UpdateIndicator()
    {
        MissionIndicator.GetComponent<TMP_Text>().text = currentPhaseIndicator.ToString() + " / " + phasePoint[currentPhase].ToString();
    }
}

idle harness
#

this is what i edited recently

leaden ice
#

those brackets

#

why are those there

idle harness
#

shit

elfin herald
leaden ice
#

that's probably confusing everything

idle harness
#

I really

#

want to die

#

bruh

#

Thanks everyone

leaden ice
#

is it fixed?

idle harness
#

yes

#

Thanks guys

primal needle
#

Hello. Is anyone aware of any .Net libraries to embed Unity into a .Net web application (specifically Blazor WASM). I would like to embed the game and allow for the following: ```

  1. Allow events from the website to be sent to the game, like pushing a button on the website (as well as keyboard/mouse events)
  2. Allow for the application to pull models/textures from an external repository (a file server) and include them into a scene. The models dont have to be introduced to the scene while it is running, it can be loaded first before the scene starts.```
leaden ice
#

assuming Blazor has ways to interact with JS

primal needle
#

Yeah it does. Yeah, I figure I could just copy the files over like any other website, just wasn't sure if there were any NuGet packages that would be helpful

leaden ice
#

perhaps multiple - depending on which formats you want to support

modern creek
#

Any tips on best practices for localization? Any negatives to using com.unity.localization?

regal flame
modern creek
#

K. I'm not using OI (yet - the pull has been strong though lol) so I'm ok there. Any issues with TMPro? The docs seem to use UI.Text examples

#

I haven't gotten far in the docs yet, just skimming

regal flame
#

tmp pro has worked without a hitch with localization ๐Ÿ™‚ the only thing is to find a good context-aware naming for your keys (imo atleast), and be very well aware that "Accept" could be "brzkneckschwitz" in some language you aren't aware of when adding it ๐Ÿ˜„

modern creek
#

heh

#

What do you mean by "context aware" naming? I hadn't put much thought into my key naming convention/scheme yet

fervent furnace
#

dont cross post

regal flame
#

if your key is for a word or sentence that has multiple meanings i guess.
key: "CompletedText" might mean it's just the translation for "Completed" or it could be the message when completing a level "Congrats on completing level 4, enjoy level 5!"

#

so name keys smart is what i mean ๐Ÿ™‚ so you don't have to think about what key goes to what text

modern creek
#

Yeah, I would probably name keys overly specific like TITLESCREEN_STEP1_TITLE

#

or something :p

regal flame
#

sounds good ๐Ÿ™‚

spring creek
#

Do you have an actual question? You can get help if you just ask it instead of asking for credentials or whatever is going on

modern creek
#

@regal flame Dumb question maybe, but how do I tie the TMPro component to the key?

#

I don't see any "key" field in the tmpro component

regal flame
#

rightclick the text component and Localize

modern creek
#

Ahhhhhhh

#

thanks

regal flame
#

then there is a string field you can update

#

might have to unfold it ๐Ÿ˜„

modern creek
#

Yeah, I got it now.. that was the little nugget of knowledge I was missing ("localize" buried under the right click menu)

#

I'm not sure I love this string table UI editor.. have you done this before at scale? How in the world am I going to get translations into the game easily? I'm currently envisioning something like a google doc spreadsheet with key/translation, I could outsource translation of the strings, but then what.. copy and paste those 1 by 1 into the string table in unity..?

regal flame
#

yeah there is some support for that, haven't tried it through some spreadsheet doc or with a translation service though

#

should be doable - i made a script at some point to bulk-add audio files to the asset table, so you can do plenty that way if you need to

#

they support a few formats for easy adding iirc. don't remember where i saw that but i think i saw CSV atleast

past idol
#

hey everyone, ive been using some scripts that have interactable events attached on them and im trying to trigger these events by code. i tried getting the interactable component and say call the onSelectEntered event but i get an error saying non invocable member. is there a solution for this? thanks!

warm geyser
#

Hey I have a mathematical question, just not sure how to solve it.

fervent furnace
#

is it code-related?

warm geyser
#

Yep

#

Sec

#

So given a units position in 3d space, it is headed in a direction at a fixed speed

solid ledge
#

Hey! I managed to get that thing we discussed yesterday implemented. I added the script to each of the prefabs but I'm lost where to go next? Thanks

warm geyser
#

Now I have another unit who moves at a fixed speed, and I need to create the direction vector where he would perfectly intersect with the first unit.

#

These two units can be anywhere in 3D space, I need to figure out the direction vector of Unit 2 so that it will meet Unit 1 after it's moving a given speed in any given direction

solid ledge
somber nacelle
warm geyser
#

I'm sure there's a mathematical equation to solve this tbh

fervent furnace
#

your first unit can be represented as Pos1+tDir1
then you want to find the Dir2 in Pos2+tDir2 such that Pos1+tDir1=Pos2+tDir2

#

bold font means vector

warm geyser
#

Yes exactly

#

Holy lag

#

They should be equal

#

Wait... I can't just subtract pos2 on the left and get the result can I?

pure cliff
#

are they both moving at the same speed?

warm geyser
#

No

fervent furnace
#

the most difiicult part is |Dir2|=speed given and you have to solve for
X1+tVx1=X2+tVx2
Y1+tVy1=Y2+tVy2
Z1+tVz1=Z2+tVz2 and
|(Vx2,Vy2,Vz2)| =speed

modern creek
warm geyser
#

Like one unit could be moving at 500units/s while the other unit could be 2000/s

#

To give you an idea, it's for AI projectiles predicting where to shoot towards players

mental rover
warm geyser
#

There definitely is a solution

#

This is just a math problem

mental rover
#

well, a real solution, with t > 0

fervent furnace
#

wait for some expert in linear algebra solve this system of non-linear equations...

warm geyser
#

This can be done on just the x and z axis but honestly the approach will still be the same

solid ledge
#

Hey, sorry. Following up from where I left this. I added a "Building" or now called "PrefabManager" to each of the building component prefabs. I'm not sure how to import them now though?

pure cliff
solid ledge
#

So I have a class for Prefab manager, and I now need to get the data from that class into the inspector?

pure cliff
#

But we dont know the constraints of your system so maybe those subsets never actually come up

fervent furnace
#

at least Pos1 and Dir1 and Pos2 are known, may not be much difficult

warm geyser
#

There should always be a solution

mental rover
warm geyser
#

Oh

mental rover
#

if you follow the equations you will get a solution, but it will be with t negative

#

not a "real" solution

fervent furnace
#

the most trivial case
find x such that x+1=2 and x+1=3, it has no solution

warm geyser
#

If the movement speed of the unit is faster than the projectile

pure cliff
fervent furnace
#

there may not be solution of a system of equations

warm geyser
#

I see what you mean now

#

If the projectile has a speed of 50, and the player has a speed of 400 and is moving away from the projectile

#

It will never hit

vast wyvern
#

Hello! Reaching out to see if I am confused on the use of Texture2D.Reinitialize... I want to use it to resize a texture but everytime I do, it results in a grey or corrupted image. For example, I would do something like this:

                QR = DownloadHandlerTexture.GetContent(requestTexture);
                QR.Reinitialize(128, 128);
                QR.Apply();
warm geyser
#

Hmm I wonder how complicated this is then

vast wyvern
#

Am I missing a step in this process that removes the image data? I tried Texture2D.Resize but it says its deprecated and I should use Reinitialize.

warm geyser
#

I'm going to go shower and think about it

#

I'll be back in half an hour

vast wyvern
#

Seems like the documentation is confusing because another person here is having the same issue. I just want to resize an image ๐Ÿ˜ญ

cedar jolt
vast wyvern
#

No. I am receiving an image from an API and I am resizing it to paste it on a model.

#

It comes in at 1000x1000 but it needs to be 128x128

cedar jolt
#

Ho I have no clue how to do that ๐Ÿ˜•

#

sorry

vast wyvern
#

Its okay! I know there is a way to do it, its just finding out how.

#

Pasting it on the model works find, its just too big.

regal flame
modern creek
#

Localization is one of those things that are like "worry about it later when you're selling a million copies" but also, if you do that you have a monster headache of work.. All the embedded strings in that project are enough work for me to just say "sorry, it's gonna be english only"

#

the funny thing is my project is super popular in brazil for some reason, even though it's not available in the store there

#

So portuguese would be an obvious first locale

#

(I suspect that a lot of people there VPN through USA and set their stores to USA for some reason - my game checks country based on self-reported IP, and often these players "sign up" in USA but then sign in later from .br)

regal flame
#

yeah unfortunately it's hard to tell early on if it's even worth worrying about ๐Ÿ˜…

#

if you're making a text or audio heavy game i'd say its worth worrying about early, otherwise its not too big of a hiccup to add later

solid ledge
#

Not the specific script component I added to each?

modern creek
leaden ice
#
public Building[] buildings;```
regal flame
pure cliff
solid ledge
#

ahhh ty!

hard tapir
#

Hmm, why this doesn't work. It shows error object was destroyed. Controller.Func(prefab); Destroy(gameobject):
Controller script... Func(gameobject prefab); Currentprefab = prefab;

leaden ice
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.

vast wyvern
# vast wyvern Hello! Reaching out to see if I am confused on the use of Texture2D.Reinitialize...

If anyone is confused like I am, this does the job!

    {
        // Create a new Texture2D with the desired resolution
        Texture2D resizedTexture = new Texture2D(targetWidth, targetHeight, sourceTexture.format, false);

        // Calculate the step size in x and y directions
        float xStep = 1.0f / (float)targetWidth;
        float yStep = 1.0f / (float)targetHeight;

        // Loop through the target resolution pixels
        for (int y = 0; y < targetHeight; y++)
        {
            for (int x = 0; x < targetWidth; x++)
            {
                // Calculate the normalized texture coordinate for the original texture
                float u = xStep * x;
                float v = yStep * y;

                // Sample the original texture using the normalized coordinate
                Color color = sourceTexture.GetPixelBilinear(u, v);

                // Set the pixel color in the resized texture
                resizedTexture.SetPixel(x, y, color);
            }
        }

        // Apply changes to the resized texture
        resizedTexture.Apply();

        return resizedTexture;
    }
}```
hard tapir
leaden ice
#

you need to give some context as to what is going on here

#

and what you want to happen

#

Destroy destroys whatever object you pass into it

#

nothing more

#

nothing less

hard tapir
leaden ice
#

then player should store that cube inside controller
What does this mean

pure cliff
#

Are you calling Instantiate in your code?

warm geyser
#

I'm back, I am going to try and mess around and look online to see if I can solve this issue

swift falcon
#

hello, everyone. I am looking for a team with unpaid collaboration. Plz DM me.

tawny elkBOT
warm geyser
#

This is just to illustrate the issue I was talking about a little more clearly

leaden ice
warm geyser
#

Wow that was fast

fluid willow
#

doing some Bรฉzier curves

#

not sure what method i will use to calculate it

fluid willow
#

Bรฉzier curves - how do they do?

They're used for animation, text rendering, and all sorts of curved shapes! But how do they actually work? well, like, that's what the video is about, so, watch it to find out etc!!

โ€ข Lots of love to
๐Ÿ’› Jazz "queenjazz" Mickle for making the music โฑ https://queenjazz.bandcamp.com/
๐Ÿ’™ Grant "3Blue1Brown" Sanderson...

โ–ถ Play video
robust dome
#

@fluid willow

 public Vector3 QuadraticBezier(Vector3 a, Vector3 b, Vector3 c, float t)
    {
        Vector3 d = Vector3.Lerp(a, c, t);
        Vector3 e = Vector3.Lerp(c, b, t);
        Vector3 f = Vector3.Lerp(d, e, t);
        return f;
    }
warm geyser
robust dome
#

Codemonkey has a tutorial explaining it, you might want to take a look at the tut

fluid willow
#

btw how do you think i should draw the curves on a texture, i could use a 2d marching cubes algorithm but im not sure yet

robust dome
#

you could use the line renderer

fluid willow
#

im thinking just use the marching cubes and then generate the texture based on the intersection point

#

to speed it up i could also only place the cubes next to the curve so it does not have to check the entire texture

pastel patio
#

I'd like to be very certain, I really can't make interfaces have a fixed method, can I?
I can write a method in a interface like public void act(){} but it can't actually be found by classes that implements it.
I am aware that one could use extension methods to get that effect, but it has some issues:

  • minor issue: The class implementing it needs to have this. to be able to use the method.
  • major issue: Animation events can't locate it, making it inviable for my case.
somber nacelle
#

default interface methods require casting to the interface to use the method

pastel patio
#

Ow... Is that recommended though? Even though the other way require me to write the same method in every implementation '^^
Probably can be slightly optimized by caching its interface after casting

somber nacelle
#

casting to the interface shouldn't really incur any costs unless it is a value type since that would box it. but you have to operate on the instance as the interface if you want to use a default interface method. the alternative is to not use a default interface method and just implement the method on the object normally

pastel patio
#

Alright, I would prefer avoiding to copy-paste the exact same code to anything that implements it, so I'll go with casting.
Probably need to search up what casting is since I don't understand some stuff, anyway, thanks

warm pine
#

https://youtu.be/XtQMytORBmM?t=2648 yo does anyone know how to animate like how he just did ๐Ÿ˜• (timestamp in the link)

GMTK is powered by Patreon - https://www.patreon.com/GameMakersToolkit

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then give you some goals to learn ...

โ–ถ Play video
#

i want to make the flap animation but idk how he did it like that in unity

#

all i have to animate with is a png with the wing going up, down and the bird's body

simple egret
pure cliff
#

A class can both inherit from another class and implement interfaces at the same time

swift falcon
#

How can I create a UI that would only disappear if the user puts in a specific word/phrase?

#

Probably from an array

pure cliff
#

so if you need to have some specific method that is the same on all implementations on your interfaces, you can just do:

public interface IMyThing {
   void SomeMethod();
   void SomeOtherMethod
}
public abstract class MyThingBase : IMyThing {
   public void SomeMethod() { ... }
   public abstract void SomeOtherMethod();
}
public class MyThingA : MyThingBase {
   public override void SomeOtherMethod() { ... }
}

@pastel patio

robust dome
#

@swift falcon you can disable the gameObject the Ui is sittong on or just disable the componenet that is being renderer.

swift falcon
#

Oh wait!

#

I am so dumb

#

Haha thatโ€™s what no sleep does to you

#

Thank you @robust dome

robust dome
#

gameObject.SetActive(false) / GetComponenet<Image>().enabled = false

#

just a small example ;D

swift falcon
#

Thank you :)

tawdry jasper
#

Can a monobehaviour have a static variable pointing to a scriptable object? (I'd like to make a system of collectables or unlockables that can be tracked across several scenes and saved/loaded to player prefs. But I'd like to do it with minimal code / setup changes. Ideally I'd like to drag a prefab onto a scene and have it "registered" - not sure how to accomplish the opposite - to remove a collectible from my project when it's removed in the editor. (because if I just use ondestroy then I'd loose my collectibles at runtime when I unload a scene, right?

leaden ice
#

because that's not how static fields work

leaden ice
pastel patio
# pure cliff so if you need to have some specific method that is the same on all implementati...

Sorry for late reply, wasn't around.
Well, I know that I can do something alike, however right now the system somewhat looks like this:
Creature - Player [IItemWielder]
\
Npc - ExampleCreature

Villager [IItemWielder]

Here it becomes kinda apparent that only some creatures have IItemWielder, and making it a baseclass sounds... Uhm well...
Creature - WielderCreature - Player
\ \
\ Villager
ExampleCreature

Besides the new arrangement, it can also no longer share basic npc functions, so that's why I'd not make IItemWielder a baseClass

Oooooh no... And then remembered that I needed it to be accessible by animation events ๐Ÿคฆโ€โ™‚๏ธ
Basically no matter extension methods or method in interface, they simply don't work.
The only way would then be either writing methods that do the link, or just pasting the method in every class, both end up kinda the same... Gosh I really am not a fan of interfaces, such a headache half the time

quasi flume
#

hi, do you know how in my 2D URP game i can add some kind of effect to the light, like to make the torch look like it actually gives light? because right now all I have is stationary lighting, and it should kind of wave

pastel patio
tawdry jasper
leaden ice
tawdry jasper
#

yeah, that's what I want an automatic way to maintain a project wide list of collectibles. So they're automatically registered when someone adds them to a level in the game, and deregisters if they're removed.

light rock
#

I have a question about collision callbacks. A is the parent of B. if i have a rigidbody on a gameobject A, and a capsule collider on gameobject B, should OnCollisionStay be called on monobehaviours on A, B, or both?

tawdry jasper
simple egret
#

Yeah the collision message will get reported on the object that has the Rigidbody. As long as you got your script there, it will receive OnCollision* messages

light rock
#

yea i just wrote a script to test it and you guys are right

#

kinda annoying but i guess it makes sense thanks

knotty sun
leaden ice
#

doesn't sound right at all

tawdry jasper
#

the hierarchy is to have something to hook when someone removes a collectible from a level, this info will be passed to the scriptable object asset maintaining the list.

leaden ice
#

oh when you say collectible you mean something like a coin?

tawdry jasper
#

yeah

#

should have been more explicit, I was thinking something like a korok in botw

civic carbon
#

Hey I wanted to make an ActionController for different enemies and I also have abilities like the following. Sometimes I need to run a function on another ability if it exists. Do you know a good way to handle it or is sending the ability as a parameter the only solution?

    [System.Serializable]
    public class ActionPunch : ActionAbility {

        public void Init(State _state, Essentials _essentials, Surroundings _surroundings, ActionPunchData _data) {
            state = _state;
            essentials = _essentials;
            surroundings = _surroundings;
            data = _data;
        }

        public override void PerformAction(params object[] parameters) {
            if (parameters.Length > 2
                && parameters[0] is bool wantPunch
                && parameters[1] is bool isDash
                && parameters[2] is Vector3 punchDirection
                )
            {
                if (wantPunch){
                    if(CheckPunchRequirements(isDash))
                    {
                        if(isDash){
                            DashPunch(punchDirection);
                        }else{
                            RegularPunch(punchDirection);
                        }
                    }
                }
            }
        }

        private bool CheckPunchRequirements(bool dash) {
            if(!state.AlwaysAllowedStateChange()){
                return false;
            }

            if (groundTime != null && groundTime == null){
                if (!groundTime.Grounded()){
                    return false;
                }
            }else{
                if(!surroundings.foundGround){
                    return false;
                }
            }

            if(groundTime != null)
            { groundTime.Update(); }
            return true;
        }
    }
leaden ice
#

if you want to call a function on an object, you need a reference to that object

#

the best way to get that reference is highly dependent on your architecture

civic carbon
#

I don't have one yet
that's how it looks basically.

public class GhoulActionController {

Ability1;
Ability2;

UpdateAbilities()
wantAbility1 = true;
Run.Ability1()

}

upbeat copper
#

Im having issues with unity saying basic functions like start are unused? this only started happening like 10 minutes ago and ive tried regenerating project files to no luck

leaden ice
#

So "Unity" is not saying that

upbeat copper
#

Yea i know its vscode? How do i stop it from saying default functions are unused

leaden ice
#

VSCode has a terrible Unity integration. Would recommend switching to a better IDE

#

you'd have to suppress the warnings manually I guess

upbeat copper
#

how can i do that? that seems like an alright solution

leaden ice
#

doesn't it give you suggestions for the warning?

upbeat copper
#

theres two, the top one just removes the start function and the one below just adds private to the start of it

#

which funnily enough DOESN'T remove the problem

hidden flicker
#

I currently have a grenade with these two scripts on it:
Grenade.cs https://hastebin.com/share/yeseculize.csharp, and
Explosion.cs https://hastebin.com/share/ziyukaxagu.csharp.
My enemy has multiple colliders on it, and so my grenade counts each of those colliders seperately, and as such deals damage to the enemy multiple times. Here's a screenshot of the enemy structure, for reference. How would I make it so that the grenade only applies damage for each enemy once, even when contacting multiple colliders on the same enemy?

lean sail
upbeat copper
#

Yea i think ill just bite the bullet and swap, I don't want to go through the hassle just to hide a blue squiggly line and a bit of text

lean sail
jagged flax
#

is there a alternative way to get a sprite from sprite atlas without using getsprite()? the clone of the sprite causes errors

jagged flax
#

basically im trying to assign a sprite from a sprite atlas to a player but anytime i use getsprite in onvalidate the errors pop up

#

like it does work, but the editor doesnt like it

leaden ice
#

You won't be able to save them to the scene file

jagged flax
#

yeah trying to save is how i first got the errors, i wanna find some alternative so it can be shown in the editor since that doesnt work

hidden flicker
jagged flax
# leaden ice You won't be able to save them to the scene file

is there some way to detect and change values before/after it gets saved to the file? im thinking of setting the sprite of whatever has been given a getsprite to null before saving and then reassigning it again when its done (unless you know of a better way to solve this, im just guessing at this point lol)

lean sail
toxic idol
#

one thing which I havent seen on the internet about and dont really wanna bother asking GPT, is there a way to detect an animation that is currently playing?

im 100% aware you can check an animation state, like if the model is on Open or Close or whatever, but my model freezes on the last frame of the animation once its complete, which means it'll always detect it on that animation and its sort of a problem for me as im trying to code a deadbolt right now and want to make sure it cant be used while the door is moving to prevent softlocks

#

so itd be perfect if theres some way to see if theres any current animation playing not frozen and then have the deadbolt be inactive during that time, which i can work out myself but just need info on the former

eager pewter
#

This is my setup for creating a TMP object (everything must be done in scripting at runtime for an unrelated reason)```cs
private void setupTMP()
{
textObj = new GameObject("GrabberText");
textObj.transform.parent = GameObject.Find("Menu").transform;
textObj.AddComponent<CanvasRenderer>();

textVisuals = textObj.AddComponent<TextMeshProUGUI>();
textVisuals.color = Color.white;
textVisuals.fontSize = 50;
textVisuals.font = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().Single(font => font.name == "Blogger_Sans-Bold SDF");
textVisuals.fontMaterial = Resources.FindObjectsOfTypeAll<Material>().Single(material => material.name == "Blogger_Sans-Bold SDF Instruction");
textVisuals.enableWordWrapping = false;
textVisuals.alignment = TextAlignmentOptions.BaselineLeft;

textObj.GetComponent<RectTransform>().anchorMin = Vector2.zero;
textObj.GetComponent<RectTransform>().anchorMax = Vector2.zero;
textObj.transform.localPosition = new Vector3(-854, -531, 0);
textObj.transform.localRotation = Quaternion.identity;
textObj.transform.localScale = Vector3.one;
textObj.layer = LayerMask.NameToLayer("UI");

}```The goal is to put some text in the lower left corner of the screen, regardless of resolution/aspect ration (hence anchorMin and anchorMax = 0). I'm setting the location of the text on the screen w/ the transform's local position (values found through trial and error to get it in the right part of the screen). Now, it works 90% of the time... (the text is Grabs: 0 in the pictures)

#

Now, all that's assuming I boot the game with the intended aspect ratio and then change the resolution... If instead I boot the game in a resolution like the one pictured here, the text loads off screen (in the black bars) and then changing the resolution just moves the text around out of the frame...

#

If I boot the game in a wide ratio, however, it doesn't appear in the corner. Again, changing the resolution moves the text appropriately, meaning it never reaches the corner.

#

Using only runtime scripting, how can I actually anchor the text to the corner of the screen?

glossy charm
#

I have imported dll's of a .NET lib into unity and i'm using it to launch a minecraft instance, everything is working well with offline auth,
but the real problem comes when i need to execute a function to connect to Microsoft account (for premiums), the function should (normaly) open a (integrated i gess) web-browser to login to microsoft account, but instead Unity is throwing me this error :

#

If anyone know something about making this default WebUI to work, i will be grateful ๐Ÿ™‚

lean sail
# eager pewter Using only runtime scripting, how can I *actually* anchor the text to the corner...

skimming through, part of the error is probably related to how you had to manually find that local position to assign. Its quite a large negative value which indicates to me this isnt anchored to the bottom left at all
I dont know much about anchoring through runtime, but an easy solution really would just be do it manually (in inspector) in your own project and debug the values so you can see what you really need to set.

leaden wigeon
#

I don't know what these errors mean, so could someone help? Also, I'm following this tutorial: https://www.youtube.com/watch?v=e2RXDso6fWU


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;

public class PlayfabManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Login();
    }

    void Login() {
        var request = new LoginWithCustomIDRequest {
            CustomId = SystemInfo.deviceUniqueIdentifier,
            CreateAccount = true
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnSuccess, OnError);
    }

    void OnSuccess(LoginResult result) {
        Debug.Log("Successful Login/Account Create!");
    }

    void OnError(PlayFabError error) {
        Debug.Log("Error while Logging in/Creating Account!");
        Debug.Log(error.GenerateErrorReport());
    }

    public void SendLeaderboard(int score) {
        var request = new UpdatePlayerStatisticsRequest {
            Statistics = new list<StatisticUpdate> {
                new StatisticUpdate {
                    StatisticName = "Arena",
                    Value = score
                }
            }
        };
        PlayFabClientAPI.UpdatePlayerStatistics(request, OnSuccess, OnLeaderboardUpdate, OnError);
    }

    void OnLeaderboardUpdate(UpdatePlayerStatisticsResult result) {
        Debug.Log("Successful Leaderboard Sent!");
    }

    public void GetLeaderboard() {
        var request = new GetLeaderboardRequest {
            StatisticName = "Arena",
            StartPosition = 0,
            MaxResultsCount = 10,
        };
        PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError);
    }

    void OnLeaderboardGet(GetLeaderboardResult result) {
        foreach (var item in result.Leaderboard) {
            Debug.Log(item.Position + " " + item.PlayFabId + " " + item.StatValue);
        }
    }
}

๐ŸŽ Support me and DOWNLOAD Unity project: https://www.patreon.com/posts/46591972?s=yt
โœด๏ธ NEXT PART: Design your leaderboard in UI: https://youtu.be/jlZYr9Hbmys
3๏ธโƒฃ Next Playfab part: https://youtu.be/9-vW2z88xCs
1๏ธโƒฃ First Playfab video: https://youtu.be/DQWYMfZyMNU

๐Ÿ’œ Join our Discord (and get help โœจ): https://discord.gg/hNnZRnqf4s
๐Ÿ”ต Follow me on...

โ–ถ Play video
last peak
#

i have a script i wanna use as a base, and i wanna have multiple other scripts that inherit from it, what is the best way to set that up ?

#

for instance all equipment has a script that should be apart of all types of equipment, but the specific types, do diffrent things

#

nvm i figured it out

pure cliff
#

There are a few ways to do that

#

Inheritance, composition, strategy pattern, decorator pattern...

tawny pier
#

Hello, I am looking for coders that could help with the I Love Katamari Reroll + Katamari Amore game. If youโ€™re interested, please DM me. Thanks.

karmic basin
#

hello
could you please assist me
I need some help on ecpm man. I have a super low ecpm and wanna increase it.

tawny elkBOT
pure cliff
red stratus
#

I'm having trouble figuring out how to get the missile to flytowards the target dummy. They orbit around the target. I've also tried setting the angular velocity to zero but that didnt have much effect as well. I have provided my locomotion code these missiles use. What can I do to improve my attempt so these missiles fly directly towards any target and not orbit?

private void Update()
    {
        if (!target)
        {
            GetRandomTarget();
        }
        Vector3 direction = target.transform.position - transform.position;

        direction = Vector3.Normalize(direction);

        //Quaternion targetRotation = Quaternion.LookRotation(direction);
        Vector3 targetRotation = Quaternion.LookRotation(direction).eulerAngles;
        transform.LookAt(target.transform);

        //transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 100);
    }
    private void FixedUpdate()
    {
        if (target)
        {
            Vector3 moveTowards = (target.transform.position - transform.position).normalized;
            rb.AddForce(moveTowards * moveSpeed);
        }
        else
        {
            rb.AddForce(Vector3.forward * moveSpeed);
        }
    }
pure cliff
#

Orbiting occurs when the force moving it towards the target is too weak to pull it in and overwhelm the centripetal force of the object continuing to move forward

#

Your force that corrects the projectiles course towards the target needs to just be stronger to overcome its inertia

calm crest
#

I really need help Ive been sitting here for a few hours and I cant get my head around this shit.

https://hatebin.com/rnuttrauot
So my first script here is linked to another script for a door (yes Ive done a door script like this because I wanted a small cutscene animation to play while opening it because I also need to additively load a scene)

https://hatebin.com/qqbyqsnauv
On THIS loadout script I need my weapons to be holstered automatically. It works perfectly fine with my keys 1,2,3. 3 is just an empty object for hands or whatever, 1 is a pistol and 2 is for a rifle. But for some reason if I call it from that first door script (need them to holster) then it is stuck in a loop of holstering and equipping constantly. The m4IsEquipped does turn false and the pistolIsEquipped does aswell and the selected weapon int also changes, but the weapon I just had out is stuck in that loop

after the animation is done for going through the door, it teleports me back to the original position for a split second aswell

#

will provide footage of what I mean 1 moment

red stratus
bright rover
#

Hey does anyone have a replacement for tags? My tags are about to become a nightmare to manage and I want to know if anyone has a simple alternative

bright rover
pure cliff
bright rover
pure cliff
#

then you can do stuff like

var validChildren = options.Where(o => parent.ValidChildren.ContainsFlag(o.NodeType));
bright rover
#

Iโ€™ll have chat gpt explain like Iโ€™m 5 ๐Ÿ˜…

pure cliff
#

Flagged enums have a method called HasFlag, basically lets you store multiple possible values in a single value.

So you could have

[Flags]
public enum MyFlaggedEnum {
    None = 0,         // 0
    Foo = 1 << 0,     // 1
    Bar = 1 << 1,     // 2
    Baz = 1 << 2,     // 4
    Phi = 1 << 3,     // 8
    All = (1 << 4) -1 // 15
}

And you can have a var of type MyFlaggedEnum and you can store multiple of those "flags" on it, like so:

MyFlaggedEnum fooBar = MyFlaggedEnum.Foo + MyFlaggedEnum.Bar;

And then you can do checks if it has one of em like:

if (fooBar.ContainsFlag(MyFlaggedEnum.Phi)) { ... }
quartz folio
leaden ice
#

Wouldn't they both work?

quartz folio
#

it's also HasFlag, not ContainsFlag

leaden ice
#

I guess as long as you don't add the same one twice

quartz folio
#

and it boxes in this version of .NET so it should probably just be done with the full logic

pure cliff
quartz folio
#

yeah same diff

pure cliff
#

Oh wait wat lol

#

TIL

#

well now I need to go question my relationship with god, thanks XD

pure cliff
#

does IL2CPP not play nice with flagged enums?

dusk apex
#

Addition of values and bitwise OR should be different.

pure cliff
#

but TIL you cant + flagged enums, I swore you could

dusk apex
#

Check the overload for the add operation.

quartz folio
#

What overload

pure cliff
#

the what

quartz folio
#

it literally doesn't compile, because it's a dumb thing to be doing

dusk apex
#

I'm assuming there is else it's simply addition. Ah, flags, not integers..

pure cliff
quartz folio
#

Not even sure you can

pure cliff
#

dang, you really cant

frosty vigil
#

hey

whole dawn
#

Then it should work let me know if it

tawdry jasper
#

General question.. I'm using unity's starter asset pack and it's example third person controller. Is there any reason unity devs decided to use Physics.CheckSphere for the ground check if the charactercontroller component already provides a isGrounded?

quartz folio
agile coral
#

what is it called when you do what he does in the picture on the right?

#

and while I am here, does doing so help with making variables accessible outside of a script or does it even matter?

quartz folio
agile coral
#

making the data visible like that

quartz folio
#

Serializing it?

agile coral
#

ok so that is what I need to learn how to do

#

where do I see serialized data? I swear I have tried to find the answers to these questions on google

agile coral
#

inspector of the script or of the object that contains the script?

quartz folio
#

The instance of the script that is on an object.

hard tapir
#

I don't understand this. I pass that power prefab but later it is null

    public GameObject powerupPrefab; // Assign the prefab in the Inspector
    [SerializeField] private AudioClip pickUpSound;

    public void RaycastEquip(FPSController controller)
    {
        

        if (controller != null)
        {
            controller.ApplyPowerupEffect(powerupEffect, powerupPrefab);
            Destroy(gameObject);
        }
        else
        {
            Debug.LogWarning("FPSController parameter is null.");
        }
    }
}```
scarlet viper
#

Did they change something with

Cursor.lockState = CursorLockMode.None;
in newest unity versions? It wont stay with lockstate none it will change to Locked after one frame

lean sail
scarlet viper
#

nvm i had other code breaking it

lethal plank
#

guys why is this [ExecuteInEditMode] not working?

main shuttle
lethal plank
#

saved
still

main shuttle
lethal plank
#

but i want it run on awake only

main shuttle
lethal plank
#

lemme try

#

hmm thank you

lyric moon
#

would this work? i wanna wait a certain number of frames then call callback

lean sail
lethal plank
#

frame related
how can i force limit fps from one camera?

lusty dune
#
ChessPiece cp = PhotonNetwork.Instantiate(piecePrefab[(int)pieceType].ToString(), transform.position, Quaternion.identity).GetComponent<ChessPiece>();

^ This line gives this error -> DefaultPool failed to load "Rook (UnityEngine.GameObject)". Make sure it's in a "Resources" folder. Or use a custom IPunPrefabPool.

What i understand is, that the prefab name is not coming of right. How do i make it work?

This is the full spawning function -> https://hatebin.com/zeecfqhbdp

#

PieceType is an enum

#

nvm solved it

lethal plank
#

guys
i have a question

#

_attachments = item.ItemData.AttachmentSlots;
this mean i set value from item.ItemData.AttachmentSlots to _attachments right?

#

or am i wrong?

#

because whenever i edit something in _attachments it also edit item.ItemData.AttachmentSlots

lethal plank
#

the same

prime sinew
#

What type

#

What data type

#

A List?

lethal plank
#

ye list

prime sinew
#

Lists are reference types

#

Study up on value types vs reference types

lethal plank
#

oh

summer prairie
#

How do I play a sound effect whenever a ragdoll limb collides with another object? The biggest problem that I'm facing is that my ragdoll manager is on the player, which uses a character controller, so I don't think OnCollisionEnter would work.

#

I need a way to check if the colliders of the limbs and such collide with other objects whilst the script remains inside the main player prefab.

shy knoll
#

use layers

summer prairie
#

Layers...?

#

what

shy knoll
#

layers and Physics 2D

summer prairie
#

I'm doing this in 3D.

shy knoll
#

i meant Phyics 3d

summer prairie
#

Well, I have no idea what you mean by "layers".

#

oh wait

#

No, what I'm saying is that I want my script (which is connected to my player prefab, which contains a character controller, not a collider), to detect if the limbs collide with other objects, layered or not, so that it can execute code upon collision.

shy knoll
#

oh

lethal plank
#

have you try OnCollisionEnter yet?

summer prairie
#

That's the problem that I stated earlier, is that my script is attached to my player prefab, which has a character controller, not a collider.

#

So OnCollisionEnter wouldn't really work at all.

lethal plank
#

oh

#

there are trigger collider have you try that?

summer prairie
#

wdym by that?

#

Like, where are these trigger colliders?

lethal plank
#

in collider

summer prairie
#

The limbs? The environment?

shy knoll
#

and the turn trigger collider on

lethal plank
#

trigger collider will go through object

summer prairie
#

No, there are no trigger colliders.

shy knoll
#

or you do this


public class CollisionDetection : MonoBehaviour
{
    public float collisionDistance = 1.0f;

    private void Update()
    {
        GameObject[] otherObjects = GameObject.FindGameObjectsWithTag("Obstacle");

        foreach (GameObject obj in otherObjects)
        {
            float distance = Vector2.Distance(transform.position, obj.transform.position);

            if (distance < collisionDistance)
            {
                Debug.Log("Collision detected with: " + obj.name);
            }
        }
    }
}`
celest canyon
#

Hi guys I'm a beginner in programming and I need a hand with the movements for the player (which is a rocket) in an Endless runner game that I'm developing to learn.
The game is split into 3 low lanes like SubwaySurf, and another 3 high lanes
The problem I encountered is that in the 3 low lanes the Player Object goes to the extreme points without passing and stopping in the middle lane, so it is practically impossible to stay in the middle lane.
An example:
The three lanes are (-1, 0, 1)
If I'm in lane "0" and I click the "A" key, the player switches me to lane "-1" (the one on the left).
Now that I'm in lane "-1" I have to go to lane "0" (might because there is an obstacle), and this is where the problem occurs, instead of going to the middle lane (0) I go straight to the last one lane (1). And I don't understand why. Can you help me if I send you the code?

lethal plank
#

tick the "Is Trigger" Box

summer prairie
#

But then everything will go through the environment.

lethal plank
shy knoll
# summer prairie But then everything will go through the environment.

using UnityEngine;

public class CollisionDetection : MonoBehaviour
{
public float collisionDistance = 1.0f;

private void Update()
{
    GameObject[] otherObjects = GameObject.FindGameObjectsWithTag("Obstacle");

    foreach (GameObject obj in otherObjects)
    {
        float distance = Vector2.Distance(transform.position, obj.transform.position);

        if (distance < collisionDistance)
        {
            Debug.Log("Collision detected with: " + obj.name);
        }
    }
}

}

summer prairie
#

I meant with anything, layered/tagged or not.

shy knoll
#

you just need to modify that

summer prairie
#

bruhhh

shy knoll
#

?

summer prairie
#

I'm trying to make an open-world game.

celest canyon
#

Guys i need help pls

shy knoll
#

ok

#

whit what

summer prairie
#

My player prefab not only has a character controller, but it's what stores the ragdoll managing script, which is where I want it to detect if the limbs collide with anything so that it can execute code. More specifically, play audio clips.

celest canyon
# shy knoll whit what

I need a hand with the movements for the player (which is a rocket) in an Endless runner game that I'm developing to learn.
The game is split into 3 low lanes like SubwaySurf, and another 3 high lanes
The problem I encountered is that in the 3 low lanes the Player Object goes to the extreme points without passing and stopping in the middle lane, so it is practically impossible to stay in the middle lane.
An example:
The three lanes are (-1, 0, 1)
If I'm in lane "0" and I click the "A" key, the player switches me to lane "-1" (the one on the left).
Now that I'm in lane "-1" I have to go to lane "0" (might because there is an obstacle), and this is where the problem occurs, instead of going to the middle lane (0) I go straight to the last one lane (1). And I don't understand why. Can you help me if I send you the code?

shy knoll
#

can you send a clip?

celest canyon
#

Ok

shy knoll
#

and send the code

shy knoll
dawn dock
dawn dock
#

!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.

celest canyon
celest canyon
celest canyon
dawn dock
#

Yeah I think I see the problem

dawn dock
celest canyon
#

Ok

#

I need to send the link?

#

I use hatebin

dawn dock
#

Yeah

celest canyon
void remnant
#

hello, is there a way to force particles to interact with every trigger, not just the ones in the trigger module list?
I basically want my bullet to detect when it is inside a collider
Also, if there is a better way to do this (maybe without these modules), pls tell me.

shy knoll
#

private void Update()
{
if (keyPressedA == true && transform.position.x > -1)
{
float targetX = Mathf.Clamp(rb.position.x - moveUnit, -1, 1);
rb.MovePosition(Vector3.Lerp(rb.position, new Vector3(targetX, rb.position.y, rb.position.z), rocketSpeed * Time.smoothDeltaTime));
}

if (keyPressedD == true && transform.position.x < 1)
{
    float targetX = Mathf.Clamp(rb.position.x + moveUnit, -1, 1);
    rb.MovePosition(Vector3.Lerp(rb.position, new Vector3(targetX, rb.position.y, rb.position.z), rocketSpeed * Time.smoothDeltaTime)); 
}

}

had the same problem so here

#

@celest canyon

celest canyon
#

Now i try change it

celest canyon
shy knoll
#

ok

#

here

private void Update()
{

if (keyPressedA == true && transform.position.x > -1)
{
    float targetX = Mathf.Clamp(rb.position.x - moveUnit, -1, 1);
    rb.MovePosition(new Vector3(targetX, rb.position.y, rb.position.z));
}

if (keyPressedD == true && transform.position.x < 1)
{
    float targetX = Mathf.Clamp(rb.position.x + moveUnit, -1, 1);
    rb.MovePosition(new Vector3(targetX, rb.position.y, rb.position.z)); 
}

}

celest canyon
#

Ok

void remnant
#

It would be nice to have a "world" flag, just like in the collision module

#

I guess there's none

shy knoll
#

you can useprivate void OnTriggerEnter() and Exit

void remnant
#

you mean ```cs
private void OnParticleTrigger()
{

}
shy knoll
#

yeah

shy knoll
celest canyon
#

No it's the same thing :(

shy knoll
#

๐Ÿ˜ฆ

celest canyon
#

It makes the movement even less smoother

#

Because to not make the object teleporting from one line to another i need to use the Slerp() function but a slerp function needs more than one frame to work

#

That's why i don't simply use the input from a Key

shy knoll
#

you could use Input.Getkey.... and use Timeline to make it smooth

celest canyon
#

Because when you press a key, the Slerp function to move the rocket doesn't work, so i created a bool for each key (WASD) and after some time it return false

shy knoll
#

btw timeline is like animation so it will take time

summer prairie
#

Alright, sorry about my inactivity. Quick medical issues and an overwhelming crowd inside this channel.

shy knoll
#

MGLR did you find a solution

#

?

summer prairie
#

Not yet.

shy knoll
#

do you use colliders in the limbs or not

summer prairie
#

Yes.

shy knoll
#

then use On Collider Enter

#

why cant you use OnColliderEnter?

summer prairie
#

Because the so-called "collider" is a character controller.

#

I'm just trying to figure out how to detect the collision of all of the... Screw limbs, I'm gonna say bones now.

#

Yeah, it's kinda complicated.

#

And that's why I'm asking for input.

lean sail
#

What was the question?

summer prairie
#

I'm trying to make a script where it will detect if the bones' colliders collide with other objects of any kind, and then execute code whenever it does. The problem, however, is the fact that my character is the player which has a character controller component instead of a collider/rigidbody component.

prime sinew
summer prairie
#

Okay.

prime sinew
#

OnControllerColliderHit()

#

i think that's it

summer prairie
#

Well, yeah.

#

But I'm talking about individual bones.

prime sinew
#

Okay

summer prairie
#

So, what do I do?

#

I'm basically trying to detect collisions within children of the script's GameObject.

lean sail
#

Children colliders will still send messages to a parent if that parent has a rigidbody. Not entirely sure if CC follows the same logic but worth a test

summer prairie
#

I've tried testing it. Nothing happened.

#

Not even the Debug.Log functions worked.

lean sail
#

You might want to use some kinematic rigidbody then and just use those collision messages

summer prairie
#

Yeah, but at the same time, it's a ragdoll. Ragdolls can't be kinematic.

lean sail
#

If it's a ragdoll, then your bones have rigidbodies and colliders.

#

Just put a script on the limb and use the collision message

summer prairie
#

I'm trying to do this with every limb because the script I'm talking about is a ragdoll manager which holds all of the code for the ragdoll.

#

Adding a script for just the impact sound effects for every limb is not only time-consuming, but also inefficient.

lean sail
#

You can mass add scripts by just selecting all the limbs and adding at once

summer prairie
#

Like I said, that's an inefficient method.

lean sail
summer prairie
#

They're all calculating their own physics forces because it's a ragdoll!

lean sail
#

Put a script on your limbs then to call functionality on your main script when collisions happen

lean sail
summer prairie
#

Because I think it'll cause performance issues.

lean sail
#

Ok and you can think that, but you havent profiled it and seen any performance issue

lime niche
#

Hello!, I'm looking to learn C#,do you guys have good tutorials?

lime niche
lean sail
lean sail
lime niche
#

Ah okay. Thanks!

lyric moon
#

why the hell not :)

#

ive got an ICollection of strings
i want the first one

#

why cant i just do [0]

lime niche
lean sail
lean sail
tawny elkBOT
#

๐Ÿง‘โ€๐Ÿซ Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

lyric moon
#

not gonna go into it, its not important

lime niche
lean sail
rain minnow
# lyric moon why cant i just do [0]

this is general coding, you should know that ICollection only has a Count and IsReadOnly property. you cannot index an ICollection; if you need to access an element use IList instead . . .

lyric moon
#

i used linq

#

linq works

#

thanks bawsi

rain minnow
azure geyser
#

Hello, so I opened up my project today and VSCode seems to have updated a plugin breaking all intelisense. I saw that there is a new VScode Unity plugin, so I deleted all the other Unity plugins and followed the instructions found here https://code.visualstudio.com/docs/other/unity .

Intelisense is now working but I have errors all over the place in my IDE even though it is compiling just fine in Unity. No external packages seem to be importing correctly and even basic functions like FindObjectOfType apparently not longer โ€œexist in the current contextโ€.

Has anyone experienced the same problem, or know of any possible causes ?

Iโ€™m not sure if this is because I have something setup wrong or what. As someone trying to learn Unity, having the tools break mid project Is really discouraging.

quartz folio
rain minnow
#

VSCode often breaks (for most people). however, i have not installed the new unity plugin from microsoft. it may have bugs or issues . . .

quartz folio
#

If you have access to Rider through GitHub student stuff I recommend that

azure geyser
fervent furnace
#

my vs code even cant open the project, it just keep "processing workspace information in background"

quartz folio
#

Can't you just roll back the package?

fervent furnace
#

After my vs code automatic update to 1.81 then all the stuffs are broken, even reinstall 1.79.2 doesnt help

summer prairie
#

aaaand i just killed the chat

lusty dune
#

What does Instantiate(prefabName, transform) mean? I don't understand why it works cause there's no position or rotation values...

lusty dune
#

Ah that's how it should have been searched in the docs

#

Thx

civic vigil
#

Hello, I have a rolling ball game. Added bumping into objects sound effects.. however due to the nature of the level being separated into several meshes, the sound effects play while traversing from one collider to the other. Looking for a solution if anyone has one, thanks.

whole dawn
#

You can combine mesh to make only one* collider for the whole road

devout fox
#

Anyone got a stomp code i could use? I'm rushing a submission i have. I want to have players stomp on a barricade to get a powerup.

modest blaze
#

Do you have an idea to remove the reference in Visual Studio Code ๐Ÿง

somber nacelle
#

that's code lens. but why would you want to remove convenience stuff like that?

civic vigil
leaden ice
modest blaze
somber nacelle
#

do you just have like hundreds of members per class or something?

#

but also having it enabled makes debugging a bit easier since you can just click on that to see its references

modest blaze
uneven monolith
#

hello, not much unity related, but what datastructure would be best to saving data like this, so like dictionary, but it takes 2 parameters, and doesnt care of their order, Like Dictionary<Pair<var, var>, var> is a solution but it cares about the order of pair,

#

I mean simple way around is just make some rule of asigning them and then ordering by that, for example, the dot with lower x and y value combained is first in the pair always, would do the work, but if there is better ideas i would like to hear them

leaden ice
#

however for what you described you would indeed just use a Dictionary

uneven monolith
#

no?

#

or

leaden ice
#

just make sure the key has a .Equals and .HashCode that doesn't care about the ordering

uneven monolith
#

oh

#

true

#

so i make own class for that

#

and override equals/hashcode

#

that could work

leaden ice
#

e.g.

struct NodePair {
  Node a;
  Node b;

  public override Equals(NodePair other) {
    return (a == other.a && b == other.b)
     || (a == other.b && b == other.a);
  }
}```
#

yep

#

I've done this many times

uneven monolith
#

seems clever, thx

leaden ice
#

I'll let you figure out the HashCode part

#

you could also just put everything in the dict twice - in normal and reverse order

pale island
whole dawn
#

Thank you for the reply I came up with

#

hello not much unity related but what

strong ravine
#

there is a gray square on my screen

somber nacelle
#

this is a code channel, mate. but try restarting the editor

strong ravine
somber nacelle
#

#๐Ÿ’ปโ”ƒunity-talk is the channel to ask in when no other channel fits the issue. but if restarting and updating did not resolve it, then it's likely some asset you've downloaded or editor code you've written

strong ravine
#

hmmm, well, thanks

frozen robin
#

Its shouldnt be visible ingame cuz its a function og gizmos

#

Of

frozen robin
strong ravine
# frozen robin <@198777489575641088>

that I know, I have a friend that we keep sharing this project with github, he does not have this gray square, so I belive it might be something I need to delete on the assets

frozen robin
#

These squares come from gizmos bro..

somber nacelle
rigid island
#

probably a custom window maybe?

frozen robin
#

Oh now i see it

somber nacelle
#

yeah probably a window from some asset if they haven't written their own editor code

rigid island
#

wait 2022.2 isn't even LTS

#

that version probably broken xD

strong ravine
#

'-'

#

gonna update again later, after I finish some things

brazen junco
brazen junco
brazen junco
# fervent furnace After my vs code automatic update to 1.81 then all the stuffs are broken, even r...

It could be that the C# extension is the problem here. I've heard that you can't really control when extension updates are installed, so installing a specific version might get tricky...
However, a workaround (if you don't want to install the preview Untiy extension) could be to install the Insiders version of Visual Studio Code. I have no idea why, but that one seems to work with the very same Unity projects. (But since it's a separate installation, you'll have to reconfigure everything and reinstall all extensions.)

fervent furnace
#

i downgrade my vscode to 1.79.2 (same as the version shown in picture of the guide) and it is just keep loading on it and i google nothing on vscode keep processing workspace information

#

i have tried: restart computer/regenerate project/clear all data in .vscode then reinstall it, nothing work, maybe i should try insider

brazen junco
fervent furnace
#

yes i use it, and i havent back up my previous workable setting, sad

rain minnow
#

Very weird indeed. I received the notification for the 1.81 update but declined it. So far I have no problems, but the new Roslyn warnings/suggestions pop-up everywhere . . .

fervent furnace
#

i am using 2021.3 editor it says at least Unity 2021
i notice that the version of his editor on screen shot is 2022.3.1

azure geyser
gray mural
summer prairie
#

What the hell--??

#

How did you do that??

fervent furnace
#

i delete all files and folders in .vscode and reinstall the vscode then install unity extension.
i havent tried the link you sent, thank

gray mural
summer prairie
#

Noted.

#

Anyway...

#

I was wondering how to call a function from an object in a different scene, since you can load multiple scenes at once. I have a persistant scene that has a LoadGame function that I want to call upon pressing a UI button, but I can't seem to figure out how to get that to work.

fervent furnace
#

static instance
same as what you do when you want a singleton

summer prairie
swift falcon
#

If you activate a Rider free trial in a sanctioned country like Russia and levae within 30 days, it won't ever expire. I have been exploiting this loophole for well over a year and won't ever pay for Rider to use it legitamately.
Does anybody here use Photon Fusion? I need some help with my KCC setup. Basically I don't know what stage I'm able to change data.kinematicvelocity. Any help appreciated!

grand lance
#

I'm having this strange issue with a mesh that I'm baking repeatedly while the Player is dashing to make a trail. I've been following this tutorial here: https://www.youtube.com/watch?v=7vvycc2iX6E&t=1s&ab_channel=GabrielAguiarProd.

For some reason, when the mesh gets baked using the code I've screenshotted, certains parts of the Base Mesh Model (Trousers and Jumper) do not get baked but the Head and Hands do even though they are all a part of the Base Mesh Model and I can't figure out why.

With this Unity tutorial now you can add a cool Trail to your Characters! Super useful for when trying to convey a speed boost or a quick character movement, like a dash. I am speed!!!

I am making a game, check it out: https://twitter.com/GoldenBugStudio

00:00 Intro
00:51 Mesh Trail Script - Start
04:54 Baking the Mesh
08:05 Glow Shader
10:2...

โ–ถ Play video
#

Has anyone tried this method before and ran into a similar issue?

languid saddle
#

this is not code, but i dont know where to ask, i cant build my game, but when the build fails i dont get more error than this :
Build completed with a result of 'Failed' in 128 seconds (128480 ms)
Building Player failed
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

primal needle
#

Hello. I am hoping someone can provide some insight for me. I have a web file server that has a folder full of OBJ files and JPG texture files. I have a simple unity scene that I have built for WebGL deployment, which is embedded into a .Net web application. I would like to be able to dynamically load the OBJ file from the web server as well as the JPG texture file. I've had some luck using https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547 to load the OBJ file but I can't get the JPG file to load with it. Are there any tools (free) that I could use to accomplish this?

#

Would I need a library for this? Or can it be done without something like the obj importer?

topaz ocean
#

If I wanted to do something like store an object's local position only while in the editor, how could I do that? Im thinking something along the lines of fetching it in "OnValidate" but im not sure how to make it not occur while the game is running.

primal needle
ashen yoke
primal needle
ashen yoke
#

doesnt need to be any specific format

#

bundles can pack shaders, materials, whatever else, all you need is the infrastructure to pack and load

primal needle
#

Can this be done dynamically? All I have access to is a file server with OBJ and JPG files. I have to load them into the website webgl unity scene when the page loads

topaz ocean
primal needle
#

No, I can't touch the web server. I can do web request to load the files

ashen yoke
ashen yoke
#

only good thing about your situation is that obj is so simple you can write importer yourself pretty fast

#

unity already can decode jpgs

topaz ocean
ashen yoke
#

you just need the bytes

#

ImageConversion class

primal needle
# ashen yoke yeah then use whatever library you find that works for you, there is no standard...

Yeah, there is an obj import I was looking at, but I dont see how to include the jpg file. It seems to expect an MTL file? https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547

Get the Runtime OBJ Importer package from Dummiesman and speed up your game development process. Find this & other Modeling options on the Unity Asset Store.

ashen yoke
#

mtl file is material

#

its what is referencing your jpgs

primal needle
#

Do I have to dynamically create a Material and assign the JPG to it?

ashen yoke
#

should come with obj

#

obj+mtl is the standard package

#

obj describes triangles/etc, binds material to triangles

#

references mtl's

#

mtls describe material and which textures it uses

#

test it

#

open the obj in notepad, find any material name it uses, try getting that mtl from the server

#

should be in the same dir as the obj

#

if it works, you can automate it, scan the obj for materials, load them from server, load textures it references

#

if there is none, maybe it is assumed one texture per object then you can use any material with that texture, maybe

#

refer to the server docs if there are any

whole mist
#

im looking to add a jump pad feature and the charactercontroller isnt designed to use a rigidbody would there be an easy way to detect collision to just change the jump height and call the jump itself rather than on key pressed with like with raycasts? like in my queuejump method an if statement to detect collision with something specific

warm coyote
#

is anyone familiar with best practices for representing a 2d gridded space with edges? I'm working on a project that involves a large square gridded map and both grid spots and the edges between them would need have information stored about them: A tree would occupy a grid spot making it untraversable and a fence might sit on the edge between two traversable grid spots disconnecting them.

An obvious choice would be a connected graph but this seems utterly too complex and hardware intensive so my initial thought was to simply have a 2d container of grid spots and have each grid spot keep track of the information for the edge north of it and to the east of it, if im missing some better solution i would be thankful for some help and if you have any clarifying questions feel free to ask.

warm coyote
whole mist
#

what would the detection part look like

warm coyote
#

you would want to use the Physics.Raycast() method found here, this would return a bool to whether the ray collided with an object, this could be used to trigger an m_JumpQueued in another if statement like you have. Some tips i would suggest are to 1. place the start of the Ray as close to the bottom of the character as possible 2. make the Ray distance quite short so that you only trigger this when the character is right on top of the jump pad 3. assign the jump pad object to its own layer and specify that the Ray should only collide with that layer so that it only returns true when colliding with a jump pad you should be able to find very comprehensive tutorials online for all of these things, as Raycasts can be kind of confusing to figure out for the first time

whole mist
#

would the start of the ray be defined using a float value near the ground or would it reference a camera placed towards the bottom of the character

#

Iโ€™ve seen versions where they use a cam on the bottom of the character to see if itโ€™s in line with it

warm coyote
#

you could create a child empty object to the character that is at the position you want the ray to start at and reference it or you could simply represent it by the characters position plus or minus some vector 3 offset that places it near the ground

#

i dont think a camera itself would be needed

#

having an empty child object is more convenient IMO because it allows you to visualize that position in the editor

whole mist
#

alright Iโ€™ll give it a shot

warm coyote
#

rather than pluging in numbers and seeing if it works

#

good luck!

whole mist
#

i cant seem to find a down direction for a Transform object

#

i guess i can just rotate it downward

sharp adder
#

Not sure if this is the correct channel to ask this question, but I noticed that a few days ago the Splines package #2.4 was released. I'm in editor version 2022.3.6f1, not sure if that package release is in a pre-release editor version?

pure cliff
#

cuz dynamically loading those files client side is gonna add a pretty heft chunk of load time to the webpage tbh

whole mist
#

ok so i set it up like this but its not initiating a bounce am i referencing the layer wrong?

fervent furnace
#

i found that if i remove all c# sdk then my vscode will not stuck in loading project (processing workspace in background) but instead this pop up:

#

and no intellisense

teal knot
#

am i the only one randomly having issues with vscode giving unnecessary warnings like saying the start function is unused etc

spring creek
teal knot
#

i see, that sucks

spring creek
#

Not sure what, if anything, fixed it. Sorry

fervent furnace
#

my vscode even not working maybe i should report it as bug

spring creek
#

Someone said there was a recent update? Maybe that broke something

simple egret
#

They're rolling out a Unity extension for VSC, in preview

teal knot
#

yeah i presume its related to the new extension

#

installing it didnt seem to fix anything though

simple egret
#

The installation instructions are easier, but they're different nonetheless. You need the C# extension, and in Unity the Visual Studio Editor (not Visual Studio Code Editor) package

#

VSC Editor package will be deprecated soon, because VSC doesn't need it anymore with the new extension

teal knot
#

maybe ill just give up and use the free rider student license i have xD

fervent furnace
#

it says install the unity will automatic install all dependences, you just need to install the ms unity extension

leaden ice
spring creek
teal knot
#

only issue is the license doesnt apply for commercial games

#

but i think i found the fix, just need to downgrade the C# extension version to before 2.0

#

and uninstall the C# dev kit and unity extension with it

#

(thats how you can install an old version)

brazen junco
late rivet
#

Custom keybind manager

eager yacht
# leaden ice if you have Rider Idk why you'd bother with VSC

I use Rider mainly, but recently I've been using VSCode a lot more. It's kinda nice sacrificing a lot of the intellisense speed and debugging support in favor of extremely fast load times and fast project-wide searchs of either text or tokens (such as classes or methods). My main complaint with Rider is how slow it tends to be for me on project-wide searches, so when needing to constantly bounce between closed files or to find a certain method quickly, VSC makes that nicer imo. If I want debugging and stuff, I'll still use Rider though.

teal knot
swift falcon
#

Excuse the really bad paint textures, they were just solid colour materials for testing

#

With this I'd have a similar approach to what you mentioned but I wouldn't have the cell containt information on what is around it... it would just contain what is inside itself and then the cells know where they are

#

Well in my system the cells actually don't know... the chunks handle that

ashen yoke
swift falcon
ashen yoke
#

the original question is about pathfinding graph

swift falcon
#

I may slightly misunderstand but with a 2D grid with more linear movement you can use A* Pathfinding with the 2D grid using the method I mentioned but if the "Graph" thing is a package or something then I might be wrong

#

Because you just grab the cell to see if it's valid using that method, a bit like how Rimworld pathfinding works?

ashen yoke
#

the question as i understanding it is - "i want to avoid using a massive connected graph with each connection represented as reference because it seems not performant"

primal needle
swift falcon
#

It depends how many things are using it, how many cells you have / size and etc because I don't believe it's that bad?

ashen yoke
#

my thoughts on it - depends on the size of the map, even with value based structure you will still hit a ceiling after which you will need conceptual shift to optimize large queries

#

rimworld segments the world into regions, and long distance paths use different greedy algorithm that approximates a path

swift falcon
#

Rimworld did a region system I believe? Where it made bigger blocks and checked if they had connections to other blocks and then if they had a connection, it would then go inside that block to pathfind

swift falcon
#

I am no expert in this though tbh... But there isn't really other ways of doing it?

#

The unity Navmesh does it the same way I believe? A bit fancier but it splits the mesh up into tri's and pathfinds using them as the blocks for A*?

ashen yoke
#

navmesh is less dense

#

generally its so much sparser you have less issues on large maps

swift falcon
#

I need to figure out how I plan to do Pathfinding on my game tbh

swift falcon
#

World changes a lot, I need a way to load the chunks and generate the navmesh which I think the experimental package does

#

Assuming it works with all my cells

#

Worried it might be quite expensive because of all the seperate floors

#

Floor is a lot of these

#

It stresses me out honestly, I really am unsure about my approach

ashen yoke
#

unity navmesh is chunked by itself already

#

you can control its tile size and only rebuild the tiles containing changes

swift falcon
#

I'd need to look into it then, if I can have a Navmesh chunk the same size as my chunks with the same tiles, that would be optimal

#

That being said... I was thinking of loading in the navmesh chunks when my map chunks loads, if Unity can automate that then I shouldn't have to worry about any of that?

ashen yoke
#

the only issue is that you will most likely need to build your own agent, default agent is very limited

#

loading in chunks?

swift falcon
ashen yoke
#

simplest is to build it once, update on change

#

its still going to be there

#

switching on off anything should not affect the navmesh

swift falcon
#

Yeh I thought it would but from what you've said, I guess it might not be an issue

ashen yoke
#

navmesh tile of this size will be fastest at rebuild

swift falcon
#

5x5 units

ashen yoke
#

im just speculating

#

you are paying with more memory

#

and longer large path compute

swift falcon
#

The bulk of pathfinding will be short distances anyway because AI that go outside of the rendered 3x3 chunks will just finish their current path and if they aren't back in a loaded area will just disable

#

The pathfinding won't be rebuilt that often if I can prebuild it...

#

I just thought I would have to build it in game every single time I go into a new chunk

ashen yoke
#

actually

#

you may still need the grid anyway

#

missed the fact you need to extract data from environment

#

enclosed spaces, flood fill searches, etc

#

but at least the pf will be offloaded to navmesh

swift falcon
#

You seem to know far more about this than me ๐Ÿ˜… I only know a little bit, I hope I didn't appear more competent than I am haha

ashen yoke
#

same

swift falcon
#

One thing I need to really think about implementing is how I am going to calculate rooms and houses automatically

scarlet viper
#

why is this particular scene pink?

swift falcon
#

But maybe the Rimworld dev logs somewhere can help

ashen yoke
#

you flood fill

swift falcon
#

At least that would be my first guess

scarlet viper
#

Nvm got it to work

ashen yoke
#

thats all there is to it, you create a general use fill function, you customize it by providing selector/predicate/any logic that should analyze the tiles

swift falcon
#

So do some reading up on "flood fill" is my take

ashen yoke
#

wdym by calculate

#

i.e. this room is enclosed space?

swift falcon
#

When you put down loads of walls and eventually create an enclosed space yes

#

But thinking about it... I could probably trace the walls if it's connected on both sides, follow it around to see if it links back up with itself

ashen yoke
#

never tried this approach

swift falcon
#

Well I've not really heard of flood fill but I can take a guess at what it does

#

I'll have to look into that because it might be better

ashen yoke
#

same as BFS

#

but you dont search you instead visit tiles and analyze them for properties you are interested in

#

in your example it can be, "if there is a tile that doesnt have ceiling above it - we are outside, so the room is not enclosed, so abort fill , this is not a room"

swift falcon
#

hahaha

#

Oh man... I need to sort roofs out

#

๐Ÿ˜…

#

That actually might be the best way to do it

ashen yoke
#

maybe not

#

if you generate roof based on whether a room is enclosed, this wont work

swift falcon
#

Building isn't automated so the roofs need to be placed but my whole world is just 2d currently, no levels... I need to figure that out too and it pains me

I think the roof approach is easier but less accurate

#

Yeh... I think I might shift my focus to making a house in general, figure out a way to define things as rooms, allow building a 2nd floor and etc

#

In general every cell is independent and only holds information on itself, there is no real grouping of any sorts other than chunks.

I need to figure out how I want to store information like "Rooms" and how the cells will link to it

#

@ashen yoke I'll do some reading on the flood fill and thanks for the insight / help

warm coyote
# swift falcon I don't know how much depth your world has but I build worlds using a matrix cla...

appologies, i was afk for a while, the depth is very limited in comparison to this example as there is no map making component, and movement is very discrete between single cells (pathfinding would only be needed for AI and i was planning on using A*) in your example, is movement continuous or discreet? essentially i need my code to be able to determine if movement from one cell to another is valid based on both edge and cell barriers

thorny hound
#

I'm using an audio mixer for the first time in order to pitch shift audio that has been sped up so it sounds normal. That's all working fine. I have an array of clips and I set the clip for the audiosource based on a selected clip. After that clip has played, you can select another clip and play that. Without the mixer, this works great. With the mixer, the 2nd and subsequent plays play a bit of the previous clip first. At the end of each clip I do a Stop() and at the start I set .clip = null then set .clip to the next clip. If I remove the mixer from the audiosource, it works, if I add it, it plays a bit of the previous clip. I'm not using the mixer for all audiosources, I have audiosources all over the place for buttons and whatnot. I feel like I must be missing something obvious. I've looked for a way to "reset" the mixer to no avail. Any clues/ideas/suggestions very welcome.
I found one thing that works, but..... if I do AudioSettings.Reset() there's a slight delay running it, but the sound artifact goes away. Feels like using a sledgehammer to kill an ant though.

swift falcon
warm coyote
#

so each individual square has its own walls

swift falcon
#

Has 2 walls or 2 edges

#

like an "L" shape

warm coyote
#

ah so it is similar to my concept

swift falcon
#

my old original one there was 4 and it was such a pain determining where the walls went... I also had to check neighbour cells to see if I was replacing it or if it already existed on neighbour and etc

#

So yeh probabily similiar to yours

#

1 floor, 2 walls, 1 corner

warm coyote
#

thanks, i feel much more confident in the implementation i have now

swift falcon
#

It just felt like the most logical approach

#

The only issue you get is that the the furthest top and right edge can't be populated

#

Of the entire map

warm coyote
#

yea, ive basically accepted that once i get to proc generation ill have a one tile border around the map

swift falcon
#

Well my chunk system helps with that

#

It just gets the next chunk on the corner but if you have a more static map just make the one tile border invisible, it's a cheap fix but players won't notice

#

The other solution is logic specifically for the end but I think it's more work than it's worth, better invested elsewhere

warm coyote
#

yea, im hoping to implement a kind of wave function collapse as an easier method of proc gen and my maps will be relatively small 100x100 as a maximum size so hopefully those wont me major issues

swift falcon
#

If you are doing proc gen then it'll honestly be very similiar to mine then

#

How do you access tiles? Have you got a grid class to handle it?

#

Or do you just have an array by flattening the Vector2?

warm coyote
#

i havent really started the implementation as i was planning this aspect out first, but i expected to have a map class that contains 2d array of scriptable objects taht each represent the tiles

swift falcon
#

I see, so your tiles are going to be predefined

warm coyote
#

yea, the static content of the cells will either be designed in a testing map, or eventually proc generated before play, entities will be able to move through tiles though

swift falcon
#

I won't pretend to know a lot about pathfinding, I did some fundamentals a while back in uni so I can't guarantee this is the best advice but to your original question, what do you mean by a "Connected graph"?

#

Is that like caching A* results?

warm coyote
#

when i suggested a connected graph for storing the data thats the easiest way to think about this grid in a literal sense because it is nodes connected by edges so you actually have a place to store the edge information that is the edge itself

#

the idea being that if i stored the map data in a graph that "looks" like this

#

if i wanted to represent a wall in code

#

i would flag that edge in the graph as a wall

swift falcon
#

Ahh I remember

#

An Adjancency matrix?

warm coyote
#

but iterating through a graph is taxing and its hard to access a specific part of the graph intuitively

#

so in the above case each circle is a cell and the lines connecting them are the edges between

swift falcon
#

I think adjacency matrix might be wrong for that case...

#

But if you did a region based thing it might be useful to see if places are reachable

warm coyote
#

yea thats true

swift falcon
#

So there are multiple factors to see if you can go on a tile?

#

Like for instance the floor type, the edge? What's on the tile?

warm coyote
#

yea for example, the tile itself might be totally blocked cause there is a tree occupying it, or the edge between the tile you are on and the destination has a wall or fence on it

#

in either case you cant move from the tile you are on to that tile

swift falcon
#

If there are multiple factors you could save on computing but take a bit of memory if you do precalculate these and put them into an index like that

warm coyote
#

yea, listing for each tile, you can go up, down, left, but not right might be useful

#

depends on the compute time and the map size i imagine

swift falcon
#

Are you going to store these as an array of bools with a quick lookup?

#

For consistency when it comes to numbers I start from down and go clockwise
0 = down
1 = left
2 = up
3 = right

And I use that for everything

#

cell.validPath[3] for instance

warm coyote
#

yea thats probably how i would do it

swift falcon
#

But you do get a lot of duplicate data then

warm coyote
#

if i really wanted to be efficient i would calculate at run time if the path hasnt been traveled and then store the result for future

swift falcon
#

Maybe but I wouldn't worry too much about that to start with

#

Each cell is stored as what?

warm coyote
#

i was planning to write a scriptable object to store them

swift falcon
#

1 SO for each tile?

warm coyote
#

i dont think i need a fully fledged class but i might need one

lean sail
#

a SO is still a c# class..

civic locust
#

i'm getting this weird behaviour and I can't explain it. I have set all of the values in the inspector as well

#

I just run my script and nothing is actually interfereing with it

#

code dies here

swift falcon
copper blaze
#

is there a significant difference in choosing lf or crlf line endings for unity projects?

warm coyote
swift falcon
#

The stuff I can spawn are SO's because they all behave and interact with the world in a similiar fashion

#

But my Matrix and Cells use classes with polymorphism

#

SO is good for things like this

#

SO might be suitable for your tiles as they are predefined... it really depends

swift falcon
civic locust
#

bruh wtf, i found the problem

#

somehopw

#

idk how the fuck right

#

the camera had a game manager script

#

so the singleton was wiping my array

#

smh

lean sail
swift falcon
# warm coyote i think thats just waht im used to using but in hindsight its probably just best...

Sorry sometimes it's difficult because I get a bit tied on my thought process for my game, my cells have a lot of autonomy but in your case I think you just get the world to create the map 1st and then have it loop through each cell to evaluate the link connections and on each tile set the bools in the array for if it is a valid movement.

Sorry for the long discussion for your question btw lol

#

Or you can create a 2nd grid which only contains the bools of where it's allowed to go.

Personally I'd have it on the cells because it means I can just grab the tile and have additional info if I need it... Like for instance if you have certain units that can bypass certain things like fences

warm coyote
#

no worries, i think at this point its most valuable for me to start implementing some of this and see what sticks, cause atm this system exists only in my mine lol

swift falcon
#

I have an idea for you

#

Instead of bool, store your allowed movement as an int for each direction
0 = can't move
1 = can walk over
2 = can jump over
3 = can fly over

#

Depends on your game... just a random idea if you wanna do stuff like that ๐Ÿ˜…

warm coyote
#

yea thats good, cause i will definitely have flying units in the game

#

thanks for all the advice, i have to run to the store so ill be afk again

swift falcon
#

Yeh so have something like... movementLevel on the unit and you just check directions to it's movementLevel to get allowed directions

#

Alright! np and gl!

warm coyote
#

ty!

copper blaze
lean sail
solid ledge
#

What's the best way to animate sliding doors to open on player proximity? Do the actual doors need to be different meshes to the frame?

soft shard
solid ledge
lean sail
solid ledge
#

Ah k ty.

#

Can I have trigger areas in prefabs?

spring creek
#

Yes, it can be on prefabs

#

Or a child with a trigger collider if it's off to one side or something

solid ledge
#

ty

solid ledge
spring creek
#

Sphere or Box collider. 2d ones say 2d at the end, 3d ones say nothing at the end

solid ledge
#

ty

spring creek
#

And also, of course, spheres and boxes are 3D shapes

cobalt gyro
#

Does anyone know why ```cs
Camera.main.WorldToScreenPoint(worldPosition);

unreal valley
#
    JumpHeightBuff, Assembly-CSharp (1 object)``` Anyone have any idea on how I can fix this?
#

Ohhh i see. It was a Scriptable Object. And it was null for some reason when I opened unity. Strange

#

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

solid ledge
#

Oh, "Is Trigger" I assume mb

#

I now have the colider set up, I have it set the door scale to Y 0 on enter, but it's a really sudden jump to open - how can I animate the door opening?

devout harness
#

JSONUtility creates a default instance of an object, then populates/sets each field as it reads the json file when deserializing?

#

And the [OnDeserialized] attribute makes that function get called afterwards?

somber ether
#

Create animation and controller. add controller to the door parent

narrow blade
#

does anyone know how to fix this so it has collision

        if(Input.GetKey(KeyCode.W)) {
            transform.Translate(Vector3.forward * Speed * Time.deltaTime);
        }
        if(Input.GetKey(KeyCode.S)) {
            transform.Translate(Vector3.back * Speed * Time.deltaTime);
        }
        if(Input.GetKey(KeyCode.A)) {
            transform.Translate(Vector3.left * Speed * Time.deltaTime);
        }
        if(Input.GetKey(KeyCode.D)) {
            transform.Translate(Vector3.right * Speed * Time.deltaTime);
        }```
somber ether
#

Collision as in? If you mean the character itself, need to add a capsule collider - not code

narrow blade
#

no that does not work i have had that for a longtime

lean sail
#

Then when your raycast hits something, you now have the max distance from the raycasthit variable

narrow blade
#

so i do a ray cast in the dirction you are moving in at the length of speed and if it hits then touchingWall = true?

lean sail
#

Well theres a LOT more that goes into making a proper character

#

You could use KCC on the asset store

narrow blade
#

ik i have a lot more code

#

is this good code?

lean sail
#

!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.

narrow blade
#

i tried this and it does not work

lean sail
#

you should look at some basic movement tutorial

#

there are hundreds, and they 100% cover this

narrow blade
#

how would you do it