#💻┃code-beginner
1 messages · Page 254 of 1
if(returnType == DerivedClass1)
do this
You probably want to learn object pooling at some point, if you're instantiating thousands of objects there is a performance implication when creating so many objects
In this situation I don't think it does. I want to add a new inventoryItem, which is essentially just an inventory slot, with an item and quantity. But the abstract class doesn't have a field for Item, only the derived ones do since that slot can be either an itemSO or a structureSerialised
my unity crashes when my gameobject dies, how do i know what's the issue? there are no errors in VS
Hey, guys! Can you help me please with Null Reference that I am dealing with? So, I am making a flappy bird game and whenever my player enters the collider of the other object(gem) it disappears and my particle is being instantiated with object pooling method. So, what's happening basically is that instead of returning my gem particle game object back to its pool for one reason I am destroying it or something but as I see on my code I don't have any Destroy() method or something that destroys the object I have replaced everything. Check what is happening in the video below.
Do you have an infinite loop running when the object dies
public bool DoTypeStuff(Item item)
{
if (item is Weapon weapon)
{
//weapon.Attack();
}
else if (item is Potion potion)
{
//potion.Drink();
}
}```
Bad example as this could be like a polymorphic Use() method maybe but you get the idea
wouldnt TypeOf(Thing) be easier?
i'll check and try to fix
If it's a Particle System, is it set to Destroy on completion?
what about outside the screen?
clearly something is destroying
Can I make a thread please to provide all the information needed?
no because that would then require comparing against another type object and a manual cast. what Mao showed does the type check and the cast all in one line
Ahh those are particles nvm digi is prob right
ah, okay
SO Inventory with an abstract class as it's container type
Null Reference Exception Error
@polar acorn Hey mate! Join the thread to discuss the issue if you are available.
Not it isn't.
It is not set to destroy on completion I think but it is a particle system
prove it
any idea why this guy just walks past his point? he occasionally stops at one but then it just bugs out again
start debugging
log the current patrol point etc.
i am
new dest when he reaches the point and finds a new destination and it logs the new patrol point to go to
Anyone know how to fix vscode not having intellisense when trying to write my unity scripts?
make sure the point is where you think it is
!vscode
follow these instructions ^^
can you show the External Tools window in Unity
yeah its the point i pointed out on the video and hes supposed to just go to it and stop for a couple seconds and then move again
Uncheck the last to second check mark and click regen, clock vs first. Then open script again from unity
check Output window for any errors
so which part isnt working the timer or
fixed, thanks
i think its the distance logic maybe? like the distance between points, but im not sure because occasionally it works, but for other points it doesnt like that one
wats agent stoppin distance set to
its 1
how would i reference the clones i made? for a rubber or an eraser
hmm maybe its pretty big, depends how you scaled everything
You need a way to query them based on a condition
the stopping distance doesnt matter i found, i was testing with it
um it usually does
just because it may not for your case, but stopp distance can matter a lot
yeah thats what i mean for this it doesnt matter
all the gizmos i can see are the ones on the video
do you see the red circle gizmo around your Point ?
not loading
wtf is good with attachments rn lol
i can't see my spawned hovertank in the scene, even tho i can see that it's spawned in the console
using Core.Utilities;
using JetBrains.Annotations;
using System;
using System.Collections;
using System.Collections.Generic;
using TowerDefense.Agents;
using TowerDefense.Agents.Data;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.AI;
public class NewEnemy : MonoBehaviour
{
[SerializeField] private GameObject myHoverTank;
private void Start()
{
DamageableBehaviour damageableBehaviour = GetComponent<DamageableBehaviour>();
damageableBehaviour.died += DamageableBehaviour_died;
}
private void DamageableBehaviour_died(DamageableBehaviour obj)
{
Destroy(obj);
Debug.Log($"{obj} destroyed");
GameObject newEnemy = Instantiate(myHoverTank, transform.position, Quaternion.identity);
Debug.Log(newEnemy.name);
newEnemy.GetComponent<NavMeshAgent>().enabled = true;
}
}```
i know what you mean tho
anyway yeah that red circle around your point, at first is there but then it goes to the other one
ye
the red circle is the agent current destination
but thats only supposed to happen through the distance check
like the switch of points
well clearly its happening earlier
and im assuming it does but it happens too far
so something is flawed in logic
the only place im referencing OnReachPPoint(); is in the distance check so idk what it is
selectt the spawned object in playmode in hirerchy and Press F on keyboard, check where it went
!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.
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Paint")
{
if((Input.GetMouseButton(1))) Destroy(other);
}
}
i tried this
make sure all pivots are correct
on points?
how do you expect this to work exactly
mainly the player
the ai you mean
ok
Pivot on Center mode can be misleading
pivot points are fine
make sure its set to Pivot Local
and the pivot is where the enemy is
ye
lemme fix it actually
i would store the Distance first of all , inside a variable
start debugging that make sure its correct numbers
i checked in the hirerchy, the object spawned but it was disabled by default, how do i enable it? even tho i instantiated it
do you have a script on the object ?
it's a prefab
irrelevant
but yes, it does have few scripts
and does one of the scripts have something in Start/Awake ?
its spamming the debug.logs so i think whats happening is maybe when it tries to find a new point it finds more than 1 maybe
mate
its just spam setting new points
hmm wdym by that
anyway this is why changing agen stopping distance didnt help
your Distance is still fixed to 1
are you sure that is the correct distance you want?
like, everytime he is done waiting at a patrol point, the script finds a new point multiple times before he moves making his movement a bit laggy and maybe offputting the transform.position of the point he wants to go to
changed that
just stuck it into a variable
in the code?
yeah
(Vector3.Distance(ai.transform.position, selectedPoint.position) <= pointDistance)
and you also debugged ditance?
var distance = Vector3.Distance(ai.transform.position, selectedPoint.position);
no ill do that
alright ill take a gander with this distance debug
Note that if the variable is serialized in the Inspector, modifying its value in the initializer code does nothing, as the Inspector takes precedence over values set in the code
there are multiple scripted and many of them are attached with each other. It's a bit too complicated to figure out what's the issue
script used to work fine before i made few changes an hour ago or so
and i dont think i made any major changes
you're doing a whole lot of assumptions without testing the basics
and that script acts weird in some other levels
Ie if you have certain Nulls in Start/Awake then your object will disable itself
can you dm me pls? i can share the template with you
thats too much committment lol
its an easy thing to check mate, the object you instantiate check its script on Awake/Start
share those two scripts if you want !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.
well, i tried using SetActive(true) and it spawned now
unless your prefab was saved as Inactive
then it would explain it
otherwise you're putting a bandaid on a bleeding gash
!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.
// Your code here
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Paint" && ((Input.GetMouseButton(1))))
{
Destroy(other);
}
}
idrk what else to do
images on discord arent working rn
do you know what OnTrigger does?
Oh good I thought it was just me
it works now! thanks
without the setactive()
triggers it
well with a physics object
triggers dont collide, they Trigger lol
they aren't solid
anyway doing what ur doing is prob wrong for an erasing method
Like I said earlier you need to select them with the mouse prob using a raycast or something
hmmm ok
but do they have colliders?
ye
alr well use a mouseraycast and look for collider with Paint tag or whatever
image finally loaded btw @lost anvil lol
ok
ISO or ANSI for coding?
wa
keyboard layout
Ohhh..use whatever you're used to lol
Im in US so I use ANSI
using \| next to Z key would be weird af for me
why is this happening
Are they world space objects or UI elements
world space
objs
they're probably not in front of the camera
Are they actually in front of the camera
That's not something that just happens, do you have code that is meant to do something when the player collides with them? Are you disabling the renderer?
i do have code that does somethings when they collide
So show that code
!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.
but this is also happening to the ground
i have a ground object and you can't see it until the player colides with the flying boxs
but you can colide with the ground
Okay, so, considering this code teleports the player to this object's position and then moves the camera to follow them, that lends further evidence to the "They are out of view of the camera" theory
What are the positions of the camera and the objects?
what do you mean
I mean what are the positions of the camera, and the objects that are not visible
objects to be infront they have to be greater Z value from the camera Z
And the objects?
so the camera is infront of them
do you see the problem now
So then what's the problem
let me try somehting with the code
i got it
!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.
When I put 2 weapons in the weapons list, it won't let me put a legend for some reason.
https://gdl.space/orumagogog.cpp
Anyone have an idea why this is happening? If you need more details I will
What do you mean by "won't let you", does it hit your error log?
Yup, when I try to put a legend when there are already 2 weapons, it says
"Cannot equip more than two weapons at a time. WeaponsList count: 2"
then category is "Weapon" and you already have two
So it's doing what you told it to do
No, let's say there are already 2 weapons in the list. It won't let me add a legend to the legend list and says me
"Cannot equip more than two weapons at a time. WeaponsList count: 2"
Then category is "Weapon" and you already have two
So it's doing what you told it to do
I don't think you understand 😅
No I understand pretty clearly
category is "Weapon" so it runs the weapon branch
and since there's two things in the weapon list, it won't add another
But I checked, it's completely legend category
Not according to that log it ain't
That log only runs when category is "Weapon"
If you're getting that log, then category is "Weapon"
It does, if I try to do it the other way around, add the legend and then the 2 weapons, it works.
That's why it's weird
Then you should try to find out why category is equal to "Weapon"
Have you tried actually logging it to see what value it is
That's why I came here 
Yes, it appears that it is from the Legend category
Show the logs you get, in order, with collapse disabled
how could i reference clones from an instantiate?
Instantiate returns a reference to the thing it makes
alr so i dont need to make one?
Make what
a reference to it
cuz i wanna delete clones from instantiate if a button is presssed
put them inside a list
You don't "make" a reference, you get a reference
var theObject = Instantiate(etc..
myListOfObjects.Add(theObject);```
hmm ok ty
I´m a dumb Unity newbie lol working on a 2d project, I have a character that can jump. The jumping worked fine before.
I changed some settings for the UI scaling and... suddenly it doesn't jump anymore? I know the jumping function is getting called properly and I´ve played with the movement values to no avail, so I think it has to do with the different objects parameters in Unity...? I checked with the version where the jumping did work and nothing is different on the objects or the script I used, so I'm a bit unsure where to look next.
I have a Debug.Log line that shows me I enter the jumping method and the following line is what doesn't seem to take effect, with jumping power as 6f, the same value it was before the UI scaling (have played with this variable to test if the number could be an issue but it didn't make a difference, should I try any different values? calculate it a specific way?)
rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
The character always falls down when I run the game and gets stuck in the middle of the ground collider. Depending on the initial position I set for the character, it sometimes gets moved away from the screen, just off the ground collider and gets stuck there. So I think the issue lies in this initial position change...?
Both the ground and the character have box colliders. None of them work as triggers.
First image is the character rigidbody + collider, second image is the ground's collider. Should I be checking anything else?
(since someone was asking abt another issue before, feel free to make a thread if you reply to me or smthn lmao)
Unless this object is a UI element, changing the UI scaling would not affect any world-space objects at all. Do you have anything else modifying rb.velocity, perhaps your horizontal movement, that might be overwriting your Y velocity?
Are you using a GetButton instead of a GetButtonDown?
It could be adding force for every frame the button is held
If you don't want the player to do that (hold the spacebar) check for getkeydown and not getkey
when i do the var thing a weird error shows up
https://gdl.space/mukuseferu.cs any idea why the debug in StartWave() returns 0 timescale, but the game keeps going and timescale is at 1?
What error
do i need to do brackets when putting the var
like i named it paint
do i need to do paint();
What does LevelManager.main.Pause() do
What is line 29 of PenDrawScript
paint;
Where's the rest of it
Yes, it does get modified for the horizontal movement inside FixedUpdate. 
private void FixedUpdate()
{
rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}
Is there a better way to handle the jump?
Usually that error is because you used == instead of = could it be?
So the reason it's logging zero is probably because it's zero
if timescale == 0 then set it to 1 and if timescale != 1 then set it to 0
thats it
What is paint
but the CheckTimescale method* returns 1
dont think you can just have a variable sit there and do nothing lol
nothing else anywhere in the code touches timescale only levelmanager and enemyspawner
but dont i need to call it if i want it too paint?
So what the absolute heck is paint; supposed to mean
but it never pauses the game with the bit in enemyspawner, the levelmanager timescale buttons work fine
like Dr. Manhattan on mars
paint is the object returned in Instantaite but do you store it outside the method its called in?
no?
thats why i mentioned storing it in a list if you want to erase a bunch spawned
Then when that runs, it's probably 1. These logs are running at different times, so it's entirely possible that between one and the other, it changes again
i have no idea why it changes though
!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.
the timescale shouldnt change from when i set it to 0
Add a log anywhere you change timescale, and see what order they're called in
// Your code here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PenDrawScript : MonoBehaviour
{
[Header("Keybinds")]
public KeyCode ClearKey = KeyCode.Backspace;
public GameObject pen;
public GameObject effect;
public bool drawing;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
var paint = Instantiate(effect, pen.transform.position, Quaternion.identity);
if(Input.GetMouseButton(0))Instantiate(effect, pen.transform.position, Quaternion.identity);
if(Input.GetKey(ClearKey) && pen.tag == "Paint")
{
}
}
}
script is unfinished***
i need to get rid of the bool too**
omg why is it in update
- Why do you have two instantiates
- What do you actually want to happen inside the second if
whats the keyboard shortcut in VS to check for text in all scripts?
like ctrl F but for all scripts at once
you're literally assigning a newly spawned on to the same variable
its in update cuz every frame? no?
Ctrl+Shift+F I think, or just normal Ctrl+F and change the dropdown to "Entire Solution"
plus u said to leave the var on its own
yeah thats it, thanks
do you only want to erase the specific paint that spawned in that frame?
i thought i should put the other instantiate back
i want to clear all paint
so store it inside a list like i said..
Then you're going to need to keep a reference to every object you've cloned
Why is "Jump" an axis
is "mylistofobjects" an actual thing u can do?
That should be keeping the Y velocity just fine, so that's not the issue. Are you maybe colliding with something you weren't expecting to? You didn't put any colliders on UI elements, did you?
or is it just an example?
found the issue, for some reason the timescale in Start() in levelmanager gets called last
What is mylistofobjects
is multiplayer beginner coding or advanced coding i can't tell
here
Very very advanced
ill put it in OnAwake()
You should probably make it a button
Not for beginners definelty
oh
Makes sense, the order objects call Start in is largely random
something like this basically
[SerializeField] List<GameObject> paints;
void Update()
{
if (Input.GetMouseButton(0))
{
var paint = Instantiate(effect, pen.transform.position, Quaternion.identity);
paints.Add(paint);
}
if (Input.GetKey(ClearKey))
{
for(int i = 0; i < paints.Count; i++)
{
Destroy(paints[i]);
}
paints.Clear();
}
}```
is there a help channel
yeah works in OnAwake(), thanks for the help
That's just the name they've given to the list variable
This is a help channel, if you need help for multiplayer check out #archived-networking
You can still check if a button is held without it being an axis. You can start your jump on GetButtonDown, and adjust the height based on when they release the button
thanks
Also, isn't "Controlling the height by holding the button" literally the problem you're trying to solve?
You said you didn't want that to happen
TYSM sry for getting u to write the code too im just too thick and clueless
GetKeyDown is only true for a single frame
You can use GetKeyUp to see when the press is released
Then calculate the difference in time
its fine, these are very basic parts of C#. You will learn them you will be able to do a lot inside Unity.
Lists, Loops, storing references etc.
hi
i can't tell if multiplayer movement being client sided is a networking issue or a script issue, what do i do?
What does that even mean?
And it's worrying to see networking questions in #💻┃code-beginner
i was trying to make multiplayer game in unity
and movement is client sided
Yeah I got that part haha 😸
i don't know if it's movement issue or script issue
where do i post for hlep
for help
The "client sided" part is what makes no sense
You were directed to #archived-networking earlier 🤷♂️
Yes, but movement SHOULD be done on the client, that's what is confusing me about your question
Nope, those are free lol. I have other elements with trigger colliders that work as expected of them. Logging showed me the only collission at the start is between the character and the ground, as it should be
Irrelevant
but then the movement is client sided
which means only you can see it
server can't see it
i think
or am i dumb
Ahhhh, that is completely different than what you made it sound like
You have to send the inputs to the server of course
But the movement would happen on the client
First. Don't ask in code BEGINNER haha. It is an advanced topic. And you were directed to #archived-networking anyway
But it depends on the networking framework you are using and what architecture you're going for. It's impossible to speak in generalities here
what networking framework
what do you mean
i don't undergrand
What networking framework are you using
what's a networking framework
You definitely should not be doing multiplayer
i am using multiplayer HLAPI
Yeah sorry dude, but if you don't know that basic terminology, you really need to do some reading. 😕
is that what he is asking me or
So, that would be relevant information to post with your question in #archived-networking
Pretty sure
You should probably ask in #archived-networking
It looks like this is the fifth time you were told that
if you don't know this you should probably not be making a multiplayer game..
ok so ik ive used this channel WAAYYYYYY tooo much but this is the LAST thing for today. I added a colour changing script for more colour variants obvs but it changes all paint instead of just the new paint if yk what i mean. Ik what is wrong with the script i just dont know how to fix it. It is bc im refrencing all of the paints insted of new ones
!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.
// Your code here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColourChangerScript : MonoBehaviour
{
public SpriteRenderer sprite;
public bool newPaint;
// Start is called before the first frame update
void Start()
{
sprite = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update()
{
if(Input.GetMouseButton(0))
{
newPaint = true;
}
if(Input.GetKeyDown(KeyCode.R) && newPaint == true)
{
sprite.color = new Color(1, 0, 0, 1);
}
if(Input.GetKeyDown(KeyCode.B)&& newPaint == true)
{
sprite.color = new Color(0, 0, 1, 1);
}
if(Input.GetKeyDown(KeyCode.G)&& newPaint == true)
{
sprite.color = new Color(0, 1, 0, 1);
}
if(Input.GetKeyDown(KeyCode.C)&& newPaint == true)
{
sprite.color = new Color(0, 0, 0, 1);
}
}
}
script
Is this script on every instance of your sprite
I don't see anything here that would prevent this running on all objects that have the script on it
ye thats the problem
So how are you intending to know which ones to change
I really dont know ive tried searching it up but there isnt anything useful
how do i lock the cursor to the middle of the screen
waait i can help
I mean how are you the person making the game, intending to choose which things to color
ik ik
!code Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
📃 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.
// Your code here
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
@rich adder damn bro i just had to make pointdistance higher then the stopping distance you were right 😭
i spent a good hour trying to fix the script that was right
the power of Debugging numbers!
lol ill be debugging thoroughly from now on
actually is there a way of saving the screen. What I mean is that instead of changing the new instantiated objects color I could save the existing ones meaning the only the instantiated objects will change. Is my logic correct?
Make a list. When you instantiate a new one, put it in that list.
alr will do
https://gdl.space/ikunidutoc.cs hi, I need help because I don't know how to get the door interaction working like when player 1 goes up to the door and is at the center of it and I tries to press q but nothing happens as I didn't get teleported to another door or the screen fades to white and then to normal like in Kirby
my list is calle color but what would color =?
WAIT NVM
didnt u already do this with example i sent of adding them to list ?
so yk how u need a var what would that =? thats what i meant.
so i could combine my color script with my pendrawscript?
Whatever the type is that you are instantiating
are you trying to change color of the same spawned objects?
so share the list, doesnt have to be in the same script
ok
do you know how ?
we need to see things like colliders and all that jazz
also doing this inside every keypress Camera mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
i know how to like reference one script in another but lists not so sure
yes you reference the other script and access the list
but what do i de then
so does currentInteractible have those methods
wdym what are you trying to do lol
and what are u struggling with
u said to share the list
everything tbh lol
you want to change to colors to all the things you spawned ?
keep it all in one script if it helps you understand better
sorry im like very new to coding, and im trynna do this off a tutorial, how do i check this?
I want to change the colour when a button is pressed but not the ones already on the screen
Your classes have to have their methods defined if you are trying to use them.
https://gyazo.com/be1f33e2f690e6cb2154534710761e36
I'm getting weird graphical glitches with my 2d tile map when I'm moving my camera.
I've attached a pixel perfect script to my camera. It dosn't seem to be fixing the issue when I use a perspective camera.
How do I fix black lines going across the tiles when i'm moving?
If you are following tutorial its either bad or you missed a step where they created those methods in that Interactable class @rocky lava
heres my full code
first of all !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
cause your error wasn't highlighting in editor
which is a big problem coding without intellisense/error underline working
I only want the ones u are currently drawing the i want the ones on the screen to stay the same
bump
so your goal has DoorInteraction which calls OnTriggerEnter2D but has no collider?
i genuinely dont understand whats wrong
don't mind the goal name, i'm using a different object but this is not the name
won't collider jsut block my way through?
colliders can also be triggers
triggers dont block any object but send trigger messages
ok, but right now when i tried to press q, NullReferenceException appears
well congrats now the script is actually running
you just didnt catch the error because it never ran
you should store these cameras in the beginning of the Level btw.
not sure why you're doing this
Camera mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
Camera mainCamera2 = GameObject.FindGameObjectWithTag("MainCamera2").GetComponent<Camera>();
Camera pixelCamera = GameObject.FindGameObjectWithTag("PixelCamera").GetComponent<Camera>();```
This is a Null Ref Waiting to happen..
my game is very good rn
How would you assign a integer to a string in a list?
if that's possible
basically I have a varialbe and I want to assign more than one integer value to it
huh ? which type is the list ?
yea please disregard that
can I assign more than one integer to a variable?
actually how could i make a designated area for the drawings?
well you could yeah
how would i go about doing that
what are you trying to do exactly ?
you can make a tuple
give an named variable stats like strength is 5, speed is 10 etc
alr ima look into that, thank you
it's been sometime since I used Unity while I was focusing on drawings
yet nothing still happens when i press q
did you fix the error first?
I don't know hot to fix the error
but it seems that it takes me to there also what do you mean by "store these cameras in the beginning of the level"?
if you dont fix the error the rest of the code wont run..
meaning you should put them in public or [SerializeField] private and just assign them inside the inspector
[SerializeField]
private Camera mainCamera, mainCamera2, pixelCamera;```
then remove the = Find, this will guarantee those are assigned
How do u make animations for ur movement
yea
which one?
wdym which one? assign them inside the inspector
I meant when oyu said "remove the = find"
with Animator and some animations ?
how do i make the water not turn into a trampoline
i need to add enough force so the player stays at the water surface
without bouncing
oohh all the ones that have to do with the camera
you have 6 of them on this script alone
use the newly created variables
Animations when I move
move with script?
would it result in this?
now remove the lines completely, the Camera ones
No
I got all the movements but I don't know how to add Animations for it
then I'm confused what you're asking, you're in a code channel
Bro _
like this?
huh?
oh right
Your force is always 50, you could make it depend on how deep you are. But anyways I don’t know proper water physics
true
well it seems to be working right now, but except for that the camera screen doesn't fade to white when i pressed q to teleport to the other door and then the screen turns to normal
fading background color of camera doesn't make much sense to me
your objects will be infront background of camera
just switch it out from camera to a UI Image stretched to Screen
then fade the alpha
you can easily just keep current code and make one color full alpha and other with no alpha
three ui images here
alpha?
what are those supposed to be and how are they related to changing camera background color ?
did you ask me to switch out from camera yo a UI image stretched to the screen?
you want to just fade white image?
like in Kirby old games where you go in a door and the screen faded to white and then to normal when you are in another area
yea
IEnumerator FadeToColor(Image fadeImg, Color endColor, float duration)
{
float elapsedTime = 0f;
Color startColor = fadeImg.color;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
fadeImg.color = Color.Lerp(startColor, endColor, t);
yield return null;
}
fadeImg.color = endColor;
}```
na sorry fixed the edit
also send code you write in code snippets like here
code snippets?
!docs
I don't know how to do that
!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 need two colors one with full alpha one with 0 alpha
fadeIn and fadeOut respectively
even if I wanted to, it just won't sent because of text being too long
how do i add alpha?
only when you send short snippets, kinda did not need the whole class this time lol
tag names?
Color fadeInColor = Color.white;
Color fadeOutColor = new Color(1, 1, 1, 0);```
you can prob get more fancy results using a curve on the float of alpha only or maybe even dotween
public string playerTag = "Player";
public string interactionButton = "q";
public string player2Tag = "Player2";
public string interactionButton2 = ".";
public AudioClip doorSound;
public Transform teleportTarget;
public float fadeDuration = 1f;
public Color fadeColor = Color.white;
Color fadeInColor = Color.white;
Color fadeOutColor = new Color(1, 1, 1, 0);
[SerializeField]
Camera mainCamera, mainCamera2, pixelCamera;
sure, not sure why you need to send every step you're doing lol
hopefully you're somewhat understanding why you are changing what you're changing..
I just wanted to make sure that i'm placing them in the right places
also should I put fadeInColor and fadeOutColor somwehre?
you thought they were for decoration only 😅
XD
ok think about your method FadeCameras first
which, should probably now be FadeScreen
StartCoroutine(FadeToColor(...
what you think goes here
delete some of the line?
so you dont want to Fade anymore?
you're literally replacing the two things you changed
make the fields for the image components you have
plug them in the method and ur done
I mean when you send me this StartCoroutine(FadeToColor(...
I thought that I'm supposed to deleting some of the line
can someone help me stop the player from bouncing on the water surface?
no it was more of like a quiz
I'm not good with quizes
hoping you at least took away some knowledge from this change but 🥲
I didn't know this was a quiz, since I am not a fully-focused person
would probably query for water another way
what way
there is this object with navmesh attached and nodes telling the object where to navigate, on destroying i need to spawn a tank. But when i spawn the tank, they are either stuck at some node on the map of some level or stuck on the ending node on the other scene
depends how underwater you want it to be, I put a sphere-like check on the players head usually or you can do chest
mainCamera, fadeColor, fadeDuration
using velcoty random - number , seems to magic
no , camera is not part of this anymore
thats the problem
How do I ensure that no matter what two gameobjects will be connected at a point. So like in a car, you have 4 tires. obviously the 4 tires are moving and your chassis is going along with it. but how can i ensure that the chasis stays where it is relative to the tires even when the tires are moved.
you literally put the same ones are the old ones..
wrong
thought it was clear background color on camera does Nothing with sprites infront of it..
then what am i supposed to put there?
did you not write any of the code ? you need the do the same thing you did for the camera..
writing random syntax like that does nothing
..all the camera stuff needs to be gone and replaced with Image component , that is all..
camera.backgroundColor has no affect being behind sprites..
so its a useless fade
oh ok
I think its a couch co-op
it is coop
oh okay, so split-screen, okay
you cannot write too short
bot doesn't like that
ideally keeping from spamming vertically
@rich adder can you assist me later pls? once you are done helping him
just ask your question! there are hundreds of people that can help lol
I'm a girl
no one else is helping rn 😦
my bad
it's ok
your question and video is scattered around, its not easy to read. Should've made it one message
Also where is the code
yeah gimme a min
sounds more of a question for #⚛️┃physics
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
when i call it on start, it works on few levels that the tank spawns, but on some levels it doesn't work. I can't seem to figure out why
hi
you have to make sure you are spawning close enough to navmesh
or better yet on it
do a SamplePosition first
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
the other code which is responsible to navigate the object on the path, i dont know how to integrate it into my newly spawned object so that the object follows the same path. From what i can understand i need to connect the 2 scripts but i dont know how exactly.
what might have happened here? it was 2.7 and added 0.1 to it and turned into this
nah cause i think i can do the physics. i just need to know how i can make sure the children stay tied to the parent
float imprecision
do i need to round every float? 😦
no i think its probably close 2.8 is just showing like in inspector
Does it truly matter that this number is exactly? You can round when showing stuff to the user but usually you dont need to round internal values
it looks bad to the user but yeah I guess ill just round it before displayingg
and those objects are physics objects?
lol
then how are you moving them ?
use the constraint components then
their position
i meant the method smart face
🤣 i was being serious
their position
i wasnt using a rigidbody or a cc. literally their position
their position isn't a method..but ok
are you're saying you are assigning it a value?
just use the constraint component then
im still working on the implementation
kk ty
just so you know AddForce doesn't work while .velocity is running not sure if you knew that
also dont see anywhere you're incresing jumpHeight based on Jump input held
it probably breaks cause you have soo much going on the script is kind of a mess
Reduce gravity on player while player is in air and moving up and holding jump
That's a good approach I always use
all you really need is increase a float number by GetKey
Restore otherwise, of course
Hi again i try to make Scriptable Object that store bool value at 2 states initial - "initialValue" and runtime "value"
But i can't figure out how to set value to be same as initialValue at open game (i mean on what even i should call Initialization function?)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RPG
{
[CreateAssetMenu]
public class BoolValue : ScriptableObject
{
[SerializeField] private bool initialValue;
[NonSerialized] private bool value;
public bool InitialValue
{
get { return initialValue; }
}
public bool Value
{
get { return value; }
set
{
if(this.value != value)
{
this.value = value;
OnValueChanged?.Invoke(value);
}
}
}
private void Initialization()
{
Value = InitialValue;
Debug.LogWarning("Change BoolValue to: " + InitialValue);
}
private event Action<bool> OnValueChanged;
public void ToggleValue()
{
Value = ! Value;
Debug.Log("BoolValue toogle");
}
public void SetValueByObjectState(GameObject targetObject)
{
Value = targetObject.activeInHierarchy;
Debug.Log("Set BoolValue by hierarchy to: " + targetObject.activeInHierarchy);
}
public void SubscribeToValueChanged(Action<bool> callback)
{
OnValueChanged += callback;
}
public void UnsubscribeFromValueChanged(Action<bool> callback)
{
OnValueChanged -= callback;
}
}
}
{
Value = InitialValue;
Debug.LogWarning("Change BoolValue to: " + InitialValue);
}
I might be dumb, but won't
{
Value = InitialValue;
Debug.LogWarning("Change BoolValue to: " + InitialValue);
}
``` be what you want?
or void Start(){Initialization();}
Use a second nonserialised variable as a flag, and check in the getter if it's false - if it's false, set it to true, set value to initialvalue, return value. Otherwise simply return value
how do i start my unity game but in full screen
I were thinking this gona work too but sadly ScriptableObject doesnt call Start since its not component(?)
a yeee... well then call it from somewhere else :))
ty
That's sound like a working solution but more like hack then it doesnt sounds great to do like this with hundred of scriptable objects to make an additional flag and make unnecesary condition check at every get call
Fair.
I'd have to refresh my memory on specific scriptableobject methods to see if there's anything that can help you, but a editor script could help you as well. They're not as intimidating as they sound xd
Custom inspector I mean
Yeah sure i thought too about some kind of "bootloader" or smth but i belive theres a better solution then manually put every scriptable object like this to script that gona call function on each of them
You can also use Nullable<bool> instead of a separate flag. A cleaner option imo
I think its about "GetKeyUp" it only works when u release key as function name says Get Key Up 😛
Instead of calling jump with the time held, consider calling it immediately, and reducing the gravity of the rigidbody. Restore it when spacebar is not held
I’m trying to use the virtual scripting, but for some reason my all of my nodes aren’t in my script graph and I can’t find them
Uhhh did you save it before closing it last time you used it?
Never mind I found out how to fix it for some reason put me like 1,000,000 miles away from where all my nodes were, but I hit overview and it fixed it
you never set isJumping to false, which means the gravity is now forever changed
you need to set it to false when your jump button is not pressed
you're adding half of a reverse gravity artifically upwards, when holding jump. You are turning off normal gravity when grabbing a ledge
but when you're grabbing a ledge and holding jump, the half of reverse artifical gravity is still applied
For some reason, my game object falls even when fall = false. https://pastecode.io/s/vw02fvmw
did you turn off gravity for it?
in the rigidbody2D settings
gravity scale should be zero
if you're moving it from within the script
That was the issue, thanks
maybe
if (isJumping && myRB.useGravity)
{
myRB.AddForce(Physics.gravity * (jumpGravityMultiplier - 1), ForceMode.Acceleration);
}
?
sadly, I don't know enough about your project to help, but maybe there is a good solution along that path
anyway I'm going to sleep now
Any idea why my script to change image of button on start would not work?
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
namespace RPG
{
public class ImageByBoolValue : MonoBehaviour
{
[SerializeField] private BoolValue objActiveValue;
[SerializeField] private Image image;
[SerializeField] private Sprite trueSprite;
[SerializeField] private Sprite falseSprite;
private void Start()
{
setImageSpriteByValue(objActiveValue.Value);
}
private void setImageSpriteByValue(bool value)
{
if(image != null)
{
Debug.Log("Obj image set : " + this.gameObject.name + " -> " + value);
image.sprite = (value) ? trueSprite : falseSprite;
}
}
}
}
All properties are setted and it returns true so i expect to it change image from falseSprite to trueSprite but it doesn't on Start
(later if i change flag manually or by click for example it works)
OnRenderImage?
nah same effect 😦
Is the image null?
Nope
Are you receiving any logs?
On start its same as falseSprite
Define "work"?
This Debug.Log("Obj image set : " + this.gameObject.name + " -> " + value); gives me log in console
Show what it logged.
It'd only change from false sprite to true sprite if it were false to begin with and if the value was true.
Debug.Log("Image : " + image);
Debug.Log("image.sprite.name: " + image.sprite.name);
Debug.Log("falseSprite : " + falseSprite.name);
Debug.Log("trueSprite : " + trueSprite.name);
Debug.Log("flag : " + value);
Debug.Log("GameObject : " + this.gameObject.name);
ohh my bad flag somehow is false?
What didcs Debug.Log("Obj image set : " + this.gameObject.name + " -> " + value);logged?
Wait wrong object on screen
I changed this Debug.Log u wrote to this above with more informations
All looks fine but image ain't changing when it's called from Start function
I'm uncertain what the actual problem is but if you believe it's correct and simply not updating the canvas button, you can try https://docs.unity3d.com/ScriptReference/Canvas.ForceUpdateCanvases.html to force all canvas' to update.
how to i set or find a working variable?
simple capitlization problem
strings are much caseSensitive
so what would work
@ivory bobcat i don't think it is i added Debug.Log after changeing it and it have still wrong sprite like it didn't evevn change value under image.sprite
idk did you make the field for it ?
I dont even see you defining it
Show your current method/function
yeah how do i do that
private void setImageSpriteByValue(bool value)
{
if(image != null)
{
Debug.Log("Image : " + image);
Debug.Log("image.sprite.name: " + image.sprite.name);
Debug.Log("falseSprite : " + falseSprite.name);
Debug.Log("trueSprite : " + trueSprite.name);
Debug.Log("flag : " + value);
Debug.Log("GameObject : " + this.gameObject.name);
image.sprite = (value) ? trueSprite : falseSprite;
Debug.Log("image.sprite.name after chang: " + image.sprite.name);
}
}
And last debug returns name of sprite that was before change
I dont really know much about #763499475641172029
You'd have to define what forwardSpeed is
I guess somewhere in the graph , no clue about visual scripting
Add a final log:cs Debug.Log($"The object we're looking at is {name}, click me to see it in the Editor", this);
Verify the inspector values and that it's the expected object
In inspector it also shows wrong value
Im quiet sure it's somehow about event life cycle but idk how fight it
Cause when i use this function from an button it works perfectly 😐
It looks correct. The flag was false so your result would be the false sprite.
Which was layerbase
can we talk about IEnumerables? I have a list of type Competency that is returning null on my calls to it in other methods... 😦
The strange thing is I've got a display area in my UI that is displaying the various Competency titles and is a parent object to an Improve button that I'm using to increase the rank of a competency. I've either got my lambda's incorrect where I'm using them, or the IEnumerable class needs work, or both.
So the flag was true and you got the true sprite layersactive. What's the issue?
i got falseSprite
Are you sure the calls to the property is null and not the call to the class that holds the property?
The image said
The logs are correct so the issue is likely something else?
And yes, wrong lambda context could also break this
I'm not sure what that means XD
I'm kinda in mind that calls to the property are good (get values in display are valid)
For instance, your image reference may not be the expected image cs Debug.Log($"Click me to see the image we're changing", image); @young wren
When you are calling the list in your function, are you sure the list is null and not the class? like this part -> holder.list
Before I start asking such things, can you show your code?
there's a bit to show - can you send a link to pastebin or other?
!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.
thanky
warning: psyhazard
https://hastebin.com/share/qofikeguve.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I know there's some code missing from the display script (I haven't implemented the display of a competency's rank)...
it might also have something to do with the fact that I'm not Updating my displays
And what part is returning null?
also a note, your singleton thing in the awake would destroy the singleton if you instantiate a second one by fault, did you mean to do Destroy(gameObject) there? If you get a second one you are left with none afterwards, or rather a reference to a destroyed gameobject
the ImproveCompBtn call to competenciesScript is returning null
which Awake? 😛
Competencies awake
I kinda did that on the fly - I wasn't sure if multiple instances would be throwing exceptions
I'm an IEnumerable virgin X)
Ty for try help
Restart fixed issue ...
It wouldnt throw errors, but the first one assigns itself as the singleton, if you accidentially spawn a second one, that one would destroy the original one you spawned and then does not assign itself as the singleton, so your CompetenciesInstance would be a reference to a destroyed GameObject
cheers - that's something I want to avoid
Which line is it exactly that throws a null where you dont expect it?
Can someone help me? I need my hands to collide with objects and not phase through. Its for unity vr
ImproveCompBtn script, line 27
Does either your hand or the object you want to collide with have a rigidbody component?
That would be an empty line?
line 163 in the dump
ahh
Yes my wall does
Is your wall marked as static?
Top right, a little checkbox
Are both scripts on the same gameobject?
Oh, no it is not marked static.
Alright, thats good
do you want your hands be blocked by the wall or do you want your wall to move when you hit it?
so my door does work i dont know if its becuase my hands phase through it so it doesnt open or its bad colliders.
with either one
so you want to move the wall/door with your hands?
no - the ImproveCompBtn is on multiple Buttons and the Competencies script is with a parent panel
well i want mostly my hands to not go through the door. But i also want my door to work so which ever one is better i will do.
TryGetComponent accesses the current gameobject, it will not find your competencies there 😄
i can send a video if you want to see the situation?
would be perfect
lol that sounds so simple
Try using Competencies.CompetenciesInstance instead
its a static, so it should be available once you have spawned one instance of Competencies and the awake has fired
thanks - wish me luck
@silk night
Dont mind the wisphering and stuff
It can open slowly with two hands but i want to hit it with one hand and it opens like wide enough and smoothly
i have sphere colliders but i dont think their doing much because they dont seem to be colliding correctley
do u know the settings i need for that?
to me it looks like the only thing that can interact with it is the flashlight
Ya probably, I dont know how to do that with the hands tho becuause i can put in the same colliders and it wont do anything
as i said not fully sure about how the hands are handled in unity, never worked with it but i can imagine that the collision resolving does not work fully cause of the "unusual" nature of those colliders, moving directly by 3d input
The flashlight has a small capsule collider but thats it
can you disable the flashlight and see if you can move the door at all?
lemme test it
also this answer at the bottom looks promising:
@silk night i can still collide with it but it still sucks
can you show me the settings of your door rigidbody?
yes
also this video seems to go indepth: https://www.youtube.com/watch?v=VG8hLKyTiJQ
- this answer by unity themselves: https://forum.unity.com/threads/how-to-stop-hands-going-though-objects.1458943/#post-9136957
any idea what could be causing this? https://gdl.space/ejecegozim.cs
At this point i would assume its directly related to VR, and at that point i cannot help anymore, I suggest the links i sent above and #🥽┃virtual-reality if you need further help
you are calling a variable that has not been assigned or has been assigned null
oh you posted code, let me check that
Either your SettingsScript, SettingsScript.main or musicSource is null, check it maybe with an output and find out why its null 😄
I get a null reference at line
''var competency = Competencies.CompetenciesInstance._competencies
.Where(comp => comp.competencyTitle == competencyTitle.ToString())
.FirstOrDefault();''
now. Pretty sure it's the _competencies which is the culprit... but I've tried a couple of different edits on the lambda & no dice
its SettingsScript.main.musicEnabled but i have no idea how a bool can be null?
you are using the constructor of a MonoBehaviour here, never do that, your _competencies most likely never gets filled
sorry about the patch formatting
this is the settings script
gotcha - & thanky again
another gremlin exposed
you are never setting the main, fill it in Awake with "this"
Anyone know how I can add a multiplier to the money
also i think you want to fill your _competencies with a call to CompetenciesList instead of a parameter (that you so far haven't used from what i can see)
oh my god im an idiot
yeah that fixed it thank you 😭
What triggers the adding and how do you want it to react?
I got no idea what that means - lambda's are a killer
It just adds one to the value right now but i want to be able to multiply how much I add to the score
Also I am not sure why you yield return it instead of just returning a list
i mean yeah it does the same, but ive never seen it done manually 😄
it's part of the IEnumerable structure
just do value += multiplier
so I could still use lambda expressions when making calls to an array?
what line would be an example?
I'm sure I got no idea 😦
i mean where are you using it right now 😄
so at first you should add
_competencies = CompetenciesList()
to the Awake
Next replace CompetenciesList() in line 27 with competencies so you used the cached value
var competency = Competencies.CompetenciesInstance._competencies
.Where(comp => comp.competencyTitle == competencyTitle.ToString())
.FirstOrDefault();
here again? just maybe formatted differently?
that is a lot of stutter in 1 line
oh yeah that lambda usage has nothing to do with it being a list directly
its just a syntax for anonymous functions
also use
```cs
CODE
```
to post code here
can someone help me in #archived-urp plz 🙏
also you can ditch the .Where and just toss the lambda in FirstOrDefault
oh, it's three ''' now
var competency = Competencies.CompetenciesInstance._competencies
.FirstOrDefault(comp => comp.competencyTitle == competencyTitle.ToString());
for example
I got it to work but now the score isn't showing on the screen only in the Inspector
nvm got it
I see you are having trouble with lambdas, to make you understand it easier ill give you an example of what they are, you will understand easier 😄
thanks for the tip there
also would try and reduce the stuter a little like no need to call the intance CompetenciesInstance
just instance would be good enough
cheers - it's grade 4 average for me
also these linq stuff and lambdas you can just 100% ignore if you want
its really just shorthand for stuff you can do with a loop
yeah, I got that much
Yeah, I only really use it for single-run things that I want to take up less space. Pure readability usage
Edit: linq specifically I mean
can someone help i am using a script from yt and i can only look up and the camera doesnt follow the player
!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.
class Test {
public void Testing(string value) {
Debug.Log(value)
}
public void Main() {
var list = new List() //Imagine this is a filled list
list.ForEach(value => Debug.Log(value))
list.ForEach(Testing)
}
}
Both calls to foreach do the same here, one is a named function, the other one is anonymous, the things before the => are the arguments, behind it is the executed code (mutliple arguments can be done like (value1, value2) => code)
yeah if something gets complicated, like more then a where and a select i will just use a loop, or a function to yield from. just easier to read and exapand on and make sure its not doing extra work
thanky - that adds some clarity to my thinking
yeah its function shorthand, just there is no name for the function, and args come first
Is it normal to have tons of scripts layered onto game objects? I moved to the MVC pattern and now have 14 scripts layered onto a single item: moving, shooting, health, selectable, localGUI, grouping, faction. There's no end in sight.
its a approach, as long as its work for you
Yes in that case its normal, if you dont want to layer it directly onto the gameobject i can suggest the ECS pattern, in that case you have background systems doing the work and you just hold components on your gameobjects (not the unity components, component is a term in this pattern)
though feels odd you would have GUI stuff on the same object
like moving shooting health etc makes sense UI not so much
ah
It's all the stuff the other views don't directly manage.
No.
Read the bot
why do i have to go to a link
Because it is the rules here
Which is why there is a bot command for it
- Your script only modifies the rotation of the playerCamera
- Your script only modifies the x axis of the rotation of your camera, so you can only look up and down
Is that mobile? For me it just shows up as code
Yes. Embeds only happen on desktop
Which is why sending it like that is against the rules on this server
how does the ECS differ from MVC? I still have individual aspects that control functions/features in different scripts, but I separate them between control (e.g., user input handling) and graphical representation contrl (=view)
Ahh got it, ty
But if someone can and is willing to help, it's all good
Ecs is not separated by the same lines I guess. Systems can control visuals or input or whatever
Components are simply data containers, which can also hold visual or input data
Your objects (entities) like the player just store a big list of values (components), depending on the state of those values they get manipulated by systems [Entity, Component, System, in short ECS]
Very simplified example: your players velocity component has a value of 1, so the movement system changes your players position by 1 value each frame
Entities are basically just indexes
sorry im not sure how to do that
Systems are logic
Components are data
Entities are indexes for the components being acted ok by the systems (and form archetypes inside chunks)
I have SOs + a separate object for dynamic stats as the entity. Every player has a link to a base-SO and a live stats object. In MVC, the controllers change the live stats object, and the views listen to changes of the live stats to update the interface. How does this loop work in ECS?
The SOs+live stats object form the model.
They were pointing out what is wrong, not what to do
I can't help without seeing the code though, so I dunno
If you got it from a youtube video it should be in there, if its not you should test around with the line that revolves around the camera
it really doesn't like that cast 😦
Make the CompetenciesList return an array instead of that IEnumerable shenenigans, and rename the function accordingly 😄
lol will do
I created a thread to talk about it in there, dont want to spam the main channel 😄 #1218032527680208996
decided to take another approach to the endless runner genre, found a sample scene with movement and grapple mechanics, and tried to repurpose my code to procedurally spawn buildings for the player to swing from using a trigger box to determine whether to spawn or destroy a building. the code works on start, but none of the other code works and idk why
What’s the issue? The building isn’t moving?
What exactly is going wrong?
I dont want the buildings to move, I want more to spawn. I want an endless amount of buildings for the player to swing to/from
this is broad of a question
how do you want to spawn them, where in relation to player, etc..
using a trigger probably wont scale well
I thought my code handled that tbh. 0-51 of whatever measurement that is away from the building that the trigger box was entered/exited of
no because you need to pass it that
you're putting world coordinates
I thought i did lol
those are world coordinates?
how do I make it local, then?
yes you would need to use +
Vector3 thePosition = theBuilding.transform.position + new Vector3(etc.
I thought I did lol
so how would I modify this code to do that?
if (other.gameObject.CompareTag("New_Building_Trigger"))
{
Instantiate(Building, new Vector3(Random.Range(0,51),0, Random.Range(0,51)), Quaternion.identity);
}```
transform.position + new Vector3(etc.
if you want it to relation of the building that spawned new building
phew
back to a non-error state
also Random.insideUnitSphere is also an option
hows that different from the random.range?
so for your first suggestion, it would be:
if (other.gameObject.CompareTag("New_Building_Trigger"))
{
Instantiate(Building,Vector3 thePosition = theBuilding.transform.position + new Vector3(Random.Range(0,51),0, Random.Range(0,51)), Quaternion.identity);
}
???
and what is thePosition and theBuilding?
dont mindlessly copy example code
try to understand what is happening
Vector3 thePosition is a made up example name, and it certainly would not be declared inside a method param like that
I dont understand what is happening or how to apply what you mentioned
go through the basics then
start with c#
learn how to store info in variables etc
I know what variables do, but I dont get how to apply what you mentioned to my situation or what that difference does
If anyone has a fix to what i posted in #archived-code-general I would appreciate the help ty
i explained what it does, it adds onto the offset
Please don't cross-post or redirect from other channels.
#📖┃code-of-conduct #854851968446365696
I tried to apply what you mentioned to my code though, and I wanna make sure I applied it correctly. I dont have a variable for the position or the building, though, so the variables dont make sense in the current context
Okay thats my fault wont happen again
then why didn't you use the second example ?
I missed that
so would it look like this?
{
Instantiate(Building, transform.position + new Vector3(Random.Range(0,51),0, Random.Range(0,51)), Quaternion.identity);
}
Try it
it still doesnt work
then verify the code is even running past if statement
how can I do that? I know how to do that in unreal, but not here
Debug.Log($"hit {other.gameObject.name} tagged with : {other.gameObject.tag}");
Might be good to learn the common debugging methods. Look it up.
It took so much time to really be able to use the debugger stuff in rider efficiently but i always go back to caveman tactics anyways and just Debug.Log 😄 i cant be the only one
I do it often too. Specifically when I want to diagnose a system as a whole and not fix one specific bug.
no debug about what I put in the script, but there is this thing from a plugin that the file came with on install
That a screenshot of the whole console tab.
I remember debug.log now, its been a while since I had to type that. yea, I only ever use that loll, its pretty effective
The error is very descriptive of whats going wrong
Hey i got a question on a bug and its most likely user error
i got bones and animation but how do i assign that to each other
everything ive done has failed and im stuck t posing lol
Is that code related?
im annoyed that idk how to fix my procedural building spawner
Break it down
And go learn the basics.
that doesnt really help me with this problem specifically. its definitely important to learn, although I thought I had learned them, but thats not really practical advice for this particular coding problem. also, I am used to unreal blueprints, and its been a while since Ive messed with code, so I am familiar with programming enough to know the basics, just not really able to figure out this problem here. Im trying to get back into unity, but it annoys me that I can run circles around myself in unreal compared to here
how can i learn the basics? what do i need to install?
a crypto miner that lets you download ram
fr
Well, yes, telling somebody to go learn the basics won’t fix your problem, but it’ll make the process of us helping you much easier for everyone
And you might even figure it out yourself
