#archived-code-advanced
1 messages · Page 197 of 1
yeah Odin makes dealing with serialized interfaces a lot easier
I just cant go back to normal unity without it
at very least NaughtAttributes has to be in the project
the question is: why.
why have IFireRate at all
you can use an abstract base class inheriting from behaviour. then attach it to a gun prefab
if you read the prior convesation, obviously IFireRate is very simplistic, and not necessary if you just want a float, but having compositional design of something and each component "socket" having generic behavior, and being able to compose that from the script level is what the purpose is
you already have composition, it's a prefab
when using the editor for storing data, they get in the way
Anyone know a good resource for learning about Rotation matrixes (or matrices?)?
Trying to learn how to rotate 3D vectors mathematically using linear algebra
interesting.
hey is it possible to make a Raycast continue if it hit a certain target ?
for example If the raycast hit a player, i want it do some impact animations on the hitpoint but also keep going, what is the best way to do that ?
RaycastAll, order by distance, loop over the results and break if you deem that something is not traversable
Use a loop. Fire a new raycast from the hit point continuing in the same direction.
You could also just do a RaycastAll and do something for each hit
I am officially invisible it seems
(note that a sorting is required as RaycastAll results are in an undefined order)
Only if order matters for this use case 😛
Something like that ?
public Transform source;
RaycastHit hit;
if (Physics.Raycast(source.position, source.transform.up, out hit, maxRange))
{
if(hit.transform.GetComponent<Player>())
{
// do some hit impact and health damage to the first player
RaycastHit hit2;
if (Physics.Raycast(hit.transform.position, hit.transform.up, out hit2, 500f))
{
if(hit2.transform.GetComponent<Player>())
{
// do some hit impact and health damage to the SECOND player
}
}
}
}
I'm not sure if hit.transform.up would be the right direction; not sure if it would be the same as source.transform.up
If your limit is 2, then yeah, otherwise you might need iteration or recursion
Using a loop if you want to do it more than twice
lol I am indeed invisible
and no it'd be the same direction vector
Or blocked
Not blocked, reactions pass
As for the direction, I would store the original direction in a variable, and pass it for each new raycast
That way it can easily be adapted if you use a loop or recursive methods
ok thank you guys!! @sly grove @fresh salmon
I had the similar mind at the beginning but I was skeptical as i'm not an expert and maybe there is a better way to do it
if the damage and impact stuff is the same for each player it hits - it looks like you can just do a RaycastAll and iterate over all the hits, applying the same impact and damage for each one. No ordering is required.
Very interesting idea!!, Thank you!
but yea I'd need the order as the damage should decrese after the first impact 🙂
How efficient is the IPointerDownHandler & IPointerUpHandler When there's atleast 80+ objects that implement those interfaces? Is it less efficient than just getting where the mouse was clicked and mathing out if that point is on an ui element?
My scenario is that I have a grid of tiles that all need to be "clickable" but that they need to know about when the pointer is down on them or up.
very efficient.
More efficient than just doing the calculations of where the mouse was clicked myself?
Hard to say.
You could do the calculations for a simple 2D grid very fast compared to the general purpose interval-tree or quad-tree they probably use. but Unity's code is also running on the native C++ side so it has that advantage.
The benefits of working within the event system are many though, so I'd just stick with IPointerDownHandler etc...
if you notice a performance issue, you can revisit it.
Right, thanks a bunch!
Does anyone here uses Ryan Hipple approach for Game Architecture using ScriptableObjects the same way?
Anyone ? Can't make it work correctly. I've probably made some mistakes while porting this to C# but can't figure it out
hey guys i tried to run a unity x86 (not x86 64) build headless server on a windows 2003 server but got .exe is not a valid Win32 application (the server have .net framework installed) any tips i'm missing or just isn't compatible
that seems like a pretty extreme use case and I'm assuming there's a bunch of waaaay out of date .NET stuff that possibly can't be updated even if you include newer .NET assemblies
yep but in player settings say .net 2.0 that is even older...
I'm trying to use these two packages together in my Unity project:
https://github.com/oshoham/UnityGoogleStreamingSpeechToText
https://github.com/YarnSpinnerTool/YarnSpinner-Unity
Unfortunately, both have the dll file Google.Protobuf.dll, and Unity requires that there be only one of a dll file present. I've tried renaming, however, due to the different versions between the two packages of this file, they throw a weird versioning error:
The type 'ByteString' exists in both 'Google.Protobuf, Version=3.8.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604' and 'Google.Protobuf, Version=3.15.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'
I've also tried overriding references AND renaming the files for both assembly definitions but to no avail.
Do you know of any way I can use these two packages?
decide which one you'll use, and disable the other one in the editor (made sure all platforms unchecked)
Looking for the big brains.
I have a BigDecimal class for an idle game with two members, a decimal Mantissa and int Exponent. The Mantissa must be between 1 (inclusive) and 1000 (exclusive) and the Exponent must be a non-negative multiple of 3.
I've overloaded operator* (multiply) and operator^(BigDecimal left, int right) (raise to the power).
It's not fast. I have a need to do this every frame in my client. Any obvious optimizations?
Alternatively, any strategies for profiling this? I'm not an expert in profiling.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The code in question that's slow:
private const double ManualTapCostStartingA = 50; // Cost to upgrade level 0 to 1
private const double ManualTapCostR = 1.5;
public static BigDecimal GetManualTapUpgradeCost(int currentLevel, double reductionPercent = 1) => (((BigDecimal)ManualTapCostR) ^ currentLevel) * ManualTapCostStartingA * reductionPercent;
Hm, OK, nevermind entirely, problem is elsewhere in the code. The above still runs millions of times in a second no problem
Is there a way to standardize the size of different models to make them all the same size ?
I have the player upload various 3d models and I want to make them all the same size
you can take their bounds, and scale the model so the bounds fit into the same size...
but you need to define, what is 'the same size' first. Should a mouse have the same size as an elephant?
is there a way to uniformly generate random points inside a sphere in HLSL?
AKA Unity.Mathematics, due to the similarities
I can't use UnityEngine.Random
How can I get IAsyncEnumerable? One of my packages requires it and I was wondering if there was any way to get support for it without rewriting the package
This forum thread didn't help https://forum.unity.com/threads/wheres-iasyncenumerable-t.1246822/
that does not guarantee it would run on separate thread, if running on a thread is your intention... unless you do context switching...
if you want to await but still running on a separate thread you can do this instead
var a = await Task.Run(() =>
{
//do your thing
});
you may need to ConfigureAwait(true) so it would switch back to the mainthread once done or else your game will freeze
if you never dealt with multi-threading, you need to learn this carefully, I agree that your use case is very suitable for that
second method without configureawait but requires custom thread dispatching
var a = await Task.Run(() =>
{
//do your thing
//Operation end, dispatching
MyCustomDispatcher(()=>
{
});
});
due to some constraints with configureawait, it may not always work for all use cases, thus you need your own thread-dispatcher
take a look at https://github.com/clemensmanert/fas
C++ has templates that accept numbers, so that's how i knew there'd be an arbitrary floating point library compatible with your choice of mantissa and exponent sizes
do you mean uniform for real, or gaussian?
@turbid tinsel use voronoi in 3d and reject points greater than a certain distance away
unitask already has simple things for this
just waiting for a webrequest UniTask is just too much imho...
but that's an option too, yeah
also UniTask has the same restrictions as ValueTask.. I'm not sure how would you consume the task if the request hasn't been completed yet and you or users want to cancel it as GetAwaiter().GetResult() would throw... at least it won't in net 6
can somebody please help me with random level generation?
looks cool
well you're very close
i think the inside of the rooms looks nice
oh yeah
i'm not sure why you would have this sort of off by one error
you are probably mixing up your x's and y's in a for loop
that goes through the grid of rooms
wouldn't know yet
i dont use a for loop :|||
set your runtime to netstandard2
yikers
yeah
so that i can smack a "jank" emoji on it
i see you have not ascended
oh
uh
i have spawner objects on each of the rooms
(top right bottom left.)
and i spawn a room
to make sure multiple rooms dont spawn on eachother
i have a trigger on each room
and a box collider on the spawn script (and rb2d kinematic)
and destroy and thing
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RoomSpawner : MonoBehaviour
{
public GameObject[] rooms;
public string destroyTag = "RoomSpawnedHere";
private void Start() {
Invoke("CreateRoom", 0.1f);
}
private void CreateRoom() {
GameObject grid = FindObjectOfType<Grid>().gameObject;
if(grid.GetComponent<RoomList>().roomList.Count >= 20)
return;
int rand = Random.Range(0,rooms.Length);
Transform newRoom = Instantiate(rooms[rand], transform.position + transform.parent.position, Quaternion.identity, grid.transform).transform;
// Transform newRoom = Instantiate(rooms[rand], grid.transform, true).transform;
grid.GetComponent<RoomList>().roomList.Add(newRoom.gameObject);
Destroy(gameObject);
}
private void OnTriggerEnter2D(Collider2D other) {
if(other.gameObject.CompareTag(destroyTag)) {
Destroy(gameObject);
}
}
}
but ometime i get thing like thi
i think you're in a good place and you'll figure this out
the issue is in your instantiate line
oh yeah
i couldnt figure out how to get the pos right with the parent and spawn point pos
probably should've mentioned that...
well this is... better
but still have unreachable rooms
How do I do that? Can't seem to find an option in Player settings
nvm figured it out. Didn't work
IAsyncEnumerable is in System.Collections.Generic
so i don't know. it's available in unity
This is the error I'm getting
Error: Could not load signature of Google.LongRunning.OperationsClient:ListOperationsAsync due to: Could not resolve type with token 01000037 (from typeref, class/assembly System.Collections.Generic.IAsyncEnumerable`1, Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51) assembly:Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.IAsyncEnumerable`1 member:(null) signature:<none>
what is your app/game?
it looks like you're trying to use a google cloud api library
or is this firebase for unity?
This has to do with two packages in my game. They both have the same DLL file on different versions. I went into one of the packages and manually updated to be the same version as the other package, but now I get this error.
I'm attempting to use Google's Speech to Text API, correct
ive fixed the instantiate line… mostly it works now but there are a few bugs… can you help?
remove all copies of Microsoft.Bcl.AsyncInterfaces.dll (or whatever it may be called)
late versions of unity use netstandard21
and do not need it
how did you get these nuget packages into your game?
don't say the nugetforunity package
lmao that crashed unity
oh hell no
i just downloaded the DLL files
from nuget
you manually went through and picked out all the dependencies one by one?
yeah 😅
it looks like you accidentally grabbed netstandard2
if you want to do this correctly you can
create a separate solution with dotnet
target netstandard21
add the package references
then dotnet publish and grab all the dlls from there
it will choose the correct ones for you
hmm
i've seen this error before and i resolved it how i described
but i only remember vaguely
It's saying it can't load Microsoft.Bcl.AsyncInterfaces
it shouldn't have a reference to it though
if it's netstandard 2.1
however, my code is netstandard 2.0... it just happens to not reference it
you can also try disabling assembly validation
i believe there is also some kind of workaround for having an assembly with that name
pangloss please hlep
that doesn't declare any types
well i've done nothing and you continue to make great progress
all i can do is gently reassure you, like how i do with my baby or cat sometimes
but idk why the heck some rooms arent reachable
heck indeed
:/
how did you spawn the rooms anyway? nvm, just need to look higher 😄
no really you're doing well
like it's so close
try to not use .parent anywhere
you don't need it
it's almost always a mistake
let me try a thing one sec
you need to deal with a "base case" the flaw is somewhere in doing the 1st room
i also sometimes reassure the chickens
reassuring intensifies
i am happy. i am a chicken, baby, and cat all at the same time
thats a pretty darn good feat if i donsay so myself
How can I do this with dotnet?
only seeing these options https://b.tixte.com/snap_cd39235f.png
… not sure why that one didnt work
but do you know why this one still gens those annoying unreachable rooms?
yeah
this is pretty painful
try editing the project file directly
and changing targetframework to netstandard2.1
So I'm trying to encapsulate "Actions" for my autobattler, so I can Move to a position, then cast a spell or something, etc. To encapsulate them, I'm trying to use generics, and just add Actions to a list to be executed sequentially afterward. I'm having trouble adding an object to the list though. Here's the definitions:
public abstract class PawnAction<T> where T : PawnActionParameters {
protected T _parameters;
protected PawnAction(T parameters) { _parameters = parameters; }
public abstract IEnumerator Execute();
}
public class PawnActionParameters { }
public class MoveAction : PawnAction<MoveActionParameters> {
public MoveAction(MoveActionParameters parameters) : base(parameters) { }
public override IEnumerator Execute() {
Debug.Log($"Moving to {_parameters.Position}");
yield return null;
}
}
public class MoveActionParameters : PawnActionParameters {
public Vector3 Position;
}
Usage:
private List<PawnAction<PawnActionParameters>> Actions;
...
MoveAction move = new MoveAction(new MoveActionParameters {Position = pos}); // pos is a Vector3
Actions.Add(move); // Error
Halp?
im not sure how to fix your problem…
but fyi when writing code snippets
after the ‘ ‘ ‘ add cs and a line
it will syntax highlight it
Visual Basic and C# have keywords that enable you to mark the generic type parameters of interfaces and delegates as covariant or contravariant.
A covariant type parameter is marked with the out keyword (Out keyword in Visual Basic). You can use a covariant type parameter as the return value of a method that belongs to an interface, or as the return type of a delegate. You cannot use a covariant type parameter as a generic type constraint for interface methods.
Note
If a method of an interface has a parameter that is a generic delegate type, a covariant type parameter of the interface type can be used to specify a contravariant type parameter of the delegate type.
A contravariant type parameter is marked with the in keyword (In keyword in Visual Basic). You can use a contravariant type parameter as the type of a parameter of a method that belongs to an interface, or as the type of a parameter of a delegate. You can use a contravariant type parameter as a generic type constraint for an interface method.
Only interface types and delegate types can have variant type parameters. An interface or delegate type can have both covariant and contravariant type parameters.
Visual Basic and C# do not allow you to violate the rules for using covariant and contravariant type parameters, or to add covariance and contravariance annotations to the type parameters of types other than interfaces and delegates.
For information and example code, see Variance in Generic Interfaces (C#) and Variance in Generic Interfaces (Visual Basic).```
https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance
Oh, been meaning to read up on these. Thanks
I think the solution is to make your PawnAction and interface and define T as out T
Thanks, will have to read up on this
yes i want every model to fit 1m cube
is there a bound just for mesh ? i was using the collider bound but when i add a box collider, the collider doesnt fit the mesh if the mesh have alot of children
You can use mesh.bounds I guess
Hey Guys, does anyone have experience with an event based state machine?
I have a state machine like this:
The state machine updates the state, the state does its actions and checks for transitions. The transitions have a decision which contains logic and return a bool, if the result is true it switches to the next state.
My Problem with this is that the state controller has all sorts of references, for example I put the state machine on an enemy.
My first state is a patrol state, in that state i want the action to be "Patrolling", which basically means find a waypoint, go to that waypoint and find a new one if one is reached.
public class Patrol : Action
{
public override void Act(StateController controller)
{
controller._Navigation.EnableNavigation();
if (controller._Navigation.ReachedDestination())
controller._Navigation.SetDestination(controller._Navigation.GetNewDestination());
}
}
You can see here that the state controller needs a reference to a navigation system "_Navigation".
My question is how would i decouple this? If i want to remove or replace the navigation system i will get all sorts of errors, plus i maybe want to put the state controller on something else, like an NPC which doesn't have a navigation system....
I'm having a hard time wrapping my head around implementing an event based system for this and would really appreciate if someone can give me a push in the right direction.
Dependency injection with interfaces the define the contract
Then if you want to change the navigation system you just create a wrapper around the new system that exposes the same contract as defined by your interface
So i have something like
public interface INavigationSystem
{
void SetDestination(Vector3 pos);
Vector3 GetNewDestination();
bool ReachedDestination();
}
public class EnemyNavigationSystem : INavigationSystem
{
public void SetDestination(Vector3 pos)
{
}
public Vector3 GetNewDestination()
{
}
public bool ReachedDestination()
{
}
}
and how would i inject this and where
If your Patrol state requires a type of Navigation system, it can be passed through the constructor when creating a new instance, or through a separate method that every State can inherit from I think
I don't see how that would decouple references. The states are ScriptableObjects, so they share all the same properties and functions and i can't pass anything through a constructor.
But even if i could. How would that look like?
public class StateController : MonoBehaviour
{
void CreateState()
{
INavigationSystem navigationSystem = GetComponent<INavigationSystem>();
State patrolState = new State(navigationSystem);
}
}
Like this the state controller is still dependend on a navigation system...
If i would let the state care about it's dependecies like:
public class State : ScriptableObject
{
public List<AI_Action> actions = new List<AI_Action>();
public List<Transition> transitions = new List<Transition>();
void GetReferences(StateController controller)
{
INavigationSystem navigationSystem = controller.GetComponent<INavigationSystem>();
}
public void UpdateState(StateController controller)
{
DoActions(controller);
CheckTransitions(controller);
}
private void DoActions(StateController controller)
{
}
private void CheckTransitions(StateController controller)
{
}
}
This will still produce errors when removed and it'll make the whole state machine way less modular.
Because now i have to either pass the navigation system to the actions and transitions or have a reference to the state on those...
Which than means I can't just simple swap actions in a state.
I'm spawning a big table of text items. This takes a long time.
Do you think the Job System would be able to speed this up?
As I understand it the Job System is not able to edit the Text.text anyways, so I would have to loop over it all again?
How would you speed up this spawning? (object pooling is slower)
Or how could I show the window first, and then start loading the list?
Also, deleting the window or moving the window around takes a long time, anyway I can speed that up?
Look into the new ui system, there are scroll lists which recycle items, so not every item is loaded at the same time and when you scroll the top items get placed at the bottom with the content replaced
What exactly should I search for? This sounds interesting.
if the mesh have many children meshes do i have to calculate mesh.bound for each one ?
thanks! 🙂
And for the sorting of the long list, is that achievable through the Job system? 🤔
sorting?
Yeah, I sort that list by Country, then City.
have you debugged just the sorting with StopWatch?
About a year ago, but I decided to postpone the perf improvements to when it made more sense to focus on that 😛
I should do it again, you think it won't affect that much?
Hey, Who have experience with VContainer? Can't understand how to Register factory.
Anyone here good with camera manipulation and bounds of objects? My game is built for portrait devices and I have the main game camera viewport rect offset to allow for space for some UI elements. I then grab the bounds of all the renderers in the game and adjust this for the viewport rect. And zoom the camera z position to show the entire scene…
foreach (Renderer render in il_renderers.OfType<MeshRenderer> ()) {
totalBounds.Encapsulate (render.bounds);
}
if (b_resetCamera) {
Vector3 viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
float c_yPos = Camera.main.transform.position.z;
yield return new WaitForEndOfFrame();
if (viewPos.x >= 0.125f) {
while (viewPos.x >= 0.125f) {
Camera.main.transform.position = new Vector3 (0.0f, 0.0f, c_yPos);
c_yPos += 0.5f;
viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
yield return null;
}
} else {
while (viewPos.x <= 0.125f) {
Camera.main.transform.position = new Vector3 (0.0f, 0.0f, c_yPos);
c_yPos -= 0.5f;
viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
yield return null;
}
}
}```
However the arbituary 0.125f used for portrait screens isn't correct for landscape - how can I ensure that all objects fit within the camera viewport and position the camera at that point?
As you can see as the game advances the 'cropping' gets worse!
Found this https://forum.unity.com/threads/fit-object-exactly-into-perspective-cameras-field-of-view-focus-the-object.496472/#post-3229700 which with a tweak or two, fixes the zooming and requires no lag for calculation!
Hey, I’m running into this issue that is preventing me from making a build of the game. since updating and trying to build I’ve been getting this popup prompting me to install unity 2019 etc, even though the unity version in the ProjectVersion.txt is up to date. Where is unity getting this idea from?
does a shader need something special (order or queue) to be able to read from depth texture?
because I want to read camera's depth for already rendered objects and terminate my raymarching at the depth
to make raymarched objects and regular geometry renderable at the same time
but SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.screenpos) seems to have no effect...
i'm not sure why that message is so strange. are you using source control?
can you roll back before your upgrade
did someone used sqlite4unity3d for android ?
you can use cinemachine to frame objects. set the target to a target group, and include all four objects in the target group
cinemachine will zoom or dolly the camera to fit all the objects
there is a depth prepass in hdrp for this purpose. are you using URP?
sorting a list of 4k items is going to be less than 1ms
on a typical machine
in the worst case
how are you rendering the text? is this UGUI? what is writing this table
text rendering performance in UGUI is very poor
it's probalby just as bad in UITK
then what do you suggest?
try an infinite scroll technique https://github.com/bugrahanakbulut/Unity-Infinite-Scroll
@nimble imp
Basically a self made ListView?
I'm considering it. I feel changing my project from GUI to the Toolkit may take some time.
Which are you using? UITK or UGUI?
UGUI
You can try OSA
From the App Store
But really you need to render the text in 1 pass, which is super hard
can't tmp be batched?
You can also put it on a different canvas
It’s that the scroll view is clipped
It gets composited
hm
Also each row is its own thing
I don’t know UGUI and likely UITK both suck at rendering tables
Of text
Do you have a link for that OSA, can't find it on the asset store;
But that infinite scrollview makes a lot of sense to me.
found it 🙂
Ah, €50 is a hefty price for something that you don't know if you will have to rewrite it yourselves anyway 😛
I’ll tell myself that It saves you 50€+ because You then know what not to do.
void OnParticleCollision(GameObject other) {
if(other.tag == "Wind") {
Rigidbody particle = other.GetComponent<Rigidbody>();
rb.AddForce(particle.velocity);
}
}
how do I access the velocity of a particle?
is it even possible?
tells me there is no rigidbody attached to the particles...
to my knowledge - yes.
ah, no sorry
probably using built in
Hey, is there a way to have a fade rendermode in URP?
No individual particle collisions are tracked. You cannot get individual particle collision info afaik
dam that sucks... Any idea for an alternative
is it possible to access the particle systems rotation from the particle?
sadly cant find any documentation on what is possible with the Gameobject of the particle
It’s best to view particles as living in their own world that only interacts with gameobjects via their transform. You can do fancy things like render particles to a utility texture and extract info from that
hmmm
a more powerful particle api is vfx graph
yeah im using that as well, but you can extract even less information from that
That’s kinda inherent to the way it operates
wouldn´t it also be possible to add a rigidbody to the particle and access the velocity from that?
Maybe you should use entities
what's your gameplay objective?
Most certainly not
made that vfx wind effect and I placed a particle system inside
I want those particles to collide with the player and kick him aside
That’s a bad approach to doing that. You should just fake that pushback by a separate cpu based calculation
never did that before, so I assume there is a better way? 😄
or you know a better way
Fake it. That’s the ‚better way‘ in all complicated sim problems in game dev
Is it easy to setup via code?
so how about i make an empty windarea which collides with the player and adds force to it each collision?
Sounds good
even tho setting the direction of it would be annoying since the wind can have multiple directions but i guess thats fine
Could you grab the direction of the wind and apply a similar force to the rigidbody during the collision detection?
Sometimes the tech needs feed back into how you design the gameplay
like anything in unity, everything you can do in the inspector you can do with code
Hmm, I have the solution working quite well, but will take a look at cinemachine too - thanks for the idea
i was gonig to answer you there
in the future don't cross post
what if you did transform.forward = -linkedPort.transform.forward.
you have no reason to use rotations
you were overthinking this
what if you added a transform for every face
the snapping point
you sort of need a transform for each snapping point nayway
the key insight here is that you can set the transform's forward
it's not the underlying details
okay
then try what i wrote
alright i think i helped you as much as i could
the key insight here is that you can set the transform's forward
do you see why that's important @undone crow ?
i don't know why you're not trying it
you shoudl at least see what happens
it will help you put toigether a complete solution
i hate to do this, but i really need help in #987007344212848710 please ❤️
are you saying that you want the forward of one object's child to face the forward of another object's child?
you're trying to connect parts
and have them rotate right?
the module is always rotated the same direction
i don't know what you mean by this. clearly if you set transform.forward on something and the forwards change, it will rotate
are you trying to say you don't want the module to rotate?
there are a lot of ways to do this. you can use constraints, you can use a dummy game object, you can interpret the port's forward relative to the parent...
i mean you have to think about this
i can of course just do it for you
but you're going to do transform.forward = somewhere
because as soon as i saw you're using an angle it meant you didn't know how rotations really worked
like what if you do transform.right = ... when it's the right port? etc. etc.
you have to think a little sure
you can look up "how to turn a vector into a quaternion"
i mean there are ways to have an object "point" in a direction
that's what quaternions are for
there are lots of ways to do this
you definitely know the port's transform relative toa module
how could you not
you know which objects are ports
what do you mean relative?
alright
it's okay i think you'll figure it out
sorry i think you'll figure it out
my bad
Personally, I think drpangloss was extremely helpful. In fact, they did the opposite of treating you like a "day 2 coder." They treated you like a competent programmer and gave you all the tools you need to solve the problem.
I'll give you a few more breadcrumbs, though.
It is trivial to construct a rotation to rotate an object such that the child's forward direction points in the direction the parent's forward direction did before rotating. Look at Quaternion.FromToRotation.
So, you need to...
- Find the correct direction that you want child.transform.forward to be pointing
- Set parent.transform.forward to be pointing in that direction
- rotate parent.transform using a rotation that then aligns child.transform.forward correctly
You could also combine steps 2 and 3 into a single step pretty easily
is there a way to make a package dependency when exporting a unitypackage?
like, that it automatically downloads all neccessary packages
I'm trying to use package.json, but it's recognized as a text file, not as package info
did that, now i'm not seeing any of the DLL files for Google.Cloud.Speech.V1 edit: nvm I fixed it
Thank you
Now I'm getting Assets/UnityGoogleStreamingSpeechToText/Runtime/StreamingRecognizer.cs(329,23): error CS1705: Assembly 'Google.Api.Gax.Grpc' with identity 'Google.Api.Gax.Grpc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47' uses 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' which has a higher version than referenced assembly 'netstandard' with identity 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
which is odd because when I try to switch to netstandard2 I get warning NU1701: Package 'Google.Cloud.Speech.V1 3.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Managed to manually install all deps with netstandard2 and now i'm here https://bremea.has.rocks/snap_cf26cfe6.png
I have ``` i_numberOfObjects = i_gridX * i_gridY;
for (int i = 0; i < i_numberOfObjects; i++) {
float angle = i * Mathf.PI * 2 / i_numberOfObjects;
Vector3 myPos = new Vector3 (Mathf.Cos (angle), Mathf.Sin (angle), 0.0f) * f_radius;
Transform myCube = PoolManager.Pools ["cubes"].Spawn (t_Cube.transform);
myCube.GetComponent<Renderer>().enabled = false;
myCube.position = myPos;
myCube.GetComponent<Cuboid> ().i_myCube = i_cubes;
i_cubes += 1;
lgo_Objects.Add (myCube.gameObject);
}``` which creates a set of objects placed around a circle of `f_radius` radius - as I add more objects in i_nuberOfObjects I would like the radius to expand so that objects do not collide - does anyone have any idea how I could possibly accomplish that?
the arc length of a segment of a circle w/ angle theta is radius * theta. If your angles are small, its a reasonable approximation to say the arc length and the chord for that same segment are equal (this is the same as saying your objects are small relative to your radius). And the chord is equal to the maximum size of the object you can fit in that given arc without overlap (this assumes 2d line segments. For objects with more depth in the direction of r this approximation might get bad).
So, the total arc length taken up by your objects is numObjects * widthPerObject, and the max arc length available at a given radius is 2Pi * radius. thus, the min radius required to fit the objects is: radius = numObjects * widthPerObject / 2Pi
Again, assumptions are the objects are small relative to the radius/arc length and depth is small relative to width. If they are placed with inner edges at the circle rather than centered on the circle the second assumption doesn't matter.
😄 thats something for me to contemplate tonight - thanks @gray pulsar
I have a player model, along with a state manager singleton that holds the single reference to "the player". This model can come in from the server, and I have various UI components that subscribe to an action I fire from the singleton when the model is changed (OnPlayerModelUpdated). However, this can happen several times per frame, so obviously it's not a good approach for anything UI related that's instantiating or laying out components. However, I do want these dialog boxes and whatnot to respond to player model changes. What's your approach to this?
I've thought of two so far but.. I'm not sure how I feel about either:
A: Break down each type of state update into several and emit those granular actions instead.. OnPlayerDistanceUpdated, OnPlayerCurrencyUpdated etc.. ad nauseum.
B: The UI component hashes and caches the part it cares about and rebuilds itself only if the hash value has changed. Ie..
private int _lastKnownHash;
private void OnPlayerUpdatedHandler() // perhaps this is a "crew" dialog box
{
int thisHash = PlayerStateManager.PlayerModel.Crew.GetHashCode();
if (thisHash == _lastKnownHash) return;
... otherwise do all the UI update stuff ...
}
I'm sort of thinking option B is looking good?
the problem with approach A is I'd have to write a method to compare two models - a "client" model and "server" model and sniff for differences in order to emit those actions - I don't do that now, I just send the OnPlayerModelUpdated action and let whatever UI needs to rebuild their UI based on the state
error: - net462 (.NETFramework,Version=v4.6.2)
error: - netstandard2.1 (.NETStandard,Version=v2.1)```
yikes.
Can someone please tell me how can I manually serialize an instance of a serializable class? I assume there must be an existing API for that, no?
Depends on what you want to serialize it to. JSON? byte[]? XML?
@gray pulsar only one slight issue - now its time to rotate each item to face towards the centre of the imaginary circle 😄
I have been doing this so far:
But it returns me a simple string like this:
{}{}{}{}{}{}{}
unserializable classes return a {}?
Well, it cant be... which means I must be passing the wrong class... Im going to re-check
ok so im making a vr game but when i have my vr plugged in and i go press ctrl p it only loads in my vr not unity
All classes are serializable as empty objects. Whether their fields are serializable depends on their type and the serializer you use. JsonUtility is known for being quite limited in what it can do.
mb
Ok, indeed. I was not passing the serializableData, but a container with the Serialized data
if it uses grpc
you are going to have a very hard time at getting this to work
grpc.net doens't work in unity
period full stop
you'd have to figure out grpc core
it appears that you are on a macos device, is that right? @high dock
if it's an ARM64, you're talking to the 1 guy who's publicly documented how to get grpc.core to run on macOS
there's someone else who has littered the grpc github issues with misinformation / is deeply confused
I figured it all out lol. Turns out the solution was very obvious and I'm dumb. Just had to download the updated version of Google.protobuf to match my other package and then update the assembly reference overrides in my asmdef file.
I get a ton of warnings, but it works!
hmm
are you on windows or mac?
i understand that it might import
but i don't know if it's going to work
probably a bit premature to say that
the protobuf assembly isn't related to those issues
don't be this guy https://github.com/grpc/grpc/issues/28974#issuecomment-1114120457
because unless you are using the grpc build for unity
it is probably not going to work
mac
I just tested and it works fine
the package i'm using has bundle files for mac
haven't tested on windows yet though
sorry, i said errors - meant warnings
the warnings are just letting me know that it couldn't find the target version (3.8) so it's using the version it does have (3.15)
on an intel or ARM mac?
is it a bidirectional streaming call? are you sure you tested it?
anyway good luck out there
you can disable assembly version checking in player settings
intel
is it using grpc.core? then it will be intel osx standalone only
is it using grpc.net? then it won't support bidirectional streaming - i don't know if google's apis support grpcweb
so it really depends what you want to support here
i was saying yep to the "are you sure you tested it?" bit
one of my QA people is testing on windows now
grpc.core works on windows
but i don't think you have a binary for it properly
unless you use the unity grpc build
do you know if you're using grpc core or grpc net?
core
No, i'm using whatever is in here https://github.com/oshoham/UnityGoogleStreamingSpeechToText
it has runtimes folder so
ig?
gotchyu
so yes, this will not work natively on apple silicon, if that matters to you
it will only work rosetta
there are other problems with the grpc this ships with, it's pretty old
but it won't really matter
nothing significant
i guess i should have asked you if you were using a library in the first place
i saw unitygooglestreaming... and i thought you named your own library you were authoring
oh nono i'm not that smart 😅
Anyone knows about generic trees, cuz i need help with that plEEease 
hi, im watching this tutorial here and i have a question
Learn the fundamentals of programming State Machines in Unity with this new video break down!
This tutorial explains important concepts of the State Pattern, and how to use State Machines when programming! Today we will walk through an example project to showcase the benefits of using state, the state pattern and state machines in Unity!
This ...
can an object have two states active at once? (eg shooting and running)
ah yeah just got to that part
so ill make a seperate state machine for weapons
you can have a hierarchical state machine where a parent state is always active while a child state is active
if you use multiple state machines in a non-hierarchical fashion you loose most of the benefits of a statemachine
but if i want my shooting and movement states to be independent of one another, what should i use here?
several state machines?
that seems convoluted
if you primarily want to manage multiple active states, you would use a different model to manage your states (not an FSM)
what model would you reccomend?
i dont know if there is a name for it
but you could define a set of rules for each state that need to be true for it to enable, and on each tick it would evaluate all these rules and activate the states that are valid and disable others, triggering Enter/Exit callbacks
i'd call that an AspectMachine, but thats just my name for it
you could compare it to an inference engine that solves logic questions based on facts
ok ill try to find a tutorial on it
is there a way i can get a public serialized field I can drag and drop into of any monobehaviour-derived class that implements a certain interface?
pretty sure you can do that with [SerializeReference]
you can, it's very limited though
you can't do it with monobehaviours for example, which to me is the ideal use case for drag and drop references by interface
that technically works but unity really doesnt like it hahah
yeah like Stropheum pointed out you can't really do it with monobehaviours which is pretty dumb. there are other restrictions and requirements, you can check them here https://docs.unity3d.com/ScriptReference/SerializeReference.html
is there a way to enable floating notification or open app info the user can do it manually because xiaomi mobile devices comes with floating notification disabled
Is setting Thread.CurrentThread.CurrentCulture enough to apply that culture everywhere? Do I have to do anything extra for Unity things like Job system etc?
Not sure where to mention this but importing the mediation tarball and allowing Unity to install/upgrade play services results in : General error during semantic analysis: Unsupported class file major version 57
I have a problem about deserialization, that I have no idea how to solve.
I have a list of instances of classes with a common ancestor. I would like to serialize them in a way that when they are deserialized, they can still be upcasted. How could I do that???
Since you save them as a base class, only fields it has would be saved. Objects would not have any way of knowing what it had. You can cast it later as anything, it would just not have the information
Use a more powerful serialization framework than JSONUtility
Some of them can save type information alongside the data so they can be deserialized properly
@sly grove I have no experience on this area. Could you please give me an example or two?
Newtonsoft Json
Cool, I will look into that. Thanks a lot.
You can add it by the package name in package manager. It is used internally by Unity as well. https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@2.0/manual/index.html
Oh! I see
I am using it in an package i want to distribute. So I guess I will have to add it to the dependencies list
What do you mean "add it by the package name"?
I only see 3 options to add external libraries: from git url, from disk or from tarball
It could be 2021+ yea
So I need to copy/paste it manually? 😄
use its git repository name
oh, lets see
mmm... didnt work
It worked, editing directly the Manifest.json
oh well
Glad it worked. I think it should've been just the url without the git part
To serialize and deserialize types with inheritance, you'll need to pass a TypeNameHandling value into your serializer options. See https://www.newtonsoft.com/json/help/html/SerializationSettings.htm#TypeNameHandling
Thanks, ill take a look right away
I am using this one, in my manifest:
"com.unity.nuget.newtonsoft-json": "2.0.2",
Fiddle showcasing the system: https://dotnetfiddle.net/Gs1hdj
If you don't have the "add by name" option, you put the name into the git url option and it works anyway
It seems to be having trouble serializing Vector3...
I would use this package too https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters
JsonSerializationException: Self referencing loop detected for property 'normalized' with type 'UnityEngine.Vector2'. Path '[0].NodeRect.position.normalized'.
Ah yeah, the "downside" is that it serializes all public properties by default, unless you ignore them with a specific attribute. And since you don't have access to the source, you can't put the attribute.
You can however define custom type serializers that you pass to SerializeObject and DeserializeObject
https://www.newtonsoft.com/json/help/html/CustomJsonConverterGeneric.htm
The package I linked thoroughly handles all that
Yep I just clicked on it now
i will check it out...
Im still not managing to install a package using a git url... I have tried these:
- git@github.com:jilleJr/Newtonsoft.Json-for-Unity.Converters.git
- github.com:jilleJr/Newtonsoft.Json-for-Unity.Converters.git
- https://github.com:jilleJr/Newtonsoft.Json-for-Unity.Converters.git
none of those work :/
Read the installation instructions
mmm... so I have a certain DLL in my project
But if I am building a package for distribution, i have no way to guarantee that people using it will have that DLL, no?
If you mean a package like an editor extension, no, you would have to require people install it themselves or you provide it to them
Ok, I cannot afford that... makes my package much harder to use... :/
I will have to find a way to do it with the normal newtonsoft package..
I'm not sure what DLL you are talking about
If you mean the .dll it mentions as a dependency, that is what the newtonsoft package as in it
It says it in the instructions
Yes, and that dll is in this package
so I need both of them, then?
Ok, let's see...
mmm... i have no idea what an UPM is 😅
Unity Package Manager
ah
So I switched back to UnityAds and updated the plugin to the latest version in Package Manager - now calling Ad.Load in code I receive placementId cannot be nil or empty UnityEngine.Advertisements.Advertisement:Load (string,UnityEngine.Advertisements.IUnityAdsLoadListener)
can installing a asset from the asset store update the scopeRegistries in your manifest?
You can make an install window that sets that stuff up, but it's not simple
nah... i want to make my asset as "frictionless" as possible
I guess I will have to give up on a copy/paste function :/
guys please help, I'm working on an AR game project which was handed to me, there's a section in the game in which the user is prompted to take a selfie and i need to switch from the AR camera to the selfie cam. when I do the switch everything supposedly works fine but the selfie cam renders black. If i lock/unlock the device the selfie camera will render fine until i try to switch back to the AR cam again and then i will have the same black screen problem until i lock/unlock
anyone knows why the DOLookAt returns "Look rotation viewing vector is zero" and the transform.LookAt() works fine?
Question:
Let's say that I have a SO called Actor, and I create a couple of entries. Now, a couple of weeks later, I realized that the classname, namespace or maybe even assembly of the class is wrong. For example, I rather call it "Character".
Now, if I were to replace Actor with Character, all my existing instances would break. Is there a way to make it, so that they automatically migrate to Character?
I tried using [MovedFrom(...)], but that didnt do the trick...
I'm pretty sure that you can change the name of a type as long as the GUID and content remains the same
even its namespace?
IIRC yes but that's a bit more iffy
If you're changing the assembly then it'll break
Keep in mind, if yuo're renaming the file you should also rename the meta file
So I guess I am screwed
The problem is that I already have entries saved as "Character" and entries saved as "Actor"
so I need to change this, without breaking neither
How big is your project?
It is a distributed package. I am thinking about the users who have been using it.
So what you can do is write an editor script that executes after the user updates (InitializeOnLoad), that finds all objects of Type Actor and rewrites the type to be Character
Wont that replace the asset, messing all the references to the old ones?
That is, if you create a new asset in its place instead of changing the type
Im not sure how I would change the type with a script...
You can either manually change the asset file to reference the GUID of the correct class or you can iirc use SerializedProperties to change the m_Script field
sounds quite advanced
Well yeah 😛
Don't cross-post
The error is self-explanatory, you're using something that is obsolete
It's even telling you what to replace the obsolete code with
Did you get anywhere with this?
Hi. I'm trying to do some UIElements right now. How do I add an input event handler on this thing https://docs.unity3d.com/ScriptReference/UIElements.IntegerField.html
I want a sort of OnValueChanged event, but using the serialized property manually in the callback to that
Oh, there's a RegisterCallback
Hi guys. Does any can help me with my problem? I'm unable to use the copied image from clipboard. I tried to use the old system.drawing.image and system.windows.form dlls but I think the functions from the system.drawing.image dlls only return null values. Tried to search answers from stackOverflow, found some users with similar issues but there are no solutions.
Nope, I tried submitting a general support request via unity3d.com website but didn't get a reply. It's not a disaster - it just means I can't see any of my bug reports ever again.
So this might be really hard, but is there any way to change the players desktop wallpaper inside a script? kinda like that one puzzle in oneshot. Thanks
You'd be writing a virus at that point
then wallpaper engine would be a virus
Not really, wallpaper engine provides a service the user wants, you're implying that you're doing something while the player is playing the game that they didn't ask for
well this concept has been used multiple times before and no one is mad if they see a forth wall break like oneshot in the game they are playing. it doesnt classify as a virus either since it doesnt harm your computer in any way
if a game changed my wallpaper i’s be furious
2
anyone good at making maps in 2d wants to help go to 2d tools pls
so you actually have 2 scripts?
https://docs.unity3d.com/ScriptReference/RaycastHit-textureCoord.html for mesh colliders
Hi,
how do you guys delay update or by a float ( factor )?
I have a Raycast that makes the player fires as long as the player presses Space
Public float fireingRate;
void Update()
{
if (Keyboard.current[Key.Space].isPressed) { Fire(); }
}
public void Fire()
{
Debug.Log("Player is now Fireing!");
}
the current settings would make Fire() spray bullets almost like a laser!
I want to reduce the firing rate to be more believable like a regular Ak47 or MP5
You would have to add some time between shots.
you cannot delay Update itself
use variables and logic to figure out in your code whether it's appropriate to fire or not fire in the current frame.
Well you can't change update's duration like that
you have to either use a timer variable or a coroutine
Coroutines!
fun!
I'll give you an example:
{
yield new WaitForSeconds(1f/FireRate);
isAvailableToShoot = true;
}
I highly recommend not using coroutines for this.
Overcomplicated and will introduce timing error
I guess you could do current frame mod something?
I've always done it with coroutines
float timer = 0;
float fireRate = 25f; // shots per second;
float shotInterval => 1 / fireRate;
void Update() {
if (Keyboard.current[Key.Space].isPressed) {
timer += Time.deltaTime;
if (timer >= shotInterval) {
timer -= shotInterval;
Shoot();
}
}
}```
@sly grove @lavish sail Thank you for your replies
Yes I understand that there are multiple ways of doing that, but I don't know which way would be the best for example one of my ideas, but it seems to be the best
float delay = 0;
void Update()
{
if(Keyboard.current[Key.Space].isPressed)
{
if (delay >= 5)
{
delay = 0;
Fire();
}
else
{
delay = delay +1
}
}
}
no that's not good because you're just counting frames instead of time. Frame durations change based on the current framerate of the game
so you will shoot faster with higher framerate
Also setting delay to 0 discards the inter-frame time, leading to timing inaccuracy
Make delay as deltaTime
Add deltatime to delay instead of 1
that seems more legit!, thank you!
for the future this is also kind of a #💻┃code-beginner question
I heard from many devs who has games up on steam right now that coroutine leaves few "Junk" behind, and all of them agree to avoid using it.
Big if true. Weird.
Coroutines themselves are fine - but coroutines for fast repeated timers have issues related to timer accuracy that make them not suitable. They're also just way more complicated than you need for this.
I don't know if this is the right channel to ask this in but
I've been working on this game for a while now and I want to add proper mod support where you can just drag your mod into a folder and be able to choose which mod I want to activate
How would I go with doing something like this? I'm guessing it's quite complicated since I can't find any tutorials online for unity modding
ok this is a longshot specific question, but does anybody know how the ".SetSpeedBased()" function works in dotween
i cant get it to work
i think the problem is my tween starts already before the option is applied
is there a way
to ensure there's a render thread
in batchmode
is there "windowless" as opposed to batchmode?
Yeah
Hey, How would I improve my coding structure to become more advanced and efficient in unity for creating larger projects. I have been using unity for a while but after seeing after other developers I have realised their coding was more advanced and seemed like a better structure, so I'm asking how would you guys improve your structure and could you give examples, or if you know any sources about this?
Read Game Programming Patterns; it's a good primer
That's a way too broad question and really depends on how your game works and what kind of mods you want to support.
You could check out how a game like Cities Skylines does it
Thanks
Sorry, what does that even mean?
(it sounds like nonsense to me, use coroutines if they fit the problem you're trying to solve)
Well, from what I've heard, it seems to be that coroutines creates junk temp files, and sometimes they don't clean up after itself.
But I agree with you and PraetorBlue's comment, they are not ideal for fast repeated timers
They don't create files. Things like 'yield return new WaitForSeconds()' can create a tiny bit of garbage, which that can be prevented by creating the WaitForSeconds object in Awake() and storing it in a variable
if a package puts something into a Resources/ folder located in its file system, will that something be shipped into the player?
Uh, I wouldn't expect it to.. but if you can access it with Resources.Load, then yes
@undone coral Back again 😔. I'm getting this error when trying to build my project
Copying /Users/bremea/Desktop/Overdue/Packages/com.oshoham.unity-google-cloud-streaming-speech-to-text/Plugins/Grpc.Core/runtimes/osx/x64/grpc_csharp_ext.bundle to /Users/bremea/Desktop/OverdueBuild/MacOSBuild.app/Contents/Frameworks/MonoEmbedRuntime/osx/libgrpc_csharp_ext.bundle: No such file or directory
Why is it trying to copy from /Packages/? I have all of the assemblies in my /Assets/ folder.
how did you add this package
to your unity
is there a line for it in manifest.json?
I downloaded the source into the assets folder. There is not.
you can't copy and paste it into assets
you have to create a LocalPackages/ directory if you want to vendor in a package like that
ProjectRoot/LocalPackages/com.oshoham.exactpackagename@packageversioninpackage.json
I have my states set to idle and when I debug the character is always in idle, but on start the character starts walking when i want it to be in idle animation
@high dock also you will need https://github.com/grpc/grpc/issues/22485#issuecomment-933666885 if you want to build for il2cpp
on all platforms
Alright so I got it to build but now the game crashes as soon as I boot it. Let me try to get a crash report
To be more precise
I'm remaking the original classic version of Baldis Basics from the ground up with much cleaner code and lots of different settings, a new engine entirely
I want to be able to support pretty much any kind of mod wether it just changes a couple sprites or changes up the entire game
are you the developer of baldis basics
No
or is it open source on itch?
Just a fan
gotchya
what is your objective? modding?
if it's open source that's the best way to mod
asking people to PR
that's what modder swill tell you
especially the good ones
at the end of the day they just want the project source files and to PR their contributions
lol
@high dock try to build for mono first
i'm building for mono
try building devleopment mode
super hard to say what th eissue is
it could be a million things
it's probably an async error
wrong threads
I want to make an entirely new engine from scratch that can run mods from a folder easily without having to redownload the entire game everytime, similar to what a lot of the fanmade FNF engines do
But its probably a lot more difficult to do in unity though
I don't mean game engine, I mean the actual game itself like
You could also look at how VR Chat does it
I'm making a custom version of the game basically
Was vr chat made in unity?
yeah, if you want to make content for VR Chat, you do so through a unitypackage
but if you don't have the rights to Baldis Basics, I can't recommend you go through with this project
yep it's fixed now
Baldi is free
It's 100 percent legal
And I'm pretty sure the original dev is fine with mods
It's not a mod if you're recreating it from scratch? What license is it under
Would it not technically be a fangame then?
i would make it open source
the problem with unity modding is not having the source
if you give peopel the source it's easy
then they can e.g. build addressables and it just works
if they need to add code you can use Mono and load the assemblies or merge it
it's the best way
in reality nobody who authors mods
wants to deal with mods
they just want to modify the source
even if there were 1,000 mods the game would probably go from 90MB to 400MB... it won't matter
you can always auto-update
don't overthink this
I don't see anything on this being open source
Just create your own game, don't copy someone else
i'm trying to say that the user @heavy frost should make his clone fangame an open source game
is there a way package authors add things to the project's link.xml
or is there another way to preserve types specified in external assemblies for il2cpp?
oh my god
do they not test hdrp with medium or higher code stripping?
this is a joke
This error is popping up and I do not know how to fix it. I have been trying to fix it for the past hour. Is there any expert on C Sharp that can help me fix it
im making inventory buttons and my controller's navigate only goes vertical and horizontal, but i need it to go diagonal
You likely have two classes with the same name, not an advanced issue
(They left)
you don't need an expert in c#. you have two Update methods
or two scripts called PlayerAttack
oy
I have an extremely specific need (want really). I want to run Unity headless. The same way you can create dotnet console projects using the cli, I want to create a Unity project and build it for Android, all from an Android device. I should be able to instantiate everything I need from scripts without the need for an editor, I just need a way to create and build a project.
Any resources to get started at least?
Thank you.
How do I create such a mini-camera view in the right bottom corner of scene view through scripting?
Like, I want a specific camera to always be shown there
I do not need some custom inspector guide regarding it, only the action of creating the mini window with camera
Bloons tower defense?
?? never heard of that name
Nvm then
Something like this? https://docs.unity3d.com/Manual/class-RenderTexture.html
sure but I expected a special method to exist
why my message is being deleted when I post code?
Can there be any issue related to threading (like deadlock) with this?
#854851968446365696 for how to post code
Also looks like the bot (or new misconfigured discord feature) right now deleting messages with repeated spaces even in code blocks.
hey guys, if you think you can help please checkout my question on SO https://stackoverflow.com/questions/72669754/unity-ar-camera-not-rendering-black-when-switching-from-back-camera-to-front-c
precious internet points are guaranteed to the solver
{
childLetGo.parent = null;
LookingAtPlayer();
Invoke("ChargeTowardsPlayer", 2f);
}
void LookingAtPlayer()
{
Vector2 direction = player.position - transform.position;
direction.Normalize();
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.AngleAxis(angle + offset, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotateSpeed * Time.deltaTime);
}
void ChargeTowardsPlayer()
{
transform.position = transform.forward * 5f * Time.deltaTime;
}```
Hi just wondering, why doesnt this object charges forward from where it was facing? it just stays the same. did i do anything wrong? 🤔
You're setting the position to a very small vector, instead of adding to it
#💻┃code-beginner next time
That invoke in update with 2s delay has no sense. It is, every frame schedule invoke function with delay. Why don't you just call it normally\
hi guys i want to try calling a method in unity from python using this package https://docs.unity3d.com/Packages/com.unity.scripting.python@5.0/manual/inProcessAPI.html but the example only shows calling debug.log() from python. Im wondering is it possible to call a method in Unity from python using that package?
Sure. Should be possible.
aight gonna try
what's your objective?
the python scripting package does not work in standalone players
what is your objective?
i want to use the tiktok live package in python to make a tiktok live game that responds to likes, shares, gifts etc
found this error when installing the package
wait so what should i do here
use webGL perhaps?
man this package is so confusing, anybody here know a better way for a python script to communicate with Unity? im talking about passing data here not just keyboard input stuff
I don't think that you can interact with the game app from outside regardless of whether it's C# or python. The best you can do is something like http requests, or hook to some outside api from inside unity.
oof this is what i thought initially, okay thanks for the info man
you're at the start of a very long journey
i think not that long bcs i found this awesome library https://github.com/Siliconifier/Python-Unity-Socket-Communication/tree/v1.0.1 😄 just tested and works like a charm
journey just became longer 😉
i'm curious, has anyone done an implementation of using "intelligent" yielding in a coroutine for like building caches and things like that? something like: https://paste.myst.rs/yywcj9np
an example as simple as this i would probably just use async but i'm referring more to the principle than this specific implementation
say it was like a batch spawning system
something that has to happen on the main thread
I think it'd be better to use system time which you can measure within a frame
Basically you could do something like have a budget of N milliseconds after which you'd yield
Oh true
Does deltatime not change within update?
Oh I get what you're saying. Like it'll increment but it'll start as time.time - time at last frame. So it wouldn't be counting the number of milliseconds ON this frame
I don't think it does increment. I haven't specifically tested, but my understanding is that Time.deltaTime has a constant value through the whole frame. That's what the documentation implies:
The interval in seconds from the last frame to the current one (Read Only).
Makes sense. Yeah I'd either have to use system time or cache time.time. though I thi k the latter is less precise
hi devs, as you all know that icons appear grey in android notifications, is there any way to make them colorful or make them appear the actual image
Nope it's the same throughout the entire frame
It wouldn't really work if it wasn't
yeah made sense immediately after i asked. guess i never really thought about it though but yeah
this seems like it should work
stopwatch starts at the beginning of each frame, if it runs for more than half a frame, it yields and resets
oh crap it's hanging. i think i have to use milis
cool that's working perfectly
how did you set up the animation event?
you should be able to drag a gameobject as a reference and you'll be able to choose any of its PUBLIC methods
if you want it to be triggered by an animation event that is required
I was following a tutorial and the guy used the same code but his worked
animation events are most likely classes under the hood, so they'd function like any other class that takes your script as a reference
hmm i dont think i understand
I am trying to set an event at 25
and then assign the function deactivate
but it does not showup
you need to add an event
i did
Make it public
i tried but unity crashed
Don't think that related...
you should have an object reference though. that's weird
yah i find it strange
should look like this when you double click the event you created
i cant double click
do you have your object selected? the one you're configuring the animation for
also i did try setting it public didnt work
yessir
actually
when i click 25 to set event it clicks off from the object to sample scene
is this normal?
off the object or off the animation event
off the object
friends used same code as mine their's work so i dont think the issue is with my code
can you record a video of yourself doing this step by step
moving the play head to a location
selecting the add event button
navigating to the inspector window
i can get there literally no problem
made a new animation, moved the play head, pressed the button
can we join a call?
ok
What was the issue?
assigned the wrong script to the object lol
does it say what script it's occurring on
Line 3 suggests you're using a constructor where you shouldn't be
hi guys, is multiplayer a advanced topic?
its a #archived-networking topic
ah cool, thanks
Is there a way to make some specific area can be raycasted?
I am making a tutorial system, I've created a blocker to block the raycast, and I want the "highlight" object to un-block the raycast.
Or is there better approach?
code:
I tried every way that I know to fix but nothing work
error:
NullReferenceException: Object reference not set to an instance of an object
ShopManager.LoadShop () (at Assets/Scripts/Managers/ShopManager.cs:48)
UnityEngine.Events.InvokableCall.Invoke () (at <db7f68c084e842d98504c53b2b4dd3db>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <db7f68c084e842d98504c53b2b4dd3db>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:68)
isOwned is null or date is null
You'd need to Debug.Log them both to see which is, they might of course, both be null
how i do i Debug.log them?
We're in #archived-code-advanced...
my brother in christ we're in #archived-code-advanced you should know how to Debug.Log a variable by now
I know to debug.log
I mean really, a NRE should never make it here either
Debug.Log(variableName);
Then do it?
but which line in code?
Take this to #💻┃code-beginner
right
Thx
any idea, why this doesnt work? You can barely see the fade in/out animation
its like 1000th of a second
you are not using a coroutine to break it up into frames
so it happens in a single frame
hey i am going to ask here because in the other i was in said it was really hard but i am not sure if it is not pls warn me
can i ask?
😅 i am making a first person controller using CharacterController and i repeat NOT RIGIDBODY. so i don't want my player to sprint mid jump or stop sprinting mid jump and all that. basically i want to make that if you have momentum and you are sprinting and jump you cannot stop sprinting but if you are not sprinting you cannot sprint during your jump. How can i make this?
brooo, not trying to be mean right now... It´s not as if I´m not doing my own research.. whatever Ill do it myself
if you dont want to answer, than just dont type like cmon...
you should do your own research
that's how you get better
thanks anywaysim coding since 6 years and am a webdev and have to do this for university 😄 I know how I learn to code^^
no uhh so for ex: you can sprint mid jump or you can stop sprinting mid jump i don't want that i want to be at the sprint speed if we are already sprinting and we cannot stop it. if we are not and just jump we shouldn't sprint and we should jump at the default speed.
after this project ill never touch unity again and I asked politely for an answer. People who feel like answering can do so, people who feel like "I´m too good for this, this is beginenr stuff" can just sit back and chill
you did, but you couldve just leave it at that
sorry to bother or anything or i am not trying to be mean but did anybody understand this pls help me?
unnecessary unfriendly.. and i say that lol
well its basically you make a state machine with swapping objects
interface Move{ Move Move();} lets say you got that
then in your character
yeah
void Update(){ if( Move() != null) currentMove = ...) }
Don't bother, they've cross-posted in #archived-code-general
in your jump you just dont react to input which you would react to move
just statemachine
both will work
without knowing what the other is
Cross-posting is against the rules, for your information
oh really ****
sorry i actually didn't know
i kinda didn't understand can u expand a little?
Yeah, but how
Looking back at the stack trace, this is an internal Unity error (line numbers are all at 0). You can safely ignore that.
I’d love to but it halts my game
Restart the Editor, if that doesn't fix it report a bug and attach the Editor logs.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
in your character controller you just swap states if the return is not null
null == stay in same state
you can trigger internal errors like this with unconventional code - the error suggests you're using a constructor in a UnityEngine object, so you'll need to look at your code and see if you're doing that
if the object is in state jump the key input shift has no meaning
if you want to animate / tween things, use DOTween. DOFade achieves this. you should use a canvas group
don't overthink this. create 4 rectangles that block raycasts to "cut out" the area you want to make interactable.
Hey,
I'm using ParentConstraint on all children objects to assign a parent for them
but when I want to delete the parent, I also want to delete all it's children.
Is there is anyway to find which gameobject has a certain Item as a ParentConstraint.source ?
no. you would have to store it yourself
Hi, is there a package I should read up on if I want to spin up Unity in a remote VM, send it some C# code, and see if it compiles? Then run unit tests and retrieve its XML document of results?
I think compilation errors are outside the purview of the Tests suite, right?
I have a "Runtime C#" asset but that seems maybe overkill, to have Unity in Play mode to test compilation
hi, thanks for the reply but what if I used the other one instead childConstraint ?
can I add the childConstraint on the parent and keep track of all the children under ChildConstraint.source ?
what isy our objective?
you just make a field
don't overthink this
[SerializeField] private ParentConstraint[] parentConstraints;
void OnDestroy() {
foreach (var child in parentConstraints.Select(c => c.gameObject)) {
// you should probably assert that the parent constraint
// specifies this object's transform as its only source
Destroy(child);
}
}
@woven kettle
there's no way to do this automatically
ChildConstraint doesn't exist
I need the parent to somehow know all it's children Percisily , Imagine if I deleted a gun with attachements ( children ) and a mag ( child also ) ..., the gun would disappear but everything else would just hang in the air and console would have an over float of errors.
this is a very long journey
what do you mean send some c# code? what's your objective?
it's not that simple, its a multiplayer game and that ParentConstraint would be on the attachements and mags not on the weapon ( the source in this case would be the weapon )
where could I just make a filed that is aware of all the parentconstraints and whne the object gets destroyed, im supposed to loop through that and compare the source of each to see if it matches the ones that has been destroyed ?? ... I dont think that is the best idea
you can make the field on a new script
i think maybe you should ask #💻┃code-beginner @woven kettle because you're getting stuck on something
I'm not stuck , but I dont think you get it yet, but thanks for your help , appreciate it
you're trying to destroy some objects right?
why in the world wouldn't you know what those objects are
surely you have them in your scene or you Instantiate them somewhere
var attachment = Instantiate(someAttachmentPrefab);
attachment.parentConstraint.sources[0] = someWeapon;
someWeapon.implicitChildren.Add(attachment);
it seems so straightforward that yes maybe i do misunderstand
but you're also talking about something that makes no sense
i didn't show any comparisons or any loops
and besides, even if you have 10,000 attachments, so what... computers loop all the time, it won't register in the profiler
so you sound stuck
are you working with PUN? @woven kettle
anyway @woven kettle the answer is no. there's no pre-existing unity api for finding all the objects that use a specific object as a source in a parent constraint component
that's in the docs
so i guess you'll have to make a list and keep track of it in a place you deem appropriate
or just parent the objects
I'm destroying a Gun >>> the Gun has no idea if there is an item (like: attachement or magazine ) with a parentconstraint script attached to it and has Gun as the source.
if runGetComponentsInChildren it would only get the children in the hierarchy.. ( the attachments and the mag wont show up )
so to make a script/field on the Gun itself to keep track of those, is one possible answer (YES!)
but I was thinking, what if I used ChildConstraint instead ? , if I'm not wrong, to use ChildConstraint i need to add it to the Gun instead to the attachements, where I can use get component on the Gun and look for each source on the list
there is no childconstraint component
i think you should go to #💻┃code-beginner
so to make a script/field on the Gun itself to keep track of those, is one possible answer (YES!)
this is the answer... go code! by now you would have finished
wow, i used to see it in unity2019, but its no longer there in 2021
yes, i think i know why we both were confused, thanks ^^
it was the second time i wrote that line
you can go to #💻┃code-beginner and ask questions like this
i don't think i was ever confused
So I have this line renderer I was wondering how I would set the end of the line to follow a specific point like a mouse. And I want the rest of the line to bend
Hello everyone I have a question
Is it possible to make a public function which you can input in the script properties
So there would be a function that you can input there
Use a trail renderer
That doesn't really help 😅
create a 3d object or a plane that helps you map the 2d mouse positions to a 3d position using raycasts / the pointer event data. then set the line renderer's positions to be attached to that point. if your intended effect is to make a 3d rope... use a rope package, and use a joint to connect the rigidbody end of the rope to the 3d position you determined
don't
say
that doesn't help
say what your objective is
-_-
Ok well I was about to go more indepth until you said that
Ill get help from somewhere else
You can see when people are typing I thought you'd figure that
#💻┃code-beginner use a UnityEvent
@undone coral
You don’t need to be so passive aggressive to everyone
Oh don't worry it's a frequent thing to see from them
thanks
Receive C# from an AI service, drop it in a file for the Unity Editor to compile and ensure it compiles in the current context (eg. no Editor namespace references, no inappropriate types like int32), then run unit tests. What I'm stumbling with is how to get a notification if won't compile. Like, I know [AssemblyRefresh] or whatever the hook is, but if it doesn't compile, how do I get callback?
what is the big picture app or game here
are you trying to filter out code that doesn't compile, or is the expectation that a typical code snippet generated this way will compile?
I guess filter out code that doesn't compile
999/1,000 to 9,999/10,000 code snippets will not compile
that aren't the absolute minimum basic complexity
is that okay?
why does it have to be in the unity context?
Yeah I'm not worried about efficiency yet
it's very unlikely such a generator will be aware of the unity api, there isn't enough open source unity code for it to work for that
have you gotten something that works with an ordinary command line c# compiler?
you can use stub versions of unityeditor and unityengine apis, they are available on github
Stub version, like... headless, call on command line?
Like, the things that get expanded in a C# code snippet? Templates, sort of?
or an API you implement
hmm
i'm saying you can use a mocking library to mock the unityengine and unityplayer assemblies
you don't need the unity editor to see if something compiles
you don't need the implementations of the functions
you only need type signatures (types and function signatures)
I'll check it out, thanks
does that make sense?
do you see why you don't need the editor
let's say you just had
It does, but I'm probably going to stick with an editor solution since I'll be running unit tests using it afterwards anyway
well then i suppose you can copy and paste a C# class into a project
then try to build and run the tests from the command line
i don't know at what level you want or need to automate this
what's the bigger picture app / game?