#๐ปโcode-beginner
1 messages ยท Page 410 of 1
Debug.DrawLine(ray.GetPoint(0), ray.GetPoint(distance), Color.red, 0.5f);
This draws a red line that lasts half a second
Ooo new debug thing learnt
Yea it doesnt care about the mouse at all
Just raycast from the camera
I think imma take a break from this its so stupid, its also better because I have to polish how my camera moves around in the map as well
Rn you just hold right click i nthe direction you want it to be, Ill work on scrolling
Out of curiosity, why is plane casting the ray? What is it?
This lets you shoot a ray at a plane defined by a point and a normal
It's not physics-based at all -- just seeing if a ray hits a plane
So plane here is roughly where the terrain is?
Hey was doing some basic mathematics functions and the code sends out -infinity first time second time gives out what is supposed to come out
what's the code?
Coming.
That's the idea. I'm wondering if the plane is bogus
It being misconfigured could definitely explain the 0,0 world coords, I would think. Thanks for the elaboration, in any case ๐
The code in question was PlaceX = (player.transform.x / WorldX) ร MapX - transform.getcomponent<recttransform>().rect.width/2;
This again for the z axis then given to the local position of the raw image
First time it gives out -infinity
Other times not
is there an easier / better performance way to find an object in a list that is not active than go with foreach through it?
looping is the quickest way
thats what the other finds methods essentially do, except the list to loop through is bigger
hm. because i am trying to make a pooling system for projectiles, and searchin for a not active object in the pool every time hurts performance
uhh if you are searching everytime something is wrong with your pooling
why
what else could i do
put the not active ones in a separate collection
You might have 3 collections honestly:
- A list of all the pooled objects
- A HashSet of the active objects
- A HashSet of the inactive objects
depending on your needs
Log your inputs... Maybe something doesn't initialize until after the first call, resulting in different values
hashset?
ah
Did that except for player position will check
it's a collection optimized for unordered Contains Add and Remove operations
interesting, was using a queue at some point, hmm yea hashset makes more sense
hey guys. I want to continuously check if a time limit has ran out without the player selecting an answer in my quiz game, and if so play an error message ONE TIME. The way Im trying to do this is by checking in Update() whether or not the time limit has ran out without the player answering a question, and if it has, calling a method which is supposed to play the audio one time and then subtract from a counter which would disable it from being able to play again. The result I'm getting is that the audio clip is being played every single frame without ever stopping until the if condition becomes false. This is the relevant code: https://gdl.space/dorakehige.cs
else if (!hasAnsweredEarly && !timer.isAnsweringQuestion) //If the player hasnt selected an answer and the time limit runs out.
put another bool here
!shownFailed or someshit
HashSet<T> be quick as f*** . . .
yeah! I need to play around more with them only used a couple of times.. I'm slacking ๐ฎ
Queue<T> and Stack<T> have their uses, as does List<T>. it really depends how you need to access the elements . . .
List<T> is simple and easy because it appears from the inspector . . .
yeah thats the main benefit in unity tbh lol
I was working on a line checkout for a store and queue is perfect but its just a pain to debug
I'm trying to ween off using inspector for any debugging though its a bad habit but so eez lol
It does seem a little strange that Unity doesn't provide serialization/editors for some of the other common collections
always wondered, why aren't things like [,] arrays serialized?
btw, if you're doing pooling, look at the UnityEngine.Pool namespace
the unity pooling is great ! it takes care of the heavy work for you
the same problem i have as well . . .
I almost exclusively use it for list and hashset pools
sometimes going too hard and making custom inspectors like whyyyyy
what makes it a bad habit?
I try making everything onscreen now like a UI though. It helps to send a tester/designer just the exe and they can just tune it
@rich adder true, they do have one now, but i kinda like mine. maybe i'll let at theirs and derive a new one to fit extra functionality . . .
you wind up serializing a bunch of random junk you don't need
It would be nice to have a way to explicitly draw extra fields into the inspector.
yeah its just a mess
You'd need a wacky custom editor for that
let's be fair, all of it is junk, but necessary junk (at least, we think so) . . . ๐
alright.. u called me out just a bit ๐ค
when I can I do use the Debug mode now, fun fact. You can pop out one component you want and put debug mode only on its inpsector
right click > properties ftw
i do that often to record video's and dock the relevant inspector on top of the game view
I've written a decently elaborate debug system
It draws everything with IMGUI
I need to fix the layout again...
the IDebug interface requires a DoDebug iterator method that can yield other IDebug objects
is IMGUI still good to use?
I heard we should not use it anymore
ohhh vewy nice!
neat!
Depends what for.
I only use it for debugging purposes
It generates a crapload of garbage
All of my actual UI is UGUI-based
This lets me make a tree.
Still trying to figure out if I can use scroll areas...
as far as I can tell, I can't tell IMGUI to make a scroll area that can also shrink if its content is small enough
oh didnt even notice this thing was here
https://docs.unity3d.com/ScriptReference/GUI.BeginScrollView.html
haha yeah this feels like I'm undoing everything I learned in UIToolkit
Can someone help me? Can I detect when someone leaves the game? Like to detect if a function is the last one that its called?
"leaves the game" is very vague
Is this a multiplayer game? Networked?
A singleplayer thing
Unplugging a controller? Leaving a physical zone?
i'm trying to learn UIToolkit for creating my own inspectors. it's . . . trying . . .
Ig so
Its basically, when someone basically leaves the game, like if on a phone, delete it from the apps open, or pc, alt f4 ed
There's no gaurantee you will be notified if you get alt f4ed or deleted from open apps on Android etc.
i recently added context menu portion to my inventory and I'm getting errors
with selector and forced selector scripts when entering a new room and trying to open the inventory
the scripts work perfectly when opening the menu in the first initial room but only upon loading a new room does it do this
https://hastebin.skyra.pw/sulotuqumu.csharp selector view
https://hastebin.skyra.pw/ejexeturaj.csharp forced selector
the context menu: https://hastebin.skyra.pw/feluvasita.pgsql
note: the way level streaming works in this project is the player and menus are children in a dontdestroyonload object and are teleported to an exact x,y,z cord
But you can do OnApplicationQuit for a best effort. There's also https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html
Ill try to use it and see the best I can do
Yeah thats where I meanly use it , Custom windows / Inspector for my simple tools n stuff.
Lucky I don't have any old GUI habits to shake off so transition was easier.
I do not use UXML though or their editor , I do everything in C#
Seems pretty clear that you don't have an event system in the scene
I've been playing with an asset that lets me write my UI Toolkit interfaces as a Preact application... it's great fun - at least coming from a web background. I like it more than the UI Toolkit editor stuff, anyway
Its perfect. Thank you @wintry quarry & @raw token!
im gonna be so done if this is the solution
Bsaed on the error I don't see what else it could possibly be
omg thats what it was
i thought about this approach, but i really like how you can create your own drawers with the visual editor. i'd use the builder pattern to make using C# easier though, it's a bit of boilerplate to create everything
my issue right now is displaying derived types (the correct drawer based on the value of a field) . . .
I have zero experience with UIToolkit outside of creating basic property drawers via code
I need to try out the visual editor at some point.
yeah never tried visual editor
the visual editor does seem appealing though, it just looks limited but idk never touched it lol
there is a lot of boiler plate in c# for sure but you can easily write your own VisualElement components so they can be easy to bring into other projects
yo, I was trying to make a game but I had a issue where I can use WASD to move my little 2d cube but I wanted to make more effects like speed increase over time and slowing down so its not so snappy. anyone know a way I can do this? Also, how could I figure out when the object touches the top of a collidable object (the ground) or when it touches the side of a colliable object and run a function with that??
GetAxisRaw
idk what that is (I code in C and not very much C# ToT)
ToT?
As to the second question, OnCollisionEnter has a Collision object which you can get the hit normal from and check if it's vertical or horizontal
It is a method. Always google things you don't know
ToT = Crying emoji
@swift crag oh, the visual editor is just for viewing, i have to figure out the code to display the correct property drawer: to display the Stat or Resource class based on the value of the type field . . .
something like this ? maybe I misunderstood
https://docs.unity3d.com/ScriptReference/SerializedProperty.FindPropertyRelative.html
hey guys
i have a configurable joint a collider (not trigger). so basically this joint conflicts with the colliders and makes it buggy (throwing me everywhere)
how could i possibly fix this?
If your rigidbody is getting pulled in one direction and the joint is trying to do something else, then you're going to get bad behavior
could you show us the problem, along with how you've configured the joint and the rigidbody?
ok lemme upload a video
as you see on the video, when i grab and stand on the collider, it just throws me everywhere
well thats just an exploit.. i dont think u should be able to stand on the thing ur holding..
what
couldn't u just put a limit on it.. so u couldnt stick it up under ur character?
You're getting into a "troll physics" situation (:
the physics system isn't fully accurate; it can't understand that you're pulling on yourself
funny thing is that in editor it works lol
no throwing here
we called that "prop surfing " in gmod
its pretty easy to check with a physics query or even just a dot product if you're above a prop while holding
ya, i was young and dumb.. now i could probably fix it
never too late!
erm
lol, its been deleted.. all i have is memories
SOT clone anyway.. wasn't anything special
you never know, it can turn into something of its own. not a lot of good SOT-like games out there
i mean.. the physics pickup was cool.. but it was more trouble than it was worth
also had to contend w/ walls and stuff
u could rubber band the prop a long distance from ur hands
if i were to do it again id come up with some kinematic solution
kinematic is good too, with dynamic you just have to have more checks in place cause it has a mind of its own lool
perhaps locking the object to a container
and using regular rotation methods to rotate it manually
instead of letting it get hung up on things
ya, the edge-cases are alot to deal with tbh
hmm todo:
to physics or not to physics.. that is the question.. ๐ชถ
love this mechanic.
i wish i could help the guy above but i don't/can't do VR but it should be pretty similar
video no worky
damm thats fire
not really sure how he does it.. i've asked him before and he told me it was proprietary ๐
its the exact low poly style i want
his lighting/colors pop like a mfr
oh i was looking at the magnent part not the lever lol
the magnets cool, but i know how tha tworks
im not sure if he's using a hinge joint on the cursor..
or if hes just using lateral mouse movement and rotation
yeah hinge is what I would use and get the "pull" direction
you mean a hinge on the lever or the crosshair?
the lever
oh yea ofc.. but im thinking he might connect it to a dummy object in front of hte cursor
to do the actual pulling and pushing..
that i can't say for sure tho.. i need to experiment ๐ฅผ
i'll report back w/ my findings
Would make an interesting mechanic within itself
Hello guys! I found this script that you can use in order to get a gameobject in 2d to follow your mouse but it seems it doesnt work. I know that I used it several times in the past and now it seems like I made a typo or something. Can anybody help?
using System.Collections.Generic;
using UnityEngine;
public class Drag : MonoBehaviour
{
private Vector2 mousePosition;
private float offsetX, offsetY;
public static bool mouseButtonReleased;
private void OnMouseDown()
{
mouseButtonReleased = false;
offsetX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x;
offsetY = Camera.main.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y;
}
private void OnMouseDrag()
{
mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector2(mousePosition.x - offsetX, mousePosition.y - offsetY);
}
private void OnMouseUp()
{
mouseButtonReleased = true;
}
}```
I assigned this script to the gameobject, putted rigitbody 2d, gravity scale to 0, sleeping mode = neversleep ; box collider 2d, isTrigger = on, and still 0 result
@full kite were they helping you earlier ?
you shouldn't tag people into your questions if they weren't actively helping you
yes, it was working earlier but now it seems like I made a typo or smth
oh
yes he did
earlier
ok but still they might be busy or might not want to be pinged for every issue, just post the question and someone can chime to help
oke
can you show the setup where you put this script
i dont know whats going on here (the error about VCS client not the UI being wrong)
so drag is on a gameobject that has a collider?. You should not drag a gameobject with a rigidbody like this btw
and you tell me that I should delete rigitbody 2d from the gameobject?
depends what are you trying to do with this drag exactly ?
I don't understand what about them and what does rigidbody have to do with it
Are you using Unity VCS/Plastic?
this is the link to the script https://www.youtube.com/watch?v=9-ok9Cn3d90
How to merge two objects to get a new one? That is what this video is about.
TO BLAST! - My New Fun Relaxing Puzzle Game Available On Google Play Store
https://play.google.com/store/apps/details?id=com.ZoGames.ToBlast
Not only your hands are responsible for aiming ability :-)
Logitech G305 LIGHTSPEED Wireless Gaming Mouse
https://amzn.to/2VxEO...
i dont think i am? i finally decided to come back to this project and suddenly somethings wrong
Without the last function is my entire script
it was working perfectly when i left it
cringe ok but I get it, just so you can easy use Triggers.
so what happens for you in playmode instead
they dont move at all while trying to drag it
did you check the console window for errors?
0 errors
show me in playmode
I've never used them, myself. But I think it's often packaged in many of the templates. And frequently seems somewhat error-prone.
You may be able to just remove the Unity VCS/Plastic package from the package manager.
Ah probably "Version Control"
using System.Collections.Generic;
using UnityEngine;
public class Drag : MonoBehaviour
{
private Vector2 mousePosition;
private float offsetX, offsetY;
public static bool mouseButtonReleased;
private void OnMouseDown()
{
mouseButtonReleased = false;
offsetX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x;
offsetY = Camera.main.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y;
}
private void OnMouseDrag()
{
mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector2(mousePosition.x - offsetX, mousePosition.y - offsetY);
}
private void OnMouseUp()
{
mouseButtonReleased = true;
}
}
``` and entire script
you have multiple things going wrong here
seems you accidentally made it a UI object
its supposed to be a regular Sprite Renderer object
also no clue why your Image component is scuffed.
first of all you're forcing transform on a rigidbody thats a big no
use torque at minimum
erm its a child of the minecart
thank you. This thing worked
But why sprite renderer instead of Image?
If I can know
Ofc
Image renders on a completely different space than world.
Sprite Render is inside the world, you dont want to add physics/colliders on a UI object since it lives on a screen space
i have a probleme with my code that manage my inventory, when i click on the button to go to the next or previous item, after that, when i jump it pass to other item and use some, only when i jump, and when i click a it does not use my current item
invetory script : https://gdl.space/gebidareso.cs
item script : https://gdl.space/akapizocil.cs
can you elaborate 
you need an additional object that is tied to the cart
Thnak you for this thing. Appreciate it!
i made a parent for the lever?
use for example a FixedJoint
so fixed for the parent of the hinge, then you can keep the hinge for rotation purpose
how is the cart moving btw
splines
i had another kind of hinge joint and it worked completely fine ๐
lever IS parented??
so it has a rigidbody
is it set to kinematic
show the setup / inspectors
oh and we're in a code channel this isn't really a code issue
I don't understand why I'm being told this bool can be removed because it's not used? It is being used in the NPCFacePlayer Method. If I remove the bool, I get an error in that method. I keep getting an error message in Unity saying that it can be removed and it's annoying. Is this a bug or am I missing something?
where are you using it ?
you're only assigning it, that's not using
You're writing to it, but never reading it
erm so i added a rigidbody to parent, set to kinematic, and assigned it to "connected bone" in the lever higne joint
it work
I'm not sure I understand what you mean
assigning values isn't the same as using that value for anything
I'm using it in the NPCFacePlayer method, in the If statements
How can I get rid of the error then?
either do something with the bool or remove it lol
hiding warning is just a band-aid
why are you assigning value to it if you're not using it in a if statement or something
Ooooh shit, I see what you mean lool
I've come back to this project after like 2 months of not doing anything, I must've written that for debugging and forgot to delete it
๐คฆ๐ปโโ๏ธ
oh haha
maybe you were trying to use it as a field for a get property ๐
can come in handy I suppose
public bool IsFacingLeft => isNPCFacingLeft
You'll get warned (or even get an error) when you do something that the compiler knows is pointless
3; // unacceptable kind of expression -> error
bool x = true; // never used -> warning
transform.position.x = 3; // transform.position is not a variable -- it's a property, so it's really a function call that returns a Vector3
actually, i don't think it's a warning to have an unused local variable
it just gets grayed out
very dumb beginner c# question but if I inherit from another object do the usings from that object's file get carried over
Nope.
ah I see im trying to find out why my debug.log has ambiguity
using strictly affects the file that it appears in.
You probably have a using System.Diagnostics;
System.Numerics is another nuisance with Vector3
is there a way to change the default file unity creates when you make a new script?
oh i googled
theres a unity article on it but no docs
I'd like to know what you find. Last time I looked, the docs I found were outdated... I vaguely remember there being a more recent solution, but I don't remember what it was
Awesome!
3 years into unity i can finally stop removing the comments that come with the script every time
im not sure what #NOTRIM does though
problem is you have to do it for every installed version there is no central repository
keeps ur whitespace
so ur methods aren'[t on top of each other
sorry, missed this. that's part of it. i'm using a value changed callback
TypeObjectField = Root.Q<ObjectField>("type");
TypeObjectField.RegisterValueChangedCallback((e) => UpdateStat(e));
```for the object field to check the new value. i try to assign the property (referenced from `PropertyStat = Property.FindPropertyRelative("_stat");` based on the `Type` of the new value of the `_type` field. at least, that's what i can remember. i haven't check in a long time . . .
Oh I see yeah, I still haven't gone that deep into UIToolkit esp with editor or dealing with more complex classes. Most I did with object field, though similar with what you did here but without the Q since I'm building the tree in c# directly
ojField = new()
{
name = "A",
label = "SpriteSheet",
allowSceneObjects = false,
objectType = typeof(Texture2D),
};
ojField.style.paddingTop = 16;
ojField.Bind(new SerializedObject(this));
ojField.RegisterValueChangedCallback(TextureObjectChanged);
root.Add(ojField);```
the whole binding process is still a bit confusing without using uxml
Yep, that looks pretty similar. I believe mine is bound, but I should double-check. When I have time, I'll look at it again
My object field is a custom Stat type with a custom property drawer. The same applies to the derived Resource type so that could be giving me issues as well . . .
Is there a way to disable all user inputs without using a global boolean?
Just curious
If you're using the Input System you can just disable all the action maps
Use a global integer and check if it's == 0 
Interesting, I'm not sure that's my case
I'm not aware of a built-in means to like pause or disable input using the Input Manager... but that doesn't mean it doesn't exist ๐
I gotcha haha
I just added a global boolean to my game and called it a day
it only had 1 input point, so no worries
hey I have a question about animator override controllers if anyone has a minute
my bad
having trouble making my animator override controller be active when i transfer to different scenes. it works when i equip it in the customization screen but doesnโt save when i transfer to a different scene
DontDestroyOnLoad(gameObject);
it works when i equip it in the customization screen but doesnโt save when i transfer to a different scene
Nothing you do in the old scene will affect anything in the new scene.
I'm unclear what you're doing here, exactly -- are you expecting a player prefab in Scene B to reflect the changes you made to the instance of the player in Scene A?
I've got a Question which Image Format can I use for my screenshots so I'm able to send them into the group as I've got told earlier you lot don't Approve jgrx
yes
well, that's not how Unity works!
it destroys everything in the old scene
the new scene is loaded, and all of the stuff in it gets created
ohhhh
You could use DontDestroyOnLoad to move the player into a special scene that is never unloaded
Alternatively, you'll need to remember the changes you made (probably in a "game manager" object that lives in DontDestroyOnLoad!) and apply them every time the player is created
hmm okay i think i got that
actually that will work perfectly because every scene iโve just been copy and pasting the background and player
thank u thank u ๐
You'll just need to make sure to create the player once when the game starts
You can check if a player exists and instantiate a prefab if you need to
yes thank u that will also work great. I appreciate it iโve asked this question on so many different platforms and havenโt gotten an answer. ur a life saver ๐
Is this the right spot for animation help?
Thx
Hey, quick question! Just wondering if anyone knows what the most performant solution would be to dynamically creating a sprite which would be used in a tile-based pool system, each "pool" would be split into tiles and each tile would be 16x16 pixels, I am currently trying to find a solution to creating a sprite that based on a "fill" amount of each tile would determine how many pixels tall that tile would be dynamically, the only issue I have currently is finding the most performant solution to creating 16 possible "liquid fill" sprites, ideally this solution is dynamic and would be able to be reused by changing the color for different possible liquids. Any thoughts or ideas would be amazing! Thanks.
There are quite a few (potentially hundreds) of tiles per pool so performance is definitely key, however since each tile is only 16x16 I'm sure it's not too hard but other than creating all 16 "possible" sprites I am a little lost for where to go, I know there's definitely a way to dynamically create sprites based on parameters but I cannot find a good solution as to how!
Why would you need to create the sprites dynamically when they can be premade and reused
The liquid simulation sounds like the real challenge here
I don't necessarily "have to" create them dynamically however, if I wanted a system that could have different colors of water based on the biome they're in and mix the colors of two merging pools of different colors dynamically I think it could be cool/useful to have it be dynamic, plus the memory overhead of swapping a lot of sprites might be a lot especially if I have many pools of different times besides water.
I created a cellular automata type system which works well, and is quite efficient with pooling, draining, etc. Controlled by a parent "pool" object, a lot of documentation on it so it wasn't too bad. Obviously it's not perfect yet but I am at the stage where I am confortable starting to integrate a proper visual implementation ahah.
plus with my current system I have a pretty nice "pressure" based fluid transfer system where pools will always try to level and overflow if there's not enough level space to fit all the liquid at a level plane! It's actually pretty convenient how it's working out, just trying to implement shaders and proper visual implementation before I polish all the bugs out.
16 16x16 sprites in memory sounds negligible
Tilemaps can handle hundreds of tiles and let you read and assign any color per tile
As well as any sprite
Yes, true however I determined that using a tilemap wouldn't be the best option for my liquid so they're just perfectly aligned gameobjects that are stored in the same layer which I'll pass as a render texture to the shader, I've been using separate "fill amount" sprites, but I was looking for a more clean solution if possible, especially if I wanted to change liquid based on whatever other factors I have in the project down the line.
I know I want more than just water, so having a universal dynamic 16/16px "liquid" could be useful to have in the liquid script, but if that wouldn't be performant I understand if that isn't worthwhile.
How did you determine that gameobjects would be better than a tilemap?
I made this system a month or so ago, so I am not 100% certain but I believe it was an issue with the way colliders were handled in a tilemap non-individually to one-another.
Hello. How can I change cursor on cursor pointer from script?
Also, storing a "fill-amount" or any data in the tilemap is significantly harder and requires a lookup table which again isn't good for performance.
So I just have a gameobject system that are able to be enabled and disabled based on when they're "falling" or "pooled".
You're using physics collisions to detect adjacent water tiles rather than reading the array?
No it's a raycast, it's only one raycast check per update, on only the spreading top tile of a "subpool" I call it, so essentially the phase right before a "pool" is determined.
So I guess technically yes, it is a physics collision but it is only a single one which is negligible performance-wise.
I assume that is much faster than having a dictionary for each pool, and having to lookup in that dict every update.
You seem to find very creative ways to work these problems
I would be more inclined to look for existing examples
Fluid and light pixel/tile simulations have been a thing in games for thirty years, there should be something
Yes, but it's not really learning or innovating to use other people's work which is really the goal. I have a very nice idea in mind for how the liquid will be handled.
I would also argue that both starbound/terraria are both heavily lacking in terms of how liquid physics is handled, on top of just being plain inaccurate it's also extremely laggy since each tile is updated separately, where-as my solution would only be updating the "pool", both cutting a lot of the overhead and the frame of empty space when taking water from the center of a pool as an example.
and for light there's very little documentation on how a process could be handled without light values per tile which again is not performant and also looks quite bad, Starbound does a pretty solid job of how light is done but only old documentation is available from what I've found :/
Doing something per-tile is not inherently unperformant in any way
Even if it intuitively might feel that way
Not implementing proper optimizations when doing so is the issue
That's true, however I've found cellular automata to be quite unflattering especially when draining even in the biggest games out there since they all seem to follow pretty much the same solution. I'm trying to improve on that concept by using references from cellular automata and creating my own rules which will allow it to be pretty much unnoticeable performance-wise but also look quite a bit better hopefully.
Also, allow for me to create "pseudo physics" such as pressure.
how can i solve it?
Liquid simulations are hard and when working in pixel space some issues are nearly unsolvable
Starbound has a lot going for it, the water system even simulates pressure differences
It's not strictly cellular automata
True, I agree that starbound is leaps and bounds above where Terraria is as-far as the physics goes, however still it is quite bland and unflattering even with a lot of what it has going for it, programatically it's great, visually not so much.
._.
try changing "TextEditor.content" to "TextEditor.text" as the error message says
hmmm ok then wait
If it's not one of your scripts and it doesn't seem to be breaking anything (even after an editor restart) then ignore it
it wont
If the error is not recognizable to us, you would have to give more details about what seemed to cause it
It looks to me like you're using a gui package that's outdated.
Generally if something is "obsolete" it means there is a newer solution and that support has stopped for the prior function.
Unity is very good at telling you when something has been updated and will often recommend the exact replacement for it in the error message.
can you paste in this chat both lines causing it
If that doesn't work and you want a really easy solution, I'd recommend looking to see if the package has been updated to the same unity version you're using, and if not maybe search for alternatives.
```put code inside```
Also use this to post code ^
I updated all packages before start hit play
Hmmmm it's tooooooooo long
Or U mean the line that has the problem?
only the lines causing it
are you using a package called "NGUITools"?
Uhhhhh let me check wait
Alright
Just send line 53, and line 58.
how outdated
Alright thanks for helping yo
This 10th time that I install unity again lol
nono, you don't need to reinstall unity!
Just the specific package you're using if it's been updated.
Because I got mad from these errors man
The errors will tell you exactly what the issue is, and what file they occur in.
I assume you're trying to make a UI?
ok so im following a youtube tutorial for a 2d game and i was doing the animations. one of the things was to flip it when you go in the other direction shown in the image bellow. however, my character sprite stretches out horizontally whenever i move. i'm pretty sure its because the code is actually making the size of the sprite 1 or negative 1 for the switch, but if i change it to the transform scale that i have my sprite at (so -0.7 and 0.7) it gives me an error?? so im not sure how exactly to fix this...
you want to be flipping the "Z" ideally.
this is the error
add float cast
put an "f" right after the numbers.
if you have a single decimal point that is called a "double" and will be recognized differently to a float.
placing an "f" directly after a number will always format it to a float.
like so?
start by making sure that your !IDE is configured so that it will underline errors in the code so you see them and can correct them more easily
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
โข Visual Studio (Installed via Unity Hub)
โข Visual Studio (Installed manually)
โข VS Code
โข JetBrains Rider
โข Other/None
Yep! But you also want to probably do one after the zeros in the if statement.
also a simple "else" instead of an "else if" will do the same thing and be marginally faster.
Another tip, avoid elseif, remove the if statement
this is not necessary
It should still work
I know but it'll make it less confusing most-likely.
Technically they are not the same. Currently, with else if, neither condition runs if xAxis is exactly 0 which might be what they want
they likely don't want it to change where there is 0 input on the X axis hence the else if instead of just an else
that's true, but if he's flipping the character he doesn't want 0.
Hi all, what Unity version do you suggest to use today for development purpose for a game that probably will be released in 2025-2026 (probably 2026 or more, it will be hard for 2025): It will be a mobile multiplayer based on Photon Quantum. I spen the today stream but I'm still unsure about what to use. Is the v6 a lot bugged now or it is ok to start with it yet? I want to avoid migrations if te 6 LTS will be available this year for sure, and I like something in v6 more than v2022. On the other ends, probably I'll find more exmaples, tutorials, and less bugs, in 2022.. Any suggestion will be appreciated, thank you!
would this not only update if there is a change beyond zero in the other direction?
the adding the f after the numbers worked thank you.
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using UnityEngine;
public static class NGUITools
{
private static AudioListener mListener;
private static bool mLoaded = false;
private static float mGlobalVolume = 1f;
private static Vector3[] mSides = new Vector3[4];
public static float soundVolume
{
get
{
if (!mLoaded)
{
mLoaded = true;
mGlobalVolume = PlayerPrefs.GetFloat("Sound", 1f);
}
return mGlobalVolume;
}
set
{
if (mGlobalVolume != value)
{
mLoaded = true;
mGlobalVolume = value;
PlayerPrefs.SetFloat("Sound", value);
}
}
}
public static bool fileAccess
{
get
{
return true;
}
}
public static string clipboard
{
get
{
TextEditor textEditor = new TextEditor();
textEditor.Paste();
return textEditor.content.text;
}
set
{
TextEditor textEditor = new TextEditor();
textEditor.content = new GUIContent(value);
textEditor.OnFocus();
textEditor.Copy();
}
}
!code
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
I am using Unity 6, it is stable for me, no bugs
you don't need to send the entire thing, just the two lines I said.
loooool
sorry wait
oh thank you
it's okay, haha.
I'd say just use the latest LTS unless there's something specific to Unity 6 you want to use
their current code will only change if input is not 0. so if there is no input on that axis it won't revert to the other direction (since that is exactly what would happen if they were moving left then stopped it would face right with no input if they swapped to else)
public static string clipboard
{
get
{
TextEditor textEditor = new TextEditor();
textEditor.Paste();
return textEditor.content.text;
}
set
{
TextEditor textEditor = new TextEditor();
textEditor.content = new GUIContent(value);
textEditor.OnFocus();
textEditor.Copy();
}
}
Ah, gotcha.
@digital warren This NGUITools is not an official package, we can't really advice how to fix it and there's no guarantee it has any way to keep up with your unity version
the unity 6 lts should be releasing in Q4 of this year so if that is the version you want to use, then it would be perfectly fine to use the unity 6 preview
Did you write this code or is it from a library
It's unity 6 ._.
this seems to be package-specific, so we don't know exactly what to do.
But the package might have documentation relating to how to properly use the "TextEditor"
It is from NGUI package
Nope just decomplie
An app
Is this package compatible with Unity 6
There's basically no reason to use NGUI any more, it's practically built in
I'm sure that package is not for Unity 6, just look at date of last commit to that file
this seems like it programatically makes sense, you really need to find documentation on that in the package.
so you're trying to decompile an application (presumably ancient) and then smash the resulting code into modern Unity
Ohhhh lol
This why then
Wait let me change the version
is it for UI?
Yuo
Decompiling is against the rules, in any case
I would find a recent guide on basic UI. And avoid third-party-packages almost always.
._. it's an old game lol
Still against the rules
that doesn't make discussion of decompiling or modding any less against the #๐โcode-of-conduct
Unity has recently updated the UI system, so natively it's a lot more malleable than versions prior.
https://www.youtube.com/watch?v=DX7HyN7oJjE Try this, and see if it suits what you're going for!
In this Unity tutorial we'll make a Main Menu.
How to make a PLAY button , OPTIONS button and QUIT button in Unity ?
Enjoy the video โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Hi Game developer
Welcome to Rehope Games I'm Murat
I share unity tutorial videos on my channel. if you want to make a game with unity (especially 2d platformer game), the ...
Hmmmm I see
I assume this teaches basic buttons and ui elements which you could apply to more than just a main menu.
Hmmmm ok ._.
It's in my opinion not very helpful to rip packages from online whenever you need something and instead try to find guides that can help teach the concepts of what you need going forward, learning isn't using already finished products.
So even if you think it'll slow down progress, in the long term it's way more worthwhile to just learn how to create whatever you'd like yourself, in all elements of game design, (barring maybe design assets if that's not your thing).
Alright man ._.
Good luck on your UI though! I'd love to see it when it's finished.

Wait I run the game Before in unity 6 lol idk why it's get this error again @lime pewter I face it before
And chat GPT helped me lol but idk why it getting back
Ok I asked him
Now I got 80 errors
I don't honestly know much about Unity 6, I personally have never used it.
GG
Me too
I liked unity 6 because it's has the ability to remove splash screen
This why I using it lol
this is possible in all versions prior to my knowledge.
Really?
I heard it from YouTube dude say unity 6 has ability to remove it without paying
Or anything
Yeah, I think you may need a license. Which you'd have if you were going to release your game anyway.
Hmm I see now
That could be true, but you really don't need it gone if you're only compiling for personal use.
you need unity pro to remove the splash screen in versions prior to unity 6. unity pro is not required to release on all platforms, just consoles, and also there's a revenue threshold that once you pass you must purchase pro
I personally don't use new versions until they've been out for a significant amount of time so documentation is less scarce. But there's a lot of reasons I avoid Unity 6 personally which I won't get into.
I believe it has a lot of native features which are very good for realism from what I've heard.
._.
https://docs-multiplayer.unity3d.com/netcode/current/tutorials/get-started-ngo/#the-helloworldmanagercs-script
I'm trying to follow this tutorial and I'm confused by how StartButtons and StatusLabels are static in the example. I get an error because m_NetworkManager is not static. Making that member static resolves the issue but I'm not sure if I'm misunderstanding something.
I think that's an error with the docs. those methods shouldn't be static since they access instance members
I guess the idea is that the buttons are only meant to be created once, or that there should only be one instance of network manager?
"network manager" referring to the entire class
ah yeah, looks like they've changed at some point and either should be using the networkmanager singleton or previously did. the snippet with those methods further down the page uses the singleton instead of the direct reference
Ohhh I missed that, thanks
This docs page https://docs-multiplayer.unity3d.com/netcode/current/components/networkmanager/ is using NetworkManager.Singleton so I'm assuming the change was just missed in that one section of the tutorial page? 
when i was looking into ngo some time ago, it was said there are very few people updating the docs (think it was like one person at the time). So yea often there will be mistakes or typos especially with a constantly changing framework
theres also the server for it pinned in #archived-networking
should i just put var everywhere as rider suggests?
if the type is inferred, i don't see why not?
Up to you. You can change that suggestion in settings.
It only affects readability (and whether it is better or worse is HOTLY debated).
if you have to stop and think what type it is, then no, i wouldn't use it . . .
i noticed that Rider rewrote all of my explicit types into var
i wonder if I can make its cleanup process leave simple types untouched
ah, you can!
much better -- it wanted to make everything into a var. I made built-in types explicit and used var when evident in other cases
But should i have var everywhere? Sometimes is good but not everything.
I found it very awkward in situations like this
var x = 1;
Maybe that's just because I'm used to using the explicit type for these "simple" types
you can read about how to configure things here
How do i forget the habit of asking wveryhting to copilot and copy pasting. I want to stop but it does everything I say perfectly I can't stop to think and understand wtf is he writing but it works to perfection I need tips
Every thing I ask he writes it perfectly. He's not longer copilot he's capitan I'm the copilot
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
hello, i am making fps shooter and my camera is jittery
the player is a parent to the camera and when i move the camera (like rotation) it is fine but only when i start moving and rotating the camera the camera movement is very jittery
the rigidbody is interpolate, movement is in fixedUpdate as it is rigidbody movement, and cameramovement is in lateupdate
please help (tell me if you need to see any code)
What about rotation? Where does that happen?
I need help with my code. I want to apply a force to the 0,0 point to simulate a gravitational body at that location. The problem is that the force just doesn't do anything. The rigidbody just sits there. I've tried with Vector2.up and it works so I'm not sure what the problem is.
public class Gravity : MonoBehaviour
{
public Rigidbody2D Rocket;
public float GravityStrength = 1;
void Start()
{
}
void Update()
{
Rocket.AddForce(new Vector2(0,0) * GravityStrength);
}
}
When you add force, it's a direction you're pointing it. You're giving it a direction of nothing.
If I added another rigidbody to simulate a planet, could I get that planet's transform and use it in my vector
!code
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
u can do anything pretty much
that's the hard part really, I see so many methods and none seem as simple as it should be
https://hatebin.com/qrdpnrgiyv I don't understand why this code works. The values being put into Vector3.Lerp through curve.Evaluate(sampleTime);at line 22 are crazy and are never between 0 and 1. This line if (sampleTime >= 1f) somehow works when sampleTime is in the 20s.
you should note that you are printing Time.time and not your actual sampleTime variable. so what you are printing has pretty much nothing at all to do with the value you are actually using
what part is hard? if you want gravity towards another planet, then you simply just get the direction from the object to the planets center and add force
if im doing a top down game and i have a doorway how do i make it so the player goes under the door way but renders over the wall
i also have props that need to render over the wall
not really a code question. it's a matter of setting up your sorting layers and stuff correctly
https://docs.unity3d.com/Manual/2DSorting.html
https://pastebin.com/c6DGanrs So i have this code here, and in my SetGrapplePoint void im tryna make it so if the player clicks close enough to a grappleable object it will auto lock to the surface of the object, it it works fine, the issue is that when a player clicks on a object to grapple it grapples where ever the player clicked, including the middle of the object, instead of the surface. example attached. how do i fix this?
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.
when u click the grappable object shoot a raycast towards it from the player.. then use the hit.point to set the grapple point (where it actually hits the rock)
okay got it
cool system so far ๐
https://media.giphy.com/media/3oEdv4fgCP53WxKG2Y/giphy.gif reminds me of this game Worms2 i used to play.. modded to allow ninja rope themed games
lmao i used to play worms on my 360
im tryna make a getting over it rage game thing
best game ever imo
i tried to do this and now it doesnt shoot at all
ik i did it wrong i just have no clue like how this works
why would that happen? the only thing u would change is hte location ur grapple targets
!code
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
o my bad
//Face mouse
Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
float rayLength;
if (groundPlane.Raycast(cameraRay, out rayLength))
{
Vector3 pointToLook = cameraRay.GetPoint(rayLength);
Debug.DrawLine(cameraRay.origin, pointToLook, Color.yellow);
transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
}
could someone explain to me why this code works to make my character face my mouse? im not really familiar with anything "Ray" related so i'd like to know how it works
Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); ur shooting a ray from the camera thru the screen, thru the mouse position, and hitting the level
thats ur point.. then LookAt just looks at that point
It draws a ray (a line with a statt and no end) from the camera through your mouse position (a point on the near clip plane of the camera) out into world space
LookAt() is just a magic unity function..
normally ud need to write out ur rotation logic as well
ur passing in transform.position.y soo that it doesn't look up and down. (basically looking at a point on the same height as the transform(player)
just left and right (x and z)
Imagine shining a laser pointer towards a plane in the scene (geometry plane, not airplane) from your camera at where the mouse is pointing. Then turning the character towards the dot the laser pointer creates on the plane.
instructions unclear -> swat sitting down the road
but in seriousness, you get all that Taf?
yeah i think i got it mostly
thank you for the help everyone
i just realized that im pretty sure the debug line isnt necessary at all and just to visualize the ray in the scene
Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); // you make the ray
Plane groundPlane = new Plane(Vector3.up, Vector3.zero); // you create a invisible plane oriented same as ur ground i imagine
float rayLength; // the length of the ray
if (groundPlane.Raycast(cameraRay, out rayLength)) // shoot the ray and if the ray hits the plane
{
Vector3 pointToLook = cameraRay.GetPoint(rayLength); // get the point where the ray hits the plane
Debug.DrawLine(cameraRay.origin, pointToLook, Color.yellow); // ur fancy debug
transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z)); // look at the point
}```
correct
okok i got it now
can you just use LookAt whenever you want anything to look at anything basically? itll do all the rotation for you?
yup
sometimes u want more complex rotations.. but LookAt() is pretty good when getting started
and if u dont want it to look up and down or left or right (a certain axis) you pass in its own transform for that property
like u code does for the y part of the vector you use
yeah okay i see that that makes sense
I'm really new to unity's Mirror networking, can anyone explain what this does
NetworkServer.Destroy(gameObject);
I had an idea of what I thought it did, but the behavior I'm seeing is not following that
destroy a game object on all clients connected to the server.
but when you say gameObject, that only refers to the gameobject that the script your in is attached to, right?
well w/e is in the ( )
gameObject is the gameobject the script is on correct (its the same as this.gameObject
but u could put any gameobject/ any reference in there
because I have this attached to a missile and when I shoot the missile with a bullet, it's supposed to destroy the missile on both clients
does it not?
but what it actually does is destroy the missile on one of the clients and destroy the player on both clients
that doesn't make sense
the player that shot the missile that is
this means it shouldn't be on ur player..
and shouldn't therefor destroy the player for no reason
void OnTriggerEnter2D(Collider2D collision)
{
if (isServer == true)
{
if (collision.CompareTag("Player") || collision.CompareTag("bullet"))
{
Debug.Log("network missile hit player or bullet");
NetworkServer.Destroy(gameObject);
}
}
}
this is in my network missile script
yea, unless that was yourPlayerReference.gameObject it wouldnt destroy the player.. just the gameobject that script/trigger is attached to
Don't you have to destroy via a [Command] function
yea โ๏ธ
ok lemme try that
wait
the example has the function with [Client] above it
do I need that?
or can I do this
i have no clue.. i make singleplayer games.. sorry
void OnTriggerEnter2D(Collider2D collision)
{
if (isServer == true)
{
if (collision.CompareTag("Player") || collision.CompareTag("bullet"))
{
Debug.Log("network missile hit player or bullet");
CmdDestroyObject(gameObject);
}
}
}
[Command]
private void CmdDestroyObject(GameObject obj)
{
if (!obj) return;
NetworkServer.Destroy(obj);
}
put a line break after cs
not sure what [Command] does.. but its some sort of attribute
The [Command] attribute in Unity's UNet (Unity Networking) API designates a method to be called on the server, even though it might be invoked from a client. When a client calls a method marked with [Command], the request is sent to the server, which then executes the method.
Unet is old
#archived-networking theres a mirror server pinned in there
Yeah I haven't used it, but I use NGO so its "ideas" are similar
yea, i figured the [Command] part was still relevant..
yea networking would know more about this stuff
i am trying to make a mouse movement script, it works kinda the only thing rotating is the camera ```using UnityEngine;
public class MouseMovement : MonoBehaviour
{
public float sense;
public Transform Player;
void Start()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * sense;
float mouseY = Input.GetAxis("Mouse Y") * sense;
float PlayerX = Input.GetAxis("Horizontal") * sense;
float PlayerY = Input.GetAxis("Vertical") * sense;
transform.Rotate(Vector3.up, mouseX);
transform.Rotate(Vector3.left, mouseY);
Player.Rotate(Vector3.up, PlayerX);
Player.Rotate(Vector3.forward, -PlayerY);
}
}```
howd u come up with this?
tutorials and stuff, i just gathered what i saw and tried making it
i tried my best to understand everything
never in my life i seen anything like that.. lol
this is how i do it.. you should only need (1) rotation method for each object
the fact u have 2 for each object is extremely odd to me
augh so much mathhh, ill look at the docs and stuff to try and understand what is going on
i wasnt sure how to do it
i just rip off mouse movements.. as its pretty simple and straight forward.. (pretty much the same)
i could send you my version if ur using 3D
I am using 3D
i started unity yesterday help
thank u
it is
ur camera rotates up and down... and the player left and right
i could show u a screenshot
the camera is working fine, it just needs limitations
the player isnt doing anything
yeah, im not sure what im doing wrong
mine looks different
whats different?
i changed my limits to 80
i cant understand this at all ๐
what do u suggest i start learning
or should i just rack up experience
!learn
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
thanks
hey fellas, i'm working on a top down game and struggling to implement bullets that travel in a straight line from where they're shot. any ideas on how to do this? do i need raycasts? i'm also planning to make them bounce llater, so there's that
So this is how I want to handle triggering a ragdoll on a bot's death:
The main bot object, like the parent of the rig and everything etc has a script called Human. and when the health is 0 out of 100, it calls a function called KillBot, This loops through all the body part rigidbodies and turn them on etc.
Each collider body part has a script called BodyPart. When lets say a bullet hits it, it does GetComponent<BodyPart>().DamageBot(100f), Each BodyPart script can access the Human script.
Im wondering if this is the best method, other than having one overall collider to register bullet hits, and then it would get disabled and the body part colliders/rbs enabled
scroll down to the where/how and theres some good resources i recommend @native hill
alright i will
spawn projectile.. rotate it so its transform.forward is facing the target.. and give it forward velocity..
should travel in a str8 line as is.. unless ur doing something weird to it
why do i get this error 4 times
not sure why, but it isnโt. gravity always seems to affect it
also, youโre always here to help people. youโre a real one man!
Disable gravity so its not getting pulled down
change its gravity scale to 0
probably because:
object is too large for origin
click it
it should highlight the object
(or maybe not, ive never had that exact error before)
its not highlighting anything for me like i can normally do with errors
hmm do you have any object that you know of that may have a really big scale..
or way off the screen?
already did
that's why i'm so confused
then why would gravity still be affecting it?
i have zero idea, i can send a video if you'd like
oh nevermind, i figured it out. just had something set up wrong lmao
(โฏยฐโกยฐ)โฏ๏ธต โปโโป
i know right
but now that i look at it, the issue is actually persisting
when the bullets fly for a bit, they start falling off
i mean, maybe it thinks the UI is a sprite? i can cintinue doing whatever i want without resolving these errors, but there are 4 of them and 4 coins so it has to be something in the coin counter scene
its a weird error..
b/c underneath it says UnityEditor..
those are usually Unity Bugs that disappear w/ restarts
BUT if its a UI element.. it may be something of urs.. u can restart and test maybe
every time i start the unity project i get the errors but once i clear the console they dont come back
hmm interesting.. i wonder if it would affect the build any?
see what i mean? ignore the ugly placeholder graphics lmao
it may be a non-issue but a broken editor..
@hybrid tapir hey, try resetting ur layout
did that
send a screenshot of the bullet prefab inspector
imma restart the editor and see if i get the errors again
id love to try that but for some reason unity wants the android sdk api level 39 when the highest that exists is 35
Did you save those changes on the prefab?
the errors came back
yep
tf?
now show me the bullet mover script
ironically, the movement doesn't happen in that script. here's the code for the bullet's movement though
\
GameObject bullet = Instantiate(BulletPrefab, Spawner.position, Spawner.rotation);
bullet.GetComponent<Rigidbody2D>().AddForce(Spawner.up * BulletSpeed, ForceMode2D.Impulse);
\\
well that ain't right. oh well
i see everyone using 33
no, it's on the method fire. could it be that the force is only applied at the start, not throughout, henceforth why it falls off?
so im looking at a question on stack overflow and theres different answers, should i just try understanding one of the easier ones or complex ones so i could learn more
thank you!
yes thats it
the drag on ur RB2D is slowing it down
soo it appears to be falling
i think
there's zero drag on it, though
i ohh ur right.. nvm
can u debug the velocity?
in update
and see what velocities its using
something weird is going on
i would be lying if i said i knew how to do that
i thought the issue is that force isn't being applied throughout?
if thers no gravity.. and no drag.. the force u apply to it.. would stay w// it
yeah, exactly
it'd be like pushing a satellite in space.. it'd just keep going the way u pushed it
that's why i'm confused
#๐ปโcode-beginner message debug the velocity.. and check that it only has forward velocity..
alright, let me see to that
huh?
what happens if u change it to AddLocalForce
let me check that out
sorry, im just spitballing at the moment. cuz i dont know what else to do besides just throw stuff at it lol
you mean relative force?
yea that
don't be dude, i can use the help
would this be the channel to ask about colliders? or is there a different channel better suited for that
you can also just set the velocity directly.. soo that way u know it wont change
rb2d.velocity = forward * speed;
depends on what ur doing w/ them.. if its related to code heres fine..
if its just about the collider and inspector u can ask in physics or unity-talk
okay thanks
set the velocity directly ๐
mkay, let me try that
bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(BulletSpeed, BulletSpeed);
how's that?
That would move BulletSpeed m/s vertically and BulletSpeed m/s horizontally
is that.. what you want?
i'd like it to travel in a straight line from where it's shot
not sure how exactly that translates into (x,y) consider that changes on the fly
I would get the vector from the direction and use that then
instead of making a new Vector
often for 2d that means either transform.up or transform.right depending on how it is set up
The transform would either be the player or a gun or some firePoint object
i had that before, spawncamp suggested that i add velocity directly
Well, what I'm describing would be used to set the velocity directly
I am only talking about directions
rb.velocity = transform.right * bulletSpeed
isn't this the same as what i had before?
ah, you're talking about transforming the object directly
No
I am talking about setting the velocity
oh. my mistake
best i can do for ya
transform.up and transform.right are just directions. they dont' actually DO anything to the transform
i set velocity directly in the Start() function of the projectile
right, well now when i shoot it, it curves hard right lol
nice video
agreed, thank you for the demonstration
whats the difference with getaxis and getaxisraw?
Former has smoothing
it goes from 0 to 1 with all values in between
the latter just jumps immediately to 1 or 0
Something else must be affecting it then
I see instantiate isn't makng it a child... is there another script on it?
i have the same exact thing here, why in god's holy name do i get different effects lol
idk who to ask for help atp
#๐ฑโmobile would be the best place
oh okay, thank u
im bummed out i literally got an android phone FOR DEV STUFF and i still cant do anything after enabling dev mode
mobile can be tricky..
i thought not being able to build to your device was just apples self imposed problem
a script on what? the bullet prefab?
just run in the simulator until u figure it out
Yes
nothing really, just some basic code to destroy the bullet on collision
Can you send a screenshot of the inspector showing the rigidbody of the bullet?
Ah, thx
here you are, friend
put ur bullet prefab in the scene and press play
see if it still happens (w/o instantiating it)
well, nothing happens. this is probably because the movement script isn't inside the prefab itself
Wait, when you say hard right, do you mean it comes out at the wrong angle, or it CURVES to the right.
๐ค why not
Wait what?
BulletMover is not on the prefab?
interesting..
on the cannon, pressing the fire button calls to the method fire. that's what both instantiates the bullet as well as adds force to it
Oh, you set the velocity in the code that instantiated it
BulletMover is on the prefab
that should work as well...
it doesn't actually move the bullet because i'm a sick man
hes got phantom code
i'm just cursed i guess? i don't know, why the heck is it doin that
hey do you guys know how to get suggestions like the ones this guy has
that tell you what types of things go in the brackets
you need intellisense. make sure that unity has visual studio editor installed and active
what do i do? quite the conundrum
delete it and re-do it
i mean, i'm just going to redo what I have here and reach the same result
first thing u need to do is get a 2d projectile to fly str8
worry about that first..
and then spawn it and rotate it or w/e
mkay
using UnityEngine;
public class ProjectileMover : MonoBehaviour
{
public float speed = 10f; // Speed variable
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>(); // Grab the Rigidbody2D component
// Set the velocity to be its forward direction multiplied by speed
rb.velocity = transform.right * speed;
}
}
heres what u seen in the video if u want
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
โข Visual Studio (Installed via Unity Hub)
โข Visual Studio (Installed manually)
โข VS Code
โข JetBrains Rider
โข Other/None
thanks, will use
as expected, i got the same exact results
just the one.
yes, i did. the bullets are falling straight out of the cannon like water droplets
it's .5 lmao
my mass was 1
... im lost for words
me too dude
me too
i must be doing something seriously fucking stupid, that or the engine doesn't like me
i seriously don't know
create a new scene.. drop the prefab in it by itself and test it..
the prefab itself doesn't do anything. the cannon has the movement script.
if it doesn't go straight.. send a screenshot of the prefab selected in the heirarchy and the mode set the pivot local
ya, put the movement script on the bullet
just make it move by itself.. in a str8 line.. w/o falling first
we're trying to isolate whatever is causing it to fall
mkay
u can spawn the bullet.. and rotate it.. and then let the bullets movement code set its own velocity
that way the cannon isn't telling the bullet what to do..
SOLID
Single Responsibility
why the fuck won't it let me add the bulletspawner into the script
i'm losing it
when i add it to the hirearchy i can, when i put it back into prefabs it dissapears
forget it, i'll go without that part
i'm done, i have no idea what the problem is and it absolutely refuses to work. i give up, goodnight
best take a break.. u might discover the issue in no time after some rest
on a side-note i almost crashed my editor ๐คฃ
here's to hoping, i appreciate the help
it creates a quaternion from euler angles. what is confusing about that?
i dont even know what any of that means ๐
i saw it in a camera movement tutorial video and im trying to understand it
Unity uses Quaternions.. transform.rotation is a quaternion.. (we humans usually visualize angles as 0 - 360*) the method converts what we associate w/ angles and rotations to a Quaternion you can use for functions that require it
a quaternion is a 4 axis structure used to represent a rotation. that's really all you need to know about that part. euler angles are the X Y Z angles in degrees you are likely already familiar with
Quaternions are 4 Dimensional ๐คฏ
can anyone help me with a animation problem here?
we can help w/ coding issues related to animation
i think its a coding error but idk
if its str8 up animation queries you can use #๐โanimation
explain and we'll tell ya
the animation is freezing at the frist frame and idk if its bc of the code or the Transition times
transition shouldnt matter until the end of the clip
https://gdl.space/osayolipib.cs code is here if you wanna look
if its freezing at the first frame i doubt its transition issues.. Unless its looping to an animation over and over and over
and then the animation might not get a chance to play
oh ok let me see
open up the Animator window while u play test..
and click on the object w/ the animator in the hierarchy
u can visualize whats happening
they'll be a white progress bar growing under the clip thats playing.. and then transitions will light up when it goes from one clip to another
it doesnt look like the Idle anim is looping it just goes to the walking anim and just kind stops at the first frame
like littary the bar just stops
sounds like a clue ๐
i'm gonna guess that's it is constantly reentering that state, perhaps due to a transition from Any State
what does that mean
โ๏ธ yay, validation
ohh
it means the issue is likely in your transitions
okok
wait let me Test something
ok yea ig its because i put coming from any state
my bad i was stupid
thank you guys
remember, Any State includes every state, including the one you are transitioning to. so you gotta be careful when using that and pay extra close attention to your transition conditions
whare i can i get help about tiles in unity 2d?
ok yea thank you ill rember that
To be fair, the #๐โfind-a-channel essentially says "go find the channel yourself"
yes, that's the point
That doesn't seem much more useful than saying nothing
People need to learn to show initiative, that is one small step in the right direction
Initiative is good. Dismissive response is not so good.
"Check out #๐โart-asset-workflow, but in the future try #๐โfind-a-channel first"
Nice in theory, pointless in practice
Empathy and kindness is free.
nothing about it was dismissive, you can be the one to always reply like this if you want. this is pointless bickering though
Absolutesly. But there is also the old adage, Give someone an inch and they will take a mile
Honestly, most people don't know about #๐โfind-a-channel
I think it is a good response
It shows all the categories of channels with descriptions, and is very helpful
can anyone hlep me
It can cut both ways. Treating newcomers with apathy / low empathy makes it more likely to occur again in the future.
If you say what you need help with, it is likely, yes
how to get first person template its not showing in templates
Requires editor version 2021 or older
You can also find them on the asset store from what I understand. You'd have to search though, I don't have a link handy
well i can't download bcz my wifi is trash
You do not need templates
there is no 3rd person game also?
If you don't see it in the list, then I guess not
2021.3 has First Person and Third Person Core
Yeah, they seem unwilling to use that editor
i can't download
well then
wait what so what is 3d core
its ur basic 3d project..
This is not something anybody can really help you with.
Well, like I said, you don't need to use any template. It just preinstalls some packages. You can use any template and achieve the same things
3d core is 3d project w/ camera and light
You having bad wifi is not something we can help you with.
they're really not that much different from each other.. (maybe some unity assets included in each)
i didnt asked you for help and i didnt asked for wifi well so thats not your fault ignore it just answer me direct dont be silly
who said that i came here for wifi?
i have some questions so what is your prob?
That is not what they are asking for help with. Not sure what you are trying to say. Especially after all that empathy talk lmfao
can i make 3rd person game on 3D
I misunderstood. I thought he was implying his main problem was his inability to download the template.
You can make it in any
Was my response directly unempathetic?
Yes
bruh then what are templates for
A starting point. They make no difference in the long run though. You can install anything yourself that you want
pro-tip.. unity is a 3d engine.. even 2D is basically 3d while ignoring an axis
;=;
I don't see how it would be. "I cannot help you" is not a lack of empathy.
And that is not what you said. Can you stop with all the drama
cya
Why are you getting so defensive?
I am clearly not. Sorry if I upset you. Gonna just leave it to you. Goodbye
I'm using UGS C# Cloud Code Module as a server, it's non-persistent.
The server handles all my combat logic, to prevent cheating.
Now I'm trying to add different spells to my game, with randomized stats.
The server will need to know these spells, again to avoid cheating.
But how would I get them on my client?
I'm thinking to save them in code on my server, since that will be the easiest to edit for me.
Then when a client loads the game, it sends a request to the server to get all the spell data? Not sure if this is a good idea?
There won't be a crazy amount of spells, maybe like 50-100 max?
See: Especially after all that empathy talk lmfao , a mocking tone, and And that is not what you said. Can you stop with all the drama when my exact words were: This is not something anybody can really help you with.
Let's leave it at that, then.
when making UI how do y'all embed 3d renders in? load another scene in parallel or just put the character somewhere in the world
If you mean like having a 3d object elsewhere in the scene rendered on the UI layer, you can do this by setting up a separate camera with masking to only capture the object you intend to display on the UI layer. Is this what you are asking?
For example, if the player is holding a sword, and you want to render the 3d sword object onto the UI rather than in real worldspace, such as in most FPS games. Like this?
yep I just wanted to know how others did it
on what is best practice
I am not sure if it is best practice, but I followed some docs in one of my previous projects.
The primary steps were:
- Create a camera elsewhere in the scene, and only capture the prop objects you want to render onto the UI
- Output the camera capture onto a UI Canvas element
when rendering dialogue like this do you use 3 cameras? because it feels kinda inefficient
the characters on the left and right are in the same scene
I think you might have to if you have three different perspectives you want to capture. Alternatively, you could genuinely take a picture of these characters, edit the image, and store it as a single image file, but I imagine you might be trying to capture animated characters
this is a live scene where they have expressions and stuff
like mouth movements, some particle effects
The others can chime in to suggest alternate approaches, but the only one I am aware of involves a camera outputting to a canvas element, since capturing an image/video from a scene necessarily involves a camera, I believe, though there could be other approaches.
https://docs.unity3d.com/Manual/class-RenderTexture.html
Create a new render texture, set the camera's target texture to the new render texture, and then create a RawImage UI element, and set the texture property of the image to the render texture from earlier. I created FPS overlays using this technique and I believe it is the standard approach. It will be slightly more complicated using three concurrent perspectives, though.
