#💻┃code-beginner
1 messages · Page 307 of 1
with pixel art usually its like 16x16, with normal i have no idea? i assume like 128x128 or something, you can probably find the best resolutions on google
so your player and things dont walk through other things, you would add a collider in the inspector, BoxCollider2D or whatever shape fits
i suggest following a basic unity tutorial if this is your first time using it
I'm trying to make a script that will control the Camera, so would I use transform for that? and for zooming, how would I do that, I just need some pointers. Thanks!
you can change its position, and for the zoom it has a value for that
Sample SO:
public class AmmunitionWeaponAttribute : ScriptableObject, IWeaponAttribute
Interface:
public interface IWeaponAttribute
{
}
SO Reference:
[SerializeField] private IWeaponAttribute[] _attributes;
For this, I get Redundant 'SerializeField' attribute. This leads me to believe that I can't serialise an interface based SO like that. Does anyone know how I can do that?
obligatory: use cinemachine for camera controls
ummmm....... ok
you dont have to use cinemachine, it would be much easier though and save time
Yeah I think imma use it just to make it easier for my self right now and later down the road
um..... what should I use?
what kind do you want?
Well, I need it to move around a part, move up and down, zoom in and out, and the ability to lock all controls when a condition isn't met
but idk
free look or virtual, i dont remember which one is the main one just try both
i want to upload png images to a panel UI thing in my game but it wont let me drag them into the panel pls help
create a game object of type image under the UI section
uh oh. thats alot of settings
what about the panel
freelook is the one that pivots around a point
you probably don't want that
just use regular VirtualCamera
ok
create a child to the panel? which would be your image
which you would drag your sprite to?
or are you trying to change the actual panel itself?
How do I fix this?
nah im just trying to drag my image to the bg part of the panel
you deleted the main camera
set up is
GameObject1 : MainCamera | CinemachineBrain
GameObject2: VirtualCamera
it still wont let me drag the png
did you set the image as 2DUI/Sprite
what are you trying
im trying to make a health bar so i made some art for it and put the art in my assest folder, now im trying to assemble the health bar itself and cant drag my frame image into the thing that says source image
btw this is not code question
it says Code beginner
I asked you a question you never replied
look at the Inspector when you click on the image
should probably do the essentials path on the Unity website
BEHOLD!
why would you want this method
being able to easily add components using string gives quite some flexibility
…how
if you want to add a component, you already have the type itself
also, ClassTypeReferences is a thing
one SO easy to get the components it needs
this is gonna be dumb but how do i reopen the heirarchy
go to top menu bar, look at the windows dropdown, i think
my man, use ClassTypeReferences
thanks
it’s how you can serialize references to types
hmm not familiar
and not accidentally type “Protecor” and wonder why the hell nothing works
i am telling you the name of the extension
i am looking at their api, dont think it will work in my unity
it works in unity. it is made for unity
Probably doesn't support prehistoric versions of unity
your unity is not a different unity than everyone else’s unity
That's pretty nifty. I never needed this but that's a handy tool to have if I ever do
the extension also has a very old version, as it has been a thing for a while
so I can guarantee there is a version of it that will work
the solid alloy fork uses specific dropdowns that are more likely unity-version specific. the older version just makes some dictionaries and shit, and that is it
I'm playing this game, with basic unity text, the code below is what the image is.
Is there a way to Outline the text with a color?
<i><size=95px><b>R<size=590%>obinson <i><size=95px><b>G<size=590%>ap <size=95px>C<size=590%>oal
it is extremely useful to tie a class (that inherits from a given base/interface) to an SO
because SOs can’t refer to anything in scene
and sometimes you just want to tie logic to different SO instances, but not bloat the SO itself with a bunch of crap
especially for classes that you want to access without instancing a whole prefab
how do I have the camera rotate around this empty game object while still looking at it. (I'm using Cinemachine virtual Cam)
should be able to accomplish that with the FreeLook component
Freelook
I added the component and, you spin me right round baby right round
u dont have the camera parented to the target do u?
No not yet I'm fixing a lot of it currently
armed with the knowledge of freelook component u should be able to find a good amount of tutorials to check out
even if its just enough to get u started
and thanks btw, that songs stuck in my head
lmao
can someone link me a good tutorial on how to use the animation window? i cant really find a good one
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I bet they cover it properly in one of the beginner pathways
What's the best way for me to create a global sound effect script, that plays a sound when a 3d object is being moved?
How could i play a sound when a object is moving?
Do you want to play it once?
I want it to constantly loop until the player stops moving the object.
Yes
Is there a specific part you struggle with?
what is stopping you from doing this
It's on your 3d object, right?
Its only the code part, i'm not sure how i could code it.
Nevermind
Is this supposed to be with only 1 object, or whenever a player is moving any object? if any object, can these objects play different sounds?
Think about these things, then first thing you can know where this script should be.
Then consider what moving the object means, like a UI object, rigidbody, or manually affecting the position
I want to make a global script, that can be put on any object, and all i input is the audiosource.
Any object at all? not just rigidbody for example?
Alright, I'd go to a folder used for scripts and right click -> Create -> C# Script
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
public AudioClip aud;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
audioSource.clip = aud;
audioSource.loop = true;
audioSource.Play();
}
Then, I'd name that script whatever you want, and then add it to your 3d object
I think that should work, maybe
Just rigidbody
you really dont need to guess, or try spoonfeeding. This clearly wont work for what they asked. This just plays audio only
Thank you, but this just plays the audio.
I need the audio to be synced with the movements of the 3d object.
Since its RB, you can just check the velocity and then do the above logic based on if the object has velocity
Ok, so check to see if the velocity is over 0?
Can someone push me in the right direction - im attempting to make a grid based inventory system. watched a few youtube vids and still confused, doesnt seem like im getting it right
velocity is a vector3, so you either check if its equal to the zero vector or check if the magnitude (or sqrMagnitude) is 0
Yea thats what i meant.
you should specify more, like what you want for it to do, what doesnt work specifically. I would start by making an inventory that just exists by itself, no grid or UI associated with it yet. Make add, remove, drop, swap methods if you want those. Then make some grid UI which calls methods on the existing inventory
What .NET version does Unity 2022 use? 
thanks!
I've made a fps walking system in unity. But i've had this issue with the code. That when the player changes the Y level even for a bit or just goes to another cube that is in the same Y level as the floor it just levitates in the air infinitly. I've tried some things but they dont seem to work. Here's the code.
`private void FixedUpdate()
{
float horizontalInput = Input.GetAxisRaw("Horizontal") * Time.deltaTime;
float verticalInput = Input.GetAxisRaw("Vertical") * Time.deltaTime;
Vector3 cameraForward = Camera.main.transform.forward.normalized;
Vector3 cameraRight = Camera.main.transform.right.normalized;
cameraForward.y = 0f;
cameraRight.y = 0f;
Vector3 ForwardRelative = verticalInput * cameraForward;
Vector3 RightRelative = horizontalInput * cameraRight;
Vector3 MovementDirection = ForwardRelative + RightRelative;
rb.velocity = new Vector3(MovementDirection.x, rb.velocity.y , MovementDirection.z).normalized * MovementSpeed;
}“`
https://gdl.space/upirivafit.cs
its supposed to be a script for switching guns with scroll wheel
this is the error
The name 'SelectWeapon' does not exist in the current context
you made the SelectWeapon method inside of your Update
which made it local to Update
which means it doesnt exist outside of it
Can you DDOL objects when working with online multiplayer? Might try and consider making a multiplayer component to my game if I can parse over the player input manager and stuff.
Hi. I have a question: I want to make a random value for red in Color Grading through a script, but there I need to convert int to the desired type for Unity. I tried searching the internet and found nothing. How to convert?
whats the error
Severity Code Description Project File String Suppression Status
Error CS0029 Cannot implicitly convert the type "int" to "UnityEngine.Rendering.Post Processing.Spline". Assembly-CSharp
OKay got a issue, i'm trying to make the audio now, but their is a small pause between the loop. I'm not sure if its unity or not.
First time with unity and c# My idea is a Tetris-style multiplayer Pacman (each person on their own half of the screen). I took a github with a classic pacman and duplicated everything, the problem is that they use the same scripts and if I want to change something it ends up being a chain of errors and code to change. I think the easiest way is to run 2 instances of the game in each half, is it possible? Each one with its own assets? Or there is a simpler solution and I am drowning in a glass of water.
simply duplicating everything is very unlikely to just work. Game managers for example would just be referencing one thing, any global events or singletons being used would immediately cause issues.
The easiest way without learning someone elses system and trying to fix it, is just make your own
im not too familiar with audio. it could be a problem with the audio clip itself having no sound at the end
It seems my "DynamicManager.asset" got messed up. The collision matrices I set up are still working correctly, but the when I go to Project Settings > Physics and look at the collision setup, it's all messed up. You can even see that the rows and columns don't align.
Also I don't use gravity, but it shows a gravity of -9.81.
anyone got tips for making my objects in a list appear in an inventory, i have the grid fully setup now i just need a way for it to create an object slot and show the image
instantiate more cells to a grid
Have the item provide a sprite. Show the sprite in a grid slot
Often a slot is an object
If I revert to a pervious version of the DynamicsManager.asset; it shows the same behavior.
Nevermind i found it, unity doesnt like looping mp3 audios. I had to change it to .wav
i got what your saying all ready but i'm just wondering how to have slots become created as new objects become filled in the list/array
Yeah, i find .mp3s have a silence added at the end of the file, even if it isn't there beforehand
When you create the inventory, do a loop and instantiate a slot for each required slot
Generally just a for loop
Then using the i, you can do rows and columns with some math
Yep, sucks.
Or a for loop inside a for loop with i and j, j being the rows and i being columns
alright thanks
U guys know how to enable nullable for the entire project in unity?
as far as I know you cant, since Unity overrides the csproj settings.. instead you have to manually enable it per file unless you can set up some kind of post-csproj generation script to change the Nullable setting every time Unity regenerates it
So I'm having a couple issues here. This is a script for a bullet. https://gdl.space/iheralilug.cs My first issue is that it will not bounce off walls. It just sort of hits them, then glides along them. Does anyone know why?
i logged it, and the collision is happening
could possibly be related to that you are assigning it in update? add some Debug.DrawRay to visualize where it is going
I did some debugging and that seems to be fixed
Updated code: https://gdl.space/avabiparip.cpp. the other issue i have is that the overlap circle is not working at all. The layer that I wan't it to collide with is 6, and I'll watch it collide, but nothing gets logged
it is not 6 that you wanna hit, you want 1 << 6.
https://unity.huh.how/bitmasks
you should just pass in you collider.includeLayers to make sure it is the right layer
? Where?
in OverlapCircle
instead of "filter"
get a rerference to the bullets collider and then pass in includeLayers
make sure to set the include layer to the thing u want to hit in the inspector
If I have a Class Item and then two classes that inherit item ItemA and ItemB
Can I make a Dictionary<Item> that contains both ItemA and ItemB?
Or is there some other solution for this?
yes, you can . . .
I never really worked with inheritance 😛
Thats pretty much the whole point
doesn't seem all that common in most projects
what happens to the variables ItemB has that are not in Item?
Nothing happens to them
so I can access them from the Dictionary?
If you know that the specific item is itemB you can typecast it to B
But you should not be designing like that
Item should have a virtual method that does the work. B should override that to use its specific variables
it's probably better to define all the fields in Item?
the reference in the dictionary is that of Item. you can only access fields from that class. as Uri stated, if you know that specific reference is an ItemB, then you can cast it to ItemB in order to access those specific fields . . .
The you can go item.DoSomething and it will B,s DoSomething
Trying to make this worldTimer check if gets passed 10 seconds, and if it does it will increase enemy health. I want this cycle to happen every time worldtimer increases by 10 seconds. cs if (worldTimer % 10f == 0) { EnemyScript.health += 10; } --- This is the code that I am having problem with
No Item should only have fields that will be common for all items
So what I'm trying to do is on my server create a list of items to send back to the client.
But different item types have different fields.
I can only send one reply from the server.
what do you mean one reply ?
client asks for an item list and the server makes the items and sends them back
this will rarely hit precisely, if not at all. especially if you increase time using a float. check if the time passes 10 seconds (or vice versa if counting down), send an event, and then reset the timer . . .
Me personally I would a virtual NetworkSerialize on the base Item class and have each concrete Item implement it's own specific serialization in this case
It's kinda silly, for now I just have scrolls and equippable items,
the equippable items have 2 extra fields
then again I would just make it so tha the client already has all the items on his side and server just sends a list of id's like You currently have items 0.4.7,45
the items are generated on the server 😦
but yeah I could just serialize them seperately
Why should the actual item object be generated on the server ? Have the server just generate what items the client has. You are wasting network trafic sending whole objects back and forth
ah that is different, serializing the values and sending them over will work here then, but just the values, not the whole object. Client can reconstruct it on his side
When trying to use OnTriggerEnter with rigidbody on both the player and the platform, it is very glitchy, and I fall off the platform alot even when the platform is going across flat ground
why does this happen?
Maybe you need OnTriggerStay? if that's the correct name
OnTriggerEnter only triggers once
OnTriggerEnter indicates the platform or the player is an area/zone that you can pass-through . . .
falling through the platform makes sense . . .
What do you mean to pass-through
objects are meant to pass-through trigger colliders . . .
you can enter and exit a trigger collider. basically, it's an area that triggers when smth has entered or exited . . .
a regular (non-trigger) collider cannot be entered as the object stops when touching it, like, walking into a wall . . .
i can created a script where it will generate random numbers from 1-5, depending on the output, it will generate an enemy on the number generated. For example if the number generated is 3 then it will spawn an enemy on spawner 3.
It worked completely fine although when i instantiate the enemy model, i have an error in navmesh.
Error : ```"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
enemyMain:gotoPlayer () (at Assets/Enemies/enemyMain.cs:46)
enemyMain:Update () (at Assets/Enemies/enemyMain.cs:32)
Will someone help
This code is not running
public class ColorTransition : MonoBehaviour
{
public Material CurrentColor;
public Color[] colors;
public int Index = 0;
public float time;
void Start()
{
StartCoroutine(ChangeColor());
}
void Update()
{
ResetIndex();
}
IEnumerator ChangeColor()
{
yield return new WaitForSeconds(3f);
CurrentColor.SetColor("_EmissiveColor", Color.Lerp(CurrentColor.color, colors[Index], time * Time.deltaTime));
Index +=1;
}
void ResetIndex()
{
if(Index >= colors.Length)
{
Index = 0;
}
}
}
Theres no error
wait time was set 0
It still doesnt work
umm did u fill all the vars and added the script and stuff
which part of the code doesn't work?
the color.lerp i believe
the emmision color never changes
all of those colors have no alpha . . .
also, the third parameter for Color.Lerp is used incorrectly . . .
it should animate from 0-1 over time . . .
in the coroutine, Lerp is only called once and Index is added once . . .
help me with my problem too
i can created a script where it will generate random numbers from 1-5, depending on the output, it will generate an enemy on the number generated. For example if the number generated is 3 then it will spawn an enemy on spawner 3.
It worked completely fine although when i instantiate the enemy model, i have an error in navmesh.
Error : ```"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
enemyMain:gotoPlayer () (at Assets/Enemies/enemyMain.cs:46)
enemyMain:Update () (at Assets/Enemies/enemyMain.cs:32)
Share the code too
thx lemme try fixing all of them
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Destroyer : MonoBehaviour
{
public GameObject toBeDestroyed;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
private void Start()
{
}
private void Update()
{
Check();
}
private void Check()
{
if (toBeDestroyed.transform.position.x <= DestroyWhenReachesThisXPosition)
{
Destroy(toBeDestroyed);
}
bool condition_for_procreation = ((toBeDestroyed.transform.position.x + 5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
Instantiate(toBeDestroyed, new Vector3(7.73f, -2.85f, 0), transform.rotation);
condition_for_procreation = false;
}
}
}
Why is this creating an exponential amount of objects in my game?
the code doesnt seem to have a problem but sure, https://pastebin.com/RYJUxjhV
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
In the error it tells theres a problem in enemymain scripts at line 32 and 46 try seeing those lines
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.
i saw the script but i dont see any error
the enemy probably spawning too far from navmesh
ooo
but the thing is
when i use enemy as prefab to spawn them, it doesnt work cuz the player needs to be a prefab too and then the prefab doesnt detect the player
so i thought of keeping a enemy out of sight outside the map and instantiate it inside the map
Why not just pass the player instance into them as they spawn.
idk how to do that
like what would the script look like
i am trying to make a game without watching any vids
You spawn them at some point via Instantiate. Make a method, lets say void Init(GameObject player) and call it on the instantiated enemy to pass the player instance.
so the player doesnt have to be prefab here right?
you only have one player anyway no?
so yeah, either way if you were to spawn player. same concept applies
the object is created from the scene
Yo guys, check this out why is my game creating so many new obstacles at an exponential rate so fast? it looks as if its creating very fast and my code doesnt slow it down at all.
i am not understanding anything here ;-;
have u add a timer?
Does the obstacle have a script that creates obstacles?
📃 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.
Show the inspectors of everything in the nested pipe
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 3f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
bool condition_for_destruction = (whatIstoBeDestroyed.transform.position.x <= DestroyWhenReachesThisXPosition);
if (condition_for_destruction == true && _timer >= when_timer_should_stop)
{
_timer = 0; //reset
Destroy(whatIstoBeDestroyed);
}
bool condition_for_procreation = ((whatIstoBeDestroyed.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
cloneInstantiator();
condition_for_procreation = false;
}
}
void cloneInstantiator()
{
Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
fbruh
Also, make that a prefab instead of instantiating from the thing you're about to destroyed
how
the link
Oh wait. That IS the prefab?
You aren't caching the instance you instantiate
idk how do i put it in my code
break down the logic into smaller bits
try understand what the code even does
what do you mean?
catch it ? its not a baseball, how am i supposed to catch it?
i said CACHE
Please just do screenshots instead of videos
storing the instance (instantiated object) in a variable . . .
erm... acthually it's not a variable, it's stored inside a method
void cloneInstantiator()
{
Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
this is a method right?
or am I crazy?
😛
we're telling you to store it in a variable . . .
You are not storing the reference that Instantiate RETURNS
ohhh i gotcha
why tho?
To destroy it
method is good enough, no?
No
No, not even close to what we're saying
You need a reference to the thing you want to destroy
then what am i storing?
You don't have one
Instantiate creates a new object, right?
You are storing a reference to THAT object
the method has nothing to do with this . . .
WhatIsToBeDestroyed is actually something you should NOT destroy
It is NOT the thing you instantiated
thats correct, i am supposed to be doing that, no?
You're destroying a prefab or whatever is stored there
Instantiate returns a copy
Save that into a separate variable
Yes you are supposed to, and you are not
ok so i need a new variable then to make a reference to the new clone objects?
Yes
Your conditionForProcreation is apparantly always true, because you are checking the wrong object
Which explains the super fast spawning
And also nothing being destroyed
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 3f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
bool condition_for_destruction = (whatIstoBeDestroyed.transform.position.x <= DestroyWhenReachesThisXPosition);
if (condition_for_destruction == true && _timer >= when_timer_should_stop)
{
_timer = 0; //reset
Destroy(whatIstoBeDestroyed);
}
bool condition_for_procreation = ((whatIstoBeDestroyed.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
cloneInstantiator();
condition_for_procreation = false;
}
}
void cloneInstantiator()
{
GameObject newclone = (Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation));
}
}
ok, so I created a new name for that thing I wanna instantiate
now you were saying I need to refer to the new clone right?
on destroy?
ok i gottit
You wrote GameObject in front of newClone. So it is a local variable you cannot access elsewhere
imma make it public then
You need to make it a class variable
thats easy to fix
Nope
Cannot do accessors in methods
Just declare the variable in the class
how am I gonna make an Instantiate method into a class?
I can make cloneInstantiator() into a class
that I can do
Not what I'm saying to do at all
and then inside of that call the Instantiator
ok
I'm saying make a variable in your class right here
Assign the instantiate return TO that variable
so make cloneInstantiator() a class
Again NO
Excuse me mysql database isn't creating on my phone. It has been working but recently stopped for no reason. It creates when I test on PC though
Here is my code: https://paste.ofcode.org/K536rFAfy2VeCkBQhssfC9
Dear Lord almighty
No new class. Make NO NEW CLASS
I'm surprised you managed to write the rest of the code if you cannot understand something so simple
what do you mean?
I have no idea how to explain it simpler
Make a variable.
Inside your class
Not in a method
you mean this class?
private GameObject m_clone;
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
private void Check()
{
...
Destroy(m_clone);
}```
Sorry. I did misread that. Yes it would be in that class
ok thanks... fun fact, it's still creating millions of objects btw.
Yes, I told you why
Your condition you are checking
It is likely still pointing at the prefab, right?
yes
ConditionForProcreation
Well yeah, that will always be true
I mean, the check should be a timer anyway, not the position check you are doing
I gotta go to bed though. Best of luck
please help me with this first
i found the solution, i just had to bring the spawn points near the ground so that it is an acceptable drop height and it can detect the navmesh
ok I remove the check for position condition and right now I am only using the timer, so as you said I gotta remove the pointer that always points at the prefab that always returns true right? so that means that I gotta remove the
public GameObject whatIstoBeDestroyed;
and replace it with what exactly? m_clone?
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 3f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
if (_timer >= when_timer_should_stop)
{
_timer = 0; //reset
Destroy(m_clone);
}
bool condition_for_procreation = ((whatIstoBeDestroyed.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
cloneInstantiator();
condition_for_procreation = false;
}
}
private GameObject m_clone;
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
m_clone is down there by the way, I just changed that according to the direction that @caesar has provided
Move m_clone to the top, no reason for it being down there
your condition for procreation still uses the whatIstoBeDestroyed prefab
Ah yes, the timer
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
private GameObject m_clone;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 3f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
if (_timer >= when_timer_should_stop)
{
_timer = 0; //reset
Destroy(m_clone);
}
bool condition_for_procreation = ((m_clone.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
cloneInstantiator();
condition_for_procreation = false;
}
}
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
aaaand.... still broken
Show your current code and if there are any errors
bool condition_for_procreation = ((m_clone.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
it's no longer pointing to the old prefab thing
this is the current code 
yep
ctrl+s
Maybe this public GameObject has to go?
but then there will be no initial clones to be cloned after
A question first, since I wasn't here since the beginning of your issue - should there be only one clone at all times?
there should be always one clone, yes
Hello!
Then simply move your spawn logic to the timer check, or the other way around, the destroy logic into the position check, because right now the timer check could possibly destroy the clone when later you want to check its position (it's already destroyed so you're gonna be greeted with an error), thus the instantiation should most likely take place right after destroying the previous clone
My friends told me to choose unity instead of unreal to begin with, but I don't know where to start
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I know how to use the Unity interface and all its plugins, but I don't know how to program or anything about the visuals.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yes, I've already entered, but which one should I select?
Can you program at all?
no
then look at https://dotnet.microsoft.com/en-us/learn/csharp
I still cant figure out what the problem is, so now that I did that all excited that it will finally be working this time, now there's no obstacle pipe objects showing on the screen at all
I'm new to this world, I've only tried unreal with their blueprints, but they told me that unity is a better option and I don't know anything about code.
even tho I literally and very clearly have this cloned at the start
Show current code
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
private GameObject m_clone;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 3f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
if (_timer >= when_timer_should_stop)
{
_timer = 0; //reset
cloneInstantiator();
}
bool condition_for_procreation = ((m_clone.transform.position.x+0.5) <= (DestroyWhenReachesThisXPosition));
if (condition_for_procreation == true);
{
//create one of your kind here
condition_for_procreation = false;
Destroy(m_clone);
}
}
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
which is why I linked you to the code learning site for C# which Unity uses
Okay, but here I have many options which I choose from all to start
Are there any errors?
by the way timer is stuck at 0.02
this is one thing that is very sus
and not expected this to happen
no errors at all
at least not being detected on the terminal
In the Unity console
If you cannot read the website and make a decision on which is best for you you will not go far
Yeah, then fix that error
If there's an exception in a component, it will deactivate itself if I remember correctly
Thus the timer is no longer updated
And as I said earlier, you're trying to access a destroyed clone
You have two separate checks
how is it being destroyed if nothing is showing up in the first place?
(destroyed or null)
Either way, instead of doing two separate checks (timer and position), make just one instead
If there's supposed to be only one clone at a time then decide whether you want to use the timer or position
is this the same problem rn?
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
private GameObject m_clone;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 2f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
if (_timer >= when_timer_should_stop)
{
_timer = 0; //reset
cloneInstantiator();
Destroy(whatIstoBeDestroyed);
Destroy(m_clone);
}
}
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
Because right now two things can happen.
- Your timer reaches
when_timer_should_stopand makes a new clone, thus leaving the previous clone to be forgotten for eternity, yet still active in the scene (that's why you had a ton of them earlier) - Your position condition is met and the clone is destroyed. But the timer still didn't reach
when_timer_should_stopso there is no new clone and you're greeted by an exception the next time you want to check the position.
Why do you destroy whatIstoBeDestroyed (also, rename it to "pipePrefab" instead to avoid any confusion for yourself and others)
Also the old clone should be destroyed first, and then call cloneInstantiator() to make a new one
Learn c#. But beware that this has a huge learning curve. If you've never even touched programming before, learn the basic principles first before pursuing a language like c#
i have another simple timer for you if u are intrested
its 4-5 lines
First he has to understand what he does
No worries
it doesnt look like it makes any new clone
Seisan
it didnt destroy it either
what are u trying to make?
First fix your code so the error doesn't show up and then show the current code
crappy bird ( for training )
oo
bruh then why are u doing all this
Bro what 😭🙏
just give ur player a constant velocity in one direction and make him add rb.force at his feets everytime the player presses space
That's literally it
yeh
listen
I don't even think you need to animate anything as well since rigidbody rotations handle all of that well
how are u detecting that the pipe has exited the screen
Object pooling. If he collides with the pipes, game over
I did add rigidbody on the body of the player
and a gravity script
thats it
but the pipes have no rigidbody
I did give them rb 2D but didnt do anything
then dont need to have one
You don't need a gravity script with rigidbody...
What mesh bro this is a 2d game
oh okay
just listen to me
delete the project, make a new one
add a cube
make it jump and move in one direction constantly
dont add any sprites or something like that
it can be done later
and try to make different folders for everything so u make it clean and organised
something like this
its super clean right now
ur variables are too long for me and it confuses me
i get it that its for clear understanding
then try writing a new script
that does everything
dont delete the old script,
reference them in ur new script
That's for 3D
and IsTrigger
ok
just search " collider " and everything that says 2d will work
what video are u referencing?
A sphere is a 3d object
dont use IsTrigger,
🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...
goto brackeys
he is the god
idk how to spawn the piller cuz have never made a flappy bird, but the player controller script that u made is really confusing and complex for a simple task
no not brackeys 
Do not watch brackeys, yes
why
super old and mostly buggy tutorials
his personal yt for a nice explanation for 3d stuff
Can you show your current code?
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using static UnityEngine.RuleTile.TilingRuleOutput;
public class Destroyer : MonoBehaviour
{
public GameObject whatIstoBeDestroyed;
private GameObject m_clone;
public float DestroyWhenReachesThisXPosition = -10f;
// Start is called before the first frame update
public Vector3 pipeSpawnVector = new Vector3(7.73f, -2.85f, 0);
public float _timer = 0; //we need a time slowdown to slow the speed of generating new obstacles in our game
public float when_timer_should_stop = 2f;
private void Start()
{
cloneInstantiator();
}
private void Update()
{
Check();
_timer += Time.deltaTime;
}
private void Check()
{
if (_timer >= when_timer_should_stop)
{
_timer = 0; //reset
cloneInstantiator();
Destroy(whatIstoBeDestroyed);
Destroy(m_clone);
}
}
void cloneInstantiator()
{
m_clone = Instantiate(whatIstoBeDestroyed, pipeSpawnVector, transform.rotation);
}
}
For movement I think is important
!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.
Remove line with Destroy(whatIstoBeDestroyed); and move Destroy(m_clone); before cloneInstantiator();
Idk his movement code and I'm worried if it's overcomplicated asf
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LeftMove : MonoBehaviour
{
// Start is called before the first frame update
public int speed;
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector2.left* Time.deltaTime * speed);
}
}
the movement code is not that scary
yeh
Also for a game like flappy bird, object pooling is a far better method than instantiating and destroying the pillars constantly
Fair enough
Move left?
oh fuck, it finally works perfectly
i suggest making a 2d movement showcase if u think the pillars are confusing af
nice
Infinite scroller, the pillars and background should move, not the player
ooooooooooooh i remember that
Ah so he's moving the background, not the player
Makes sense
The player should just have a jump script then
makes sense
Thank god, now I'm going back to my own work, good luck with the rest
Or me, to avoid making a new project as he suggested
Do you wanna start with the player movement or the random pillar height?
Player movement is really easy for flappy bird btw
I can help
sure, random pillar height
me too if u wanna make a 2d platformer
I can make that on my own btw im just kind of slow
I'd suggest movement first
okay
It's easier to implement
Would be good if he tried to figure it out by himself, but do it however you want
I'm going back to work, cya
movement of what exactly?
That's fair, but I can try guide him along
me too, bye
Not exactly gonna give him the answer in a cheat sheet
Player
what type of game are u working on?
Yknow, you gotta jump and have gravity and stuff
Try make something yourself and show it to us
Would be best to make a thread for this now
pixel art Bullet Hell space shooter, pixel art story-driven RPG on the side
If you have any questions feel free to ask
ooooo ohki, good luclk
flash, what game are u working on?
Oh damn I tried making a game like that before but i sucked at pixel art at the time 😭
Hack-n-slash
i still suck at it 😭
oh nice
I suck at pixel art too, but thankfully I now have a friend who does wonderful arts for me
i am kinda stuck and not stuck
Maybe add roguelike elements in the future but nothing huge as for now
i can find 3d models online but they are either paid or not good enough
I just learned how to make my own based on references but I can't make up a piece myself 😭
Kinda like in 3d modeling, you know how to make a gun hut you need a reference to actually do something
i have a small list to add today........... farming, wave spawning, new gun
Agreed
lol
Visuals are one thing, gameplay is another. One rule when making a game by yourself is make the gameplay and visuals separately. You cannot get stuck on gameplay if there are no visuals. Just use placeholders and focus on gameplay
I work on visuals last personally
i am focusing on gameplay cuz my graphics are literally beans and cubes
At work, when making a game in UE5 for most of the time we were using basic placeholder models and the proper visuals came last, just around a month ago. But the gameplay was pretty much done by that point.
can someone join a vc, i wanna show a problem i am having. i cant understand what's causing it
I don't know what style would flow well with the mechanics until I actually finish with the mechanics, yknow?
Yeah but it's hilarious to see placeholder textures left in by devs in your favourite game. Making tf2 maps, you'd be able to see a slime texture that's just a neon green bsckground with "Slime" typed in the center
i have some problem
when i play the game in unity editor, my gun shoots fine
but when i build and play its like it misses the shots even tho there are no features like it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gravity : MonoBehaviour
{
public float speed = 4f;
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector2.down * Time.deltaTime * speed);
if (Input.GetButtonDown("Jump"))
{
transform.Translate(Vector2.up * Time.deltaTime * 4);
}
}
}
no errors
but the space key doesnt do anything
neither does the up arrow
And...?
I looked at the edit>input system
try using rb.addforce, its better in playing
and it looks like its already configured so when you use that keyword
they are supposed to make it work that way
ok
just use Input.GetButtonDown(Keycode.Space)
Yeah, right now we're doing a hex-map strategy game (kinda like Civilization, but only combat with pickups) and we're using stickman figures as placeholders for our units, it would be fun if we left them there
i have a problem need help
here
Interesting approach but not the best
yeh
You don't need to hard-code gravity
use AddForce
why squiggly red line?
For your game I'd suggest using rigidbody
if(Input.GetKeyDown(KeyCode.Space)){
// ur coode here 🙂
}
No need to hard-code gravity
Unity already takes care of that
All you have to do is move the sprite forward
And jump when needed to
try adding this to ur code https://docs.unity3d.com/ScriptReference/Rigidbody2D.AddForce.html
But rb2d doesn't have velocity?
Again, rigidbody is just how unity handles physics, moving the sprite is YOUR job
Well, your jump translation pretty much cancels out your gravity translation, and it only happens for one frame, when you Jump, so it's obvious you wouldn't notice.
But use a Rigidbody2D instead as other suggested
It does, it's just not exposed to the inspector
anyone who can come in a vc and see my screenshare, i have a confusing problem with no console errors
The build problem?
yeh
We'd need more context man
bruh thats why the vc
Send a screenshot or a recording so that everyone can see, not a single person which may or may not know the solution
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static System.Runtime.CompilerServices.RuntimeHelpers;
public class Gravity : MonoBehaviour
{
public float speed = 4f;
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
transform.Translate(Vector2.up * Time.deltaTime * 4);
}
else
{
transform.Translate(Vector2.down * Time.deltaTime * speed);
}
}
}
and why not just do this?
(space doesnt work)
okei just a saec
It doesn't work because of what I wrote earlier
Because its unnecessary
Plus with this implementation your jump would cancel out the gravity
With a rigidbody you'll get a much nicer effect, with much less effort
Im implementing shooting mechanic with raycasts. I have a camera on the player as a ray cast origin point. Than I shoot a raycast and if it hits anything i interpolate trail renderer from gun to hit.point, pretty simple. The problem is within direction, for some reason if i set a direction with a gun.tramsform.forward on some rotations it shoots wrong direction, but if i set direction as camera.forward it works on all rotation of the player. I don't understand how it works
public override void Attack()
{
if (CanShoot())
{
ammo--;
updateAmmoInterface(ammo);
PlayShotEffect();
Vector3 direction = GetDirection();
RaycastHit hit;
if (Physics.Raycast(rayCastOrigin.position, direction, out hit, _weaponInfo.Distance))
{
var trail = SetUpTrail();
StartCoroutine(SpawnTrail(trail, hit));
lastShootTime = Time.time;
IShootable shootable;
if(hit.transform.TryGetComponent<IShootable>(out shootable))
{
shootable.TakeBullet(_weaponInfo.Damage);
}
}
}
}
private Vector3 GetDirection()
{
var vect = transform.forward;
if(_weaponInfo.IsSpreadApplied)
{
Vector3 spread = _weaponInfo.Spread;
vect += new Vector3(UnityEngine.Random.Range(-spread.x, spread.x),
UnityEngine.Random.Range(-spread.y, spread.y),
UnityEngine.Random.Range(-spread.z, spread.z));
}
return vect.normalized;
}
here is the gameplay in the editor
Like it can shoot perpendicular to the player
What factors/fields impact a simple hingejoint object's friction and drag? Like a door consisting of a single cube shaped into a door
add a rigidbody and set its drag and angular drag to 0 and turn off gravity

idk if it will work 100%
is there any channel to advertise a small team or something?
I guess it has something to do with children - parent rotation but Im not sure
oh
me too
let me check ur error
i dont have the spread feature tho
so its like
idk how to explain it
i had the same problem
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class score2 : MonoBehaviour
{
public TMP_Text highscore;
// Start is called before the first frame update
void Start()
{
if (Timer.elapsedTime > Timer.bestTime || Timer.bestTime == 0)
{
Timer.bestTime = Timer.elapsedTime;
}
highscore.text = highscore.text.Replace("New Text", "Highscore is" + (Timer.bestTime / 1000) + " sec");
}
// Update is called once per frame
void Update()
{
}
}```
how do i save the lowest time to timer.BestTime
!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.
pls use pastebin or something
Simply change > to <. Right now you're saving the longest time
Thank you so much!
This only matters for large code blocks
Can anyone help, please?
@charred spoke this is exactly what you meant right?
Dictionary<int, List<Dictionary<string, object>>> combatLogs = new Dictionary<int, List<Dictionary<string, object>>>();
// Itemlist
Dictionary<int, List<Dictionary<string, object>>> itemList = new Dictionary<int, List<Dictionary<string, object>>>();
// Return dictionary that includes combatlogs and items
Dictionary<string, object> returnDic = new Dictionary<string, object>();
...
returnDic.Add("CombatLogs", combatLogs);
returnDic.Add("Items", itemList);
return returnDic;
Hope no one else ever has to touch this code 😅
I dont think this is wha I menat at all. Like I siad I would not send an entire dictionary of <string.object> over the network
it gets turned into a json string
Im implementing shooting mechanic with raycasts. I have a camera on the player as a ray cast origin point. Than I shoot a raycast and if it hits anything i interpolate trail renderer from gun to hit.point, pretty simple. The problem is within direction, for some reason if i set a direction with a gun.tramsform.forward on some rotations it shoots to the right or left instead of forward, but if i set direction as camera.forward it works on all rotation of the player. I don't understand how it works
public override void Attack()
{
if (CanShoot())
{
ammo--;
updateAmmoInterface(ammo);
PlayShotEffect();
Vector3 direction = GetDirection();
RaycastHit hit;
if (Physics.Raycast(rayCastOrigin.position, direction, out hit, _weaponInfo.Distance))
{
var trail = SetUpTrail();
StartCoroutine(SpawnTrail(trail, hit));
lastShootTime = Time.time;
IShootable shootable;
if(hit.transform.TryGetComponent<IShootable>(out shootable))
{
shootable.TakeBullet(_weaponInfo.Damage);
}
}
}
}
private Vector3 GetDirection()
{
var vect = transform.forward;
if(_weaponInfo.IsSpreadApplied)
{
Vector3 spread = _weaponInfo.Spread;
vect += new Vector3(UnityEngine.Random.Range(-spread.x, spread.x),
UnityEngine.Random.Range(-spread.y, spread.y),
UnityEngine.Random.Range(-spread.z, spread.z));
}
return vect.normalized;
}
I think 🤔
I guess it has something to do with children - parent rotation but Im not sure
I think there's a bunch of information missing to solve this problem
We don't know what gun or camera is or how they work.
You've just dumped a big block of code (which you're not supposed to) and expect someone to solve your issue for you.
Track down where in your code it's going wrong and ask for info on a single line, or better, read the docs and figure it out yourself.
Maybe someone can help you, but I doubt anyone will look at this.
doesnt matter if it's json or xml or binary. It's sending unesesarry data over the network. But if it works for you it works I guess.
lol, isnt this is the meaning of this chat...
even if all of the data in the Dictionary is relevant?
is it the structure that is adding unnesesarry data?
#854851968446365696 the meaning is to help people when they can't fix stuff themselves
not to solve problems for someone else
making a bullet go in the right direction is VERY basic and there's probably a million tutorials on it on every possible platform (like YouTube)
Didnt see the original issue but I truly doubt all of that data is necessary.
Even just having a dictionary of int to list of dictionary of string to object should indicate to you that you're doing something wrong. The structure needs change
anyone know why i cant find "Whatisground" and "Whatisplayer" layermasks?
Did you create it in project settings?
uhh how do i do that, i was following a youtube tutorial btw, didnt mention anything about that
Why does it indicate I'm doing something wrong?
is it as simple as typing in "Whatisground" and "Whatisplayer" ?
It's an overly complex structure. I cant imagine any case where this would be needed.
You shouldnt really use 'object' much, except for like serialization.
Using this structure is also gonna be a massive pain, and completely unreadable. You'll access something via data[int][index][string]. But then all you'll have is something of type object. Regardless of the types that are being used here, you can always split up your logic into other classes. Like it would be much simpler on the eyes if it was a Dictionary<int, SomeClass>
but then I would still need to send that class over the network?
agree that using classes would be better
I'm trying to do a simple skill tree for a coding asignment, but it's telling me an index is out of range. I can't find where though-
it's 27, but I'm not setting anything here I think
i know this is very stupid, but how do i use a slider as a health bar?
whats the name of it
Public Slider Health; doesnt work
(better image)
Is your p capitalized in your script too?
That's an error
public slider Slime_Health;
thats the line of code
S should be capitalized...
so, are you missing a using directive?
whattsss.... whats that
At the top of your script
its just a slider that i tweaked a lil
oohhhh
like using Slider;?
oh
using unity.ui;
make sure that your !IDE is configured so that you can use the quick actions to add the correct using directive automatically
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
whats IDE
like auto fill?
your code editor
i use Visual Studio
you could literally just read the bot message and figure that out
yeah i use Visual Studio
so get it configured . . .
already have it configured
screenshot the entire visual studio window
of the code?
the entire visual studio window
not configured
how do you know?
it's like you didn't even bother reading the bot message
i did
i clicked on the visual studio automatic thing
and i followed the instructions
Dead giveaway
so then surely you saw the part about how if your IDE is not autocompleting code or underlining errors then it is not configured, right?
bump it up
idk i saw some pics and followed thhem
did you bother reading the words
i had to restart visual studios
wait why cant i say bruh?
i just said it alone and it blocked it
so theres this thing called being terminaly stupid
yeah now it went from misc ti Assenbly-CSharp
can confirm. I meet with many people with this illness on a daily basis.
well you just met another
soo i still have the issue
😭
remove the incorrect using directive and use the quick actions in visual studio to add the correct one
DAYUM it tells you what to do?
bruh i used to programm like 3 years ago and i wanted to learn it again
i Never had that
I’m taking a break on this for a bit, I can’t for the life of me find where the out of range index is :,)
the issue is gone btw i forgot to use the Unity Elements thing
no, that is wrong too
there is a Slider class in UnityEngine.UIElements, but it is not the one you are using
Bro how 😭 even tho i dont have an error anymore i stil messed up?
im using the basic slider
Because Slider exists in many places, you need to chose the correct one
i know, which is why UnityEngine.UIElements.Slider is not the correct one.
i just want a simple slider that if i press the button it goes down by 1 and once it hits zero it hits 10 again
right, you already had the coirrect namespace so use that
even i am sure thats not that hard to programm
but wouldnt it then give me an erro?
no, of course not
it wasn't the correct one, it was close to it though
well ive never used sliders
Unity.UI is incorrect
but im using TMP_Pro
and that is irrelevant
true
doesnt it also need the ui thing?
no, the TMP_Text class is in the TMPro namespace which you did have added correctly
where can i find a tutorial how to make a car with ignition?
in the internet probably
cant find
yes i am using TMPro; but i tought i also need to use Unity.UI;
if in doubt, go read the documentation, it will tell you what you need to add
again, Unity.UI is incorrect
dont think - check docs
alr so il just remove it
you should configure your ide first anyway
bro idk last time i programmed with unity i didnt do half of this stuff
ok
don't make that everyone else's problem
ok
well is there anything else that i need to add or do or can i now start programming?
start with configuring your ide
how are yall so patient tho?
on it boss
so was this just a lie?
then it is configured
then its already configured
yeah just fix your error
do you still have the UIElements namespace added?
yes
unused namespaces will appear greyed out.. w/ a configured IDE u can hover it and it will say its unused and can be removed
cool so you only follow instructions when other people give them. good to know
uhm? sure?
can someone else tell this person to remove the UIElements namespace because it is the incorrect one? since when i told them to do it they didn't bother listening
please remove the UIElements namespace
whats the correct one?
hey, you need to remove the UIELements namespace b/c its the incorrect one
i never actually said which one is the correct one
alr have TMPro
You know what. Sebi over here has given me the confidence to move out of the code-beginner channel and into the general one
yeah bro, i always make people feel more confident
READ. THE. DOCS.
aka using UnityEngine.UI; is required
i was using that already.......
someone told me to remove it
i just got here ¯_(ツ)_/¯
nor is UnityEngine.UIElements
ah ok
thats interestting i heard that the docs are unrealiable
on like 2 other discord servers
but ur the boss
c# is very verbose.. things are exactly how they look..
good
You heard wrong, the Docs are the only source of truth
no one competent says docs are unrealiable 😄
i like everything that way
then i have been lied to
very much so
do i need to be good at math tho? i heard u also need to be superb there
you need to know basic math... and how to google
i know programming using math sometimes but u dont need to use quatorians like every second
yes, you do need to at least have a good grasp of basic math
i think i should leave that server, it has only given me missinformatyion
i do not know basic mathamatics
Vector math?
Help please, I recently found out about unity and want to download, I downloaded unity hub and entered, I clicked on "sign in" and I went to "Confirm your email" and then clicked continue, and then nothing happened except that the button turned gray and then green again.
this is a code channel mate
no
i keep hearing it in tutorials but i never actually know about them
Time to start learning otherwise youi will get nowhere
what are vectors tho?
You are meant to type that into google
it tells me about an aircraft
ok
Quantity that has both magnitude and direction
I'm sorry, I didn't understand what you said, and I can't find a regular chat here, if there's one. I just went to where the asset is. I don't know English, so I use a translator, and your words are translated, apparently not correctly, so I didn't understand you.
write in #💻┃unity-talk
add unity to ur search
so instead of vectors type unity vectors
instead of how to jump.. type unity how to jump
how to programming jumping in unity
thats how i always do it
yea sure that'll work
In this video I tried to cover as much useful information about Vectors in Unity as possible. We start by discussing what Vectors are, what useful properties they have then we go through most useful methods and at the end of the video I am giving 2 examples of solutions that require vectors.
This was until now the most challanging video to make...
Thank you
vectors are cool af ;D
can be used as directions too
or inputs even
2 inputs together could make a Vector2
so u use Vectors when u plan on making it so things change positions or size?
(x,y)
The tutorial was linked right there, no need to turn public channel into rehashing it
sorry
well ima go try my best to make a easy clicker game
cant be that hard?
if button pressed ++ 1 bla bla
@strong wren Start with Unity !Learn courses and see for yourself
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
alr father
idk why but i have a harder time working with 2d games
@strong wren There's no off-topic here either
enough ffs, at the moment you are just trolling
forgive me father, as i have broken the rules
im just going to shut up and start doing smth
alr what are the variables again? i know what they are but i cant find the names
all i know is that string is for letters words numbers for show etc
float is for not whole numbers like 0.4 etc
bool is true or false
but there was another one for full numbers
what was it calleed again
@strong wren If you want a private tutorial session create a thread. You've been provided with tutorial materials
not lookling for a tutorial looking for the a variable that contains full numbers, i cant find all the varibles on google closest i came was all but whole numbers
ima just look more
please take some time to learn the basics of c#. there are beginner courses pinned in this channel that will teach you the absolute basics of the language, including covering the built in data types
i know some basics but i forgot the names
int right?
@strong wren For the last time. Create a thread if you want to continue or you'll be muted
ok
wtf are you searching for? 'C# numeric types' in google brings up exactly what you want to know
Every C# unity variable
il just watch the video of the god himself, brackeys
then you need to seriously work on your google skills (or rather lack of them)
i'd say programming is not for you if you cannot figure it out what is a variable in 2024 using internet. It justs gets "harder", sorry
i know what variables are
i just forgot the names of some

