#archived-code-general

1 messages · Page 83 of 1

warm oasis
#

you go along

glossy basin
#

you can use a structs then and you wont even need to add the data "physically" to the tile, via code you could for example set a tile in x or y axis and then set a struct on that axis to contain some data

faint hornet
#

good to know. also how many years of exp do you have in gamedev

faint hornet
glossy basin
#

Nah, not at all, you only need to be very perseverant with this, as you will find problems most of the time a beginner

warm oasis
glossy basin
warm oasis
#

my first commercial game will go out soon, but i've been through networking code and many more first

faint hornet
#

i would love to work on a game with people like game jam stuff. do you guys do that?

glossy basin
#

but try to learn on your own to not relly on others

warm oasis
#

as storm said you need to be perseverant and never give up

#

make your own goals progressivly as you go on

faint hornet
glossy basin
# faint hornet thats kinda how i want to do it

you said previously you were looking for something like minecraft, and minecraft indeed does this that way, and as a fact, the project im currently working on is a highly optimized minecraft but made by myself

faint hornet
#

i feel like im at that stage to start working on projects with others to learn through collaberation and getting out of my comfort zone

faint hornet
glossy basin
#

wait until you mess with Jobs system, ECS and more advanced stuff

warm oasis
#

that's what's exciting about this all you will always find new things in coding that's better than before

#

but you never go against your tools

faint hornet
#

i don't like being in a learning drought

#

i try to learn at least one new thing everyday. i probably spent a few hours every day for the past 8 months writing code. wether it be JS or C#. i love it all

faint hornet
warm oasis
glossy basin
glossy basin
faint hornet
#

hey thanks guys for your help. i'll be around working on this stuff everyday. feel free to check in if anyone is curious how i get on with it. i do want to thank you guys for your time. super grateful!

will talk later. thanks again!

worn bone
#

What do y'all think about having a file where all enums are declared?

#

Is that bad practice?

latent latch
#

You could consider containing what you need in namespaces instead of just throwing it all out into global space

#

but if it's like a small project then it's probably not that big of a deal

thin aurora
frosty lark
#

the left images look like vsync issues

#

screen tearing

dry lantern
#

where do i fix that?

frosty lark
#

idk im just guessing to help haha

dry lantern
frosty lark
hexed pecan
#

Is it a VR project?

#

I dont think its VSync - the lines would be horizontal not vertical

#

Also it would not be visible in a screenshot afaik

dry lantern
hexed pecan
#

So it is VR

#

You should include that and other related info in your questions

frosty lark
hexed pecan
#

Yeah, synchronizing the horizontal scanlines vertically

frosty lark
#

welp i stand corrected

dry lantern
hexed pecan
dry lantern
#

the lines

hexed pecan
#

No

dry lantern
#

oh

frosty lark
#

have fun reading

hexed pecan
dry lantern
frosty lark
#
Frame timing in VR mode works exactly like it does in VSync-enabled non-VR mode (see documentation on the Execution order of event functions). The only difference is that Unity does not depend on the underlying 3D SDK’s VSync
, but instead whichever VR SDK it currently renders with. There is no benefit to rendering faster than the display can refresh. Instead, Unity focuses on utilizing the time most efficiently. 
#

this sounds like its already enabled?

dry lantern
#

idk

#

lmao

frosty lark
#

it sounds like

#

you move the hand

#

the framerate is faster than the refrsh rate

#

so when you move the hand it tears

#

im guessing

dry lantern
#

no its always like that

#

even when i just start the game

#

whatever

#

im tired

#

gn

frosty lark
#

gngn

steady granite
#

Hi, maybe not code related, but do you know how I can avoid these health bars acting weird? The white frame part stretches with the character animation going behind it... the frame sprite is a basic straight bar (150*18 set as native size in canvas)

leaden ice
#

Definitely not code related

south violet
#

Hey, Ive got a problem with testing. I wonder if its possible to set value to class' private variable without using reflections?
Here is my example code as image and text:

    public class MySO : ScriptableObject
    {
        public int SomeValue = 0;
    }

    public class MyMB : MonoBehaviour
    {
        [SerializeField] private MySO mySo_privateField;

        private void Awake()
        {
            mySo_privateField.SomeValue = 5;
        }
    }

    public class TestMyMB
    {
        private MyMB mb;
        private MySO mySo;
        
        [SetUp]
        public void Setup()
        {
            // I create new GO and disable it so Awake wont be called
            GameObject gameObject = new ();
            gameObject.SetActive(false);
            mb = gameObject.AddComponent<MyMB>();
            mySo = ScriptableObject.CreateInstance<MySO>();
            // Here I would like to assign `mySo` to `mb.mySo_privateField`
            gameObject.SetActive(true); // Enable object to call Awake()
        }

        [Test]
        public void TestSomeValueShouldBe5()
        {
            Assert.AreEqual(5, mySo.SomeValue);
        }
    }
leaden ice
south violet
leaden ice
south violet
wild warren
#

i want to create a graph of the players progress for eachday of the week

#

how can i achive this with playerprefs??

#

is there any example on this??

soft shard
wild warren
soft shard
# wild warren each day the player comes and play their strength will increase or decrease, and...

I would imagine that kind of data would be in a file or on a database, with for example JSON or some other serialization, I would imagine youd want to store a DateTime with the strength value (and possibly any other values that might be affected), and a database could organize that or a serialized class could group that data - PlayerPrefs is a bit limited in the kind of data it can store

wild warren
soft shard
# wild warren i have a database, is there any example that is similar to my description so i c...

If you already have a database, I would maybe use that instead of PlayerPrefs for what it sounds like you want to do, I cant think of any examples atm, maybe Code Monkey may have some videos on YouTube for graphing, if your just looking to plot your existing data, you could maybe use sprite renderers and line renderers or UI elements, or possibly shaders or mesh generation (though that might be overkill for your case)

cosmic rain
wild warren
cosmic rain
wild warren
cosmic rain
peak halo
#

Hey! Was wondering about something and would appreciate some of your thoughts on the topic.

Do you think that it is better to use a special namespace for your game when writing scripts or should I just write the whole thing without a namespace?

eg.

using This;
using That;

namespace MyGame
{
    public class Player : MonoBehaviour
    {
        //Stuff
    }
}

or...

using This;
using That;

public class Player : MonoBehaviour
{
   //Stuff
}
peak halo
heady iris
#

I was just thinking about this yesterday

somber nacelle
# peak halo Hey! Was wondering about something and would appreciate some of your thoughts on...

it's really up to you. it's generally good practice to organize your code into namespaces, an added benefit of doing so is fewer name collisions if you decide to reuse a name for some component. but there's also nothing stopping you from just writing all of your code in the global namespace

namespaces are an organizational tool that only you can decide will be useful for your project or not

#

if you're writing a library that will be used by other people then you absolutely should use namespaces, but if you are the only one who is going to use your code and it is for your own game then it really depends on what you think makes sense for your project

heady iris
#

one way to think of it

#

if everything is gonna be in the same namespace, there's no point

#

also, this is one hell of a nitpick, but without file-scoped namespaces, everything's going to get indented by a level :p

#

i guess you could just tell your formatter to not indent the namespace block

cold parrot
#

not using namespaces is such an antipattern/code-smell

peak halo
#

I kinda wanna start using now but it's too many scripts now so gathering the courage now

#

also still have to do a lot of reformatting for the new stuff I learned here a few days ago

#

was doing that

peak halo
cold parrot
# peak halo what does that mean?

it probably means that the code was written in a vacuum without regard for structure, any usage from the outside or in a more complex project

earnest gazelle
#

Which one do you prefer?
To initialize components of a gameobject after instantiation.
1- Call Initialize method of entry or main component on a gameobject and pass data to it. Then, inside that main component, initialize other components.
2- Call GetComponent and Initialize method for each component on that gameobject after instantiation outside the gameobject
3- Create a factory or Initializer class, it is like approach 2 just refactor and extract it.

cold parrot
#

2 sounds like someone tried to be too modular and made a lot of ravioli nobody understands

earnest gazelle
cold parrot
#

2 is OK if you are working at Unity Technologies and make core engine features

earnest gazelle
#

1 is OK but that main component should keep all components and has ref to them, tight coupling, probably it is OK if only for initialization and not encapsulate other behaviours like a facade

cold parrot
cold parrot
#

i think this is a big missunderstanding when it comes to dependency injection

earnest gazelle
#

That entry or main component just initialize? because I have seen some developers choose the main component as an initialization and also put some common data and behaviour on.

cold parrot
#

if you have proper IOC, it feels like you are writing the most thightly coupled code, taking to everything "directly", but you've been clever, and that com happens through interfaces, which makes it very robust/flexible

cold parrot
#

this greatly aids in understanding the identity/purpose/role of objects and provide an extensible entrypoint for adding behaviour

earnest gazelle
#
// After instantiaion ItemEntry has been used
public class ItemEntry:MonoBehaviour{
   public void Initialize(ItemData data){
       _data = data;
       // get component or ref and then call Initialize methods of components.
       _component1.Initialize(data.Property1);
       _component2.Initialize(data.Property2);
      //...
   }
   // other common methods here
}
cold parrot
#

so when viewed over time, some such components have behaviour, because they are young and innocent, others have gathered further subcomponents and only do the coordination/inject/inti/dispose of the object

cold parrot
earnest gazelle
cold parrot
#

you definitely want to have the interfaces explicit somehow so they static code analysis can catch any type errors

earnest gazelle
#

and what about other methods on that ItemEntry?
I prefer to keep it just for initialization and for other behaviours add another component.

cold parrot
foggy dagger
#

