#💻┃code-beginner

1 messages · Page 806 of 1

rich adder
#

but also depends on the game style one goes for, active and physics based games may use fully physics or combo

tired python
#

i feel like the only reason my particle collisions isn't working is because of this stupid z component

rich adder
#

what the " z component " unclear what that even means

tired python
#

position.z

rich adder
#

Z isn't a component

shell nacelle
tired python
#

no more like, position is basically like a vector, so z is a component of that vector...

#

i understand what you mean by that though

rich adder
shell nacelle
#

i see

tired python
#

wait a sec, do i need to attach a collider to the particle system for it to detect collisions?

rich adder
tired python
#

this thing

#

no collision is detected when the poop ends up farting

rich adder
tired python
#

this one or

rich adder
#

but 2D

tired python
#

the particle collides and then moves away, but it still doesn't trigger onparticlecollision

rich adder
#

and does duck have a collider

tired python
tired python
neon terrace
#

I have a question regarding the sprite editor, how can I edit the animation to start from right to left or move each slice individually? basically want the animation to run in reverse

neon terrace
#

thanks !

tired python
#
using Unity.VisualScripting;
using UnityEngine;

public class ParticleCollisionScript : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void OnParticleCollision2D(GameObject other)
    {
        Debug.Log("Particle Collision Detected.");
        Destroy(other);
    }
}
```The above code is attached to the gameobject having the component particle system attached
#

i also have it attached to the duck (the enemy which the particle is supposed to collide with)

rich adder
#

uh where does it say to write "OnParticleCollision2D"

tired python
#

i remember OnParticleCollision not working, so i was like heck, why not just try out 'OneParticleCollision2D;

rich adder
#

it should work you probably had something disabled like Send Collision events / World 2D

tired python
#

wait lemme change it back

#

still doesn't work

rich adder
#

also a bit concerning you're moving a rigidbody with A Spline Animate

#

you should probably use the spline only as path but move with rb.velocity or moveposition from the spline path

tired python
#

don't tell me to go back and change it, i will have to rewrite a lot of code to make it work...

#

pls i beg

#

aight fine, i will try fixing that too, but i want this fixed first, is there anything i could be missing out on?

rich adder
#

first test a simple rb with collider that doesn't move, see if you can get the message to popup

#

this way you can narrow down the problem better

tired python
rich adder
tired python
#

💀

rich adder
#

how else is being destroyed

#

make a vid of new setup if possible so its less confusing

tired python
#

wait, my pc potato

rich adder
#

if that line is running that means Particle system is doing the correct thing... the issue may be you moving the duck via teleport / transform instead of physics.

rich adder
rich adder
#

its detecting it though 🤔

tired python
#

ya lol

rich adder
#

probably moving slow enough to catchup

ashen wind
#

hey I have a game that I've finished and it works great in editor, but as soon as I build it the framerate drops insanely. it's got a lot of non-convex static mesh colliders, so that could be it, but I don't know how to make it run as well in the build as it does in the editor

summer radish
#

Am I correct to assume that is i created a chunk generator to generate 16×16×64 chunks with caves underground and flat above could I technically just use my cave setting in reverse to create mountains and floating island above instead of it being just flat? Havnt done anything yet just brainstorming

teal viper
ashen wind
teal viper
ashen wind
#

oh I needed to put it in edit mode

teal viper
#

First of all it needs to be a development build. Then you actually need to make sure it's running(in the foreground) while the profiler is attached.

ashen wind
#

attached?

#

the build is running, and the profiler window is open

#

i don't know what attached means though

rich adder
teal viper
# ashen wind attached?

It seems attached in your screenshot. It means that the profiler is connected to you game.

rich adder
#

needing to convert spline space into world space

ashen wind
#

do you have to open it from the build? the editor window isn't doing anything

teal viper
tired python
ashen wind
#

it's not windowed, it's fullscreen, but tabbing into it doesn't put any data in the profiler

tired python
teal viper
ashen wind
teal viper
ashen wind
tired python
teal viper
# ashen wind

You need to select your game process as you did earlier. Not play mode - this is for profiling in the editor.

ashen wind
#

ok, got it working, now what am I looking for?

#

is it just way too intensive for cpu only and it's not using my gpu at all?

teal viper
#

Go read the docs about the basics of working with the profiler. Once you get the hang of it, share a frame data(hierarchy sorted by time).

rich adder
teal viper
# ashen wind

This does seem weird. Something is throttling your GPU.

ashen wind
#

"wait for last presentation and update" is like a third of it

teal viper
#

Is that data from when the process/window was active??

#

Or do you have it collapsed/in the background?

#

Your game will not run/update/render if you alt tab out of it(making it go to background) by default. If you're doing that, it would explain what you're seeing in the profiler.

rich adder
#

its been a while since i used PS

tired python
ashen wind
teal viper
#

Or are you saying it's so slow that it's unplayable? Less than a few frames per sec?

ashen wind
#

and 99% of it is this

teal viper
ashen wind
#

laptop with 2 GPUs. unity was bugging out and kept crashing whenever it would switch between them, so i disabled one of them

#

that's probably related

#

but weird that the editor works perfectly fine

teal viper
ashen wind
#

see if that link works

#

i'm on a laptop, but I don't have a desktop

teal viper
#

Well, I'm at work, so can't really test it now.

ashen wind
#

oh gotcha, i'll get my friend to try his computer

teal viper
#

Anyways, the issue is very likely in your laptop and not unity or your project, so maybe investigate in that direction.

#

One thing to try is to specify the gpu to be used for the program in your GPU control panel.

crude condor
#

Hi so I'm using the unity tutorial for Roller Ball and my code is not working. I followed the tutorial every step of the way but I keep seeing that my movementVector.x and movementVector.y is wrong. I need help as to why this is not working

frosty hound
#

Sharing the code what you used would be an obvious starter, nobody can guess a solution otherwise.

crude condor
rich adder
radiant voidBOT
rich adder
#

!screenshots

radiant voidBOT
rich adder
#

and you're literally trying to use variables that do not exist

crude condor
#

But I’m using the tutorial

rich adder
#

yeah and you're copying it without looking correctly

#

You gotta try pay attention to what its showing and why it is a certain way

crude condor
#

I was copying it correctly and trying to pay attention to what is showing. I even paused it and then went back

rich adder
#

even with garbage photo capture instead of a proper screen

#

look at those 3 lines

#

try to make sense out of what is trying to do

#

even without understanding the code, the words don't match 100%

crude condor
#

I’m very new here and trying to learn coding.

rich adder
#

I understand but most of this issue isn't even a coding thing

#

its compare and find difference

#

do you believe movement and movementVector are the same ?

crude condor
#

I don’t know

#

I don’t know what any of this stuff means

rich adder
#

forget the code, this is literally words

#

numbers ? 1 isn't the same as 11

rich adder
high mauve
#

Hi i need some help currently I am trying to create a game that simulate fixed wing drone flight and I'm doing it by applying force at position using RB but I am stuck at the part were I have to calculate the lift direction as I need the lift to be always be perpendicular to the wind no matter the rotation or position but don't know how to do that tried AI and all but that made it more confusing as so sayes to use cross of vector 3 and -local velocity. Normalized and some give direction after adding in drag need help

twin pivot
teal viper
twin pivot
high mauve
high mauve
#

And sorry for the late reply

high mauve
teal viper
high mauve
#

The -ve normalized of local velocity to get the wind direction and the vector3. Right

real thunder
#

Anyone know a good solution to reduce garbage from sorting out an array?
I just needed to get a list of RaycastHit's sorted by distance, looks like everyone would need that, yet doing it every frame on many objects I get about 1Mb garbage
something like that:

public class RaycastComp : Comparer<RaycastHit>
    {
        public override int Compare(RaycastHit x, RaycastHit y)
        {
            return x.distance.CompareTo(y.distance);
        }
    }
public static RaycastComp raycast_hit_comparer = new RaycastComp();

int howmanyhits = Physics.RaycastNonAlloc(shooting_center.position, target.coords - shooting_center.position, hits_cache, Mathf.Infinity, check_clearance_mask);
if (howmanyhits != 0)//if we hit at least something
        {
            Array.Sort(hits_cache, 0, howmanyhits, raycast_hit_comparer);
        }

Do I need to, like, copypaste, I mean, write my own sorting algorithm or something? Can I cache something?
Reading on random sites I see they advice to use comparison instead of a comparer, is that the best I can do?
oh no, Array.Sort don't have an overload for comparison and indexes

twin pivot
#
    public static void UpdateHp()
    {
        _hpTMP.text = ($"{GameStats.playerHp} / {maxPlayerHp}");
        gameObjects._hpHand.transform.SetLocalPositionAndRotation(new Vector3(0,0,0), Quaternion.Euler(0f, 0f, ((maxPlayerHp - playerExp) / maxPlayerHp) * 360));
    }
#

the rotation isnt even changing and im not sure why

rich adder
silver fern
twin pivot
naive pawn
silver fern
real thunder
#

I dunno because I can't even compare comparison vs comparer
because "The issue is that there is no analogical Comparison<T> overload for the Sort<T>(T[ ] array, int index, int length, IComparer<T> comparer) call - therefore, the only solution is custom sorting code"

naive pawn
#

honestly im not sure how using a delegate instead would make it allocate less

#

the allocation comes from the sorting algorithm, not the comparisons

real thunder
#

"GC allocations from creating a delegate wrapping the comparison object"

#

so like each time comparer create a comparison delegate?

silver fern
#

doesn't the compiler already optimize this anyway

real thunder
#

famous last words

naive pawn
runic lance
#

what is the end goal for this? maybe you can even avoid sorting at all

real thunder
naive pawn
#

are you just calling comparers and comparison swapped

silver fern
#

possibly you're doing something else wrong if the amount of garbage is causing you to run out of memory

real thunder
#

do you care about allocations only when you running out of memory?

silver fern
naive pawn
runic lance
#

well, 1mb of allocations per frame should have a visible impact depending on platform

#

and it should cause a lot of fragmentation, it definitely should be avoided

naive pawn
#

oh wait, Array.Sort does have a Comparison overload lmao

#

i overlooked the "show more" here 💀

real thunder
#

so arbitrary 😔

naive pawn
#

ooh, the overload you're using isn't generic either. maybe there's some boxing going on as well, since RaycastHit is a struct

silver fern
#

can you use RaycastNonAlloc?

naive pawn
#

they already are

real thunder
#

if I was using with alloc I had no issue of not having an overload with indexes

twin pivot
naive pawn
#

i think i might see the overall picture now, though i'm unsure (and frankly i'm not too experienced with the internals here so i have some doubt at every step)

  • the overload you're using is non-generic, and RaycastHit is a struct, so there'll be allocations for boxing
  • the overload using Comparison is generic, and wouldn't have those allocations
    so if i'm understanding it correctly, the difference isn't in Comparer vs Comparison exactly
real thunder
#

I mean I can likely reduce the number of calls by like once each 0.2 sec or avoid using it at all somehow
still
the simple task of sorting an array of raycast hits should not take that much allocation, I think I have to find a proper way to sort it or write my own

naive pawn
real thunder
naive pawn
#

if you just need the first or last one for example, that would be an O(n) time O(1) space operation

naive pawn
runic lance
#

depending on the amount of elements being sorted, you could get away with some pretty dumb and easy to implement sorting algos

#

if you cannot just get the first/last one

naive pawn
#

-# bogosort for 3 elements let's gooo

runic lance
#

how bad could it be 👀

naive pawn
#

anywhere from [0, inf) iterations

real thunder
# naive pawn the fastest way to sort is to not sort at all if you don't need it so, what's th...

I use raycastall for 2 things
first is shooting, and it have unreasonably meaningful penetration mechanic taking into account different body parts and order of them being penetrated
second is checking if the target is in reach, which is a pretty dumb case yeah
(I can't raycast once because that ray need to go through other possible targets like if they are blocking the target it's still need to be valid)

naive pawn
#

just so we're on the same page -

  • you're referring to this specific RaycastAllNonAlloc being used for 2 purposes, right? not separate raycasts
  • the second one here wouldn't require sorting, right?
real thunder
#

second would require sorting because it can also hit a wall at any point before meant target

#

I am not sure what you mean by this specific, no, they are in different scripts running at different times from different points

naive pawn
naive pawn
#

the one you posted about

real thunder
#

code piece I copypasted look the same for both

naive pawn
#

the second wouldn't even need raycastall thonk

#

have a raycast that's the distance to the target, masked for obstacles, if it hit some obstacle then you can't hit the target

#

but yeah i can see how sorting would be ideal for processing the first case

real thunder
#

imagine if there is an enviroment with walls
and there is a crowd characters (they all have same layer)
I want to check if one particular member of the crowd can be reached
through other characters would also be valid

naive pawn
#

yeah the raycast just wouldn't account for the other characters, that's why i said masked for obstacles

#

i guess that was ambiguous, i meant having a mask that would only have it hit obstacles

#

(this isn't super relevant to your original question, just kinda thinking out loud. we can go back to the original question if you want)

real thunder
#

Raycast against a specific collider but also accounting layers?

naive pawn
#

raycasts always account for layers

real thunder
#

to skip confusion I ll just ask how

#

what API specifically

naive pawn
#

oh wait 3d has Collider.Raycast, i'm not referring to that one

naive pawn
real thunder
#

I don't see anything I coud use

real thunder
naive pawn
#

i'm referring to a raycast that would not hit any characters

real thunder
#

then it won't hi...

#

wait I think I got it

#

lol

naive pawn
#

i guess it would need a Collider.Raycast first to determine the distance

real thunder
#

the distance is known beforehand

#

since I know against what agent I am checking hence I know position

naive pawn
#

the max distance, or the distance to the collider?

naive pawn
#

i guess it's hard for me to say without knowing the full picture of what the input data points are

real thunder
#

it's just a condition for a mob if he is within target reach
so he can start backpedaling
won't make sense backpedaling if target is behind a wall

naive pawn
#

what if that wall is waist height

real thunder
#

still backpedaling

naive pawn
#

i definitely have the wrong picture in my head about what the scenario is lol. i can't make useful pseudocode for that, so i guess this is for you to design lol

naive pawn
real thunder
#

honestly fine with me
that game have pretty basic leveldesign and AIs
ik ideally I d need to have several points on a target to check against but...

twin pivot
naive pawn
#

that doesn't seem helpful for the situation tbh

real thunder
#

I do check for an interface already

#

now I should't tho

#

just raycasting only against obstacles is simple yet clever

naive pawn
#

would probably be good enough.. i think

real thunder
#

I just need that thing to know if player is in LoS to decide if it need to backpedal or push forward (there is also code checking for angles, and other stuff I don't really remember...)

naive pawn
#

oh i thought this was for humanoid characters lmao

#

yeah ok this is fair enough

real thunder
#

like if it's too close it needs to backpedal
unless no LoS

#

this is a gentle tank it won't crush you it keeps distance

#

I highly regret deciding to just make a reasonably smart tank in a simple game

#

at the same I don't because look it works, what a waste of time tho...

cosmic dagger
stable atlas
#

guys what course would help me understand C#

frail hawk
#

check the pinned channel messages

austere yew
naive ferry
#

hey I just posted a query in the Code-General for Weighted Randomiser system. Please if someone could help me with that It will be of help. :3

worldly mural
#

quick question, is there any easy way to learn how to convert old code to the new unity input system?

naive pawn
#

"easy" is subjective, the most effective way would be to learn both

shell wing
#

hi guys, New here, I have a question about a code not working right(probs new user error) is like 10 lines of code, it is supposed to give me camera rotation with the Horizontal input but is going opposite. non of my values look negative , any help?

frosty hound
#

You haven't shared anything that can be helped

shell wing
#

using UnityEngine;

public class RotateCamera : MonoBehaviour
{
public float rotationSpeed;

void Update()
{
    float horizontalInput = Input.GetAxis("Horizontal");
    transform.Rotate(Vector3.up, horizontalInput * rotationSpeed * Time.deltaTime);
}

}

#

the issue i have is that when i press a or d to rotate is going the opposite way.

twin pivot
radiant voidBOT
shell wing
#

thank you i was looking foor that

wintry quarry
#

or just set your rotationSpeed to be a negative number in the inspector

shell wing
#

got it that worked i changed vector3.up to down.

wintry quarry
#

That will work too

dreamy lance
#

can anyone help me get it so that my tiles strech and fill the my grid ? id send my code but idk whats the best way to do it ?

#

it seems to be using the grid size for scaling but it doenst conform to the actual grid

fickle plume
dreamy lance
#

thats cool and all but.. i need to to jsut stretch to match the grid cell size... and also the rotation isnt takeing etiher

fickle plume
#

If you are using flat tops you should just adjust the tile

dreamy lance
#

i meed it to just take the orienttstoon and the size of the grid genorsted but ya i should prob just stick to one orientation

#

that still doesnt fix the fact that it doesnt tile to the grind correctly

#

but ya ill just make it flat tops only

fickle plume
#

Adjutst pivot point on the sprite to match pivot used by tile grid

#

Or change tile anchor on the tilemap

dreamy lance
#

cool ill figure out how to do thag

#

i tried just changing it in the little drop down to "center" but it was imfact not center

fickle plume
dreamy lance
#

this might also be bcs im trying to get 2d tiles to work in 3d

grand snow
#

its fine to use it this way but in the past I made my own hexagon grid because i wanted to change the offset to be opposite

eager stratus
#

Say I want a list of Actions that all have different parameter requirements. For instance I have a list that points to a Brave() function which takes no parameters and an Attack(Combatant attacker, Combatant target) which takes two Combatant object parameters. How would I go about putting these in the same list especially if I don't know what I want the two parameters in Attack() to be yet (as that is intended to be what the function I'm passing it to is meant to figure out)?

#

I assume I'd need some kind of really generic delegate and then cast it as the type of delegate it's supposed to be with the parameters it's supposed to use in the function I want to pass it off to but I don't know if that's even possible let alone how I would do it

grand snow
#

Reflection to make core functionality like this work would be a bad bad idea

eager stratus
#

But the commands would be very different for each menu

grand snow
#

Then use a class to contain this data that you can inherit and modify

#

instead of trying to set up many functions you can have many sub classes

eager stratus
grand snow
#

This is why virtual methods exist

#

you can have a virtual method with the base type as the only arg (or even just object) to overcome this

eager stratus
#

Before they all had the same signature (void(StatBlock source, List<StatBlock> targets)), but then I realized one of the commands would have to operate with a very different signature (void(StatBlock source))

#

I mean, I guess I could just have List<StatBlock> targets always be passed as null whenever this function is actually used, but it seems like there's a better answer than that

grand snow
#

Then lets step back. If these things can take different arguments how were you even planning to call them in the first place with these args?

grand snow
#

Your first message describing a "list of actions"

eager stratus
#

One is supposed to take two arguments and one is only supposed to take one

grand snow
#

If you have a generic menu of many buttons then you should just inherit from some common type that provides a general way to do the task

#

Its why interfaces exist too

#
if(menuItem is IThingWithTargets thingWithTargets)
{
  thingWithTargets.DoStuff(source, targets);
}
eager stratus
# grand snow Interfaces: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/i...

Yeah, I had something like that before. It was an abstract class with two children. One contained an Action<StatBlock, List<StatBlock>> that could be directly called on to be executed (as well as the actual command name that was part of the abstract) and the other was a child that took on a list of these Action<StatBlock, List<StatBlock>> command objects which could be used by the same function to create a submenu if it was called upon to do so. The wrench comes in because, in theory, I would have to now make a third time which just takes in an Action<StatBlock> as its action. But seeing as I really don't think I'll ever be using this beyond one very specific function I'm wondering if there isn't a cleaner way to do this

grand snow
#

I think you are making things harder on yourself by trying so hard to use delegates

#

I dont really understand enough (about your case) to say anything else useful to change your mind either

#

You can surely have a class to fully contain some state of an "action to perform with data" which can be invoked via 1 single shared function (interface/base class)

eager stratus
grand snow
#

just make the class or handle a null arg 🤷‍♂️

eager stratus
grand snow
#

That is the clean way

#

Sounds like its easy to add support thus showing its "clean"

#

again i lack context to say more so im gonna check out from this chat

eager stratus
#

It just feels weird that I'm put into a position where, in order to open the command menu in the first place, the very function that does that has to take a list of targets that it will never get and never use. It just sounds really unintuitive and nonsensical. I think that's what's making me feel like I'm doing something wrong

inland lark
#

are there any tutorials you guys like for making a top down rpg? i have my map and characters, just trying to put everything together

rich adder
#

You breakdown the game into several different parts you solve / put together. Following someones entire system is never a good idea, you will find yourself in a hole you can't get out of easily because you already committed " their way" of doing things. You should be looking at individual things, and if possible multiple sources on it so you can get better at making it yourself.

eager stratus
eager stratus
golden canopy
#

guys im kinda confused on how to implement this stair detection in my game

#

ive watched almost every video but none of them adress the problem

sour fulcrum
#

Stair detection?

grand snow
#

There isnt a youtube video for everything

frail hawk
#

i am assuming they want to go up and down stairs, in this case i´d just use a ramp as collider, which i think most of the games do

#

at leats the easiest way to solve it

grand snow
#

There are plenty of examples of this in source engine maps and community hammer videos

sour fulcrum
#

Even for spirals 😄

grand snow
# golden canopy guys im kinda confused on how to implement this stair detection in my game

https://www.youtube.com/watch?v=d5B9ytF6gas
relevent to the above discussion

Stairs in CS:GO are literally unplayable in SO many ways. Come with me on an exciting journey through history, looking at how stairs are clipped in Counter Strike games. Isn't this exciting!

0:30 - CS 1.6
0:56 - CS:S
1:42 - When did Valve start caring about clipping stairs?
2:30 - CS:GO (Early versions of maps)
3:07 - First step clipping issue!...

▶ Play video
sour fulcrum
#

Was gonna link that but philip abit weird lately ngl which sucksss

grand snow
#

Just put a nice smooth collider over your stairs.
Capsule colliders may already be able to push over jagged stairs otherwise you do need special logic to handle it

grand snow
regal marsh
#

hey yall, i want to lerp a number from x to y then i want the number to lerp again from y to x, im facing problems with the while loop that im using inside my coroutine, could anybody help me with solving this? , if anybody want to see my code and get more info to help me you are welcome in the dm

naive pawn
#

!code

radiant voidBOT
naive pawn
#

send it here.

regal marsh
#

alright

#

i send it

#

;}

grand snow
regal marsh
#

ohhhhhh

#

this is my first time doing this sry

#

so i gotta make a page for the code then send the link for it ?

#

this is it

naive pawn
#

so what's the issue?

grand snow
#

where is timer set? looks like a mess

naive pawn
#

what's the intended behavior

#

seems like there's a lot of stuff in that second while that should be outside

regal marsh
#

i want to make an object moves all the time like forever at x speed like it is swimming in space and every 5 seconds make a dash smoothly then return to normal speed

grand snow
#

Id use MoveTowards and temporarily increase the max step

naive pawn
#

then you'd need the coroutine to go on forever

regal marsh
#

yeah and im using invoke repeating to repeat the process every x second

grand snow
#

Yea dont do that

regal marsh
#

what :/

grand snow
#

Its not wise to mix that with a coroutine

#

you can do it all in 1 coroutine that keeps running as Chris stated

regal marsh
#

but then how to make the coroutine stop for amount of time

naive pawn
#

Invoke/InvokeRepeating are relatively inflexible, it's much easier to just manage it all with coroutines

regal marsh
#

alright

naive pawn
regal marsh
#

so after it exits the second while loop i make wait for amount of time then it would go to the first loop

naive pawn
#

so, a looping behavior

#

you would have another loop covering the inner 2 loops for that

regal marsh
#

a loop that has two loops inside it? :/

grand snow
# regal marsh a loop that has two loops inside it? :/
while (true)
{
    float timeA = 5f;
    while(timeA >= 0)
    {
        //do stuff
        timeA -= Time.deltaTime;
        yield return null;
    }

    float timeB = 3f;
    while(timeB >= 0)
    {
        //do different stuff
        timeB -= Time.deltaTime;
        yield return null;
    }
}

Perhaps a setup like this would be best

regal marsh
#

thanks ❤️

cursive mango
#

Hmm I've done some of the Unity Learn beginner projects but Idk I feel like I didn't really "learn" what I followed with. I think Ima just start making something and figure it out im like a more hands on person 🤔

grand snow
cursive mango
grand snow
cursive mango
#

like my first interaction im just like ok what do I even do 😂

sour fulcrum
# regal marsh alright

This applies in general btw, not just in this situation. never a good reason to use invoke

faint totem
#

Hello, I want to implement delay to button press action, but i'm not sure if solutions I found on forums won't hold up my script.
Things that i found revolve mostly around using "CooldownTime-= Time.deltaTime;" and if statement in update. Since I'm not experienced I'm not sure if it wouldn't be better to just us IEnumerator to do the delay independently. Code I want to use it in is quite long and I would love to know which method is more optimal.

sour fulcrum
faint totem
frosty hound
#

But a cool down with a timer is better. 🫣

strong wren
faint totem
#

but ty for the answer

naive pawn
strong wren
faint totem
#

sure

golden canopy
# grand snow There are plenty of examples of this in source engine maps and community hammer ...

im so sorry for the late reply lol, i have seen them briefly but i trying to implement a floating collider that floats above the ground so stairs beneath them automatically push it up, the only two solutions i know are either hard forcing the transform.pos to snap them to the ground and one is a physics based spring system, none of them allow external forces to override the snapping (for example jumping and stuff)

#- sorry for low quality lol

sour fulcrum
#

Rigidbody move

golden canopy
#

the spring equation F = (x * k) - (v * c) works very well to keep him on the grond but the issue is its also pulling down, i dont know how i could suspend i apply other forces,

golden canopy
#

okay so i kinda solved it, if you guys would maybe want to know id drop the snippet

#

sorry rob for da ping UnityChanThink

#

time to clean da codeeee

silver fern
#

does anyone have a good solution for how to make a character selection for an online game using mirror?

silver fern
#

alright ty

lethal grove
#

like, it doesn't move right, the models shakes a little

grand snow
tender mirage
copper sigil
#

Is there a quick way to find the class name of a given component? (e.g. TextMeshPro - Text -> TMP_Text)

naive pawn
naive pawn
lethal grove
#

I've got no clue what my teammate is doing

naive pawn
# lethal grove

if you're going to share this much, share it properly please

#

!code

radiant voidBOT
tender mirage
inland lark
#

how i speed up the load time the project browser

naive pawn
tender mirage
#

Like chris mentioned, fixed update vs update can cause this.

naive pawn
#

i did not state that

#

i'm asking for more info

tender mirage
#

Yeah, mentioned. I was just about to correct that.

naive pawn
copper sigil
lethal grove
#

oh

naive pawn
lethal grove
#

sorry

naive pawn
lethal grove
#

These are the attributes

naive pawn
#

for built-ins, there's also the question mark icon that brings you to docs, but that seems to.. not be ideal in the case of components from modules

naive pawn
# lethal grove These are the attributes

ok, so a dynamic (non-kinematic) rb
MoveRotation and MovePosition are intended for kinematic rbs, so using them on a dynamic rb can have some interpolation issues.
if you want a kinematic rb, well, make it kinematic
otherwise, move it with other methods (other than MovePosition/MoveRotation)
also enable interpolation, and afaik you'd want continuous collision detection as well

#

though, as mentioned before, also check if your movement code is in update or fixedupdate, and check if it's the camera or the player that's stuttering.

lethal grove
#

Thanks! I'll take a look on all of that

fickle stump
#

Is there a way to temporarly disable a method?

#

im dumb i got it

slender nymph
#

Is an if statement where you call it or in the method body not sufficient?

fickle stump
#

i literally struggled with methodName.enabled = false

#

🤦‍♂️

charred monolith
#

!help

sly hollowBOT
#
​No Category:
  help Shows this message

Type !help command for more info on a command.
You can also type !help category for more info on a category.
radiant voidBOT
# charred monolith !help
<:emote:1416393040439939103> Available commands

Use !help <command> to get more information

!help
!info
!list
!ping
!avatarinfo
!bannerinfo
!guildbannerinfo
!guildiconinfo
!guildmembercount
!guildsplashinfo
!searchdocumentation
!stickerpackinfo
!report
!warns
!support

sly hollowBOT
#
​No Category:
  help Shows this message

Type !help command for more info on a command.
You can also type !help category for more info on a category.
charred monolith
#

!list

radiant voidBOT
charred monolith
#

!info

radiant voidBOT
charred monolith
#

guys im looking for a website designed for code so i can share it

#

like paste.mod but website is down or sum

naive pawn
#

man please don't spam these lmao

#

!code

radiant voidBOT
naive pawn
#

there's 4 options there, i think the first 2 are dead

#

use the 2 others

charred monolith
naive pawn
#

for future reference you can also just google "pastebin" (that's what these sites are called)

naive pawn
nova dagger
#

Hey I need advise, trying to learn Unity for game projects, trying to currently make like a party selection but I'm completely lost, where should I be going to improve my own learning so I can get better idea on what's supposed to be done?

radiant voidBOT
vapid egret
#

hello everyone.

#

I currently have a sprint in my character movement that modifies the camera lens fov. Unity keeps asking me if I want to save after I end play mode. Is there a way to stop that prompt without turning all other prompts like that off?

charred monolith
#

hello

ornate swift
#

hi guys

verbal dome
valid stone
#

So I want to put a "blank" white circle inside another circle to form a donut esque thing, nothing going wrong with that of course, but the problem is that I want to make their radiuses dependent on public variables and I'm having the error below
Assets\BalancingScript.cs(9,32): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Component.transform'

with my code being

using UnityEngine;

public class BalancingScript : MonoBehaviour
{

    public float normalRadius = 5;
    public float invertedRadius = 4;
    Transform NormalCircle = transform.Find("NormalCircle");
    Transform InvertedCircle = transform.Find("InvertedCircle");
    Vector3 normalScale;
    Vector3 invertedScale;

    void Start()
    {
    }

    void Update()
    {
        normalScale = new Vector3(normalRadius, normalRadius, 0);
        invertedScale = new Vector3(invertedRadius, invertedRadius, 0);
        NormalCircle.localScale = normalScale;
        InvertedCircle.localScale = invertedScale;
    }
}
verbal dome
#

Modifying scene objects like a camera during playmode shouldnt prompt anything like that @vapid egret

#

Maybe you have some editor window open that is prompting it, like shader graph or some other asset editor

verbal dome
valid stone
verbal dome
#

Although the best way is to make it serialized and assign in the inspector

verbal dome
valid stone
verbal dome
#

[SerializeField] Transform NormalCircle;

valid stone
verbal dome
#

public is serialized too but we dont need it to be public here

valid stone
#

The same place as usual?

verbal dome
#

Same place yes

#

It will have a null (none) value by default

#

So you need to assign it in the inspector or in Start

#

Inspector reference is usually preferred

vapid egret
#
Modified objects include:
Player/PlayerCamera```
verbal dome
#

