#💻┃code-beginner

1 messages · Page 563 of 1

azure bridge
#

oh

burnt vapor
#

Sorry, end of work shift so I can't really help anymore

swift crag
#

The canvas gets drawn directly onto your screen

#

An object at X=100, Y=100 goes at that exact pixel position on your screen

azure bridge
#

wait so anchoring doesnt matter if i do it overlay

swift crag
#

It does very much matter -- but you can't try to "line up" UI elements with stuff in the scene that way

leaden pasture
#

Yeah. Generally when changing stuff for a canvas, I find it easier to change the position and stuff in game view because it tends to create the canvas as a large element in random space within scene view

swift crag
#

Yeah, you can see how it'll look by watching the game view

#

What is this text meant to represent?

azure bridge
#

score:

#

wait ill try

swift crag
#

Okay, so it shouldn't really have a position in the world

#

It's just going to be a thing attached to your UI

#

In that case, anchor to the corner it belongs in and then adjust its position as desired

#

Look at your game view to check your work

#

While editing an overlay canvas, I'll generally put my scene view in 2D mode, then select the canvas and hit F to view the entire thing

azure bridge
#

but the thing is

#

in game view i cant find my text

#

😭

#

OH MY GOD

#

i just clciked something i cansee it now

#

i v e been blessed

leaden pasture
#

Nice! What was it that you clicked???

azure bridge
#

its this thing i edited the numbers idk how it works but now i can see a small text

leaden pasture
#

Ohhh. I tend to set that to 1920*1080 then make sure my display is at the same resolution. It's basically telling the canvas how it's going to move/scale each of its element based on screen size

green flame
#

Hello! I have a problem with the resize of gameobjects :/
When an enemy is going inside a certain circle, the enemy size decrease by 30%. My feature work well.
But the result IG is "bugged", there is a little freeze when the object change.
There is a little gif of the obvious behavior

azure bridge
#

omg guys look guys

green flame
#

Here is my script ^^

leaden pasture
azure bridge
#

thx for helping!!!

polar acorn
green flame
#

The blue alien, when the size change

#

you can see a non instant change

polar acorn
#

The change looks pretty instant to me

wintry quarry
green flame
#

I am alon e to see the little freeze on mobs ? XD

wintry quarry
#

and just use a bool flag for isShrunk or not

#

don't mess around with comparing floats like this

green flame
swift crag
#

It looks like the enemy's shrinking for one frame, growing back for one frame, and then shrinking for good

#

Do you have an OnTriggerExit2D method that restores their size?

#

If so, I suspect that the shrink is making their collider small enough that they leave the circle

#

ooh, it's happening many times!

green flame
#

Hann something like

#

IN -> little -> OUT -> big -> IN again

swift crag
#

oh man that conversion did NOT go smoothly

swift crag
#

I'd call it "flapping" -- rapidly going back and forth

green flame
#

Here is my IN/OUT code

swift crag
#

If that is what's happening, then there are a few options

green flame
swift crag
#
  • Don't make the size-change affect the collider's size (just shrink the sprite itself)
  • Don't allow the enemy to grow back at all
  • Add a delay before the enemy is allowed to grow
#

A delay is pretty easy to do

#

You record the time that something is allowed to happen after

#
delayTime = Time.time + 1f;
#

Until Time.time > delayTime, don't do anything

green flame
#

mmmmh

#

Is there a condition in unity like

#

"full enter" "full out" ?

#

OnCompleteTriggerEnter2D

#

Idk x)

swift crag
#

I don't think you can ask if a collider is completely enclosed inside of another, no

green flame
#

😢

#

The hard way, custom function to check if the current possition.x & y is inside the circle scale

#

Idk which option is the "proper" one

#

Add a delay before the enemy is allowed to grow

I'm not fan because later I'll have big enemies with slow moves

#
  • Don't allow the enemy to grow back at all
    Maybe a smooth move to the circle when enemies size change ?
#

According to the current size of the enemy

#

And the current move_speed

#

aaah not easy x)

pine cedar
#

Test mathmatically if a point is within a given bounds.

green flame
#

Ty i'll look at this 😄

severe onyx
#

Im stumbling over something which is probably just a simple math function away - how the hell do I rotate a sprite in 2d space so it faces into the direction it's travelling?

wintry quarry
sterile radish
#

how can i get all children of a certain object and then put them into an array?

wintry quarry
#

if it has a rigidbody 2d then theDirection can just be myRb.linearVelocity

wintry quarry
#

but - why do you need them in an array, you can iterate over them directly from the object

#

e.g.

