#💻┃code-beginner

1 messages · Page 366 of 1

cosmic dagger
#

since they do not know what a lamba expression is, you may have to explain _ (in your example) as that will cause some confusion . . .

willow scroll
cosmic dagger
#

oh, i missed that part then . . .

pure saddle
#

can i disable my game collision to object by using

public extern void set_isKinematic(bool value);
void thicket
#

What

willow scroll
#

I don't think there is a built-in method for this. You can store the previous position of the GameObject and calculate the difference between the current one, which, if isn't zero, can be used to calculate the force applied

cosmic dagger
#

you can obtain the speed of the GameObject by recording its previous and current position . . .

void thicket
karmic kindle
#

Spot on!! Thank you very much!

cosmic dagger
#

damn, too slow . . .

meager sentinel
#

If you mean something about the rigidbody there was a function if for example you have a grab system and you punch it into the ground to detect how many force was being used

pure saddle
#

i am noob

eternal needle
#

What are you trying to do? There isnt really a way to detect individual forces applied to the rigidbody. Youd need to make your own script which takes in these forces applied maybe.

#

Unless your just talking about collision forces, which is provided through the unity messages

cosmic dagger
void thicket
pure saddle
karmic kindle
#

The trouble with that was it would move forward in the "scene" regardless of how much I moved the camera angle, where as I want "walk forward" to relate to how the camera is facing - but I don't want the camera to move on Y unless the character is jumping etc... What Bawsi said was the problem, I forgot to add Space.World, now the line ignores the Y change

willow scroll
#

It makes the rigidbody kinematic

#

Certain collisions still happen

karmic kindle
#

Thanks for clarifying this

pure saddle
meager sentinel
willow scroll
# pure saddle ok ty bro

Basically, making the Rigidbody kinematic still calls OnTriggerEnter, assuming the method is in the class, which Rigidbody we're talking about, in certain circumstances. Of course, it doesn't call OnCollisionEnter

pure saddle
#

how can i get the

#

worldtomatrix

willow scroll
#

What does it mean?

pure saddle
#

in a unity game only using fields

rocky canyon
#

buzzwords

pure saddle
meager sentinel
#

frick my IDE in visual studio broke again, it doesn't show errors neither suggestions

#

what could i do?

willow scroll
willow scroll
meager sentinel
willow scroll
rich adder
pure saddle
meager sentinel
rich adder
eternal needle
# meager sentinel Studio

Maybe go through the ide configuration again. Did it break for every script, like you close VS, open a script through unity and it doesnt have highlighting?

willow scroll
meager sentinel
pure saddle
rich adder
pure saddle
#

my question is how can i get the matrix

void thicket
pure saddle
meager sentinel
#

ty tho

pure saddle
willow scroll
pure saddle
willow scroll
pure saddle
summer stump
#

That is an attribute to serialize a field

#

That does not explain what you are asking though

#

What is "this" and what are you trying to "get"?

#

You can of course make a Transform typed field if you want

Transform myTransform

pure saddle
#

no how can i get in a random game

summer stump
#

That is even more vague.

pure saddle
#

like is there any universal method?

willow scroll
pure saddle
#

how to find a game gameplaymodule class?

void thicket
#

What

#

Are you trying to do modding or something?

pure saddle
#

nope bro

summer stump
#

Gameplaymodule !?

pure saddle
#

i am trying to learn unity

formal venture
#

okay, i know fully get it, thank u very much :>

pure saddle
#

maybe i am to noob to ask correctly

eternal needle
#

You should ask what you're actually trying to do gameplay wise. Not code wise

summer stump
willow scroll
# pure saddle yep

Hold on. So, this whole thing with matrix was to reference a component?

pure saddle
#

but i am too nob

#

what is the property bounds in class Collider do?

willow scroll
pure saddle
void thicket
#

So confusing

willow scroll
#

Well the name literally tells you this

pure saddle
willow scroll
acoustic arch
#

can my scroll view be able to switch between different content? like have 2 different content objects and whichever is enabled is the one that scrolls

#

it won't let me scroll the 2nd content when active

#

under the Viewport

pure saddle
willow scroll
summer stump
pure saddle
willow scroll
pure saddle
willow scroll
#

Is the attacker has a collider

summer stump
#

I mean, if your attack relies on a raycast. Otherwise no

willow scroll
#

Also, why would you even detect an attack on the player if you have the data of the Enemies

summer stump
#

It won't tell you that the enemy wants to attack you. Just that an enemy is there

pure saddle
#

if i destroy my raycast i destroy my game physics?

willow scroll
summer stump
#

You don't destroy raycasts.
It is merely a query. It asks if something is there. Either yes or no

void thicket
#

If I destroy my question I destroy whole discord? 🤔

pure saddle
#
struct Ray {
 Vector3 origin;
 Vector3 direction;
};
#

is this good?

willow scroll
#

No, this is mid

summer stump
#

That is a ray
Not a raycast. You can use the ray for the raycast

pure saddle
pure saddle
willow scroll
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

pure saddle
karmic kindle
# willow scroll So does it work now?

Yep - transform.Translate(new Vector3(Camera.main.transform.forward.x, 0f, Camera.main.transform.forward.z) * panSpeed * Time.deltaTime, Space.World);

willow scroll
summer stump
#

You can use the ray, or plug in values directly

pure saddle
pure saddle
willow scroll
rocky canyon
#
Ray ray;
ray = new Ray(cam.transform.position,cam.transform.forward);```
#

ray already made for ya, just fill it in and use it

rocky canyon
#

yes

pure saddle
#

oh ok

rocky canyon
#

ones an origin and ones a direction

#

just like u had earlier

willow scroll
#

I highly doubt there're any components for this

#

Additionaly, you usually wouldn't need this. Simply let the content be the same, and instead change the items inside of it

#

This way, the content just shows the enabled items, which prevents you from changing the view's contents

pure saddle
#

what is freezerotation in class RigidBody used for?

willow scroll
#

It is literally self-explainable by its name

#

The rotation gets freezed and is not changed

rocky canyon
#

freezes the local rotation of the rb

pure saddle
#

so you cant rotate ur camera?

rocky canyon
#

world rotation if its a root gameobject

void thicket
#

Are you looking through the class and just becoming curious about every single property?

polar acorn
pure saddle
willow scroll
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

eager wolf
#

How do I get this to work?

rich adder
#

I'm still confused what you are trying to do with item

summer stump
languid spire
summer stump
#

You aren't actually DOING anything there

polar acorn
turbid ruin
#

Hey im new here and im wondering where can i request or get help to specific problems?

wintry quarry
polar acorn
ionic plank
#

Hi ! I don't understand my error :

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <0e6f69b30d82405f98d87804eacb548a>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <0e6f69b30d82405f98d87804eacb548a>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <0e6f69b30d82405f98d87804eacb548a>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <0e6f69b30d82405f98d87804eacb548a>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <0e6f69b30d82405f98d87804eacb548a>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <0e6f69b30d82405f98d87804eacb548a>:0)

Can you help me with this ?

polar acorn
eternal needle
#

If you're getting this error often, reopen unity and or reset layouts

radiant frigate
#

how can i rotate the transform.up 90º to the left or right?

wintry quarry
#

or:

transform.up = Quaternion.Euler(0, 0, 90) * transform.up;```
#