Oh, cinemachine. That was not obvious to me

#

No idea

swift crag
#

I believe there's a toggle for that?

vapid egret
#

Do you know where it is? I've been looking around and I've found prompt settings that will turn all warnings like that off, which I don't want. My camera is working as intended though

#

Should I ask in the Cinemachine channel?

fickle stump
#

Heya! Is there a way to make exceptions to disabling all InputActionAssets? :<
Basically In a dialogue scene i want to disable all player inputs except the continue key! Or can anybody think of a smartwer way :<

swift crag
#

You can have a "Gameplay" map and a "Cutscene" map

swift crag
#

(it won't silently start saving the changes)

swift crag
#

By default, nothing you do in play mode will permanently change your project

#

well, nothing done to objects in the scene 😉

fickle stump
swift crag
#

an InputActionAsset contains many InputActionMaps

#

each InputActionMap contains many InputActions

#

which are individual actions

#

for example, my game has maps like:

  • "Humanoid"
  • "Spectator"
  • "Menu"
sand field
#

What is the proper way to teleport a player (using CharacterController and Starter Asset's FirstPersonController)

This is my current function, and it logs that it successfully placed me at Spawned at Entrance: (0.00, 0.00, 0.00), but in reality I am in the exact coordinates as the previous scene I came from.

https://paste.myst.rs/cuk9ddfb

vapid egret
radiant voidBOT
fickle stump
#

jesus christ

sand field
#

My bad

fickle stump
swift crag
#

why not?

fickle stump
#

I tried to disable a specific event before where the player can move, but then he's still able to turn around.
And I couldn't think of a way where if I make a seperate input map that I can stop the movement input and have a dialogue input

swift crag
#

you can disable and enable individual maps

rich adder
swift crag
#

so, when the game starts, you enable Gameplay and disable Dialogue

swift crag
#

when you enter a dialogue scene, you toggle both

fickle stump
#

wait

#

I'm astro stupid kekw

#

you're right

#

10h of work + unity back to back might fries my brain a bit too much UnityChanThink

swift crag
#

Just make sure that you always re-enable the gameplay map when you're done

#

I have a controller whose job is to look at the current game-state and decide which maps should be active

#

e.g. if the player is controlling a humanoid entity, then turn on humanoid actions

fickle stump
#

i see

#

makes sense

#

I'll try aroudn

valid stone
fickle stump
#

@swift crag how are you assigning the action maps? Are you looking for the Player Input and then are able to access the maps somehow? I mean I can't just Serialize them and put them into the inspector... right?

#

Wait can i 🤔

swift crag
#

There is no InputActionMapReference, yeah

tired python
#
void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Entered Trigger.");
        CollidersInRange = true;
        Debug.Log($"{collision.gameObject.name}");
        _particleSystem.trigger.AddCollider(collision);
        fart();
    }

https://paste.ofcode.org/bBVt6v6LSWUxZvcnyW9PGy

swift crag
#

You have to get them by name from the asset (i believe PlayerInput can give you the maps, too)

radiant voidBOT
tired python
#

@rich adder these two objects are triggering

#

both of them have only one box collider

fickle stump
#

well you don't declare what collder it should look for right?
You're saying anything that enters, causes a collision

fickle stump
tired python
cunning narwhal
#

Just following up on git questions. Am I doing this right? When I want to make a change, I

  1. create a new branch from main with some short description of the changes,

  2. commit and push all local changes to this new branch,

  3. then when done merge the branch back into main

#

Or am I using git wrong?

fickle stump
#

We're lacking infos how your scene is set up

grand snow
fickle stump
# cunning narwhal Just following up on git questions. Am I doing this right? When I want to make a...

Branches are more for different experimential features or if multiple people work on different stuff and don't want to push it onto the main project without testing first.

I recommend having a testing branch, where you implement new stuff, depending on size of the project you can also have multiple branches for different features and later merge them. Idk if I would create a new branch everytime I want to change smth

slim solar
#

Aye bros, any idea why my values don't seem to be surviving editor close/open?

[SerializeField, ReadOnly] int persistentGuid = 0;
#if UNITY_EDITOR
void OnValidate(){
if (persistentGuid == 0)
        {
            persistentGuid = Random.Range(0,1000);
            EditorUtility.SetDirty(this);
        }

}
#endif
sour fulcrum
#

that code wont build btw

#

editorutility is editor only

slim solar
#

There, i just quickly pasted the nessecary parts.

#

It works just fine but persistentGuid doesn't seem to be serializing (OdinInspector's SerializedScriptableObject) and is set to a random number each time

