#💻┃code-beginner
1 messages · Page 438 of 1
I have a question about deltaTime, just to make sure I got it right :
I should multiply a speed by deltaTime
but I shouldn't multiply a jump force by deltaTime
is that correct ?
no, when you do or do not use deltaTime depends upon the context within which you are using it
Sorry, I think my question wasn't clear, I'll give more context about my question :
The jump force is a force you apply one time during an input (so you apply the force one time)
The speed is a transformation you apply every frame in the update (let's consider the player always press the move key here)
Hy guys, why is my UI disordered when I enter maximized screen?
And you did not understand my answer because there are multiple ways of applying force and speed, some of them require deltaTime and some do not
How'd I get cursor position? I tried
var mouseWorldPosition = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());, but that isn't working
It happens only in Game screen but I dont know why
Does it have to do with the canvas scaler?
i think this goes here?
do objects from blender automatically have a collider or do i have to set that up?
you have to add it
and, no, it is not a code question
Input.mousePosition;
thank you
The same thing, but uses old input system.
thats how you do it with the old input system
public class HandIKCrawlSolver : MonoBehaviour
{
[SerializeField]
private Transform body;
[SerializeField]
private float footPacing;
private Vector3 newPos;
[SerializeField]
private LayerMask isGround;
// Update is called once per frame
void Update()
{
Ray ray = new Ray(transform.position,Vector3.down);
if (Physics.Raycast(ray, out RaycastHit hitInfo, 10, isGround))
{
if ((transform.position - hitInfo.point).magnitude >= footPacing)
{
transform.position = hitInfo.point;
newPos = hitInfo.point;
}
Debug.Log(hitInfo.point);
}
}
}```
I want to make it look like crawling but cant figure out how to fix the hand to the ground before next step
It's supposed to place item GO on cursor's position, but it's just goes to somewhere in the corner
Console.Log??
You mean Debug.Log?
A custom class and method of mine
Anyway world position and canvas position aren't the same thing, under most circumstances
What are the canvas settings
And what are the settings for the parent
#1265813900037853255 message I am back to the problem witht he number 0 not going up when touching a muon object...
Still doesn't seems to work; the same situation, object is somewhere in the corner
https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html if your camera is a perspective one, you need to give the point a z depth
You didn't give it a z depth
oh?
Look at the doc example
Let's try getting a bit more info:
Vector3 screnPoint = new Vector3(mousePos.x, mousePos.y, Camera.main.nearClipPlane));
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(screenPoint);
Debug.Log($"Translating screen point for camera at {Camera.main.transform.position} - Screen Point: {screenPoint} - World Point {worldPoint}");
Looks like there's something with this line
(don't mind that's it commented)
Without this line it's actually works more promising
I'm not sure what's wrong tho?
📃 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.
#1265813900037853255 message I don't get what i am supposed to do...
damn thats a long thread. whats the question?
They want someone to write an entire data persistence model for them and will bury you in unrelated screenshots and videos until you're just so goddam tired of explaining how references work you just write them code for them to copy
oh 😵💫
well they said that the issue is writting (new data) that creating a new one with no data and loading a value from it, since i am having a problem with it that saving the number of the ui text from the level select scene to make a number go up, and i need to do something that LoadData are being called
how would i split a string at a specifc character index instead of a character
like for example
instead of
split at a
it's
split at character 5
so like
string[5].split?
Substring
You'd use substrings.
https://learn.microsoft.com/en-us/dotnet/api/system.string.substring?view=net-8.0
Get the substring from 0 to 5, and from 5 to end
are u saving ur stuff into a serializable class and putting that inside a file?
https://gdl.space/tavelizuqo.cs muon counter which is just in the level select
https://gdl.space/haxaqixave.cpp the counter which is in the game stage plays
and not only that, i am supposed to call loadData somewhere https://gdl.space/opukavebud.cs
at first the numbers worked before that a number changes up when i touched a muon object, but not anymore after this
Your problem is that your overall design makes zero sense
You need to separate out your UI code from your backend
thats because its a combination of different people they pasted code together from
also what is IDataPersistence? an asset from the asset store?
they refuse to actually go back n redo it properly, they rather just scotch taping it together
The only things that are lost on scene load (assuming non-additive and not using DontDestroyOnLoad) are monobehaviors
So just store your game state in a regular c# object
and use monos to display it in the appropriate scene
If all monobehaviours that reference the poco are destroyed, it will be gc'd
Where do you propose to reference the poco if not using additive or ddol?
that makes 0 sense btw. You cannot store anything in c# objects without MB to be the containing class
You need a mono to run a poco constructor anywhere..
if the class is static thats another thing (but those dont have constructors so)
I'm very confused by what you're saying, just use an initializer + statics
It's some crap they copied from the top google result for "save system" and they are just winging it by smashing together random example code without regard to what it means
oh ok
. redacted
You probably have a scene (or rolled into splash) where you load the first sets of assets that you need, just initialize things then
Static constructors exist
also [runtimeinitializeonload]
This is not going to be a good suggestion for this person specifically
completely unrelated to OPs issue though
They don't need anything this complicated
Unless you want to spend the couple weeks holding their hand getting them set up for it
I'm just very confused by the idea that you need to use monobehaviors to store data
That's absolutely insane to me
throwing static at everything is more insane
A singleton is insane?
you don't need to use MB to store anything , no one is saying that
in a singleton pattern, only the instance is static.. Nothing else
Then maybe lets drop it. The context here is helping them.
Can you explain what you mean by this comment if it is too complicated for them?
#💻┃code-beginner message
backend?
Yes, and that instance is not going to be gc'd
I really do not get the logic in your initial statement
Unless you destroy the object, which WILL happen if not in ddol or additive which you specified
Then yes, of course it will be gc'd
we're talking about Unity specific
you're going off on some other shit
Why are you assuming the class inherits mono?
Im curious, show me how you can store data in poco class in unity without the class being static?
Why are you talking about things that are not relevant to linedol?
where it holds loadData and SaveData https://gdl.space/qoxosufate.cs
This is an interface. It doesn't "hold" anything. Just to be clear
oh
When instantiating an object, it has really small size in rect transform (can't even see it), compared to original GO. How can I fix that?
make the scale of the parent good
it's the same size as canvas
the text worked before with changing the nnumber up, but ever since the instance... the number doesn't change up anymore, and i did showed in a recent screenshot in the thread...
the same as the canvas ? that can't be right..
you should def not want that
What's the problem?
canvas isn't at scale 1,1,1 is it..
it is
hey dumb questin, what does .Clone do?
Depends on what you're calling it on but it probably clones an object
Not quite sure what you're asking for since this isn't even a question I've seen pop up before if you just approach a unity project as a regular C# project, but scene changes would have absolutely no impact on something like this
_dragParent is canvas children
so if i do
Gameobject.Clone it will basically do what duplicating it in the editor will do?
size of it isn't changing

Are you talking about the ICloneable member?
this doesnt make sense
but ok
can someone help me out
post menu class, but you have a couple different issues
and soemtimes, when things liek that happening... it amkes me sad, and it hurts...
and I think i forgot to tell you that the counter script is in the ui text of the coin counter.
bump
did you check the scale of what you instantiated?
what is that?
that is not the problem @hushed hinge
You're running a method you're not supposed to inside the initilizer
you have an array of menu objects, show your menu class since all of the errors are from trying to access things in that class
ah, looked at the wrong parameter; the size of original GO (in rect transform) is 100, 100, and of instantiated is 0, 0
I think I know how to fix it?
that with the whole new Data?
just set up the anchoring of the prefab properly
@steel stirrup this is my menu scrpt
Im talking about the erro you have in the Counter script.
You have first of all too many scripts to do specific saving
Well that's not what you're storing objects of
your array is Menu[]
that class is menu
show the parent you spawn it into
ohhhh
yeah look at the top of your menumanager script
youre using unityeditor
because that's probably
thanks tho
what error in the counter script? i don't have any errors in the counter script

that was something not supposed to be there and i have removed it
and counter seems to be not calling muoncounter since i've jsut the debug.log for it
like
if (muonCounter == null)
{
Debug.LogError("MuonCounter not being found");
}
else
{
muonCounter.UpdateText();
Debug.Log("number go up");
}
ever since the instance...
Hello, i've started with Unity and currently im trying to make a registration via Firebase
https://pastebin.com/WruP8g6L
That is my code
And that is my error:
Looking for help, I haven't found anything googling yet
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.
read the full error
also any other errors
that's just an "AggregateException" which is a grouping of other errors
without showign the full message we can't tell anything
Sorry mate, thats the full one
You should know by now why or at least how to fix it. This is nothing new to you, essentially doing the same things . I'm not sure how you still haven't seen that pattern
Are there any other logs? According to your code you should also be getting a log with a reason, no?
why do the objects in my UI get desorganized when I maximize screen?
Because you haven't anchored them properly
UI elements are positioned relative to hierarchy using anchors
Nop, thats all
no logs at all? Because line 180 has a log that should be printing
it won't be an error
just a normal log
thats what i see
ahh firebase..
do you have logs hidden? (Can't tell because I can't see the top right of your console)
This unfortunately tells us that it's just not one of those known error types
You can add a Debug.Log($"The error type is {authError}");
that may help a little
if it's just an internal exception on their server side then you should reach out to google - that indicates a problem on their server
it's a log statement
printing the error code
it's not anything to do with Unity other than the use of Debug.Log
Just printing the result of this which is in your code already
AuthError authError = (AuthError)firebaseException.ErrorCode;
Firebase is crap, the unity integration sucks
go with Mongo or even Unity's own storage is getting good
it worked before but not anymore ever since the instance, it's not liek i can write MuonCounter.instance.UpdateText();...
So you say i should switch to another one?
from my experience with these DBs and Unity , yes
my player only jumps if my jump force is a big value, why does it do that? this is my jump code
private void Jump(InputAction.CallbackContext ctx) {
if (jumpsLeft > 0) {
rb.velocity = Vector3.zero;
rb.AddForce(Vector3.up * jumpForce);
jumpsLeft--;
jumpTimer = 0;
}
}
is mongodb easier to setup
I can tell you even Mongodb has proper drivers for Unity
Unity has its own solution also called Unity Cloud Save
Why not. That is literally exactly what I had told you to write
That is the entire point of the static accessor
anyone knows why it only displays 3 and 1. supposed to also show 2. when i try it with countdown on 6 it goes 6,4,2,1
{
StartCoroutine(CountdownUI());
}
IEnumerator CountdownUI()
{
while (Countdown > 0)
{
CountdownText.text = Countdown.ToString();
yield return new WaitForSeconds(1f);
Countdown -= 1;
}
yield return new WaitForSeconds(1f);
logic.CountdownFin();
}
!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.
use ForceMode.Impulse
Do you modify countdown anywhere else?
You didn't set a force mode so its using the default
the number still won't go up though
Meaningless response
That has nothing to do with the issue
how would i get a component of a object by index?
What would the index denote?
@rich adder Do your maybe have a tutorial on how to setup Mongo or Unitys db, or how to create the authentication
well it doesn't have to be that, i just want to get the TextMeshPro from my object
this is usually not something you want to do, but it's possible using GetComponentAtIndex
GetComponent<TMP_Text>() ?
Assuming it is a text, because TextMeshPro is not a component
ok, i have wrote the isntance there
its still the same thing
someone should add dark mode to the tutorial
Not sure why you deleted it from the thread and reposted it here. But cool
idk, sometimes when i am getting anxious about something, i couldn't think clearly on what Im' doing...
they have on their website, I have a few videos on Cloud Save if you want
how and why did this randomly start appearing
you probably wound up importing system.numerics at some point
because you added using System.Numerics; to your file. Probably the IDE added it by accident
but it is not enough....
Then stop. Take a break. Go eat something, take a nap, and come back to it later.
As I said, that is NOT the issue
get component takes in a string
Nope
Not using the way I wrote it
There is another overload that does, but I prefer the generic overload (and you should too)
oh my god when did all these libraries get added
yeah thanks chat
Use the one with Generic
Don't use the string version, it's very obsolete
...... sometimes this doesn't help me at all since if i am anxious about it, i do not want ot stop and leave everything be like that....
that's not how generics work
That's not how you use that function
It's not a parameter, it's a type
first example, not second
Don't call yourself dumb
wow they finally fixed it on the docs.. they had the other ones above the longest lol
For one, it is SUPER annoying when people do that.
For two, you are just learning
i dont like being annoying
am I just supposed to leave the code like that..? I just don't want to leave it like that...
On your youtube channel?
for Unity Cloud Save yeah the older one, Trying to cover the new addition they did now you can save General data as well (gamedata) not just player data with C# (before it was only JS)
what are you looking to store exactly ?
First of all, everything for authentification, then character data, like gold, hp, dmg, stats and stuff
rpg game
well auth goes without saying when storing to db..
the auth is really easy to get goin in unity
email / password or just oAuth like google/ apple etc.
so personal Player data
then yes go with Unity cloud save
Alright thanks, i will do so
Ah thanks
using your usual first person capsule character (and capsule collider), how can i get the angle of collision between said collider and the floor/sloop bellow
your usual first person capsule character (and capsule collider)
There is no such thing as a "usual" character
every game is different
it would be more productive to show us your setup
no the capsule is the usual thing here not the player
give me a second
basically either:
- do a raycast and use the raycast hit normal.
- Use OnCollisionEnter/Stay and use the normal from the contact points
alright
oh just to make sure im not being stupid, "normal" here refers to a vector3 with those -1 to 1 angles for multiplying with other vectors
No it's a direction vector perpendicular to a surface
You're thinking of Quaternions probably?
No idea but normal vectors would be a concept in any game engine
Vector math is common to all game dev
facts! thank you quake modding and source engine for teaching this valuable lesson
Unity has a cool page on this
https://docs.unity3d.com/Manual/VectorCookbook.html
bet godot doesnt have that
Maybe with the notable exception of text based adventures on DOS
Interesting, TIL
Vector math is common to all aspects of real life, it'd be damn hard to move around without it
🧑✈️
soooo hi all!!! anyone got that easy guide for setting neovim as your editor in unity on linux (popos)?
also not really a coding question , more of a niche thing
Pretty sure neovim has a guide.
I did that a while ago and it is quite a few steps
Edit: looking now, I don't think it actually was from neovim, because don't see one
yup been doing that one all morning. thanks. can you suggest a better channel?
maybe #💻┃unity-talk but not really unity topic as its not officially supported editor
I doubt neovim is gonna play well with Unity, your best option is MonoDevelop
yeah but now we're just talking about talking so gonna stay focused on a solution. thanks for your resopnses.
okay. Well the guides are online, though as I said you're probably better off using VScode and customizing it a bit
you dont have to fiddle with omnisharp anymore since the Unity plugin came out
which guide are you referring to?
like this for example
https://github.com/walcht/neovim-unity
cool. best of luck mate
Hey guys, I was wondering if anyone here could help me out with an issue or is this the wrong channel?
If you have a coding problem, and depending on the complexity it's the right channel
Well, basically I was following a tutorial I saw online on making a 2d game but now my projectile attacks no longer show up(they’re invisible)
I'm pretty much "new" to unity, So I can't quite help, But I'm just waiting for everyone to finish thier own things
I tried almost everything but I couldn't figure it out, can you help me?
I see I see
What is ContactInfo. Where is that defined?
Which tutorial were you using though? Or specificly what code are you using right now?
check the location of your bullet in the Inspector. while the game is playing, send us a photo of the Inspector showing us the bullet created.
What is ContactInfo
I was watching a tutorial from Pandemonium
I’m sorry I’m not really sure how to tell
I searched up Pandemonium on youtube and it just showed me that one ultrakill bossfight
Try pandemonium 2d game tutorial?
alr
In part 8 he showed the fix needed but when I tried that it didn’t work
I skipped around and all I saw was him making a chainsaw and changing the layers
If you check 'Hierarchy' I think (if you're duplicating it) you'll see it pop up
in there
I reccomend check that out (maybe)
The thing is that the attack projectiles are in my hierarchy as prefabs, layer set as foreground and everything necessary from the video
But still isn’t working
😭
Did you set the "User Layers" correctly?
like don't set the projectiles user layers 6 and the background 7
I dunno just making numbers
According to the tutorial, I set the layer to foreground
Which should mean it’s above whatever I set as the background
I even tried removing said background but it’s still invisible
It says to change it to enemy (Maybe we're using diffrent tutorials)
you're using https://www.youtube.com/watch?v=YSzmCf_L2cE&list=PLgOEwFbvGm5o8hayFB6skAfa8Z-mw4dPV&index=8 right?
In this episode we'll add invulnerability frames to our health system after the player takes damage and fix a couple issues as well.
➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-7
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-8
Consider supporting the channel on Patreon:
➤ Patreon: https:/...
Yeah I’m using this
Well he changes the layer to enemy.
(on the chainsaw)
Ah. We are talking about the fireballs right?
I actually didn't see fireballs in the tutorial sec
I dont get what the anchors have to do with my UI moving wherever it wants when maximized screen
Ohhh
then you dont understand anchors
also not a code question
It’s somewhere under the fixes section . Like the near end of that section
I found it and also he clicks a little checkmark on the top
to enable it
In the prefab setting or the hierarchy?
I ticks?
are you clicking the fireball in Hierarchy to check if its on in Inspector?
AFK doggys begging for food
Wdym?
back
What? Just select the fireball in Hierarchy, Then
Check if its on in Inspector
Its off
The checkbox near the name of the fireball is off
When I turn it on and press play, it just for whatever reason turns off automatically
Sorry, bad habit 😭
then you have a script doing it
I use windows key + shift + S
I have a player attack script and a projectile script
this is a prefab what about in playmode
you have a reference to that ? thats the only way it would turn off by itself in playmode
I’m new to the whole unity thing so I have no idea if I’m going to be honest 😓
Anyone know how I can like, make it not a prefab?
Was working fine when it wasn’t a prefab tbh
I think Prefab means premade
like someone made it for you before, Or you followed a tutorial 1-1 in every way
Well I made the assets and animations and scripts myself. It only turned into a prefab after I put it in some folder
oh maybe its not a prefab and the icon just looks different on light mode
usually its not filled
Right lemme change to dark mode
This is a prefab right?
no this is a prefab
Did you manually turn dark mode to light mode? I don't remember having light mode.
Maybe I automatically changed to dark mode so easily I forgot doing it lol
The fact it literally says (Prefab) right next to the name is probably a good enough explanation
I don’t remember haha……
I'm just gonna google it
ah. I see
for them it says prefab at the bottom so 🤷♂️
but the icon was dead give away
Alright
as long imma make art designs for my game to take a tiny break from it
Did you make art designs more than anything else?
(like are you using it as an escape or something? (((just asking))) )
Yep, opened it
....iiiiitttt works?
It……doesn’t work
ok dont start it disabled
awh
just make sure check mark is on.
Why my bool variable animation end dont change (my variable is public , for call the function i use the event key in the animator)
!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.
you were told already how to share code @round mirage
ohhh
Check mark is one, but when I pres play, still invisible and off
@cedar zenith do you think you'll get this problem as a core memory that you wont mess up again when you learn what the problem was?
the layer is default
{
PlayerAnim.SetBool("isDrinking", true);
StartCoroutine(DrinkTime());
}
its `
like 3 of them
what about the one that spwans ?
show that one
Oh that? Yeah no it can’t spawn 😭
whats the original issue because I only got here
Layer was also default in the tutorial 😭
NAHHHH
{
animationEnd = true;
StartCoroutine(EndTimer());
}
IEnumerator EndTimer()
{
yield return new WaitForSeconds(2);
animationEnd = false;
}
turn it on enemy lol
I dunno I'd rather just give you to enemy
it wasn't that. but still
why dont you just use Animation Events
Wait but this is projectiles for the player’s use
i use it
i made tons of art for my game and other things
still it'll appear
so whats supposed to happen vs whats happening
I’m just gonna make a enemy layer then brb
I’M NEVER TOUCHING THIS SOFTWARE AGAIN AFTER MY ASSIGNMENT
But are you using the possibility of making art, just as an escape from other things or smth?
skill issue 😛
you still havent explained the original issue
This I will admit.
i don't get about you saying using it as an escape?
also you typically dont jump into such complex things without doing the learn pathways
Um, my projectiles now for some reason?
Yeah…..well, I’m trying to improve and reflect I guess
Well I'm stupid when I make games and I can't make anything a habit, I always accidently find work arounds of starting habits, and one of them was to just do anything else but scripting, until I just didn't have anything left but to script it, and cancelled the whole thing cuz... skill issue.
at the end of my animation the animation event is supposed to start and then set animation end on true my coroutine start wait 2 seconds and set animation end to false (when animation end is set to true i cant play again my animation)
Thanks @rich adder and @topaz ice for your help
aw
Yipee!! (wait we're done?)
Nah, I’m just gonna figure it out myself from here
😭
does anybody know some resources that talk about procedurally animated spiders? I have a working procedurally animated spider but it gets messed up when i try to make it walk on surfaces with steep slopes.
I think I need to cast some horizontal rays to check for obstacles in front since I'm only casting downwards rays from above every foot but I'm not sure what to do
i jsut wante dto take a break from it until i can come back to get help
Well honestly, If you're willing to suffer more, Uhh... just remember to refresh your mind a bit by taking a break at some points
Oh alr.
your projectile what for some reason ?
🫡
send !code with links
📃 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.
so i made this to make my player interact with slopes properly, as in; gaining upward momentum from quick movement up a slope, but it has it's jank, movedir.y still increases while going down and the player doesn't stick to the slope, any ways to fix that (or another way to do what this code does)? i can't think of any
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.
Oh crud. I meant that it was working fine until I turned them into prefabs according to the tutorial and now they’re invisible
i have already sent my code
you sent screenshots
you're reminding me of this video
It has something that moves fast like a spider and its also procedurally animated in some sort of way.
If thats what you meant you could check it out
It's been a while since the last video hasn't it? I've made quite a bit of progress since the last update, and since one of the things I worked on was some procedurally animated characters, I decided to make a video about the subject. In particular, this video highlights the entire process from initial motivation, to the technical design, techni...
not a tutorial
but he talks alot about the math
I've watched it and its a great video but it doesn't relate to my problem sadly
when they spawn ?
aw, alright.
and here
this is the current version
this isnt the whole script
Also you're in code-beginner
you could just go into #archived-code-advanced
or smth
ah alright
anyway after like idk 1 hour I can ask about my problem lol-
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
Debug.Log(mouseX);
Constantly prints 0 and maybe goes up a very small bit. (for 1 messege)
Is it like a project setting problem or something?
I also do
Cursor.visible = false;
Not sure if it'll do anything though.
MouseY works. fine.
I'm making a first person thing...
and its only detecting the mouseY not mouseX
dont use time.deltaTime on mouse inputs
{
private Outline outline;
private Rigidbody Potionrb;
private Animator PlayerAnim;
private GameObject Player;
private GameObject Parent;
private GameObject Hand;
private TextMeshProUGUI PickUptxt;
public float distanceFromPlayer;
private GameManager gameManager;
private bool Near = false;
private bool CanTake = false;
public bool InHand = false;
private BoxCollider PotionCollide;
private PlayPop playPop;
public Vector3 PotionPos;
void Start()
{
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
Parent = GameObject.Find("ParentOfEntities");
Hand = GameObject.Find("Hand");
PotionCollide = GetComponent<BoxCollider>();
Potionrb = GetComponent<Rigidbody>();
Player = GameObject.Find("Player");
playPop = Player.GetComponent<PlayPop>();
PlayerAnim = Player.GetComponent<Animator>();
outline = GetComponent<Outline>();
outline.enabled = false;
PickUptxt = GameObject.Find("PickUpTXT").GetComponent<TextMeshProUGUI>();
}
void Update()
{
if (Hand.transform.childCount > 1)
{
gameManager.ManageTake = true;
InHand = false;
Potionrb.isKinematic = false;
PotionCollide.enabled = true;
gameObject.transform.SetParent(Parent.transform, true);
}
```
alr
Mouse is already frameRate independent
{
PlayerAnim.SetBool("isDrinking", true);
StartCoroutine(DrinkTime());
}
distanceFromPlayer = Vector3.Distance(gameObject.transform.position, Player.transform.position);
if (distanceFromPlayer < 4.5f)
{
Near = true;
}
else
{
Near = false;
}
if (Input.GetKeyDown(KeyCode.E) && CanTake && gameManager.ManageTake == true)
{
gameManager.ManageTake = false;
InHand = true;
PlayerAnim.SetBool("isHolding", true);
}
if (InHand)
{
PotionCollide.enabled = false;
Potionrb.isKinematic = true;
gameObject.transform.rotation = Parent.transform.rotation;
gameObject.transform.position = Hand.transform.position;
gameObject.transform.SetParent(Hand.transform, true);
}
else
{
gameManager.ManageTake = true;
InHand = false;
Potionrb.isKinematic = false;
PotionCollide.enabled = true;
gameObject.transform.SetParent(Parent.transform, true);
}
```
use the links Like i said many times already..
its not that difficult to understand the basic instructions
ok
bro just sent the entire project code through discord chat lol
I bet they're gonna keep it up and send the link instead of editing the messages
how do I make it that when the vent is enabled the boolean is on (what I have now) but when I press E again it disables and the boolean gets set to off?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class freezebutton : MonoBehaviour
{
public GameObject vent;
public GameObject UI;
public bool ventOn;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void OnTriggerStay(Collider other)
{
if(other.tag == ("Player"))
{
if(Input.GetKey(KeyCode.E))
{
vent.SetActive(true);
ventOn = true;
}
}
}
}
this is what I have so far
!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.
use Links for large code
I'm sorry
called it
its not large
truely a master of time traveling
yes an entire class is Large
gulp
so the Coroutine doesnt work ? Did I get that right ?
nothing there sets ventOn to false
ik thats what im tryna find out
my variable animation end is not set to true
made this to make my player interact with slopes, as in; gaining upward momentum from quick movement up a slope, but it has it's jank, it still increases while going down a slope and the player doesn't exactly stick to the slope, any ways to fix that (or another way to do what this code does)? i can't think of any
quickly going to point out that i do know why this is happening
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.
then you are looking at the wrong code coz it ain't in that script
Its reaching. The last part (most important part) has debug.Log() printing the mouseX (which I removed the deltatime), And its constantly printing 0
ops replied to wrong person
myb
well maybe that part of the code is not reaching , how do you know . Put debug.Log there and make sure
i will try ty
its my End() function who dont work but i dont find why
Back! And I can complain more now!
Did the channel just die for no reason
He used End() on everyone ;-;
ok, since i have the instance there now, what do i do next?
where did you put the log
this makes absolutely no sense
why even make a static Instance if you're gonna use FindObjectOfType
or have a reference at all..
as it was told to you already .
I think you're confusing the Instance name you gave there, with what an Instance of something is
It s ok to write my input code inside fixed update?
sorry I have a question about (Debug.Log) ,it doesn't work.Can anybody help me?thanks.
add one more.. before the if statement Debug.Log("Make sure the Collision is registered");
and then go from there..
if u get that log and not the others.. then ur tags are messed up.. and CompareTag("TagName"): is better than gameobject.tag
Input should be in Update
ohh thats right.. OnCollisionEnter.. only happens when u enter the triggeer.. ud have time the Keypress to be perfect for it to work
Because two different StackOverflow questions had those different things and they don't understand either
you'll never be able to use the input like that
ok so ive been trying to figure this out for like an hour now
i have this:
SpeakerLib[CurrentDialogueFileIndex].ToString()
which prints as
!
when i do
print("!" != "!")
it prints as false
but when i do
print(SpeakerLin[CurrentDialogueFileIndex].ToString()```
it prints as true
ahh now that makes more sense than looking at that code any longer
Log outside of any of the if statements and see if this object is colliding with anything at all
despite SpeakerLib[CurrentDialogueFileIndex].ToString() being equal to "!"
And i make bool variables and i say if(input.getkey(keycode.space)
Jumpbuttonpressed = true
And in fixed update i write
If(jumpbuttonpressed)
Jump
LOL I know.Thank you very much.
yes
Are you sure it's not ! or something similar?
Yes. The important thing is that you set it in Update, and un-set it in FixedUpdate. You don't want to do Jumpbuttonpressed = Input.GetKey... because multiple updates can occur between FixedUpdates
Change your log:
Debug.Log($"[{SpeakerLib[CurrentDialogueFileIndex].ToString()}], length: {SpeakerLib[CurrentDialogueFileIndex].ToString().Length}");
you mean that
the static instance from the muoncounter?
but he gave it a thumbs up in the screenshot
should i remove
muonCounter = FindObjectOfType<MuonCounter>();?
Ey, there you go. It's not "!" it's "\r\n!"
You have a carriage return in your string
carriage return?
Line break in both windows and unix styles
two characters so that there's a line break regardless of which OS is viewing it
ah that makes sense
That's why there's three characters in the string
is there a way to write that as a string?
That should work. Pretty sure C# trim gets rid of newline characters
let's see
Make sure you add the trim to the debug log to see if it's properly removing it
are you asking me because you know why you should remove or just because I said something. Huge difference, you wont understand why you're removing it then we're gonna go in circles..
because since muoncounter is already being called from the private MuonCounter muonCounter
if you already using MuonCounter static Instance there is literally no point of searching for the component and storing it
but yes you are blindly copy and pasting and this will happen until you learn to apply a bit of your own critical thinking to what you're trying to accomplish
ayyyy there we go
tysm i would NOT have figured that out otherwise ;-;
if i remove private MuonCounter muonCounter; then the underline with the muonCounter in
if (muonCounter == null)
{
Debug.LogError("MuonCounter not being found");
}
else
{
MuonCounter.Instance.UpdateText();
Debug.Log("number go up");
}
would have a red underline, and even if i remove that and keep MuonCounter.Instance.UpdateText(); it would be an error when i start the gaem and go in a stage scene, wouldn't it?
...imma try
@rich adder can you help me with that code
not sure it is the code now that I see it, i think the first issue is related to velocity being applied while collding which is wrong normally
people use the physics no friction material but I think its a poor band aid, good way to fix it just raycasting and making sure you are not blocked when moving forward otherwise dont apply velocity that way
You know why you have a red underline..
why even null check on something you dont need
yes
Instance is assigned in the other script you dont need to null check the field
just dont call this before that assigment in awake/start
if(MuonCounter.Instance)
MuonCounter.Instance.UpdateText();``` at most..
and even thats overkill..if you have good design these arent generally needed
did yuo read the rest to what I wrote
now you jsut can't moe when you're grounded
dont apply velocity if you're blocked
same check you do for grounded you do it for infront of you
also why are yuo only moving horizontal if not grounded.
it's not just if stuff is infront of you, literally if i just jump with nothing around me i go into the ground and then get placed back
this is wrong
rb.velocity = new Vector2(horizontalInput * moveSpeed, rb.velocity.y); // Apply gravity rb.velocity += new Vector2(0, -gravity * Time.deltaTime);
if(MuonCounter.Instance)?
if(MuonCounter.Instance)
{
MuonCounter.Instance.UpdateText();
}?
what should i put instead
well first of all rigidbodies should be moved in fixed update
also why are you manually applying gravity that way
why are there two ifstatements, also why ask me something I wrote it literal
not two ifs, i was asking if the second one was it you meant?
like I said its totally overkill but thats what you would check if you changed the original if statement from field you had
get it?
Instance is the script already
yeah
Ok so just load the data before setting the text ?
if you already did it then verify it works
well.... i don't know if it works since the number is still not changing up when i touched a muon gameobjecti in the other scene
also about load the data before setting the text, i don't get what you mean there
@rich adder i changed it to using unity's default gravity but it's still happening
what?
idk. show current code and inspector for the object
i am currently stuck about it...
idk at this point your spaghetti code is confusing me as well
i just wanted that the counter number can be able to go up when you touch a muon object and not staying at 0, especially when you exit the game
yes and its been told you hundreds of time, you need to learn data persistance
you just end up writing a lot of spaghetti code because you just copy and pasting everyones code
try changing Collision Detection to Continuous
or do jump with AddForce instead of .velocity
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
i never used .velocity for jump so idk
This is the last I'm going to give you so pay close attention.
- Create a Singleton that has variables for the counters.
- Your UI should reference the instance of the singleton to know what number to display.
- Whenever you touch a "muon object", increase that variable in the singleton instance.
- Whenever you need to save or load, write those variables to disk or read them back to change the variables on the singleton instance.
This is the entire process. Boom. Scene-persisting saveable data.
i tried both
neither works
both what?
how did you write the new code send
exactly this except 2D
ForceMode@D
rb.AddForce(Vector3.up * jumpForce, ForceMode2D.Impulse);
hmm yea idk I use this without a problem. You tried with the default setting in the physics2D page
I've got an issue where my input script for my player character is getting big, any suggestions on how I could improve this?
- I did made a singleton in MuonCounter
- the number which should change is _amountMuons
hello...
is there a need to crosspost this?
https://gdl.space/gaginiyuzu.cs does the playermanager count as a singleton?
I want to call this value 'ListIndex' from the script cui. PotionList is used fine without error, but the code says ListIndex doesn't exist. Why is this happening and how can I fix this?
These are cropped to meaninglessness
Does this script have a variable named ListIndex?
Share code properly. Are these two images from the same class even?
No to both questions
See how you access PotionList?
via cui
And see how you did NOT do that with ListIndex?
then why are you using something you havent declared
Overlooked that, thanks for the help!
yes
still the same issue
How am i getting transform child out of bound for this? https://i.imgur.com/auSks3x.png
Their is a child in ItemHand
not according to index out of bounds if its that line
@rich adder why is it not working
check the colliders
show the gizmos in scene during playmode, select the player and place Game view side by side with Scene view
Whatever ItemHand is, it has no children
this doesnt help lol
Well this says otherwise, https://i.imgur.com/FcLHEDK.png
is that the actual one you referenced?
yes
Well, since this object has a child, and whatever ItemHand is definitely does not, then the only conclusion is that whatever ItemHand is, is not this object
Actually i think i know, there is another item with the same tag, which is how i'm referencing the item hand.
Collision detection is still on Descrete
try Continuous like I said earlier and you said you changed it..
ok i will but i changed it back agfter nothing changed
k. well dont.
also try turning interpolation too even though thats prob for higher speeds
Yep i found it. @polar acorn @rich adder
what kind of collider do you have on the ground ?
box
let me see
I see it says its a tilemap ? You should not have a box collider
i'm not sure if you can have tiles from your tilemap have colision i literally just put another box
well then you are wrong lol because tilemap has its own component for collisions
well how do you do it
get rid of the box collider, add the tilemap collider
you also want to add this
https://docs.unity3d.com/Manual/class-CompositeCollider2D.html
where do i add the component
same object on the tilemap
i added it now it's fully filled
how do i make it so some are filled and some aren't
wdym fully filled?
every tiule on the map has a collider
put the ones you dont want colliders on separate tilemap without collider
play around with order in layer to do between background and foreground
i did it
and oit still does the same thing
like when i jump
and i ow get stuck at the edges of tiles sometimes
add the composite collider also like i told you beofore
and checkmark the Used By Composite on the tilemap collider
if it adds rigidbody make sure its static
now i just fall from the floor
i checked used by composite i tried setting the rigidbody on my player to static but it does nothing
i didnt say static on the player, I said on the rigidbody the composite collider adds..
and where does it add a rigidbody
I was on the wrong channel
There isn't really a right channel to just say "hello"
how's this progress? i have been looking at the tutorial
while i do only have few of the steps left
Please stop baiting people. Nobody here is looking over your shoulder giving their approval. The progress is good if it works and you're following the tutorial.
So, does anyone know how I can make use of either the invoke method or an enumerator to delay the conclusion of a static script?
I've tried passing in a reference to the class since IEnumerator is a MonoBehavior method
but that doesn't seem to want to work
You need a MonoBehaviour to call StartCoroutine but the coroutine method itself doesn't have to be on a MonoBehaviour . . .
Sure, as long as it's called using StartCoroutine from a MonoBehaviour reference, you're fine . . .
hmmm.. nope, still not working, but it is still in progress...
well you see I tried that approach and am probably implementing it wrong
Show what you have . . .
public static void WarpMap(string map, int sp = 1, bool isDefaultAudio = true)
{
Debug.Log("================================================================");
Debug.Log("(Menu Controller) WarpMap instantiated.");
playerInput.enabled = false;
playerCamera.SetActive(false);
playerCapsule.SetActive(false);
if (isDefaultAudio)
{
AudioSource source = MenuController.sourceA;
source.PlayOneShot(source.clip);
}
fadeOut.SetActive(true);
instance.StartCoroutine(DelayLoadScene());
MenuController.isTransition = true;
}
IEnumerator DelayLoadScene()
{
yield return new WaitForSeconds(1.5f);
GlobalVariables.SP_School_Side_A = 6;
SceneManager.LoadScene(3);
}
DelayLoadScene isn't accessible because of the aformentooned MonoBehavior exclusivity, in this script's scope
so I first tried defining it as a private instance of the class and then sending it through the function as one of its arguments but it didn't take too kindly to that concept and was still acting like I didn't give it a reference
I've been scratching my head from this simple problem. For some reason, my gun keeps moving around for no reason, even though I have no script on it, and my character controller only moves it once to (0, 0, 0) local position.
as you can see, the pistol's position (relative to the WeaponPos component) should be (0, 0, 0) as seen in the PickUp() function
but I never change its position anywhere else
and it keeps changing for no reason
this is my camera script
what next should i write?
As usual, you were not supposed to just straight up copy the example code. It is an example. You were supposed to read it and apply that knowledge to your own code
Why you made a class called Singleton is beyond me. But that was never the suggestion
Is DelayedScene part of the same script or from a different script? Also, it's private, so if it's from a different script, you cannot access private members of a class . . .
it's in the same script
also for the last part I corrected it to public accessibility
- create a singleton that as variables for the counters. and that is hwat I did
For this part, what was the actual error message? I can better understand how the setup was incorrect . . .
the error is claiming that it doesn't have an object reference even though I called it from the class itself
A singleton. Not a class called singleton.
You already HAD a singleton called MuonCounter
Again, that was an EXAMPLE.
It is supposed to TEACH you about it. You are not just supposed to blindly copy without thinking through the purpose
You want a save system, so that class should be a singleton too. The one where you have SaveData and LoadData
Assets\Scripts\UI\MenuController.cs(468,9): error CS0120: An object reference is required for the non-static field, method, or property 'MonoBehaviour.StartCoroutine(IEnumerator)'
I can see an error because you're attempting to call it from a static method. The coroutine method is not static, so it belongs to an instance of the class, not the type. You have to access the coroutine method from an instance (reference) . . .
It isn't static so you can't call it from the class itself
hm, okay I'll try something else then
Alright making it a public static instance of the class allowed me to use it
which I probably should have figured but it slipped my mind
thanks guys
Hi, I am completely new to Unity and coding in general. I purchased an asset of this game template I thought would be interesting to build upon. But I literally cannot even figure out how to change the art.
The most confusing is what the globe thing and the "Main" thing at the bottom right corner is. I believe that's the place I need to focus on to get my own art to replace the existing stuff.
Tutorials on this are somehow hard to find on YouTube.
Please point me in the right direction thank you 😦
That's a Material. Materials have Textures.
You'd probably want to make a copy of the material and use a different texture if you want to change it
https://gdl.space/afabezaful.cs
but how do i make a singleton of this with no monobehavior?
This also isnt coding related, but you'll probably have an annoying time changing the texture. It looks like that texture has many colors and objects in 1 image, so i assume its applied to every single object.
That is an interface and is irrelevant. That is not where LoadData and SaveData are
you meant Counter script?
You should know
ok, ih vae put in the instance
I managed to do this, changing the specific pictures in photoshop. but I just can't figure out why and how these specific things are being called
yeah ur right it's applied literally everywhere. I just don't get how they're being called. it's on a .png picture and if I replace the pictures with my own pictures and replace the whole image, it changes. but I don't get why and how something's becing called to it.
see I changed the banner of the dog to a fish tank
but why is that specific corner of the .png image being called to that specific banner like that, where do I decide on Unity how that happens?
Not entirely sure what channel but #🔎┃find-a-channel
It's a texture, and the models have a UV mapping. It uses specific parts of the image to color it
Still isnt a coding issue
It's in the UV Coordinates of the model
o my bad u mean i'm not supposed to post this here?
ok thx i'll check that out
so... i need to write something more..
i've been reading the tutorial
but yet..
since both MuonCounter and Counter have instances...
Your UI should reference the instance of the singleton to know what number to display.
Whenever you touch a "muon object", increase that variable in the singleton instance.
Whenever you need to save or load, write those variables to disk or read them back to change the variables on the singleton instance.
.... i don't know if these are left to do...
Read your code and see for yourself
I am struggling with it... that that with my ui should reference the instance of the singletong to know what number to display, the number to display should be _amountMuons...
So do that. Have it display _amountMuons
Put a script on it
that reads _amountMuons
and sets the text to that
put a script on it? a new script?
If you already have script that does that, then use it
MUonCounter script have the text that is conntected to the ui muon count and and _amountMuons
Then use that🤷♂️
ok..
Whenever you touch a "muon object", increase that variable in the singleton instance.
the muon object have also tag names like "Muon1" "Muon2" and "Muon3" so that it can tell which objects it is
but.... it worked before the instance thing, but not anymore...
have you tried peppering debug log calls all over to track the flow of your code?
tried debug this on
Well unless you know how to actively use the debugger to follow the flow, you're going to need more than one debug log statement to figure out what you think is happening vs. what is really happening
and it wouldn't hurt to sketch out a mini flow chart ahead of this so you have what you expect to happen in what order ahead of time
a mini flow chart?
yea, google it, it's an ancient technique lol
Debug it with values instead of just words
Um, don't increment it inside hte debug log!
Can someone help me out here
Your gun is parented to the player, yet you mention a Pickup() method, which I must have issed seeing, but does it re-position the gun when picked up reletive to hte player?
what?
explain what part of what I said you are not understanding
i never heard of Increment before
Looks to me like your CameraPos object may be ending up in a whacky location... Share screenshots of the inspectors for Player and CameraPos after things go awry.
Also, send large blocks of !code like that in an external site as described by Dyno 👇. The Discord code file embeds kind of suck
📃 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.
the word increment?
means to add to..
_amountMuons++; <- this increments _amountMuons by 1 each time its run
Definitely do NOT do this
im trying to make a simple flappy bird game but my pipes are moving at different speeds even though i have the top pipe as a child of the bottom one. ```public class Pipes : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] GameObject prefab;
void Start()
{
}
private void Update()
{
if (transform.position.x > -10)
{
transform.position = new Vector3(transform.position.x - 0.05f, transform.position.y);
}
else
{
Destroy(gameObject);
}
}
public void SpawnPipes()
{
Instantiate(prefab, new Vector3(10f, Random.Range(-3f, -8f)), Quaternion.identity);
}
}```
yes..
that would be my guess.... the pipe inside the other pipe is moving twice as fast
i wasnt sure how to attach the other pipe to the first one
Child objects inherit changes to their their parents' transforms
yeah tahts what its doing
mmhmm so u shouldnt do that
so should i just remove the pipe script in the child?
yes, it'd still move the same speed as the parent pipe
Actually. you'd have to see if that works.. b/c of things like ur destroy method
That sounds painful . . .
not like that?
it worked
another question so id put the SpawnPipes() in a loop to make them infinitely spawn but how do i set time inbetween spawns?
look up coroutines
then...
@hushed hinge This is your official last caution about this before you start receiving warnings. Make a thread, use the thread, do not come out of that thread. You've been at this same thing for two days now, and we're not going to sit through another of you occupying this channel.
to be honest, nevre hearing of increment before, you're going to struggle a lot trying to do much of a game. I'd consider stepping back to learn some programming basics first
ive seen a few posts so far.. i feel like they skipped a week or two worth of learning
bought a motorcycle before learning to ride a bicycle kinda thing
ah yes they work thx
I'm sorry... sometimes i get anxious about things and doesn't think things straight right away
No. Debug the value, don't add one to it
++ means add 1 to it
oh
is there a way to get the size of an object in any way related to box colliders?
absolutely
could you perhaps enlighten me please
boxCollider.size;
❤️
is it possible to get a boxcollider from an object or do I need to save the boxcolliders seperately?
GetComponent<BoxCollider>();
awesome
just GetComponent if its on the same object
it is
In a very strict interpretation of SOLID/Dependency Inversion Principal, is it permissible/reasonable to have multiple layers of abstraction between concrete objects? That is, interfaces/abstract classes implementing/extending other interfaces/abstract classes?
My gut feeling is that this is wrong, but I can't quite put my finger on why... Like I'm extending the contract between the higher- and lower-level objects with the lower-level objects' implementation details
Though, I guess if an abstract class is the abstraction, then you're already including lower-level objects' implementation details... maybe it's fine 🤔
im new and dont know anything but what im confused on is what do i download to start coding c#?
I'd ask, does it impede my ability to properly add unit test?
Good point! I suppose it doesn't :)
sevreal options, see this list !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
This is a kind of followup to my earlier post and problem, I more or less made it work, but despite the instance of the class being a static member and also the function that uses this reference is static, but for some reason it seems like it loses its reference at some point and returns null, that or it never got one in the first place.
public static void WarpMap(string map, int sp = 0)
{
Debug.Log("================================================================");
Debug.Log("(Menu Controller) WarpMap instantiated.");
instance.StartCoroutine(DelayLoadScene());
IEnumerator DelayLoadScene()
{
yield return new WaitForSeconds(1.5f);
GlobalVariables.SP = sp;
SceneManager.LoadScene(map);
}
Where do you set instance
Also, you have a function in your function, you probably don't want that
I was told you can use a coroutine inside a function
Idk if it's good practice
instance is defined here
public class MenuController : MonoBehaviour
{
public static MenuController instance;
didn't know C# even allowed you to declare a function within one, weird
well it's more like a MonoBehavior method by proxy
Defined yes. Where is it set
where do you actually set instance to a value
@summer stump i just can't anymore
I keep getting drawn in no matter how much I tell myself not to
My initial understanding was that it would store the reference as is
You need somewhere that you write Instance =
An equals sign is an assignment
Why would it do that
most things don't assign themselves to anything
How is it supposed to know which MenuController the variable holds
well you can't use this inside static methods to refer to the script object
ints and numbers and stuff do.. typically zero
Correct. Because it's not on an object
There is no this
alright then what do you suggest?
Set instance to something
Does it have to be specific?
needs to be of the same type atleast..
Well, if you want to refer to a specific object it's probably a good idea to set it to that object
Not gonna do you much good if you set it to a different object
This is a MonoBehaviour, you could definitely use this here
I don't know if I even need all that, my intentions are to delay a function's ending slightly, but to do that with an enumerator from what all I've managed to gather, you need to pass in an instance of MonoBehavior
The function StartCoroutine must be called from a MonoBehaviour
Wait a second, I think I know the problem
I think you're right about that
Question: Why is this function static at all
I need it to be accessible from another class
why
I have a question
so I can call a function from it?
why not just put the coroutine in that other class
can playerprefs be accessed from any object and any script?
Absolutely nothing about this uses any sort of references in this class
because the class doesn't handle any of the stuff the delay is needed for, it's all handled by the function
Just put this coroutine in the function you're trying to call it in
And then start it there
So take this function that handles everything
and put it
in the class that calls it
thanks!
the most annoying part about references is to drag the stuff into the boxes
player prefs saves a lot of time not having to do that
You don't have to do that
forget about the coroutines, do you know if any other delay option works in a static method?
why does it need to be static
Don't abuse file read and writes to avoid proper referencing
https://unity.huh.how/references
that's not important
It's very goddamn important
It is fairly important
It is basically the crux of tbe entire issue
Just put the damn function in the class that uses it
you're already abusing static to avoid referencing
why not just do neither
private void OnGUI() {
Utils.RealtimeDebug(msg, offset, textSize, textColor, screenSize); // <--- static non-mono class (w/ functions reliant on OnGUI)
}``` is this okay tho?, the coroutine comments up above got me thinkin
When i was making this.. i tried to just call it in start or something.. but got errors saying certain things from within that static class needed OnGUI.. so i fixed it by just calling it inside a OnGUI instead, (b/c i couldn't wrap the main function in OnGUI b/c its not a monobehaviour)
I'm trying to disable shadows as an option on a directional light, would this be all I need?
Having shadows enabled doubles the tri count from 20M to 40M so it'd be nice to be able to disable that
light.shadows = LightShadows.None;
Why in Update? 🤔
So I can just constantly check if the bool is false, I'm really not going for pure performance with this since it's 6 lines of code
Ah, thanks
Why not just do it at the moment you set the bool false
Then you don't need Update at all
I'm not editing in Unity, that's probably why
Just a separate project I'll use an asmdef to link to unity
ahh ok
Seems like shadows won't work, which dll would that be in if you know?
(I assume I'm missing a reference)
It normally says but not this time I guess
lol, not a clue.. Light is in UnityEngine; i guess
That's annoying 😬
What's the error say
u need a reference to a light yes
I'm referencing every UnityEngine DLL I've got access to
Oh ignore that
That was working fine
ahh ok
Well you are not doing anything there
It does exist, and it's a boolean, you have to set it to something
I am
Well
Not with the shadows
No you are not
weird Light is shadows
But, that's been added
and DLights are shadow
Hello friend, it would seem we have run into another issue. It's not a MonoBehavior class lmao
turns out that was correct..
i didnt notice u were using a DirectionLight <>
Okay, so what's calling the function you need
@quick fractal still works the same if u use Light.shadows = ..
it's a protected override void that's part of an Interactable class I have
so use whichever one u want i guess
Looks that way, thanks <3
This truly is the most complex script anyone has ever written
Okay, and what calls it
protected override void Interact()
{
Debug.Log("Interaction (" + gameObject.name + ")");
if (isDoor)
{
var GameObject fadeOut = MenuController.fadeOut;
fadeOut.SetActive(true);
MenuController.isTransition = true
MenuController.WarpMap(mapString, spawnPosition, isDefaultSound);
}
Trying to run Unity Essentials Project, but I am getting this TMPro cannot be found error. As a result other errors like TextMeshProUGUI could not be found. Using Unity version 2022.3.39f1 . Any idea how can I get these defined?
Did you install it from the package manager?
Do you have using TMPro at the top?
I return with more questions, is something up with my script that's causing the references to not show up?
Oh wait.. Might be missing that serializable thing
Been a while since I did anything with editor scripts
im following a tutorial and I want to add on a little bit by deleting some of the game objects. I have the object in as a prefab it seems as I imported it as an .fbx from blender but when I try to use the "Destroy(Easy);" the Easy party gets underlined red and says it doesnt exist in that context
I do have using TMPro at the top of the script. No I cannot seem to find it in the Package Manager. Pressing the "+" search by name TMPro but it says unable to find the package.
It is not called TMPro
It is TextMeshPro
And you are not looking in the "in project" section, right?
That, did not fix it
its only parented after PickUp() is run
where should i be looking? Unity registry?
Yeah
In Project is only things that are in your project. So all that shows is that you do not have TextMeshPro in your project
I've had bugs like this.. adding and removing them and sometimes a layout reset forced em to show up.. did ur unity compile after ur new changes were saved?
Well, you have a reference to fadeOut. That's a GameObject. That has StartCoroutine
So put the IEnumerator in this class
It did, yes. Doesn't reset when I add/remove it
and have fadeOut start it
hm okay okay
Unity won't serialize statics, and it looks like DirectionalLight might be an unserializable struct... But since it's a struct (value type), even it were originally declared to be serializable, it would be a unique instance of data rather than a reference to some other data which already exists 👀
I think you might want a Light instead
cameraPos
WeaponPos
That'd be ironic, I swapped back to directional light in favor of it. I'll give that a go thanks
Yea lmao
The actual pistol