"left or right" are not really good ways to describe rotation though

#

A better way would be "clockwise around the z axis" or something

radiant frigate
radiant frigate
wintry quarry
#

clockwise around the object's local z axis

radiant frigate
#

okay

#

ty!

stuck palm
#

Hey, just switched around the responsibility so its the damage dealer making the enemy take damage instead of the enemy damaging itself from the damage dealers collider. The issue still appears to persist, however.

#

its triggerentering multiple hitboxes and damaging the victim for every hitbox it gets hit by

eternal needle
stuck palm
eternal needle
#

Google will explain it more clearly than I can, it's just a collection of objects at the end of the day. You can also use a list too

stuck palm
swift crag
swift crag
stuck palm
swift crag
#

because how are you supposed to know if you've already hit the enemy or not?

eternal needle
stuck palm
turbid ruin
#

Could someone help me with a Unity build problem?

stuck palm
#

i think i've got an idea

swift crag
#

hopefully that idea is "track which hurtboxes you've already hit per-attack" :p

stuck palm
swift crag
#

It should only cause damage if it:

  • has never hit a hurtbox yet
  • hits a hurtbox that's better than the previous hurtboxes (if you have that kind of thing, at least)
eternal needle
swift crag
stuck palm
#

hold on i have an idea, let me cook real quick

swift crag
#

Each attack instance (e.g. each swing in a combo) tracks the hurtboxes it has seen

#

that's it

swift crag
stuck palm
swift crag
#