how do you draw a shader on the screen?

cold parrot
foggy dagger
cold parrot
# foggy dagger how do you do that?

make a game object, add a mesh renderer and filter, select a mesh on the filter, make a material with the shader, assign that material to the renderer, put it in front of a camera, press play

earnest gazelle
#

For example suppose if item level changes, we should update some components on that gameobject.
We can call ChangeLevel method on ItemEntry then inside it, change level (data/model) and call appropriate methods of components. All of them are in one place (ChangeLevel method of ItemEntry). ItemEnry is like a controller, a gate.
Another approach is event based. Other components listen to an event on data or getting/ reading a desired property of data and update itself based on. In this approach, ItemEntry just updates data.

public class ItemEntry:MonoBehaviour{
   public void Initialize(ItemData data){
       _data = data;
       // get component or ref and then call Initialize methods of components.
      // for loop over components
      foreach (var component in _components){
        component.Initialize(data);
      }
      //...
   }
   // other common methods here
   public void IncreaseLevel(){
      _data.Level++;
      _component1.Render(_data.Level);
      _audio.Play(ItemAudio.LevelChanged);
   }
}
public class Component1: MonoBehaviour{
   private ItemData _data;
   public void Initialize(ItemData data){
     data.LevelChanged+=OnLevelChanged;
   }
}
thin aurora
#

You know when I told you about that callback, I linked documentation on how to read your input using the new system. It very clearly explains how it's done, so I suggest you give it another read

sour wasp
#

any non-side keys are just completely ignored

#

same goes for color keys, only the side keys do anything

peak halo
#

Another question; should I name a private but serializable field like _value or Value?

#

like private or public?

sour wasp
#

the standard is usually _value for private fields, and eitherway when showing the serialized variable in the editor unity capitalises its name

#

so you could go with _value

neon plank
#

Hey, I'm having a weird problem with collision.
I have an enemy, and when it dies I uses use ragdoll on its corpse.
Basically, the enemy has two skeletons: the non-ragdoll -which is used when it's alive, and then it's disabled-, and the ragdoll skeleton -which is only enabled after dead-.
I don't want the player be able to collide with the corpses, so I created a layer "Destroyed Parts" for them, and configure it in the Collision Matrix to ignore "Player" layer.
However, for some reason the player is able to walk above the corpses rathen than just move throught them (ignore the collision). And I'm not sure why, any possible ideas?
I checked and no collider has configured any Layer Overrides, and their layers are correct, so in theory they shouldn't collider... but it doesn't.
What am I missing?

peak halo
#

Not very familiar but you should probably send a screenshot of the layer configuration in the preferences & inspector and the code.

peak halo
red scarab
#

How can I "offset" a sprite so that its bottom-left is at transform.position? What I mean is, I have some 16x16px sprites, and also some 32x32px sprites. When I set either to transform.position = someVector3 I want the bottom-left of both to be at someVector3

#

Right now I just set the pivot of each to the bottom-left (Vector2.zero) ... but that makes it really weird to scale the thing (it scales about the bottom-left, when I'd prefer to scale about the center)

normal cedar
#

How can I call event of EventTrigger? For example, I wanna call event OnDeselect.
How can I do this?

leaden ice
normal cedar
leaden ice
#

not sure how it'd be that useful though

leaden ice
normal cedar
#

What should I pass in param.

leaden ice
#

yeah you can call it just fine

#

you're just not providing the parameter it needs

leaden ice
normal cedar
#

Yes, but what exactly data.

leaden ice
#

whatever data you want

#

you're calling it

heady iris
#

i suppose they don't know how to get an instance of BaseEventData

leaden ice
#

make a new PointerEventData or something

heady iris
#

if OnDeselect doesn't care about the contents of that BaseEventData object, then you've got a lot of leeway

#

yea

leaden ice
#

If your listeners aren't using the parameter it really doesn't matter

#

you could even pass null if they ignore the param

normal cedar
#

I think that global EventSystem in Scene.

heady iris
#

required?

#

do you mean you had to add using UnityEngine.EventSystems; at the top?

#

because its fully-qualified name is UnityEngine.EventSystems.BaseEventData

normal cedar
heady iris
#

ooh, I see

#

sorry, thought of the wrong thing there

#

just give it a null, tbh

#

as praetor suggested

leaden ice
normal cedar
heady iris
#

ah, of course

normal cedar
red scarab
leaden ice
flint sierra
#

How can I debug a Unity project built in Xcode? My unity project crashes on a build for Mac with no error.
Building for Xcode and it stops on assembly code.

Attaching VS Code to the Mac Build and stepping through just shows that the last file it was trying to access was OnDemandRendering.bindings.cs which it says it cannot be found.

red scarab
#

I don't WANT to put the sprite in a child object but I may have to.

#

That seems to be the de-facto fix according to others

leaden ice
#

because the pivot acts as both

red scarab
#

it'd just be nice if the sprite was separate from the transform itself. Like, if I could have a SpriteOffset value, without affecting the pivot

#

but others have raised this point as well and it seems like it's a non-priority for unity devs atm

leaden ice
#

that's exactly what it is already...

red scarab
#

brainfog lol

polar marten
polar marten
polar marten
#

you should also try a mono build first

polar marten
latent latch
#

So I'm trying to think up ways to create a class that handles triggered abilities depending on specified conditions. An example of one of these abilities is say, when the player catches on fire, increase their movement speed by a percentage. I'll probably want to categorize these triggers for when I want to check them, but I guess what I'm trying to figure out is how to make this class with minimal hard coding. Maybe what I am looking for is some sort of super class where I have all the conditions available, and the effect would be applied when all the conditions are met.

#

I can't imagine a lot of games of recent develop these type of systems with minimal hardcoding. Perhaps some parsing is involved lol

sour wasp
#

i'm using URP, specifically with a 2d setup

#

i can understand now why it didn't work before

#

since 3 keys needs 3 points for the color uv

polar marten
#

the complexity depends on: how big of a design space you want to support?

#

is this a networked or single player game?

latent latch
#

ive got some networking going, but otherwise relatively small roguelike-ish game

polar marten
#

and will effects be able to modify other effects like metaprogramming? for example, a slay the spire card that does this would say "whenever you would draw a card, discard a card instead."

latent latch
#

yeah, I got an ability system already going with some meta stuff working

polar marten
#

okay

#

is the design space "all of slay the spire"

#

it sounds like a platformer

#

or like "all of hades"

latent latch
#

I'd go with hades and vampire survivor

polar marten
#

okay

latent latch
#

^^

polar marten
#

so it sounds like you picked all three of the hardest options
✅ networked
✅ a design space larger than games that took years to make with huge audiences
✅ metaprogramming

#

is that correct?

#

i feel like i'm turbotax

latent latch
#

absolutely

polar marten
#

lol

#

can you show me a snippet of some example gameplay you already have working? like an implementation of a sophisticated item

latent latch
#

let me see if I can get this to compile

polar marten
#

"can you show me your w2"

polar marten
latent latch
#

That's what I got with my ability system so far

polar marten
#

okay

polar marten
latent latch
rose token
#

I'm making a stickman shooter game. I want the stickman to hold the weapon in his hand, as the stickman is rigged with rigidbodies and hingejoints I made it such that each weapon offsets the arms a given amount as seen on the second picture there is a slight bend in his right arm, whilst the left is on the barrel of the weapon. The weapon follows the stickman using a ParentConstraint component, which has a constraint source for the left and right hand transforms such that it follows those. I might have configured the parentconstraint wrong since on certain occassions the stickmans arms behaves in an undefined way.

This is the code that makes the stickman aim:

polar marten
#

any experience modding any games?

#

or similar games?

rose token
polar marten
#

or maybe a previous game you've worked on that has a "gameplay ability system"

latent latch
#

ah, dota 2 I've done a bit

polar marten
#

okay cool

latent latch
#

I actually wanted to do something similar to their system, but it's a lot of work for that

polar marten
#

okay

heady iris
polar marten
polar marten
polar marten
latent latch
#

;)

#

it's so convenient

pearl whale
#

Unity crashes with code anyone knows why ?

private void OnTriggerEnter2D(Collider2D other)
 {

        StartCoroutine(waiter());

        IEnumerator waiter()
    {
        while (true)
        {
            if(!other.gameObject.CompareTag("carotte"))
            {

        yield return new WaitForSeconds (0.5f);

      Debug.Log("sus");

     }

    }

   }

 }
thin aurora
tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

heady iris
polar marten
#

it's realtime like hades is?

#

and you want two players to share that same space?

#

all of this stuff is possible

latent latch
#

Yeah, it works pretty well. However, I kinda do it a composite way instead of oop because there was too many edge cases I was running into.

polar marten
#

knowing what you've shared with me, i would probably have used ECS

latent latch
#

yeah

#

ecs would been way better

polar marten
#

but let's not rewind your working thing

#

in order to "lift" piece by piece

#

into what you need

latent latch
#

I've just hide a lot of data, used or not used, but I manage to minimize what can be used via attributes

polar marten
#

is this what you are doing right now to add more behavior: literally select big portions of a method, extract to its own method, declare virtual, and subclass. then in your scriptable object, when you want to declare a new type of behavior, refer to that subclass instead?

#

the key trick of ECS systems is that they force you to write stateless functions. you can do that in any context. in my card game, i have a huge stateless library of gameplay functions. it literally has entities, just no components per-se

#

the specific structure of what "attributes" looks like... it's okay if it's "just a dictionary"

latent latch
#

lot of the logic is done in a procedural way, so I do a bunch of checking. It's not ideal but I kept rewriting and minimizing my classes till I just realized I should just focus on more of a single super class.

