#archived-code-general

1 messages · Page 346 of 1

hexed pecan
#

@hearty merlin Show your input manager settings for the vertical axis?

#

Do you have separate gas/brake pedals? 🤔 If yes, do the same with those

heady iris
#

Those would be providing the Y inputs

hearty merlin
#

pedals did nothing.

ancient magnet
#

Hey, how do I check if I'm on mobile (Android) or PC (Windows, Linux) using the #if statement? I could only find UNITY_STANDALONE and UNITY_STANDLONE_WIN and PLATFORM_STANDALONE and PLATFORM_STANDLONE_WIN, but I'm not sure what they do.

gray thunder
#

UNITY_STANDALONE_LINUX, UNITY_STANDALONE_WINDOWS, UNITY_ANDROID

heady iris
#

Check this out

ancient magnet
heady iris
#

If a symbol isn't defined, C# doesn't have any clue that it could ever possibly exist

knotty sun
ancient magnet
#

Alright, thanks a lot of the help 👍

hearty merlin
#

i also can send a video of what the player is doing when I press play.

hearty merlin
#

nevermind, finally fixed it. only took 6 hours

karmic sand
#

hey im trying to procedurally create a terrain mesh but am having an issue with it not rendering the mesh when i increase the depth or width like theres some sort of limit to the amount of triangles it can render.

heres my code https://pastebin.com/Xqh6zekY

as you can see in the image below 256x256 works fine but as soon as i go over that it doesnt even though its still generating the triangles.

#

nevermind didnt realise there was a limit on mesh vertice count 😭

heady iris
low crag
#

hey guys, I'm trying to make a simple curved world, and I already made a shader to achieve the visual result, but I'm getting some issues with the trigger collider I'm ussing to put another gameobject of my pool in front of the other piece together, I have some printscreen, but:

  • I can handle different to achieve that?
  • or maybe exists a simple solution for that?
heady iris
#

You have not stated what the problem is.

low crag
#

the problem is to set correctly the position, as you can see, the colliders are getting pretty close one to the other, it's strange to work like this, with a anchor point far away to the road curved

#

I'm just looking for more consistency

heady iris
#

If everything uses the curved world shader, then it'll work out correctly.

low crag
#

actually the road segment it's a prefab, all with the same default material with the shader

heady iris
#

all of the game logic will work on a straight line

#

the visuals will just get distorted

low crag
#

but look, why I'm getting different location at my colliders of the same prefab?

#

I change the values to not curve to show it

heady iris
#

Get rid of the curved material entirely to make sure.

low crag
#

well, I'll stay with this solution, and try to adapt

heady iris
#

not to permanently remove it

#

I just want to rule out anything shader-related

heady iris
low crag
#

I was just wondering if this is a really good solution, or maybe I should try something different

#

because the shade make not so easy to put all pieces together to achieve a infinite curved road

heady iris
#

Using a shader to make a "curved world" effect is reasonable. I've done it before.

#

you just have to remember that this has no effect on anything other than the visuals

#

So you will see the visuals "detaching" from your objects

#

And there are some cases where you do have to manually move objects to match the shader curve

#

For example, if you have lights, those need to be moved

low crag
#

but probably I'll get some issues to fit the pieces right?

bright relic
#
                uOffset = (adjPos.x % tilingFactor) * tileSize;
                vOffset = (adjPos.y % tilingFactor) * tileSize;
                break;
            case Direction.East:   //X+
                uOffset = (adjPos.z % tilingFactor) * tileSize;
                vOffset = (adjPos.y % tilingFactor) * tileSize;
                break;
            case Direction.West:   //X-
                uOffset = (adjPos.z % tilingFactor) * tileSize;
                vOffset = (adjPos.y % tilingFactor) * tileSize;
                break;
        }

        uvs.Add(new Vector2(uOffset, vOffset + tileSize));
        uvs.Add(new Vector2(uOffset + tileSize, vOffset + tileSize));
        uvs.Add(new Vector2(uOffset + tileSize, vOffset));
        uvs.Add(new Vector2(uOffset, vOffset));```  left some cases out to make the message shorter, how can i correct the offsets for z- x+ and y-? this works fine for the other 3 directions
heady iris
#

Assuming they're all being distorted in the same way, they'll still fit together

maiden stone
#

For example, if I have 3 sounds in my scriptable object, and I go through each of them, increasing the index, gameobjects are returned, however, they all are the last audio clip that was input.

audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[0].ReadAudio()));    audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[1].ReadAudio()));     audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[3].ReadAudio()));
low crag
maiden heath
#

any ideas?

heady iris
low crag
#

I mean the object road put in front of the other object, doesn't fit in the position, and I was trying to adjust manually

#

but seems annoying

heady iris
#

If they line up with the curving disabled, and your curving shader is written correctly, they'll still line up when you turn on curving

low crag
#

well, let me try fit without curve and test

ivory smelt
#

Hello, im building a little popup message and I wanted to know how to target this task:

  • Using a singleton to access the functions from any class (I already have a few and I think I shouldnt have too many but idk)
  • Using a static class (I think its not possible since I need to attach a prefab somewhere, explanation below).
  • Attaching the script to the canvas and calling it a day.
  • Something else Im missing.

I either can render the popup to an existent canvas or create a temporary canvas from code and render it there, but I 100% need to be able to have the popup panel (background, buttons, etc) in a prefab.

Which solution should I pick?

low crag
ivory smelt
#

But is it possible to attach the prefab to a class that is not assigned to a GameObject in the inspector?

low crag
#

yes, for sure? just a prefab?

ivory smelt
#

ye

low crag
#

you can use a gameObject or Transform reference serialized to put your prefab

ivory smelt
#

and in the code I should put the name of the prefab as string?

#

like,


void Awake()
{
prefab = GameObject.Instantiate((UnityEngine.Object) Resources.Load("Popup"), Vector3.zero, Quaternion.identity);
}```
low crag
#

wait a minute

ivory smelt
#

sure

low crag
#

you can't make like this

#

as I can see, you want to instantiate a resource for your project

#

right?

ivory smelt
#

Yes, an UI element in this case

low crag
#

ok, and why you need this object?

#

change movement or something?

ivory smelt
#

its a popup confirmation window,

"u sure?"
"yes/no"

#

and then i pick the resulting bool

#

and perform x action

low crag
#

ok got it

heady iris
low crag
#

maybe it's a lot of easier for you, just have a Canva with Modal object and set active, when it's necessary

heady iris
#

Two vertices at the same position on different objects should wind up at the same position after the curving

ivory smelt
#

I know how to make it work, i just dont know wich approach is the best in order to keeping the code clean and logic

low crag
heady iris
#

One issue could be if this is an HDRP game: it uses camera-relative rendering by default

#

hence there being the Absolute Position node, which isn't camera-relative

low crag
#

it's urp

low crag
#

and then handle all types of menu inside my game

ivory smelt
#

Yeah, I have a small addiction to singletons

low crag
#

ok, cool

ivory smelt
#

So, another one cant hurt, right?

low crag
#

now, it's good to have a canvas for this modal popUp and active the reference

low crag
ivory smelt
#

maybe i should just stick it to the screen manager?

low crag
#

in MyScreenManager you can handle

ivory smelt
#

alr

ivory smelt
#

Welp, that was pretty much it

#

Thanks buddy!

low crag
#

yw

maiden stone
#

I have a method which creates a new audio source with a clip. When calling this method through another script multiple times, it sets all of my clips to the most recent time I run the method.
Why could this be?

somber nacelle
#

show the code

leaden ice
grim gyro
#

Has anyone encountered such a problem?

maiden stone
# somber nacelle show the code
    {

        AudioSource audioSource = GetAudioSource();

        if (audioSource == null)
            return null;

        audioSource.name = clip.name;
        audioSource.spatialBlend = 0f;
        audioSource.clip = clip;

        return audioSource;

    }

    private AudioSource GetAudioSource ()
    {
        foreach (AudioSource source in audioSources)
        {
            if (!source.isPlaying)
                return source;
        }

        if (audioSources.Count < maxSources)
        {
            GameObject newAudioSource = new GameObject();
            newAudioSource.transform.SetParent(transform);
            audioSources.Add(newAudioSource.AddComponent<AudioSource>());
            return audioSources[audioSources.Count - 1];
        }

        Debug.LogWarning("No available audio sources found and maximum number of audio sources reached.");
        return null;
    }

This error happens when I try to run this under start:

        audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[0].ReadAudio()));
        audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[1].ReadAudio()));
        audioQueue.Add(soundFXHandler.GetSound2DRaw(inputMusic.Sections[3].ReadAudio()));
leaden ice
grim gyro
#

No

#

This problem occurred after reloading the project. It's very strange

maiden stone
grim gyro
#

😶‍🌫️

maiden stone
spring creek
grim gyro
#

3d. But, I recently migrated a project to WebGL. Is CharacterController not supported in it? I haven't found any information about it, plus everything works on other platforms...

grim gyro
#

Well, this is sus

heady iris
#

Show me your package manager window.

#

oh yeah, you can also just look in the "Physics" section of the Project Settings, it looks like

#

it looks like unity 6 rearranged the menus a bit

grim gyro
#

Default settings

heady iris
#

you have no physics engine selected at all

grim gyro
#

Hm, so that's what they changed

rigid island
#

well ofc its not working 😛

heady iris
#

you may have switched it by accident, since I doubt that the default is now "no physics Crab "

rigid island
#

yeah def not default

grim gyro
#

Oh, yeah, it's working now

#

Thanks 🙏

swift falcon
#

#texture

#

Where is texture chat?

lean sail
vivid halo
#

This is a very common approach that should work for you

#

You could consider using a constant seed for debugging if you want to make the process a little easier