#

Specifically the persistentGuid just isn't saving and im not sure how to save it. Ctrl+S doesn't save all assets apparently

rich adder
cosmic dagger
slim solar
#

even if i just set it to 42069

#

Okay I finally got them to save by adding AssetDatabase.SaveAssets(); i there but I don't see why it's nessecary, surely there's other ways to save dirty assets

#
    static Database _cachedDatabase;
    void OnValidate()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode) return;
        
        persistentID = name;
        if (persistentGuid == 0)
        {
            if(!_cachedDatabase) _cachedDatabase = Resources.Load<Database>("Database");
            persistentGuid = _cachedDatabase.GlobalGuid;
            _cachedDatabase.GlobalGuid++;

            EditorUtility.SetDirty(_cachedDatabase);
            EditorUtility.SetDirty(this);
            AssetDatabase.SaveAssets();
        }
    }
#endif    ```

There we go. Now that they actually save, every single scripted object will automatically get a unique string and a unique ID starting from 1 (rather than a massive guid number)
inland lark
#

my project is loading so slowly, how can i do some kind of performance audit or something

rich adder
#

try deleting / refreshing cache

#

delete library folder

gaunt cipher
#

Is there no way to outline text in a textmeshpro on a per instance basis without having to create a material preset?

queen adder
#