foreach (Transform child in myObject.transform) {
  Debug.Log(child.name);
}```
sterile radish
#

oh yeah ur right

#

the second option is a lot more suited for what im trying to do, thanks for the help!

swift crag
#

one annoying gotcha: you must explicitly write Transform there

#

If you do this...

foreach (var child in transform) {

}

...then child will be a System.Object

#

for some reason, Transform implements IEnumerable, not IEnumerable<Transform>

snow ruin
#

im trying to do the expert challenge 2 for the junior pathway and im struggling to get my sliders in the correct position. i put in the coordinates as the instructions said to but in play mode they are appearing at a wildly different place and i have no idea why it could be

grand snow
tiny vault
#

Hey, when you interact with a specific NPC you load a new scene. Once you complete the game in the new Scene, you go back to the main game, however i don't go back to exactly where i was when i initiated the new scene, instead it resets the whole game. Any ideas how to fix that ? And btw the sampleScene is the main scene. Just haven't got to change the name yet

grand snow
tiny vault
#

Yes exactly

grand snow
#

You need to implement some way to store the old game state of things in that scene, or just load the puzzle scene additively and remove it once done.
Then your sample scene is never removed.

tiny vault
#

I tried that already. Just gives me these weird errors

wintry quarry
grand snow
# tiny vault

If you load the scene additivley you need to wait for it to be loaded. If you want to manually activate it then it can only after this load is done (its async).
by default it should activate on load complete for you unless you changed an arg.

#

the doc page should explain this all and give examples.

wintry quarry
#
  • LoadScene will not complete loading until the next frame
  • LoadSceneAsync will obviously require handling the async task properly.
bright sail
#

Hey there! I am not sure where this belongs exactly so i might try my luck here, if thats the wrong channel please help 😄
So i have a Line renderer which should display 3 Points and i want my White Circle Sprite to repeat along the 2 created lines. But currently it looks like the picture. I need to have a 3d Material in the Linerenderer Material, so i created one gave it the 2d Img as Albedo (Which is a Single Sprite (Texture Type 2D) with Wrap Mode Repeat). On the SpriteRenderer i activated Texture Mode "Tile" and all goes well until the Edge of the Line where you can see it stretches very weird. Ive looked online but i have not really found why or how to fix it. Hopefully one of you guys can help? ❤️

wintry quarry
#

Make sure the scale on the renderer and all its parents is 1:1:1

#

looks like a classic non-uniform-scaling skew thing going on.

bright sail
swift crag
#

do you mean you set the texture mode to tile on the LineRenderer?

bright sail
#

yes it set it to this

#

Tiling, Scaling 1 and 1 and left everything i dont know to the default 😄

swift crag
#

I do see some skewing when I slap a grid texture onto a line renderer

wintry quarry
swift crag
#

It behaves much better if you set "Corner Vertices" to at leaset 1

bright sail
swift crag
#

note that this will cause a bit of weirdness on the actual corner

bright sail
# swift crag

with no texture it looks right aswell but with the dot its screwed

swift crag
#

right, because each line is sheared a bit

bright sail
swift crag
#

One edge is longer than the other, but they're trying to cover the same range of UV coordinates

#

so it skews

bright sail
#

ohhh that actually makes alot of sense yea

swift crag
#

Ideally, it would just create a separate pair of triangles at the corner

#

but I guess it can't do that if Corner Vertices is set to 0!

bright sail
#

That is actually exactly what i wanted thank you very much

#

dang 😄 Happy new year haha

swift crag
#

ah, nice (:

#

The corner winds up having constant UV coordinates along the arc. It doesn't look half-bad with this grid material

#

In your case, since the texture is transparent at its edges, you shouldn't see anything at all in the corner

bright sail
#

yea the corner is just blank

#

but its not tooo much of a problem for this specific project since its thought as a helper line for where a ball is gonna move towards so the exact corner location isnt that important rather than the reflected angle from the wall 😄

bright sail
gaunt sandal
#

I cannot get my raycast to detect the ground no matter what i try:

    void OnCollisionStay2D(Collision2D other)
    {
        string otherLayerMaskName = LayerMask.LayerToName(other.gameObject.layer);

        if (otherLayerMaskName == "Wall")
        {
            Rigidbody2D rb = GetComponent<Rigidbody2D>();
            HaltHorizontalMovement();
        }

        RaycastHit hit;
        LayerMask groundMask = LayerMask.GetMask("Ground");

        // Detect if there is ground beneath the player
        if (Physics.Raycast(
            transform.position,
            transform.TransformDirection(Vector3.down),
            out hit,
            (transform.localScale.y / 2) + 0.1f,
            groundMask
            )
        )
        {
            Debug.DrawRay(
                transform.position,
                transform.TransformDirection(Vector3.down) * hit.distance,
                Color.yellow
                );
            
            isGrounded = true;
        } else
        {
            Debug.DrawRay(
                transform.position,
                transform.TransformDirection(Vector3.down) * ((transform.localScale.y / 2) + 0.1f),
                Color.white
                );
        }
        Debug.Log("Colliding with: " + otherLayerMaskName);
    }

so far, i have:

  • double checked that the ground object actually is on the layer "Ground"
  • written the raycast such that it doesn't require a layermask and visa versa
  • added Debug rays to check what's going on

my editor setup:

swift crag
#

You're using the 3D Physics raycast in your code

#

but this is inside a 2D Physics collision method

#

That does not sound correct.

gaunt sandal
#

oooooooooooooooooh

#

thanks!

swift crag
#

i usually mix them up when trying to help someone with 2D, haha

gaunt sandal
#

lol the 2d ptsd

swift crag
#

Note that Physics2D.Raycast looks and feels just different enough from the 3D one to be confusing

#

so pay careful attention to how it works

gaunt sandal
#

it is fixed!

snow ruin
hallow bough
#

I have a question. I am currently working on a menu navigation for my home screen. I am trying to make it so when I press a button, the program will close the current screen, and selected a certain button. Can someone please help me?

leaden pasture
hallow bough
#

when I close the menu (run exit) nothing becomes selected

#

update: just restarted unity, its all working now. idk why it didn't

leaden pasture
#

Ahh right very fair. Unity does like to do random stuff sometimes but at least it works now

hallow bough
#

ty for trying to help

grand snow
polar briar
#

How do custom game tick rates work

#

It’s not frames is it? (I kinda have an idea but I don’t get how to use it)

errant pilot
#

Guys how can i make a 2D object flash as in become brighter for a second?

wintry quarry
swift elbow
errant pilot
swift elbow
#

wdym by "flash that specific object only exactly"?

#

do you want the gameobject itself to glow or to mimic a general lighting effect?

errant pilot
polar briar
swift elbow
wintry quarry
#

it's more or less what FixedUpdate is

#

easy to make your own as well

polar briar
#

Ok that’s what I was kinda hoping

#

I just need to look into how fixed update actually works. It always kinda confused me

wintry quarry
polar briar
#

Okay yeah that makes since

wintry quarry
#

To add pausing you could just do:

void Update() {
  if (!paused) timer += Time.deltaTime;

  // the rest...
}```
polar briar
#

I never seen a frame interval before so that’s a lil new

#

But I get it in concept

wintry quarry
#

it's just a number indicating how many seconds each frame takes

#

in this case I defined it as 1/50th of a second

polar briar
#

Okay

#

I need to understand code format first. I can read it but writing it feels rly foreign still

#

But that’s good to know where to start with my learning

wintry quarry
polar briar
#

Tutorial hell time

gaunt sandal
hallow bough
#

