#💻┃code-beginner

1 messages · Page 791 of 1

brazen aurora
#

because im looping the music

frail hawk
#

you can use PlayOneShot

#

audio clip wont be interrupted

brazen aurora
#

i fixed it, i was calling play in update so it was executing every frame

brazen aurora
naive pawn
somber ivy
#

hello 👋 I have got a question how could i make a similar character like a xenomorph in a game called Broforce. I was just wondering how can it crawl on a wall and ceilings?

#

could someone please explain?

somber ivy
#

I was thinking about overriding linearVelocity instead of using Rigidbody gravity to get more control. Or is there a better/standard way to handle wall/ceiling crawling in Broforce?😭

grand snow
#

Gravity is just some force thats always applied so you can disable gravity for a RB and apply your own force

grand snow
# somber ivy may i ask you how?

rigidbodies have an option for using gravity. You can then just apply your own force in the direction you want each Fixed Update.
Gravity on earth is -9.18 meters a second and is what unity has configured by default too.
If you know the normal of a surface you know the direction to apply force (the opposite)

#

To allow movement it will require extra steps to correctly do this for the new "plane" however

#

You can also choose to disable gravity and just let the user move on that plane only to better control the results

somber ivy
#

aight

#

i see

#

thank you so much for you time

wraith moon
#

https://pastebin.com/vCd1UA3r
https://pastebin.com/mjqBWbAt
https://pastebin.com/tvnyMxU9
whenever i switch to another slot the visible selection doesnt dynamically change, does anyone know why?

balmy vortex
#

can I actually just swap the OnMouseEnter & OnMouseOver functions with their pointer counterparts or do I actually have to do smth else too?

#

sry for the late message btw

frail hawk
#

you just have to use a pyhsics raycaster and implement the Interfaces of desire

balmy vortex
#

wdym?

frail hawk
#

in your script you implement the interfaces ipointer you like

#

for example if you wanted the clickhandler

#

in your case it would be IPointerEnterHandler

hot wadi
#

U simply inherit the interface and implement its callbacks

frail hawk
#

in the docs i sent you can see all the interfaces you want to use (on ther left)

balmy vortex
#

is there no OnMouseOver function for the ipointer?

frail hawk
#

OnMouseOver would be IPointerEnterHandler

#

YourScript : MonoBehaviour , IPointerEnterHandler

hot wadi
#

Wrong order

wraith moon
#

even if its no longer selected

balmy vortex
frail hawk
#

you did not implement the callback correctly

#
  public void OnPointerEnter(PointerEventData pointerEventData)
    {
       your code here
    }
grand snow
#

Implement the interface for each event you want and use the function for each interface

#

It shouldn't be possible to do this wrong because you are forced to implement the functions

frail hawk
#

and VS does the job actually

#

if you click on the small arrow when it misses the callback

grand snow
#

Whatever ide you use will and it will cause a compile error too

frail hawk
#

true

potent hornet
#

Is there a reason why Unity VSCode sometimes randomly adds in imports I'm not using, and also is there a way to stop that because it's annoying

rich adder
#

Unity VSCode ?

potent hornet
#

I meant just VSCode

#

Mb

#

But I use it for Unity

rich adder
#

normally if you click the class in intellisense thats when namespace gets added

grand snow
#

You probably auto completed some type so the using statement was added for you

rich adder
#

never had vsc add namespaces on its own

balmy vortex
#

wat is the equivelant to OnMouseOver for this btw?

rich adder
balmy vortex
rich adder
potent hornet
rich adder
#

you use those and create your own

potent hornet
#

Which I'm not making anything to use this

#

and I scrolled up and it's grayed out so I know I wasn't using it

balmy vortex
#

thanks king

grand snow
#

Pointer enter and pointer exit need to be used. If you want to do things while the pointer is over the object you need to track the state and use Update/FixedUpdate @balmy vortex

potent hornet
#

And other times it'll be random

frail hawk
potent hornet
#

Yeah I've just been removing them, I'll just do it at the very end or whenever it gives me build issues

frail hawk
#

sound like a nice plan

rich adder
#

its probably tucked somewhere in the preferences in c#

red igloo
frail hawk
rich adder
frail hawk
#

first time i see that in a game

wraith moon
#

https://pastebin.com/vCd1UA3r
https://pastebin.com/mjqBWbAt
https://pastebin.com/tvnyMxU9
whenever i start the game it starts off correct selecting the initial slot but when changing slots nothing happens and the first slot stays highlighted

#

does anyone know what im doing wrong

red igloo
red igloo
rich adder
red igloo
#

these?

rich adder
#

I just use the built in Cinemachine noise and create sways there

red igloo
warm iris
#

What is a good way to learn unity? Does anyone recommend any tutorials? ( I know coding and making games, I'm just new to unity), I'm looking for somethign that won't take long but will say everything that I need, and I won't be just copying the code but actually practicing

signal spruce
radiant voidBOT
prime goblet
#

you don’t have to do all of it

iron cobalt
#

Hey!
Could anyone point me towards best practice/resources for level up mechanics?
What I wanna do:
Player collects specific item -> Level Up, set of stats changes, but to specific stats, not math

Im not sure if I should just overwrite stuff like movementSpeed in my playerscript etc.

Thanks :)!

cosmic dagger
iron cobalt
grand snow
iron cobalt
grand snow
#

Then you dynamically look up in some data structure the correct stats based on player level

iron cobalt
warm iris
#

why is there no C# script

#

ok I found it but why is it so hidden

#

All tutorials have this option immediately

#

nvm this does not work

teal viper
warm iris
teal viper
#

I mean different to the one in the tutorial

warm iris
#

ok, how to add a script in this version

ivory bobcat
#

It's in your image

warm iris
#

its open C# project

#

not script

teal viper
ivory bobcat
#

Create > Scripting > ...

warm iris
teal viper
#

MonoBehaviour is just a class.

#

I usually create scripts via the ide anyway. I don't remember the last time I created it via the editor.

teal viper
warm iris
#

ive got it cuz I created empty script earlier

#

but thats stupid why not keep creating the script as in earlier versions

teal viper
#

Got where??

warm iris
#

now its more clicking

warm iris
teal viper
warm iris
#

I fixed it

sour fulcrum
warm iris
#

how to fix that

sour fulcrum
#

have you googled that

warm iris
#

no

sour fulcrum
#

well

edgy sinew
# warm iris how to fix that

My advice, use the "Generate C# class" feature, put it somewhere nice in your Scripts folder like an "Input" sub-folder
Manually subscribe to (on Awake is the way AFAIK), or even interpret and store in variables, all the stuff you need up-front

For example I like to just have one "InputReader.cs" component (script),
And in there I have variables like Gamepad Left Stick X (float), Gamepad Right Trigger Held (boolean), etc
And wherever I need them I can just grab a reference to that InputReader instance.
Could be on a Singleton if that's how you roll

sour fulcrum
#

it's not neccasarily bad advice but i don't think that's what their problem is here

edgy sinew
mental terrace
#

Completely new to Unity so excuse my ignorance, I'm creating a game similar to Terraria for a school project, what would be the best approach to creating a weapon system? Like would I have stuff like weapon aiming, shooting and swapping on the same script or all on different scripts? As for creating the weapons I'm planning to use 4 different scriptable objects (melee, ranged, mage, summoner) to create instances of each weapon, is this a good approach?

untold shore
#

Hey - I apologize, but I still need some help regarding this. Could someone please look at this for m?

edgy sinew
#

It just sounds like a timing issue. Are you 100% sure things are happening in the order you intended?
You can use Debug.Log to confirm

edgy sinew
untold shore
#

I’m not, so I’ll check that asap

edgy sinew
#

And weapon slots, in other words attached to the character places where the weapons can be equipped.
That would connect to the inventory surely

sour fulcrum
mental terrace
sour fulcrum
#

what do you mean by that

edgy sinew
#

Inheritance is more like "melee, ranged, mage, summoner" are all a "Weapon" type.

