#archived-code-advanced
1 messages ยท Page 173 of 1
what's that?
that makes no sense. you already have the materials in all other builds
no-
try searching "mod" in the asset store
I need someone to be able to install the sdk, add their own materials and models
upload the map which I need to convert first somehow
and then someone can join by accessing it from the database
use addressables
so I need to learn how to use them
I need the user making the map to not have to do a lot of complicated stuff
just make the map and press a button
what's your game dev experience
I've been donig it for 5 - 6 years and I can pretty much make a full game
there are assets in the asset store to help you do this
you can look at one to learn the whole workflow
however this is a lot of new stuff, including networking which I never got quite right
but I think I'm on the right track with taht
ok but can I use them to just, take everything in a scene, with materials, models used, everything, and just make them into addressables and then upload that?
that's all I need to know
are addressables usable for this?
ok they don't seem to be
When calling UnitySendMessage(string gameObjectName, string methodName, string message) from a native iOS plugin, does anyone know if the third parameter, string message, is optional? I know it is when calling from a .jslib plugin, but I haven't tried it with an iOS plugin yet.
The docs say this:
From native code, you can only call script methods that correspond to the following signature: void MethodName(string message);
Now if you pass null as that third parameter I'm not sure what Unity would do - throw an error or just give you a null message param
I'd say... try it and see?
worst case scenario, just send an empty string
No
I've been messing around with additional Display and have managed to achieve what I wanted using win10 user32 api stuff, avoiding actual Unity code. Now I am trying to render into a very large window (6400x2560) and using Display.SetRenderingResolution does not work, it get's clamped to 1920x1080. The one thing that hurt me the most, that this is completely undocumented.
https://docs.unity3d.com/ScriptReference/Display.SetRenderingResolution.html
It worked in the editor (the editor-windows dont have this clamp)
https://i.imgur.com/KrmYRmf.jpg
I'm wondering if there is any way to get aound this clamping behaviour?
I have a special walk animation I want to play when walking along a narrow platform. I use a trigger on the bottom of the player to find this narrow platform to start this walk. But I need the player to face the direction of the narrow platform. This is 3d game. The player can only move forward and backwards on this platform so they don't fall off. When they start to walk on this platform, like I said, I need the player to face the platform. I know how to cast a raycast, would this work somehow? Thanks.
what is your objective?
what is the direction of the platform?
It is like the ground, but narrow and long
Is rayHit.normal the way to go?
a narrow platform sounds like it could have two directions
for this example a narrow platform would just be a box collider
But it wont always be a box collider, it could be a meshcollider
is the platform's direction platform.transform.forward?
you can do player.transform.forward = platform.transform.forward right?
cant use this because you need to go onto the platform from both sides when you finish walking on it
Will do! Lol now I just need to actually figure out how to write the native class in Obj-C or whatever
@river musk it sounds like a #archived-code-general or #๐ปโcode-beginner question i think you'll figure it out
it's not optional. pass an empty string
you can download the prime31 plugins to learn more about ios-unity plugin development
did you try searching the asset store for this?
Ah, yeah, no for sure, it's definitely a try it and see sort of question. But thought that it'd be more likely to find someone who'd worked with external native plugins in #archived-code-advanced
that was meant for TitanDev
Oh my bad
you can use the dot product of the player character's input direction and the "forward" of the platform to determine which of the two logical platform directions to use
@undone coral my objective is to create an animated wallpaper that spans all 3 screens (or more). I can settle for single screens I guess, but if possible I want full expansion
so you want unity to run as a process in the background, and then interact with a bunch of windows APIs to render updating desktop images?
currently the only thing in my way is the resolution limitation. I want to have one window to interact with and one window as a wallpaper that shows everything without the controls
when you say spans all 3 screens
this all works. but the resolution is just capped.
what do you mean? a contiguous graphic?
yeah, I make one window that spans all 3 screens
you can use a render texture on your camera to create a single contiguous image large enough for all the desktops, and then slice it into each respective view. or you can render each desktop separately, using its own camera, if you line up the cameras right
how are you putting an image onto the desktop?
so 6400x2560 for my personal setup. the window gets rendered behind the desktop icons
I'm actually using a asset (live wallpaper) and have modified it quite a bit
can you show me a doc for how you are rendering a window behind the desktop icons?
okay
that's helpful
but this all works
i heard you the first time
splitting is a decent idea, but also means more draw-calls. the asset supports it, but only in the editor. it was never intended to do what I want
okay
the asset is designed to place your main window in the background, not a secondary display
so you modified the asset?
yes
got it
well mostly repurposed some of the code
I wrote all the window management code myself
besides turning it into a wallpaper
why would you use Display.SetRenderingResolution?
is there another option?
well the resolution of the large window was obviously wrong, so I tried to overwrite it
but it's probably wrong because of the same clamping mechanism that stops me from setting a higher resolution
something works in the editor
yes. the editor windows allow super-sampling (I read that in a forum post)
or super scaling: https://forum.unity.com/threads/resolution-superscaling.447034/
yeah, but the output to the screen is the problem
i'm not sure why the displays are showing the wrong resolution
maybe try to use their real resolution
your splitting idea might work, but it's a horrible work-around for something that seems like an arbitrary limitation
I'm using post processing effects and the context width/height is clamped
or shows that it's clamped to 1920x1080
I guess the final option would be to start messing in Unity source-code, but that might be too much for me
there's a lot going on
since i don't know how the asset really works it's hard to give good advice
it's like detectives work when you don't know why something does not work...
thanks a lot for your help, I was mainly wondering if I missed something obvious. looks like I am just at a dead end caused by this weird limitation
I really don't think the asset is even relevant in this context (only to understand what I am doing and why)
hmmm. what I have not tried is to use the main screen to resize for the full 3 screens. Not sure if Screen.SetResolution might have different limitations
Is there any other way to make dialogue narratives properly without using Ink?
no
there's an asset that ships an Ink compatible UI
Dialogue System
anyone have a good example of localized controls in local multiplayer using the new input system? The issue I'm having is everything is working as intended (new players are spawning and moving) but every input moves all players. I think I messed something up because of the method I used (subscribing to events in onAwake();) It seems that my script is failing to add new distinct players and I'm not sure how to fix it since there aren't any tutorials I've found covering this method of input.
in awake im defining a new playerinputaction but this doesn't seem to matter, they're all still inexplicably tied together
I think the strategy might be to drop back to sending messages as opposed to bothering with subscription but I've been told the latter is more efficient
If you're not using myPlayerInput.onActionTriggered then you're using the C# events method for PlayerInput wrong
for example if you're doing something like myPlayerInput.actions['MyActionMap/MyAction'].performed +=
Also if you're doing this you're also ignoring the PLayerInput component
Actually using the PlayerInput is important so you can take advantage of all its nice local multiplayer features
such as automatic device binding etc
do that
Alright, got it. Is there a good body of example code I could look at? clearly the tutorial I followed was doing it quick and dirty without multiplayer in mind
yeah this is more or less what I'm doing
my awake method looks like this atm more or less
yeah you're completely ignoring the PLayerInput and all the joy it provides
you're using the generated C# class instead
which is great under normal circumstances, but not for local multiplayer
Which methodology would you recommend instead when working with local multiplayer?
using the PlayerInput
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/Components.html is a decent introduction to it and the PlayerInputManager and the ways to use them
thanks, appreciate it
Also there's an #๐ฑ๏ธโinput-system channel!
it generates a c# class??
if you ask it to
Can someone please check these two codes? I made a system to switch between cameras to make cutscenes when a lever is activated. For some reason, when I use this script, on 3 cameras, in only one camera's case does the camera switch work. By switching, I mean main camera becoming inactive and other becoming active. In the case of other 2 cameras, they become active but main cam doesnt become inactive. This is the code for the lever that is activated.
//See update function
public class LeverScript : MonoBehaviour
{
[SerializeField]
ConsequenceCam ConCam;
public bool isActivated=false;
Animator anim;
BoxCollider2D triggerArea;
// Start is called before the first frame update
void Start()
{
anim=GetComponent<Animator>();
triggerArea=GetComponent<BoxCollider2D>();
}
void Update()
{
if(isActivated)
{
isActivated=false;
if(ConCam)
ConCam.ActivateCinematic=true;
triggerArea.enabled=false;
}
}
void OnTriggerStay2D(Collider2D col)
{
if(col.tag=="Player" && Input.GetKey("x"))
{
anim.SetBool("isActivated", true);
isActivated=true;
}
}
}
Next code is for the cutscenes attached to a UI object as I animate this object to make the cutscene movie like.
//See playCinematic,endcinematic and update functions
public class ConsequenceCam : MonoBehaviour
{
public bool ActivateCinematic;
[SerializeField]
float duration;
[SerializeField]
float destroyCamIn;
[SerializeField]
GameObject consequenceCam;
[SerializeField]
GameObject currentCam;
Animator anim;
void Start()
{
anim=GetComponent<Animator>();
ActivateCinematic=false;
}
void PlayCinematic()
{
if(ActivateCinematic==true)
{
anim.Play("SequenceBegin");
Invoke("EndCinematic",duration);
}
}
void EndCinematic()
{
anim.Play("SequenceOver");
ActivateCinematic=false;
Destroy(gameObject,destroyCamIn);
Destroy(consequenceCam,destroyCamIn);
}
void Update()
{
PlayCinematic();
if(ActivateCinematic)
{
consequenceCam.SetActive(true);
currentCam.SetActive(false);
}
else
{
consequenceCam.SetActive(false);
currentCam.SetActive(true);
}
}
}
Ignore the destroyCamIn variable, I tried to fix it with that
Idk what to search for
All I know is Asset Bundles seem to be the best option and the right tool for the job
You should pointed down which section of the code... or else people wouldn't take a look at those huge chunk of codes
ok wait
done
please help someone
Hello. Can someone tell me how to do collision detection without CompareTag etc.. Maybe someone will mention a design pattern or practice?
I want to make next relations:
Player - Enemy
Player - Coin
Enemy - Coin
Enemy - Player
Coin - Enemy
Coin - Player
I don't want to make multiple if statements and describe each logic. Im trying to create some system which will just execute logic. Maybe State pattern will come handy?
good way to do that is with interfaces
But how to make comparing automatic? Create class which will compare, but how to automate this? Is it possible to avoid 100+ checks?
yes it is possible
let's say you want to be able to collect the coin as the player
you add an interface to the coin called ICollectable. In that interface you define a method Collect( ICollector collector ). When the Player or whatever overlaps with the coin trigger, the player checks the interface and calls Collect on it. Maybe ICollector has an AddCoins method on it, and the coin calls that in its Collect method
Let me expand my question to clarify
that would be nice
Enemy - Player = Reduce hp to player on collision and make him invulnerable for a period of time.
Enemy - Coin = Enemy AND Coin destroys on trigger
Player - Coin = Collect coin and destroy coin on trigger
In my personal case destroy means move it back to object pool of course ๐
when you say disable, do you mean they both get destroyed
At this moment its not that hard to describe every relation in if statements, but what when i want to add and add more?
well, as a general rule it's not a good idea to try and design your system to handle every possible situation
Corrected
you will find yourself in paralysis by analysis very quickly
often best to just do it quick and dirty and refactor as necessary
Yea but i making technical specification for applying a job ๐ and thought it would be nice if i ended up with something new
ah
Add IPlayerDamage interface to the Enemy, and add ICollectable to the Coin
the player looks for both IPlayerDamage and ICollectable
the Enemy looks for ICollectable
when I say "looks for" I mean in a trigger/collision event
So in the end you will always add this "looks for" by yourself
yes, at some point some code has to be written so that things happen
lmaoo
In my mind i was thinking about collision detection system which will somehow operate logic between collision types.
Lets say create CollisionType : ScriptableObject which will have collision name variable and somehow store collisions/triggers that will have some logic related
That basically sounds like a wrapper over the collision callbacks, which you would have to code anyway
I feel like that system would get cumbersome fairly quickly
and CollisionController : MonoBehaviour which will have CollisionType refernce with Callbacks that will automaticaly execute logic
yea basically its wrapper
Maybe something wrong with me but i want to avoid this same and infinite "looks for" things
you gotta look for a thing to do something to it ๐
I mean at the end of the day you'd have to look for the CollisionController in order to call the appropriate callbacks
otherwise how would you know the collisiontype
unless you encode that in a tag or sommin
You mean check for CollisionController existence on object that collides?
yeah
otherwise how do you know what type you're colliding with
in order to execute the rules
Not that hard i think. Before any callbacks just check if he has collisionController in order to communicate with that system
Anyways, big thank you @granite viper @modest lintel for conversation. Gonna find solutions on my problem on tech interview i guess XD
Goodluck!
Hello. How would I go about replicating the parent->child position relation through script?
What I mean is, that when you put a Cube into another Cube, its direction from the parent stays the same; all the time... (during rotation, during change of position, etc.)
Let's say I have two GameObjects (or 2 Vectors, to be more exact) and I want to "stick" one Vector to the other, like I explained.
Vector3 dir = volume.transform.position - examplePoint.transform.position;
examplePoint.transform.position = volume.transform.position + dir;
This is something I tried, it works fine, until I rotate the cube. At that point, it stays in the same position... which is understandable, I never say it should be exactly "in front of the cube", but I cannot rely on the fact, that it will always be in front of the cube, it can be behind, on the side, and so on.
volume is the parent
examplePoint is the "child" (not literally, but its behaviour must be as if it was a child of volume.
Thank you
I am facing a weird problem.
I have two scripts XYZ.cs and ABC.cs.
Both are on same game object.
I am trying to access ABC from XYZ.
But it's returning null.
I tried getcomponent<ABC>() and dropping the object in inspector to script.
I tried everything I could but don't understand why this is happening.
Can anyone tell why this is happening?
how do you know ABC is on the object?
I am trying to make an API listener in unity WebGL, how would yall do that?
I made one but i hope to get more info how u would do it
your script is called Camera
therefore it is trying to access a field in your class called main
oh holly shiet! im so dumb lmao
lmao
thank you!
np
Anyone??
Could somebody advise on this error:
In this case the file and the class name do match
This is the file:
CommandEventConfig.cs
using UnityEngine;
namespace EffortStar {
[CreateAssetMenu(menuName = nameof(EffortStar) + "/" + nameof(CommandEventConfig))]
public class CommandEventConfig : BaseEvent<
CommandEventInfo,
CommandEventConfig,
ICommandEventFilter,
ICommandEventEffect
> { }
public struct CommandEventInfo {
public Actor Actor;
public Command Command;
public CombatContext Context;
public CommandEventInfo(
Actor actor,
Command command,
CombatContext context
) {
Actor = actor;
Command = command;
Context = context;
}
}
public interface ICommandEventFilter : IEventFilter<CommandEventInfo> { }
public interface ICommandEventEffect : IEventEffect<CommandEventInfo> { }
}
And screen shot of file with name?
Seems like it should work. Maybe try creating a new file? Maybe it cached something funny?
I'll try deleting scriptassemblies
Yeah it's likely Unity lost track, re-create the script
examplePoint.transform.position = volume.transform.rotation * (volume.transform.position + offset)
Thanks a lot
hey so, I figured out how to use Asset Bundles
problem is
I have to select the asset and then trigger the function
is there any way I can tell it to get an asset at a certain location and convert it
instead of taking the selection
a parent constraint
@undone coral I managed to solve the problem I was having with screen resolution. I can use the main screen to stretch over 3 screens no problem and the resolution is perfect. It just does not work with a secondary screen.
Now I have a new issue. I need to switch cameras from one display to the next. This works fine by simply changing the targetDisplay. The problem I am facing is that the all my Canvas UI no longer works (it renders fine, but I can no longer click anything). I've tried removing and adding the cameras a frame later + changing the render mode, but this does not help.
oh damn... Canvas also has a targetDisplay value.
Is there an attribute that I can assign to a method that informs the compiler that the method will be called from outside the project? I have a method being called via UnitySendMessage from a native iOS script. Ideally, I can mark it so my IDE knows it's being used.
Okay, just in case anyone's curious, I think I'll use UsedImplicitly (I'm in Rider) for this (https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html#UsedImplicitlyAttribute)
making it public is usually a good hint
yes... it's called externally referenced or something like that
it's unity's version of usedimplicitly
there's also something related to il2cpp
that marks it as something that should never be stripped
you don't distribute il2cpp precompiled libraries though
so it's unusual to mark methods this way unless they are access by plugins
maybe it's in the AOT namespace
Does anyone know how i can change values of a mask in a shader while in runtime?
what do you mean
in a shader graph?
using something as a mask?
Well i have never made a shader, this shader is made by the person who does the graphics and now i have to change the values during runtime
This is what i got, i gotta change the BlackMask Offset
then set the appropriate property
use this and similar api https://docs.unity3d.com/ScriptReference/Material.SetFloat.html
That is the thing, this shader is not on a certain object
We have it on the forward renderer
not sure. you'll have to google "animate forward passes shader unity"
then use the appropriate api there
how ya mean?
urp?
yes
ok i don't understand. when you blit, you blit with a material for this purpose. so you still should have access to the material
Is there a certain way i should do the reference to it in the other script?
what other script?
? what? that's a monobehaviour
Ok i guess i am trying this wrong
you want it as fullscreen pass right?
What i am trying to do is, at a certain time in the game i need it to change, planned to just call a function then
Basically yes, its a vhs filter
you can only do fullscreen passes with ScriptableRenderFeature / ScriptableRenderPass
Do i just change monobehaviour to it? It wont register it if i do
what do you mean?
Thanks
Don't mean to spam, but anyone know about scripting LineRenderer in a way that doesn't lag behind the object it's starting from?
#archived-code-general message
Hey guys, how does getpixels work?
When I try to do GetPixels(gameobject.position.x, 0)
It has an offest
offset for different devices
But when I do GetPixels(400, 0)
it gives me the exact correct colour
How goes GetPixels read the texture?
compared to reading say world space coordinates?
What does thismean, how do you read world space coordinates, and how does that have anything to do with getpixels?
GetPixels returns an array of pixels in a pixel area, that's it
Im trying to use it with mouse coordinates
So when I have my cursor on the specific part of the texture, it should give me the exact colour of where my mouse is
What texture
It's a chromatic texture
I cant show mine because its a custom one which im not allowed to show
but it looks like this
It's it on a 3D object or what
Its on a ui object
I read some forums where it said you have to make some form of calculation to get the exact pixel
Then you need to convert your cursor position into the space of that rect, and then use that to sample into the space of the texture
Is there a built in function to perform this?
The rest would have to be manual
You mean actually inputting the parameters of the function?
I mean converting from local space to pixel space
That could do it, I've never used it before
Hi,
i am trying to register Event Handler that calls a function with args.
I had this to call the function:
itemSlot.RegisterCallback<PointerDownEvent>(OnPointerDown);
According to unity docs, it is possible to register event with args:
https://docs.unity3d.com/ScriptReference/UIElements.CallbackEventHandler.RegisterCallback.html
So i tried to apply args:
slotName = "itemSlot1";
itemSlot.RegisterCallback<PointerDownEvent,string>(OnPointerDown(),slotName);
slotName is a string i want to pass into the "OnPointerDown" function, but no matter what variation i try, i always get errors.
Don't call your callback
The function is a parameter, adding brackets to it calls it and then you're passing the return value to the method (presumably void)
Compare the two pieces of code you posted if you're missing it
Thank you, i get what you mean, i corrected it, but it still doesnt pass the arg "slotName"
newSlot.RegisterCallback<PointerDownEvent,string>(OnPointerDown,slotName);
i thought this is the way that docs suggest, but i have an error (i will screenshot it, but must change languae of my IDE first)
Cannot change debugging language to english in stupid vscode, as it adapts from system.
This is my code
and the error underlined in red is this:
https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs1503
Your method needs to take the correct arguments
Can you use your IDE to generate an overload
By pressing alt-enter on the error
This looks good, presumably it works?
The error is gone, i thank you very much ๐
Not sure if i should consider this "advanced". Is this ok to post here? I'm really desperate ๐
I'm trying to stop the character (Polygon Collider 2D) from moving through a wall (Tilemap Collider 2D).
1 var hitResults = new RaycastHit2D[10];
2 var hitX = collider.Cast(new Vector2(desiredX, 0), bodyFilter, hitResults);
3 //var test = new Collider2D[10];
4 //hitX = collider.OverlapCollider(bodyFilter, test);
5 if (hitX == 0)
6 {
7 transform.Translate(desiredX, 0, 0);
8 }
Why does the character not stop moving horizontally when I run the code like this? I proved the character can collide with the wall because it does stop moving horizontally when I uncomment the two lines (3&4).
Anyone have any fun tips on how I might want to program this to make the debris spiral around? Essentially its a magnetic gravity gun - I break the rocks, I can lift and suck them in
but it might be fun to have them spiral around one another
vortex like
I suppose I could have some sort of check that sees if they're close to the center, otherwise it pushed them in a direction (up down left right)
Iโm on mobile @wary quail but you can use a point offset by sin for the x and cos for the y feeding in a growing time value to make it move in a spiral
https://sites.math.washington.edu/~ebekyel/Math126/Spiral.html
does anyone have a good water tutorial or script i can look at?
dude I already answered you, don't double post the same Q
#archived-code-general message
Ik u answered it was j i didnt get anything from reading the code that exist in that github
so without a reply knowing that How can I direct you the right way, your question wasn't specific to your code knowledge just you wanted to look at scripts
This is not an advanced code question. Provide more context in the original channel you posted in so people can actually provide meaningful help
there's probably an asset with tons of physics fields for rigidbodies
messing around with some recursive stuff, is there a way to tell c#/unity there is a limited amount of iterations so it doesn't try to allocate infinite memory?
public class EcoSystem
{
public Vector2 position;
public float radius;
public EcoSystem[] children = new EcoSystem[7];
}
```still happens when i don't use the array as a member and use new in the constructor
i'm guessing it's just a terrible idea to use classes and constructors for this in the first place? haha
Nothing necessarily wrong with using classes for it like this, but you need to just not call new EcoSystems[7] anymore when you're at an object that doesn't actually have children anymore
Only serialising this would be a problem
that's what i tried, if(iterations <= 0) return; at the start of the constructor and only initializing new "selves" after that, but seems like it still still doesn't like that
The array has 7 null values in it, there's no infinite loop unless you're always initialising the indices
Oops, how did I not notice that... That's what I get for looking at code before having fully woken up ๐คฆโโ๏ธ
public class EcoSystem
{
public Vector2 position;
public float radius;
public EcoSystem(int iterations, float radius_, Vector2 position_)
{
EcoTrack.Track();
if (iterations <= 0) return;
//EcoSystem[] children = new EcoSystem[7];
radius = radius_;
position = position_;
EcoSystem one = new EcoSystem(iterations - 1, radius / 3, position);
for (int i = 0; i < 6; i++)
{
float angleRad = (60 * i) * Mathf.Deg2Rad;
Vector2 childPos = position + new Vector2(radius * (2.0f / 3.0f) * Mathf.Cos(angleRad), radius * (2.0f / 3.0f) * Mathf.Sin(angleRad));
EcoSystem six = new EcoSystem(iterations - 1, radius / 3, childPos);
}
GameObject circle = Utils.DrawCircle(radius, World.me.matUnlitColor, Color.cyan);
circle.transform.position = position;
}
}```it's still not happy 
https://i.imgur.com/uAnaHdy.png
i think i just need to change my approach
hi someone can help me to fix these errors ? it's strange because just jump out sometimes and sometimes no, i think that is a editor bug but i dont know
actually i think those errors and warnings were unrelated at that point, i might have screwed something with memory permanently in earlier attempts and should have restarted the editor sooner
switched to recursive function outside of the class anyway and got it working https://i.imgur.com/Fsr31Wu.png
that's a nice pattern
Are these causing any obvious problems for you? In general, GUIUtility errors are seemingly harmless editor visual errors. I wouldn't worry about them unless they become an issue. Or you could report them.
No, they do not cause me noticeable problems, even so they worry me
Hi, I've not posted much on this server before, so I don't know if this is the correct place for this, but here goes.
I'd like to combine multiple animation curves into one, so that the width curves from several line renderers can be used for one continuous line. The same goes for colour gradients, but right now I'm focused on getting widths working correctly. Here's what I have so far, I'm aware its a little hard to understand, so sorry about that. If anyone knows a good way to achieve this, please let me know as soon as you can.
Also, I'm not sure if the tangents and weights work correctly, so that's something to bear in mind.
_width = new AnimationCurve(); // Create a new curve
for (int i = 0; i < _lineParts.Length; i++) // Loop through all LineRenderData scriptable objects containing width data
{
LineRenderData renderData = _lineParts[i].RenderData; // Cache current render data
for (int j = i > 1 ? 1 : 0; j < renderData.Width.length; j++) // Loop through each keyframe in the cached render data's width curve. This ignores the first keyframe from subsequent frames, to avoid overlap, this is something I'm not sure how to mitigate
{
float time = i * (1f / _lineParts.Length) + j * (1f / lineData.Width.length); // Get time value, this is what I'm struggling with, I'm not good at math. :(
_width.AddKey(new Keyframe
(
Mathf.Clamp01(time),
Mathf.Clamp01(renderData.Width.keys[j].value),
renderData.Width.keys[j].inTangent,
renderData.Width.keys[j].outTangent,
renderData.Width.keys[j].inWeight,
renderData.Width.keys[j].outWeight
));
}
}
_lineRenderer.widthCurve = _width;
Hey anyone know how to look if every element of a list is equal
`public List<int> A = new List<int>();
public List<int> B = new List<int>();
If(A == B)
//statement true`
Will this do the trick or is there something else?
A.SequenceEqual(B)
Thx man I will try
1 more thing
How do I make a rpg defense system like diablo 2?
just curious, how are u 'breaking' the rock into smaller ones? it it like a entirely new prefab or something else?
I mean when In diablo if enemy ever hits you even if you have 300 defense while the enemy has damage btw 12-24 the player always takes damage it does not subtracts it from the defense instead makes a chance to block that determines if it is true player takes 0 damage if false player takes a random btw min/max of enemy?
Anyone has an idea how?
those are just rules you can implement with simple if-statements
How?
your question is more suited for the channel he pinged
Hey I am not a beginner, if u guys think so I will look into this myself and get a good output!
for some reason transform.InverseTransformDirection() isnt working correctly
here is the code: ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class localVel : MonoBehaviour
{
Rigidbody rb; // <- OBJECT NEEDS RIGIDBODY COMPONENT
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
var locVel = transform.InverseTransformDirection(rb.velocity);
locVel.y += 1f;
rb.velocity = transform.TransformDirection(locVel);
}
}
when used on an object parented to a rotating object, it gets added velocity in the direction the parent is rotating
this should **not** be happening
the **reason** it **shouldn't** be happening is because `locVel` should be a **velocity** vector in **local space**.
` locVel.y += 1f;` should accelerate `locVel` in the **`y-axis`**.
instead, what i am observing is acceleration in the `y-axis` **and the `z-axis`**.
Hey in here, I'm looking to implement an algorithm that can visualize a tech tree for me. The tech tree is in essence a directed acyclic graph, and I've been looking into layered graph drawing as a solution, but I can't find any resources that explain how to implement in a more approachable way. Anyone who can point me in the right direction, perchance?
I've found some potential research papers on the subject, but would like to see if I can't find something more approachable before I spend a good bunch of hours trying to follow the papers.
is it a very elaborate, complicated tech tree that needs to be expanded a lot? because in a case i ran into recently, i was thinking similarly but then realized it's much easier to just store a bit of grid data per skill/tech manually, though in my case it was fairly simple
What would be a good approach for snapping/aligning instantiated objects with another surface?
As a start, aligning spawned objects with the ground plane for instance
grab surface normal, align object up with surface normal
Raycasting to the bottom + 1/2 vertical bounds offset?
yes, by raycasting
Okay, figured that one, but I don't know how to get the proper offset
this looks about right
no
because if you have the normal and hit position (assuming the object's pivot is at its bounds center), you'd place the object at hitPosition + normal * bounds.size.y * 0.5f
you will need to account for rotation to align the object's rotation with the surface, yes
but positioning doesn't require it
if you can guarantee that the object pivot is at the base, it gets real easy
since you can put the object at the hit position
I see. That's fine, I'm not sure if I need to account for rotation then, positioning should be enough
Yeah, but I can't guarantee that unfortunately
if you don't care about the rotation of the object itself yes
Thanks for the hints, I'll try it
@granite viper Works great, thanks again!
Hi guys, I have a question how to read texture coordinates from mouse position
So if I put my mouse cursor on a specific part of the texture, it should give me that exact colour of the area on that texture
I need to get the texture coordinate on a UI image
@thick spire first step is to get the relative position of the cursor over the image
then you can convert that into a pixel position, then you can use GetPixel on the texture
assuming it's readable
it's a bunch of arcane stuff. maybe use a color picker component. if you are on a deadline, use ScreenCapture.CaptureScreenshotIntoRenderTexture
getting the relative position of a cursor over the image is arcane
the ui image isn't a piece of geometry, it doesn't have UVs, it has some sense of a local space but not one that is easy to understand
is the tech tree dynamically generated? if not, lay it out by hand
this isn't the right approach. have you considered an asset store asset for kinematic character controllers?
yes
at least to study
yes
Hey guys! I made a thing in Unity. Two things stand out: Artificial gravity based on a trigger collider, and the fact that all the physics objects inside that volume seamlessly inherit all transforms. (Also, they donโt receive any external acceleration that the master rigidbody experiences!) I achieved this with this hierarchy i...
im trying to replicate this
it does not use kinematic
or at least i reckon it doesnt
How do you convert it into a pixel position?
if you have an x/y relative to the image (meaning that 0 is the left side and 1 is the right side), then the pixel position is Mathf.RoundToInt( x / image.width )
and same for y
I found this, if its of any revelance. https://gamedev.stackexchange.com/questions/198782/how-do-you-get-the-texture-coordinate-hit-by-the-mouse-on-a-ui-raw-image-in-unit
that works
Wait, do you mean that after you do RectTransformUtility.ScreenPointToLocalPointInRectangle, the left side of the rect transform should return 0 if you hover over it with the mouse?
I don't know what ScreenPointToLocalPointInRectangle returns
a point
but in either case you can convert it to be in 0-1
XD
do you mean by doing screentoviewport?
no
again, I don't know what type of coordinates
(๐ @modest lintel) localpointinrectangle returns
so if you can answer that for me I can tell you what to do next
I have this rectangle
Like someting like this which i cant actually show
Its a child gameobject
it has a ui image texture
can you just implement LocalPointInRectangle and tell me what it is returning for that gameobject
Ohh
Wait let me see that functio
wait
waiting
Ok
So for both upper left and bottom left corner it returns -342
how performant is an inverse lerp? pretty solid?
yeah it's fine
upper right and lower right its 342
it's just a simple math expression
okay good
Im looking at few different formulas and inverse lerp seems to be the simplest for my needs
@thick spire do you know how big the image is
its 512x121
width and height
how big is the recttransform it's on
ok
looks like localpoint gives you a position that is relative to the center
so you're going to want to do something like
var localX = sampledX + rectTransform.width / 2;
var uvX = localX / rectTransform.width;
same for y
uvX is a value from 0-1 (hopefully)
create individual images and add pointer click handlers for them
so now you multiple uvX by the image width
and round it to the nearest int
that is your pixel coordinate
the image im using is verified by my company
its custom made
so i cant really use any other assets
is it 5 swatches of color?
its a chromatic image
like all the colours on a rainbow but mashed together
use capture screenshot then
and sample it
it will be faster and simpler than this
using a canvas scaler, for example, makes doing the arithmetic much harder
there are many pitfalls
@thick spire so trust me, use capture screenshot
ScreenCapture.CaptureScreenshotIntoRenderTexture
So your saying this right
Is it impossible to use the new unity analytics on WebGL? Seems like core initialization and authentication relies on System.Threading and I see no way around that
I cant use other assets because the custom one im using is verified by my company
i have to work with company asset
Hey, did somebody mess around with writing Lexers/Parsers before?
I feel like I understood the concepts, tokenization ->syntactical analysis/building AST->semantic analysis,
What's confusing me is, that almost all examples I've seen would tokenize into something that already has a meaning, for example
i have an idea would be tokenized as SUBJECT (i), VERB (have) and OBJECT (an idea),
while my brain is telling me that they should all be STRING and it's the Parsers job to give that sequence of tokens a meaning by trying to parse that STRING into a verb, subject etc depending on the grammars expectations
Any advice and/or recommendations? I've read and watched around 10 different videos and talks, if you have a really good >read<, feel free to share it, but I'm mainly looking for personal experiences!
for anyone interested, the Unity-Context is that I'm making some form of developer command system, i already have a working, easy to extend version, but I'm trying to rewrite it with a proper Lexer/Parser, for learning purposes and eventually easier extendability of the command syntax and possible features?!
I've written lexxers and parsers for programming languages but natural languages are an entirely different beast
It's for a programming language like syntax
If your input allows you to parse while tokenizing then go ahead, it'll be faster
But might not be possible once your syntax becomes more complex
For example you cannot simply infer the verbness or nounness of a word from the word itself, as many can be Both with depending on context
I took the example with the natural language because I found it easier to understand what's bothering me in the tokenization examples
Ok if it's not actually natural language it's easier
the lexer understands the individual symbols that make up the language
Cause I find it nonsense that tokenizer knows, for example, what a STATEMENT would be, it would know STRING OPEN STRING CLOSE in my opinion
And parser would know it's a Statement and creating a node for the AST
the parser understands how those lexer tokens get combined together into context
in other words the difference between a lexer and a parser is semantics
Do you guys know if it would be possible to export a character from a Unity scene to FBX format at runtime in a compiled Unity project via code?
I was toying with the idea of making a character creator that allows users to export their characters but I am not sure how feasable is this via code.
a lexer understands how to convert a string into tokens, a parser understands how to convert tokens into code (in the abstract sense)
@regal olive should be possible, would need to write or find an FBX serializer
I don't think unity has one
built-in, that is
It's all just semantics and separation of responsibility, if it makes sense for your language then you can do multiple things in the some process
I know that modern parsers do the tokenization "on the fly", also I've seen examples of "functional" parsing where the tokenization process was skipped entirely by parsing in a recursive way, where the only parser you'd use would be a, example, 'commandParser' that would then call further parsers like nameParser and argumentParser which, again, call more parsers, for example stringParser which would go to letterOrDigitParser and so on, that's quite elegant but too confusing for me at the moment
I'd like to completely separate them from each other
Yeah it gives a value between 0 and 1!
yay
I see, I am not familiar with that branch of programming but do you have any idea of how common it is?
I was thinking about trying to find a freelancer to help me with it if its something feasible.
i think you said to multiply a width by texture width after?
uvx i mean
FBXs require a licensed library from autodesk, iirc it's not cheap
is it the width of the actual texture
or the rect transform width?
I see
@thick spire the width of the texture
basically what I'm wondering, in my context
Should I tokenize something like Command, Arguments etc, or rather String and then let the Parser check
-
what am I expecting, grammar wise? (Would be
Commandfirst) -
is there a matching
CommandforString? -
more work
-
create Command Node for AST
I would probably err towards the former
if you can identify it in the context of the lexer, it makes your parser work easier
True! What I thought about, is multiple lexing stages, if that makes any sense
Like in the first stage, 1+1 would be NUM OP NUM
and the second would replace that with EXPR
Parser would then check if EXPR is a fit for the expected grammar
hope the abbreviations are clear XD
that would make
command(Blabla).do()
from
STRING OPEN STRING CLOSE DOT STRING OPEN CLOSE
in the first stage into
COMMAND ARGUMENTS CHAIN
in the second stage
Something like a primitive Lexer that can have more concrete lexers in connection with a parser on top of it, if that makes any sense?! ๐คทโโ๏ธ ๐ค
Also, I would, for example, in the first stage tokenize + etc as PLUS or SPECIAL because at this stage the Lexer wouldn't know if it's in a mathematical context
Anyways, I'll just continue experimenting, thx for your Inputs!
It works!
Thank you so much!
woot
either way, how do i get movement in local space? nothing seems to be working, kinematic or not
hey, i'm having troubles with converting my mouse position the mesh vertex in the world
i'm not sure why but it has a small offset to the real world
private void Update()
{
if(Input.GetMouseButton(0))
{
Vector2 mousePos = Input.mousePosition;
Vector3 worldMousePos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, cam.nearClipPlane ));
mapGen.Dig(worldMousePos, digRadius);
}
public void Dig (Vector3 mousePos,int brushRange)
{
int digX = Mathf.RoundToInt(mousePos.x* mapDetail);
int digY =Mathf.RoundToInt(mousePos.y* mapDetail);
test.transform.position = new Vector2(digX, digY);
if (digX>=0&&digX<width*map.Count-1&&digY >= 0 && digY< height*map.Count-1)
{
int _chunkIndex =Mathf.FloorToInt(digX / width);
Vector2 _chunkPos =new Vector2( _chunkIndex*(width-1)*(1/mapDetail),0);
for(int i=0;i<brushRange;i++)
{
for (int j = 0; j < brushRange; j++)
{
if((digX - _chunkIndex * width - 1 + i)>=0 &&(digY + 1 - j)>=0&& (digX - _chunkIndex * width - 1 + i) < width && (digY + 1 - j) <height)
{
map[_chunkIndex][digX - _chunkIndex * width - 1 + i, digY + 1 - j] = 0;
}
}
}
UpdateMesh(_chunkIndex,_chunkPos,meshGen[_chunkIndex]);
}
}
what happens is that when my player camera is at world origin, the vertex index that i get from digX and digY is correct, but the further i go to the right in the world , the bigger the gap between my mouse and the vertex index is
idk what a mesh vertex even is
Is your camera set to orthographic?
yep it is
actually, kinematic does work. but is that the only way
i only want to apply a local force
so tha means i have to produce a clone of unity's physics engine just to apply a force in local space?
that sounds extremely inefficient
the meaning of local space as in transforms versus local space as in physics are different
the former isn't going to help you with the latter
try spelling out the exact rules of what you want to do, in plain english, and it'll be apparent that to program it, you will not be using information about the transforms most of the time
making a clone of unity's physics just to make gravity in local space seems extremely inefficient
i'll make some mockup in Blender
i wouldn't use this word local space
i know what you want to do
just in terms of turning it into programmable rules you have to write it out
getting better at this stuff means using words
so for example, from that video
the rules are: when an object enters this bounding region, it experiences a force opposite of the normal of some ground plane "A" in it. when it is stationary against that ground plane, it continues to experience that force "A". when something collides with it, it stops experiencing force "A".
do you see how that doesn't really have anything to do with local space or transforms?
it's an illusion, based on the sequence of things that really happened, of "local physics"
wait are you saying its fake
so i do have to produce a clone of unity's physics engine just to add a single attribute
Man
no...
it's not a clone of unity's physics engine
i think it comes down to understand what it means for something to be "attached" to something else in real physical terms
it will help you understand that doing what is in your image
requires calculating a force / change in velocity to create the illusion of something being "attached"
and nothing else
ik how that is done
ive done it around 3 times over and it hasnt worked
in the real world, you would achieve that illusion using a rigid object / attachment like a nail
the only time its worked has been with using kinemtics
right which is why you probably should get the asset
which i shouldnt have to do
and by "using kinematics" i mean writing a physics engine with that one extra attribute
which sounds extremely inefiicient
okay i think you'll figure it out ๐
you should watch this guillermo del toro short called Geometria
you remind me a lot of the kid in that movie
lol
accel seems to worrk correctly for first 2 timesteps, then breaks at 3rd timestep.
seems proportional to rotation of parent (rotation spd increased from 1 -> 5)
and ofc when rotation spd is 360, it does not break
What are you trying to do?
Why not just use AddRelativeForce?
i just tried ordering scripts
this did not work
ive tried that
what i get is this
You did it wrong then
almost as if its adding to the previous force in world space
Yes forces are in world space
is there a way to get them to translate to local space for calculation
Unless you use AddRelativeForce then it's in the local space of the body
its only in the local space of the body at the instance its added
then it translates to world space
I don't understand what you mean
Can you explain what you're doing
Your picture is unclear
if you add a force in local space/world space, it translates to world space, calculated in local space or not
im trying to do https://youtu.be/1UqEHrXva0U
Hey guys!
Just a quick demo of the Local Physics grid using my Aurora MR
Most of the commentary will be in the annotations for this one!
Want to become a Star Citizen?
Enlist now! - https://www.robertsspaceindustries.com/enlist?referral=STAR-RN46-L2CJ
STAR-RN46-L2CJ - Use My Referral Code for 5000 Bonus UEC
System Specs
Intel Core i7 4790K...
forces calculated in local space
stay in local space
You'd have to use multi scene physics or something
https://youtu.be/mFzPIw_nsYc this person apparently managed to acheive this without having to set the cubes as kinematic objects
Quick tech demo of simple localized physics grid technology running in Unity 5.
To separate the two physics simulatons
but how
This
Or use a custom physics engine
ive only seen physics scenes used to predict paths of objects, not to achieve different physics simulations in the same timestep
It can be used for all kinds of things
Yes this means to create a physics scene
That's how you use multi scene physics
ok but where doi start
When you do difficult and unusual things sometimes you have to blaze your own trail
Hey Guys, so i have a MAJOR game breaking problem with my automated system.
Essentially I have a system which chooses targets based on meeting a condition, and when your characters bar is full (read: ATB Bar), it performs the aciton on the target.
Now I started to implementing dying and reviving which removes/adds from the dead/alive list. It seems to be that the problem is that, in the course of someone being revived/died AFTER the vondition check for the action is performed, suddenly now the target is null and i hit the red error
Anyone know what I should do?
for context its a JRPG game system and each character ha this automated mode, so i think because theyre all separate, its causing the system break
I guess you're destroying the object when they die and reinstating it?
But idk you really need to examine which line the error is on and figure out which thing is null
its the chosen target
It's the same as any NRE
so heres the check
Basically, in the first screenshot, you can see the TryTacticTargets(i), which finds which enemy is eligible for the action, then if your bar is full, do it, otherwise you go to the elseif() stuff. the break is at the elseif, where the ChosenTarget is null
i think its because theres a couple of instances (player heroes) doing this and someone is either dying/reviving and being removed from that list which checks target eligibility so by the time you get to the elseif(), the guy essentially vanished
so trying to figure out how to resolve it. like do i do the check later or something?
I am having a problem with rigidbody2d gravity physics being super slow.
the camera size is set to a massive number. this makes the camera huge. a normal sized sprite is basically invisible on the camera so all the sprites are also huge. for some reason this causes gravity to be incredibly slow as the sprites have to cover a much larger distance as the ground is in terms of unity distance much further away
I am not allowed to change the size of the sprites or the camera size which is scaled dynamically based on the screen size. So I need a way to dynamically compensate for the large and changing scale of the scene which is dynamically generated from the scripts to make gravity work properly
i cant change either the sprites or the camera size, i need a way to compensate by changing the units of the scene or scale the gravity of the scene in a consistent way
Why can't you change them
not my part of the project, don't have permission
What's not your part of the project
the way the camera stuff and art works
Also if that's the case, you talk to the person whose job is that part of the project
Anyway surely you can change the import settings of the sprites
You don't have to change the images themselves
don't have time to change all that and a lot of things are dependent on it so i just need a physics based solution
the camera is required to be based on the screen height
so the sprites have to be the size they are
It would be so much easier and faster to change the sprite import settings than some insane gravity manipulation code
it would. but i can't
which i already stated
right now i am just setting the physics2d.gravity to -9.81f * screenHeight/4 to compensate because that is not really the solution i want
It needs to be dynamically generated, as it needs allow for mods to add new research with ease.
Yes, it's unfeasible to manually build the layout as I cannot be certain which nodes it contains.
Does anyone know how to compensate for my camera being scaled by the screen resolution as it breaks all velocity and gravity physics and my raycasts dont reach the right distances either? is there a way to make the world points scale with the camera?
How to change the gravity of my scene?
Not an advanced question
Not a code question
This can be done from the physics settings
What's the type of scenePredictionPhysics
for a new physics scene
PhysicsScene
how to change g
You have the answer in this screenshot, but that's for an entire scene
for 1 physics scene
I don't think it's possible
If these are not present in the docs, they're either read-only or not accessible, or not defined
https://docs.unity3d.com/ScriptReference/SceneManagement.LocalPhysicsMode.Physics3D.html u see this but how tto implement this
I don't know
Read what it says
how to parent scene to game objet
What?
what?
afaik you cant. gameobjects are present under their respective scenes. not the other way around
then how am i supposed to make a physics scene local to a gameobject
How feasible is to make a script that would export everything inside a Unity scene as Unitypackage at runtime?
I was thinking about hiering a freelancer for that.
do not crosspost #854851968446365696
yeah, my bad just didn't know where to ask here or code-beginner channel
I need a roadmap to be a professional unity developer, instead of just watching random youtube tutorials for years now
roadmap: get a job in the games industry
do not crosspost? ๐
applies to questions, not answers
do you knwo hp local physics
so i read about physics scenes
thy are used to separate physics simulations which isnt rly what im looking for
im looking for an option to make some of Physics attributes shuch as gravity local
or rotate a physics scene
idk
So. Say I had books in my game that has text and pictures. What would be the simplest way to display the book in-game? Is there a markdown plugin that allows images? Or should the books just be an HTML document that is opened using some sort of in-game browser which iirc exists
ui textfields and images?
Well Iโd have to parse the document and automatically create those and that sounds like a pain and error prone
Separate physics simulatons is exactly what you want
ik but i have no idea how to use it
You're hoping for a quick and dirty solution, but it doesn't exist
ik one way but you dont even need a physics scene for it
it involves using a proxy platform to calculate physics
you can do that without a physics scene, you just have to make sure the proxy system cannot interact with the master, which you can easily do by separating the rigidbodies from the master to use as proxy
local gravity, make a boxcollider and invert the gravity / etc of anything inside the collider
well you're gonna have to parse it regardless of the solution
He wants not just local gravity but local momentum etc
It's not tenable with the basic system
tfuq does local momentum mean?
It means if you shake the snow globe, it doesn't affect the snow insidy
ye
Two totally separate simulations
ive got physics scenes spawning, but how do i rotat them?
you could just negate the values applied to the snow and then there's no need for local momentum
ok but how do i rotate it
I may be wrong, I didn't mess around with PhysicsScenes, but I'd say you can't rotate it, a Scene doesn't have a position or rotation by itself, it's contents have positions/rotations.
That's my guess, i don't know if it's correct.
You could google for "Unity3D rotate PhysicsScene" or take a look at the Documentation if that functionality exists
so then how a i sposed to utilise it in this cade
ive been on this case of physics scenes for a few hours now
i havent seen anything of the sort
๐ค
To utilize what exactly?
What's your end goal? Besides a different gravity value?
a separate physics system with an origin that is local to a game object
Hey guys!
Just a quick demo of the Local Physics grid using my Aurora MR
Most of the commentary will be in the annotations for this one!
Want to become a Star Citizen?
Enlist now! - https://www.robertsspaceindustries.com/enlist?referral=STAR-RN46-L2CJ
STAR-RN46-L2CJ - Use My Referral Code for 5000 Bonus UEC
System Specs
Intel Core i7 4790K...
i dont see why this is so difficult to implement
@sly grove doyou have any ideas
As said, I didn't mess around with PhysicsScenes/Systems before, but I doubt that a "Physics System" has an origin, it will have Colliders and/or PhysicsBodies which themselves have origins/position etc
I'm happy if anyone can correct my thoughts and I can learn something!
default gravity is global not just for individual scenes but for entire projects
so ig there is nothing i can do about that
Did you try googling "Unity3D Custom Physics System"? Pretty sure you did, but still asking, I'm getting curious about this topic
yes
If you're not working with additive scenes, you can have a component in each scene that'll change gravity on loaded/unloaded
i was just wondering if that was the only way
custom physics seems to be the only way
it just seems extremely inefficient
i mean think about it
a clone of unity's physics engine, just to some make some of its attributes local
If you're not working with additive scenes, it's pretty straight forward, no need to "clone Unity's physics engine", just a simple assignment to a property when scene is loaded/unloaded
physics scenes dont seem to offer anything that could possibly help solve the issue
other than being slightly more organised
the only thing ive seen physics scenes used for it
- predicting physics
- rigidbody collision groups
nothing to do with local gravity/momentum
wdym?
I still don't know if I so understand your end goal or why you're wanting to have a different physics system, but, again, let's say you're always having a single scene loaded, not multiple ones
i sent a video of the effect um trying toa cheive
Quick tech demo of simple localized physics grid technology running in Unity 5.
You'd just have
Physics.gravity = customGravity in your Awake and Physics.gravity = defaultGravity in OnDestroy
Ah ok, i think I get it
Looks like you just want your gravity to be another direction
a physics subscene
that can be translated in a scene
without any effect on the object inside the subscene
the issue is that i dont know hwo to trnasform a subscene
That's pretty well manageable by setting Physics.gravity i think, but you'd have to handle the upwards direction of affected GameObjects yourself ๐ค
Anyways, I'm just continuing to make guesses without real knowledge of the subject, I'll stop cluttering this channel and hope that somebody with actual experience can guide you
a subscene is not even transformable
gravity is global to all subscenes
why is this niche so underdevloped
not just in unity
in most game engines
I mean is it not as simple as having a trigger area, and OnTriggerEnter make gravity a high number, OnTriggerExit make it a lower number?
That's what I got from that video, it's just a trigger area where you'd set gravity higher on an object inside it
That's what you need. Ditch the Unity gravity and make your own on all objects. I've done so on my player to be able to walk sideways on walls if I please.
hmmm...
Anyone's unity hard freeze if you compile code while the visual studio debugger is attached?
i dont want to apply custom gravity
more like
i want to transform a physics group of objects without the objects being affected by the transformations
would someone mind going into a screenshare or something and helping me spawn the food objects at the start of the game? because they spawn each time someone joins https://cdn.discordapp.com/attachments/497874004401586176/952619455362519170/2022-03-13_17-27-58.mp4
hi hmm anyone know, how in PropertyDrawer to get a values from List, example for int i can do property.FindPropertyRelative("MagicNumber").intValue;
property.FindPropertyRelative("IntList").GetArrayElementAtIndex(index).intValue
this is ridiculous
im not buying it
im not going to use a kinematic physics engine just to make a single attribute local
until ive exhausted all other possible options
@sly grove PhysicsScene can separate simulations but it cannot produce local simulations
im pretty sure
apply your imagination to this... local physics simulation is perfectly achievable with it. But like most things in game development, you might have to use a little smoke/mirrors to achieve it. It's not going to just work out of the box how you want. You may need to simulate the physics "elsewhere" and apply the simulation results from "elsewhere" to the local motion of the objects in your ship for example
ik that method
the Proxy method
yes
thats the particular method im trying to avoid
that's how i'd approach it
less efficient than what?
also
The nonexistent thing
so why are you here asking us if you know what to do
because i was wondering if it was possible to simulate local physics out of the box
clearly not
oof
well, physics scenes will help with organisation a ton
you can keep all the proxies in a single coordinate without them interacting with each other
but its still less efficient than flat out physics calculation
Man
hmm i want whole list not just 1 element, there is no get whole list
im not sure about the validity of this statement tho
"Proxies are less efficient than Physics Calculation"
only one way to find out
so can i somehow cast property.FindPropertyRelative("IntList"). to a List<strings> or something like that
cuz this way i have to reacreate new list by itering with GetArrayElementAtIndex(index).intValue
https://youtu.be/eQt7TwCr6ao?t=334 this is one of the biggest issues with proxies
Jittering caused by changing of physics calculation from global -> proxy
I finally decided to tackle some of the more complex issues I was having with multiplayer, and this is how it went...
Join the community on Discord: https://tomweiland.net/discord
Previous devlog: https://youtu.be/RmmLmc34O-U
Devlogs playlist: https://www.youtube.com/playlist?list=PLXkn83W0QkfmQI9lUzi--TxJaOFYIN7Q4
Further reading about client...
There's no other way
totaly wierd but ok at least it works
This is... mildly appropriate to the channel but does anyone know why the com.unity.nuget.newtonsoft-json package just doesn't work? It doesn't seem to add references to the solution and as a result does not compile
I just have a quick question. I'm just trying to press "D" and have unity Debug Log the letter "D", but it seems that depending on my framerate, Unity sometimes has a major delay or even skips the key press altogether. How can I mitigate this?
Basically I've got input lag. idk if it's an advanced issue or not, but this causes major problems like the player continuing to move when I let go of input
are you polling your input in FixedUpdate()?, what are you doing with the input immediately after polling it before the log happens?
It's in regular Update() and I've commented out everything aside from the Debug Log statement. I would post my code but it seems this server doesn't want me to
If I press D when the screen is small, it happens almost instantly. When I press it on Maximise play, it takes up to a full second or sometimes does nothing
#854851968446365696 on how to post code
that doesnt compile
where and how do you set STATE?
It's set in public and it's always set to 1. Nothing affects it currently
show code
What part of it?
all of it
that code does not produce any input lag
Yeah it doesn't seem like it should. But on my end it's lagging
you are probably looking for the source of the problem in the wrong place
this code only manifests the issue, it is probably completely unrelated to the cause of it
Any chance my computer is just too weak?
It's a Macbook Pro with a uh
1.4 GHz Quad-Core Intel Core i5 Processor
too weak for what?
you aren't doing anything yet from the looks of it.
what frame rate do you get in the editor in playmode?
Where do I see that? Is there a stats button?
Yeah I fluctuate in the 80s and 90s
In Maximise it drops to the 30s
I'm sure I can find out how to optimise this, even if I just have a corrupt OS or something - but really I just wanted to know if there was a way to reliably do input that isn't affected by framerate. Because even if it runs well on my system I don't want the game literally glitching up at low framerates
nvm disregard I'll stagger into the winds and figure this out on my own after I take a walk
@sly grove yh so after a while i finaly done it
it is messing with the velocity attributes a little but thats expected
Hey does anyone know how I can fully restart my game? If I just do SceneManager.LoadScene(0); it will unload all active scenes and load my title screen... but when I load back into the other scenes, everything is broken, because serialized references in all my scripts are pointing to the old destroyed references from the unloaded scenes.
I tried manually unloading scenes with SceneManager.UnloadSceneAsync(scene, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects); but this did not solve the issue. I am stumped here, and every single google answer is the simple LoadScene method
How do I have multiple projects share code? Do I make my own package and host it somewhere?
@jovial totem put it on github as a private package. you can develop it with a file:../Sibling-Directory path and change it to a git:... path when it's in good shape
- don't use scenes
- centralize your state in one place
wat. how do you make a large game and not use scenes
use prefabs instead of scenes
nested prefabs have obsoleted scenes for all but extremely few cases
first I've ever heard of this
ok... does anyone else say this, or is it just you?
in 2022, with the industrial and publisher game development shops i know, they don't use scenes
also, how are you supposed to do operations that rely on objects being finished loading in a prefab?
with scenes, you can subscribe to SceneManager.SceneLoaded
you can use scenes or addressables for the narrow purpose of loading prefabs, but i wouldn't organize my game logically around them
besides, there's no game anyone is developing here that needs loading
only stuff that 100% will always be glitchy because it's too big for any computer, or 100% too small to matter
Ive managed to iron out all bugs to do with scenes so far. This restarting thing is the first I've run in to that I cant figure out
thats a lot of people's experience
"I do XYZ... and now W doesn't work at all with scenes"
it was never viable to rely on scenes to restart your game
nor to organize it from menus to levels or whatever
yea, I dont believe that
considering you're the only person i've ever heard this opinion from
I'm sure every game I made needs loading, I'm just too lazy to make a loading screen for them
No idea what this means. Is this a NuGet thing?
read up the docs on packages. you can add local file system references and git references
anyway, think critically if there's really loading in your game. like everything could just be loaded up front
I have gone through that thought process already, and no, I cannot load everything up front
there are*
try building to standalone player
and see what happens
Yeah idk what the issue is. I mean, my disk is kind of full - I've only got 9 GB left of storage on it
But doesn't this mean that if someone has a slow computer, the game will glitch up when they try to play it? In most games I play, the game simply lags. But here, it's like only the input is lagging, and that's causing major issues
It might be not the input that lags, but the debug.log itself, try making a text on screen and change the text based on your input
unfortunately rakyat, I've already tried other things with this. Originally the "D" made the character move, which was lagging. The Debug was just to confirm this
also, iirc there's a setting in macbook called "Slowkey" or something that delay the input, you might want to check it out if it's enabled
been a while since I had my hand on mac, but from google :
https://support.apple.com/guide/mac-help/change-your-keyboards-response-speed-mchlp2264/mac
On your Mac, slow the response time between when a key is pressed and when your Mac accepts the keystroke.
i think it's a red herring and your code is buggy
Alright that wasn't the issue but thanks for letting me know about that because that was kind of funny
maybe start with a fps example
like use an example project or an asset
or whatever it is you want to do
I'm almost positive it's a performance issue, because another person on this forum confirmed there was nothing wrong with my code and the response time gets faster and slower when I'm in maximise mode or not
but really I just wanted to know if there was a way to reliably do input that isn't affected by framerate. Because even if it runs well on my system I don't want the game literally glitching up at low framerates
you can just disable the camera, and have it updating at desired rate using Camera.Render();
yes but how can we help you with that
try a different project for now, see if anything opens on your computer
I'll do that
Yeah my hardware must be messed up or something. I made a new unity project with a scene that doesn't even have a camera in it- just an empty game object with this script attached to it:
https://gdl.space/erezogihep.cpp
And I'm still getting a little bit of lag
And its URP
ok, got that. But how can I get Unity to compile it?
Hey, can somebody enlighten me? I'm in a very weird situation with the Substring method.
I am extracting tokens out of a text. When there is only a single token in that text, Substring works fine, but any further calls throws me an ArgumentOutOfRangeException for unknown reason. I am definitely not mutating the string throughout my process.
I've tested with
Debug.Log(end <= text.Length);
var substring = text.Substring(0, end);
The Debug.Log gives me true in the Console Window, but the method call is still throwing an AOOR ๐ค
I can almost guarantee the error isn't on my side of the code, i have written my own GetSubstring method with 6 lines of code, passing it the same values as the original one, and it works perfectly, and I'm fine with using that instead, but I'm still curious to why that Exception would be thrown
Any ideas?
Easily setup GPU instancing / material property blocks to optimize your batches and draw calls
Availalbe at: http://u3d.as/1qXC
I want to do whatever this video does
It explains what the code does quite clearly but it doesn't give any hint on how to code it
Can someone guide me to some tutorial that's on the same topic?
i.e. changing colors of the same objects via shader, with the help of GPU instancing, making it possible that all same meshes w/ different colors can be drawn in one batch
Show the actual line of code throwing the exception, and ideally the surrounding code. Also print the length of the string and end
Hey guys is it true that you cant serialize references to scriptable objects?
If so how does the engine do it when you assign them from the inspector?
unity will correctly compile the source in the referenced package. you don't have to make a precompiled assembly
it works like all the other unity packages
serialize in the sense of JSONUtility.ToJson?
๐จ Binary Formatter Alarm ๐จ
use the shader graph instance id node https://docs.unity3d.com/Packages/com.unity.shadergraph@12.0/manual/Instance-ID-Node.html
Haha i got the warning last week lol
vary the color based on this node
That JSON would be safer if the data structures were redefined
Unity uses YAML, and its serializer doesn't behave like other serializers you'll see
Hmm I take it this means that I can't do this just because Unity does it ๐ฆ
purely because it's got awareness of the C++ side of the engine that nothing else can see
Ahh
sounds pretty radioactive.
Yes. If you want to serialize something for runtime you probably should avoid Unity Object types
So say I want to store a list of starting units for the sake of saving a game and my units are defined by scriptable objects. Is my only option to store a list of those SO somewhere and serialize an index?
if you've been at this for a week at this stage write the save file exactly as you need it
if you need an X to later read an X, write it however is intuitive to you. then, if you need field X.Y, write field X.Y
in an hour everything will work because your game isn't complicated enough to benefit from generic serialization
even if you had 100 fields to deal with it'll take you 5 minutes to write the serialization and deserialization code
and maybe a total of an hour over the lifetime of the game to maintain it
Yeah but I imagine there are risks here if those scriptable objects change
your choices are thing that doesn't work versus thing that does
so what if they change
big deal. you know how to deal with it
just roll with it
it'll add up to an infinitesimally small amount of time
Wdym? You'd have different values for the units that were loaded from the save and the ones that were created at runtime
binary formatter won't work in that situation anyway
you need to TextWriter.WriteLine at this stage, or create a "data transfer object" (the correct answer)
create a "plain old csharp" class that works with JSONUtility to represent the save file
then copy the data you need to save into that class instance
write it to a file using JSONUtility.ToJSON
later, to load the save, use JSONUtility.FromJSON
then copy fields / objects from that simple class into your scriptable objects or whatever you have going on in your game
does that make sense? @alpine kindle
Yeah but it's not really the issue I'm having, the BinaryFormater works in general it's specifically these scriptable objects that I need a solution for. I would have the same issue with text serialization
i think you'll figure it out ๐
Yeah worst comes to worst i'll just go with the list. I feel like this is smt Unity should have a solution for though
Thatโs what I thought but it said that it canโt compile anything if itโs not in /Assets
hmm it will compile
oh, i guess I need to make an asmdef file? ill figure out how to do that. Also, can I make unity make a csproj file for me so I can use Omnisharp
you have to reference a package in manifest.json
for it to compile
carefully read the docs there
Packages do need assembly definitions too
you will need to create a package.json in the com.... directory
yes it's all in the docs
"com.slashscreen.openworldcommon": "file:S:/LocalunityPackages/OpenWorldCommon", I did thoyugh
you'll figure it out!
carefully read the docs
oh, do I have to name the file com.slashscreen.openworldcommon
it expects a version if you put the contents in a Packages folder
folder*
This was done by the package manager
hm
{
"name": "com.slashscreen.openworldcommon",
"version" : "1.0.0"
}
I did this
I did all the steps in Creating a new local package here: https://docs.unity3d.com/Manual/CustomPackages.html
maybe im reading the wrong thing. Which docs?
I'm playing around and trying to learn about GPU instancing. Here I have a scene where I generate 10,000 balls in the scene, and for every 0.5 seconds, I randomize every ball's color.
Could someone explain to me, why is it slower when I tick the box before "Enable GPU Instancing" in this case?
not that im an expert, maybe the random function? is it on the CPU?
alright, i made an asmdef and now it's giving me compiler errors which is good. Now I have to figure out how to get Omnisharp to work
next question: how can I include a dependency for my package that is a package that is added to Assets so it isn't included in the manifest? Im trying to use YamlDotNet
There are requirements for gpu-instancing, you should read up a lot about this topic if you want to go this route...
Also note, srp-batcher hates gpu-instancing...
quite a broad of a topic, so yeah, you must do your own research on this
Hey, I am looking to change the processor of on a binding in an InputAction, in an InputActionMap
one of these classes must have a method for changing the processors at runtime... anyone know where?
oh wait, maybe I can write a custom processor
you should be using shader graph and URP/HDRP
not the legacy render pipeline
use the geometry index i talked about...
if you want to render 10,000 multicolored balls used vfx graph
omfg I think I finally fixed this issue
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
InputActionMap playerMap = inputActions.FindActionMap("Player");
InputAction ui_Navigate = playerMap?.FindAction("UI_Navigate");
InputBinding leftStickWebGLOverride = ui_Navigate.bindings[0];
leftStickWebGLOverride.overrideProcessors = "invertVector2(invertX=false,invertY=true)";
ui_Navigate.ApplyBindingOverride(0, leftStickWebGLOverride);
}```
might be a cleaner way to do this, but this works so...
also fixed my issue of references breaking on scene reloads.... turns out it was entirely due to static reference and events not being cleared. I changed a bunch of things that were unnecessarily static to non-static, and made sure to null out all my events OnDisable or OnDestroy
How are you changing the colors of those balls? MaterialPropertyBlock?
i think there are only 3 possibilities: material instantiating, MaterialPropertyBlock, or change the colors with screen position node (like a plane that looks like colored balls using vertex deformation/normal map, or a lot of balls sharing the same material)