those are data types that you have forgotten. not the "names" of variables
Lol
yep now i remembered that its Int,
i know what variables are. i just forgot the variable that stores whole numbers and that is INT
I have a bunch of spawners with their own type of spawner script, but i wanna add an interface... how do i implement it? do i make a new script where i define the interface then give that script to all the spawners or?
Can I ask what makes you want to use an interface? Perhaps you want an abstract class?
you know what variables are, yet you keep confusing variables with their data types. seriously take the time to actually learn instead of assuming you actually still know
you have to be either trolling at this point or you are just not a smart person tbh, not being rude

Lol
why are you guys still going on about this 😭
@hard lodge This is not a place for random reaction messages
Make sure you are using them for intended purpose. Interfaces are used to reference and create common methods for objects originated from different classes. If your prefabs from the same group, you might want to go with common inheritance grouping instead #💻┃code-beginner message
its kinda of hard to explain... its for this, the Ienumerator is not correct
you probably just want a base class that they all share for that
Yes, so abstract class
depending on what this SpawnerController wnats to spawn, it would access the spawners script, and find a Spawn() method in there, and run it
simple inheritance with abstract BaseSpawner class
also those nested dictionaries are horrifying
yeaa
do you know what's inheritance? @scarlet skiff
abstract BaseSpawner : MonoBehaviour -> ProjectileSpawner : BaseSpawner
and make some kind of Spawn() function which you will override in your classes
An immediate solution would be to pass a delegate rather than the specific spawn type and have it be invoked in the coroutine.
Hi guys...
Currently I have these line of code to detect collision if player goes to a vault, an UI prompting user input will pop up, however my UI doesnt show up, yet it prints Vault UI Activated. Any idea why and how to fix it?
private void OnCollisionEnter2D(Collision2D collision) {
if (collision.gameObject.tag == "Player") {
vaultUI.SetActive(true);
Time.timeScale = 0;
print("Vault UI Actived");
}
}
unrelated to the issue you described, but you should be using the CompareTag method rather than string equality when checking tags
but also are you perhaps doing something like fading your UI in? or literally anything at all that depends on the time scale?
tbf I just copied this collision thingy off some yt videos, some theres that
in addition no I just setactive to true, no animation
Check it's active state in the hierarchy, it can be inactive due to an inactive parent.
Panel is the vaultUI (sorry for bad naming, doing it in a rush)
By this sense is the parent Canvas? cuz its active :<
In play mode when you activate the object, is the object activated in the scene hierarchy?
There's nothing there called vaultUI
public GameObject vaultUI; i reference it
it keeps slowing down even with drag and angular drag 0 and gravity off, i don't get where the slowing down is coming from
I see now, gotcha 👍
nope
these icons shouldn't be visible.. unless they're enabled OR the mouse cursor is over this object in the hierarchy
but, thinking about it.. that only hides the object in the scene view... ignore
hey its me again
Change your print to this cs Debug.Log($"{vaultUI.name}'s active state was set to true", vaultUI);Maybe you're referencing the wrong object.
Panel' active state was set to true
UnityEngine.Debug:Log (object,UnityEngine.Object)
vaultTip:OnCollisionEnter2D (UnityEngine.Collision2D) (at Assets/Script/vaultTip.cs:26)
wheres the s
{
public int DMG = 1;
public int Coins = 0;
public TMP_Text CoinCounter;
public Slider SlimeHealth;
bool isDead = false;
public void DmgSlime()
{
SlimeHealth.value =- DMG;
if (SlimeHealth.value == 0)
{
isDead = true;
}
}
public void AddMoney()
{
if (isDead == true)
{
Coins++;
CoinCounter.text = Coins.ToString ();
SlimeHealth.value = 5;
}
}
}```
When you click the log in the console, which object is highlighted?
so the issue is when i click on the Slime it sets the value of the slider to 0
which shouldnt happen since i manually set the dmg to 1 which u can see and the health is 5
Edited @oblique herald
my Vault sprite ithink
Try it again with the updated code and see which object is highlighted
there is also the issue where it would not reset the healthbar nor add the money
Panel's active state was set to true
UnityEngine.Debug:Log (object,UnityEngine.Object)
vaultTip:OnCollisionEnter2D (UnityEngine.Collision2D) (at Assets/Script/vaultTip.cs:26)
Now its highlighting Panel
It should be an object in the scene and not a prefab
oh yeah that what I meant sorry
which i assume is cause of the glitch or i frogot to do smth, i set the button/slime if its used to call on DmgSlime
Is the panel active?
idk why im explaining the code yall know alot more then me