I am working on a input system for menu navigation, and I am having some trouble creating a delay in the middle of a script. I read online Invoke and coroutines help a lot in this kind of situation, but I do not know how to implement them. Can someone please help me? (I want the canMoveSelector variable to turn true after a few miliseconds so it doesn't skip any buttons)

{
    if (currentSelection != 0)
    {
        if (input.y > 0.9f && canMoveSelector && currentSelection + 1 < MainInteractions.Length)
        {
            UpdateColorMain(1);
        }
        else if (input.y < -0.9f && canMoveSelector && currentSelection - 1 > 0)
        {
            UpdateColorMain(-1);
        }
        else
        {
            canMoveSelector = true;
        }

        if (currentSelection == 1 || currentSelection == 0)
        {
            if (input.x > 0.9f && canMoveSelector)
            {
                UpdateColorMain(1);
            }
            else if (input.x < -0.9f && canMoveSelector)
            {
                UpdateColorMain(-1);
            }
        }
    }
    else
    {
        if (input.x > 0.9f)
        {
            UpdateColorMain(1);
        }
    }

    if (pressed)
    {
        MainInteractions[currentScreen].GetComponent<Button>().onClick.Invoke(); // run the button's on click event
    }
}```
gaunt sandal
tame oriole
#

Is this where I learn code

gaunt sandal
tame oriole
#

Ah

hallow bough
tame oriole
#

Yes I am wondering if there's any free courses that teach c# to help understanding I've been stuck in tutorial hell and am unable to script without a tutorial

#

I did do a script once that worked and it's still in my game

gaunt sandal
hallow bough
tame oriole
#

I wanna make a multiplayer rts

gaunt sandal
tame oriole
#

And I plan on adding multiple classes in the future

gaunt sandal
tame oriole
#

I've followed a tutorial series but he doesn't explain the code very much I've got click select and drag select as well and deselect and when I click the selected object move to the selected point

cosmic quail
#

yeah tutorials tend to do that (not explaining code)

tame oriole
#

Yea one tutorial just said copy and paste this script

gaunt sandal
#

have you programmed in c# before making this game?

tame oriole
#

Yep

hallow bough
gaunt sandal
#

i shall visually explain it

tame oriole
gaunt sandal
tame oriole
#

The puzzle game is out on itch but the UI is overcrowded and the puzzle is really difficult

hallow bough
tame oriole
#

Classes are the start function type things right

gaunt sandal
tame oriole
#

Wait that's fuctions

#

Ok

#

I'll get ready for the day in a sec

gaunt sandal
#

oki

wintry quarry
#

You need to drag a GameObject with the script attached to it to the slot, not the script itself

frosty hound
#
  1. It's not a public function
  2. It contains more than one argument
wintry quarry
#

Those also need to be true^

steep rose
# tame oriole Classes are the start function type things right

A class is not a function, it is a class which I would say is the "holder" of all of your variables and methods which can be executed in it to get a desired outcome (e.g making a calculator class to calculate addition, subtraction, multiplication, division for 2 numbers), A method like the Start method goes inside of a class and methods are functions which do a specific thing (which in my last example would be a Calculate(float x, float y){}; and would be called in start or update depending on what you put in it).
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/classes
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methods

west radish
#

Another thing to note, Start() and Update() comes from MonoBehavior, they aren't inherent to what a class is

languid spire
#

except in C# we call them methods

gaunt sandal
# tame oriole I'll get ready for the day in a sec

this is the easiest way to understand classes:

  • Our game is like the house we want to build
  • Classes are like a box
  • In those boxes, we can put materials (variables, fields, properties) inside
  • We can also put tools (functions) inside that allow us to create our house (game) using those materials

Classes allow us to couple data with methods of manipulating said data in a neat little package.

torn jolt
#

never coded in my life

#

need help as im trying to make a puppet combo kind of game

#

or you could say like Fears to fathom

gaunt sandal
#

what specifically are you needing help on?

torn jolt
#

toggling i guess it says

slender nymph
#

!ask

eternal falconBOT
torn jolt
#

we could hop in vc

gaunt sandal
#

sure!

tame oriole
west radish
tame oriole
#

I'm now watching a 1hour explanation on the basics of c#

cosmic dagger
burnt vapor
# torn jolt we could hop in vc

There are no voice chats in this server. Just ask your question instead of reserving a single person because you will likely get a better answer anyway

cosmic dagger
hot laurel
gaunt sandal
#

I sent over some resources to get started

gaunt sandal
#

since everything in c# is an object

#

but in terms of unity, it's an object that can then be used as a component for GameObjects

burnt vapor
#

It defines a type of object

runic lance
#

yeah, if it was an object it would be something more similar to Javascript prototypes

#

I think the blueprint definition is pretty accurate

gentle bone
#

Just imagine a Class like a Basket... In this Basket you have like Types(enums) Apples, Oranges, etc. with different properties (variables) like string NameOf Fruit .... int SizeOfFruit ... and Methods(functions) what you can do with them... void EatApple(); void EatBanana(); etc...

burnt vapor
#

Methods aren't objects, for example

#

But we can define a MethodInfo object

gentle bone
#

the class is simple just the whole Basket with all Info of the items and what you can do with them

tame oriole
#

um how do i make an object clicked and unclick

#

how i allow selected and deselected

hot laurel
fair badge
#

whats difference between struct and class?

inland cobalt
#

Hey all, im trying to make a generalised abstract class that other classes can inherit to implement as a singleton, this is what i've done:

using UnityEngine;

public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
    public static T Instance { get; private set; }

    private void Awake()
    {
        if(Instance != null && Instance != this)
        {
            Debug.LogWarning("Duplicate instances of player controller exist");
            Destroy(gameObject);
        } else Instance = this as T;
    }
}```

And in my player controller for example, its being inherited like this:
```cs
public class PlayerController : Singleton<PlayerController>
{
  // ...
}```


however when i try to access this singleton in another script:

```cs
public class PlayerTelementery : MonoBehaviour
{
    private PlayerController playerController;
    
    // ...

    private void Start()
    {
        playerController = PlayerController.Instance;
        // ...
    }```

PlayerController.Instance causes a undefined reference exception to be thrown. Does anyone know what im doing wrong?
burnt vapor
#

The important thing here is that structs, being value types, are passed by copies of itself and classes are passed by reference

#

What happends here is that if a value type leaves the scope, it's gone

#

A class is not gone. It has to be collected by the garbage collector when it's fully out of scope

tame oriole
#

im trying to make a gameobject that when clicked it pops up a ui menu

burnt vapor
#

This makes value types the better choice when you have small allocations and/or want to run fast processes, as you want to avoid garbage as much as possible. However, it's not always the best idea here

#

Example, a Vector3 is small and a struct. It's used and called often by math so it should be fast

tame oriole
#

and when ground is clicked it closes teh menu

fair badge
#

what is garbage collerctor?

burnt vapor
#

It's an internal system used by .NET that handles the removal of stale reference types that are no longer used

#

You can look into some of its features with the GC class, but I advice you just leave it alone

#

In C++ you always had quite the risk of having dangling pointers because in that language there was no GC and you had to make sure pointers were properly disposed of.

#

.NET has it easier. You can say object referencing through parameters and such is kind of the same as the pointers, minus the manual disposing

swift crag
#

Unity just grabs the most specific method it can find and runs that. It won't run both Awake methods

swift crag
#

Consider making Awake virtual in that case, and then overriding it on the player controller

#

(and then making sure you include a call to base.Awake()

inland cobalt
swift crag
#

I have a fair bit of code that will malfunction if you don't call the base method, so it's not exactly uncommon, I'd asy

#

I don't see a way around that if you want to assign the reference in Awake

burnt vapor
#

BTW @fair badge this whole thing with classes and allocation is also why you should generaly try to reuse classes, like through pooling. It's always a very good idea to reuse a class instead of just creating a new one since you just take up more memory and force the GC to collect more stale objects

inland cobalt
swift crag
swift crag
#

i find an instance with FindAnyObjectByType

#

this doesn't check for multiple instances

inland cobalt
swift crag
#

It has a mildly funny behavior if it fails to find anything

#

I have Domain Reload disabled, so I need to do some cleanup when exiting play mode -- but objects are getting destroyed by that point, so my instance can compare equal to null

inland cobalt
tame oriole
#

how do i make a gameobject via script as in i click a button and it add a prefab to teh scene

slender nymph
#

or is that comment meaning that you are using the other data on your MB that doesn't touch unity stuff?

swift crag
#

Right.

#

It's all stuff that would be irrelevant in the built game

#

I should check if Application.quitting is raised before stuff gets destroyed

#

(I'm pretty sure I've also had problems with this during scene unload)

verbal dome
marble hemlock
#

So I was originally going to have an array, and then try to have the game keep a list of all the different things that get spawned, and then... I guess just keeping track of it. I'm not exactly sure how to have the player leave and exit a scene but without restarting the scene so I was just going to do this, and forcefully have it manually update each time they leave but

#

surely there is a more efficient way to do this right?

torn jolt
#

ok so

verbal dome
#

I'm not exactly sure how to have the player leave and exit a scene but without restarting the scene
Not sure what that means

#

Do you want these things to persist when the scene changes or not?

marble hemlock
#

yeah

#

Okay so for an example, lets say the player goes through an entire section and interacts with everything, clicks on a door to leave, and it'll load a new scene. If they go back through that door to the original scene they just came from, I don't want everything to just reload, but to be in the same state they just left it in.

verbal dome
#

Okay so you need some sort of save/load system here

marble hemlock
#

agony

#

thank you i will look into it

#

is it a generally difficult thing to do?

verbal dome
#

It's not the first thing I would tell a beginner to do but most of us need to learn it at some point

tame oriole
#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UIElements;

public class Castle : MonoBehaviour
{
public GameObject indicator;
public GameObject menu;

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

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


// Clicks on tower
private void OnMouseDown()
{
    indicator.SetActive(true);
    menu.SetActive(true);
}

}

tame oriole
eternal falconBOT
tame oriole
#

huh

marble hemlock
#

its like that huh

astral falcon
tame oriole
#
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UIElements;

public class Castle : MonoBehaviour
{
    public GameObject indicator;
    public GameObject menu;

    // Clicks on tower
    private void OnMouseDown()
    {
        indicator.SetActive(true);
        menu.SetActive(true);
    }



}
#

woa

#

ok how do i add a deselct thing

marble hemlock
tame oriole
marble hemlock
#

The first two seem reasonably sane but the 3rd just feels like its going to beat me down

sinful hawk
#

Hey there-- for whatever reason my linerenderer keeps bugging out and swapping locations on the 0'th index here. The transform that is attached to the location is not actively moving, and seems to be a purely line renderer thing.

The only thing I can gather atm is that somehow the object parenting is messing it up, but it's so inconsistent that I am unable to figure out what is specifically the issue.

#

The gameobject labelled bobberstart is placed on the end of the fishing rod, and does not move unless you look around. The only thing glitching around is purely the linerenderer

swift crag
#

What is the line renderer attached to?

sinful hawk
#

The fishing rod object-- which also has this script attached

swift crag
#

totally irrelevant, but that's producing interesting video artifacts

sinful hawk
#

Oh weird

swift crag
sinful hawk
#

I am certain

#

I've compared the two whilst split screening it and the bobber start object is not moving whatsoever

#

Yeah

#

I'd get a gif for proof it's not happening, but it's somewhat hard lol

swift crag
#

(actually, just toggle the behaviour on and off)

#

I wonder if something else is trying to set the points as well

sinful hawk
#

hmmmmm maybe

#

lemme try

#

Also here's the gif for the bobberstart posiitons

slender nymph
#

so it's only happening when you move around?

sinful hawk
#

sometimes its when im stationary too

#

just depends

#

its a bit random

astral falcon
#

Moving two things separately is never a good idea if they are parented

sinful hawk
#

Ig I don't understand what you mean by that

#

I'm not moving things that are parented directly really

#

But yeah I'm really quite at a loss

#

Bc I'm only reading world position data and directly feeding that into the line renderer

#

And the thing that is supposed to be moving (the bobber itself) isn't even the thing causing issues lol

swift crag
#

Do you have anything setting bobberstart's position?

sinful hawk
#

It's just a basic parent on the fishing rod itself

#

🤷

swift crag
#

A very sneaky problem can happen if you use the position of something before you update it. You'll see the correct position in the scene view, but the position will be wrong when you actually use it

verbal dome
#

I'd try moving this to LateUpdate

robust condor
#

Should I use a global pool or a specialized pool for each weapon? Imagine if I have 10 different weapons in the scene, all shooting different types of projectiles, missiles, lasers etc. Should each weapon itself have its own pool or should I use one big pool for all bullet types?

sinful hawk
swift crag
#

Consider using Gizmos.DrawSphere to draw a gizmo at the exact position of bobberstart

#
Gizmos.DrawSphere(bobberstart.transform.position, 0.1f);

This'll draw a small solid sphere at that position

#

That'll rule out a bogus position

#

I'm also wondering if you have a rigidbody on the player or on FishingRod

#

This smells like something that's updating out of sync with something else

verbal dome
#

It isn't guaranteed that in OnDrawGizmos the positon is the same as in Update/LateUpdate though

swift crag
#

duh

sinful hawk
#

Using LateUpdate seems to be solving the issue-- though oddly enough now when moving and casting the rod, it'll move in a strange direction, but I can realistically fix it

swift crag
#

I wrote a system to let me request a gizmo to be drawn later

#

so I forgot about that

swift crag
verbal dome
#

I recently wrote a "GLDrawer" that I submit triangles and lines to and draw it whenever I want

#

It uses GL.LINES etc.

#

So works in builds too

swift crag
#

I just shove an entire anonymous function into a list to run later lol

#

GC Alloc? Yes

sinful hawk
#

I think the weird casting position is a result of my own implementation though so idt its a huge issue

#

I appreiciate the help though guys!

#

Thats a weird desyncing thing though

#

You'd kind of think that the positions would be finalized when on screen, but ig not 🤷

swift crag
#

If you do things out of order, you can get "off by one frame" issues

sinful hawk
#

oh weirdddd

swift crag
#

Are you using a Rigidbody anywhere? if so, is Interpolation on?

sinful hawk
#

I have a rigidbody on the bobber and the player character for which the rod is parented to

swift crag
#

I believe interpolation applies between Update and LateUpdate

sinful hawk
#

Yeah there's no interpolation, so that's probably it

swift crag
#

So you were getting one-frame-old positions

#

oh, if there's no interpolation, then that wouldn't be relevant

sinful hawk
#

oh

#

Welp-- I'm very glad it's working now at least lol

slender nymph
#

that shouldn't have affected when it was perfectly still though and you indicated that it would still do that when not moving

swift crag
#

The video didn't show that; it looked like the error was proportional to the movement rate

#

as far as I can tell, at least

sinful hawk
#

it definitely exacerbated the issue yes

swift crag
#

Do you mean that it happens both when looking around and when moving around?

slender nymph
#

yep, but i specifically asked right after they posted the video

swift crag
#

not when you're both:

  • not moving
  • not rotating
swift crag
#

Moving and rotating both cause the objects to move around, so that would make sense

#

It would be weirder if it was happening when nothing was going on at all

sinful hawk
#

Sometimes it'd happen when standing in very specific circumstances, but I think that's because there's some slanted objects on the boardwalk which would cause the player position to shift

verbal dome
sinful hawk
#

I have one camera for the render texture and one for the fishing rod to make it appear before other objects

verbal dome
#

Oh well you do have them side by side in the video

#

Okay, could be related to that, maybe the cameras interfered somehow when the linerenderer is being calculated for each of them

#

Just guessing though.

sinful hawk
#

I thought about that-- but I think at one point I removed the fishing rod cam and the line also disappeared

#

And because the component was on the rod, the linerenderer itself was effectively on the same layer (that's my understanding at least)

swift crag
#

you mean the "HeldItemCamera"?

#

that's very interesting information

sinful hawk
#

Yep

#

It's an overlay cam for the rod

swift crag
#

The camera's culling mask decides what layers it can see

sinful hawk
#

yeah thats what i meant

#

apologies

#

The culling mask only targets the helditem layer, and the rod and therefore the linerenderer component would only be rendered by that camera then

#

That's my understanding on the topic

#

Either way, I appreciate the help for getting it working! I can now finally progress without losing my mind over a line that teleports 😂

swift crag
#

I would want to figure out the root cause here

sinful hawk
#

Fair enough

swift crag
#

but I don't see anything particularly obvious at this point

sinful hawk
#

yeah-- especially considering even though there may be some difference between the update and lateupdate-- it doesn't make sense as to how far away the positions were when the line was to glitch out

#

Idk-- I'll come back and share more assuming it comes back up 🤷

cold elbow
#

I'm using rider and sometimes it tells me expensive method invocation

#

like how expensive?

#

I dont get it

swift crag
slender nymph
# cold elbow like how expensive?

$5 per call
/s
it's basically just warning you that you should cache the returned object for that method instead of calling it over and over if possible. you'd have to profile it if you want hard numbers

swift crag
#

I only charge $3

#

Buy now

verbal dome
#

I don't really like how it marks a method "expensive" when it contains, for example a Debug.LogError in case something goes wrong

#

But I guess I already got used to seeing those non squiggly yellow-ish lines

slender nymph
#

store it for reuse

swift crag
#

I have a ton of methods flagged as "frequently called" because they're called by an Update message...even though they'll only run once, ever

#

i should probably turn off that analysis

cold elbow
#

how can you do that

slender nymph
#

well it depends on what the actual method in question is, if it's a method that returns void, obviously you can't. but if it returns some object then you just store it in a variable

#

like GameObject.Find returns a GameObject and beginners tend to spam that, but you can just call it once and store the returned GameObject in a variable instead of calling GameObject.Find each time you want that specific gameobject

cosmic dagger
#

True; any method with a log inside will get flagged as expensive. I've seen methods flagged that didn't have it, but somewhere along the chain, one method had a log in it, thus activating the warning for every method along the chain . . .

cold elbow
#

in my case I keep using GetComponent

slender nymph
#

yeah that can easily be cached. though it isn't really an expensive operation per se

cold elbow
#

it's generally best used when you keep calling the method in update right?

slender nymph
#

i don't know what you mean by that. but storing the result of GetComponent can easily be done in Start and just reusing that variable so you aren't calling GetComponent unnecessarily each frame

cosmic dagger
#

Any GetComponent should be cached . . .

cold elbow
#

fair enough

cold elbow
#

does the position of this object depend on the position of the blue green red arrows thing?

slender nymph
silk meteor
#

is it possible to easily convert a vector 2 into vector 3

#

(simplest way possible)

frosty hound
#

Depends if you want to provide a value for Z or not

#

It's easy either way

silk meteor
#

well z can be 0

frosty hound
#

Can be or will be?

silk meteor
#

will be

#

Vector2 controller => transform.parent.localScale; because i have this code

frosty hound
#

(Vector3) myVector2

silk meteor
#

i just realized

#

omgg

#

thanks :3

#

can you not multiply vector3's?

wintry quarry
#

Vector3.Scale, Vector3.Dot, Vector3.Cross

silk meteor
#

oh i see

wintry quarry
#

The reason the * operator doesn't work is because it would be ambiguous which of the three types of multiplcation you want

silk meteor
#

interesting

#

well i see, thanks

inland latch
#

hi, i keep getting this error

UnityEditor.SerializedProperty.get_objectReferenceInstanceIDValue () (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EditorGUIUtility.ObjectContent (UnityEngine.Object obj, System.Type type, UnityEditor.SerializedProperty property, UnityEditor.EditorGUI+ObjectFieldValidator validator) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.UIElements.ObjectField+ObjectFieldDisplay.Update () (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.UIElements.ObjectField.UpdateDisplay () (at <64861216782042de93237b5c061bff1b>:0)
UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at <9b3502c626dd433da43ca50f8c32f6ba>:0)
UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at <9b3502c626dd433da43ca50f8c32f6ba>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <9b3502c626dd433da43ca50f8c32f6ba>:0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <9b3502c626dd433da43ca50f8c32f6ba>:0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <9a95e3c806024daf96fa9e2a7f9d9fba>:0)

in the editor in unity, nothing breaks and everything still works, but it spams the editor and only after i've run the game once and closed it in unity?

compact stag
#

hey guys! just a general question, but if im starting out with unity is it better to use 2019.3 or unity 6?

wintry quarry
wintry quarry
compact stag
#

well, the tutorial seems to be from 2019.3

#

or a 2019 version, not sure

wintry quarry
#

But if you want to start an actual game project, using the latest LTS version is recommended

compact stag
wintry quarry
#

plus you can remove the splash screen for free

inland latch
#

i did have mockhmd too, but i removed it for testing as it's experimental and nothing changed

wintry quarry
compact stag
#

!code

eternal falconBOT
compact stag
#

please! ^

noble forum
#

oh mb

#

can anyone help me?
im using a slider in settings to change the lens of my cinemachine camera (in 2d) and it only changes after i close the pause menu (so when i set the time back to 1 from 0)
https://paste.mod.gg/xfjvlmfndyna/0
this is the code

inland latch
# wintry quarry Any Asset Store assets?

none from the asset store but i did download the files from this tutorial

Are you ready to dive into VR game development with the latest tools and techniques? This video is your ultimate quick start guide to creating a VR game using Unity 6 and the XR Interaction Toolkit 3.0. Whether you're new to the VR dev community or a seasoned developer, this tutorial has something for everyone.

Key Topics:
-Unity 6 installation...

▶ Play video
winged seal
#

hey im wondering if i have to code or anything im making a vr game and i just cant make the controller i have the model and stuff but i cant make it work

winged seal
#

do i have to code?

wintry quarry
#

I don't know, do you?

winged seal
#

im no good at coding

wintry quarry
#

What are you trying to do?

#

Do you have to fly airplanes?

winged seal
#

no

#

shooting

wintry quarry
#

If you want to make a game in Unity you generally have to code, yes.

inland latch
#

find one online if you don't wanna do anything, look at the asset store

winged seal
#

i made the vr run on the headset

#

so thats something

inland latch
#

and when focused inside a prefab in isolation it stops too

winged seal
inland latch
#

in your unity assets folder

#

assuming you installed the package

winged seal
inland latch
#

click open in unity

winged seal
#

i did

#

shoot i have the 2017 version downloaded

wintry quarry
# winged seal this?

The way to add assets to your unity project is from the package manager within Unity

#

not from the website

winged seal
#

but when i use the package manager it wants me to get the zip

#

yuh

ashen frigate
#

how do i find this collider i dont see it in the hierarchy

wintry quarry
#

(which is a Collider btw)

ashen frigate
#

ohhh

#

how can i move it up ?

wintry quarry
ashen frigate
#

rect tool dont work on it ?

wintry quarry
#

rect tool is for 2D stuff and UI

ashen frigate
#

isee ty 😘

ornate aurora
#

Hi! I'm trying to make an infinite version of Minesweeper in unity. At the moment I'm just messing with the map generation. I want a seed-based tile map generation that supports local mine density (you will see what I mean soon). I'm generating the maps completely revealed. So my current system goes as follows:
There are two functions that generate the infinite map. One is opensimplex2 from fastnoiselite and the other one is the same function on a different seed but shuffled (previously via trickery with hashes and now it's just a big sine wave with big frequency modulo 1) so that it resembles a bunch of iid uniform random variables for each tile. There's some constant threshold p and a given cell is a mine if the noises added up (open simplex is smooth, the other is just white noise) go higher than p.
The render system consists of a list of chunks that has the chunks that will be rendered, and has a maximum size. Every frame, it looks at the camera corners and removes all chunks that are outside the visible part. When removed, I call SetTilesBlock to set all the tiles to null. After that, it tries to add as many chunks as the list allows, from the visible part. When a chunk is added to the list, I call SetTile to all of the cells in the chunk. Setting the tile requires knowing the tile type (safe or mine) and that requires calling the noise functions from above.
My issue is that this is actually extremely laggy! The functions that use the most cpu (I got that from deep profiling) are the SetTile and evaluating the noises at a given point, with 22 and 17ms respectively (should be less than 16 to run a 60fps). This makes me think that my approach was flawed from the very beggining, because it's not like games can't generate infinite 2d worlds (Minecraft does it in 3d). What is the issue here? Are tilemaps not the right tool? Maybe there are better ways to generate noise? Any help is appreciated!

naive pawn
wintry quarry
winged seal
wintry quarry
#

then import it

winged seal
#

ok.

#

there is nothing

#

wait

wintry quarry
#

Is this the package?

winged seal
#

yeah i just realized xd

#

i think it is

wintry quarry
#

open the scenes folder

#

open a sample scene or whatever

winged seal
#

1st or 2th?

wintry quarry
#

whichever you're interested in

winged seal
#

or i can choose whatever i want

#

it just said this

#

not errors againn

wintry quarry
#

show your console window

winged seal
#

here

wintry quarry
#

do you have the XR package(s) installed?

winged seal
#

the vr ones?

wintry quarry
#

these

winged seal
#

let me check

#

i have interaction toolkit

wintry quarry
#

Looks like you need the packages listed there and one of the Unity versions listed thre

#

er wait is this the same package you're trying?

winged seal
#

the game's name?

naive pawn
#

the asset you're using

winged seal
#

wait

#

its called xr interaction

naive pawn
winged seal
#

31 is alot

naive pawn
#

seems like it doesn't list its deps

#

i see one of the errors is for the inputsystem

#

make sure you've set that up correctly

#

oh

#

you didn't install the sdk did you

naive pawn
winged seal
#

so theese right

#

i checked the entire page

naive pawn
#

no, praetor linked the wrong thing

naive pawn
winged seal
#

alright

naive pawn
winged seal
#

where do i get the sdk tho?

naive pawn
#

it's linked below the template

winged seal
#

this here?

naive pawn
winged seal
#

k downloaded it

#

also in unity

#

this here popped up

naive pawn
#

no don't download it

#

install it via package manager

#

like we've said before

winged seal
#

wait i cant find its name to download it via package manager

naive pawn
#

make sure you're on the "my assets" tab and that youve added to your assets from the store

winged seal
#

ight

#

why cant we just download it tho

naive pawn
#

this lets it be managed properly

winged seal
#

The video is an intro for the Alteruna Multiplayer development package (SDK) at Unity Asset Store. It bridges the gap between the complexity of real time network programming and the artistry of creators in all disciplines.
It is network development for the Unity creators: Easy setup, creation and use with no network coding required! Just drag an...

▶ Play video
near wadi
#

Is anyone using Rider (personal) fully offline? the wording in their EULA always gives me pause. I am wondering if it works indefinitely, offline

winged seal
#

k i downloaded it

#

it runs

steep rose
#

I could be remembering it wrong though

near wadi
# steep rose ~~Why wouldn't Rider work offline, that seems unnecessary~~ Actually I remember ...

well, that is the problem. the EULA is worded in such a way as to not make clear sense. it Seems that you can use it offline, but maybe you have to connect for license verification.
and they will do telemetry, but not too much, unless they think they need to, and then you can turn it off, but not really. etc..

Yeah, there have been conversations about it, so you are probably recalling correctly. they have changed the EULA a bit since i refused it last time. it used to not work if you took it offline. that seems to Not be the case anymore, but it works differently for personal vs paid, etc. So, i was hoping someone using personal, who has kept it offline, can tell me that it is working ok

steep rose
near wadi
#

Yeah, that one is not terrible, but annoying. let me see if i can find what i was looking at exactly

steep rose
#

So you have to generate an offline code to use it offline then you have to generate a new one periodically, so I guess that means you have to come online but then go back offline kekwait

#

why even allow offline use then lmao

near wadi
#

indeed. strange way to do it., but not too terrible. they gotta track ya somewhow! 😛

steep rose
#

"you can be offline for approximately 2 minutes before you have to come back online to generate a new code to be offline again"

near wadi
#

They have expanded and revised since the last time i read it, and did not agree with it, so that is good. I still wish the data was not held under Czech jurisdiction though. this is a personal thing. not trying to start a political conversation. here is a link the the privacy notice https://www.jetbrains.com/legal/docs/privacy/privacy/

#

but, in the end, i am just trying to verify from someone who is doing it, that there is not an issue with it, if say, user is in a location without internet for extended periods. Doesn't seem to be a huge issue anymore, but hoping for verification. long ago, it was Supposed to work offline, but did not for me. that is the root of this question

steep rose
#

or is it a preference thing

teal viper
eternal falconBOT
near wadi
#

@steep rose
yeah, no problem there. I would like to utilize the advanced features that Rider has though, so collecting information (in case i end up stuck in Oregon without Internet again :D)

steep rose
#

ah okay 👍 what kind of info would you collect?

#

like business things?

near wadi
#

just the original question "Does it work indefinitely without internet" just trying to collect That information 🙂

steep rose
#

ah okay, cool 😅

steady sentinel
#

How do i adjust main camera size? I'm trying to make the main menu to a game but I just dont know how to do it

slender nymph
#

2d camera you just change the orthographic size. 3d camera is FOV, both are also affected by the resolution of the game. set your Game View to the desired resolution

naive pawn
#

not sure how that's related to making a main menu though?

slender nymph
#

but also main menu is typically UI, so check the messages pinned in #📲┃ui-ux to learn how to anchor and scale the UI based on the game's resolution

steady sentinel
#

Thanks

slender nymph
#

read very carefully through the properties in that screenshot

steady sentinel
slender nymph
#

no, it is literally called Size

steady sentinel
#

How do i delete palettes?

slender nymph
#

If you mean a tile palette it's just an asset in your assets folder, delete that

steady sentinel
#

when i add in other sprites like trees it always deletes the preexisting tile how do i stop that also when i place sprites into the tile palette it appears like this

spare mountain
long niche
#

Anyone know if there’s like a “main way” to resolve complier errors becuase i am so clueless

spare mountain
#

what does that even mean

#

read the error and address it

long niche
#

Like code wise becuase I physically and mentally have no clue how to code

tiny wind
#

Ok so I finally configured my editor, and I think the problem I have is that I have 3 unused private members

#

what do I do for that?

naive pawn
tiny wind
#

ohh ight

naive pawn
long niche
#

I mean I can try that

tiny wind
naive pawn
#

then make them do that thing they're supposed to do

unreal snow
#

Am i doing something wrong? Why is the asset not moving?

teal viper
teal viper
steady sentinel
#

is there a manual i can read for c# to know whatever statement or action i write does?

unreal snow
teal viper
charred spoke
tiny wind
#

Ok so I just realised that the axis that my player was moving was the wrong one, but the character is still stuck in place

#

atleast now the speed is correct

echo kite
#
    void DetermineRotation()
    {
        Vector2 mouseAxis = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
        mouseAxis *= mouseSensitivity;
        _currentRotation += mouseAxis;
        _currentRotation.y = Mathf.Clamp(_currentRotation.y, -90, 90);
        transform.root.localRotation = Quaternion.AngleAxis(_currentRotation.x, Vector3.up);
        transform.parent.localRotation = Quaternion.AngleAxis(-_currentRotation.y, Vector3.right);
    }

why cant i look left and right? i can look up and down

#

no errors too

tiny wind
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

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

west radish
#

!vsc

#

heh

tiny wind
west radish
#
void Update() {

  player.velocity = 0f;
  player.velocity += 1f;

}```sounds silly, but there's not a chance that the code might be doing something similar to this, is there? like at the start of every frame the velocity you added last frame, is erased
#

ah, I just looked further up adn you posted code before

tiny wind
#

!code

eternal falconBOT
west radish
#
private void Update()
{
  Debug.Log($"A: {body.velocity}");
  
  float horizontalInput...
  body.velocity = ...
  
  Debug.Log($"B: {body.velocity}");```could you put those debug.logs into the start of the update?
tiny wind
#

alright

burnt vapor
#

I'm confused

#

I told you to log it yesterday, how come we are a day later and this information still hasn't been shared?

#

It has been mentioned 3 times

#

Is this the result?

tiny wind
tiny wind
visual cedar
#

guys i am trying to follow up a tutorial and i cant make see a new project option so i just cloned my new repo now i want to create a solution file and and a folder with a project,it used to do that in vscode but i dont know it doesnt in my

#

like this

west radish
#

at some point one of those should have a value you dont expect, likely the place that resets momentum

tiny wind
#

ight, thanks for thye help

olive galleon
#

How would I implement an attackCoolDown function for when an enemy damages the player? Here is my code:

whole cliff
#

can any1 help me make a collision script

#

i always get errors when following tutorials

ivory bobcat
night raptor
whole cliff
#

||using JetBrains.Annotations; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; public class triggerscript : MonoBehaviour { // Start is called before the first frame update void Start() { Public } public void OnTriggerEnter(Collision info) { if(info.gameObject.tag == finish) } // Update is called once per frame void Update() { } }||

#

wait how do i show yall my scripy

eternal falconBOT
whole cliff
ivory bobcat
night raptor
# whole cliff

I highly doubt the tutorial code looked exactly like that

whole cliff
#

yeah but they made the trigger a enemy and i couldnt do that

#

it was pretty old

#

this is the tutorial

night raptor
# whole cliff

”Enemy” is a string literal as a tag should be. finish is a variable, constant or something else that doesn’t exist.

whole cliff
#

okay ill try to fix it

night raptor
#

Hint ||the double quotation mark might be of importance||

whole cliff
#

i just made it wayyyyyy worse...

night raptor
#

How so?

burnt vapor
# whole cliff

If this is the way you write c# then I strongly suggest you start with some basic C# lessons before doing anything Unity related

#

Check the pinned messages for beginner C# courses

#

Instead of combining learning C# with Unity, start with just C#. Unity is a whole 'nother thing by itself and you will not have a fun time if you have to learn them both at once, and likely waste even more time in the process compared to just doing these seperately

severe onyx
#

I have issues with changes to SOs not being properly tracked by git, is this a known issue or maybe something I messed up in my settings/gitignore? unsure what the right channel for this is but yeah. whenever I pull from my master branch certain values of them are just empty afterwards, and when I change only those values and try to commit them it tells me that there's nothing to commit

fickle plume
#

That should not be happening. Make sure you are not selectively ignoring .meta files.

north kiln
#

Also make sure you hit Save Project before committing

fickle plume
#

Other possibility is if you are setting values from code and not updating undo system

severe onyx
#

I have run into issues with accidentally overwriting values in other places for sure lol

severe onyx
#

could this be the cause?

north kiln
strong wren
#

Are you hitting Save Project before committing?

severe onyx
# strong wren Are you hitting Save Project before committing?

just tried doing that, here's the result

warning: LF will be replaced by CRLF in Assets/ScriptableObjects/LevelData/Level1/Rewards/Pool1Early.asset.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Assets/ScriptableObjects/LevelData/Level1/Rewards/Pool1Normal.asset.
The file will have its original line endings in your working directory

$ git commit -m "trying to push SO data"
On branch master
nothing to commit, working tree clean
#

so when I run git add it recognises something changed but when trying to commit it doesnt anymore idk

severe onyx
tiny wind
#

hey, im wondering, what do the colors mean? because the tutorial im following said to make sure that "OnCollisionEnter2d" was blue, but it isnt blue in mine

prisma ivy
hot laurel
fickle plume
#

You can mouse over as well it will tell you the reason

tiny wind
#

its saying its unused, i dont think its meant to be unused, but idk how to fix it

prisma ivy
naive pawn
#

but assuming default themes; methods are yellow in the default

naive pawn
hot laurel
obsidian plaza
obsidian plaza
#

the whole function is unused?

#

didnt know that was a thing it said

tiny wind
obsidian plaza
#

the ide just sees 0 references and figures its never being referenced u mean

fickle plume
#

Just have to make sure that plugin is up to date.

naive pawn
#

types, members, variables

obsidian plaza
#

didnt know that ive only seen variables

tiny wind
fickle plume
#

Also like I've mentioned, if it's VS Code, it struggles with supporting those, might just have to ignore. Still make sure everything up to date

burnt vapor
#

You can also change the severity, or assume all warnings are errors. Up to you

steady sentinel
#

what does this mean?

naive pawn
#

did you read the error message?

#

and did you check where it's coming from

obsidian plaza
steady sentinel
#

no im just starting out and i want to know what it means

naive pawn
#

is that function call in your own code?

hot laurel
naive pawn
#

it can "mean" a few things depending on where it's from

steady sentinel
naive pawn
#

if it's from something internal, you messed up config or something is corrupt

burnt vapor
naive pawn
severe onyx
naive pawn
#

read the stacktrace

naive pawn
severe onyx
#

git bash

rancid badger
#

hi guys, can anyone help me to figure out how to implement a slower loading between scenes?
the following code works fine but it is too fast

using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.SceneManagement;
using System.Collections;

public class RetryLevel : MonoBehaviour
{
    [SerializeField] private GameObject loadingPanel;
    [SerializeField] private Slider progressSlider;
    [SerializeField] private TMP_Text percentageText;
    [SerializeField] private GameObject GameOverPanel;

    public void StartReload()
    {
        GameOverPanel.SetActive(false);
        loadingPanel.SetActive(true);
        StartCoroutine(LoadSceneAsync());
    }

    private IEnumerator LoadSceneAsync()
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);

        while (!operation.isDone)
        {
            float progress = Mathf.Clamp01(operation.progress / 0.9f);
            progressSlider.value = progress;
            percentageText.text = $"{progress * 100:0}%";
            yield return null;
        }
    }
}

but whenever i try to introduce a delay or a fake loading progress the loading panel stays stuck at 0%

naive pawn
#

ah, ok. cool

naive pawn
tiny wind
obsidian plaza
#

through unity? idk how it works if u dont tbh

naive pawn
#

it should work fine provided you follow the appropriate !ide setup steps

eternal falconBOT
fickle plume
#

VS actually had some problems supporting Unity 6

tiny wind
#

wait, whats the difference between VS Community, Enterprise and the other one?

fickle plume
#

But I thought they were fixed recently

steady sentinel
rancid badger
# naive pawn how did you introduce that delay, exactly?

for example like this as suggested by gpt

private IEnumerator LoadSceneAsync()
{
    AsyncOperation operation = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
    operation.allowSceneActivation = false; // Prevent immediate scene switch
    float fakeProgress = 0f;
    
    // Initial delay
    yield return new WaitForSeconds(2f);

    while (fakeProgress < 1f)
    {
        fakeProgress += 0.005f;
        progressSlider.value = fakeProgress;
        percentageText.text = $"{fakeProgress * 100:0}%";
        yield return new WaitForSeconds(0.05f);
    }

    operation.allowSceneActivation = true; // Allow scene switch
    yield return operation;
}
naive pawn
fickle plume
tiny wind
#

ah, alright

naive pawn
hot laurel
naive pawn
steady sentinel
steady sentinel
hot laurel
steady sentinel
naive pawn
naive pawn
tiny wind
#

apparently i didnt see the installation steps

steady sentinel
rancid badger
steady sentinel
#

but i found smth in the code thats hightlighted in orange

fickle plume
#

@tiny wind So currently at least VS 2022 Unity methods support is just fine for Unity 6. So you must have something missing in yours. Go over the IDE install guide that was linked.

teal viper
naive pawn
#

for example of what dlich said, like this:

steady sentinel
#

these notifications keep popping up

tiny wind
naive pawn
steady sentinel
fickle plume
steady sentinel
#

which one do i download

naive pawn
#

just screenshot the console, please...

naive pawn
steady sentinel
naive pawn
#

those are very different environments

#

so something's messed up internally

#

does the error appear after restarting the editor

steady sentinel
#

gimme a sec

steady sentinel
naive pawn
#

latest version of what?

steady sentinel
steady sentinel
naive pawn
#

and this is on startup, right? not when pressing play?

naive pawn
#

ive only found threads about it happening in playmode...

steady sentinel
#

oh (cooked)

#

oh the red message disappeared its only the yellow one now

hot laurel
#

so it fixed itself

steady sentinel
#

nvm i just restarted again and the red message appeared again

naive pawn
#

try closing all your vs and unity processes and trying again?

naive pawn
steady sentinel
naive pawn
#

try #💻┃unity-talk, this definitely isn't a code question, maybe you'll get better answers there

hot laurel
#

i would close project, remove Library folder and then open project to let unity reimport all assets/packs

echo kite
steady sentinel
#

this is the start of the problems im going to come across 😭

#

and i havent even started coding which sucks

hot laurel
# steady sentinel it disappeared ty

seems like something got corrupted during importing then, if something not related to your code generating errors and they persist, then just repeat what i wrote before

steady sentinel
#

oke

echo kite
static cedar
#

Fiddled with Unity's RectTransform, finally understood how they work.

#

Had a vague idea for a while but had to make my own layout.

tiny vault
#

Hey, anyone have any idea why my button's " area of effect" is much larger than the button ? if i click either of the four buttons closest to the submit button, it still registers as if i pressed submit. I'm new to this, so maybe it's obvious, but i couldnt find any answers through google

willow shoal
#

Hi . my player is not teleporting : / why? ```cs
public GameObject gameObject;

public Transform start;
public void OnTriggerStay(Collider collider)
{
if (collider.gameObject.tag == "wood1ded")
{
gameObject.transform.position = start.transform.position;
}
}```

#

player in inspector to "gameObject" and my point "start"

swift elbow
swift elbow
willow shoal
#

okey

tiny vault
naive pawn
echo kite
naive pawn
#

also should probably be OnTriggerEnter

swift elbow
cold elbow
#

I made this method to get the top most and bottom most of a box collider 2d but it doesn't really work as intended can anyone spot any issue

private float _getTopMostOrBotMost(Side side, bool isTopMost) {
        var boxColliderPaddle = side == Side.Right ? _cachedRightCollider : _cachedLeftCollider;

        var center = boxColliderPaddle.bounds.center;
        var size = boxColliderPaddle.size;
        
        return isTopMost ? center.y + size.y / 2 : center.y - size.y / 2;
    }
swift elbow
tiny vault
torn dome
#

What is the diffrence ?

wintry quarry
torn dome
#

this two pixel art sprites

cold elbow
torn dome
#

one that work and the other doesn't

wintry quarry
cold elbow
#

@wintry quarry does it also work for 2d?

wintry quarry
#

I'm not even sure how you even got an asset that is just a sprite

wintry quarry
cold elbow
#

so I can just downcast it to vector2

torn dome
wintry quarry
#

You don't change it into a sprite

#

You get it to generate a sprite asset

#

And use that wherever you need it

torn dome
#

You are a hero

#

Sorry another question

#

how to add the other tow textures to the sprite

wintry quarry
#

Not sure what you mean by that

#

A single sprite can only come from a single texture

torn dome
#

somethig like that

wintry quarry
#

That's multiple sprites from one texture

tiny wind
#

anyone know where this could possibly be?

wintry quarry
#

You need to install the sprite package like it's saying here in order to use the sprite editor

torn dome
#

ok i will do download it

wintry quarry
#

In the visual studio install directory

tiny wind
#

the installer?

wintry quarry
#

No, the directory where visual studio is installed on your PC

tiny wind
#

ohh, ight

torn dome
#

I don't konnw what iam doing 🙂

wintry quarry
rocky canyon
#

make sure u sprite is set to Single

wintry quarry
#

So I don't understand why you're trying to slice it

torn dome
#

ohhhhhhhhhhhhhhhhhh i understand now

#

i have to draw the three sprites in one canva

rocky canyon
#

what ur doing right now would be this ^

#

which i doubt is what u want

wintry quarry
#

That's 9 slicing

torn dome
#

Hmmm it worked but it's not pixelated

naive pawn
torn dome
leaden pasture
#

On your image import settings. They should be roughly a bit more rhan halfway down the inspector when you click your image in your project browser iirc

naive pawn
torn dome
#

Bro english is not my mother language

naive pawn
#

click the texture and set those values in the inspector

torn dome
naive pawn
torn dome
#

sorry

naive pawn
torn dome
#

yah it worked

#

thx

willow shoal
#

@naive pawn my player stuck in one position. i need after touch a block teleport to my position then move still on map but player is stuck. ```cs
public Transform target;

public void OnTriggerStay(Collider other)
{
if (other.CompareTag("Player"))
{
other.transform.position = target.position;
}
}

#

can u help me?

naive pawn
#

please don't ping specific people for help

#

what is the context here

willow shoal
#

okey

naive pawn
#

is this still the loadzone thing

#

use OnTriggerEnter to make it activate when you first touch the collider

willow shoal
#

sorry i used stay

#

i change

naive pawn
#

and what's the issue here exactly?

willow shoal
#

if i use ontriggerenter my player move one time

#

for my position

#

i need every time

naive pawn
#

is your entire level a loadzone?

tiny wind
#

help, I tried to reconfigure my IDE, but now thinngs like hovering my mouse over code and autocmplete are not there

naive pawn
#

did you follow the instructions as per the bot message

willow shoal
#

what loadzone meen?

naive pawn
#

the trigger you're using to make the player go back to the start

naive pawn
#

it sounds like it's covering the start position, too

naive pawn
tiny wind
#

nvm its fixed now

willow shoal
#

yes i doing somethink like this. i need teleport for same postion every time on trigger

tiny wind
#

i was on the wrong IDE

#

unfortunately, none of what ive done for the past few hours fixed my first problem

#

character still wont move

naive pawn
#

can't really help without info

#

if you've posted about it before, link or reply back to it

tiny wind
#

this

tiny wind
naive pawn
#

what's your code

tiny wind
#

!code

eternal falconBOT
tiny wind
#
using UnityEngine;
 
public class PlayerMove : MonoBehaviour
{
    [SerializeField] private float speed;
    private Rigidbody2D body;
    private Animator anim;
    private bool grounded;
    
    private void Awake()
    {   
        //Grabs references for rigidbody and animator from game object.
        body = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
    }
 
    private void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal");
        body.linearVelocity = new Vector2(horizontalInput * speed, body.linearVelocity.y);
        
        //Flip player when facing left/right.
        if (horizontalInput > 0.01f)
            transform.localScale = Vector3.one;

        else if (horizontalInput < -0.01f)
            transform.localScale = new Vector3(-1, 1, 1);
 
        if (Input.GetKey(KeyCode.Space) && grounded)
            Jump();
         
        //sets animation parameters
        anim.SetBool("RUN", horizontalInput != 0);
        anim.SetBool("GROUNDED", grounded);
    }
 
    private void Jump()
    {
        body.linearVelocity = new Vector2(body.linearVelocity.x, speed);
        anim.SetTrigger("jump");
        grounded = false;
    }
 
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ground")
            grounded = true;
    }
}
wintry quarry
naive pawn
#

wow i have... no idea what to make of that, tbh
make sure you've saved and recompiled

#

make sure the animationclip isn't setting anything it shouldn't

wintry quarry
#

see if that fixes the movement

tiny wind
#

oh, it does

tiny wind
#

im moving again

wintry quarry
#

yep you've made the classic animator pitfall of animating the root object

tiny wind
#

what

wintry quarry
#

best practice is to put your visual elements (sprites, renderers, etc) on child objects and have the animator only animate those

#

otherwise the animator is controlling the position of the root object

#

meaning it won't be able to move

#

other than how the animator decides to move it

naive pawn
#

oh god it just does that?

#

even if that's not set?

tiny wind
#

ah, mustve not seen that in the tutorial

wintry quarry
#

You can try checking "root motion" which is a quick fix sometimes but I think it's not best practice

tiny wind
#

thank uu

echo kite
wintry quarry
# echo kite

becasue you're setting the localRotation of the same object twice

#

and the second call overwrites the first

#

presumably transform.root and transform.parent are the same

wintry quarry
#

pretty sure you just meant to write transform.localRotation for the first one, not transform.root.localRotation

#

i don't know why you have .root there it doesn't make much sense

#

although actually... now that I think about it, several parts of this are weird

#

Which object is this script attached to?

wintry quarry
echo kite
#

its attached to that

wintry quarry
#

this appears to be a first person controller

#

why would it be attached to a weapon

echo kite
wintry quarry
#

This script does not belong on the ak47

echo kite
#

thats why it says transform.parent.localrotation

echo kite
#

so i cant move it

wintry quarry