hello

ornate swift
#

anyone knows why my water is always pink

#

I have rtx 3060... Its enough ig 😭

#

i guess no one

keen dew
#

Not a coding question. Read the asset's documentation, it has instructions how to convert it to the render pipeline you're using

grand snow
ornate swift
#

My bad, i thought it had something to do with coding

#

Im so lost in unity 💔

grand snow
unkempt holly
#

how can i save and load game?

unkempt holly
#

thank you

night raptor
# unkempt holly how can i save and load game?

Google is a good resource though probably the first thing that comes up is the Brackeys tutorial on save and load system, don't watch that. It uses the binary formatter which is not safe and should never be used for anything (the vulnerability wasn't known when the tutorial was made). I'm not sure if you can even use it at all anymore, at least it should show a warning every time it's used.

rich adder
# unkempt holly how can i save and load game?

Saving data is critical for any game. Whether you need to save high scores, preferences, or game state, Unity offers a variety of methods – from PlayerPrefs to serializing data, encrypting it, and writing to a file. In this video, we share some valuable tips on creating data persistence in Unity.

Speaker:
Bronson Zgeb, Senior Content Develope...

▶ Play video
fickle stump
#

https://paste.ofcode.org/mYscMJUwkNjeiD2KgyBSNf

I've been trying to make a simple mini game where everytime I press space I inc a number, which is a number on a slider, which then will increase, aslong as I don't reach the final goal. Everything works semi fine aslong as i don't use Time.deltaTime. I know however that I need that, otherwise my value will perma decrease way too fast.