#

a lot of functionality is loaded into containers which is checked, which is how all the meta stuff works

polar marten
#

it is okay to build something that looks like

class Attributes : IDictionary<Attribute, object>, ICloneable<Attributes> {
 public int health => this[Attribute.HEALTH];
 
 ...
 Attributes Clone() {
  var copy = new Attributes();
  foreach (var (attr, value) in this) {
   if (value is ICloneable shouldBeCloned) {
    copy[attr] = shouldBeCloned.Clone();
   } else {
    copy[attr] = value;
   }
   ...
  }
 }
}
polar marten
#

i think you can make a library of stateless gameplay functions

#

that is your gameplay. for example void DealDamage(...)

latent latch
#

right, that's my intentions

polar marten
#

and write all the interactions in there statelessly

#

that's all fine

wraith thunder
polar marten
#

the attributes example i'm showing you is just to say that this amount of ceremony is normal and unavoidable

#

neither c# nor ECS provide a way to do this

pearl whale
#

ok

polar marten
#

Instantiate sort of does... but it is really cantankerous to go all in on game objects as "the decoupled way to represent my gameplay"

#

a single super class for everything is sort of fine. you can always pull out a function and move it somewhere

latent latch
#

ive done some of the ecs stuff in rust, and I would like to attempt dots but im a little far in to migrate it all

polar marten
#

i wouldn't necessarily reinvent types

#

yeah

#

in hearthstone when healing deals damage instead, they have a global attribute called HEALING_DEALS_DAMAGE

latent latch
#

but ability systems in oop is actually quite hard it seems

#

dota 2 just parses everything

polar marten
#

and that's also how spellsource works

#

when drawing discards instead, they have a global attribute called DRAWING_DISCARDS

#

in spellsource, since it was more mature at that point, DrawSpell is replaced with DiscardSpell

#

the science that makes that possible is that all the abilities have the same function signature

#

and the arguments are just interpreted contextually. for example, int value means the number of cards to draw in a DrawSpell, but it means the amount of damage to deal in a DamageSpell.

polar marten
#

but, if you wanted to migrate to it

#

which metastone, the thing i studied to write spellsource, did

#

you are venturing into "poorly implemented half of LISP" territory

latent latch
#

oh yeah ehhh

polar marten
#

so you might as well use a scripting language that is constrained in the right ways.

#

so for example, cards in spellsource (a hearthlike) are written in JSON

#

and the JSON is a poorly implemented LISP

#

so is galaxyscript

latent latch
#

Yeah exactly what dota 2 does

polar marten
#

the essential feature of the scripting languages is that the usercode's state is exclusively on the stack, it is otherwise stateless, and execution is totally preemptible ("async")

#

another way of putting this is that it is totally context free, but even spellsource card script does not obey that

#

if i were doing it all over again, i would probably write the whole game engine / ECS system inside clojure* and implement the cards that way

polar marten
#

you can look at XMage to see how they do it for java

swift falcon
#

getting some weird results here, green wirecube is supposed to be the overlap box area, both white rectangles have colliders equal to their sprite size. This is very zoomed in so the gap seems large.
Gizmos.DrawWireCube(groundCheckPoint.position, groundCheckSize); draws the wirecube
but Physics2D.OverlapBox(groundCheckPoint.position, groundCheckSize, 0, groundLayer) for some reason detects the top rectangle despite having no contact with it. Moving it even lower solves the issue for some reason

latent latch
#

Ill probably look into it, there's actually not many systems I've come across while trying to figure out what the heck I've been doing

#

so my assumptions is that it's just hard to develop this stuff rofl

polar marten
#

yeah

swift falcon
#

docs say that both wirecube and overlapbox take rectangle center as their first argument

polar marten
#

clojure has the best set of features for this

#

i don't think it is something that you can "just" migrate to

#

but you would look for things similar to it. lua is not similar

#

you'd be reinventing homoiconicity in lua in order to do the metaprogramming esque gameplay

#

that said, you can also deal with the 10 situations that will appear

#

using a bool.

#

that is what you are doing now, it works

#

does that make sense?

#

just like in my hearthstone v spellsource examples

latent latch
#

yeah, the bool has been working wonders haha

polar marten
#

i don't think it's worth migrating away from that right now

latent latch
#

for what I have, there is very minimal edge cases or I've divided enough into categories where there can only be a limited amount of selections

polar marten
#

you can keep doing your ubershader approach

polar marten
#

yeah

#

i mean this is in a good place

#

i think the networking is going to get you

latent latch
#

the object pool with projectiles im kinda stuck at

polar marten
#

and you're going to reconsider that or you'll use a service like mine to network a local multiplayer engineered game

latent latch
#

for the networking

polar marten
#

the way modders add multiplayer to games like this

#

is painstakingly synchronizing everything

#

and QAing the hell out of it because they are 14 and have infinite time

#

the thing is you already know all this. you can do things way #1 and do it in 1 year or do things way #2 and do it in 6 years

#

but if way #2 is playable sooner that's a bigger deal

latent latch
#

pretty muchh what's been happening so far

#

too much time trying to perfect some of these systems

#

back to my c roots and just brute force it all

polar marten
#

really depending on your goals

#

if you want to lift your unity based game into something that is genuinely networked multiplayer without adding 2 years of development

latent latch
#

oh yeah that sounds like quite a project

polar marten
#

this is to illustrate that i think about this a lot

hexed pecan
swift falcon
polar marten
swift falcon
polar marten
#

since DOTS didn't exist at any time i've started something that wound up having an audience. then it arrived, but it doesn't really solve the pain points of multiplayer

swift falcon
#

collider size is (0.49, 0.03), but it stops hitting the top rectangle when it's positioned lower than -0.535

#

top rectangle is (0.5, 1) in size btw

latent latch
#

So far I've used photon, but I'm liking fishnet this time around

polar marten
#

DOTS makes it possible to develop a multiplayer game entirely inside the unity editor and Unity's ecosystem, but that's only solving problems for Unity Inc., not for you

swift falcon
#

above that it returns the top collider for some god unknown reason

latent latch
#

unity's stuff doesnt have interpolation/prediction stuff yet and I was hoping it was to be done by last year

#

that's be for my next project

polar marten
#

it's complicated. at the end of the day, in order to find out if it works, the pain point is building the fucking game and doing all the ops to test it over the network

#

ECS doesn't solve that for you

#

the streaming technology i developed does

#

even if they promise you that unity.physics does "interpolation/prediction stuff"

swift falcon
#

okay now THIS is stupid

polar marten
#

well... you don't believe it now do you

latent latch
#

eventually ;)

swift falcon
#

what the hell is even going on

#

so it's not offset, it's incorrectly sized

violet mesa
#

does anyone know why this happens?

swift falcon
#

even if I render double its size and put it at -0.535 (like what would happen if used twice the size of the given vector) it still doesn't visually hit the top rectangle yet still triggers

swift falcon
hexed pecan
violet mesa
#

how did that go away?

#

lol

#

thx

swift falcon
uncut plank
#

hello, im attempting to make a full body fps controller and im trying to make the upper body rotate based on mouse movement, i have this line of code here that runs through a list of 3 spine bones and rotates them based on the mouse values (rotationY and rotationX) multiplied by the individual bones weight. However when i run this code it will bend the spine up and down correctly but it jitters back and forth and refuses to move left and right and i have absolutely no clue why. Any ideas?

heavy lynx
#

I have this code in which the inteded outcome is that when a new room is spawned, spawn 1-3 enemies in the room at the positions, -8 <y<8 and -8 <x<8, with x=0,y=0 being the origin of the spawned room. However the enemies are spawned very far out and i do not know why.

heady iris
#

the room is scaled, isn't it?

#

(1,1) in the local space of a (10,10) scaled object sitting at the origin is (10,10)

heavy lynx
#

what the fix

#

like how do i apply the scale

heady iris
#

it sounds like your random range is meant to be expressed in world space

#

-8 meters to 8 meters

#

i'd just transform Vector3.zero into world space

#

then add an offset

#

although...that would malfunction if the room was rotated

heavy lynx
heavy lynx
heady iris
#

literally just do it

#

transform.TransformPoint(Vector3.zero)

#

this will give you the world-space position of the room

heady iris
#

so, measure the size of the room when it is not scaled

#

that's the range you should be generating the random values in

heavy lynx
#

is there a way for me to apply the rooms scale

#

so that the new scale is 1

heady iris
#

if only the room is scaled

#

and none of its parents are

heavy lynx
heady iris
#

then i guess you could do this:

float xRange = /* something */;
float zRange = /* something */;
xRange /= transform.localScale.x;
zRange /= transform.localScale.z;
#

now you can compute the random values as you already do

heavy lynx
#

bruh

#

just found another fix

#

divide 8 by the scale

#

which is 20

#

so instead the ranges are .4 and -.4

#

lmao

heavy lynx
#

👍

uncut plank
#

Ok i found a severe problem which i cannot find a solution to online, when using Input.GetAxis("Horizontal") it just doesnt work at all, and yes it is set up in the project settings. When i use Input.GetAxis("Mouse X") it just jitters back and forth and does not move, almost like something is actively trying to hold it at 0. But when i make the float public i can see in the inspector that Mouse X is working and i am getting values when moving the mouse but whatever im trying to rotate simply WILL NOT rotate on the x axis. I need help im out of ideas

earnest gazelle
#

To keep data assets like buildings, items, etc. some developers prefer to keep their fields in a list/dictionary key/value pairs implicitely instead of creating properties for each type explicitly.
What do you think? why did they choose this approach? because this way is more flexible? we can add/remove properties easily?

