#archived-code-general
1 messages · Page 83 of 1
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
good to know. also how many years of exp do you have in gamedev
thats kinda how i want to do it
Nah, not at all, you only need to be very perseverant with this, as you will find problems most of the time a beginner
i don't honestly remember 5 year or so, i don't have anything worthwhile to show so who cares
also you have discord to ask 😄
my first commercial game will go out soon, but i've been through networking code and many more first
i would love to work on a game with people like game jam stuff. do you guys do that?
but try to learn on your own to not relly on others
as storm said you need to be perseverant and never give up
make your own goals progressivly as you go on
i've spent the better part of a year teaching myself and although i've learned alot, i feel like im barely scratching the surface of intermediate level thought processes
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
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
ok so yeah that is what i will do. and that s awesome
thats part of the process, Unity and most of other game engines are DENSE, so you will always find new things
wait until you mess with Jobs system, ECS and more advanced stuff
i can wait lol
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
yeah that is the main reason why i started actually. the learning curve is endless
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
do you have a place i could check out your work?
quite not actually once you get the logic, unless you're an endless genius, the road's quite well paved.
you can test you own creations multiple times at once to see what's the best.
not the learning curve but the posibilities of what you can do 👌
I dont for now, I can send you DM if you wish
yeah send a dm.
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!
What do y'all think about having a file where all enums are declared?
Is that bad practice?
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
Nope, keep it simple. Each file should have a single principle responsibility and this keeps your project organized on one way.
The single-responsibility principle (SRP) is a computer programming principle that states that "A module should be responsible to one, and only one, actor." The term actor refers to a group (consisting of one or more stakeholders or users) that requires a change in the module.
Robert C. Martin, the originator of the term, expresses the principle...
Symptoms
Unity is ignoring Application.targetFrameRate
The application is capped at higher or lower than target frame rate
VSync is not capping to 60/30 fps
Cause
Unity intentionally ignores...
idk im just guessing to help haha
unfortunately, it didnt work :(
are you on a mac or
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
im on windows and vsync doesnt work on quest/android
vsync is literally Vertical Synchronization
Yeah, synchronizing the horizontal scanlines vertically
welp i stand corrected
do you know how to fix it?
Fix what? Vsync?
the lines
No
oh
Just looks like the post processing isnt cooperating with the VR rendering. Prob wanna ask in #🥽┃virtual-reality or #💥┃post-processing
but how you turn it on
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?
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
gngn
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)
Definitely not code related
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);
}
}
Since it's a serialized field you can do it through the serialized object API
https://docs.unity3d.com/ScriptReference/SerializedObject.html
But if it wasn't a SerializeField? Just a plain private field?
You'd have to make an accessor for it, or change the access modifier.
Ah dang, so Id have to basically kinda "share" it to the scope
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??
Why exactly might you want to store this kind of data in PlayerPrefs?
each day the player comes and play their strength will increase or decrease, and i want the player to have a graph of how much they progressed and for that i want to store the previews strength somewere
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
i have a database, is there any example that is similar to my description so i can get some ideas from ??
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)
If you already have a database, saving some extra data should be really simple. What are you using for the database?
i'm using nakama with postgre
Ok, then what's the problem?
my problem is not with storing the data, i want to know how to create a system that calculates your strength for eachday and displaying it in a graph
Save the date and time of when the player exists/saves the game and compare it with the date and time when the player launches the game. Simple.
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
}
The reason this kinda bugs me is that the Storage systems of my game started getting a bit messy and chunky so I am thinking of giving it it's own namespace but I don't know how good of a practice that is...
I was just thinking about this yesterday
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
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
not using namespaces is such an antipattern/code-smell
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
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
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.
1 or 3
2 sounds like someone tried to be too modular and made a lot of ravioli nobody understands
I agree with you. 2 is not appropriate maybe it is OK if the initialization functionality is not duplicated somewhere else.
2 is OK if you are working at Unity Technologies and make core engine features
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
tight coupling is not a controller having references to its dependents, tight coupling is when the communication between components depends on implementation details not exposed by an interface of some kind
yes
i think this is a big missunderstanding when it comes to dependency injection
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.
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
it depends on what the gameobject does, i like to have some distinctly named component on every gameobject, even if it doesn't do anything at all
this greatly aids in understanding the identity/purpose/role of objects and provide an extensible entrypoint for adding behaviour
// 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
}
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
those child data things should probably be separate arguments if you are just gonna pass them through, or maybe if ItemData implements Interfaces corresponding to the Init-data the subcompoents need, then its fine as you have it there
You mean to have more flexible way?
// ItemData with interface implementing
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
}
this looks nicer indeed, but in practice it wont be
you definitely want to have the interfaces explicit somehow so they static code analysis can catch any type errors
and what about other methods on that ItemEntry?
I prefer to keep it just for initialization and for other behaviours add another component.
thats fine, maybe it could handle IDisposable
how do you draw a shader on the screen?
give it a mesh to render, put that mesh in the camera frustrum
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
thanks i will try that!
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;
}
}
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
can someone help me understand why in this linerenderer, having a full alpha key in the center with zero alpha at the sides doesn't work, but having full alpha at the sides does?
https://cdn.discordapp.com/attachments/515580681707847702/1097871175956312205/image.png
https://cdn.discordapp.com/attachments/515580681707847702/1097871176207958016/image.png
any non-side keys are just completely ignored
same goes for color keys, only the side keys do anything
Another question; should I name a private but serializable field like _value or Value?
like private or public?
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
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?
Not very familiar but you should probably send a screenshot of the layer configuration in the preferences & inspector and the code.
ok i will. thank you!
aight thanks
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)
How can I call event of EventTrigger? For example, I wanna call event OnDeselect.
How can I do this?
pretty sure you can just call it like any other method
I cannot.
not sure how it'd be that useful though
what happens when you try
A BaseEventData clearly
Yes, but what exactly data.
i suppose they don't know how to get an instance of BaseEventData
make a new PointerEventData or something
if OnDeselect doesn't care about the contents of that BaseEventData object, then you've got a lot of leeway
yea
If your listeners aren't using the parameter it really doesn't matter
you could even pass null if they ignore the param
Well, BaseEventData required EventSystem.
I think that global EventSystem in Scene.
required?
do you mean you had to add using UnityEngine.EventSystems; at the top?
because its fully-qualified name is UnityEngine.EventSystems.BaseEventData
ooh, I see
sorry, thought of the wrong thing there
just give it a null, tbh
as praetor suggested
or EventSystem.current
Oh, nice. Thanks!
ah, of course
I will try it and say later if it works.
I figured it out. To set a sprite's offset:
Sprite originalSprite = spriteRenderer.sprite;
Vector2 newOffset = Vector2.one * 0.5f;
Sprite newSprite = Sprite.Create(originalSprite.texture, new Rect(originalSprite.rect.position, originalSprite.rect.size), newOffset);
spriteRenderer.sprite = newSprite;
isn't this literally the same thing as changing the pivot in the sprite editor though?
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.
Yeah you're right. This didn't work.
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
The fix to changing the rotation and scale origin is to change the pivot.
If you want a different rotation origin and scale origin, you'll need to do some parenting shenanigans
because the pivot acts as both
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
but that IS what the sprite pivot is
that's exactly what it is already...
You're totally right. It took a minute for it to click
brainfog lol
this isn't going to do what you think it does
what is the idea? what interaction are you trying to turn into a "deselect"?
try starting the macos build from the terminal so that you can see the logs easier. or google where to find the logs. read the logs first.
you should also try a mono build first
can you try adding a third line renderer point in the middle? old stuff like line renderer can be pretty arcane. are you using URP/HDRP?
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
thanks, that worked :D
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
this is called a gameplay attribute system, it's a common question and it has no easy answers
the complexity depends on: how big of a design space you want to support?
is this a networked or single player game?
ive got some networking going, but otherwise relatively small roguelike-ish game
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."
yeah, I got an ability system already going with some meta stuff working
okay
is the design space "all of slay the spire"
it sounds like a platformer
or like "all of hades"
I'd go with hades and vampire survivor
okay
^^
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
absolutely
lol
can you show me a snippet of some example gameplay you already have working? like an implementation of a sophisticated item
let me see if I can get this to compile
"can you show me your w2"
lol well that's not promising...
okay
do you have any experience modding a game like StS?
Don't recall that name
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:
okay well
any experience modding any games?
or similar games?
or maybe a previous game you've worked on that has a "gameplay ability system"
ah, dota 2 I've done a bit
okay cool
I actually wanted to do something similar to their system, but it's a lot of work for that
okay
How hard could it be to fully implement Magic the Gathering?
i don't think there's anything strictly wrong with the approach you are taking
the xmage source is pretty representative of the complexity of doing that, and i believe slay the spire was strongly influenced by xmage
using scriptable objects and programming in the inspector was a mistake
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");
}
}
}
}
Please share the !code properly
📃 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.
“Codeless” works until it doesn’t
you probably have a working game at this point right?
it's realtime like hades is?
and you want two players to share that same space?
all of this stuff is possible
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.
knowing what you've shared with me, i would probably have used ECS
but let's not rewind your working thing
in order to "lift" piece by piece
into what you need
I've just hide a lot of data, used or not used, but I manage to minimize what can be used via attributes
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"
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
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;
}
...
}
}
}
I should just focus on more of a single super class.
this is also fine
i think you can make a library of stateless gameplay functions
that is your gameplay. for example void DealDamage(...)
right, that's my intentions
you have your curly brace ending your OnTriggerEnter2D method in the wrong place
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
ok
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
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
i wouldn't necessarily reinvent types
yeah
in hearthstone when healing deals damage instead, they have a global attribute called HEALING_DEALS_DAMAGE
but ability systems in oop is actually quite hard it seems
dota 2 just parses everything
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.
it is too late for that
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
oh yeah ehhh
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
Yeah exactly what dota 2 does
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
it's trickier to force yourself to not make state/rule/constraint violation mistakes in C#
you can look at XMage to see how they do it for java
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
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
yeah
docs say that both wirecube and overlapbox take rectangle center as their first argument
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
yeah, the bool has been working wonders haha
i don't think it's worth migrating away from that right now
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
you can keep doing your ubershader approach
the object pool with projectiles im kinda stuck at
and you're going to reconsider that or you'll use a service like mine to network a local multiplayer engineered game
for the networking
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
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
https://www.dropbox.com/s/yy37mgv0xylu585/Editor Experience 4 Player.mov?dl=0 this is what testing and developing multiplayer on my system looks like. this means you create a local multiplayer game, but every player is streamed over the internet their own camera and inputs. like stadia, but more advanced & integrated
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
oh yeah that sounds like quite a project
this is to illustrate that i think about this a lot
I was going to say that OverlapBox uses halfExtents not size, but the 2D version uses size at least according to the docs.
So I don't see any issue with the code here 🤔 Have you debugged and made sure that it's actually hitting the collider you think?
this doesn't sound like the best solution, that'll put a lot of load onto host's GPU
it's streamed from servers, not the user's local machine
It using half the size / being bottom left corner were my first suspicions but both of them proved false
in my experience, i've only had working multiplayer unity games when
- the game business/logic backend was written separately (2013-2020)
- using the streaming technology (2021+)
... that's it
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
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
So far I've used photon, but I'm liking fishnet this time around
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
above that it returns the top collider for some god unknown reason
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
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"
okay now THIS is stupid
well... you don't believe it now do you
eventually ;)
does anyone know why this happens?
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
you need to include unity's namespace
add using UnityEngine; to the top of the file
huh?
Are you 100% positive that your gizmos and the physics code are using the same variables?
yeah, this is just a mockup to find the issue. Both variables are public and assigned in inspector and nowhere else
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?
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.
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)
ohhhhhhhhhhh
what the fix
like how do i apply the scale
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
not a problem
how do i go about doing that
literally just do it
transform.TransformPoint(Vector3.zero)
this will give you the world-space position of the room
ideally, you'd just specify the range in the room's local space
so, measure the size of the room when it is not scaled
that's the range you should be generating the random values in
yes
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
bruh
just found another fix
divide 8 by the scale
which is 20
so instead the ranges are .4 and -.4
lmao
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
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;
//...
can you show your input system settings?
I have not touched the input settings but here they are
absolutely nothing happens when i use horizontal it returns just 0
hmm
maybe its your keyboard language that messes it up? make sure that it's set to english or check if arrow keys help
nothin
hmm weird
extremely
actually using my A and D keys when using Horitzontal gives me values
on my rotationX float
bump, using 2021.3.23f1 btw
the fish (blue thing) just teleports to the food (yellow thing)
it doesnt move towards it
but teleports instantly
i figured it out
i needed to add a + to RotationX = Input.blah blah blah
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?
if i switch the foodposition and fishposition around then the FOOD moves to the FISH, not teleport but moves
do I need to call the rigidbodies move function or can I just do movement based on a gameobjects transform property?
you can move via transform. make the rigidbody kinematic
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
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
If you want realistic simulated physics you should only move via the Rigidbody. If you don't need that, it doesn't matter. You want to think about this object's interactions with other Rigidbodies though before making a decision. Just because this object doesn't need to be dynamic, doesn't mean it shouldn't affect other objects realistically. For example a moving platform in a platformer.
See "Default Contact Offset":
https://docs.unity3d.com/Manual/class-Physics2DManager.html
yeah that was it. How should I handle floor / wall contact detection then?
move player onto a different layer and raise the colliders into them?
!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.
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.
Make "AddItem" and "RemoveItem" functions on the interface and implement them in each class
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
That is totally understandable, but what if I don't want realistic physics at all? I would think Running physics simulations would be pointless if I have no need for the physics engine to calculate physics. If I just need collision detection it seems pointless to tell the physics engine to move objects around.
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
First and foremost you will need to make this non-static. Interfaces do not work on static classes/methods
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.
this method isn't supposed to be in an interface, I sent it to show how the methods AddItem()/Assign() and RemoveItem()/Clear() would be used.
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
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.
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)?
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
have a dictionary Dictionary<GameObject, bool> prefabSpawnCheckList and do prefabSpawnCheckList[prefab] = true when you instantiate prefab.
*don't forget to initialize prefabSpawnCheckList with the prefabs.
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
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?
the UNITY_EDITOR preprocessor directive doesn't mark the class as an "editor class" or anything
you just use it when you want code to only execute in edit mode
I know, but I want to cache scriptable object values only in the editor, so that way they dont become useless after building? Will that work?
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.
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
If I can use two lines to do it I'd rather do that
so you don't want to make them available after building? Why?
so the [EditorOnly] attribute
Because they're useless after building
@mystic ferry What does that do? I can't find any documentation
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?
Honestly just include them? Make them private or something on the class and add serializefield to them
I'm guessing you'll have to do a second pass
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
I don't see it in intellisense? Could it be a tag for game objects?
actually it might be a tag in the inspector. I haven't used it in so long I can't remember exactly
I'm assuming the directive will work, so I'll just do that.
WFC won't stop you from getting unreachable rooms, for sure. I'd hit the map with a flood-fill after generating it to decide what's reachable.
so the areras that are unreachable what would you do about them?
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
oh that makes sense
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
i might even uncollapse them to see if they generate something new that is now reachable as i am running wfc collapse each frame
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
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
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?
The player mouse
Like pick a box. The box moves a little up and then when the mouse moves the boxes moves to
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!
what is a "GNS3"?
3D
add [Preserve] to the class
Where do you have that code? Is it in an assembly? Is that assembly available in WebGL?
or inside a monobehaviour's Start, do var ignored = new GnsJProject(); so il2cpp does not strip the constructor
Part of namespace, and also network simulator
Thanks, I'll try it
Namespaces don't matter much for issues like this - but assemblies do.
yes took a quick peak on your github, looks cool
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
ah, petra was just explaining what this was
it will be less cantankerous to test by making an il2cpp build for standalone
it will be faster than webgl
oh yeah, webgl takes its sweet time
Thanks a lot guys, now it works
Isn't it equal to the [Preserve] attr?
good catch, pangloss (:
i just never know with that crap
I'd expect so. Using the constructor makes Unity say "well, it's used, so I won't strip it"
...unless it strips the function that uses it :p
How can i get the position of the arrow, if my mouse is that red ball?
I have to use ray?
and if the plane has arbitrary rotation then also https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.html
Possibly Plane.Raycast, then adding a vertical offset. It depends exactly what your criteria is here. Kinda unclear
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?
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
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
Check out the Course: https://bit.ly/2S5vG8u
Discover 5 different ways to move your Unity3D gameobjects, see some of the differences between them, and learn which one I usually use.
More Info: https://unity3d.college
I am moving with transform directly
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
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
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?
well
while (timedown == true)
{
flashtime -= Time.deltaTime;
}
this runs forever
it never stops
nothing in that loop could possibly make timedown become false
{
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
that doesn't matter
if you ever hit this while statement while timedown is true, it will get stuck forever
unconditionally, forever
perhaps you wanted to make that an if statement?
ye, making it an if statement fixed it
do you understand why?
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
only one thing executes at a time
you enter Update, you run everything in Update, you leave Update
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
nothing else happens until you leave Update
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
that explains why it froze
if you enter a while loop, you'd better be taking steps that eventually make the condition false
well, what are you plugging into ScreenToWorldPoint?
rect transform position of the child item
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
How is the child items rect transform not its position lol ?
i had suggested doing transform.TransformPoint(transform.position)
this would be trying to treat the world-space position as a local-space position
yea that is not correct, that static method doesnt exist and plus, transform point, transforms a local position into global position.
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
//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
}
oh! yes, overlay canvas. that makes more sense now.
i had gone and checked this on a world-space canvas, lol
Is there any common interface or parent class of AsyncOperation and WaitUntil (YieldInstruction and CustomYieldInstruction)?
oh, is it because the z position is zero?
the z components of the child positions
they're all zero, so you're asking for a world point 0 units from the camera
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
Seems like it's only object...
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
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
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
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 ??
does it have something to do with the anchoring mode?
it might , i dont know, but before I moved it was the same anchor mode
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.
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?
what exactly is a "view model" in this context?
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);
huh, neat
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
Yeah, main issue is with lighting
We don't receive any shadows at all
Yeah that's an issue, I had to ditch the dual camera for that reason
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
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?
"used other scenes"?
you havent really given a problem that anyone can tell u a solution for
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
onkeydown
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
@toxic idolaudio.playoneshot
@toxic idolhttps://docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html
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
so do you want a looping sound while button is held
:) yes
or what the sound playing every x seconds while held
its for the movement of a vehicle
alright, then ignore what I said lmao
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°.
so use OnButtonUp and OnButtonDown
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
make sure the audio source is looping
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
OnButtonDown fires on the frame where the button went from up to down
a bit complicated
OnButtonUp fires on the frame the button went from down to up
Huh...Will try that. Thanks Passerby
You need to ensure that you're properly verifying that you're next to a wall. After that, the correct way would probably be to modify the scene gravity.
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
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
It does. I have a red dot turn green when I'm near the wall it just doesn't seem to want to transfer from a flat plane to a wall. I want to have a ball just roll around the scene that just sticks to the surfaces it sticks on. Like a spider always able to chase you even if you're on a roof.
Sounds like you're not properly changing the gravity.
or the gravity is just flickering back and forth
Yeah it just pushes me backwards, doesnt seem to transition.
so then log the gravity each frame
see if it's actually transitioning to your desired gravity
Okay cool will try that, I only had it in my onaction. Ty Ty
@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
@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 👍 ❤️
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.
Your IDE looks very underhighlighted. If you're not getting errors underlined in red and proper autocomplete (which will list functions on things, so you can discover them easily) you need to configure it !ide
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.
Appreciate you for pointing that out vertx, yeah ive been working like this for awhile now. I never actually knew what to call it so I never found a fix
by that I mean like 3 years
but doesnt that mean u didnt have intellisense working too?
No, not quite. For some reason Intellisenses works - it's just whatever applies to Unity doesn't
some things do some things dont, depends on the mood of Visual Studio that day
ah thats what i meant, intellisense for anything unity related
That's what we refer to as "intellisense doesn't work"
What you're describing is how to get the character to cast full body shadows while only having the arms rendered
I was talking about when youre using a secondary camera to render the viewmodel, it will not receive any shadows from other objects because they aren't rendered in that camera at all.
The technique youre speaking of is good though, just doesnt solve this particular problem
I would need some way to use a culling mask on the second camera but still render the shadows from other layers
A practical example of the issue is going inside but having your gun still lit by the sun
using UnityEngine.InputSystem; it wont let me use this libary for the new input system, any ideas what i did wrong?
Did you add the package in package manager?
yes
Can you show me the package manager and error in the console?
it does not give me an error in the console it just says the namespace doesnt exist when i type it in viusal studio
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
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.
Either missing the IDE package or missing the setup in the Preferences > External tools
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
Ehhh. Can you check in your Project Settings > Player for this? Make sure it is on Input System Package
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 😅
No worries happen to the best
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
probably an allocation happening on unity's backend
on the docs they state that random allocations will happen in the editor
and they won't happen in build
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?
I have not used cinemachine before, but under normal circumstances, this can happen because you are not Updating the movement in the correct Update group
are you calling move in Update, FixedUpdate or LateUpdate?
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
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.
Interloping?🤔
im dumb lmao interpolating.
LMAO
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
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) ?
how about enabling the Collider in Start?
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.
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)
I'm gonna test that
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 ?
are you saying Start is not called at all
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;```
yeah, that sucks, but if it works, sure
no, it's called, but after the OnTriggerEnter2D that is triggered when I instantiate the spell projectile hitting an enemy on creation.
Yeah, I'm gonna keep the extra bool solution. My only problem with it is that I do not like writing this : 😄
{
Start();```
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?
You should not have to do that if you properly make use of each lifecycle method
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
The problem with this is that OnTriggerEnter(2D) is only called once when entering, and it won't be called again if initialization is finished. So if you're triggering something before you initialized the component, the collision will not work properly
Exactly. Thats why I said that bool is pointless
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 😄
Well youve not provided the problematic code that needs to be initialized, which the bool is making sure of
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.
then rename Start to Awake
So get the rigidbody in Awake
That's the whole point of Awake
Awake is Unity's constructor basically
I edited the code written :
rb.velocity.normalized
This is not set correctly if called in awake.
Collect the references in Awake, and do initial logic in Start.
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?
It is called "originPosition" because it's the RB position at its "origin", when it hasn't moved yet (on start).
you can use both Awake() and Start()
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 ?
using a wait until initialized == true in the collision ?
I dont know your whole setup and what the outcome should look like. But if that logic makes sense to you then yes
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
i copied that first line of code on top here for visual demonstration purposes but I realise i probably need to call it every time
yeah that was it
ignore me
Hello guys can anyone help me on dm cause my problem is so big so i can share all script files if you want
You can make a thread in here
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
That's not very specific. What exactly is the issue?
Start a thread and share the relevant code. Also explain in short how it's supposed to work.
No.
okay
Is it relevant to dots??
no okay sorry
Tree cutting script issue
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?
Some people say that the first one is more readable, some say that the second one is more readable. There is no other difference.
Any way I can make a server that holds a single string and make the unity app manipulate or change it?
Yes, plenty of ways
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.
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
Second one is shorthand for the first one
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.
The error says it hasn't been assigned. You may be referring to another instance.
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
Place this before the error: cs Debug.Log($"Top Button: {buttonTop}", gameObject); Debug.Break();
Maybe you're invoking a method from the prefab and not an instance in the scene - assuming you're using injection.
When you select the log, what object highlights in the scene?
It's all just objects in the scene
oh my god
Right
i had a copy of the LauncherUI object, and the UnityEvents are assigned to that disabled object's methods
Congratulations
that's what i get for not changing the name.....
massive thanks, been stuck on this for a bit!
im decompiling some code and found this... Time.time cant actually be less than 0 can it? surely this is broken
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?
Just a note that if horizontal I will always separate with commas in one block
[A, B] not [A] [B]
Is that a thing???? didn't know that
how do you decide if you want to use horizontal or vertical?
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
what do you do with tooltips?
they get quite long and ugly
if anything...
This value is undefined during Awake messages and starts after all of these messages are finished.
https://docs.unity3d.com/ScriptReference/Time-time.html
Testing on a modern build of Unity-Windows, it would be zero but who knows how old the application you're decompiling is, the platforms or whatever the de-compiler/dev was thinking.
New line
Looks fine to me
cafting menu
yeah, doesnt go below 0 on 2018.4.27f1 either. assuming its a decompilation error (rare but possible)
i'm guessing it's either a holdover from some very old behavior
or just cargo culting
How do you like to add documentation to private fields?
///<summary>
///Explanation...
///</summary>
private string _property;
or
private string _property; //Explanation
potayto potahto, really
.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??
does not matter much, since private fields would not show up in exported docs
My code does not execute past the .Invoke(), any clue what could be causing it? OnDownloadingGame is a public UnityEvent
If you cause an exception to be thrown this will halt execution, so presumably you're causing one there
The event doesn't seem to be called, the function attached to it in the inspector doesn't get executed
Or you're running this code in a background thread and touching some Unity engine object
would assume the event is null or something is failing in the subscriber to the event
Which will silently kill the thread
If you don't use async properly by awaiting every task you create that can cause exceptions to be eaten
What exactly do you mean by "touching some Unity engine object"?
the majority of the Unity API is not available off the main thread
would help to see more of the code, so we know why you are in a async method and returning a task
I'm modifying an asset that deals with making a launcher to download and update a game, so I'd rather not change the method properties
So the UnityEvent invoke just breaks when trying to do it from a Task?
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
If I used await OnDownloadingGame.Invoke() would that help or?
I mean dereferencing most anything derived from UnityEngine.Object
I use Task.Run() to start the method
you are just grasping at straws unity events are not tasks
It could be the simplest error of all time, threading doesn't even need-well that'd do it lol
And there it is
that is the root of your problem that means you are not on the main thread
how can I run it on the main thread then? Would running it from an async method with await fix it?
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
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?
I see, thank you. Tasks, async and the like are still a little confusing to me..
unity doesn't have documentation talking about the implications of using async, does it?
searching it just gives me AsyncOperation
It's more C# i suppose
its a C# thing, but unity does have a sync context setup, so after awaiting something it will return to the correct context
along with Tasks and Jobs it just feels like a headache to understand :^)
also async ops have tasks, callbacks or ienumerators
Right.
so you can pick and choose which way to handle concurrency
There are just some special considerations for when using it in Unity -- no touching the scene from anything but the main thread, after all
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
Of course.
how do i do an inverted sprite mask in unity 5...
But it’d be nice to have this explained as it pertains to Unity
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
Unity 5 was released <t:1425384540:R>
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
im limited to that ver because i use the new 3ds platform
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?
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
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
Oh yeah that makes sense
Thx lmao
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
What are you trying to do
Let me write a hierarchy
This doesn't really sound like a code question BTW
Are you trying to export assets from one Unity project to another?
Here is the hierarchy:
Old Folder
- TextPrefab1
- SomePrefab1
- TextPrefab1 inside
New Folder (Duplicate)
- TextPrefab1 inside
- 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
^^^
Basically I want to be able to have a 'hard' copy of the folder
but why?
It's quite a long explanation, but I hope you get the idea
this feels like an XY problem
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
So how do I do it?
you should really answer the question first
in case it turns out there's a much, much easier way to deal with your problem
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.
is this in-game or in-editor?
In-editor
would prefab variants not be better for this
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
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
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)
I separated it from the start
hmm
So any help is appreciated
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
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
Sounds smart
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
Yeah, would you be so kind as to help me with it?
@heady iris Anything for me?
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
does that not just install it in your Packages folder that you can commit
ya, its installed locally, but because it's a local reference it has to be removed and then reinstalled by any collaborators
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
oh maybe I'll try the relative path in the manifest. I didn't think of that
If anyone ever needs this, here is the solution http://answers.unity.com/answers/1823316/view.html
Just tested the code and it works
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
i put the tarball in my projects packages folder then added it via the add tarball in the package manager
"com.unity.services.leaderboards": "file:com.unity.services.leaderboards-1.0.0-exp.1.tgz",
that is how it showed up in the manifest so thinking it might work
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);
}
}```
TY! Ya, I just tried the same thing. I actually had accidentally fixed it but just uploading the tarball to the project and importing it. Apparently unity it smart enough to know to use that as a relative path.
cool yeah was trying to remeber how i did it, there are just so many ways to install pacakges and some go into the folder by default and some are in the cache
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
Is it difficult to make a bot for my game? So that I can play offline
hello i have a question, who uses node js? for call this aplication in webgl
I use it for a school project
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'));
You use node.js with unity
if i siwtch
then i change application
yes
juste for lunch in local
there is a cache probleme i suppose
i don't know
Ah sry then i cant help you much. I use node.js with a webapplication. Sry for the confusion
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?
level ^ 3 - this is level elevated by 3 correct?
How can i do this in C#?
You can have per project script templates. I personally find that it's easier to create new classes by just adding it to an existing file and then extracting out in IDE.
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
Mathf.Pow will raise its first argument to the power of its second argument
Mathf.Pow(level, 3);
Thanks!
(int)Mathf.Round((4 * Mathf.Pow(level, 3)) / 5); I am questioning what does the (int) before the function do
forces it into an integer type
(TypeName) performs a cast
you can cast a float to an int by throwing out the decimal part
you can also just use Mathf.RoundtoInt() instead
Mathf.RoundToInt((4 * Mathf.Pow(level, 3)) / 5);
guys i think i did a random.range via using scriptable object!! BUT