If I use time.deltatime I'm instead not loosing value, but fruthermore increase it.
I think it's a small mistake somewhere but I can't figure it out rn

rich adder
#

nothing is “wrong” with Time.deltaTime itself

#

seems you decreasing slowly over time
increasing in big instant chunks

fickle stump
rich adder
#

not Time.deltaTime at all

strange gate
#

Hey guys! I was wondering if anybody could give me advice. I am making a game in which you have spells that automatically activate every set given of time, but Im not sure how I should go about doing that. Is it optimal for me to make a base class for the spells that have most of the base functions for the spells and then for each spell I code I make a new file for the spell which extends the base?

fickle stump
#

scriptable objects for each spell probably

strange gate
rich adder
strange gate
fickle stump
rich adder
#

this is older code, an yes normally I use properties but was for a jam years ago xD

fickle stump
rich adder
fickle stump
#

Oh intressting. Def. need to read up more about the callback context

rich adder
#

always check the manual / docs

#

its overwhelming at first, because there is a lot there and much you can do

fickle stump
#

Yeah I've been doing that the last couple of days. Learning a lot the last few days, so my mind is a bit overloaded with infos

#

thinking about it 5 days ago I couldn't write a single line of code haha

rich adder
#

I started with the older Input Class, very limited but got the job done..
tbh it took me almost a year / committ to kinda grasp the new input system and still there are new things I'm learning

fickle stump
#

Learned about action maps yesterday and how to change the input depending on what kinda scenario I wanna do. Pretty neat

rich adder
#

yeah they have really good features, I'm glad they swiched it . You had to use assets to get this in depth before and even then it wasn't as good

#

the interaction type you can do etc. really cool

fickle stump
#

hm anow that i think about it, with the new input controller i could technically easily support gamepads 🤔

rich adder
#

ya it also supports specific gamepad types or other devices

cursive mango
#