solar hill
#

Also im confused as to why you would need 4 scriptable objects for the weapons? In Terraria the weapons are mostly divided into
Melee and Projectiles

sour fulcrum
#

Tbh I wouldn't do that, I meant more on a case by case weapon basis

edgy sinew
#

Or depending on your architecture they can just implement some "IWeapon" interface that requires certain methods like fire, reload, etc
Likely need some kind of "IEquippable" interface too, maybe if you can equip other kinds of items too.

mental terrace
# sour fulcrum what do you mean by that

I mean am I right in saying that's the whole concept of inheritance? Like for example I would create a base weapon script with core stats such as damage, knockback, crit rate etc. and then each of the 4 weapon types will inherit these attributes and then have their own seperate niches.

sour fulcrum
naive pawn
#

and melee things that do both

edgy sinew
#

It's diagram time UnityChanThumbsUp

naive pawn
#

venn diagram lmao

mental terrace
#

I'd have melee as strictly true melee

sour fulcrum
sour fulcrum
queen adder
#

may someone help me, my unity wont start up, it says

Shader compiler initialization error: Failed to launch UnityShaderCompiler.exe shader compiler! C:/Program Files/Unity/Hub/Editor/6000.3.0f1/Editor/Data/Tools/UnityShaderCompiler.exe

solar hill
#

Youre on the right track but your classes need more abstraction

queen adder
#

huh

#

i just started unity and learning cs

solar hill
#

I was talking to the other individual.

sour fulcrum
#

And yeah as kuzmo said earlier there's no reason for you to have 4 seperate scriptableobject types for your class types, the class types don't mean much code wise, personally i'd probably have a scriptableobject that defines the name of the damage type, icon etc. like ScriptableClass and have your items have a serialized field for it so you just put in the type it is

mental terrace
#

Apologies btw I'm like completely new to Unity

sour fulcrum
#

correct yeah, on potentially a per weapon basis or some middle ground between that (eg. maybe 1 inheriting script for all gem staves)

solar hill
#

Honestly you should probably have a base class that is defined as just a usable item

edgy sinew
#

or "Equippable"
which could be under "Lootable"

sour fulcrum
#

equippables in the context of terraria would be a different thing

queen adder
#

🌺 Python error
🖥️ 🔥 C error

naive pawn
#

"Useable" which would comprise "Weapon" and "Consumable" and "Block"

solar hill
#

Yeah but they all share properties

sour fulcrum
#

I mean just Item is fine

naive pawn
#

goddamnit, tip of my tongue lmao

solar hill
#

Honestly idk why i couldnt think of it either

#

Usable made more sense for some reason

#

Lol

naive pawn
#

i thought of consumable first and worked backwards to usable

edgy sinew
#

What about a trap door that u can press E to open / close...
Interactable

sour fulcrum
#

those aren't items

#

whole different type of content and programming

solar hill
#

Yep

edgy sinew
#

so we got
Interactable (can be interacted with)
Lootable (can be looted into inventory)
Equippable (can be equipped)
Place-able (traps, blocks?)

solar hill
#

What you have in your inventory and what is placed in the world are not the same

sour fulcrum
#

Lootable is not a thing that needs to be defined

naive pawn
#

town npcs and trapdoors/doors might be handled in similar ways in terraria actually, they have a very similar UX

sour fulcrum
#

interactable is all of them

edgy sinew
sour fulcrum
#

equippable is just a bool and flavour text esque

edgy sinew
#

so you can just differentiate with a Boolean or something

naive pawn
#

equippables aren't interactables

#

well... you'd need to define what "Interactable" comprises

#

to me, that sounds like only stuff in the world

edgy sinew
#

Well you have to interact with an equippable or lootable item to loot it ...
Or is that not the same lol 🤷‍♂️

solar hill
#

Thats something else

sour fulcrum
#

With full respect i don't know if much of what your saying is helpful for the initial question

naive pawn
#

then everything is an interactable

edgy sinew
#

Both need to show some "press E to interact" or "press E to loot" no? Same detection behaviour

solar hill
#

No

#

Theres no press e to loot

shell sorrel
#

the same object to the player muight be many objects to the game

naive pawn
edgy sinew
#

Idk in a lot of games you press E to open a "nearby" door, same way you press E to loot a "nearby" item.
But okay guys.

shell sorrel
#

like a fishing rod on the ground might be intractable, but interacting with ti just removes it and adds a item to inventory

naive pawn
sour fulcrum
solar hill
#

Also in terraria interactions happen through left clicking

naive pawn
#

i don't know what the original question here was

sour fulcrum
naive pawn
#

oh cool, ontopic then (somehow)

edgy sinew
#

Person didn't make it clear they're making a 1-for-1 clone. But okay.
I'm just here to provide options alright.

mental terrace
naive pawn
#

i just saw "melee, ranger, mage, summoner" above and went straight to terraria

sour fulcrum
solar hill
sour fulcrum
solar hill
#

Or melee and summon (whips)

mental terrace
naive pawn
#

or mage and summon (uses mana)

mental terrace
naive pawn
#

whips are also summoner class in terraria

solar hill
#

Still just an item with OnLeftClick function

mental terrace
solar hill
#

That does something

sour fulcrum
#

summon staff use, melee use, placing tile, using potion etc. all derive from a base OnPrimaryUse / OnLeftClick etc. etc. behaviour

mental terrace
#

yeah I see how they all the same now 😭

solar hill
#

This is why abstraction is important

#

Its good youre noticing it

true pasture
#

Can i make this world space UI element appear in front a 3d object in the scene? Layers don't seem to work.

mental terrace
#

So in general is there no point having separate weapon type classes? The weapon type would effectively just be flavour text? (apart from type specific damage)

I'd also like to ask what's the best way to create weapons? Like would I create a different prefab for every single weapon? Or just have the assets with the base stats, and then haved the behaviours as a bunch of modules

sour fulcrum
#
  1. Mostly yeah, there's some stuff that will come up when you calculate damage where you need to see "what" type it is but for the most part it's just a association

  2. no one answer but probably a prefab for every weapon yeah, at least for someone starting out

solar hill
#

Prefab per weapon is a sound approach

edgy sinew
mental terrace
sour fulcrum
#

as a freebie example for the inheritance talk, here's how you might approach handling potions.

green are virtual functions and blue are overriding functions

#

you can see how you could set up base functionality and have layers of inheriting classes extend ontop of it as needed

rich adder
mental terrace
naive pawn
sour fulcrum
#

yup

#

thats what i get for waking up at 3am

mental terrace
#

don't worry I gathered 😂

rich adder
#

how's this a unity code beginner question ?

sweet meadow
#

damn wrong server 😅

cosmic dagger
#

stats for what?

sweet meadow
#

srry

#

D&D

#

wrong server

rich adder
edgy sinew
rich adder
edgy sinew
#

Would there still be a way for certain objects like walls to occlude the object?

rich adder
#

I think so cause you're playing with depth

#

before normally you would do this via shader code / render queue, this simplifies everything a bit

tall halo
#

Quien a creado juegos poderosos

rich adder
devout sluice
#

first time using unity
can anyone tell me why is the movement jittery?