in fact, UnityEngine.Pool.HashSetPool<Hurtbox>.Get() is right there (:

swift crag
#
var hurtboxSet = UnityEngine.Pool.HashSetPool<Hurtbox>.Get();

// sometime later...

UnityEngine.Pool.HashSetPool<Hurtbox>.Release(hurtboxSet);
eternal needle
swift crag
#

I do that in my AI planner system

stuck palm
swift crag
#

it pools the PlannerState objects, which contain a big pile of hurtboxes

swift crag
#

we're talking about individual attacks here

#

i don't think we're on the same page here...

eternal needle
#

I think you just need to start implementing the code where an attack tracks what it hit, and then itll become clear what you actually need to do

stuck palm
#

yeah okay

#

will try that

#

how can i delete a hashset?

#

make it null or?

stuck palm
eternal needle
#

There is a clear method

#

Same with lists

stuck palm
#

okay, thank you

swift crag
#

if you allocate a new hash set every time you attack, you don't have to clear it at all

#

you throw out the attack object and it gets garbage collected at some point

#

you never see the hash set again

#

you could set the variable holding the hashset to null, but that would change nothing

#

if you pool your attack objects, then you must clean up the object before you re-use it

#

part of this would be clearing the hash set with the Clear method

#

Setting the variable to null would defeat half of the point of pooling, since you'd have to then allocate a brand-new hash set

swift crag
#

That's the big win that pooling gives you

#

My AI planning system uses and modifies tons of hash sets, but it generates very little garbage

#

everything is getting re-used

stuck palm
#

can i ask what you define as an attack in this case?

#

i just wanna make sure im getting everything crystal clear

radiant frigate
#

!code

eternal falconBOT
swift crag
#

Each jab can cause damage.

#

and each jab does not care if the previous jab happened to hit something

radiant frigate
swift crag
#

An attack should probably correspond to a single animation being played.

#

but you could totally have a single big swing that can hit over and over

#

I haven't played Smash in a while, but doesn't Roy's Up+B hit enemies many times?

#

That would be many separate attacks going off very quickly

#

each one with its own hitboxes

stuck palm
#

from what i've read in the wiki

swift crag
#

sure

#

each attack creates a set of hitboxes, and if those overlap an enemy's hurtbox, the attack connects

turbid ruin
#

Hello, I'm having a problem, today i made a build of my game but then it suddenly had a like dark gray screen, i'm not able to interact with the game but i hear the background music and only that. Sometimes it flashes up and i can see the game for half a second before it disapears once more. I looked around the Unity forums but non of their solutions seemed to fix mine. It has only being doing this since today. Yesterday everything was working perfectly fine.
I'm on Editor version 2020.3.29f1 if it helps
Please @ me if you found a solution or want to help!
Thanks

stuck palm
stuck palm
# swift crag sure

i did what you guys said, every time the hitbox is active, if it hits a collider it adds the root player's character script to this hashset. if it hits something and the same root object is in that hashset, it ignores it. when the hitbox collider is disabled, it clears the hashest.

#

idk if this is the right way

#

the main issue is avoided, that being repeat damage instances

#

but i feel like projectiles and stuff are going to be a whole other beast

swift crag
stuck palm
#

wouldnt make sense for my game i think

#
if (!hitCharacters.Add(_hitCharacter))
            {
                print("Already hit this player!");
                return;
            }
``` this is the base of the logic
swift crag
stuck palm
#
if (!hitCollider.enabled)
        {
            hitCharacters.Clear();
        }
#

this runs in update

buoyant knot
#

i feel like there is a smarter way to do that

stuck palm
ember gate
#

how can I not get bulldozed by the enemies if Im staying still and how can I not get slowed or stuck in them when I got the min amount of speed to be able to run them over

polar acorn
#

!code

buoyant knot
eternal falconBOT
buoyant knot
#

or an event that gets invoked

stuck palm
#

i could use an animator event but

#

that would mean going through like 120 differrent moves and switching them all out

#

and i dont wanna do that so

buoyant knot
#

why does the animator affect your collider

stuck palm
buoyant knot
#

is that just graphics?

#

oh shit, you’re in 3D

stuck palm
#

yeah

buoyant knot
#

uh, idk then tbh. but i can say there should be a cleaner solution

ember gate
buoyant knot
#

i have no idea what you are doing

#

i just see a bunch of boxes and circles

ember gate
#

ight so
basically a car drifting, when it has a certain amount of speed it should run through enemies else it would get damaged leading to death(not introduced yet) and when the car stays still it can get moved around by the enemies, instead I want the car to remain still and the enemies to just basically circle it round
@buoyant knot

willow scroll
#

Using Physics.IgnoreCollision

ember gate
#

ight

#

thanks

willow scroll
# ember gate ight

Ignoring the collision when the player is not moving can be valid if you ensure the enemies don't get thru it

ember gate
#

what do I add inside the parentheses

willow scroll
#

So you ignore it when

  • The player is not moving
  • The player's speed is high enough
    And don't ignore when
  • The player is moving at a normal speed
willow scroll
ember gate
buoyant knot
#

i would either change the layer or settings on the collider

willow scroll
buoyant knot
#

or enable a separate trigger collider with the given settings

static dune
#

Can you help me with an error in a code that I don't know what it is?

buoyant knot
#

eg, have a trigger collider for the hitbox, and a trigger collider for your hurtbox. Then in FixedUpdate, based on speed, enable one and disable the other

willow scroll
buoyant knot
willow scroll
#

Ignore the collision between the Enemy and Player layers

buoyant knot
#

you didn’t use ignore layer collision

willow scroll
#

I forgot to mention it

buoyant knot
#

you said IgnoreCollision

willow scroll
#

@ember gate use layers

buoyant knot
#

and you don’t need IgnoreLayerCollision either. that is a bad idea

ember gate
#

I was reading both opinions

#

I was creating some layers rn

willow scroll
#

This is much more efficient than ignoring the collision between the player and every enemy

buoyant knot
#

IgnoreLayerCollision changes the rules for how ALL colliders interact with each other

#

what he/she wants is to change the rules for that specific player object

#

which is simplest by either changing it to a different layer

#

OR have 2 hitboxes of different layers and settings, and enable only one. I would only do that if the settings are wildly different and specific

willow scroll
buoyant knot
#

you don’t need to use that

#

just change the layer of the one object you want to change

ember gate
#

I got confused so my car is on the Player layer and the enemies are on the Enemy layer

#

do I change the car layer?

buoyant knot
#

yes

#

like make a layer that is SolidIgnoreEnemy, and a layer that is Player

#

or just change the settings of the car’s collider

willow scroll
#

I don't see why you would have a 2nd layer if you can simply ignore the collision between the existing ones

ember gate
#

does the order matter?

#

for the layers or na

buoyant knot
#

no

#

does not matter

#

in this case, I might use Collider2D.forcerecievelayers

willow scroll
buoyant knot
#

this is a layermask of layer overrides. Whatever your layer is, you will additionally receive forces from whatever is here

#

and reverse for forceSendLayers

rocky canyon
compact nymph
#

how come it keeps giving me errors for line 27 whenever the ray isn't over the object

buoyant knot
#

you can also have a separate trigger hitbox to allow your player to destroy or be damaged by enemies

static dune
willow scroll
buoyant knot
#

which is not what we want

compact nymph
rocky canyon
#

so when u try to access hit theres nothing there

willow scroll
void thicket
rocky canyon
buoyant knot
#

we want to change the rules for the one object interacting with everything else

compact nymph
void thicket
compact nymph
#

just check if hit is not null

buoyant knot
#

so you should change the settings on the collider

rocky canyon
buoyant knot
#

either changing its layer or its layer overrides

#

then any changes solely apply to that one thing

willow scroll
buoyant knot
#

you are now changing the rules for it, for no reason

#

like if you add a second car or whatever

willow scroll
buoyant knot
#

because you have no clue what features they might add a year from now

#

but by using IgnoreLayerCollision, yoh are changing static variables that apply to everything

ember gate
willow scroll
buoyant knot
#

so you get a ref for the collider2D of the car, and then say myCar.forceReceiveLayers = whatever

rocky canyon
#

^ u don't call AddForce on a Rigidbody.. you call it on an instance of a Rigidbody.. Rigidbody is the class for all rigidbodies.. same thing here

#
Collider2D thisCollider;
thisCollider. dadada```
ember gate
buoyant knot
buoyant knot
#

and that layer mask should have the relevant bit for the layer to receive forces from turned to 1

#

and 0 for layers where you don’t

willow scroll
buoyant knot
#

making a layer mask from layers is a really important part of working with the unity physics system

#

like if your layer mask says to interact with layers 2, 5, 6. Then in binary that is 000…001100100

#

i think Unity has methods to do the conversion

#

important class for working with physics

buoyant knot
rocky canyon
#

wheres the OP?

buoyant knot
#

probably writing code

rocky canyon
#

nah i mean the post

willow scroll
rocky canyon
#

im confused on what even he's trying to do.. i just stepped in

rocky canyon
#

thankyou

ember gate
rocky canyon
#

ahh ok i see

buoyant knot
#

note that layer mask and layers are not the same

static dune
buoyant knot
#

a layer mask is a bitmask. it is a number where each digit in binary corresponds to a specific layer being “on” in that number

#

so layer mask 5 means YES to layers 0 and 2, because 5 = 000…00101 in binary

rocky canyon
#

im really bad at all that bitshifting stuff

buoyant knot
#

in the context of a contactfilter2D, this would be like one number that tells you all the layers you can touch when you raycast

rocky canyon
#

it hurts my brain :d

buoyant knot
#

in the context of forcesendlayers, it’s all the layers to which a collider can send forces

#

same for forceReceiveLayers

#

the LayerMask docs tell you what methods that class has

nova swift
#

Does manually dragging components into variables rather using GetComponent optimise the game, and would it actually help with loading times to do that when possible?

rocky canyon
#

any getcomponent u get rid of the better ur performance is

#

but theres nothing wrong with using them for initialization (1 - time use)

#

like in Start() or Awake()

#

u can use getcomponent to cache ur variable.. and then accesss that cached variable..

#

not the getcomponent call each time

buoyant knot
buoyant knot
#

it makes a class called Layers where you can use Layers.PLAYER to get the layer number of player. And Layers.PLAYER_MASK to automatically get the number corresponding to a layer mask of just the player

ember gate
#

Installed it now aswell

nova swift
swift crag
#

and thus you can do Layers.FLORP_MASK | Layers.BLORP_MASK!

rocky canyon
willow scroll
swift crag
#

i wonder if that compiles down to a constant. C# isn't nearly as aggressive as C++ can be about such things

rocky canyon
buoyant knot
#

so you can do LayerMask playerAndEnemy = Layers.PLAYER_MASK | Layers.ENEMY_MASK;
and that is a layer mask that includes player and enemy

wintry quarry
rocky canyon
#

that can give ur game time to load up correctly..

ember gate
#

what I do not get is idk what should the forceReceiveLayers equal to @buoyant knot

nova swift
buoyant knot
wintry quarry
#

God I hope some generative AI picks this up

rocky canyon
#

everything else can be assigned via the inspector

buoyant knot
#

eg myCar.forceReceiveLayers &= ~ Layers.ENEMY_MASK;

#

~ is the bitwise NOT, which flips all 1 and 0

nova swift
buoyant knot
ember gate
#

or wait u meant Collider2D as a general thing instead of it I should put my car

ember gate
buoyant knot
#

yes

willow scroll
buoyant knot
#

Colider2D.forceRecieveLayers is the name of the property (as it is defined), which is not static, and you can only use on instances

buoyant knot
#

&= takes each individual bit, and ANDs it. So if every bit on the right hand side is 1, then & makes the result the same as the left hand side. But since the enemy bit is 0, that AND forces just the enemy bit to be 0.

ember gate
#

I don't think this is what you mean

#

idk im sorry im stupid I haven't coded in unity for a long time

rich adder
#

0 is not a layermask

buoyant knot
#

you have to explicitly cast it to a LayerMask

#

because unity is too dumb to figure that out by itself

#

does your IDE at least acknowledge that property?

#

it should automatically find the right property in like a dropdown list

ember gate
#

not sure

#

I created a layermask

buoyant knot
#

what is the error

ember gate
rich adder
#

which version of unity are you on

ember gate
#

good question

#

one sec

rich adder
#

i think thats 2022 property

buoyant knot
#

force overrides were added later

ember gate
#

DAMN

buoyant knot
#

yeah. it’s semi recent

ember gate
#

2021.3.19f1

buoyant knot
#

bro wtf

#

get off that shit

ember gate
#

DAMN XD

rich adder
#

Unity 6 is about to be out lol at very least use lts 2022

buoyant knot
#

layer overrides make life vastly easier

ember gate
#

does the game change a lot if I change the version?

#

I mean its not much to it anyways

rich adder
#

always make a git commit before doing such drastic change

ember gate
#

its not drastic I got 5 objects on the screen and 5 scripts

rocky canyon
#

basically the UI changes around.. some things get deprecated / or their names changes the very most

rich adder
#

then ur fine

ember gate
#

last version 2023.2.20f1

#

should I install this one

rich adder
#

thats not LTS

ember gate
#

or unity6 6000.0.4f1

rich adder
#

use LTS

#

2022

rocky canyon
#

LTS's will be clearly marked

#

Long Term Support

buoyant knot
#

just back up the project

ember gate
#

ye found it

#

thanks

rich adder
rocky canyon
rich adder
#

fork is good client but might be too overwhelming for beginner

rocky canyon
#

true.. the revert changes and check-outs and stuff might be a bit much

#

for ur basic push/pull stuff its pretty much the same

#

the documentation could be better tho 😢

#

i get help from my friends that use it when I get stuck 😅

ember gate
#

doing that tutorial rn

rocky canyon
#

if its too overwhelming.. u can always duplicate ur projects folder and zip it up as a backup

#

but learning how to use version control is a must eventually

rich adder
#

but then u have to wait to rebuild. its a double edge sword 😛

rocky canyon
#

true.. thats a good general point
the Library folder is included in the gitignore.. b/c its HUGE and Unity rebuilds it automatically when u open a new project..

#

soo if u want to u can delete it completely.. wont hurt anything.. and when u put ur project up on version control it gets excluded automatically (if ur gitignore is correct)

swift crag
#

yeah, this is just for the sake of making a local backup

ember gate
#

damn it took me so long

woeful ivy
#

hi could someone help me figure this out? im trying to make a wizard shoot a fireball in a 3d topdown game but i cannot get my head wrapped around what im supposed to do

ember gate
#

anyways imma go to sleep too exhausted to process all the stuff that were received by my brain, good night

woeful ivy
#

most of the things ive found are about shooting towards like a point, but i just want it to move in the direction that the mouse was at

wintry quarry
woeful ivy
wintry quarry
#

Then you can shoot your fireball int he direction towards that world space point

woeful ivy
#

oh okay, thank you :)