Hmm so I was able to make a version of pong but I did have to google a bunch of stuff with making the scripts and stuff. I still feel like I need a lot more time practicing with these scripts and writing the code before I start trying to make out something of my own. If anyone has some advice or tips when it comes to scripting, feel free to let me know I would appreciate it a lot. (Just trying to not watch these tutorials and copy paste since I'm more of a hands on learner)

slim solar
# strange gate Hey guys! I was wondering if anybody could give me advice. I am making a game in...

Heya. If you want a very advanced version of this you can have objects that all use the same scriptable object code but let you select the spell functionality from a dropdown.

Just make 1 scriptable object calls SpellData or something.

Then make a class called “BaseSpell” and put [System.Serializable] above the class name. (It should not extend monobehavior)

In the scriptable object make a variable called

[SerializeReference]
public BaseSpell SpellCode;

Now you can make many spells using the same spelldata object, and each one lets you select the BaseSpell class to be used. Sort of like selecting which brain the spell will use. Much simpler than creating a ton of different scriptable objects

(Btw im on mobile sorry for no code formatting)

I use this all the time for enemies and their ai, weapons, etc. its cool cus you can duplicate enemies/weapons and just swap the ai.

strange gate
copper sigil
#

I'm trying to create a top-down character and I've set my player's Rigidbody2D to be Kinematic.
I have a test object with another Rigidbody2D that is set to be static.
The player walks straight through the test object, and I haven't been able to figure out why.
This is the player's script (minus some boilerplate)

    ...
    public Rigidbody2D body; // assigned RB with inspector
    ...
    void FixedUpdate()
    {
        body.MovePosition(body.position + (moveAction.ReadValue<Vector2>() * Speed) * Time.fixedDeltaTime); // Speed is a constant and I'm using the new Input system.
    }

Is there some alternative function I'm supposed to be using?

copper sigil
grand snow
#

do the walls have a rididbody2d set to static?

copper sigil
#

it shouldn't be able to go into the red square

#

but it can

#

ehh whatever I'll just make them both dynamic, thanks for your help

slender nymph
grand snow
#

the fuck, they say "it will collide" so

slender nymph
#

When this happens, collision callbacks will be produced when kinematic/kinematic or kinematic/static pairs collide although no actual collision response will happen. In other words, callbacks will happen but the Rigidbody2D will allow colliders to overlap similar to the situation when a Collider2D is set to be a trigger.

slender nymph
slim solar
#

How to start the base class

[System.Serializable]
public class WeapBase
{```

And how to use it in your scriptableObject, so you can also change their custom variables:
```cpp
[Title("Weapon Code")]
    [NonSerialized, OdinSerialize, InlineProperty, HideLabel]
    public WeapBase WeapCode;

I'm using odin inspector but it's prob similar without

slow blaze
#

I'm trying to rotate my camera (the player's vision) according to my mouse movement, I'm in first person and I locked the cursor itself but I wanna rotate right when I move my mouse to the right and vice versa
how can I achieve that?
I tried doing smth like this

        _virtualMousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);
        Quaternion rotation = Quaternion.LookRotation(_virtualMousePosition);
        transform.rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0);```
but I'm unsure of the validity of this as the cursor is locked (and also the rotation does not work) 
is there a way to not rely on the cursor?
slender nymph
#

You should be using the mouse's delta, not it's position

#

When using the input manager, there is an I out axis set up for that already

slow blaze
#

so something like this?

    void RotateWithMouse()
    {
        InputAction lookAction = InputSystem.actions.FindAction("Look");
        Vector3 mouseDelta = lookAction.ReadValue<Vector2>();
        _virtualMousePosition = mainCamera.ScreenToWorldPoint(mouseDelta);
        Quaternion rotation = Quaternion.LookRotation(_virtualMousePosition);
        transform.rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0);
    }```
slender nymph
#

Why were you using the input manager in the previous code and now using the input system? Are you just generating code with AI or something

grand snow
slow blaze
slender nymph
#

Even still what you have is very wrong. As was pointed out you shouldn't be using a position at all. The delta will just be the number of degrees to rotate that frame. Also do not find the look action every frame. That's pointless, store it in a variable to reuse it each frame

vernal ledge
#

i've used a tool before that optimizes the project, now i lost the tool. the thing is, outline drawing is changed

#

i've put a material into a 2d sprite

#

it was okay, it was rendering as it should like a contour

#

however after using that tool, the renderıng changed

#

it got more harsh

#

does anyone know a setting related to this

hazy basin
#

yo guys, I'm new to this sevrer

tired python
# rich adder Why does that have rigidbody without collider btw

some of the children have colliders on them, i remember reading somewhere that the rb gets inherited by child objects unless you attach an rb for every child which has a collider attached to it, in which case, each of those colliders will act differently

dawn wave
#

I am learning about AudioSource right now and it seems like any given AudioSource component can play only 1 audio clip at a time and if you were to try and play, let's say a gunshot sound but a gunshot sound is still playing, then the first sound would immediately end and the new sound would play. After googling around, is it correct that to work with this "only 1 clip at a time per AudioSource component", I'm suppose to have X amount of AudioSources already ready to play the exact same sound or possibly dynamically add AudioSource components?

tender mirage
#

Oh wait, this is the code channel. Why are you asking this here?

dawn wave
#

oh lol oops

tender mirage
dawn wave
#

got it sorry, and thanks I'll check out what you said. It just looked silly to have so many audio source components get spammed in the Inspector so I thought I was doing something wrong

golden canopy
#

does this make me a professional tehe

slender nymph
#

You do know that is only inside the outer if statement, right?

golden canopy
#

i just realised that lmfao

lament halo
#

Can someone share me a method how do I plan on making a game? We have a capstone project ongoing and all of my ideas just scattering around on how I map the excel file to JSON

#

For example a turn based game, it's a simple me action, end turn and then enemies turn but by the time it has game conditions, passive abilities, debuff and etc this is where I get bamboozled on what's going on with all of these

fickle stump
#

blink

Why does my InputAction trigger on other keys in certain situations, I'm so confused notlikethis

slender nymph
#

You're missing a semi colon on line 14

lament halo
#

I installed obsidian but I still don't know where to map things out and what to include for my json file aside the ID, Name and description

golden canopy
slender nymph
#

if it's any consolation, that array doesn't live outside of the method so it gets cleared at the end of the method anyway

wintry quarry
#

empty it? Wdym? It's going to get garbage collected

slender nymph
#

how about you provide actual useful information about your issue and someone can help you instead of expecting people to guess at what the issue might be

native widget
#

why my firebase code cause my unity to silently crash with no logs?

#

it works in editor, but on windows build, the app just forceclose

wintry quarry
#

you would have to share the code and include how you hooked up the input action asset to the code as well

wintry quarry
fickle stump
#

Yeah I'm stupid, I figure it out.
Why do I always figure it out after I type it out <-<

native widget
wintry quarry
#

for some reason none of all these pastebin links are loading for me

#

maybe because I'm travelling abroad right now

native widget
#

I just want to play in a window build and editor at the same time, for multiplayer testing

#

does firebase hate that?

dusk herald
#

anyone has a clue how import models from blender into unity ? it keeps fucking up my model

fickle stump
fickle stump
teal viper
spark laurel
#

what is a good program to write the code in atm i am using JetBrains but it keeps showing errors and doesn't compile correctly. is there a different program i can use?

wintry quarry
#

JetBrains Rider, or something else?

spark laurel
#

its JetBrains Rider 2, I'm following a video on you tube and write the code exactly like its written in the video but it just keeps showing a bunch of different errors, when i get to the part of the video that shows a test it doesn't work. if i listed all the errors ill be here all day

wintry quarry
#

Have you installed the Jetbrains Rider Editor package in Unity?

#

And have you set unity's external code editor to be Rider?

spark laurel
#

sorry i misread its JetBrains Rider 2025.3.2

wintry quarry
#

ok good, you should continue with setting up as per that link.

spark laurel
#

everything appears to be setup correctly, maybe its just me ill go through everything again maybe i missed something that's causing the code to freak out

wintry quarry
#

And your external editor in Unity is set as Rider?

spark laurel
#

yes

wintry quarry
#

Can you show a screenshot of the "freakout"?

fickle stump
#

Rider is one of the better IDE imo

smoky mural
#

hey people, Im having a couple issues with loading prefabs from bundles in the editor since the game developers swapped to asset scenes.
they allow us to make custom maps etc for the game and i was using the editor outside of runtime could load prefabs etc with coroutines
since they swapped to asset scenes my map editor cant load prefabs from the bundles any more and ive been stuck in this loop of using a closed source
runtime application to manipulate the prefabs in my maps and then using unity to do terrain and splat etc etc

#

ideally id like to keep my workflow in unity outside of runtime if possible as it lets me use custom editor scripts and assets from the asset store to aid in making maps.
if anyone has any idea about how i can get this fixed up id be greatly thankful

sour fulcrum
#

We can’t help too much, sorry

#

This server can’t support modding

broken meteor
#

is there a way to figure out the rect transformation size for a canvas? Not sure if anyone understands what I mean there so I'll try to explain what I'm doing- I want to know the min and max X and y points of a canvas, as the player can drag around a image and I want to make sure it cannot go off the screen, I also need the size to help kinda scale certain variables I'm using.

Not sure this matters, but I'm building a game for android so I'm currently using a Canvas scaler as well.

What I've tried- Not much honestly, I'm quite stumped on how to approach this, I could have the player kinda as a calibration to move a slider to both ends of their screen, but thats going to be inacurate and annoying. I also searched my problem up online and didn't find any information that lead me in the direction of a solution.

broken meteor
#

Ah, this wasn't what I was looking for but led me in the right direction, can't believe I didn't check canvas's methods enough to see if it already existed 😅
Canvas.pixelRect was what I needed

#

'preciate it anyway 😛

wanton geode
#