wicked cairn
# devout sluice first time using unity can anyone tell me why is the movement jittery?
rb.linearVelocityX = Movespeed.x * speed * Time.deltaTime;
rb.linearVelocityY = jumpheight * Time.deltaTime;
```Move this to FixedUpdate, because it has to do with physics it shouldnt go in Update(). If one player has 10fps then the physics will calculate 10 times, but for another player with 60fps theyll get 60 physics updates. FixedUpdate will keep that consistant regardless
#

On your rigidbody settings, set Interpolation to Interpolate

#

there may be more reasons contributing, hopefully someone else can respond with more

keen dew
#

Don't multiply velocity by deltatime. Having it in Update is fine

devout sluice
#

Thanks
I'll try that

rocky whale
#

when I run the game the particles appear like on the left but when I just play the particles its like the right. why dont they spread like on the right ? The particles r played when the ship is moving btw

grave frost
#

Is there a way to tell if a scene is loaded OR currently loading? gameObject.scene.isLoaded is false in Awake.

keen dew
#

All Awakes run when the scene is already loaded. You have to load the scene async if you want to track the progress

grave frost
#

nah scene.isLoaded says it's true only after the objects have been enabled and awake runs before the objects have been enabled when loading a scene

keen dew
#

What do you need this for? If Awake runs then you already know what stage the loading is in

grave frost
#

Well the issue is I have some code that's not in a monobehaviour that checks some stuff with a scene struct but the scene struct doesn't say it's loaded in Awake when i call that code

keen dew
#

Then do it in OnEnable

grave frost
#

nah I can't it's false in OnEnable too, it's only true after OnEnable is called

keen dew
#

Run Start as a coroutine and delay it one frame

grave frost
#

Its true in start but its nice having the seperation of awake and start yk

#

yea i usually keep awake for "me" telling "others" about me and start for "others" asking about "me" if that makes sense

keen dew
#

But if you can't run the code on the frame when Awake runs then you can't really use it then

grave frost
#

yea. this monstrosity works tho but i gotta find a diff way eventually

//TODO: fix this workaround
public static bool IsSceneLoadedOrLoading(Scene scene)
{
  try
  {
    var gameObject = new GameObject();
    SceneManager.MoveGameObjectToScene(gameObject, scene);
    UnityEngine.Object.Destroy(gameObject);
    return true;
  }
  catch
  {
    return false;
  }
}
#

why would they make the scene api that wack

teal viper
#

Probably because you shouldn't really need to probe it from outside the entry points that unity provides you with.

midnight plover
grave frost
teal viper
grave frost
#

awake

teal viper
#

Then perhaps what joer said. Make it the last awake to run via execution order, then you'll be sure all other awakes are complete.

keen dew
#

When Awake runs the scene is loaded for all intents and purposes. If you want to make sure all Awakes have run then that's a separate issue (and what Start is meant for)

grave frost
#

yea i guess its just weird that scene.isLoaded is false until the last OnEnable

midnight plover
#

Makes sense to me in terms of relying on the scene to be fully loaded and accessible

keen dew
#

It's meant for monitoring the load status from outside the scene, where you're more likely to want for the gameobjects to be fully initialized before continuing. It doesn't make sense to use it inside the same scene that's loading because whenever you can do anything inside the scene it has already loaded

sour fulcrum
#

It is odd that unity doesn’t have any proper callback for when a scene is accessible but before objects are given messages

rocky whale
#

How do you stop emitted particles from rotating along with the emitter

grave frost
sour fulcrum
#

There is still no callback like what i mentioned but glad you resolved the issue

tender mirage
#

Curious should i be concerned. This has been on the back of my mind. But whenever my project recompiles while i'm running it, all my coroutines stop running, could this happen if say my game was left running in the background for long enough as well?

grand snow
tender mirage
shell sorrel
#

Recompile while playing has never worked or been worth using

bold berry
#

Is this the appropriate channel to ask for help with HLSL basics in Unity URP?

hazy crypt
#

Theres an old archived channel for shaders but no new one

bold berry
#

Hmmm okay

solar hill
#

Ask here

hazy crypt
#

I have a quick one

#

Ive just watched a tutorial where the programmer writes an if statement like this

#

Why no curly brackets?

solar hill
#

Dont need it for one line

hazy crypt
#

I see

#

But it is essentially the same right

solar hill
#

Yes

hazy crypt
#

Perfect thanks

bold berry
#

Here's the struct for context

solar hill
#

Well im not really well versed in hlsl but the underlined line just looks like youre setting all the struct fields to 0?

#

I guess

bold berry
#

Oh that might well be it

#

I'm looking at someone else's code so I didn't write it

#

thanks!

grand snow
#

Here is the wrong place

bold berry
#

Ah thanks, I couldn't find the right channel before

carmine geyser
#

hi guys, does anyone knows a good article or doc on handling Slopes with character controller? Ive been trying to make it work properly for a time now and i searched a lot of videos about it, but everything just breaks a part or sounds like bad practice, like making the jump break because of gravity forces and so on. I just want a Character to be able to stick to the slope, not bouncing on the way down

hazy crypt
#

Never had any issues

#

Could you describe what you mean by bouncing? maybe finding out why that happens would be helpful

#

In the meantime, I need some help

#

I am trying to read the mouseposition difference from one frame to the next

#

unfortunately my variable "difference" is just coming out as 0,0,0 and im not sure why

rough granite
# hazy crypt

Just so you know the stuff happing in the first and second if statement happen in the same frame every time this function is called

hazy crypt
#

Yeah I was worried that might be the case

#

Im not sure what else I should be doing

rough granite
#

Meaning difference is equal to value - value so (0, 0, 0)
Unless they are negative

keen dew
#

The operations are the wrong way around. First calculate the difference, then set the dragOrigin to the current value

hazy crypt
#

Yeah I can see what you mean

hazy crypt
#

OOOO

#

Perfect

#

Thanks

#

Works like a dream

elder hearth
#

Hi! So this is my script and the "Sprint" action is throwing an error, more specifically " NullReferenceException: Object reference not set to an instance of an object
Player.PlayerMovement.Update () (at Assets/Scripts/Player Movement.cs:29) "

public class PlayerMovement : MonoBehaviour
 {
     [SerializeField] float WalkSpeed = 4.5f;
     [SerializeField] float SprintSpeed = 4.5f;
     [SerializeField] InputActionAsset inputActionAsset;
     private InputAction MoveAction, Jump, Crouch, Prone, Sprint;
     //Rigidbody rigidbody;



     void Start()
      {
         MoveAction = inputActionAsset.FindAction("Move", true);
         Jump = inputActionAsset.FindAction("Jump", true);
         Crouch = inputActionAsset.FindAction("Crouch", true);
         Prone = inputActionAsset.FindAction("Prone", true);
         Sprint = inputActionAsset.FindAction("Sprint", true);
         //rigidbody = gameObject.GetComponent<Rigidbody>();
     }

     // Update is called once per frame
     void Update()
     {
         float speed;
         if (Sprint.IsPressed())
         {
             speed = SprintSpeed;
         }
         else
         {
             speed = WalkSpeed;
         } 
         Vector2 moveValue = MoveAction.ReadValue<Vector2>();
         Vector3 moveVector3 = new(moveValue.x, 0, moveValue.y);
         gameObject.transform.position += moveVector3 * WalkSpeed * Time.deltaTime;



     }
 }
keen dew
#

Which line is 29?

elder hearth
#

"if (Sprint.IsPressed())" is line 29

keen dew
#

Then it didn't find an action called Sprint in Start

elder hearth
#

Thanks

#

It was there and everything but it didnt find it which is very weird

rough granite
elder hearth
blissful stratus
#

i cant figure out how to make jump

using UnityEngine;
using UnityEngine.InputSystem.XR;

public class CharacterChontroller : MonoBehaviour
{
    [SerializeField] CharacterController pCon;
    [SerializeField] float speed = 6f;
    [SerializeField] float turnSmoothTime = 0.1f;
    private float jumpHeight = 1.5f;
    private float gravityValue = -9.81f;
    private bool groundedPlayer;
    private Vector3 playerVelocity;
    float turnSmoothVel;

    void Update()
    {
        groundedPlayer = pCon.isGrounded;
        if (groundedPlayer)
        {
            if (playerVelocity.y < -2f)
                playerVelocity.y = -2f;
        }


        
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        Vector3 dir = new Vector3(horizontal, 0 , vertical).normalized;
        if (dir.magnitude >= 1f)
        {
            float targetAngle = Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg;
            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVel, turnSmoothTime);
            transform.rotation = Quaternion.Euler(0f, angle, 0f);
            pCon.Move(dir * speed * Time.deltaTime);
        }
        

        // Jump using WasPressedThisFrame()
        if (groundedPlayer && Input.GetButtonDown("Jump"))
        {
            playerVelocity.y = Mathf.Sqrt(jumpHeight * -2f * gravityValue);
        }

        // Apply gravity
        playerVelocity.y += gravityValue * Time.deltaTime;
    }
}
polar acorn
naive pawn
#

you don't see to be using playerVelocity anywhere, you aren't applying gravity

#

that pCon.Move shouldn't be in that conditional, you should call Move once per Update

blissful stratus
#

oh i figured it out thanks

rough granite
#

Is there any reason the Move is called before the jump action happens? Wouldn't this just make the game feel like it has extra input delay?

tiny island
#

i have this problem , unity is saying the variable is not assigned in the inspector but it's there in my inspector , anyone know what this could mean?

polar acorn
tiny island
polar acorn
#

Unity doesn't just put random components on unrelated objects.

tiny island
#

might be me from 2 day ago then , anyway tkx

warm iris
#

Is old input system bad? Im a beginner following an old tutorial and should I just follow the tutorial or try to make the movement to the new system

#

@polar acorn maybe u can help

verbal swift
naive pawn
verbal swift
#

the new input system is "better" but much more confusing imo

warm iris
warm iris
verbal swift
#

but for learning something from a tutorial your input doesnt rlly matter that much

naive pawn
#

you should learn the new input system eventually though

warm iris
#

ok thanks

warm iris
#

does anyone know how to remove this?

#

these small texts are really annoying me

naive pawn
#

that's called codelens

frail hawk
#

yes it is called codelens

naive pawn
#

you can search for that in settings

#

you can either disable codelens entirely, or disable the unity extension from providing codelens

warm iris
#

how to disable it entirely?

#

I only see for this line

#

option

#

but not entirely

grand snow
#

It may be something in the VS unity tools options, it not then code lens has to be turned off entirely

warm iris
#

ok thanks I found it in unity plugin settings

frail hawk
warm iris
frail hawk
#

i have it also disabled

warm iris
#

can someone tell me is there a way to fix this game window to have rounded edges?

#

like I see that this is prob for performance

#

but if I'd like to see the actual game resolution, how can I do that?

silk night
#

you can configure your resolution freely here

warm iris
#

thanks

silk night
#

also looks like you have antialiasing disabled which creates those rough stepped edges

frail hawk
#

or the scene view is zoomed in

silk night
#

oh yeah that could be, on the right of the resolution the scale slider should be at 1 if you want to see what it would look like

rough granite
silk night
#

you can only configure the editor resolution there

#

not the build resolution

rough granite
#

But yes this is an easy in editor way to test resolutions

warm iris
#

is there still a locking layer unity option? I can't find it

naive pawn
warm iris
#

ok

onyx blaze
#

Hello, happy new year, guys \o

#

I need a help ><

naive pawn
#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
onyx blaze
#

I'm trying to use Quaternion.Euler, but are rotation around the local Transform
How can I change to rotate into Global Transform?

I'll send the code

naive pawn
#

this isn't a social space, you can include pleasantries if you want but just start with your question

onyx blaze
#

I was typing the question in a new line

naive pawn
naive pawn
onyx blaze
naive pawn
#

!code

radiant voidBOT
naive pawn
#

please share it properly

onyx blaze
#

Ah, ok, let me adjust

naive pawn
#

(unrelated minor issue) that code is using wronglerp, this will result in framerate-dependant and asymptotic behaviour, of which the second might be an issue, and the first is definitely an issue (though probably minor)

onyx blaze
#

Done
I believe that the issue is in the line 60
The first image is the Local Axis
The second image is the Global Axis

I'm trying to rotate into the Global Axis, but I don't understand very well how to do this

https://paste.myst.rs/huyxd010

naive pawn
#

rotate into the Global Axis
what do you mean by this?

onyx blaze
#

I'll record to be easy to demonstrate

naive pawn
#

the issue here might be due to how rotations compose

#

i'm not super familiar with quaternion math, but iirc:
quaternions represent rotations
a * b represents rotating by b then rotating by a (or rotating b by a)
so as you multiply in those new quaternions on the right (what *= does), that looks like rotating on the global axis, and then rotating according to the original rotation of the object
transform.rotation is already global

#

if that's the case, you could make the new quaternions multiply in on the left instead, like newRotation = Quaternion.Euler(...) * newRotation;

onyx blaze
#

Here the video

In the first part, when rotate into Local Axis is okay, but I want to rotate into Global Axis to avoid this angle issue in the second part

naive pawn
#

what?

#

changing the tool setting in the scene view does not affect any behavior ingame

onyx blaze
naive pawn
#

that local vs global setting just changes whether the rotation gizmo in the scene view shows handles aligned the existing rotation of the object in its local space, or if the handles are aligned to world axes

onyx blaze
#

I don't know how to adjust it to Global instead Local

#

Because I want to use the Global Axis instead Local Axis
But I don't understand how to do this in the code :/

naive pawn
#

i don't think i'll be able to give any other answers past that, it's pretty late for me

#

in general you wouldn't be compounding quaternions anyways

naive pawn
#

the typical approach is to store the pitch/yaw, and apply a wholly new quaternion rather than modifying the existing one

naive pawn
onyx blaze
#

Hm...
Let me try inverse it

naive pawn
onyx blaze
#

Very thank you by your help ❤️

naive pawn
naive pawn
onyx blaze
#

I'll adjust with your tips too
Thank you by your time, bro \o

tawny sorrel
#

Greetings to you all, I'm just asking if learning to code on unity from scratch is worth it? i read #🌱┃start-here and #📑┃channel-directory and this seems most relatable to this question, im about to ask another question in a channel most related to that question.

upper pebble
#

I'm trying to make a simple left and right movement system for my game but I can't find any good tutorials on how to do it because they're all outdated. Can someone help please?

prime goblet
tawny sorrel
#

But im mainly asking if i should dive into a brand new language

#

Specifically for unity

#

Specifically so i can make stuff for vrchat

prime goblet
#

Always good to broaden your horizons and learn multiple languages

tawny sorrel
#

Yes

prime goblet
#

since you have the basics down it’s actually quite easier than you think to get into new languages

upper pebble
prime goblet
#

Also

tawny sorrel
prime goblet
#

If you want help with vrchat specifically

#

!vrchat

radiant voidBOT
tawny sorrel
#

Yes ik

#

But its not specifically vrchat

prime goblet
#

ah

tawny sorrel
#

As it includes coding too

prime goblet
#

well yeah learning a new language is always good

upper pebble
tawny sorrel
#

I heard c's are used for many things

tawny sorrel
#

Im gonna lock in and change the platform

prime goblet
#

c# is what unity uses yea the c’s are quite similar tho

tawny sorrel
#

Im gonna assume your a programmer without looking at any of your roles, how long have you known c# for if you know it?

upper pebble
prime goblet
tawny sorrel
#

As all things yes

#

Wait fuck

grand snow
#

try to not target one person on here to be your helper

tawny sorrel
#

01 15
2025
2019

grand snow
#

ask for help generally for anyone to assist with

tawny sorrel
#

Damn so 6 years

upper pebble
prime goblet
# tawny sorrel Damn so 6 years

yea pretty much lol but time spent does not matter I’m sure there’s people way smarter than me who know more in less time

#

regardless

tawny sorrel
#

Yes

prime goblet
#

you should learn c# if that’s what you want to do

grand snow
tawny sorrel
#

I feel.... lost.

#

The thing is whatever i choose i wanna go all out on it

prime goblet
#

that’s a good thing you have motivation

upper pebble
#

or in my previous case were just bad

prime goblet
prime goblet
#

Even if c# or unity isn’t your thing you’ll still gain more transferable skills

tawny sorrel
#

I have 0 knowledge on c#

prime goblet
#

All languages have the same fundamentals

tawny sorrel
#

Where would you recon I begin? I have some time now

grand snow
tawny sorrel
prime goblet
balmy vortex
#

hi is there some way to rebind an input action to a different key in a script?

tawny sorrel
prime goblet
#

np lol and good luck

tawny sorrel
#

Last question, do yk of any youtubers that do videos on unity?

normal mango
#

Is it possible to only allow certain functions to activate if something is true?
More specifically, I have DragHandler functions with OnBeginDrag, OnDrag, and OnEndDrag, and I only want those functions to activate if a certain boolean is true. Do I just need to add a return statement in an if statement at the beginning of each function or is there a better way to handle this?

grand snow
grand snow
prime goblet
tawny sorrel
grand snow
#

!learn

radiant voidBOT
tawny sorrel
#

When it came to lua coding some youtubers would just confused the heckles out of me, while others it clicked instantly

prime goblet
#

yeah so you have to find what works for you

upper pebble
grand snow
#

Id just learn c# with microsofts stuff first

tawny sorrel
prime goblet
#

me personally videos just don’t stick

But also nothing will stick unless you’re making things as well

grand snow
prime goblet
# tawny sorrel Definitely this, yes

https://learn.microsoft.com/en-us/dotnet/csharp/

this is good for understanding just how c# works a bit before getting into unity

I also recommend you shouldn’t make yourself finish the whole course because you may never need some stuff

#

if you want to then that’s good too

tawny sorrel
prime goblet
#

still learning

#

You know what to do next time now

#

and those times probably won’t stop too

#

when you go onto harder concepts

tawny sorrel
#

Facts

tawdry fox
#

where do i go when i find no help in the troubleshooting pages? I'm just starting the coding essentials in the unity tutorial and am not sure what i did wrong despite watching the tutorial and re creating the code

tawdry fox
#

so on the right are the instructions, which i do and it doesnt auto populate the " (collider other) { " part in the code, so i put it in manually and it makes the "0,rotationSpeed,0" line not function

#

Whats happening

radiant voidBOT
polar acorn
#

It mentions you'll only get auto complete if you have a configured development environment

#

If you don't you'll have to do it manually as it shows, but you really should just configure the IDE

tawdry fox
#

coolio thank you

tawdry fox
#

Besides it actually working is there another way to tell if its workin?, I believe i did it but the IDE is still not functioning, even though i have it listed as the external editor, although instead of it letting me go through the Unity editor files, it made me go through my pc files to find it. it currently is installed on unity hub as well.

prime goblet
#

it should be preinstalled but just check

#

you can search for them

upper pebble
#

Why is it saying this? I'm trying to follow a Unity tutorial and this never popped up for them and I KNOW I followed the steps correctly

#

Wait do I need to change the thing to rigidbody 2d or something for this?

prime goblet
#

CapItAliSation MATTers

upper pebble
#

Welp it doesn't move even when fixed. Back to the drawing board

#

Aight I def need help with this. Is there a call I can get into to make this easier to communicate?

prime goblet
#

not really, no and the server doesnt allow soliciting dms

upper pebble
#

Who designed this place????

#

"Ah yes, lets keep it strictly to screenshots"

prime goblet
#

there used to be an offtopic but apparently it was too toxic so they made it more of a "professional" help space

upper pebble
prime goblet
#

regardless you'll have to share screenshots and code if you need help

upper pebble
#

Also that's wild that they don't allow people to talk in dms

prime goblet
#

!code

radiant voidBOT
grand snow
prime goblet
#

!ide

radiant voidBOT
prime goblet
#

it should be able to autocomplete tehse things

grand snow
#

haha ofc its not set up

prime goblet
#

(example)

grand snow
#

wtf is that font ew

upper pebble
prime goblet
prime goblet
grand snow
#

^do that

upper pebble
#

I feel like a new kid who just got thrown into a professional Esports team

tawdry fox
#

so i looked and all i see is the folder packages > packages.unity.com > then big list of "com.unity.blank"i see visualscriptin@1.7.8 and "com.unity.ide.visualstudio@2.0.16" Is that what im looking for?

prime goblet
#

you're looking in the wrong place

tawdry fox
#

ah

#

i am lost then

prime goblet
#

click on this button (colour doesnt matter)

tawdry fox
#

got it

#

what next?

prime goblet
#

search to see if the visual studio editor package is installed

#

on the "In Project" tab

tawdry fox
#

it is not, but it is in the unity registery, i assume get it from there?

prime goblet
#

yes

#

odd that it's not installed

tawdry fox
prime goblet
#

lol np

upper pebble
#

Okay I fixed the thing but it still has errors connected to RigidBody

sly shard
upper pebble
#

Wait that's not what you were asking was it

grand snow
#

you are trying to get the 3d rigidbody type

#

its Rigidbody2D

#

i doubt the unity tutorial fucked this up

upper pebble
grand snow
upper pebble
grand snow
#

pff sorry

#

the same concepts apply

#

go search unity learn yourself then

sly shard
smoky garnet
#

First time creating a game, I'm tryna make a simple topdown roguelite style game.

I've got player movement down and I want to create a weapon system, I plan to just have your standard ranged weapons (guns, bows, staffs, tomes) that fire a projectile, and then some melee weapons that swing about a pivot to attack. Sorry this is a rather broad question, but what would be the best approach to creating this weapon system? As far as I've seen weapons can be created in several different ways and it's a little overwhelming.

upper pebble
grand snow
upper pebble
#

I was originally trying to follow a YT tutorial but it was using the old input handler thing so I didn't realize that was a problem until much later so I had to improvise with this

sinful zinc
#

any way to make a rigidbody fall faster to the ground without changing the projects gravity

polar acorn
#

Add downward velocity

sly shard
#

I’ve tried (and failed making a couple games lol) either from losing motivation or a problem that forces me to restart project lmao (this is why you don’t use a Rigidvody movement script from 5 years ago that causes stuff to mess up (especially with procedural animations), also don’t use ai it kinda messes stuff up and makes me feel like I did nothing). don’t make the mistakes i made lol.

Let’s hope the next one I improve and actually make it okay-ish

sinful zinc
#

without code

upper pebble
#

Lowkey used the built-in GPT-5 thingy in VS Code just to see if it was good at all and I managed to make a far simpler and easier to read thing than it. What a waste of electricity and water lol. I barely even know how to code

prime goblet
polar acorn
sinful zinc
#

no i know that i cant though

polar acorn
#

why not

sinful zinc
#

is there another way in the rigidbody settings

prime goblet
#

weight? i dont think that does anything though

#

why are you asking for non-scripting methods in the coding channel

sinful zinc
#

where else

prime goblet
#

why cant you use code?

sly shard
upper pebble
prime goblet
#

if you have a brain you're immediately better than any gpt model. gen ai is a buzzword that allows billionares to ruin the planet

sly shard
#

procedural stuff idk

sly shard
#

Ai is js a way to ruin your project and get more regrets in life

upper pebble
#

How do i make the object move faster? It accellerates extremely slowly

polar acorn
upper pebble
polar acorn
sly shard
#

We love rv.addforce.

upper pebble
edgy sinew
#

Love RB, hate PID controllers notlikethis

sly shard
#

I can’t type the letter that’s meant to be after r in the thing (phone keyboard broken)

sly shard
upper pebble
#

I know there's a simpler and better way but my memory is way too foggy

#

Like I used to do this all the time but now it's just... gone

sly shard
#

ForceMode.Impulse

#

Is fynnt

#

Funny

edgy sinew
#

ForceMode.VelocityChange is a useful one

upper pebble
sly shard
edgy sinew
#

It’s on Unity docs better than i can explain.
But i recall it ignores mass

edgy sinew
#

It’s an optimal parameter default is uhh ForceMode.Force I think ?

sly shard
#

Impulse is good for like short bursts or like pushing things with gravity and stuff (I think) (so like jumping and wasd)

#

I don’t remember cause I didn’t code in like 5 months after I kinda accidentally destroyed my 6 montg project accidentally

#

Hard to bounce back. But I wanna finish one game in my lifespan

edgy sinew
#

AFAIK VelocityChange is identical to Impulse. just that it doesn’t consider mass

#

Unity Docs imply that in their wording “In contrast to ForceMode.Impulse . .”

upper pebble
#

I am Frankensteining code together

#

IT WORKS HAHAHA

#

IT'S ALIVVEEEEE

#

How do I make this monstrosity have a movement speed cap? I tried something at the bottom but it doesn't seem to do anything

prime goblet
#

if (speed < target) { essentially

#

is movementX your speed?

upper pebble
#

(I have no idea)

sly shard
#

If speed > maxSpeed{
Set movement X to maxSpeed}

#

Could work

teal viper
sly shard
teal viper
sly shard
upper pebble
#

I'll try it

sly shard
#

Also do you have friction? You kinda need it

upper pebble
sly shard
smoky garnet
teal viper
upper pebble
smoky garnet
upper pebble
sly shard
#

I don’t remember fully lol

upper pebble
sly shard
#

Lmao

upper pebble
#

My issue is:

  1. It's ignoring the code that is supposed to stop it on occasion
  2. The speed isn't capped
sly shard
#

YouTube tutorial it is lol: “2D friction in unity how???”

#

Or smth lol

upper pebble
#

I keep accidentally pressing enter lol

upper pebble
sly shard
#

Why are you using fixed update

cosmic dagger
#

If you're moving using force, you need to check the velocity and stop applying force when it reaches your maximum speed . . .

upper pebble
#

Okay so I changed some values and the max speed works when I move to the right but not the left...

sly shard
upper pebble
sly shard
upper pebble
sly shard
#

Well hmm.

#

Maybe like cause you’re moving backwards the velocity is becoming negative?

#

Idk

#

Lmao

#

I need to relearn

upper pebble
#

Ye lemme create something rq

sly shard
sly shard
upper pebble
sly shard
#

lol

#

Well

#

Shi idk lma

sly shard
#

IM SO COOL

upper pebble
sly shard
#

YES I FINALLY HELPED SOMEONE

#

I’m so proud

#

Of both of us

#

I can’t believe I helped someone while I’m in an airport tired af lol

upper pebble
#

I just need to make it accellerate faster now

edgy sinew
#

It’s all online for sure. I’d avoid “complete” tutorials and do it how you like piece by piece, step by step

sly shard
#

E.G: interaction colliders, ray cast, idk

upper pebble
#

I love frankensteined code

#

But how would I make this accelerate faster?

prime goblet
#

add larger values

#

where is your acceleration?

#

is it the movement var?

#

multiply that by something

upper pebble
teal viper
#

And by the way, movement has nothing to do with speed in your setup. Your max speed logic doesn't do what you think it does.

sly shard
sly shard
#

I’m also curious

upper pebble
#

Truely am curious why there aren't any calls for this type of stuff

edgy sinew
#

Probably clamping velocity not movement? or worse acceleration?

prime goblet
#

-# how are you writing this code and not knowing how it works?

upper pebble
teal viper
# upper pebble Explain

In your code movement is just the input/direction. The speed that your rb get is calculated from force. Normally, it would increase every frame. Speed == velocity magnitude. You've been told that several times now.

upper pebble
#

(I have no idea what it does)

warm iris
#

can someone pls help on #💻┃unity-talk ? Its a question about how to make folders in hierarchy

upper pebble
teal viper
# sly shard Brain cell loss?

Can you please avoid unrelated comments? And suggesting solutions when you clearly have no idea. You led them into misunderstanding about their code and writing incorrect logic.

teal viper
upper pebble
upper pebble
teal viper
#

If it's above your max speed, you can avoid applying force. Though you'll have to take into account it's direction too.

If you want a simple solution, set velocity instead of applying force.

warm iris
#

hey guys waht is a still working version of FindObjectOfType?

prime goblet
#

FindObjectsByType i believe

warm iris
#

I think its only for objects

#

like plural

#

what about a single object?

edgy sinew
#

Probably that still works fine you’d just want the 0th item then UnityChanHuh

cosmic dagger
warm iris
#

thanks

heady matrix
#

I just moved to unity and wondered if someone had some insight about parallax for 2d platformers build in a 3d space. Sorry if my question is long and vague. I am trying to make a parallax system like hollow knight/ori. Apparently, hollow knight uses Orthographic camera, which avoids distortion, object scaling, and Z-fighting. Meanwhile Ori uses perspective cameras. Seems like orthographic is the right way, but a lot more tedious, and there is no tutorials, as most youtubers prefer showing the perspective way since it is a "quick hack" to get it working in 5 minutes.
So my goal is to be able to place the objects in the editor where they appear in game, and moved from game maker for that. I know Godot has a "live preview parallax" feature that achieves that, but i am more interested in Unity, in which live preview while do-able, was more problems.
The solution that i created is "camera anchoring triggers" which makes my objects in certain trigger zones think the camera spawned at different areas. Which works, but once again tedious and far from perfect. But at least my objects in editors can be somewhat close to where they should be.
So I wondered if anyone has been doing parallax with 3d layers in editor, how you dealt with layers and sorting orders.

prime goblet
#

ortho has no depth so those "perspective hacks" that convey depth arent really hacks

#

iirc hollow knight silksong uses a perspective camera

heady matrix
#

Ok i had a long argument with chatGPT about that haha. According to what i've found on reddit, it is an orthographic camera. How to deal with Z-fighting with orthographic, just a small FOV and far away camera?

prime goblet
#

ortho cameras dont have FOV

#

FOV only applies to a perspective

#

generally i think it's mostly just moving assets forward and backward on the z axis

heady matrix
#

It's not an issue with orthographic, just annoying sorting orders to deal with. Basically i am using Z only to build scenes and simulate stuff like fog, parallax, etc. But with orthographic moving left/right from objects can cause some Z-fighting

#

unless they are like super far back on depth

prime goblet
#

move them off of the same z position then?

#

can you show an example maybe

heady matrix
#

I tought i could do it by making them Z = 0, Z = 0.1, etc. I don't have much of example as i haven't build much yet and can't make videos.. but on this picture the selected item is Z 0.1 but rendered in front of the Z 0. It only draw behind if i make it a full unit behind, which is too much. Also, even if i had 3 column at Z 1-2-3, they would Z-fight if i move the player/camera, left and right from them. So i guess maybe i just need a low FOV and move the camera far back?

edgy sinew
#

I meant sick visuals They/Them/etc (respectfully)

heady matrix
#

thanks, yeah well it's from my game maker game, i'm just doing some test to see if i want to port to unity

cosmic dagger
heady matrix
#

hoping to be able to do a bit more vertex displacement and better parallax in unity

edgy sinew
#

Lots of great games are made in Unity. Good to hear

sly shard
heady matrix
#

yeah i find everything much longuer to do, but i can feel the power. in game maker i am simulating a 3d camera and it's been quite a headhache

shell sorrel
#

there is a setting in its asset to tell it how to do sorting, might want to use a custom axis

heady matrix
#

yeah, i learned about it way too late and realized i wasn't even on latest Unity version so hard to start over, but learning shader graph right now and i love it

shell sorrel
#

also the camera i would adjust its far and near plane to not extend too far past your content

#

doing so greatly reduces the chances of z fighting

heady matrix
#

still looks better in game maker but theres so many post processing tutorials on unity i hope to learn more techniques

#

chatGPT has been REALLY insisting on using orthographic so i came to ask on discord lol

shell sorrel
#

yeah its just a learning curve to learn a new engine

heady matrix
#

(yeah i haven't learned C# yet so letting AI code for me..)

shell sorrel
#

the approach you are tarking in layering these scenes looks close to what like hollow knight does so that proves it can work very very well

#

like your art, its simple but carries the mood well and is easy to read

edgy sinew
#

Seriously how are you cooking up these sprites UnityChanCheer Krita?

heady matrix
#

basically spent 2 weeks coding this parallax system, while it all works right away in perspective.. but it does feel a bit weird and distorted in perspective, so honestly starting to believe orthographic is the best way on the long run

#

I've been doing pixel art games all my life. then i bought an ipad and fell in love with Procreate, so decided to take a shot at hand drawn animations

shell sorrel
heady matrix
#

(photoshop great too but i like spriting in my bed lol)

#

honestly i kind of cheat with post processing for the color palette haha

edgy sinew
shell sorrel
edgy sinew
#

Then again looking closer it rly just does look like the typical "3px wide" brush notlikethis
Nice cooking for real

heady matrix
#

yeah using some pencil like brush, planning to use same brush size everywhere like a comic book, and avoid blur effects, so i'm building different type parallax fog

#

unity sure is opening up a lot of options

shell sorrel
edgy sinew
#

it's giving fancy pants adventure vibes UnityChanThumbsUp

#

except yours looks better already

heady matrix
#

yeah now that i can finally make decent distortion shaders, i'm thinking of trying a more paint style and go full on Ori

#

fancy pants, classic 💪

shell sorrel
heady matrix
#

per object, just like those shaking leaves and bushes in the wind

#

(looks terrible with outlines though)

shell sorrel
#

with a mask the outline could be left alone with distortion in the middle

#

Ori and stuff like that also has a lot of vertex position stuff going on as well to bend things as you walk past

heady matrix
#

i'm very, very beginner with shaders, but currently it's just a height mask that makes the thing shake left and right

shell sorrel
#

or shake them in wind / things that make force

heady matrix
#

yeah like when you pick up an object it all moves, super cool

#

(in my game it just rotates, doesn't look all that good)

shell sorrel
#

visual tricks like that are often iterated on a few times in a dev cycle

#

sometimes makes sense to get further along with content to see it in context

heady matrix
#

for sure, i'm basically trying to do a vertical slices, not even touching gameplay

#

visual prototype/reality check

#

before ditching 3 years of work to start over lol

shell sorrel
#

but yeah think it looks cool, and reads well, its very obvious what is forground, background and enemies

heady matrix
#

yeah my first test in unity is i build a fog/noise shader that colors the further Z objects in the color of the background, hopefully that will help with that without using blurs

shell sorrel
#

yeah that is simple in 3d, not sure how much of these things are writing to a depth buffer though in 2d i would need to play with it to know

heady matrix
#

yeah i don't know a thing about optimization.. it's not actually using the 3d though, just using Z as value for depth simulation

sour fulcrum
heady matrix
#

Yeah unity seems a lot more optimized and powerful than what i am used to. Not as worried drawing big sprites and have big scenes

wild cove
#

Hey guys, I've ran across this confusing problem where the level manager keeps spawning levels in a completely different place then where I want them to be. But for some reason the position of the entire level tells me the level is where I want it to be, yet it definitely is not where I want it to be. I don't think it's a coding problem, but I don't know what I did wrong with it.

wintry quarry
#

you need to switch this to Pivot mode

#

then you'll be able to see the real positions of your objects with the position gizmo

#

From the inspectors i can see the positions are correct (exactly the same as each other except for +25 on the x axis)

wild cove
#

ok, thank you!

sour fulcrum
#

no modding support on this server, sorry

merry lotus
#

Anywhere where I can find that support

sour fulcrum
#

you'd have to seek that out

merry lotus
#

Wonderful.

sour fulcrum
#

offical server so gets into tos related stuff

magic crown
#

Hey small question how can i find with math or code the coordinate along an segment between two point?

stone oar
#

anyone tried using vscode on ubuntu? no matter what i do mine can't acknowledge the existence of dotnet sdk. i pinpointed the dotnet location manually in settings, i reinstalled it multiple times, i tried using omnisharp, i tried multiple other internet "solutions" but nothing works. I can trigger dotnet --info in linux terminal, but not in VScode. this is the error:

The .NET SDK cannot be located: Error running dotnet --info: Error: Command failed: dotnet --info /bin/sh: line 1: dotnet: command not found /bin/sh: line 1: dotnet: command not found . .NET debugging will not be enabled. Make sure the .NET SDK is installed and is on the path.

magic crown
#

do you know what version sdk you have?

#

Cause maybe your .net just is corrupted or you have to download it manually (i'm not sure which version vscode use tho)

#

Was vscode open while you installed .net?

magic crown
#

thx

teal viper
#

Lerp for short.

magic crown
#

thx idk why i didn't think of that

naive pawn
teal viper
stone oar
#

that didnt work so i tried through terminal (the flatpak iirc)

#

still nothing

stone oar
#

also, probably unrelated, but unity crashed my entire system by eating all of my RAM and swap memory

#

idk how to profile that

stone oar
#

found it

#

Error : (DotnetAcquisitionFinalError)

#

An error occurred while installing .NET: Automated installation for the distro Freedesktop SDK is not yet supported. Please install the .NET SDK manually:

#

:/

#

okay despite the errors, thee vscode now sees my functions properly

undone wave
#

I'm currently making an undo/redo system

#

The problem is that whenever I undo a 'Create' command, the reference gets destroyed, and subsequent redo's cause exceptions

#

(if I destroy the GameObjects)

#

if I disable the GameObjects, garbage objects that can no longer be accessed pile up

#

(for example, Create Object #1 -> Undo -> Create Object #2 will cause Object #1 to be inaccessible permanently, and the object is no longer useful)

#

Can someone point me in the right direction?

midnight plover
undone wave
#

I somehow fixed it by creating a List<Object> that holds disabled (instead of destroying so that their references aren't destroyed) objects whose creation commands have been undone, and whenever a new command is performed (instead of undoing/redoing), destroying all the objects in the list (so they don't pile up) and clearing it

midnight plover
undone wave
#

Otherwise, if you start adding up all objects created for lifetime, you might run into a big pile of unused but still present objects
i mentioned how i resolved this issue in the second part of the sentence

midnight plover
undone wave
#

yes

midnight plover
# undone wave yes

Ah, got it. I still got a bad feeling about your issue that there are still references present when undoing. If you create object A, undo, undo, redo, redo. What happens there? Because on the second undo for example, the object A gets destroyed but redoing two times should bring it back, right?

undone wave
#

no (as in object A doesn't get destroyed)

#

as i mentioned, object A only gets destroyed when performing a new command

#

undoing/redoing preserves the whole stack, and the objects are still present

midnight plover
#

Ahh, yeh, true. the new is the important word. Sounds like a solid workaround.

midnight plover
undone wave
#

yeah, i'm planning on only destroying objects in the aforementioned case

real thunder
#

Is changing agent.avoidancePriority GC heavy?

teal viper
real thunder
#

because the method with it shows 0.5KB at profiler

#

there might be other things causing that tho but it's my first suspect

teal viper
#

You can use profiler markers to isolate separate lines/blocks of code in a method

#

Or just share your code

worn veldt
#

Elo, I'm working on a game similar to Prison Architect but focused around SCPs, entity interactions and events. I've gotten a rough version of the camera to work using the PlayMaker plugin, but am unsure on how to get the actual building/tile placement to work. It will be a 3D game, and I will need the tile/building system to work like this:

I will need the tiles to have multiple states and layers for different types of object on each tile, for example: all on 1 tile would be: The ground ( layer 1 ), Object ( layer 2 ) Entity/Character ( layer 3 ), utility/wiring layer ( invisible, but allows systems to function ).

I will need it so that I can easily have hundreds - thousands of tiles at once while remaining performant.

Entities will need to be able to navigate around and interact with tiles, such as walls and doors, and respond to tile states, such as if a tile is on fire.

I have tried to do this and have looked at many tutorials, and I couldn't find anything similar to what I need, so I was hoping I could ask for help here, and preferably get continued assistance throughout development of my project from someone, who preferably knows C# well. If you have any idea on how to do this, or are willing to help me make this, please let me know, but if not all good, thank you for your time and reading this :)

teal viper
real thunder
tiny island
#

is there a way to connect a object scene into a prefab script?

real thunder
naive pawn
#

i imagine it'd internally basically be an array-backed list of delegates, so would just potentially be that array in that case

#

imo just stop guessing and go check so you can just know

teal viper
real thunder
#

I got 128 bytes and I am curious what did it

teal viper
#

Well, we can't really help you with that without seeing the code.

real thunder
#

it's just a bit confusing

    private enum VelocityStatus { SpeedingUp, Stopped, SlowingDown };
    private VelocityStatus _velocity_status = VelocityStatus.Stopped;
    private VelocityStatus velocity_status
    {
        get
        {
            return _velocity_status;
        }
        set
        {
            if (value == VelocityStatus.Stopped)//so transition be more smooth
            {
                if (is_halting_walk_anim_on_stopping) animator.SetFloat("speedKoeff", 0);
            }
            else
            {
                animator.SetFloat("speedKoeff", max_speed * move_anim_speed_koeff);
            }
            _velocity_status = value;
        }
    }
    protected virtual void AngerEnter()
    {
        velocity_status = VelocityStatus.Stopped;
        agent.avoidancePriority = standing_agent_priority;
        agent.ResetPath();

        spotting_anger_timer = spotting_anger_cd;
        is_spotting_anger_allowed_now = false;

        doState = AngerLoop;
    }

Is that animator.SetFloat()? 🤔

#

doState is a void delegate yada yada

#

this one AngerEnter call gave 128B garbage

teal viper
#

Probably the doState assignment.

#

This likely creates an objects on the heap containing the state of the function to call.

#

Might be wrong. But it should be easy to test.

verbal dome
#

I suppose SetFloat could allocate if you use strings instead of integer parameter IDs?

low copper
#

Hey everyone. I am currently building a game using a bootloader scene that adds/removes scenes additively. In my current situation I am loading a scene, and the scene has objects that registering some scripts to my service manager. I then unload the scene later on. Then I get an error when I try to load the scene again. My service controller throws an error because the script is already registered. I can easily just do a check if it exists already and just not register it again. I can also just make it a rule to not unload scenes if I am going to use them (maybe just disable all elements) but this seems like I might forget/not the safest approach. Or I can try to do some kind of unloading system with my service manager when a scene unloads (which I'm guessing is going to be tricky). Any thoughts/ideas?

teal viper
low copper
#

So, I was guessing this was the best approach but I'm guessing that would require me tracking which scripts are loaded by which scenes. I was just not loving the added complexity of that.

low copper
#

So my current scene loads three scripts for example, when I unload the scene how am I going to know what scripts in the service manager to remove

teal viper
low copper
#

Ahh...so add OnDestroy to the scripts and have it unregister in them. Then, when the scene gets unloaded the unregister will automatically run?

teal viper
#

Yep

low copper
#

Haha...yeah...that is much easier. Ok, thanks so much.

real thunder
#

each NPC change it's current state fairly often

#

ok I got questions

#

delegate allocate 1.2 KB?

#

oh right it was for 10 mobs at the same time

#

well I prolly going to learn to make delegates alloc free

thick root
#

Hey, is this the correct Chanel for asking about performance?

cerulean flax
#

why is this happenin that refrence script thingy is cuz i removed the script cuz i figured i want the camera to be fixed instead of following day2 in unity already having me crash out

thick root
cerulean flax
wild peak
#

Maybe your environment falling

thick root
#

From the camera it looks like it's not moving

#

Does the canvas have rigidbody or something?

cerulean flax
#

lemme check

#

enviroment does got rigid body

wild peak
#

remove it

thick root
#

Why does the environment need the rigidbody?

cerulean flax
#

oh damn its fixed ty guys i look up to both of you now 😭

wild peak
native flame
#

Could anyone clarify why the unity docs say that for a collider to trigger, one of the two gameobjects needs a rigidbody component? I've been triggering colliders with nothing but a charactercontroller till now

cerulean flax
#

i thought it need for collision and stuff

thick root
#

Rigidbodys and character controllers

native flame
sour fulcrum
midnight plover
naive pawn
#

(or is my understanding of interning wrong)

thick root
#

Anyone capable of reading this? Yesterday 150 fps on average but after changing some very very small code, nothing performance heavy, and now its 120 - 30 fps spikes

real thunder
#

I kinda forgot the interface but enable deep profiling open call stacks select the spike on the graph sort by time and unwrap functions figuring out what is the worst performance killer

#

also look for GC, idk where exactly to see how it affects peformance but too much of garbage is always bad for it

thick root
#

Okey I'll try, thx

#

I think learning french is easier at this point...

#

Ill look for a good yt vid on how to read this

fickle plume
#

@thick root no off-topic images, please

thick root
#

Is there any official Chanel for performance?

fickle plume
thick root
#

Okey I'll note it down for future

#

Btw for anyone curious about my fps issue, when laptops are not plugged in they enter into energy saving mode and loose 70fps of your build.

fading barn
#

should i use animator.setbool or animator.Play for changing animations

wintry quarry
#

But you can build your own state machine in code and use Play if you want.

fading barn
#

my animations dont play sometimes

wintry quarry
balmy vortex
#

hi I'm trying to add a mechanic to my game that requires two keys to function properly, was wondering if the best practice here would be to just make two keybinds for each letter and only check for one at a time or if it would be better to just rebind one singular input action every pendulum swing

naive pawn
#

rebind one singular input action every pendulum swing
that would be a fragile/stateful system

#

using 2 binds would probably make the most sense

balmy vortex
naive pawn
normal mango
#

Can anyone guess why this is crashing when Attack() is called?
NullReferenceException: Object reference not set to an instance of an object

{
    HandleHighlight();
    if (GameController.Instance.State.currentPhase == GamePhase.Battle)
    {
        Debug.Log("clicked");
        BattleManager.Instance.Attack(eventData.pointerPress);
    }

    if (GameController.Instance.State.currentPhase == GamePhase.Main1 || GameController.Instance.State.currentPhase == GamePhase.Main2)
    {
        RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out dragOffset);
    }
}

public class BattleManager : MonoBehaviour
{
    public static BattleManager Instance;
    public GameObject attacker;
    public GameObject defender;

    public void Attack(GameObject target)
    {
        Debug.Log("called");
        //if (attacker == null) attacker = target;
        //else if (defender == null) attacker = target;
    } 
}```
naive pawn
#