cedar crest
#

Hi! I have a small generated dungeon and got some performance issues with the amount of objects increasing. Can you give any links on how to improve and optimise procedural generation in Unity. Thanks in advance!

wintry quarry
#

optimization goes like this:

  • Use the profiler to identify bottlenecks
  • Think about how to optimize those parts
  • Do the optimization
  • Go back to the beginning
swift crag
#

If you have no clue where to look, you can use Deep Profile to see every single function call. This slows things down a lot and unfairly punishes small functions (since each function takes longer to run).

#

you can then add your own profiler markers to areas of interest

#
  moduleMarker.Begin();
  foreach (var moduleList in moduleTypeMap.Values)
  {
      foreach (var module in moduleList)
      {
          if (module.Tickable)
          {
              module.ModuleInfo.Marker.Begin();
              module.Tick();
              module.ModuleInfo.Marker.End();
          }
      }
  }
  moduleMarker.End();

...maybe like this!

cedar crest
#

Thanks guys, I'll try to locate the bottleneck

#

Are these advice for finding issues in my own code or can i use it for analysing frame render?

#

I thought of some articles about runtime light or culling, as far as I know they don't work out of the box

woven idol
#

Can someone please tell me what in this is making my player slow fall (I am new to bolt)

wintry quarry
#

you're explicitly setting your Rigidbody velocity to 0

#

On the y axis

#

C# code equivalent of what you're doing:

rb.velocity = new Vector3(something, 0, something);```
You need to put in the rigidbody's exisitng y velocity in for y instead of 0
woeful ivy
tight scarab
#

Would there be any way possible to make land like this from Sonic with decorations on top procedurally generated?

wintry quarry
woven idol
tight scarab
swift crag
#

yes, that's what Praetor was describing

#

using SpriteShape to make ground that goes up and down (and generally has randomly-generated shapes)

flint python
#

Hello, I want to get some advice for my enemy spawn method.

I have EnemyAvailableList with 10 game objects(the enemy), which will spawn 3 each time(set active), when no game object is available, all 10 are active, and will instantiate a new enemy, will not Destroy() this instantiate object when killed by user, instead add it to the list for later use. And I believe they will get cleaned up automatically when switching scene or exiting the game.

do you see any issues that could caused by this method and impact the game?

wintry quarry
tall torrent
#

hey, im a new scripter and this code doesnt act as i intend it to.

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

public class PlayerMovmentScript : MonoBehaviour
{

    public float movementSpeed = 15f;

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

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            transform.Translate(Vector3.forward * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            transform.Translate(Vector3.back * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            transform.Translate(Vector3.left * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            transform.Translate(Vector3.right * movementSpeed * Time.deltaTime);
        }
    }
}
#

the problem is that i have to keep pressing the key repeatedly for it to move

#

when I want it to move smoothly while holding down the intended key

outer coral
#

That method only returns true the frame you start pressing that designated key

rich adder
#

or are you talking about like enemy waves ?

tall torrent
flint python
cosmic dagger
#

that's what i did . . .

#

then you can remove the added instances back to the normal count when the current active instances hit below a threshold . . .

plucky wharf
#

Im tryina make a custom cursor and also lock and hide the system cursor, but for some reason its telling me that i cant do that anymore. Underlines with red and says "does not contain a definition for lockmode/visible" since when has this changed and whats the new way?

short hazel
plucky wharf
#

Ahhh sheit, definitely that, thanks lot

gaunt basin
#

im new to C# and dont know how to program pls help

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

rich adder
#

start with the pathways

stuck palm
#

i realise this might sound like a stupid question, but does LateUpdate always run after update?

rich adder
#

LateUpdate is called once per frame, after Update has finished. Any calculations performed in Update will have completed when LateUpdate begins. A common use for LateUpdate would be a following third-person camera. If you make your character move and turn inside Update, you can perform all camera movement and rotation calculations in LateUpdate. This will ensure that the character has moved completely before the camera tracks its position.

void thicket
rich adder
#

its literally in the name 😛

ionic zephyr
#

If I am making a survivale game, should I make every breakable item an scriptable object?

rich adder
ionic zephyr
#

should I contain the data of each item?

ionic zephyr
rich adder
#

or an array of SOs and maybe randomize it

ionic zephyr
#

okay, thanks!

summer stump
ionic zephyr
#

Ill start with the collectable resources

rich adder
#

the SO can also contain an array of resource prefabs and then pick from there etc

woven idol
ionic zephyr
rich adder
#

they could but, just have to keep modifying the enum each time you add one

ionic zephyr
#

is there a better way to make this inventory?

rich adder
#

SO + Poco is usually how I do it

hoary halo
#

Hey, Im making a multiplayer(Mirror for multiplayer) fps and I'm using animation rigging. Im assigning the target for "Two bone IK constraint" through code when the player is spawned. But when that happens the actual movement for the arms (that have the TB Ik constraint) doesnt happen. But if the target is assigned before starting playing it works. Does this have anything to do with Mirror or am I making a mistake?
This is how I assign it.

 RightIKBone.data.target = weaponComponent.RightHandIK.transform;
 LeftIKBone.data.target = weaponComponent.LeftHandIK.transform;
ionic zephyr
rich adder
#

in other words a regular class or even a struct

#

thats where my Mutable data goes

ionic zephyr
#

Okay, I think I get it, I´ll try that

rich adder
#

the SO has the base stats, then create the plain object. that I can change damage and whatever on it

ionic zephyr
#

but what if the object is an apple?

rich adder
#

what about it?

#

if you mean separating between consumable and whatever, that can be an enum for sure

#

how many types of resource can really exist, they are usually already defined ahead of time

ionic zephyr
#

so each type of object could be an enum

#

should the object be an abstract class?

rich adder
#

depends what you're going for , now you're getting into a very complex topic

#

U usually use modularity though

outer coral
#

Abstractions are delicate

rich adder
#

using interfaces instead of inheritance

#

but sometimes inheritance makes more sense

ionic zephyr
#

oh okay, maybe Im going too far for my knowledge

rich adder
#

start with simple items, and simple things like enum sure

outer coral
#

Only abstract when absolutely necessary otherwise you are just adding unnecessary complexities and making it harder for yourself to debug at least from my experiences

rich adder
#

multiple enums per object doesnt hurt if it makes it easier for you

#

ie
Consumable vs
Stackable non Stackable
etc.

ionic zephyr
#

Okay, thanks for your help

radiant frigate
#

why cant i drag the audiosource to the audiosource var?

rich adder
radiant frigate
#

in what way can i do it then?

rich adder
#

put audio source on shotgun

radiant frigate
#

oh, smart

#

how didnt i think of that lol

#

ty!

rich adder
#

np.

#

its good a idea what ur going for but sometimes its better to Keep it Simple stupid

#

you would use an Audio manager which would have a static Instance, that would be easy access to play sound on an external component

#

or the component can be passed if its instantiated

radiant frigate
#

noted

timid oriole
#

I'm free

#

It's been a long 3 years but I'm back

ionic zephyr
#

is it better to use the "Invoke Unity Events" option in while using Unity´s new Input System?

cosmic dagger
#

it depends how you want to interact with your input. use the unity events or the c# events . . .

zenith cypress
#

Whatever works the best for you and your systems ^

ionic zephyr
#

Okay, thanks!

summer stump
rocky canyon
#

ive been pursuaded to think SendMessage as being bad

#

not sure why i feel that way lol

formal escarp
formal escarp
rich adder
zenith cypress
#

I think it's one of the last options on the component

ionic zephyr
#

How can I freeze ONLY my player once the inventory menu is shown on screen?

frosty hound
#

Have a bool that you check before moving your player

ionic zephyr
frosty hound
#

If you say so

ionic zephyr
#

I freezed the constraints of RigidBody

cosmic dagger
rocky canyon
#

that'll work too but still need a conditional, like a bool or to check if the menu is active or not

ionic zephyr
#

however i think I partially solved it by freezing the constraints of the player´s rigidBody

cosmic dagger
ionic zephyr
#

yes, if the conditional was active, rigidbody.velocity was set to Vector2.zero

#

I also tryed it with the vector I was using as movementVector

cosmic dagger
#

that's an important detail to provide. we don't know how you tried to stop the player from moving . . .

#

so it never stops. it just keeps on moving?

ionic zephyr
ionic zephyr
#

but I managed to more or less solve the problem (i think) by freezing all constraints in RigidBody

wintry quarry
#

It needs to go in at the end

rocky gale
#

how do i take a random position of a axis of a plane? for example if i have a plane and i want to get a random position in the bounds of its x

summer stump
rocky gale
#

ye but what do i put for min tho

summer stump
#

Then just add that to the position - x scale / 2

summer stump
rocky gale
#

oh

void thicket
#

Plane as in linear algebra doesn’t have ‘bounds’

#

If Plane is just your game object then random range sure

hollow patrol
#

is it okay to create scripts just to organize variables for a specific object/task?
I don't want my main script to end up being a monster script with everything in it, but it feels a little awkward to use obj.GetComponent<Script>().variable when I could probably just declare the variable in my main script

#

ie. im wondering what the best practice is

cosmic dagger
#

single responsibility principle (SRP) . . .

rocky canyon
#

you shouldn't need to call getcomponent more than 1nce unless u have to either..

#

cache it and use that instead

cosmic dagger
#

each class has one responsibility, not multiple . . .

hollow patrol
acoustic arch
#

is it normal for a decent sized game to have quite a few scripts

rich adder
#

is this a real question?

void thicket
#

Very vague

rich adder
summer stump
rich adder
#

yeah there isn't a "guage" for normality..

acoustic arch
rich adder
#

you got as many scripts as you need, doesn't matter

void thicket
#

You’d need to define “normal” “decent size” “quite a few”

summer stump
#

The answer given has usually been to split responsibilities

acoustic arch
#

i'd think so to but this one i don't think so that i can remember

#

but i'm also very dumb

summer stump
#

Don't worry about the number of scripts

cosmic dagger
acoustic arch
#

i basically live on this discord sometimes so

hollow patrol
sleek pond
#

Hey guys

#

Can anyone tell me which YouTuber i should follow for c# coding

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

stray pivot
fathom locust
#

hey ehh,How to do the Cursor lock in unity?

rich adder
fathom locust
#

alr,I'll try

rich adder
#

its like the first result lol

fathom locust
#

Bruhh,its kinda ez af lol

quasi sparrow
#

Hey guys

#

Can you learn coding in unity on the unity learn hub

#

Like the language for unity projects , what we use

dark hatch
#

i want a place to store certain functions (abilities) so that with some parameters i can call them from anywhere (eg. player script or enemy script). how do i go about doing this?

charred spoke
#

Sounds like you need a static class

#

Or perhaps a singleton

#

Need more info

dark hatch
#

i want to be able to call Abilities.Explode() or similar from both player script and enemy script. there's a lot of way to do this, but what is ideal? (to keep things organised and not run into a plethora of future problems)

rich adder
eternal needle
quasi sparrow
teal viper
quasi sparrow
#

ok

#

tnx

vagrant zealot
#

hey! im trying to add a Animation for UI image, how can i achieve that? couldnt find a proper topic on the internet. Thanks !!!

teal viper
stuck axle
#

If you want a tiling/repeating texture, is having a shader/script to change the tiling of the material a must? It feels so common a usecase that there must be a way builtin

radiant frigate
#

i builded my game and now the character moves slower than in the one i open with the unity hub, is it something that i can change via code?

dense pike
#

I need a enemy follow player script

unkempt carbon
#

hi guys I have a question! How do I access an enum from a scriptable object class to another script using monobehaviour?

#

ok never mind i just wont use enums at all Evil_Patrick

plain oxide
plain oxide
#

So, this is the definition of your ScriptableObject class. Do you have any asset of this class? (I'm not sure how familiar are you with SOs)

unkempt carbon
frank zodiac
#

should i use raycast or physics2d.overlapcircle for my groundcheck?

teal viper
teal viper
frank zodiac
teal viper
# frank zodiac what are the ups and downs exactly? and also are there any other methods besides...

Raycast:

  • would not detect colliders that it starts in
  • only checks a ray, so you character would not be grounded when standing a bit below the edge
  • would require some specific logic for deciding if you're grounded. For example, checking the distance of the hit.
    Overlap:
  • Would still detect collision even if you're at the very edge
  • would require some logic to not become grounded when colliding with a wall

There are probably more things that I can't come up with right now.

As for other methods, you could also just use the collider collision events.

plain oxide
unkempt carbon
willow scroll
plain oxide
#

But that doesn't mean you shouldn't use enums!

unkempt carbon
frank zodiac
#

ill be sure to try it

#

i appreciate the help 👍

plain oxide
willow scroll
#

I don't think there are more precise options

teal viper
# frank zodiac oh i see.. thank you then!

I mean, these are all obvious properties stemming from the fact that one is ray and another is an overlap circle.

The best way is to try and see for yourself what fits your project.

willow scroll
#

If you need to simply calculate whether the player is on the ground, regardless of its shape, use OnCollisionEnter & Exit

#

It's going to detect whether the colliders touch, which is appropriate for the majority of cases

frank zodiac
#

so i need it to be extra precise

willow scroll
frank zodiac
#

thanks

willow scroll
#

Of course, it can be achievable with Raycasts and SphereCasts, but it doesn't make sense if you already have an option, which calculates collisions for you

teal viper
#

There are issues with collision messages as well. There's no perfect solution. You need to test and see for yourself.

rich egret
#

!codr

#

!code

eternal falconBOT
rich egret
languid spire
#

Because there is nothing in that code that calls it

rich egret
languid spire
#

then I suggest you ask in the Photon server

#

the main reason why an overriden method would not be called is because the calling method has not/could not cast the class correctly

ionic plank
#

Hello everyone,
I have a python script and I want to use it with a cs script ( I already looked on internet but I can't find any answer). Do you know how to do it ?

https://gdl.space/epopugoniz.cs

https://gdl.space/guqamulamu.py

I have also this error :

See "Script Serialization" page in the Unity Manual for further details.
Save.persistence.ConnectionManager..cctor () (at Assets/Script/Save/persistence/ConnectionManager.cs:9)
Rethrow as TypeInitializationException: The type initializer for 'Save.persistence.ConnectionManager' threw an exception.
Save.dao.ExecutionDao..ctor () (at Assets/Script/Save/dao/ExecutionDao.cs:17)
Save.service.ExecutionService..ctor () (at Assets/Script/Save/service/ExecutionService.cs:9)
Donneesentrees..ctor () (at Assets/Script/IA/Donneesentrees.cs:14)
languid spire
#

Follow the stack trace backwards. It gives you all the information you need to find the error

teal viper
#

Or at all

stuck palm
#

why can i use a character class as a boolean?

verbal dome
#

Unity allows MB's to be implicitly cast into booleans

#

It's basically the same as if(player == null) return;

#

Well not just MonoBehaviours, but all UnityEngine.Objects really

stuck palm
stuck palm
swift crag
#

it's an implicit operator

stuck palm
#

how can you program explicit casting?

#

if necessary

teal viper
#

Explicit casting is just (bool)variable

stuck palm
teal viper
swift crag
stuck palm
#

i havent touched operators yet

#

i dont need to but it sounds itneresting

swift crag
#

if only they were as wild as C++ operators

#

you can overload = there

swift crag
teal viper
#

Pretty sure you can define custom asignment operators in C#

languid spire
teal viper
#

Hmmm... Looking at the docs, it seems like you can't

swift crag
#

You are limited to the unary, arithmetic, and comparison operators

#

(and a few unay operators aren't permitted)

slender nymph
#

Yeah pretty sure the best you can do is implicit casts for weird assignments

swift crag
#

what's interesting is that there are true and false operators

#

you're allowed to return false from both of them at the same time

#

true, false, file_not_found

tender breach
hardy vortex
#

I'm not sure if this is the place to ask questions, and if it's not please let me know.
I'm trying to use the line renderer but it's only moving in the y direction even if I enter a value for the x-axis.

tender breach
swift crag
hardy vortex
#

How / where can I check?

tender breach
swift crag
#

also ensure that your camera is facing in the +Z direction. Setting your Scene View to 2D mode will do this

tender breach
#

@swift crag

tender breach
hardy vortex
frosty hound
# tender breach Respond

Please don't bother people. Consider maybe those who are experienced enough are not in the headspace to deal with another long discussion over messy code. You can be patient and wait.

lethal bolt
#

I dont even know anymore

polar acorn
polar acorn
swift sedge
lethal bolt
#

oh

#

Is there another way to make wait?

polar acorn
#

Or keep a running timer and do some math

lethal bolt
#

I see

swift sedge
#

i dont know if you can use threading... but that would not be a good idea to do so

lethal bolt
swift sedge
polar acorn
polar acorn
lethal bolt
#

I Noticed

#

that

swift sedge
#

its half way there

lethal bolt
#

Lol

polar acorn
#

You do nothing, wait one second, do more nothing, then exit

lethal bolt
#

yes....

swift sedge
#

you need to instantiate it inside the coroutine

lethal bolt
#

okay

dim wharf
#

im not used to C#. How do I make it so the other class knows that the class its referring to exists in a different folder

lethal bolt
#

Public?

dim wharf
#

they are public classes

lethal bolt
swift sedge
polar acorn
kind cave
#

public class Script1 : MonoBehaviour
{
    private Manager manager => GetComponent<Manager>();

    private void Update()
    {
        if(manager.b != null)
        {
            mananager.b.Func();
        }
    }
}

using UnityEngine;

public class Script2 : MonoBehaviour
{
    private Manager manager => GetComponent<Manager>();
    private B b;
    private void Awake()
    {
        b = manager.Resolve<B>();
    }
    private void Update()
    {
        if(b != null)
        {
            b.Func();
        }
    }
}

using UnityEngine;

public class Manager: MonoBehaviour
{
    public B b;
}``` Which script will be better for performance? Script 1 or 2?
dim wharf
#