#

Nice, good luck with it!

low crag
#

@heady iris I remade my shader, now it's working fine

heady iris
#

nice (:

low crag
heady iris
#

If you want to put lights on the track, you'll need to implement the same bending logic in C#

#

(or anything else that you can't bend with the shader)

low crag
heady iris
#

lighting turned out to be a major pain in the ass for other reasons

#

the lights wouldn't light up the track properly if it was curved far enough

#

because Unity thought that there was no way for the light to affect the mesh at all

#

I need to go re-visit that

low crag
#

god damn

#

well, maybe I can afford of this, it's just a mobile game, I want to make it simple

#

but decent

heady iris
#

For a mobile game you probably don't want to use realtime lights anyway

low crag
heady iris
#

they also wound up being kind of ugly lol

low crag
#

I'm not sure

low crag
heady iris
#

I don't know much about mobile performance

#

bloom doesn't seem too expensive though

low crag
#

thanks again

spare island
heady iris
#

sounds like the code is wrong, then

#

or you have some other configuration that is incorrect

#

e.g. you need to change something in the cloud dashboard

spare island
heady iris
#

oh, the join code

#

not your actual c# code

#

What is the full error?

spare island
#

oh right it got cut off

heady iris
#

Note that a 404 would not be the expected response for a bad join code

#

you'd expect a 403 (Forbidden)

spare island
#

really doesn't give me any information

heady iris
#

show your !code

tawny elkBOT
spare island
heady iris
#

The entire LobbyManager script.

heady iris
#

how does GetJoinCode work?

spare island
# heady iris how does `GetJoinCode` work?
        public async Task<string> GetJoinCode()
        {
            var code = State.CurrentLobby?.Data["joincode"].Value;
            if (State.CurrentLobby?.Data["joincode"].Value == null)
            {
                await RelayService.Instance.GetJoinCodeAsync(State.CurrentRelay.AllocationId).ContinueWith((task) =>
                {
                    code = task.Result;
                });
            }
            return code;
        }
#

the if statement is for when the relay is first created

#

As far as I know, the problem isn't with the join code

#

On both ends they're identical (at least from what I see in the logs)

heady iris
#

yeah, I'm not seeing anything obvious

spare island
#

rn i'm digging through utp transport stuff, i'm guessing i missed a step somewhere in the setup/connection

heady iris
#

This should be separate from the actual transport that'll be used for gamepaly

#

since this is just requesting a Relay instance and then connecting to it

spare island
#

i saw something about binding a driver but then another message under it saying that you don't need to do that anymore

heady iris
spare island
#

I should mention im using Mirror

#

maybe i'll find an example that shows me what im doing wrong

karmic sand
heady iris
#

are you rotating a rigidbody?

karmic sand
#

yeah

#

oh wait

#

i think ive just realised

#

yeah i had interpolate on 😭

#

fixed now

spare island
#

fast ass save times

karmic sand
#

fr 😆

#

cos its only saving like 4 floats

spare island
heady iris
#

if so, do it in LateUpdate instead. Interpolation happens between those two messages

spare island
karmic sand
#

i dont think i even need interpolate on so should be all good as is

spare island
#

well, trying to start the client/host THEN join the allocation

tepid meteor
#

anyone know how to change the UV scaling and offset values through code? I'm not seeing it in the shader script for LitTesselation

heady iris
#

hit Select Shader in the material's little ... menu

#

this will let you look at all of its properties

kindred pike
#

im having a problem, i followed the brackeys tutorial using player controller for 3d player movement, https://gdl.space/vuborozike.cpp this is my code, but the problem is when i go backwards then its kindof funky, and when i jump backwards and move my mouse downwards then i go really high, and when i point my mouse down then i cant jump at all

tepid meteor
#

thats a lot cleaner, but im still unable see the values im looking for. is there inheritance or importing values in hlsl?

heady iris
nimble cairn
#

I understand the difference between a double and a float with a few exceptions.

Does defining a variable like this have any impact? Do I need to always suffix these numbers with f?

float foo = 1;

In examples similar to the below mentioned, is the number 1 getting compiled differently? Is this format to my disadvantage?

float foo = .5f;
foo += 1;

float bar = .5f;
bar = foo + 1 + .5f;

Is there any reason as to why I should put the f after a "whole number" float?

tepid meteor
#

pretty sure f at the end is a static cast so itll happen at compile time. if you do something like 3/4 and no static cast it'll assume integers so you truncate

#

@heady iris its the LitTesselation shader in the hdrp folder. I can upload it here

heady iris
#

I want you to show the inspector after clicking "Select Shader"

tepid meteor
hollow cradle
#

I saw that BinaryFormatter is bad idea, does it refers to every binary saving? And while I have many large arrays of integers (mostly byte) what is good and fast way to serialize that?

tepid meteor
#

there are vulnerabilities in binary deserialization iirc

#

better to google it

eager yacht
#

There is also a section half way down for good alternatives (and bad ones too)

heady iris
#

I was TAing a cryptography class in grad school

#

The students built a networked application for their final project (then tried to break another team's project)

heady iris
hollow cradle
#

thanks, Ill see these alternatives

heady iris
#

You can literally just tell it "run this command"

#

BinaryFormatter is still vulnerable, but it's more convoluted

spare island
# heady iris Note that a 404 would **not** be the expected response for a bad join code

https://youtu.be/msPNJ2cxWfw?si=xAhLmHi-KsE6gWQe&t=637
I think this might've answered my problem (timestamp embedded)

❤ Watch my FREE Complete Multiplayer Course https://www.youtube.com/watch?v=7glCsF9fv3s
✅ Learn more about Relay and UGS https://on.unity.com/3tQZLLW
📝 Relay Docs https://on.unity.com/3OjXL8z
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
👇 Click on Show More
🎮 Ge...

▶ Play video
upper turtle
#

Hey, i'm trying to detect if I can spawn an object in without it overlapping another, I have this code written: transform.position = new Vector3(worldPos.x, 30f, worldPos.z);
Debug.DrawRay(transform.position, Vector3.down, Color.yellow, Mathf.Infinity);if (Physics.SphereCast(transform.position, 1f, -transform.up, out hit, 1000f, whatIsInterior))
{

#

but it doesn't seem to find anything, is there something I am doing wrong?

spare island
spare island
#

worked instantly

#

(it won't let me take a two monitor screenshot)

upper turtle
spare island
#

does the object expected to be hit have a collider

upper turtle
#

I've added a print into the If statement and it never prints anything

#

Yeah the object that is spherecasting and the object getting hit both have a collider

spare island
#

is your game 2D

upper turtle
#

3D

rigid island
spare island
#

oh my god there is

rigid island
steady whale
#

Hey guys I'm trying to rotate a cylinder forwards (when I press W), but the cross product of vector up of the game object and vector up of world sign gets flipped when the object rotates. I'm wondering what I'm doing wrong here?

spare island
steady whale
#

Using radians

lean sail
#

also not even sure what euler angles or radians have to do with that because a cross product has nothing to do with rotation

steady whale
#

Thing is the camera can rotate

#

so I get the dot product to know which side of the object I'm on and apply the input accordingly

lean sail
rugged elbow
stark sinew
#

Hey, small question!

I need to run some logic pre-build (precisely, fetching some ScriptableObjects and assigning some Data to them), and i'm wondering if OnPreprocessBuild is the proper thing to hook into?

Nvm, i think it's BuildPlayerProcessor and PrepareForBuild

iron vortex
#

Can anybody tell me about how Toggles are supposed to work, and more specifically how OnToggle is used and where it's referenced?

somber nacelle
#

where are you seeing anything called OnToggle

iron vortex
#

it's code I wrote a long time ago so I'm just trying to figure out what I even did** **

#

somehow a toggle with no references to this function manages to call this static function I wrote in a script
public static void OnToggle_Processing()

somber nacelle
#

you'll have to show the context for this if you want anyone to interpret what it does. just showing the signature doesn't help at all since this is some method that you created

#

at a guess though, I'd say you probably subscribed to the toggle's onValueChanged event with that method

faint otter
#

how can i make a collider with a set of points?

somber nacelle
#

2d or 3d?

faint otter
#

2d

faint otter
#

I tried mesh collider but that didnt work at all

#

Thank you

knotty sun
iron vortex
# somber nacelle you'll have to show the context for this if you want anyone to interpret what it...
        pauseOptions = MenuController.pauseOptions;
        Debug.Log(pauseOptions);

        // - Graphics -
        toggleE = pauseOptions.transform.Find("toggleEffects").gameObject;
        Debug.Log(toggleE);
        toggleEComponent = toggleE.GetComponent<Toggle>();
        Debug.Log(toggleEComponent);
        // v
        preferencePrAll = PlayerPrefs.GetInt("DisablePrAll");
        Debug.Log("Read PlayerPref 'DisablePrAll' with value (" + preferencePrAll.ToString() + ").");
        switch (preferencePrAll)
        {
            case (0):
                Debug.Log("Case (0) iterated.");
                toggleEComponent.isOn = true;
                MenuController.ProcessingOn();
                break;

            case (1):
                Debug.Log("Case (1) iterated.");
                toggleEComponent.isOn = false;
                MenuController.ProcessingOff();
                break;
        }

This is how the toggle is obtained currently.

#

the function it's calling, MenuController.ProcessingOn()/Off() respectively, just disable one gameObject

#

and it's unrelated to this script

#

it also contains no references to this

somber nacelle
#

paste the whole class in a bin site 👇 !code
at no point is that method you were asking about shown here

tawny elkBOT
iron vortex
faint otter
iron vortex
#

idk why the link immediately broke

#

hold on

somber nacelle
#

hastebin has been doing that a lot lately, it should appear in a few minutes

#

but use a different site if possible. hastebin has gotten terrible since toptal acquired it

#

lmao i just got ip banned from the site due to rate limiting for refreshing a couple times so even if the link does start working i won't be able to see it

iron vortex
somber nacelle
#

oh god everything is static 😬
but none of those methods are being used in this code so you'll need to use your IDE to find out where they are actually being used. and since it's all static none of it is being set or subscribed in the inspector

iron vortex
#

I was worried you would say it was that bad lmao

#

let's just say I didn't learn to code by making a game, but I did learn CS that way

sleek bough
#

Do you have more than one copy of that object?

#

It's pointless to have private static objects if you do not intend to share references between object instances

iron vortex
#

It's uh self-referencing in a way

#

you probably don't want me to get into all that, it's even worse

#

actually it's quite simple I can probably summarize it

#

basically I don't think I ended up using scriptable objects to make my game's objects (the player, hud elements, etc.) scene-consistent and also persistent in cases where the objects are destroyed, I uh.. yeah, I made everything static and that seemed to solve most issues

sleek bough
#

But if you are destroying everything, you'll have to repopulate all references anyway with new ones

iron vortex
#

exactly! I had the same epiphany, I decided to use a "cache" scene, so that in one instance of the game session it only needs to instantiate once, and then a global persistence system I made carries the same objects between scenes

#

they're just not scriptable technically

#

this requires weird workarounds

plucky inlet
#

Is there any equivalent to AssetDatabase.GUIDToAssetPath on runtime? I have a imagelibrary I need to access through runtime, but the library itself is only providing GUIDs.

cosmic rain
nocturne wyvern
#

Hi

Why when I enable obfuscate my list elements are null? List is not null, only elements of list

plucky inlet
placid summit
#

does IL2CPP-generated code mean you can not detect null errors without a ton of extra code affecting performance? This was easy to catch in mono but I guess c++ land does no such thing!

cosmic rain
maiden heath
#

why do people use the abstract keyword on scriptable objects classes?

hybrid relic
#

I think this belongs here, tell me if this is more something for #archived-code-advanced

I have my own API and i want to have my own Player Feedback System ingame.
I already have an idea how to set that up, doesnt sound too hard.

Now i also want if there are bigger errors or execptions to not start the unity Execption / Problem thing, but to start my own automated system that sends that to my API with their Account name, Machine Information, The Point where it crashed and the Stacktrace.

How would ago disabling the Unity Error Popup / Window and replace it with my own code / access the Error stuff ?

placid summit
cosmic rain
placid summit
cosmic rain
maiden heath
#

right?

dusk apex
#

It's for explicitness like keywords private, const, readonly and whatnot.

maiden heath
dusk apex
#

Only if you do not want anyone (including yourself) to create an instance of it. You can create an instance of something that inherits it but not it specifically.

maiden heath
hollow mesa
#

hi, can someone help me, i have a cube, who normally jump when spacebar is clicked, it function is call, but nothing happened :

gray mural
#

Also I hope you note that you Rigidbody's mass is 100

hollow mesa
gray mural
gray mural
hollow mesa
gray mural
#

Or increasing JumpHeight a lot

gray mural
# hollow mesa

Sorry, I meant FixedUpdate in that question. That's fine.

#

Serialize your JumpHeight and significantly increase the value

#

I don't know the suitable ratio, so you'll have to find it out yourself

#

Also it seems you're updating the IsJumping boolean. Are you sure the collision happens properly?

hollow mesa
#

that work, thank

gray mural
# hollow mesa that work, thank

So Impulse requires a lot of force. Consider changing the JumpHeight as required in the Inspector and multiplying it by some value to keep it low

hollow mesa
gray mural
gray mural
#

Sorry, wrong channel and person.

hybrid relic
#

I have my own API and if there are bigger errors or execptions i want to start my own automated system that sends the needed Info to my API with their Account name, Machine Information, The Point where it crashed and the Stacktrace and not start the unity Execption / Problem thing.

How would ago disabling the Unity Error Popup / Window and replace it with my own code / access the Error stuff ?

#

Better said i want to replace the Unity Crash Handler thing with my own more hidden automated system.

hybrid relic
#

that is complete bull

cosmic rain
#

If you want to override the unity crash reporting system, you'll need the source code.
Another alternative is to maybe provide a launcher/wrapper app that would actually run your game and would detect when it exited with a crash. Then it could take the files that unity saved and upload them to wherever you want.

hybrid relic
#

ive written crash handlers before

#

that is just a lazy excuse to "its hardcoded and we dont want to change it"

cosmic rain
#

Well, it's probably in the C++ land. And they don't provide access to their C++ code for free

hybrid relic
#

i will just make my own crashhandler and replace the one that unity puts into the project

#

so it starts my exe instead of the unity one

cosmic rain
#

And it totally makes sense what they're saying. The game runtime could be messed up, so providing hooks for a crash reporter could mess up many things

cosmic rain
hybrid relic
#

just whatever data they are giving to the crash handler to be used by a custom exe

#

like my own exe

#

without needing to replace it each time

cosmic rain
hybrid relic
#

thats super easy to do

#

but they want to sell their overpriced unity services crap so they make it harder then it needs to be

cosmic rain
#

The info that the crash handler produces is stored somewhere on the user device and you can access it freely

#

It's just that you can't access it from the crashed app

#

since, well, it's crashed

hybrid relic
#

cuz i think having automated crash reporting to be send to their api for automated tracking with gh issues or youtrack is not only i would want

hybrid relic
#

how did you find that

cosmic rain
hybrid relic
#

i was looking for that for 3 hours

cosmic rain
hybrid relic
#

or rather something like that

#

i have google skill issue then

cosmic rain
#

unity crash report location

hybrid relic
#

yeah i guess i really have google skill issue

cosmic rain
#

It comes with experience

hybrid relic
#

im a gamedev for 8 years by now

#

but only hobby

#

never had the need to replace the crash handler with something automated

#

but thank you very very much

sour trench
#

Is EventSystem.current.IsPointerOverGameObject() really supposed to hit BoxCollider ? 🤔 I have zero UI and it returns true for my floor which makes no sense to me...

cosmic rain
#

If you have a physics raycaster, then yes.

sour trench
#

Needed that for the IPointerEnterHandler etc to work. So how do you detect clicks on just UI then? 🤔

cosmic rain
#

Unless your ui is not actually ui, but a physics object.

sour trench
#

It's not UI, this is to detect clicks/enter for physics objects like floor tiles. I guess I need to exclude UI from the raycast I'm doing, so I guess just put all UI on a separate layer and use that to ignore it.

cosmic rain
#

Ah, okay, so you are using the event system both for normal ui on a canvas and for physics objects?

#

Is that right?

sour trench
cosmic rain
#

Ok, I see.
I'd avoid relying on the events system for something like that, especially if you want more control.

sour trench
#

Just a manual raycast from the camera is better?

cosmic rain
#

The way I'm doing it is having a UI manager that can tell me if the pointer is over any of the UI(using that data for other stuff as well, like dragging and tooltips). While the player controller is handling interaction with the environment. It checks the UI manager for whether the pointer is over ui, before executing it's logic.

cosmic rain
#

And you can avoid casting it, when the pointer is over ui, to save some CPU cycles.

sour trench
# cosmic rain The way I'm doing it is having a UI manager that can tell me if the pointer is o...

I've used a similar approach in the past but found it difficult to isolate code in smaller component scripts. All of a sudden my Door script for example will need to know about Player stuff (PlayerController for mouse input), and vice versa (since I need to check what I clicked in the PlayerController).

Maybe the PlayerController can use an interface, similar to how like IPointerClickHandler works, but for my custom raycast? So when I click something it's up to the Door to check in the implemented interface method if it was clicked:

class Door : MyCustomClickHandler {

  // Wouldn't fire if clicking UI
  MyCustomClickHandler.OnClick(GameObject clickedThing) {
    if (clickedThing == gameObject) {
      // do stuff when clicking on this door
    }
  }
}

This way I don't have to check in PlayerController what I clicked... Thoughts?

cosmic rain
sour trench
cosmic rain
#

You don't have to end up like that.

cosmic rain
# sour trench Yeah but if you then have many interactable objects you will end up with *a lot*...

One way you can do that is have the interactable objects implement an IInteractable or similar interface or an abstract class, that you can call Interact(this, someParam) on, and the object would handle the interaction.

What I have in my current project is a bit more complex. I have an actions queue system. I get the appropriate action from the interactible and queue it on the character controller. The action has access to the character, interactable and/or whatever else it might need and executes the specific logic.

scenic sigil
#

How do I stop Visual Studio from correcting my own methods to Unity messages? Hard to escape too, because basically any input accepts the suggestion

slate quest
cosmic rain
slate quest
#

then delete the typo (if u add an extra character)

scenic sigil
#

This is so stupid

#

Me: ...Quit()...
VS: Did you mean OnApplicationQuit()?
Me: No~
Vs: You did mean OnApplicationQuit().

slate quest
#

normally i would let this be and then delete the OnApplication bit

#

btw is there a way to detect whether a button is pressed not through the editor but through script?

scenic sigil
slate quest
#

how does one detect button pressed without editor

#

the context is that its attached to a gameobject that keeps on making copies of itself and then destroys itself

#

thus the references would all be detached

soft shard
tawdry pecan
ashen pewter
#

is there a way to open file explorer in runtime?

ashen pewter
#

Thanks for your help tho

rigid island
ashen pewter
#

Thanks for the help guys

ashen harbor
#

Hello guys, im new to this and Im following a tutorial, anyone knows why the squares (enemies) shows on the scene but not in game window? thanks

heady iris
#

This isn't a code problem.

If the squares are being drawn by a "Screen Space - Overlay" canvas, then their position in the scene view doesn't correspond to where they'll appear on the screen.

eager steppe
#

Hey y'all

Trying to load AudioClips in parallel with async/await and MainThreading, but for some reason my audio clip always comes back null, no matter what happens? Looking into LoadSongFile() method specifically. It always comes back as null in the debug.log. Stuck for a few hours, i'm embarrased to say, but I'm new to working with parrallel threading so i have no idea what's wrong. This only happens when using the ThreadDispatcher though, i justadded it on because I can't create things on anything but the Main Thread.

Here's the relevant scripts:
Initializer.cs (with LoadSongFile()): https://pastebin.com/MKAFcMaj
UnityMainThreadDispatcher.cs (Relevant to RunOnMainThread() method): https://hatebin.com/zbmiuwevnm

if you need more info let me know i'm just gonna go eat really quick

leaden ice
#

Also async await are not generally related to multi threading in Unity

eager steppe
eager steppe
thorn isle
#

Hello! I'm trying to add unity ads to my game. In unity editor, when I click the button that's supposed to show ads, it says everything works. But when I build and test in my phone, it doesn't show anything

quaint rock
alpine geode
#

i have watched the entire “Beginner Scripting Tutorial” series made by the official unity yt channel, and i was wondering if you guys think i would be able to make my first project using the knowledge i have acquired and some stuff from the unity forums

somber nacelle
#

nobody here can possibly know if you've properly absorbed the knowledge that was presented. so the only objective answer to your question is "try it"

alpine geode
spring creek
#

Don't be afraid to do bad work and restart. That is a HUGE piece of learning.

alpine geode
#

thanks

ivory cove
#

Hey so I've been optimizing my game recently as when using the profiler I noticed my garbage collection would spike pretty frequently. I start with learning a little more about the better practices of memory usage. I noticed that one of the big ones was creating new instances in code that is repetitive. I can understand that for expensive operations such as creating gameobjects, but what about values such as vectors? Would you recommend that I initialize a temporary vector and reuse that one rather than creating a new vector every time? Or is the difference negligible.

somber nacelle
#

vectors are value types so if you are creating new instances of them inside of methods they will live on the stack and won't have any impact on GC

#

GC impact will come from instantiating reference types, or anything that lives on the heap that you only use for a short time

steady moat
#

You can easily see what is being allocated by frame with the profiler.

#

Find the worst offender.

ivory cove
#

Alright got it! Thank you ^^

rain tide
#

Is there anyone here who has experience with movement on orbiting objects, or anything similar*?

lean sail
heady iris
#

that question is also very vague, since orbiting objects could be a physics simulation or just parenting stuff to other stuff

dawn nebula
broken light
#

how can i instantiate prefabs but create an instance of its materials since i need each material to be different in a few of its properties on a per object basis

heady iris
#

when you access the material or materials properties of Renderer, the materials areinstantiated

#

so that happens automatically

broken light
#

wouldnt that just be the reference to the material ...

#

that all the prefabs reference

#

unless you are saying if i do:

var mat = renderer.material;
//change the color property

that will now only affect that specific game object's material not all other instances?

rigid island
#

yes

#

other instances you would use .sharedMaterial

broken light
#

ah i see.

proud loom
#

I’m trying to get my player to flip when I move the other direction. The sprite renderer is saying it slips on the x axis but is not showing in game. Is this code or something to do with my sprite

rain tide
rain tide
crystal holly
#

Using the UI Toolkit with custom uss vars, is it possible to edit vars in the UI?

Eg I have something similar to bootstrap in a vars.uss file:

:root {
    --brand-primary: #375a7f;
    --brand-success: #00bc8c;
    --brand-info: #3498DB;
    --brand-warning: #F39C12;
    --brand-danger: #E74C3C;
}

I'd like to be able to edit these in the UI Builder interface, can I? Or possibly connect them to a scriptable object if not?

dawn nebula
rain tide
cosmic rain
rain tide
#

I already tried simulating gravity.

rain tide
void basalt
#

No. He asked you a question needed to solve your own question

cosmic rain
#

And? It didn't work?

void basalt
#

Apart from the floating origin problem of space simulations, you'll need to simulate your own gravity

#

so you apparently didn't do it right.

#

no need to get hostile for no reason.

rain tide
void basalt
void basalt
#

can I see

#

physx has it's own gravity system that you'll need to disable

#

so that you can implement your own.

maiden stone
#

Hello. Would anyone be willing to help me figure out what I'm doing for my code? (I know what I'm trying to do but I cant actually figure out how to achieve that)

cosmic rain
rain tide
lean sail
void basalt
cosmic rain
# rain tide Okay.

And you still didn't answer my questions. But I'd assume that the answer is that it didn't work.
In that case, did you figure out why?

rain tide
#

The name isn't extremely informative, but:

{
    Vector3 gravityUp = (transform.position - referenceBody.Position).normalized;
    Vector3 localUp = transform.transform.up;
    Quaternion targetRotation = Quaternion.FromToRotation(localUp, gravityUp) * transform.rotation;

    //Debug.Log(gravityUp);


    transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 50f * Time.deltaTime);

    moveDirection = new Vector3(moveAction.ReadValue<Vector2>().x, 0, moveAction.ReadValue<Vector2>().y).normalized;
    if (!IsGrounded())
        rb.AddForce(-transform.up * referenceBody.mass, ForceMode.Force);
}```
void basalt
#

three ` for a better code paste btw

cosmic rain
void basalt
#

I personally would've just used gravityUp in my addforce call

rain tide
cosmic rain
void basalt
#

you're also not taking into account acceleration

#

force = mass * acceleration

rain tide
rain tide
void basalt
#

what doesn't work?

rain tide
cosmic rain
void basalt
#

the big issue is that you don't have a realistic gravity calculation

#

if you jump, the jump is gonna be massive

#

earth's gravity is 9.82M/s^2

#

and that does a good job of keeping everything grounded

#
}```
at least I think that should be right
#

your rotation code might also be getting you lodged inside the collider and shooting you up

spring creek
# rain tide You really think I'm an idiot?

I have no idea how you could possibly have read that from what they said. Please don't speak to people like that. Dlich is trying to get information in order to help you. We have no idea what stage of knowledge people are at. I do not appreciate you calling people that don't know stuff like that idiots.

maiden stone
# maiden stone Hello. Would anyone be willing to help me figure out what I'm doing for my code?...

So, I'm trying to make a dynamic music system. I currently have my music being held in a audioQueue list. I'm what I'm attempting to achieve is:

  • Have my music play, one clip after another. (1, 2, 3, 4...)
  • Have a fall back once the music clips played reach a specific song. This will repeat the current song playing if its position in the queue is the same as the measure where it should stop. This is defined in inputMusic.Measure. The songs playing would look something like this: (1, 2, 3, 3, 3, 3).
  • If the inputMusic.Measure variable is changed, it should finish playing that song, and then continue to play the songs with the pattern mentioned previously until it reaches the next instance of inputMusic.Measure.
    (I apologize for the poor description. Please ask questions and I will clarify if you are confused)

Currently, I am able to run this code and it nearly functions as intended. The audio clips play as follows: (0, 1, 2, 3, 2, 2, 2...) My issue: When it is supposed to loop on the 3rd clip, it returns back to the second clip instead. Any help or input would be appreciated, as well as any input on how I can improve.

Here is my code:
https://pastebin.com/Az1Vj3T7

void basalt
#

@rain tidejust an fyi, if you're planning on having multiple planets, or any 3d space game at all, you will need floating origin or something similar. otherwise you will exceed the limitations of 32 bit floating point numbers and everything will start glitching out past a certain point in space.

dusk apex
maiden stone
#

Yeah that may be a good idea...

rain tide
maiden stone
tawdry pecan
rain tide
#

The problem seems to be that I'm going through the planet.

void basalt
#

remove that rotation code temporarily and see if things get any more stable

#

you also said that you're moving your player with velocity. that is also a likely culprit

rain tide
void basalt
#

I don't know. Moving a player around a circular planet is a lot more difficult to get right than moving a player on a universally flat ground

#

I have no clue what that video is supposed to show

#

if you're trying to move your planets like they'd move in our real universe, I would probably not do that.

rain tide
#

Sorry, I'm not moving with velocity, I'm using the MovePlayer method.

void basalt
#

idk what a moveplayer method is

#

and second, you're going to run into floating point issues like I said earlier, very quickly

#

and you don't even have a system to handle that yet

rain tide
#

MovePosition, wow sorry.

void basalt
#

MovePosition bypasses the physics engine

#

which is probably why you're teleporting through the planet

rain tide
#

Oh.

void basalt
#

after you fix that, you should let your simulation run for a few minutes and see how glitchy everything gets as your planets move past the 10,000+ meter mark. so you can see what I'm referring to w/ floating origin

#

you should really consider just having statically oriented planets, like most major games do. nobodies really gonna know the difference anyways...

maiden stone
# maiden stone So, I'm trying to make a dynamic music system. I currently have my music being h...

As an update, I found out my issue is the fact that I limit the running of my code if it passes an if statement:

if (clipsPlaying.Count < 1)

What can I do to work around this or even what can I redo to make this function without removing things from my audioQueue? This line of code is important to making sure multiple clips dont play at once unless intended to, however I dont know what I can do to fix this...

Does anyone have any ideas?

chrome trail
#

So if I create submeshes for a mesh, is there any way for me to feed it different sets of vertices for both or do they have to share the same set of vertices? Because I'm only seeing a way to do this for the triangles

leaden ice
#

the triangles for the submeshes reference from the same set of vertices

supple pewter
leaden ice
ashen pewter
#

why's my python code is error in unity
it works pretty well in vscode

cosmic rain
ashen pewter
#

yea it was a dumb moment

gray mural
#

Hey. When having a MonoBehaviour A and its derived class, B, both with the Awake method, is it possible to give A.Awake the functionality, which will also execute when B.Awake is implemented, without marking them as virtual and override?

#

This way, I don't want to always call base.Awake()

cosmic rain
gray mural
#

Alright, it seems so. Thank you

ashen pewter
#

is python can be used in runtime?

cosmic rain
#

No. At least not by default.

#

You could probably use the OS api to launch a batch file or a python script, but that would require python to be installed on the user machine among other things.

ashen pewter
#

ah okay

#

i thought its going to work with python

craggy pewter
#

Hi all, is there a way to enable word wrap in the Unity console?

chilly surge
#

For UGUI InputField, it seems like selectionAnchorPosition and selectionFocusPosition reset to 0 when you lose focus. Are there properties that track the last known positions, or do we just have to do our own tracking on top of it?
My use case is that I have some buttons that essentially pastes some predefined texts and I'd like it to replace the selection.

night elk
#

Hi, I want to get access of the username of a player in the server side; which is stored in the cloud save: player data but to get access I need to log in with an admin account, I tested the ServiceAccount but there is no documentation about how to connect to the service account. I tested this method: ServerAuthenticationService.Instance.SignInWithServiceAccountAsync(); but I have this error: ServerAuthenticationException: HTTP/1.1 400 Bad Request

hollow comet
#

hii, im having a problem with my players animation when they move. it works in the editor perfectly and no errors show up in the log. but when i build it the animation is stuck on idle instead of switching the walk anim like in the editor. does anyone know how to fix this?

knotty sun
hollow comet
#

just this one

#

is there anything here that looks like it could be wrong? sorry i dont know alot about this part

knotty sun
#

To start with this is not a code question But...
Select development build. Build and Run then check the player.log for errors.
The !log location can be found in the documentation

#

!logs

tawny elkBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

hollow comet
#

im new to the server so i wasnt sure what chat to ask in, since i also dunno whats wrong so 😅

hollow comet
#

tysm

#

its just in the console in the editor that should tell me if something is wrong after the build right?

knotty sun
#

No, when you Build and Run any errors will be written to the Player log, which is why I told you to look at it

hollow comet
#

sorry where can i find the player log`?

knotty sun
hollow comet
#

i didnt see that earliernotlikethis

old linden
#

Hello. Is there a more efficient way to get the current playing time of an audio clip instead of AudioSource.timeSamples / AudioSource.clip.frequency? Thanks

humble thicket
#

hey im trying resize my rendertexture however the camera refuses to render to the texture until i enable and disable the camera script in the editor is this a bug?

#

the camera has the render texture it just refuses to render unless i turn the camera script off and on

stark sun
#

Anybody know how can I make my character hold the weapon with 2 arms. I thought about adding a public gameobject to a script which is on the both lower arms but didnt know what to do next. I also want to use those slots because I want to also use one handed weapons

#

I want to use slots too because there are another actions character does when weapon in not 2 handed

lean sail
#

Depends on how you want these objects to move

upper pilot
#

If I want to create a turn based combat with animations, would creating coroutine within a coroutine be a good idea?
Top level coroutine as a "loop" for each character
Then each character would have its own coroutine to play its animation.

Is that correct way?

#

Tbh I could also just have infinite loop and reset index when I reach last element until specific condion is true(i.e. enemy or player lost)

#

This would only have coroutine for animations right?

lean sail
upper pilot
#

I see, I am working on a prototype so I might get a better idea of what I need once I start writing combat logic.
It's meant to be automated combat, so it loops through all characters and they do their attacks/animate etc.

my logic would be:

void Update()
{
  StartCoroutine(CombatTurn);
}

IEnumerator void CombatTurn()
{
  foreach(Unit unit in units)
  {
    yield return unit.DoAnimate();//I assume its another coroutine? It has to wait until this character stops animating
  }
  yield return null;
}
#

This could be wrong, but that's current idea.

knotty sun
#

Starting in Update is your first mistake

upper pilot
#

Yeah thats true, I just saw it in an example somewhere, it will start only 1 time, since whole combat is automated from start to finish.
it's really just a bunch of things animating, but it has logic for combat too.

Loop units -> unit.DoLogic() -> unit.DoAnimate()

lean sail
#

Maybe do some experimenting with coroutines first to see how things even run. Like that yield return null at the end does nothing too

upper pilot
#

Yeah I will do that first, the project is still empty lol

#

I thought that you always need to yield return null to stop the coroutine

#

but maybe its used to end it early

lean sail
#

But still I'd just try to define as much as I can in update and have my own control of when things are running. Maybe with some pseudo state machine though im not sure what logic you intend on actually running

lean sail
upper pilot
#

I kinda want to take advantage of coroutines, just to learn them a bit.

But the logic is simple, some calculations for combat + animating simple 2d sprite.

#

I will be back in an hour or two if I get closer to writing some code, I should have a better idea by then!

stark sun
lean sail
misty blade
#

I have an issue with async tasks cancelling. I’m creating a simple game creation scene where you can change between game modes. There is local, host and join and some of them fetch data from the Relay server or Authentication Service.
When the user selects host game mode it starts fetching some data and after it finishes the data is displayed on the screen. But if in the mean time the mode is changed then it still shows the previously fetched data on the current freshly selected game mode screen.
I would like to cancel these tasks when the other mode is selected, but was wandering how? Is CancellationToken the right way to go about it? Tried to implement it, but had some issues.

    private async void OnGameModeDataSelected(ISelectable selectable)
    {
        GameModeData gameModeData = selectable as GameModeData;

        #if UNITY_WEBGL || UNITY_EDITOR

            await HandleRegions(); //fetch data from the Relay
                return;

        #endif
    }

    //example method
    private async Task<bool> HandleRegions()
    {
        try
        {
            foreach (var region in await RelayManager.Instance.TryToListRegionsAsync())
                //stuff happening here
        }
        catch (Exception e)
        {
            HandleErrorText(e);
            return false;
        }

        return true;
    }
gray mural
#

The TryAddTile method adds a Tile to the Tilemap on the specified position, if it's available.
When recording the changes and setting both player and its Tilemap dirty, the torso seems to be collapsed after undoing the changes.

Undo.RecordObjects(new Object[] { _player, _player.torsoTilemap }, "Paint torso");

if (_player.TryAddTile((Vector2Int)position))
{
    EditorUtility.SetDirty(_player);
    EditorUtility.SetDirty(_player.torsoTilemap);
}

My question is, what am I doing wrong that the Tilemap does not get saved?

wraith spear
#

When I make a development build I get a lot (>50) of errors like these:
The referenced script on this Behaviour (Game Object 'Player') is missing! A scripted object (probably Players.Player?) has a different serialization layout when loading. (Read 32 bytes but expected 88 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

However, I don't use #if UNITY_EDITOR or any other #ifs anywhere, aside from a package I'm using. I've Googled around a bunch, but none of the answers are helpful. Most give solutions like "I copy pasted every script and now the error is gone" or they do actually use #ifs. Since the errors are shown on basically all of my scripts, I'm kind of at a loss where to start. Any help is hugely appreciated!
Here is a complete log output: https://docs.google.com/document/d/1hXmh1SlaFanRyubuLlryTnsbV_KdUs8KRNH0WTtpV2Q/edit?usp=sharing
And Player.cs code: https://hatebin.com/ajkyrmdcsk

wraith spear
# wraith spear When I make a development build I get a lot (>50) of errors like these: `The ref...

I've made a simple scene with only an object and a movement script, and it still gives me the error. I've tried removing things until I don't get the error anymore and apparently the thing throwing the error is... All my variables???

My methods are fine, but as long as I have any public or [SerializeField] private variable in my script I get build errors. I've tried it with public vars, private vars and [SerializeField] private classes, enums, floats and ints. Only private vars don't give errors. All methods are fine.

So now I'm wondering... What the heck's wrong?
Here's the script: https://hatebin.com/hliqdrrqvq

weak spruce
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SheepManager : MonoBehaviour
{
    public PlayerData playerData;
    public GameObject sheep;
    public Transform spawnPoint;
    public GameManager gameManager;
    public int spawnedSheep;


    private void SpawnSheep()
    {
        if (spawnedSheep <= playerData.sheepAmount)
        {
            Instantiate(sheep, spawnPoint.position, Quaternion.identity);
            spawnedSheep++;
        }
    }

    private IEnumerator SpawnSheepRoutine()
    {
        while (spawnedSheep <= playerData.sheepAmount)
        {
            yield return new WaitForSeconds(1);
            SpawnSheep();
        }
    }

    private void Start()
    {
        StartCoroutine(SpawnSheepRoutine());
    }
}
#

why only 1 sheep spawn on start

wraith spear
#

Second, it's a bit hard to say without more info. What number is playerData.sheepAmount?
And maybe multiple sheep are spawned, but they all get spawned on the same point so they overlap?

knotty sun
#

because playerData.sheepAmount is zero

weak spruce
#

but if i debug.log(playerdata.sheepamount) it show right number

gleaming falcon
#

I'm making a rhythm game and I need to spawn the notes at a certain time in milliseconds. This is how im currently doing it:

public class SpawnNotes : MonoBehaviour
{
    [SerializeField] BeatmapParser beatmapParser;
    [SerializeField] AudioSource song;
    public long ms;
    private Stopwatch stopwatch = new Stopwatch();
    public int currentNote = 1;
    private bool songStarted = false;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        ms = Convert.ToInt32(stopwatch.ElapsedMilliseconds);

        if (songStarted && Convert.ToInt32(stopwatch.ElapsedMilliseconds) == Convert.ToInt32(beatmapParser.notes[currentNote].Item2))
        {
            UnityEngine.Debug.Log("Spawned Note");
            currentNote++;
        }

    }

    public void StartSong()
    {
        songStarted = true;
        stopwatch.Start();
        UnityEngine.Debug.Log("ran");
    }

}```

However, the if statement is never fired. I'm assuming this is because the update method is tied to the frames and cant keep up with exact ms. Is there a better way I could do this?
#

The StartSong() function is being called in a different script btw, the issue isnt that thats not being fired

steady moat
#

It is because you are checking if the time is a specific time.

#

Obviously, it is not

gleaming falcon
#

Yeah but it goes straight past the time its meant to fire at without firing. I know my method is probably flawed so im asking for a better solution for my case

spring creek
ivory smelt
#

Hey! Is anyone else struggling with IHeartGameDev procedural environment animations?

I started the unity tutorials a couple of days ago and Im having trouble building everything from scratch.
The guy explains things really good and the editing is fantastic, but there is some stuff, mostly components attached to the GameObjects, that he has done outside the video and are never shown, for example:

-Rigidbody
-Capsule collider
-Animator
-PlayerStateMachine script

Sometimes also there are scripts that change between videos without context or explanation.
Since the guy is widely known in the community, I was wondering if someone also had this same problem and managed to solve it and get the thing to work.

If someone had already the finished proyect, or the parts Im missing, Id be extra satisfied! But I'll settle for a little help.
Obviosly Im willing to share the code I got if needed, just ask!

lean sail
ivory smelt
wraith cobalt
#

That kinda thing is a frequent problem with tutorials, but hard to bugfix without going through it. Especially if they just leave stuff out.

ivory smelt
#

Yeah, but idk, since is a big channel I am expecting, with a bit of luck, to find someone that aldeady went throug it and could help me.

#

Made a post in reddit too

lean sail
ivory smelt
#

My problem is that there is stuff missing, the question is if someone figured it out.

#

Sadly, cant make my own solution tho, if I dont know how that missing part works.

#

;(

lean sail
ivory smelt
#

I know, but I am not aware of their config

#

Made a copy to test stuff but couldnt get the errors fixed, those evil red messages are always there.

lean sail
#

It seems like you're just blindly following a tutorial. Honestly theres almost nothing you need to do to setup a rb or collider. It's all unique to your game anyways so those should be things you're setting up different from the tutorial

ivory smelt
#

Well, lets say the collider and the rigidbody are not the problems, still missing a script, animator and such stuff.
Im trying to understad things, not blindly following, but im aware that I couldnt do it alone since is over my level. I dont have that much expecience using Unity.
My target is to get it to work, then modify it to fit my needs.

craggy cobalt
#

Hey guys what is your opinion about muse?

mighty void
#

hi someone could help me? i have a problem

#

look at this

somber nacelle
#

is OrionEditor something you made or is it an asset?

mighty void
#

something that i made

#

wait i show you my code

somber nacelle
#

but the error is pretty clear, you did not call BeginLayoutGroup but you are trying to call EndLayoutGroup

mighty void
#

` public override void OnInspectorGUI()
{
DrawDefaultInspector();
OrionFile f = (OrionFile)target;
if (GUILayout.Button("Create new Animation"))
{
Save(f);
}
GUILayout.BeginHorizontal();
if (GUILayout.Button("Save Animation"))
{
if(f.GetOrion() != null)
{
f.Save(f.GetOrion());
}
}

    if(GUILayout.Button("Load Animation"))
    {
        string path = EditorUtility.OpenFilePanel("Load animation", "", "orn");
        Debug.Log(path);
        if (path.Length != 0)
        {
            f.Load(path);
        }
    }
    GUILayout.EndHorizontal();
    GUILayout.BeginVertical();
    if (GUILayout.Button("Reset Animation"))
    {
        if(f.GetOrion() != null)
        {
            f.GetOrion().ClearLayers();
        }
    }
    GUILayout.EndVertical();
}

public void Save(OrionFile or)
{
    string path = EditorUtility.SaveFilePanel("Save animation", "", or.name, "orn");
    Debug.Log(path);
    if (path.Length != 0)
    {
        or.Save(path);

    }`
#

the error becomes from here

rigid island
mighty void
rigid island
wide mural
#

Im making an ar app, i made an animation in unity using blend shapes imported from Blender, when I enable the objects with blend shapes, my application crashes, when i disable these objects it works fine. do blendshape not work on mobile? struggling to find anything online

cosmic rain
merry surge
#

hey guys is there a way to force unity to regenerate csproj and solution files

#

i figured it would regenerate them when i launch the scene but nope

quaint rock
#

delete them

merry surge
#

they are gone

quaint rock
#

Assets->Open C# project

merry surge
#

but now i cant get em back

#

open c# project gives me an error

quaint rock
#

is the external edtior setup right

#

how it generates them depends on the target ide

#

like Rider, VS and VS Code all have slightly differnet files for it

merry surge
#

i have it set up to use visual studio

#

but idk it's not generating anything

quaint rock
#

and whats the error

merry surge
#

if i try to launch c# project i get

quaint rock
#

thats pretty strange

merry surge
#

i had this on my laptop and threw it on git and pulled it onto my desktop

#

so maybe i missed a file on the laptop

#

but idk what

quaint rock
#

nah pretty much everyone ignores csproj files in git

merry surge
#

yeah i didn't commit anything that the gitignore has by default

#

since they're all generated files

quaint rock
#

well defualt gitignore is no good for unity

#

there are alot of things you will want ignored

merry surge
#

i used the one that github supplies i think

#

can i delete library or something to force a full rebuild

quaint rock
merry surge
#

yea thats whaty i have

quaint rock
#

how are things looking for these settings

merry surge
#

pretty bare

quaint rock
#

got the package for it installed in package manager

merry surge
#

oh ffs

#

that's prob the issue

#

i had problems with other missing packages

#

must have not committed that file

quaint rock
#

yeah pretty much all ide support is in the package

merry surge
#

that did it

#

cheers

mighty void
#

exists a way to fuse diferent sprites in an animation

#

i have some sprites but i dont know how to fuse then

cosmic rain
mighty void
#

like layers, but with booleans

#

is a menu

#

i dont really how could explain clearly but i wanna reproduce a diferent layers in a animation in a specific moments

#

like in this sprite

cosmic rain
#

Do you have some example of how you want it to look like?

#

Also, is that really a coding question?

mighty void
#

i really dont know how i can do it

#

like minecraft furnace

cosmic rain
#

A simple script with an ui image would do it. You can control the fill with the fillAmount property of the image.

tepid charm
#

anyone have any advice on how to make a custom animator event system? unity's system is utterly unusable and I can't really find any good alternatives except making one myself

spring creek
tepid charm
#

so the whole system becomes useless for anything beyond maybe some visuals/sound

spring creek
tepid charm
#

well I have, a lot

#

which meant I had to stop using them, and I haven't found a good alternative that doesn't cost $90

#

the problem with the existing one is that if a frame in the animation is skipped due to changes in the animation's speed or low FPS (which happens a lot), the event tied to that frame never gets called

#

so for my system I want to tie events to coroutines which are guaranteed to be called properly

#

but I have no idea how to make an actual editor for it

cosmic rain
tepid charm
#

the point is that it doesn't work

cosmic rain
#

Perhaps with a little troubleshooting you could get it to work as you expect, instead of reinventing the wheel.

tepid charm
#

I've looked a lot on the forums and the prevailing answer is usually "the unity devs don't even know why it doesn't work"

#

and I don't feel like spending another 2 years trying to use this system that breaks at seemingly random times

#

also I've noticed that if you have transitions at the end of animations, the events during the transition often aren't fired

#

but even without transitions it's inconsistent

cosmic rain
# tepid charm but even without transitions it's inconsistent

Well, we can't really help you if you don't have a specific problem. That being said, if your system is dependent on the animator, it would probably have similar issues. So you might need to implement a whole new animation system along with it.

tepid charm
#

I asked for suggestions for how to implement my own system, specifically making an editor for it

#

and I don't think I would need to implement a whole new animation system

#

this system would be animator independent

cosmic rain
spring creek
#

Ah, I thought you said an animation event system. I didn't see you say anywhere it would be a whole new animation system entirely

twilit scaffold
cosmic rain
#

Ah ok, guess my discord bugged out. Sorry

tepid charm
#

you can see it says "today at 11:56 AM" meaning it was a message from someone else

cosmic rain
tepid charm
#

by keeping track of the timings in coroutines

#

all I really need is to know how far into the animation the event should be, and the playback speed

#

I don't see the issue with that?

cosmic rain
tepid charm
#

but that doesn't matter, I just need the timings to be correct

#

if it doesn't line up frame perfect that's fine

#

as long as the timings are right and the events actually get fired, I'm good

#

the visuals come second to functionality

#

which is not how the built-in animator system seems to work

cosmic rain
spring creek
#

It is for me 🤷‍♂️
I have literally never had an event get skipped or heard of it happening

tepid charm
#

well you're lucky then, but that doesn't really help my issue lol

cosmic rain
tepid charm
#

as for hearing of it happening, just google "unity animation event not firing"

spring creek
cosmic rain
#

Animation events are intrinsically tied to the visuals.

tepid charm
#

alright, whatever you want to call it

tepid charm
#

I may be exaggerating how often this happens, but it's common enough that it makes gameplay inconsistent and unfair which is something I want to avoid at all costs

#

and on second thought I don't really need to make a proper editor extension (at least not yet)

cosmic rain
#

But my guess is that the issue is on transitions and/or blending of animations, which is not impossible depending on your animation states setup.

If you have a fighting game of sorts, and depend on the events for hit/dodge or other mechanic timings, then it would definitely be unreliable

tepid charm
#

I'm making an rpg and in the beginning I was using these events as an easy way to make complex weapon behavior without having to write a bunch of custom scripts

#

I thought I could fix the issues I had previously had with animation events, but I couldn't

#

I guess that makes me bad at debugging or whatever

#

but anyway, I'm gonna get to work on this (even though it's already 5am)

wraith cobalt
#

Umity animation events aren't great.

old nymph
#

Hi, have a nice day.

#

I'd like to ask, what possibility make a scene too slow to load? I have a simple scene like this, with some vfx and textures around 200KB. I checked the profiler but nothing-suspicious. I use LoadSceneAsync and It took about 9 seconds to load the scene.

cosmic rain
cosmic rain
wraith spear
#

When I make a build of my project I get a bunch of errors on public & [SerializeField] private variables. For some reason private variables are fine. They don't show up when in the editor, only when I run a made build. Does anyone know why this might be the case?
The errors are the following:
The referenced script (Unknown) on this Behaviour is missing! The referenced script on this Behaviour (Game Object '<null>') is missing! A scripted object (probably Animations.AnimationSequence?) has a different serialization layout when loading. (Read 44 bytes but expected 296 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

And again, this doesn't happen if I comment out all public & SerializeField private variables. Very strange.

cosmic rain
wraith spear
#

The entire error is:
`Begin MonoManager ReloadAssembly

  • Loaded All Assemblies, in 2.611 seconds
  • Finished resetting the current domain, in 0.002 seconds
    <RI> Initializing input.

New input system (experimental) initialized
Using Windows.Gaming.Input
<RI> Input initialized.

<RI> Initialized touch support.
The referenced script (Unknown) on this Behaviour is missing!
The referenced script (Unknown) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'Square') is missing!
The referenced script on this Behaviour (Game Object 'Square') is missing!
A scripted object (probably Movement.TargetMover?) has a different serialization layout when loading. (Read 32 bytes but expected 36 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
UnloadTime: 8.304700 ms`

knotty sun
#

this is a Windows or Mobile build?

wraith spear
#

Windows

#

I've made sure that I don't have any #ifdefs in my code, and my Test assemblies are set to build in Editor only

knotty sun
#

My guess is you have a problem with your input action maps for the input system as this is scriptable object based

wraith spear
#

Ooh I see, haven't looked for any issues there yet

knotty sun
#

this
<RI> Initialized touch support.The referenced script (Unknown) on this Behaviour is missing!
and this
A scripted object
point towards that

wraith spear
#

Oh, my bad, there should be a breakline between those two lines. It's
`<RI> Initialized touch support.

The referenced script (Unknown) on this Behaviour is missing!`

#

Regardless, I'll have a look at my input settings

knotty sun
#

you may find just regenerating your input actions solve the problem

#

Also make sure you are using the latest input system package version

wraith spear
#

I've got 1.7.0. I see that there's a 1.8.0 online, but the Package Manager doesn't show an update button. Should I remove 1.7.0 and try to install it again?

knotty sun
#

what Unity version?

wraith spear
#

I'm on Unity 2022.3.21f1

knotty sun
#

then 1.7 is the best you get

wraith spear
#

Alright, thanks!

knotty sun
wraith spear
#

I've tried updating to 2022.3.4f1 to fix the issue earlier, but that didn't fix it sadly enough

knotty sun
#

.21 -> .4 ?

wraith spear
#

Yes

knotty sun
#

how is that an upgrade?

wraith spear
#

Oh my bad, the other way around! I used to be on .4, and then I upgraded to .21.
I need a coffee 😓

knotty sun
#

the latest 2022.3 is .38

wraith spear
#

I didn't yet have any Input Actions, so I made a new asset and generated a C# file for it, but I still get the same error. I'll try upgrading to .38, and I'll see whether Input Actions 1.8.x is available for that version

knotty sun
#

? How are you using the new input system without input actions?

wraith spear
#

I'm not sure honestly, I set this all up at the beginning of the project (>6 months ago), and that was my first time doing so, so it's a bit hazy now

knotty sun
#

I hate to say this but that sounds very much like the root of your problems

wraith spear
#

Yeah I think so too

#

I'll go do a deep dive into correctly setting up the Input Actions, and I'll see if that fixes the problems

#

Regardless, thanks a lot for pointing me in this direction. I would never have thought of looking here myself

knotty sun
#

I guess you have never looked at the actual input system code, it is very brittle and fragile if not used exactly how Unity wants you to use it

wraith spear
#

For the new IS or the old one?

knotty sun
#

new IS

wraith spear
#

That sounds... fun

knotty sun
#

I took one look at it and just built my own input system based on the low level code. Not fun but at least it works

wraith spear
#

I just checked my Input System settings, it was on "Both"
Just switched it to the new system and I'll incorporate it according to the official docs

misty blade
#

How can I get the pressed keyboard key? I found online this solution, but it seems inefficient to loop through all the possible key codes. Are there some input events I can listen to make it better?

Heres the example solution:

    void Update()
    {
        foreach (KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode)))
            if (Input.GetKeyDown(keyCode))
                Debug.Log("Key Pressed: " + keyCode);
    }

I’m trying to avoid the new input system, because my project is generally mouse only and using it to detect a left button click seems like an overkill

scenic sigil
#

Howdy. I have a problem.
So I have a value 0..1, and I want to check if it multiplied by 10 is a multiple of 2 (so 0.2, 0.4, etc.). But the native % operator returns stuff like 1,192093E-06 for 1.0 (10). What do I do?

knotty sun
#

Cache this

KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode)

for the rest it's your only option using the old input system

lean sail
lean sail
knotty sun
# scenic sigil how

for future reference try to spend at least 30 seconds understanding what you have been told before responding 'how'

scenic sigil
knotty sun
lean sail
maiden heath
#

strange question but how would i go about implenting a battle system for my game? not the technical way; i want to learn HOW to make it. i have the knowledge i need but im kind of stumped. was thinking of using enums for state machines, lmk if thats a good idea

#

and scriptable objects for the enemies and their stats

maiden heath
#

similiar to undertale but with a twist

#

heres a diagram i drew

gray mural
#

Not sure what to start from. Surely, you will need an abstract class Enemy to then derive specific enemies from it

gray mural
#

What's next?

maiden heath
#

i just want to make it perfectly, and not have to restart it because of sphagetti code, so im trying to come up with a plan

maiden heath
#

and scriptable objects for enemies

gray mural
maiden heath
#

i already have that set up

gray mural
#

Sure, you would also need a UIManager to update things associated with the UI

maiden heath
#

because i already have different singletons like dialogue manager and inventory manager so i would have to rearrange EVERYTHING

#

seems like a hassle

gray mural
#

Combat manager only manages the dialogues? Then that's fine

#

If you have a Singleton for every part of your game, it's fine

maiden heath
gray mural
maiden heath
gray mural
maiden heath
#

is it DontDestroyOnLoad(transform.gameObject);

#

in the awake function?

dreamy niche
maiden heath
dreamy niche
# maiden heath providing more context would help

Yeah for sure! I'm trying to have it so that the gun will always shoot the asteroids but depending on the angle or distance sometimes it will just keep missing target and I was hoping some fresh Ideas on how to fix that since I've ran out.

gray mural
maiden heath
gray mural
maiden heath
gray mural
maiden heath
#

but still nice

gray mural
ebon leaf
#

does anyone know why rigibody.AddForce() is inconsistant with screen resolution? and how can i fix this?

mellow sigil
#

You'll have to show the code

maiden fractal
molten thicket
#

I don't know where to put this so will ask here in case someone can help.

Has anyone come across this and knows a fix for it?

Unity V 2022.3.11

Deleting the folders from the Unity Editor data folder does nothing and I have no idea why this is happening 😅

Any help is greatly appreciated!

rain minnow
#

The amount of force applied doesn't change based on the size of the screen . . .

ebon leaf
#

it applies different force

knotty sun
mellow sigil
#

I'm assuming they mean different framerates which changes when resizing the game

scenic sigil
#

In a coroutine, how do I start another coroutine and wait for it to finish?

ebon leaf
#

so anyways how do i get consistant force with different screen sizes

knotty sun
maiden fractal
mellow sigil
#

Continuous force needs to be applied in FixedUpdate, not Update

scenic sigil
ebon leaf
#

let me try that and let u know if it works

knotty sun
ebon leaf
#

but like im curios

scenic sigil
ebon leaf
#

when do i know it should be in fixedupdate

#

and not

scenic sigil
#

fixedupdate runs every physics update instead of frame update

#

so it is independent of frame rate

ebon leaf
scenic sigil
#

see Fixed Timestamp in unity settings

knotty sun
scenic sigil
#

googling didn't yield clear results

ebon leaf
scenic sigil
#

no

#

deltatime is the difference between frames

#

all physics go into fixed update

ebon leaf
#

ahh i see

scenic sigil
#

update: runs on frame rate. if it's 30 fps, runs 30 times per second, if it's 60, runs 60 times per second
fixed update: runs on physics simulation rate. by default every 0.02 seconds, approx 50 times per second. used for all physics as it's independent of frame rate
late update: runs after update/fixed update is finished. good for camera updates

ebon leaf
#

i placed it in fixedupdate and it worked like a charm 🙂

#

thx alot

scenic sigil
#

np

ebon leaf
#

one more thing

#

i modified a value in a prefab outside of the prefab

#

and it wont get updated witht the prefab because of it

scenic sigil
#

im not experienced with prefabs heh

#

never used em actually

ebon leaf
#

fair enough

scenic sigil
#

sorry

ebon leaf
#

no worries man

#

thx again :))

uneven elk
#

so i have this issue with my gaem where there's this rotating platform but the player does not rotate with it. would anyone here be willing to help me figure this out? i know it's kind of a newb question.

#

yes i tried parenting the player to the platform and that's not working for some reason, it just gets stuck

#

i suspect it's an issue with the way i rotate the platform

gray mural
vagrant chasm
#

Hoi, I'm working on a portal system that will be able to recursivly render them. The problem I'm having is that when I'm trying to render the camera with UniversalRenderPipeline.RenderSingleCamera(context, portalCamera); it causes a stackoverflow, anyone got any alternative ways of rendering the camera in URP? or any solutions to fix this?

The for the render feature:
https://paste.ofcode.org/5MayTgL3mMCSTxQGYgemdh

Cheers!

stark sun
#

weapon is attached by joint btw not becase arm is its parent

ruby belfry
#

I seem to have misunderstood something about rigidbody, for some reason whever I add force to my object no matter what the direction it always shoots upwards. When I press down it moves up slowly (video) when I press up it shoots up fast. When I press left and right it goes left and right but always upwards too. It's like something is gravitating it upwards.
https://gyazo.com/b0dd077094a831174221b5d3d0094831

Debugging script:

    public bool down = false;
    public bool left = false;
    public bool right = false;

    [SerializeField] private Rigidbody2D rigidBody;

    // Start is called before the first frame update
    void Start()
    {
        
    }

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

        if (up) {
            rigidBody.AddForce(new Vector2(transform.position.x, transform.position.y + 1) , ForceMode2D.Impulse);
            up = false;
        }
        if (down)
        {
            rigidBody.AddForce(new Vector2(transform.position.x, transform.position.y - 1), ForceMode2D.Impulse);
            down = false;
        }
        if (left)
        {
            rigidBody.AddForce(new Vector2(transform.position.x - 1, transform.position.y), ForceMode2D.Impulse);
            left = false;
        }
        if (right)
        {
            rigidBody.AddForce(new Vector2(transform.position.x + 1, transform.position.y), ForceMode2D.Impulse);
            right = false;
        }
    }
#

Anybody got any idea why this is happening?

vagrant chasm
#

otherwise if the transform is at position 100, 1000 it will add a force that is 1001 to the y and 100 to the x, and if its in the x direction it will add 101 for the x and 1000 for the y and therefor mostly go up

#

then it would look smth like this

public bool up = false;
public bool down = false;
public bool left = false;
public bool right = false;

public float force = 10f;

[SerializeField] private Rigidbody2D rigidBody;

// Start is called before the first frame update
void Start()
{
        
}

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

    if (up) {
        rigidBody.AddForce(0, force) , ForceMode2D.Impulse);
        up = false;
    }
    if (down)
    {
        rigidBody.AddForce(new Vector2(0, -force), ForceMode2D.Impulse);
        down = false;
    }
    if (left)
    {
        rigidBody.AddForce(new Vector2(-force, 0), ForceMode2D.Impulse);
        left = false;
    }
    if (right)
    {
        rigidBody.AddForce(new Vector2(force, 0), ForceMode2D.Impulse);
        right = false;
    }
}

ruby belfry
#

thank you!

gray mural
dawn dock
#

Hey, im making a dialogue system by inputting a text file into unity and then using a streamreader to read the file. Ive heard that translating the text file into binary will massively optimise the system, is this true and how would i do this? Secondly, I would also like the streamreader to read the file line by line and input each line into a separate line in a Queue, how would I do this?

gray mural
#

Also, I suppose, else ifs should be added.

ruby belfry
# gray mural Here a method should be created, and `force` should be multiplied by `Vector2.up...

The script above was just a debugging tool I added to find out what the problem was, I'm trying to make it work with mouse inputs

This is what I'm working with right now:

        public void shoot(GameObject ball)
        {
            playerManager.losePossesion();
            ball.SetActive(true);
            Vector3 dir = GetMouseWorldPosition();
            Debug.Log(dir);
            ball.GetComponent<Rigidbody2D>().AddForce(dir, ForceMode2D.Impulse);
            ball.transform.parent = null;
        }

        public static Vector3 GetMouseWorldPosition() {
            Vector3 direction = GetMouseWorldPositionWithZ(Input.mousePosition, Camera.main);
            direction.z = 0f;
            return direction;
        }
        public static Vector3 GetMouseWorldPositionWithZ(Vector3 screenPosition, Camera worldCamera)
        {
            Vector3 worldPosition = worldCamera.ScreenToWorldPoint(screenPosition);
            return worldPosition;
        } 

Which I now realise is not going to work the way I had intended

wary coyote
#
    public void OnColorSliderValueChanged(float value)
    {
        currentHue = value;
        UpdateColor();
    }

    public void OnLightSliderValueChanged(float value)
    {
        currentValue = value;
        UpdateColor();
    }

    public void OnSaturationSliderValueChanged(float value)
    {
        currentSaturation = value;
        UpdateColor();
    }

    private void UpdateColor()
    {
        Color color = CreateColorFromHSV(currentHue, currentSaturation, currentValue);
        cursorPreview.color = color;
        icoPreview.color = color;
        col = color;
        ClientsideNetworkMessenger.instance.SetPlayerColor(color);
    }

    public Color CreateColorFromHSV(float h, float s, float v)
    {
        return Color.HSVToRGB(h, s, v);
    }```

Do you see any obvious reason why adjusting the Saturation in thos code causes the color to default to red?
gray mural
#
private void Update()
{
    if (up)
        AddForce(Vector2.up, ref up);

    else if (down)
        AddForce(Vector2.down, ref down);

    else if (right)
        AddForce(Vector2.right, ref right);

    else if (left)
        AddForce(Vector2.left, ref left);
}

private void AddForce(Vector2 direction, ref bool value)
{
    rigidBody.AddForce(direction * force, ForceMode2D.Impulse);
    value = false;
}
#

Also it's really bad to use booleans this way

ruby belfry
#

But I apreciate the input 😄

gray mural
maiden fractal
ruby belfry
# gray mural So what's the problem, currently?

I think what you and Tapeman have highlighted is that I'm trying to use a location as input while the addForce method is asking for a direction into which to push the object.
Say my Character is at x4 y5 and I'm trying to pass the ball down, I press a spot on the field let's say x1 y3. The way I programmed it now I put that in the add force and it just propells the ball upwards

#

Still figuring it out how I want to tackle this but I'm on the right track now I think

gray mural
ruby belfry
#

Behold my ugly quick and dirty fix

#

Im going to clean it up later but this ended up solving it

#

I based the direction on where I clicked the screen regardless of where the ball currenlty is

gray mural
ruby belfry
#

Can you elaborate?

gray mural
#

This means, you can apply the - operator directly on 2 Vector2s

#
vector = vector1 - vector2
#

Also, you're supposed to use the target position, not direction, as you have it called dir

ruby belfry
maiden heath
#

dk if i can post this here or in #archived-game-design but basically im making a turn based battle system and every enemy has its own special attack pattern so should i just:

jam it all into one script
or make seperate scripts for each enemy or
make a script called EnemyAttacks

gray mural
maiden heath
gray mural
#

But not sure how you manage it

maiden heath
gray mural
maiden heath
gray mural
maiden heath
#

well thanks i guess

gray mural
#

Because ScriptableObject is not an interface itself

maiden heath
#

also what does protected do?

gray mural
weak spruce
#
using System.Collections;
using UnityEngine;
using UnityEngine.UIElements;

public class SheepController : MonoBehaviour
{
    public float rayDistance = 10f; // Raycasti kaugus
    public int rayCount = 36; // Raycastide arv
    public LayerMask hitLayers; // Kihid, millele raycast reageerib
    public float speed = 5f; //Lamba liikumis kiirus
    private Animator animator;
    private float rotationSpeed = 5f;

    void Start()
    {
        StartCoroutine(RaycastRoutine());
        animator = GetComponent<Animator>();
    }

    void PerformCircleRaycast()
    {
        for (int i = 0; i < rayCount; i++)
        {
            float angle = i * (360f / rayCount);
            Vector3 direction = Quaternion.Euler(0, angle, 0) * Vector3.forward;

            RaycastHit hit;
            if (Physics.Raycast(transform.position, direction, out hit, rayDistance, hitLayers))
            {
                Debug.Log("Tabasime " + hit.collider.name + " suunas " + direction);
                transform.Translate(-direction * speed * Time.fixedDeltaTime);

                Vector3 targetDirection = hit.point - transform.position;
                targetDirection.y = 0;

                Quaternion targetRotation = Quaternion.LookRotation(-targetDirection);

                transform.rotation = Quaternion.Slerp(transform.rotation,targetRotation , rotationSpeed * Time.deltaTime);

                animator.Play("Run");
            }
            else
            {
                animator.Play("Idle");
            }

            Debug.DrawRay(transform.position, direction * rayDistance, Color.red);
        }
    }

    private IEnumerator RaycastRoutine()
    {
        while (true)
        {
            yield return new WaitForSeconds(0.01f);
            PerformCircleRaycast();
        }
    }
}
weak spruce
dusky lake
# weak spruce whats wrong with sheep

First up, use a SphereCollider and react to collision events or use CastSphere instead of 360 different raycasts, ill look at the rest now to figure out what causes the movement

clear siren
#

Hey guys I'm a beginner and I need help with a pong thing

#

I'll record it brb

dusky lake
clear siren
dusky lake
clear siren
dusky lake
tawny elkBOT
dusky lake
#

hard to see anything on a phone recording 😄

clear siren
#

There's 4 scripts though

rigid island
#

use links

clear siren
#

I don't know which one is the faulty one that's the problem

dusky lake
clear siren
clear siren
rigid island
#

where is the one that supposed to increase point