Dictionary<string,IEffector> Effectors;
Dictionary<string,IInput> Inputs;
//...
swift falcon
#

can you show your input system settings?

uncut plank
#

I have not touched the input settings but here they are

swift falcon
#

oh huh

#

what do you mean by it not working btw?

#

what value does it return

uncut plank
#

absolutely nothing happens when i use horizontal it returns just 0

swift falcon
#

hmm

#

maybe its your keyboard language that messes it up? make sure that it's set to english or check if arrow keys help

uncut plank
#

nothin

swift falcon
#

hmm weird

uncut plank
#

extremely

#

actually using my A and D keys when using Horitzontal gives me values

#

on my rotationX float

stoic creek
#

the fish (blue thing) just teleports to the food (yellow thing)

#

it doesnt move towards it

#

but teleports instantly

uncut plank
fringe scroll
#

So I have been using Unity for about 10 years and for some reason I just had a question about Rigidbodies that I never thought to ask.

I know you need rigidbodies for collision detection to work. So what I'm wondering is if I'm not doing physics based movement/collision do I need to call the rigidbodies move function or can I just do movement based on a gameobjects transform property?

stoic creek
polar marten
#

you will get the callbacks after fixedupdate, which is the same as when the rigidbody is moved with forces

#

this means if you move a rigidbody in Update, the earliest you will get collision callbacks is the next frame. this might be unexpected if you move a rigidbody using transforms

swift falcon
#

I believe I found something - it seems that the issue is unrelated to the overlap box size as distance at which it triggers is static

leaden ice
swift falcon
#

move player onto a different layer and raise the colliders into them?

peak halo
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

peak halo
#

Hey! Was wondering how I can utilise interfaces in this case as one of the classes are made to just be assigned an item while the other is for keeping countess items in a list.

Code: https://gdl.space/ixuzeyopax.cs

leaden ice
peak halo
#

aight gonna give it a try. was also what I thought of, just needed to hear it from another person

#

what'd I call it hmmmm

#

IAssignable?

#

nah

#

interesting

fringe scroll
glossy basin
#

Hello there, Im trying to use the profiler to debug whats causing this GC alloc, but it only displays profiler.callStack, I enabled both call stack and deep profile but the result is still the same

thin aurora
uncut vapor
#

Is it possible to save TMP font asset with newtonsoft?
Cuz it gives an error of UnassignedReferenceException: The variable atlas of TMP_FontAsset has not been assigned.

peak halo
#

I ended up not using interfaces at all as just putting these methods on the base class that all the storage UI classes inherited from made a whole lot more sense

wheat spade
#

I am attempting to add a singleplayer mode to my multiplayer game. I am using Unity's Relay and Lobby. From the research I've done, most people say to have a server run locally on the computer and not let anyone else connect. While all that makes since, and it is what most people do when testing multiplayer (ei. they make a build on their device and connect the build and editor), this does not work with the Relay transport protocol. I've attempted to change the protocol type from Relay to the normal, but the protocol doesn't have a setter. Then I tried to set the Network Transport at runtime instead of in the inspector, and also couldn't figure out how. If anyone knows how make Relay start a host without needing to send data online, I'd appreciate that.

rain saffron
#

Is there a function to check whether a prefab (GameObject in an array) has been instantiated?

Not sure if I'm thinking about it the wrong way, but I'm attempting to have an array of prefabs, then instantiating them when needed directly into the same array.

Roughly: if (array[X] == isNotInstatiated) { array[X] = Instantiate(array[x]) }

I don't see anything wrong with the idea exactly, but I'm guessing there's a reason that I can't find an easy way to do it (without creating a flag or additional array)?

simple egret
#

You can, by examining the result of .GetInstanceID() called on the object. If it's negative, instance. Positive, prefab. Or the inverse, I don't remember

#

You could also use two arrays, or a flag yep

peak halo
#

this doesn't mark every prefab but lets you keep track of which prefabs you instantiated before.

#

this may help you find a better solution for your case if you tweak around with it a little

severe coral
#

Can the #if UNITY_EDITOR compiler thingy be used in the middle of a non editor class? Like if I want a certain class to only have a field when used in the editor would it be okay to use it for that case?

mystic ferry
#

you just use it when you want code to only execute in edit mode

severe coral
mystic ferry
#

you might be thinking of EditorUtility.SetDirty?

severe coral
# mystic ferry you might be thinking of `EditorUtility.SetDirty`?

Perhaps I should have worded that better. I already know how to set the values through the editor, by using EditorUtility.SetDirty or through SerializedProperties. But what if I want one of those values to only be present in the editor? So I couldn't even get them after building? Almost like putting a variable in an editor folder if that makes sense.

heady iris
#

unless you're getting some kind of massive savings from excluding the values, it sounds simpler to just not bother

#

i'd expect the serialized data to still be there

severe coral
#

If I can use two lines to do it I'd rather do that

winged mortar
#

so you don't want to make them available after building? Why?

mystic ferry
#

so the [EditorOnly] attribute

severe coral
whole night
#

I was working on wave function collapse to generate rooms for my game but i get these areas which are completely packed ( like ones in the front where there is no door to the room) which just leaves them useless how do i deal with them?

winged mortar
#

Honestly just include them? Make them private or something on the class and add serializefield to them

deep oyster
#

I'm guessing you'll have to do a second pass

mystic ferry
#

if you apply [EditorOnly] to a gameobject, it's removed from compiled scenes. If you just use them on properties or fields, then they're only accessible in edit mode

severe coral
mystic ferry
#

actually it might be a tag in the inspector. I haven't used it in so long I can't remember exactly

severe coral
heady iris
#

this is a tag, yes

#

i am not aware of an attribute with that name

heady iris
whole night
heady iris
#

well, I'd make sure that they don't get used for anything, for sure

#

no enemies are allowed to spawn in there, for example

whole night
#

oh that makes sense

deep oyster
#

Hey all. So I'm using a 2d Tilemap with the Game Object Brush to create the level for my 3d game. But now I need to have a script access it and actually check whether there is a block at a given location.

#

Having trouble finding out how to do that

whole night
#

i might even uncollapse them to see if they generate something new that is now reachable as i am running wfc collapse each frame

heady iris
#

You could also flood-fill to identify blocked rooms, then explicitly create a door in any wall that splits reachable and unreachable areas

#

then redo the fill in the newly-opened room before proceeding

deep oyster
#

Hey all. So I'm using a 2d Tilemap with the Game Object Brush to create the level for my 3d game. But now I need to have a script access it and actually check whether there is a tile at a given location.

#

having some trouble figuring out how to do that

dull yarrow
#

I am going to create a system where the player picks objects, but teh object can only be moved around a specific area
My ideia was to create invisible walls so the object only moves inside that area.
Is a good logic or i can add that on the code?

heady iris
#

"picks objects"?

#

do you mean "picks up objects"?

dull yarrow
heady iris
#

ah, gotcha

#

Is this a 2D game or a 3D game?

sacred dove
#

Hi! I have an error

JsonSerializationException: Unable to find a constructor to use for type GNS3.JsonObjects.GnsJProject. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path '[0].auto_close', line 3, position 21.

Although I have

[JsonConstructor]
public GnsJProject() {}

This error only exists in WebGL build, works fine in the editor
Thanks in advance!

heady iris
#

what is a "GNS3"?

dull yarrow
leaden ice
polar marten
#

or inside a monobehaviour's Start, do var ignored = new GnsJProject(); so il2cpp does not strip the constructor

sacred dove
sacred dove
leaden ice
polar marten
polar marten
# sacred dove Thanks, I'll try it

or inside a monobehaviour's Start, do var ignored = new GnsJProject(); so il2cpp does not strip the constructor
this is guaranteed to work if your issue is il2cpp stripping

heady iris
polar marten
#

it will be less cantankerous to test by making an il2cpp build for standalone

#

it will be faster than webgl

heady iris
#

oh yeah, webgl takes its sweet time

sacred dove
#

Thanks a lot guys, now it works

sacred dove
heady iris
#