Hey ! I'm trying to see and understand the new InputSystem, for my older projects i kind of copied what I saw, so I'm trying to make a player controls script for my character on my own, and even when trying to understand it's kind of confusing and I'm seeing a lot of unique method, so that's why I'm asking here, how do I make a simple character controls script ?

wintry quarry
strong wren
real thunder
#

So I have a mob with several colliders which able to shoot downwards and upwards and I want to check if shooting is obstructed
said mob and possible obstructions (other mobs) and targets (same mobs) obviously having the same layermask so
So I wonder is there a better way than raycasting for everything and sorting through that?
I guess not

wintry quarry
#

Ideally you just make a layer mask that includes only the objects that you consider to be "obstructions" and do a raycast with that

real thunder
wintry quarry
real thunder
#

but what if it hits the other target

wintry quarry
#

wdym "the other target"?

real thunder
#

well to be honest I could make a layer for each faction

wintry quarry
#

Why would you need that?

#

Can you explain what "target" actually means in this context?

#

And "other target"

#

How many targets are there?

real thunder
#

I thought that line "said mob and possible obstructions (other mobs) and targets (same mobs) obviously having the same layermask so" would explain everything

wintry quarry
#

And how are those different from all the other mobs

wintry quarry
real thunder
#

there is a generic I-shoot-things mob
and they have different factions

wintry quarry
#

so by "target" do you mean "anything in a different faction"?

real thunder
#

to be clear I meant a mob which is a "target" within an AI script
but anything in a hostile faction would make sense to shoot through so

wintry quarry
#

Do a raycast:

  • If it hits nothing, it's not obstructed
  • If it hits a mob:
    • check the faction. If it's the same faction as the shooter, it's obstructed
    • if it's a different faction as the shooter, it's not obstructed
  • If it hits something that isn't a mob: It's not obstructed
real thunder
#

I did that at first but it kept hitting the source mob
target could be anywhere, behind, almost under, almost above, raycast kept hitting some minor parts of a shooter itself

#

...
...
yeah I should probably use a layer for general big colliders of mobs for a check, not the body parts

wintry quarry
real thunder
#

oh that's a clever hack

wintry quarry
#

e.g.

int originalLayer = gameObject.layer;
gameObject.layer = tempLayer;
// Do your raycast
gameObject.layer = originalLayer;```
naive pawn
#

is this in 2d or 3d?

wintry quarry
#

2d I'm assuming

#

because 3d doesn't do this

real thunder
#

3d

naive pawn
#

if it's 2d you can use Collider2D.Raycast to ignore the current collider

wintry quarry
real thunder
#

the collider it starts but what if u hit a knee or a backpack

naive pawn
wintry quarry
#

and/or does this raycast actually need them?

real thunder
#

yeah as I said I can prolly just raycast only against generic capsule colliders I use so player don't go through them

real thunder
wintry quarry
#

not that I know of

real thunder
#

good enough for me

pliant coyote
#

Hello everyone, I have a question - How hard is it to transform my game into a simple multiplayer world?

#

combat doesn't happen in the overworld scene, but separate battle scenes, so overworld would just handle monster spawning and character movement/ their own data

real thunder
#

I am not competent in that but so far take my unexperienced advice
how hard - yes, pretty hard but doable, annoying type of hard
having to think of and separate everything you need to sync from everything you don't and making only your player to be the player sound pretty annoying

pliant coyote
#

realistically, would it be better to pay someone to handle this for me?

#

or is that insanely expensive

real thunder
#

if you plan on keeping developing probably bad idea

pliant coyote
#

yeah thats a good point

#

this has been a hobby project for a while and its now getting to the point where things are getting done

real thunder
#

game is like
either multiplayer or singleplayer by design

real thunder
#

by that I mean if you have multiplayer you meant to extend it keeping in mind it's multiplayer or you would have to do twice the job

pliant coyote
#

get some feedback really

real thunder
#

some people manage to make multiplayer mods for singleplayer games and it's pita

#

there is a RimWorld multiplayer mod which have huge issues with keeping up with game updates and DLCs

pliant coyote
#

im not expecting this to be that size lol, i have a bunch of friends we just want to play together

real thunder
#

on the other hand I don't think it's insanely hard to make multiplayer it's just like 2 times more things to do and keep in mind (for basic at least) but like take everything I say with a huge grain of salt I just tried to make very sloppy multiplayer once and quit fast

pliant coyote
#

haha i understand

#

is there a place i can get feedback?

real thunder
#

🤷‍♂️
wait till someone more knowledgable come here I gtg

silk night
# pliant coyote Hello everyone, I have a question - How hard is it to transform my game into a s...

Having a very simple scene work in multiplayer is easy with the integrations offered these days.
BUT as soon as you add just a bit of complexity you will encounter problems that you have never seen before, that have little resources on the internet and are hard to fix.
The structures and logic needed for multiplayer is often different than what you know about singleplayer game dev and often feels like its counterproductive if you introduce it after the singleplayer is already done because it works against all that you know about good practices
Then there is the problem of server costs, badly optimized games can really eat your wallet if you are using dedicated/cloud infrastructure.

If you want it as a playground to test it, go for it, if you are expecting to upgrade a shipped application that goes out to players you are in for a hell of a wild ride

#

Ofcourse the type of game is HEAVILY influencing how complex it gets, if you have a turn based 2d game networking can be relatively simple, if you have fast paced real time combat in 3d with physics good luck, you are going to need it 😄

pliant coyote
#

otherwise players just walk around in the overworld

silk night
#

If its via steam transport (e.g. dedicated lobbies) and thats the only thing you want to network that sounds fairly doable

#

But if you have never worked with networking, just introducing it will be a good task 😄

pliant coyote
silk night
#

Yes, but it is unlikely to find someone skilled who does it for free, but here is a good place to look:

#

!collab

radiant voidBOT
# silk night !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

pliant coyote
#

😄

dreamy lance
#

im trying to create a unit spawner, i have it spawnning but once it spawns the unit i want that unit to move to a target postion but im stuggling to find the nave mesh agent bcs all the sources i have found say to use a serielized field but i cant do that as the prefab with the script doesnt exit untill it spawns... how would ju get the agent when the unit spawn?

#

i hope that makes sence

naive pawn
#

you would get it from the object you spawned

dreamy lance
dreamy lance
naive pawn
#

if the navmeshagent is the "main" component you need to use from that prefab, you could have the field typed as a navmeshagent (rather than GameObject) so you would get the navmeshagent directly from the Instantiate call

dreamy lance
#

how would i do that ?

#

do u have any recourses i can look at?

naive pawn
#

i mean, i guess docs? i feel like what i said is pretty straightforward. what part about it are you stuck on?

dreamy lance
#

like this?

#

but how would i fine the agent in here?

#

also ignore the _agent that was a difrent attempt that didnt work

#

i tried using the gameobject.find

#

but that didnt work

naive pawn
dreamy lance
naive pawn
#

not sure what you mean by "hand it over"

silk night
#

you can do GetComponent on the spawned object or reference your prefab by its monobehaviour and instance it through that, gives you the refernce instantly

wintry quarry
#

well, get a reference somehow

#

Life's a game of passing references around as method parameters and such

dreamy lance
naive pawn
#

weren't you trying to get the navmeshagent

dreamy lance
#

yes

#

i may be going about this all wrong tho im super new to using navmeshs in unity

#

i need my spawn object to be able to pathfind to the target

wintry quarry
#

you would just assign that in the inspector

dreamy lance
wintry quarry
dreamy lance
wintry quarry
#

you just call e.g. _agent.SetDestination(destinationPosition);

wintry quarry
# dreamy lance

yes that's a navmesh surface but you don't need a reference to it for anything here

silk night
#

i think they want the spawner to set the target on the spawned thing after spawning

dreamy lance
silk night
#

so they need the ref to the agent fetched from the spawned thing

wintry quarry
dreamy lance
#

oh

wintry quarry
#

the surface goes on... the surface (the ground)
The agent goes on the character that moves

dreamy lance
#

then the tutorial i watched is stipid

wintry quarry
#

if it actually did that, then yes

#

technically th NavMeshSurface can go on pretyy much any object

#

including an empty one

#

it doesn't need to be attached to the ground itself or anything

dreamy lance
#

so put the agent on the spawn object and jsut use the agent.set destination?

wintry quarry
dreamy lance
#

like so ?

wintry quarry
#

afaik

dreamy lance
#

ah ok

wintry quarry
#

it seems like those two would be competing with each other for moving the object

#

And you need to assign this Agent field here

#

by dragging itself in there (or grab the title bar of the NavMeshAgent component in)

#

you definitely still need that code that sets the target after spawning though (from the spawner)

dreamy lance
#

i cant sent them before its spawn in

naive pawn
#

you can from the prefab if it's on the same object

dreamy lance
#

oh i see thank you

#

OMG THANK YOU

#

it works now

dreamy lance
#

im asumming if so its super complicated but still

naive pawn
#

i don't know anything in this realm

dreamy lance
#

also... it doesnt know how to walk around things by defult lol

#

i need to figure out how to get around obsticals now

steel mesa
#

I try launch unity and its package maanger error intried 10 different versions none had security alerts

wintry quarry
#

or include them in the navmesh baking layers

merry fiber
steel mesa
dreamy lance
#

thank you guys for all the help

wintry quarry
steel mesa
# steel mesa

Is someone able to help i tried many versions all give me this error

dreamy lance
#

ah cool, tho i feel using the navmesh obsitcal is prob better practice

wintry quarry
steel mesa
naive pawn
naive pawn
#

have you tried reinstalling the editor

polar acorn
#

And don't repost the same crunchy phone image while the old one is still on screen

steel mesa
broken nest
#

Hey, I've made a mesh in code but the edges of the mesh don't look good (kinda blurry). I suspect normals to be the problem, I used mesh.RecalculateNormals(); mesh.RecalculateTangents(); mesh.RecalculateBounds();

swift crag
#

You need to split the edge to get a sharp boundary

#

(that is, you need two sets of vertices)

broken nest
#

I see thanks a lot

swift crag
#

I don't know if there's a convenient way to do that

#

or if you'll just need to do it by hand

#

(you'd look for 2+ uses of the same vertex and add new vertices)

#

you'd need to make sure that all of the triangles on one side of the edge are using the same verts

still herald
#

Hi everyone, I need to ask: does anyone have a good tutorial for learning how to create a first-person camera in Unity? I have no idea how to do it, and I've seen a lot of tutorials on YouTube, but most of them are basic and don't explain it completely

hexed terrace
still herald
#

thanks, I'll watch it

grand snow
#

yes go watch the asset 😐

cedar tartan
#

hi

mint imp
#

Any tips on turning a test scene with all your features into the actual game or to start making levels?

My game involves going to different planets so should each of those be a unique scene or do i switch them out in a "game" scene?

Ive kinda delved into this before but just wondering what others do or what is standard.

tender mirage
mint imp
tender mirage
#

Are you literally talking about the unity Scene or like refering to active objects and wanting to switch between those as a whole.

swift crag
grand snow
#

Or use additive scene loading/ load content yourself with prefabs or by creating objects

mint imp
swift crag
#

Indeed. If you're planning to do a lot of scene loading and unloading, I'd throw them into a "Gameplay" scene that you load and unload when you start and stop playing

upper token
#

How can I make this point change location with each key press and still follow the player? I want to do this to make a weapon.

grand snow
#

you probably need to animate it to move to match the sprite

upper token
grand snow
polar acorn
#

Did that "not work" or could you just not figure out how to implement it? Because if you want this thing to move with the animation, actually animating it with that animation is the way to do it

craggy marsh
#

Hey everyone, I keep seeing this cool effect in a lot of games of the sprites slightly moving to add some juicyness. I wonder how can you reproduce this effect? Here is a gif of a game jam game that has this effect

fickle plume
sour fulcrum
#

Cool question though

#

Shader is prob the ideal route but you could prob do a version of that through code

naive pawn
#

this is usually done with separate sprites, afaik

#

i feel like using a shader could probably mess up emphasis / foreground/background separation

naive pawn
craggy marsh
#

Oh ok, its sprites, I see thanks! I sometimes see it on text too so I was curious, may sometimes be shader yeah

craggy marsh
craggy marsh
sour fulcrum
#

Quality control?

craggy marsh
#

Just found this video about a shader in shader graph that knda ressemble the effect https://www.youtube.com/watch?v=xDCRah7BbIo

Bytesize Gamedev is a series of videos featuring tiny tutorials, delivered in 60 seconds or less. In this video, learn how to make a sprite wobble effect using Shader Graph and URP.
This video was previously posted on Twitter: https://twitter.com/daniel_ilett/status/1318598139419480070

Unity 2019.4.12f1, URP/Shader Graph 7.3.1
---...

▶ Play video
fickle plume
surreal sable
#

Any ideas how to log data and save it to the database.

I'm currently using Unity Game Services for authentication and storage for player files etc. I want to create an audit log much like
[Timestamp] [User accessed this place]
[Timestamp] [User talked to NPC]

The actual main thing would be to keep track of what the users are doing. I'm using Unity Dialogue System by PixelCrusher so I think I have some event system that i can use when user starts or stop certain dialogue. Just wondering how to store it to the database to analyze

midnight plover
naive pawn
surreal sable
midnight plover
pure pine
#

!code

radiant voidBOT
pure pine
#

can anyne help me with this?

#

im trynna make it detect when the player has a certain effect applied to them

#

using arrays and lists but im having a problem with the "common" array

#

i cant get it to contain only the common elements between the effects list and the applied effects list

#

also can anyone suggest something better than having all the functions in my classes be public?

wintry quarry
#

for example:

bool containsPoison = AppliedEffects.Contains("Poison");```
#