I am not familiar with C# so I'll try looking up assembly definitions

kind cave
dim wharf
#

ok

polar acorn
dim wharf
#

No. Not yet

swift crag
#

also, has Unity tried to reload since you created those files?

#

it needs to see them so that it can update your .csproj files (which your code editor uses to know what files to look at)

dim wharf
#

thanks for this

#

didnt expect it to work like that

swift crag
#

I have Unity set to only manually reload, so I have to tab over and cmd-R it after creating new files

#

If you open the Assembly-CSharp csproj file, you'll see a big list of every single script file

#

VSCode reads that to learn what is and is not part of your project

dim wharf
#

Ohhhh I see

#

thanks

#

im used to java so

#

a lot of c# stuff is new to me

frank zodiac
#

whats the best way to create smooth, 2d platformer movement in unity?

#

should i use rigidbody.addforce or transform.translate?

frosty hound
#

Of those two options, your only option is the rigidbody.

frank zodiac
#

what are the pros and cons

frosty hound
#

Because translating doesn't respect physics, and presumably you'd want things to collide.

frank zodiac
frosty hound
#

But if you do choose to use non physics, you'll have to use raycasts and do your own calculations.

frank zodiac
#

well are there any other good options? like character controller 2d over rigidbody2d

frosty hound
#