seems like it's BattleManager.Instance that's null

normal mango
naive pawn
#

it traces where the error came from, including the specific line

#

click on the error log in the console and it'll show the stacktrace under the error message

normal mango
#

NullReferenceException: Object reference not set to an instance of an object
DraggableCard.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Scripts/DraggableCard.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerDownHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/ExecuteEvents.cs:43)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/EventSystem.cs:514)

naive pawn
#

right, so Attack isn't even being called

#

the top line is OnPointerDown, that means the error happened in that function

#

the :52 means line 52, so go check what line 52 is, see what could be null on that line

normal mango
#

ah found the issue, i didnt have an awake function to set the instance

#

thank you!

#

actually, im having the seperate issue where the target isnt being properly passed through attack()

tiny island
#

i'm trying to get the player position for the enemy attack direction but it's a bit off mark , is there a way to manually add or substract to a axis of the vector?

frail hawk
#

you can creat a new Vector3 and pass in the x y z

frail hawk
#

would be interesting to find out where the offset comes from

wintry quarry
solemn cedar
#
    {
        float t = 0f;
        Color c = fadeImage.color;

        while (t < fadeDuration)
        {
            t += Time.deltaTime;
            c.a = Mathf.Lerp(startAlpha, endAlpha, t / fadeDuration);
            fadeImage.color = c;
            yield return null;
        }

        c.a = endAlpha;
        fadeImage.color = c;
    }

    public void FadeOut()
    {
        StartCoroutine(FadeCoroutine(0f, 1f));
    }```

anyone know why this works in editor but not in build?? this has been annoying me for the past hour or so
slender nymph
#

add some relevant logs to find out what specifically is happening in the build

#

!code 👇 also see how to correctly post code

radiant voidBOT