You said:

im trynna make it detect when the player has a certain effect applied to them
And I'm not sure I understand why checking that would require checking for common elements between two lists

pure pine
wintry quarry
#

so it's wrong anyway

pure pine
#

idk why i was trynna do that in the first place atwhatcost

pure pine
#

wait then what does the enitre function return

wintry quarry
#

the right side is fine

#

leave it alone

regal marsh
#

why when i use the smooth damp or lerp with camera to follow the player is shows the color of background

wintry quarry
#

A common example is if you're forgetting about the z axis in a 2D game and so you're moving your camera to the same z position as the objects you're trying to render

regal marsh
#

oh

regal marsh
#

it make a lot of sense now

#

<33

rancid tinsel
#

is there a way to remove listeners on an event Action directly, rather than doing it on the listeners?

#

I could do it either way but I feel like for a pool it makes more sense for the object to clean itself up, rather than whatever used it

silk night
#

do you want to remove specific ones or all?

rancid tinsel
#

all

#

technically there should only ever be one at a time

silk night
#

set the event to null

#

that flushes all listeners

rancid tinsel
#

oh interesting - what about when I invoke it again? do I need to set it to something?

silk night
#

well, depends, which type of event are you using?

rancid tinsel
silk night
#

oh action is not an event listener, you just save a reference to a method 😄

#

so yeah you can set it to null and just do a null check before invoke

sour fulcrum
rancid tinsel
#

so just to confirm: this becomes not null the moment anything subscribes to it

#

so if there are no subscribers, it is just skipped?

silk night
#

yeah, with action you can only ever have one subscriber, the next one would override the earlier

rancid tinsel
#

I don't think that's the case

silk night
#

pretty sure Action is just a reference to a single method

#

how are you subscribing to it?

sour fulcrum
#

cap

rancid tinsel
#

from what I understand its a collection of all methods that subscribed to it no?

silk night
#

oh im an idiot, i switched it up with Func 😄

sour fulcrum
#

Action is just a void delegate that exists for convenience

rancid tinsel
#

oh lol

#

I've never used Func, will need to research

silk night
sour fulcrum
#

You don’t need func prob

silk night
#

yeah keep the action and if you write null to it, it should just flush all listeners

sour fulcrum
#

As sidia and plenty on google said setting to null should work

#

I understand why you’d be confused by that behaviour tho

silk night
#

yep, its weird 😄

rancid tinsel
#

I mean it makes sense as long as you keep in mind what the action actually is

#

I'm slowly getting it, but my brain is still not developed for it lol

silk night
#

yeah but usually you set something to null if you do = null, with action is just throws away all listeners, its a bit counterintuitive

sour fulcrum
rancid tinsel
#

I guess it's the same as a list, which you can also do List ... = null, which clears it

#

unless it doesn't work like that

sour fulcrum
#

That would be a null

rancid tinsel
#

oh wait yeah it is different

silk night
#

no a list will really be null after that, you need to construct a new list after that

rancid tinsel
#

yeahh

sour fulcrum
#

I do personally prefer how unity events wrap the += and -= in AddListener and RemoveListener

silk night
sour fulcrum
#

Oh does that do similar?

silk night
#

I mean it does a lot more, but yeah it offers similar functionality to yours in this case

sour fulcrum
#

nice