There is no CC for 2D built in

frank zodiac
frosty hound
#

So really, it is the rigidbody method if you don't want to get an asset of the store

frosty hound
#

Sure, as long as the rest of your world is using 3D colliders.

queen wren
#

I'm trying to add 2 to a Button event OnClick but for some reason it will add just one event, any reason why?

button.onClick.AddListener(() => { elevatorManager.floors[index].spawnPoint.gameObject.SetActive(true); });```
willow scroll
wintry quarry
queen wren
wintry quarry
#

did you add log statements? Use a debugger?

willow scroll
wintry quarry
#

You need to add logs or use the debugger

queen wren
#

As you can see it adds just the trigger ¯_(ツ)_/¯

wintry quarry
#

that's the only real way to test it

wintry quarry
#

those are for persistent listeners only

willow scroll
#

Also, you can write an inline lambda without { }

wintry quarry
#

Use logs or the debugger to actually test this

queen wren
willow scroll
summer stump
queen wren
willow scroll
queen wren
#

I still prefer + 😅

frank zodiac
#

should i use a circle or box collider for my groundcheck?

summer stump
queen wren
#

But you're right, I'll force my self to evolve even more 😉

frank zodiac
verbal dome
queen wren
#

but to improve is important, and I should use it also in ingame string instead of plus sign

willow scroll
# frank zodiac https://pastebin.com/QAL5tUGE what can i improve with this script?
  • Assign Rigidbody2D in Awake, not in the Inspector
private Rigidbody2D _rigidbody;

private void Awake() => _rigidbody = GetComponent<Rigidbody2D>();
  • You can keep the ordinate the same by multiplying the abscissa by Vector2.right
Vector2 movement = movementX * Vector2.right;
  • Create a method to not repeat the same thing, and make sure the layer is checked using your already created LayerMask groundLayer
private void OnCollisionEnter2D(Collision2D collision) => SetGrounded(collision, true);
 
private void OnCollisionExit2D(Collision2D collision) => SetGrounded(collision, false);

private void SetGrounded(Collision2D collision, bool value)
{
    if (collision.layer == groundLayer)
        isGrounded = value;
}
  • Make sure the region is ended outside of the OnJump method
private void OnJump(InputValue inputValue)
{
    // ...
}

#endregion
summer stump
verbal dome
queen wren
#

but I'm lazy AF 😂

frank zodiac
verbal dome
#

VSCode doesnt like to show intellisense properly inside interp strings

frank zodiac
#

thank you

willow scroll
frank zodiac
frank zodiac
#

wait how do i make my player movement more snappy? when i use rigidbody.addforce it makes the player slide like its on ice

#

should i use a physics material and add friction or something?

summer stump
#

Without friction, you are basically on an even slippier substance than ice. Some absolutely frictionless material

frank zodiac
#

even at max friction theres still sliding

#

which ruins the whole point of my snappy 2d platformer experience

summer stump
frank zodiac
#

and yes its on both objects

summer stump
#

Ah ok. Well, addforce is certainly going to cause SOME sliding, unless you combine it will velocity setting when you have no input

candid rune
#

quick question, is it more expensive or taxing to pull functions or variable from other scripts?

ivory bobcat
#

You'd need to profile it. Other than that, stick with what's readable and possibly follow the SOLID principles.

swift crag
short hazel
#

If it's a DateTime value, then you can call .ToString() on it and pass a custom format string to that method.

#

Do note that by default, date formatting is localized, which means it's adapated depending on the language of the system your app is installed on.

#

So a user living in the US will not see the same thing as a user living in Germany, for example

#

(default ToString() without any custom formatting applied)

stuck palm
#

what does this mean? theres no stack trace

short hazel
#

Seems like a coroutine failed to resume after a yield. First time I see that one though

#

Maybe the object with the coroutine was destroyed but Unity still got a reference to it, somehow?

worthy merlin
#

I was working on a scriptable object to hold my Operation data for game scenes. I wanted to add a variable for the scene this operation is in but for some reason it is not showing in the inspector?
Called as public Scene OperationScene;
https://gdl.space/edimeyogeh.cs

swift crag
#

Scene represents a loaded scene and is editor-only, so you can't serialize it.

short hazel
#

Scenes are not serializable. You'll need another way to reference a scene, by name or build index for example

swift crag
#

there's this lil guy

#

I use something I copy-pasted from the unity forums several years ago, as god intended

swift crag
worthy merlin
#

using Udar.SceneManager; nvm found it. Finally showeed in my VSC list

swift crag
#

add a SceneField field to your class

lethal bolt
#

Why isnt the boost working

modest dust
#

First of all, are you getting the log in the console?

polar acorn
modest dust
#

Second of all, is the speed boost value in the inspector the same as expected (40 in this case I presume)

polar acorn
#

every time you press space you move forward a bit

lethal bolt
modest dust
#

Third of all, this boost is active for one frame, so the deltaTime is small, thus the boost is small

polar acorn
lethal bolt
#

So i take away Down?

modest dust
#

Yes

lethal bolt
#

Thanks.

#

👍

stuck palm
short hazel
#

From what I could see on the forums is that it can happen when you use StopCoroutine() to stop a coroutine that was started on another object. The error seems harmless though

stuck palm
short hazel
#

eg.

Coroutine c = obj.StartCoroutine(M()); // coroutine is started on 'obj'
StopCoroutine(c); // attempt to stop the coroutine on 'this', but it was started on 'obj'
obj.StopCoroutine(c); // correct
stuck palm
#

wait that makes sense now

#

cus the issue as from an explosion

#

that destroys itself

#

that makes much more sense

#

i thought startcoroutine did that impliocitly

#
public Coroutine CurrentStun
    {
        set
        {
            if (currentStun != null)
            {
                StopCoroutine(currentStun);
            }
            currentStun = value;
        }
    }

    [SerializeReference] private Coroutine currentStun;

is this a good way to do this?

void thicket
stuck palm
#

But basically I only want one stun coroutine happening at a time

#

So when it gets set, it turns off the old one if there is any

void thicket
#

So it doesn’t make much sense that it is set by public property

#

Better way is having StartStun() method or something

#

And manage coroutine internally

stuck palm
void thicket
#

Logic inside the coroutine.

stuck palm
#

I see

#

I just left the house but will review this when I get back thanks

flint python
#

from the unity documentation "OnDestroy occurs when a Scene or game ends." if I have a listener, and I want to remove it in OnDestroy, but the game crashes, or is forced to terminate, what happens to this listener? does it still exist?

slender nymph
#

that memory will get cleaned up by the OS

short hazel
#

When the game crashes the process is stopped abruptly. It's the same as graceful shutdowns, the memory is freed and can be repurposed to other processes

wintry quarry
vernal thorn
#

I want the player too go in the direction and not too the cursor : (

    void Jump()
    {
        Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 direction = (mousePosition - transform.position).normalized;

        float appliedForce = Mathf.Lerp(minJumpForce, maxJumpForce, Mathf.Clamp01(holdTime / maxHoldTime));
        rb.AddForce(direction * appliedForce, ForceMode2D.Impulse);
    }
swift crag
#

well, you told the player to move towards the cursor...

vernal thorn
#

yeah

dense root
#

What is the purpose of normalizing a vector?

swift crag
#

a normalized vector has a length of 1

vernal thorn
swift crag
#

this is important any time you need a direction

#

you wouldn't want to move faster if the mouse was further away

swift crag
#

i have no idea what you actually want to do

vernal thorn
#

So i want too make that the player jumps in the direction of the cursor and the longer the mouse button is hold down the player jumps wider (like golf or jumpking)

swift crag
#

but you said you don't want that

#

I want the player too go in the direction and not too the cursor : (

vernal thorn
#

I said i want that two times now

void thicket
vernal thorn
#

I want the player too go in the direction

#

So i want too make that the player jumps in the direction of the cursor

swift crag
#

This makes no sense. You said you want it to go in the direction of the cursor. That's what your code does. But then you said you don't want it to go in the direction of the cursor.

#

You're going to need to show me a video of the problem if you can't explain it.

upper forge
#

what does Quaternion.Euler do and mean?

swift crag
void thicket
upper forge
swift crag
#

you should consider doing that (:

dense root
swift crag