good catch, pangloss (:

polar marten
#

i just never know with that crap

heady iris
#

...unless it strips the function that uses it :p

sacred dove
#

Understand

#

Also needed to add the property to fields

dull yarrow
#

How can i get the position of the arrow, if my mouse is that red ball?

#

I have to use ray?

leaden ice
hidden compass
#

are all these coroutines bad news? its only 3.. and the only things that sub to it is sensor on the AI

#

should i redo them with timers? is it going to cause performance issues if (3 is all im going to be using) for this class?

dull yarrow
#

Thanks
And there are any real good tutorials about physics? I watched alot of them and none could really explain that well
One time it works, other time dont
I am moving a object with rigidbody and a collider against a "wall" object and i tried every combination of gravity/kinematic and the object just pass trough the wall

hidden compass
#

try turning on continuous detection on ur rigidbody

#

but that's only if ur moving ur rigidbody correctly and not trying to translate it by moving it with its transform directly

dull yarrow
hidden compass
#

yea.. thats y ur collisions arent working

#

watch that video i shown u. it'll tell u why thats happening.. and further in it'll tell u which ones you can use for a rigidbody

#

this is what will happen.. physics update only happens so often.. if u translate it theres time when your physics update will get skipped for, the translation will move the position too far into the wall, when physics finally catches up it says, oh you're on this side of the wall and you'll clip on through

dull yarrow
#

Because my goal is to create a character move system. When the player picks up the character and move it only in a specific plane
But that character cant be placed where other characters are, so i was trying to use physics to try to make the picked character collide and not pass trough the other characters

#

But i guess i need to make a function that sees if the picked character is "inside" another character it cant be placed down

limber fog
#

OK so i have this code here

{
    public Color color;
    public Material Material;
    public DoorData doorData;
    public float flashtime, f;
    public bool timedown;
    // Start is called before the first frame update
    void Start()
    {
        flashtime = 4;
        doorData.flashlightOn = false;
        doorData.flash = false;
    }

    // Update is called once per frame
    void Update()
    {
        /*while (timedown == true)
        {
            flashtime -= Time.deltaTime;
        }
        if (flashtime <= 0)
        {
            doorData.flash = true;
        } else
        {
            doorData.flash = false;
        }*/
    }
    public void Interact(bool buttonup)
    {
        if (buttonup == false && doorData.doorOpen == true)
        {
            Color color = Material.color;
            color.a = Mathf.Clamp(0, 0, 1);
            Material.color = color;
            doorData.flashlightOn = true;
            Debug.Log("false");
            //timedown = true;
        }
        
        if (buttonup == true && doorData.doorOpen == true)
        {
            Color color = Material.color;
            color.a = Mathf.Clamp(1, 0, 1);
            Material.color = color;
            doorData.flashlightOn = false;
            Debug.Log("true");
            //timedown = false;
            //flashtime = f;
        }

    }
} ```

I recently incorporated this section right here
``` while (timedown == true)
        {
            flashtime -= Time.deltaTime;
        }
        if (flashtime <= 0)
        {
            doorData.flash = true;
        } else
        {
            doorData.flash = false;
        } ```
Now when I interact unity freezes and removing this section fixes it.
How do I fix this?
heady iris
#

well

#
 while (timedown == true)
        {
            flashtime -= Time.deltaTime;
        }
#

this runs forever

#

it never stops

#

nothing in that loop could possibly make timedown become false

limber fog
#
        {
            Color color = Material.color;
            color.a = Mathf.Clamp(1, 0, 1);
            Material.color = color;
            doorData.flashlightOn = false;
            Debug.Log("true");
            //timedown = false;
            //flashtime = f;
        }```
in the actual code i didn't have those two comments as comment and instead actual lines of code, i just commented those because it was freezing unity. this activates when i let go of mouse one
heady iris
#

that doesn't matter

heady iris
#

unconditionally, forever

#

perhaps you wanted to make that an if statement?

limber fog
#

ye, making it an if statement fixed it

heady iris
#

do you understand why?

limber fog
#

kind of?

#

my thinking for the original code was that it would execute what was in the while statement while timedown was true, which would stay true until i released mouse one

heady iris
#

only one thing executes at a time

#

you enter Update, you run everything in Update, you leave Update

vagrant agate
#

So how do I get the world space position of items in a grid layout group. ScreenToWorldPoint doesn't seem to give the correct location for the children

heady iris
#

even coroutines don't run "simultaneously" -- they just get checked every frame

#

so if a coroutine sits in a while loop forever, the game hangs

limber fog
#

that explains why it froze

heady iris
#

if you enter a while loop, you'd better be taking steps that eventually make the condition false

heady iris
vagrant agate
#

rect transform position of the child item

heady iris
#

that is not a screen position

#

therefore, it will not work

#

oops, that was wrong

#

sec

#

wait, isn't it just transform.position as usual

vagrant agate
#

How is the child items rect transform not its position lol ?

heady iris
#

i had suggested doing transform.TransformPoint(transform.position)

this would be trying to treat the world-space position as a local-space position

vagrant agate
#

yea that is not correct, that static method doesnt exist and plus, transform point, transforms a local position into global position.

heady iris
#

ah, yes, I typed "Position" instead of "Point"

#

but yeah, transform.position is the world-space position

#

there shouldn't be anything special about being in a layout group

vagrant agate
#
//myContainer is a GO on the canvas that has 50 child items inside a grid layout group
        foreach (RectTransform canvasItem in myContainer.transform)
        {
            
            //worldContainer is the transform in world space to house all my prefabs
            var myGO = Instantiate(myPrefab, worldContainer);
            
            //position of the first canvas child item in world position
            var targetPos = mainCamera.ScreenToWorldPoint(canvasItem.position);
            
            //change z so its not hiding from camera
            targetPos.z = 0;
            
            //assign position of game world object
            myGO.transform.position = targetPos;
            //this puts every object in the same position at the bottom left corner of the entire grid layout group objects bounds
        }
heady iris
#

oh! yes, overlay canvas. that makes more sense now.

#

i had gone and checked this on a world-space canvas, lol

sacred dove
#

Is there any common interface or parent class of AsyncOperation and WaitUntil (YieldInstruction and CustomYieldInstruction)?

heady iris
#

the z components of the child positions

#

they're all zero, so you're asking for a world point 0 units from the camera

vagrant agate
#

no when you get screen to world point it takes the camera z position which hides your items behind the camera.

#

the x and y is all that matters here for me, it spawns the prefabs at the bottom left corner of the container for every one of them

#

its like it doesnt know the relative position of the items in the layout container

sacred dove
#

Seems like it's only object...

heady iris
#

yeah, check this out

#
    void Update()
    {
        var from = Camera.main.ScreenToWorldPoint(transform.position);
        var to = Camera.main.ScreenToWorldPoint(transform.position + Vector3.forward * 3f);
        Debug.DrawLine(from, to);
    }
#

This would work for an orthographic camera, I'd think

#

...maybe, at least, since the camera never converges to a single point

uncut vapor
#

Hey, I'm using the newtonsoft package and when trying to serialize a TMP font it shows UnassignedReferenceException: The variable atlas of TMP_FontAsset has not been assigned., is there a way to ignore/fix it? I have NullValueHandling on ignore but it doesn't change anything

heady iris
#

but for a perspective camera, asking for a world point that's zero meters away form the camera will always give you the position of the camera

#

notice how each item has a different transform.position, but gives an identical result for Camera.main.ScreenToWorldPoint(transform.position)

#

you need to give the position a z value so that it'll project a non-zero distance away from the camera's center

#

and yeah, it works fine for an ortho camera

solemn raven
#

hey,
what is rectTransform.localPosition represents exactly ?
im having a very weird issue , im changing the localPosition of rectTransform from vector3(-500,0,0) to vector3(0,0,0)
but the position of the rectTransform it utterly different from what it says on the console.

#

at the same time that it what says on console , i debuged it just for that

#

could someone tell me what the hell is that ??

heady iris
#

does it have something to do with the anchoring mode?

solemn raven
#

it might , i dont know, but before I moved it was the same anchor mode

plucky burrow
#

Hey guys, i'm using the built in pixel perfect camera to upscale my game to achieve a pixelated rotation for my weapons... However I noticed that the pixelation looks very ugly compared to some stuff I saw online. I wondered if it would be better to use a shader or something instead of the pixel perfect camera for this purpose or if there is any other option? Maybe it would also be better for smooth movement because the pixel camera is causing some jittering sometimes...Gif for comparison is attached.

swift falcon
#

Is there a way to set FOV for first person view models by scaling them along z axis, It does work but I have no idea how to know by what factor I have to scale it right now

#

Like if I wanted to have a view model of FOV 60 in a camera with FOV 120 I have to scale it by (1,1,0.33) at the camera's origin

#

I got that 0.33 manually but what's the formula for it?

leaden ice
swift falcon
#

Something like a hands/gun in an FPS game

#

Okay I found it, it's Mathf.Tan(originalFov * Mathf.Deg2Rad / 2f) / Mathf.Tan(fov * Mathf.Deg2Rad / 2f);

heady iris
#

huh, neat

quaint rock
#

feel the normal approach is render the view model with a 2nd camera

#

this since it renders last also avoids view model guns clipping through walls too

swift falcon
#

We don't receive any shadows at all

hexed pecan
#

If theres a workaround I'm interested in hearing it

void basalt
# hexed pecan If theres a workaround I'm interested in hearing it

Basically, you have a full animated character hiding on your first person module. The mesh renderer is going to be invisible, but make it still cast shadows. When you equip a gun, you equip the 1st person prefab, and also the gun by itself, into the hand of the invisible skinned mesh renderer. Then you can IK it and have nice shadows. The second gun model connected to the hand should also be invisible, but cast shadows.

#

The shadows probably won't be 1:1 but it works

#

assuming I understood the initial question right

thorny frost
#

I have tried so many things. And I just can't fix my problem. I have a sphere. I want it to stick to walls and be able to roll up walls as if it were an insect. I've used other scenes and tried too import them to mine but they don't preform nicely. Any tips or ideas?

heady iris
#

"used other scenes"?

lean sail
toxic idol
#

something i havent seen documented too well from my searching imo, is repeated sounds on held inputs

#

ive wanted to use update as a way of checking each frame for an input, then putting out a sound continuously as the button is held blah blah

#

and it seems i wrote something perfect for that purpose

toxic idol
#

or onbuttondown, either works. ill show you what i wrote

#

theres just a bug i cant figure out at the moment

#

where the sound wont play at all or plays then immediately stops (cant tell without debug logging) even though it wasnt told to as the input wasnt released

void basalt
#

@toxic idolaudio.playoneshot

#

@toxic idolhttps://docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html

toxic idol
#

havent tried that yet, just messed around with !AudioSource.IsPlaying else AudioSource.isPlaying etc

#

i didnt think itd do a lot lol

#

ill have to show what im talking about

#

hard to demonstrate just my poorly written example

quaint rock
#

so do you want a looping sound while button is held

quaint rock
#

or what the sound playing every x seconds while held

toxic idol
#

its for the movement of a vehicle

void basalt
#

alright, then ignore what I said lmao

thorny frost
# lean sail you havent really given a problem that anyone can tell u a solution for

Oh sorry. So when I move the sphere to a wall it won't stick to the wall. I've adjust to where I use ractracing to see if there is ground then change the gravity to be perpendicular to the wall, I've tried applying upwards force to allow sticking on the wall didn't work. Sometimes it worked on slanted walls (the sphere didn't slide down) but I'm never able to transition to a wall that is 90°.

quaint rock
#

so use OnButtonUp and OnButtonDown

toxic idol
#

a looping sound that plays while held down, then when released it isnt. lets say a vehicle goes up on mouse1, it plays the 'up' sound. some sort of machine sfx. then released and it stops

quaint rock
#

make sure the audio source is looping

toxic idol
#

is it a dumb question to ask how does onbuttonup know its going up though?

#
  • to add more context by the way, it cant just check if the vehicle is going up
#

as the rigidbody doesnt have gravity for my setting

quaint rock
#

OnButtonDown fires on the frame where the button went from up to down

toxic idol
#

a bit complicated

quaint rock
#

OnButtonUp fires on the frame the button went from down to up

toxic idol
#

Huh...Will try that. Thanks Passerby

void basalt
quaint rock
#

so if you press and hold a key, you will get OnButtonDown once, then a onButtonUp once when you release

#

so also i mean GetButtonDown and GetButtonUp, or the GetKeyDown and GetKeyUp methods on Input

toxic idol
#

Thats awesome lol, exactly what I have been looking for. I checked so many API guides and videos on cars (as a similar idea for loopable movement sfx) and nothing when I looked

#

havent tried it so I dont know if it works but seems like it will

thorny frost
void basalt
#

or the gravity is just flickering back and forth

thorny frost
void basalt
#

see if it's actually transitioning to your desired gravity

thorny frost
void basalt
#

@thorny frostNegate the gravity value when you're applying it to the wall

#

"pushes me backwards" sounds like your gravity is in the opposite direction which it needs to be

toxic idol
#

@quaint rock For hours I looked for a solution into this, I cannot thank you enough. I don't know why I was able to realize "ButtonDown" was a thing, but "ButtonUp" wasnt. I shouldve known that way sooner. Looked into so much stuff to figure this out

#

ended up being the simplest thing ever in the end

#

thank you again 👍 ❤️

tepid juniper
#

is there a way to compress texture to ASTC_4x4 in runtime? Not on build time and not on editor. And how to do it if it is possible.

quartz folio
tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

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

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

toxic idol
#

by that I mean like 3 years

lean sail
#

but doesnt that mean u didnt have intellisense working too?

toxic idol
#

some things do some things dont, depends on the mood of Visual Studio that day

lean sail
#

ah thats what i meant, intellisense for anything unity related

cosmic rain
hexed pecan
#

I would need some way to use a culling mask on the second camera but still render the shadows from other layers

void basalt
#

I vaguely remember this exact problem

#

and figuring that it's not solveable

hexed pecan
#

A practical example of the issue is going inside but having your gun still lit by the sun

orchid tree
#

using UnityEngine.InputSystem; it wont let me use this libary for the new input system, any ideas what i did wrong?

whole yacht
#

Did you add the package in package manager?

orchid tree
#

yes

whole yacht
#

Can you show me the package manager and error in the console?

orchid tree
#

it does not give me an error in the console it just says the namespace doesnt exist when i type it in viusal studio

whole yacht
#

If you don't have an error in the console then it means Unity was able to compile it. It is probably a issue with your IDE setup. !ide

tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

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

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

whole yacht
#

Either missing the IDE package or missing the setup in the Preferences > External tools

orchid tree
#

its weird because I have used the same library before on a diffrent project so i was baffled when it didnt work, im using 2019 visual studio and as far as im aware everything seems to be there, im going to update my vs and see if that helps

whole yacht
#

Ehhh. Can you check in your Project Settings > Player for this? Make sure it is on Input System Package

orchid tree
#

i have the new package selected in project settings just checked

#

my vs was out of date updated it and it fixed it thanks man sorry for that 😅

whole yacht
#

No worries happen to the best

glossy basin
#

Hello there, does anyone know why I cant track this garbage collcection? I have enabled deep profiling and call stack, but it doesnt actually tells me what causes the garbage

void basalt
#

on the docs they state that random allocations will happen in the editor

#

and they won't happen in build

glossy basin
#

Ohhh, great, glad to hear that

#

thanks!

vagrant bramble
#

Hi, I've been having a ton of trouble getting cinemachinefreelook to work with my movement and rotation. I am trying to make a simple platformer and my rotation speed seems to be messed up in turn with my camera rotation. I am using the new unity input system and posting a visual of it, before the square deforms it was jittering and I don't know the right combo of settings to get this to work smoothly.
Simply put I want the camera to be rotatable and the player to rotate on their own too with it all being smooth.

My movement code is inside FixedUpdate():

    private void Move()
    {
        Vector3 moveDirection = new Vector3(moveInput.x, 0f, moveInput.y).normalized;
        Vector3 cameraForward = Camera.main.transform.forward;
        cameraForward.y = 0;
        cameraForward.Normalize();
        Vector3 cameraRight = Camera.main.transform.right;
        cameraRight.y = 0;
        cameraRight.Normalize();

        Vector3 desiredDirection = cameraForward * moveDirection.z + cameraRight * moveDirection.x;
        rb.velocity = new Vector3(desiredDirection.x * moveSpeed, rb.velocity.y, desiredDirection.z * moveSpeed);

        if (desiredDirection != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(desiredDirection, Vector3.up);
            rb.MoveRotation(Quaternion.RotateTowards(rb.rotation, targetRotation, rotationSpeed * Time.fixedDeltaTime));
        }
    }

could anyone help with this who may have used this component before?

glossy basin
#

are you calling move in Update, FixedUpdate or LateUpdate?

vagrant bramble
glossy basin
# vagrant bramble FixedUpdate

Hmmm it actually should be working good, fixed update is essentially the right way for updating rigidbodies... Maybe change the update settings on the cinemachine brain GameObject?

#

Wish I could help more but as I said, I have not messed with cinemachine

vagrant bramble
#

That's ok thanks. I've tried every combination of updates, most other settings than the ones I have make it jitter really badly. Interloping on the rigidbody, forced cinebrain FixedUpdate.
My conclusion was that it's some issue with the camera speed and my rotation speed not being in-sync so when I hold both down it causes distortion andor jitter.

cosmic rain
#

Interloping?🤔

vagrant bramble
#

im dumb lmao interpolating.

glossy basin
elder zenith
#

I have this Task called UpdateGame(), but when I run it, it just stops running after the 2nd line, on the UnityEvent invoke... No errors, no nothing, it just doesn't execute past that point. Any clue what could be causing it?

#

Here's the function that runs the task, if that helps

#

Weird thing is, the function worked flawlessly before, not sure which change caused the problem

urban marsh
#

Hello everyone !
I have a problem with some prefabs not totally initializing before their collision happen :
My player, when casting a spell, instantiate a prefab. the prefab has a script attached, which handles how the spell's projectile moves, and what they do on trigger-collision with an enemy.
My problem is that the script's OnTriggerEnter2D() is called before its Start() when the prefab is instantiated "touching" an enemy.
If there a way to make sure the Start() is really called (other than calling it myself if a boolean is not set yet) ?

prime sinew
urban marsh
#

I am not a fan of that because I am not always sure where and how many collider there are, and sometimes, I have multiple colliders that are enabled/disabled at different moments.

prime sinew
#

ok

#

not sure if Awake would be called before the OnTriggerEnter

urban marsh
#

It's a good idea and It would work for 90% of the spells the player can cast, but I would need to do things differently in the last 10%, and that would not be great for code readability ^^'
(the collider enabler thing)

urban marsh
#

I am not sure why, but it behaves weirdly with Awake instead of start.
not the same problems as when start was not called.
I think maybe the rigidbody does not have its velocity ?

prime sinew
#

are you saying Start is not called at all

urban marsh
#

It seems this is the easy and reliable way to do it, even if it's not great, I think :

    private bool isInitialized = false;


    void Start() {
        if (!isInitialized) {
            isInitialized = true;```
prime sinew
#

yeah, that sucks, but if it works, sure

urban marsh
prime sinew
#

I see

#

yeah, unfortunately I would just go with the extra bool approach as well

urban marsh
#

Yeah, I'm gonna keep the extra bool solution. My only problem with it is that I do not like writing this : 😄

    {
        Start();```
somber ether
# urban marsh Yeah, I'm gonna keep the extra bool solution. My only problem with it is that I ...
private bool isInitialized;
void Start()
{
  Debug.Log("Start");
  if (!isInitialized) {
      Debug.Log("Is not initialized");
      isInitialized = true;
  }
}

private void OnTriggerEnter2D(Collider2D collision)
{
    if (!isInitialized) {
      Debug.Log("Is not initialized");
      isInitialized = true;
  }
}
```This would be the code you are trying to do. But it is actually very pointless. you see "Start()" is a unity function that is automatically run as soon as the script is active, therefor regardless of what happens in your game isInitialized will be true, and if it is always true no matter what then why do you need it?
thin aurora
#

Awake always happens before collisions so you should use that for initializing your component

#

Start is for actual behaviour that must be done if your behaviour has all relevant data set, and this is where it will start communicating with the world and other objects

thin aurora
somber ether
urban marsh
#

Awake seem to happen so early that some "normal stuff" is not initialized yet : I could not get the rigidbody velocity.
start happens after the trigger collisions if the prefab is initialized in a position where it already hits other colliders on creation.

#

If the bool is pointless, tell me how to do it without it 😄

somber ether
#

Well youve not provided the problematic code that needs to be initialized, which the bool is making sure of

urban marsh
#
private Rigidbody2D rb;
void Start()
{
  Debug.Log("Start");
  rb = this.GetComponent<Rigidbody2D>();
  originPosition = rb.position;
  originalDirection = rb.velocity.normalized;
}

private void OnTriggerEnter2D(Collider2D collision)
{
    Debug.Log("rb " + rb );
}

in the console, I get this :

rb 
Start

Because Start is called AFTER OnTriggerEnter2D.

somber ether
#

then rename Start to Awake

thin aurora
#

That's the whole point of Awake

#

Awake is Unity's constructor basically

urban marsh
#

I edited the code written :
rb.velocity.normalized
This is not set correctly if called in awake.

quartz folio
#

Collect the references in Awake, and do initial logic in Start.

somber ether
#
private Rigidbody2D rb;
void Awake()
{
  rb = this.GetComponent<Rigidbody2D>();
}

private void OnTriggerEnter2D(Collider2D collision)
{
  originPosition = rb.position;
  originalDirection = rb.velocity.normalized;
    Debug.Log("rb " + rb );
}
#

Attempt this?

urban marsh
#

It is called "originPosition" because it's the RB position at its "origin", when it hasn't moved yet (on start).

somber ether
#

you can use both Awake() and Start()

urban marsh
#

I need originPosition and originalDirection to have their values for calculations I do in the OnTriggerEnter2D.
I can not set up originalDirection to rb.velocity.normalized in awake.
It is too late if I set it in Start() because a "early collision" would not have the value set.
I need its value to be the one on "time = 0".
How should I set it up ?

urban marsh
#

using a wait until initialized == true in the collision ?

somber ether
#

I dont know your whole setup and what the outcome should look like. But if that logic makes sense to you then yes

lone vector
#

anyone know what's going on here? edit: solved it myself

#

the animator in question has 1 state and 1 layer, and the state has a looping animation at 8 samples/second (and specifically 0.14x speed for debugging this issue)

#

I wouldn't expect it to be snapping to seemingly random values like this

#

especially when it's appearing as expected in the game

#

every online forum solution tells me this is the way to do it but clearly something aint working

#

oh wait i think i know the issue

lone vector
#

yeah that was it

#

ignore me

cursive kernel
#

Hello guys can anyone help me on dm cause my problem is so big so i can share all script files if you want

cursive kernel
#

so let me tell you my problem first

#

I'm currently trying to develop a game like Stardew Valley

#

i wrote the tree cutting script with the latest item query, but no matter what I did, no matter what I tried, I couldn't figure out what the error was

#

i'm not getting any errors in the console

#

i've added debug lines wherever I can add them, but there's still no result

cosmic rain
#

That's not very specific. What exactly is the issue?

cursive kernel
#

i can't cut trees

#

my code not working

#

but idk why

cosmic rain
#

Start a thread and share the relevant code. Also explain in short how it's supposed to work.

cursive kernel
#

ofc

quartz folio
#

No.

cursive kernel
#

okay

cosmic rain
#

Is it relevant to dots??

cursive kernel
#

no okay sorry

quartz folio
#

Tree cutting script issue

past sedge
#

can someone tell me what the difference is between these 2 functions, why would I use a lamda expression instead of a return function. what is the benefit of both?

mellow sigil
#

Some people say that the first one is more readable, some say that the second one is more readable. There is no other difference.

mellow jasper
#

Any way I can make a server that holds a single string and make the unity app manipulate or change it?

mellow sigil
#

Yes, plenty of ways

thin kernel
#

What is an efficient way to load and display images?

I can preload an image and set it's type to "Sprite 2D" through the editor, then I can just "image.sprite = sprite" and it works fine. But I need to do it dynamically, every image will be loaded from the server (but I can save them and reuse later). I can't change it's type to "Sprite 2D" through the script in build.

I tried an alternative, using "texture.LoadImage(bytes)", but every time I use this function, ram usage going up by 20-200mb, that's insane, and it takes a much longer time to load. I want to be able to save it in the right format, so the next usage will be as fast as "image.sprite = sprite" in my first example, and no insane memory allocations.

past lagoon
#

Does someone know how to handle "No connection could be made because the target machine actively refused it" ? I didn't change any settings but now i'm getting this

#

Trying to attach vs debugger

thin aurora
elder zenith
#

https://hatebin.com/eznfvcfqko
My references get set to null but only in the script? I have a reference to a GameObject, but when this function gets called, it gives me an UnassignedReferenceException for buttonTop saying it's not assigned, even though in the editor, it is. The only way I interact with it in the code is by using .GetComponent<>() on it.
The inspector still shows the reference as being there, instead of None (GameObject) or something.

I get the error on line 74.

I initially thought it was caused by some weird threading issues (I'm modifying an asset that makes use of Tasks a lot.) but I checked with System.Threading.Thread.CurrentThread.ManagedThreadId and it's all on ID 1, which I assume is the main thread.

The function path right now is UpdateGame() starts launcher's UpdateGameStart(), which invokes a Unity Event then uses Task.Run() for an unrelated process, the public Unity Event has the OnUpdating() method attached to it, which calls the SwitchTopButton() method which then produces the error.

dusk apex
elder zenith
#

I should add that when I used a debugger, the values were all ok. But at the start of the SwitchTopButton method the buttonBottom and buttonTop along with the Sprites and TextMeshProUGUIs got turned into null

#

But interestingly nothing else, like the Button Text objects or the Download Bar

dusk apex
#

Place this before the error: cs Debug.Log($"Top Button: {buttonTop}", gameObject); Debug.Break();

dusk apex
dusk apex
#

When you select the log, what object highlights in the scene?

elder zenith
dusk apex
#

Right

elder zenith
#

i had a copy of the LauncherUI object, and the UnityEvents are assigned to that disabled object's methods

dusk apex
#

Congratulations

elder zenith
#

that's what i get for not changing the name.....

#

massive thanks, been stuck on this for a bit!

lyric moon
#

im decompiling some code and found this... Time.time cant actually be less than 0 can it? surely this is broken

peak halo
#

Hello! Was wondering... How do y'all like to list your attributes? Vertically or horizontally?

eg:

[Header("Player Properties")] [SerializeField] private string _playerName;

or

[Header("Player Properties")]
[SerializeField]
private string _playerName;

I know it is mostly about preferences but I really wonder how others do it as I think both have some cons like;

if I use horizontal it looks prettier but if I have several, then it becomes so crowded that it is very hard to read the property itself.

but f I use vertical then it is easy to read the property no matter how many attributes it has, but then it kinda looks inconsistent as every property has different attributes. How do you like to do it?

quartz folio
#

Just a note that if horizontal I will always separate with commas in one block
[A, B] not [A] [B]

peak halo
#

Is that a thing???? didn't know that

peak halo
quartz folio
#

I vary, sometimes even put everything including the attributes on one line. I'm on my phone so I can't check, but I'm pretty sure I just do what sfield completes to in Rider (all inline), and then do multiple lines when things become messy. Header will always be on a separate line due to semantics

peak halo
#

yep I was also thinking of something inbetween

#

thanks!

peak halo
#

they get quite long and ugly

dusk apex
quartz folio
peak halo
#

how does this look?

#

something in between

#

pretty enough?

quartz folio
#

Looks fine to me

lyric moon
#

cafting menu

lyric moon
heady iris
#

i'm guessing it's either a holdover from some very old behavior

#

or just cargo culting

peak halo
#

How do you like to add documentation to private fields?

///<summary>
///Explanation...
///</summary>
private string _property;

or

private string _property; //Explanation
heady iris
#

potayto potahto, really

vestal crest
#
            .Join(transform.DORotate(target.eulerAngles, duration, RotateMode.FastBeyond360).SetEase(Ease.Linear));```

hi heres my dotween code, i want to throw an object until it reaches target position i want it to rotate like 3 4 times how can i do it??
quaint rock
#

does not matter much, since private fields would not show up in exported docs

elder zenith
#

My code does not execute past the .Invoke(), any clue what could be causing it? OnDownloadingGame is a public UnityEvent

quartz folio
elder zenith
#

The event doesn't seem to be called, the function attached to it in the inspector doesn't get executed

leaden ice
quaint rock
#

would assume the event is null or something is failing in the subscriber to the event

leaden ice
#

Which will silently kill the thread

quartz folio
#

If you don't use async properly by awaiting every task you create that can cause exceptions to be eaten

quaint rock
#

break it down to a simple case

#

see if it works in a non async method

elder zenith
somber nacelle
#

the majority of the Unity API is not available off the main thread

quaint rock
#

would help to see more of the code, so we know why you are in a async method and returning a task

elder zenith
#

So the UnityEvent invoke just breaks when trying to do it from a Task?

quaint rock
#

well why we need context

#

we need to now what thread this logic is running on

#

since if its not main yes its going to fail

elder zenith
#

If I used await OnDownloadingGame.Invoke() would that help or?

leaden ice
elder zenith
quaint rock
quartz folio
#

It could be the simplest error of all time, threading doesn't even need-well that'd do it lol

leaden ice
quaint rock
elder zenith
#

how can I run it on the main thread then? Would running it from an async method with await fix it?

quartz folio
#

Yes, and you want to await every Task you create. Starting at the top with an async void method is generally how I do it, but I know others have various wrappers and other mechanisms

steep herald
#

I have a system that is used to acquire prefabs by other classes. I recently moved that system from using Resources.Load to addressables. All prefabs are initially loaded like this, and then cached for quick access by requesters.
var op = Addressables.LoadAssetAsync<GameObject>(kvp.Value);
Now my problem is that I modify certain materials when a scene is loaded, and then I instantiate a bazillion things that use those materials. With the resources.load system, it worked as expected and the changes in the materials were reflected across the instantiated prefabs.

Now with addressables, it works in the editor, but in the android build, changes to the materials are not reflected across the instantiated prefabs, as if the material was no longer the same.

I am having trouble to understand what's happening. Any idea?

elder zenith
heady iris
#

unity doesn't have documentation talking about the implications of using async, does it?

#

searching it just gives me AsyncOperation

elder zenith
#

It's more C# i suppose

quaint rock
elder zenith
#

along with Tasks and Jobs it just feels like a headache to understand :^)

quaint rock
#

also async ops have tasks, callbacks or ienumerators

quaint rock
#

so you can pick and choose which way to handle concurrency

heady iris
#

There are just some special considerations for when using it in Unity -- no touching the scene from anything but the main thread, after all

quaint rock
#

well that is a general thing

#

almost all concurrncy has similar rules in and outside of C# and unity

#

most apis are not thread safe and can create race conditions

#

so some form of synchronization is required

#

that could be mutexes, patterns like async and await, channels etc

heady iris
ocean river
#

how do i do an inverted sprite mask in unity 5...

heady iris
#

But it’d be nice to have this explained as it pertains to Unity

quaint rock
#

unity does not really expose any of it to you though, anything that is concurrent you are not starting the tasks yourself its providing them to await or yield or sub to a callback

quartz folio
quaint rock
#

stuff like task factories, and task.run etc is really only if you are doing your own concurrency, and that is using the same methods as any C# app would

ocean river
#

im limited to that ver because i use the new 3ds platform

vestal crest
#

hi i want to throw an object which works with dojump and i wanti it to rotate while moving multiple times and at the end i want it to be its rotation same as target, how can i do it?

uncut vapor
#

Hey, I'm using the newtonsoft package and when trying to serialize a TMP font it shows UnassignedReferenceException: The variable atlas of TMP_FontAsset has not been assigned., is there a way to ignore/fix it? I have NullValueHandling on ignore but it doesn't change anything

quaint rock
#

what do you mean by serialize a tmp font

#

not all types can be serialized, like how do you expect it to represent a font in json

#

this feels like a XY problem, i think what you really want to do is just save a font by name or something, so you can later look it up and assign the correct reference

uncut vapor
#

Oh yeah that makes sense
Thx lmao

halcyon gull
#

Hey
When I copy and paste the folder containing the prefabs, the prefabs that are inside of those prefabs are still referencing the old prefabs

halcyon gull
#

Let me write a hierarchy

leaden ice
#

This doesn't really sound like a code question BTW

#

Are you trying to export assets from one Unity project to another?

halcyon gull
#

Here is the hierarchy:

Old Folder

  • TextPrefab1
  • SomePrefab1
    • TextPrefab1 inside
      New Folder (Duplicate)
  • TextPrefab2
  • SomePrefab2
    • TextPrefab1 inside <- still referencing the text prefab in the old folder
#

This is a code question because I'm trying to do it through code

leaden ice
halcyon gull
#

Basically I want to be able to have a 'hard' copy of the folder

quaint rock
#

but why?

halcyon gull
#

It's quite a long explanation, but I hope you get the idea

quaint rock
#

so yeah what you want to do will be a pain in the ass, will likly need to use SerializedObject and SerializedProperty to reassing things

#

but i keep asking why since what you want feels weird

heady iris
#

you should really answer the question first

#

in case it turns out there's a much, much easier way to deal with your problem

halcyon gull
# heady iris you should really answer the question first

Alright, so I got a set of pre-made prefabs, let's call them 'original' prefabs. The original prefabs don't change, instead duplicates of those prefabs are created for use (not going to get into details of what they are used for). The thing is, you can create however many duplicates you want from those originals.

heady iris
#

is this in-game or in-editor?

halcyon gull
#

In-editor

quaint rock
#

would prefab variants not be better for this

halcyon gull
#

There are many prefabs inside the folder and they are also interdependent

#

So I don't see how variants would help

#

All I want is to duplicate a folder, but for the prefabs inside the folder to have links to the new prefabs

#

I'm surprised Unity has no system to take care of it itself

orchid bane
#

I am making a game similar to slither.io. How do I make a bot for it? I mean I want the player to be able to play offline

heady iris
#

start by separating the player input from the code from the code that makes the player move around and interact

#

so, you should have a Snake class that does the moving and whatnot

#

but it doesn't read input

#

then, create a PlayerBrain class that can read inputs and give instructions to the Snake

#

and an AIBrain class that runs some kind of logic to give instructions to the Snake

#

(the logic can come once you've got this working :p)

orchid bane
#

I separated it from the start

heady iris
#

ah, good!

#

so you just need to figure out the actual AI logic?

orchid bane
#

Yeah

#

Like I never created any bots

heady iris
#

hmm

orchid bane
#

So any help is appreciated

heady iris
#

so how does the game work?

#

i haven't played that particular game

orchid bane
#

Well there are snakes which eat food or remnants of other snakes and grow

#

If you bump into body of another snake, you die

#

But you can go over yourself

#

Pretty much it

heady iris
#

ah, so it's like tron light bikes, sort of

#

I guess I'd start with a very short-ranged AI

#

if the space in front is blocked, turn

orchid bane
#

Sounds smart

heady iris
#

I'd have to think for a while to figure out a good AI for that. I suppose you want to detect when you can cut another player off and try to trap them

#

e.g. if a player is blocked from most sides (maybe do some raycasts?), try to cover up the remaining free space

orchid bane
#

Yeah, would you be so kind as to help me with it?

halcyon gull
#

@heady iris Anything for me?

spiral marsh
#

Is there a public git repo for Unity's Leaderboard package? https://i.imgur.com/ndhEnUk.png . I'm working on a collab project and sharing the project with a local tarball file makes it kind of annoying to use in a collaborative setting

quaint rock
#

does that not just install it in your Packages folder that you can commit

spiral marsh
quaint rock
#

ah looks its its in the package cache

#

you could copy it over to packages folder, or you could commit the tarball to the project and give the manifest.json a relative path to it

spiral marsh
#

oh maybe I'll try the relative path in the manifest. I didn't think of that

halcyon gull
# halcyon gull Here is the hierarchy: Old Folder - TextPrefab1 - SomePrefab1 - Tex...

If anyone ever needs this, here is the solution http://answers.unity.com/answers/1823316/view.html
Just tested the code and it works

quaint rock
dark salmon
#

Can anyone help me use the Input System as a singleton? I wanna access it from other scripts without cluttering my code with all those Awake() and OnEnable() and OnDisable() functions. They are very confusing to me and I wanna keep it simple when I use it in a script like this, which currently uses the old input system:

using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    Rigidbody2D rb;

    float horizontal;
    float vertical;

    public bool R = true;
    [SerializeField] private float speed = 10;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        // Manage Right-Left movement separation
        if (R)
        {
            horizontal = Input.GetAxisRaw("RHorizontal");
            vertical = Input.GetAxisRaw("RVertical");
        }

        else
        {
            horizontal = Input.GetAxisRaw("LHorizontal");
            vertical = Input.GetAxisRaw("LVertical");
        }
    }

    // FixedUpdate is called after each frame
    void FixedUpdate()
    {
        rb.velocity = new Vector2 (horizontal * speed, vertical * speed);
    }
}```
spiral marsh
quaint rock
#

like some of the sdk is use for consoles are just here is a folder laied out like a pacakge and you just shove it in the folder

orchid bane
#

Is it difficult to make a bot for my game? So that I can play offline

woeful dagger
#

hello i have a question, who uses node js? for call this aplication in webgl

violet mesa
woeful dagger
#

i have got a probleme

#

i try to lanch two application

#

app.use(express.static(__dirname + '/jeu-boat-race'));
app.use(express.static(__dirname + '/visu-boat-race'));

#

app.get('/jeu-boat-race/', (req, res) => {

res.sendFile(__dirname + '/jeu-boat-race/index.html');

});

app.get('/visu-boat-race/', (req, res) => {

res.sendFile(__dirname + '/visu-boat-race/index.html');

});

#

it always launches the application put in first position

#

app.use(express.static(dirname + '/visu-boat-race'));
app.use(express.static(dirname + '/jeu-boat-race'));

violet mesa
#

You use node.js with unity

woeful dagger
#

if i siwtch

#

then i change application

#

yes

#

juste for lunch in local

#

there is a cache probleme i suppose

#

i don't know

violet mesa
#

Ah sry then i cant help you much. I use node.js with a webapplication. Sry for the confusion

radiant marten
#

is there a way to make my script templates persist after an editor version update without going through and copying them from one version to the other?

dull yarrow
#

level ^ 3 - this is level elevated by 3 correct?
How can i do this in C#?

oblique spoke
dull yarrow
#

I am trying to do this fnction in C#

    return round((4 * (level ^ 3)) / 5)
end```
#

but the exponent part is what i am having problems with

heady iris
#

Mathf.Pow will raise its first argument to the power of its second argument

radiant marten
dull yarrow
#

Thanks!

#

(int)Mathf.Round((4 * Mathf.Pow(level, 3)) / 5); I am questioning what does the (int) before the function do

radiant marten
#

forces it into an integer type

heady iris
#

(TypeName) performs a cast

#

you can cast a float to an int by throwing out the decimal part

radiant marten
#

you can also just use Mathf.RoundtoInt() instead

#

Mathf.RoundToInt((4 * Mathf.Pow(level, 3)) / 5);

wide fiber
#

guys i think i did a random.range via using scriptable object!! BUT