#💻┃code-beginner
1 messages · Page 92 of 1
What does all this mean?
https://gdl.space/fadeleyuma.cs
Then it'd seem enemy is null
ah alright, I'll try to get rid of characterController later as I learn more then, thanks for notifying it
is there any other easier way of doing it?
Is your code editor highlighting errors?
Do you have a bunch of red underlines in your IDE
Nope, and I'm using the most recent version of the Microsoft Visual Studio
!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
sure -- just do:
float angle = Vector3.Angle(eyeVec, toPlayer);
if (angle < fov) {
if (!Physics.Raycast(...)) {
// player is in FOV, nothing is in the way!
}
}
I prefer to test if there's nothing in the way on the way to the player
You could also test if the raycast hits the player
Either works.
is this a good or bad thing?
How about you tell me, I have told you what your error means many times now
well, given that this is inside an if statement that tests if the enemy is null, that seems a little odd...
think it means i should switch to python
that's not going to fix your problem
Unless the code they've shown is different from what they've written enemy cannot be null, it's guarded by the if statement
||I am fully expecting they moved the log somewhere else for no reason||
then pseudocode it is ig
I have to wonder if the code has changed again, yes
@hardy foxI suggest you take the next few days and actually learn C# instead of just trying to get people to solve your problems for you
because what you're doing right now clearly is not working
i wish i could but got hella school work
if you can spend this much time in discord, you can take 30 minutes a day to read the C# docs
i havent made any chnages
that doesnt mean you can magically skip learning to do the hard stuff. Instead of flopping around in unity, practice the basics of c# and do console apps.
juat wanna get passed this error and ill actually take a break to leran c#
cart before horse.
can i ask why you guys use Unity rather than other engines like UNreal
That's not how it works
learning C# is how you'll get past this error
u wouldnt believe how many people say the exact same thing. you "just" wanna do this one thing!
switching engines isn't going to solve your problem
I know thats what you're thinking
unity is by far the easiest 3D game engine
I just want to finish my NFT Blockchain MMORPG with full voice acting and infinite world generation then I'll learn C#, okay?
I'm so sorry for interrupting, I looked at the modifying page for MVS, and it already has Game Development with Unity selected. I'm still not seeing anby red underlines with my errors, though, and I'm mnot sure what to do to fix it.
ive tried other engines like Defold/GoDot, unity is alot better i just wanted to know whyu guys chose it lol
The guide has a second section where you modify Unity's configuration. Did you do that too?
im just wondering if its better to learn C# or python, which one will be more beneficial for me?
Oh! I didn't see that part! I'll do that as soon as MVS finishes updating; thank you so much!
It's 1am lol, so someone else will take the lead if you have more issues with it
I've never met anyone whose tried to make a serious game in python
I don't know whats more beneficial to you
Thank you, I really appreciate it! have a good night!
not just game design wise, in the future i wanna do CyberSecurity or something like that
so wondering which langauge is better to learn at a yyoung age
English
I'm currently in school for cyber security. Your best bet is Javascript and HTML just so you understand the basics of web design, before you begin to attempt to learn security. That's what my school told me to do.
Actually pseudocode 🤓☝️
Also, I am in my first semester of school for it. Correct me if I'm wrong.
I can do the basic html stuff
Once you learn one to a certain degree, it would be easy to learn the other one(though C# would probably give an upper hand).
Anyone know if game design actually pays well?
game development is notorious for being a terrible industry for the worker
this doesnt make a whole lot of sense honestly, cyber security is more than just web dev.
I have an issue with the code in my test build, my build shouldn't have any playerprefs on first launch, but apparently it does, to my script atleast. Here is the code void Start() { if(PlayerPrefs.HasKey("ActiveScene")) { PlayerHasSave = true; } }
It might be using what you have saved during the testing in the editor.
How can i clear them then?
I was told that Javascript is a prereq, however, with that being said, my advisor screwed me over and is making me stay for an extra year and a half because she just forgot to put me in some classes. take what I'm saying with a grain of salt LOL
javascript and html are frontend. they have nothing to do with backend cybersecurity
this sounds like highschool. whoever told you this doesnt know what they're doing
@meager gust dw as soon as I figure out my current error, I'll release my game and you'll be able to play the best game made in unity by a noobie🥱
or they meant specifically like "making a secure web app" where you arent vulnerable to basic stuff like sql injections.
Something easily googled
https://docs.unity3d.com/ScriptReference/PlayerPrefs.DeleteAll.html
Yeah I have a different advisor now, my old one wasnt specifically a CIT advisor
In cyber security do u use ruby (idk what it is lol)
Thats gonna clear my editor's playerprefs too though.
Yes, it's all the same location
but a new build shouldn't use playerprefs from the editor right?
It's not in your editor. Player prefs are a file.
Or rather an entry in a file(registry).
there is no predefined language for it, people use whatever they want if it fits their requirements. This applies to almost everything coding related. security has many different aspects. You said you wanted to do cyber security, but you havent done the basics so it doesnt make sense to already have chosen a field. Anyways yea this isnt unity related at all
Also, something else i notice, is that in the editor, playerprefs claims that the key being fetched, doesn't even match what it was in my build.
My build, fetched a old scene named "1.21 Decision", the Value of the same key, is "1.1 Begin" in the editor.
Must have overriten it. Regardless, playerprefs. On the same PC are shared between the editor and the build.
Would a clean build make a change?
No.
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
isnt this intended? there is a player storage folder and an editor folder
The value it fetched from that key, doesn't even exist though.
Unrelated yes , but I believe as I'm starting coding now I'll put do most people my age when I'm older (MIT is the dream), I wanna do something CS based, Software development seems saturated, but Cyber security seems interesting and loads of future jobs.
i dont get what you mean, you are saving a string. the string doesnt care about what you did to your scenes. You could save gibberish if you wanted to
software development is saturated with people that only care about money
I like money tho
people need money to live.
that's not what I'm trying to say
How else am I going to buy all those unity store assets
Hmm... Did they change the playerprefs in the last few versions. I remember the editor having the same storage location as the build.🤔
Guys one thing I've always wondered, if you are good at Cyber security does that mean you have the skill to hack ?
Just a question
im making a 2d topdown minecraft like and I need some help with shading, I want it to look like terraria's shading. I have no clue what to do pls help
How do you detect that a client has disconnected from server?
timeouts
if server hasn't received a message from client in 10 seconds, he's probably disconnected
ah i see, which function do u use to check that? sorry i don't have a lot of experience with unity netcode
Many sprite shaders out there on youtube, then after you attempted a few and have questions still then try #archived-shaders
Thanks!
no idea, never used it. try #archived-networking
!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.
https://gdl.space/ivuyiqepez.cs Hey guys, am i missing something? For some reason i cannot assign an On Click event method, I am trying to assign it to the ClickedOn() Method, but the list only has MonoScript: String name.
You dragged a script in
You need to drag in a GAMEOBJECT in the scene with the script
oh damn, i named the script the same thing as the object and accidently did that, thanks!
Keep in mind, it has to be something from the hierarchy, so even dragging object (prefab) from down there would not work
Its a prefab
Well, if the prefab you drag in is a child, it's fine
Otherwise it will not be
A prefab is a blueprint, so it will not know which scene object to use at runtime unless there is a transform relationship (like a child object)
it should, but for some reason its not working, let me share my inventory manager script, https://gdl.space/okokeqoxus.cs
Probably some dumb mistake somewhere in there, my brain is fried trying to get this done by Sunday for a class lol
It should not.
You cannot reference the concept of something and expect it to act on a real object
You cannot drag a prefab in unless it is a child
Im instantiating the object in the manager
The script is ON the same object, right?
Just drag that component from itself
Irrelevant
Maybe I'm misunderstanding you. Is that what you were trying already and THAT is not working?
(that png seems broken on my end atleast)
Let me restart, Currently i have it set up like this (first screenshot) InventorySlot Script is on the Inventory Slot game object prefeb, The On Click() is populated with the correct method now, When i run the game, the list is populating, but when i click on the list which should then display the item description that on click event is not working
Ah, it was a remix and worked for a second. Weird it turned into a dl link
Actually, hold that thought, i think there might be something broken with my player inventory script. thats probably why its not populating
its not pulling the data from it, just putting the placeholder text up
let me look at that
Hello, where do I go for questions on a problem I have in my unity project?\
Ok, i fixed that, but thats not what was causing the button to not trigger the on click event
so it populates the inventory list, but when clicking them, that function is not being called
Hello I have an issue with my code in a tes build I made for a type of spiderman swingin, Basically it lets the player swing and does a swing motion but iut drags the player down and when it reaches the halfway mark it stops and starts spinning/tweaking, is there anything i could do to fix it?
You haven't posted any code.
People aren't mind readers
!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.
Bump, code for reference : https://gdl.space/okokeqoxus.cs https://gdl.space/ivuyiqepez.cs . Thanks guys!
I did try that and it is not working
i have a code that takes an object prefab thats on a list deletes itself from that list and sends it as an object to another list. The problem is that i want to send the objects prefab and not the object itself so i can delete it and still have it on the list. Is there a way for me to send image gameobjects prefab to the list and not the object itself?
Just send the prefab and not the instance of the prefab.
that function is not being called
public void ClickedOn()
{
Debug.Log($"The clicked on method from {name} was called", this);
if (thisItem)
{
thisManager.SetupDescriptionAndButton(thisItem.itemDescription, thisItem.usable);
}
}```
My head hurts reading the question, but if you're trying to keep the reference to the prefab on the instantiated object, then you can just make a variable for it and insert it into it when you instantiate the duplicate.
Actually, probably can just set it on the prefab of itself?
Would this be where i would ask for help in a beginner level?
yeah
that would be in #💻┃code-beginner
I want to reference the prefab and not the object itself. Is there a way for me to reference the prefab and not the object itself?
My interpretation.
This is the beginner coding channel, try #💻┃unity-talk for non-coding questions.
Hi! sorry stupid question, im a beginner to unity and i just sliced a sprite sheet and made a player GameObject, i added the sprite renderer component and i cant figure out how to add the animations
I want to get a game object to follow me when I get close and to stop when you get away from it you and roaming ya know just a generic enemy ai but I’m confused by the ; and { stuff
This is the beginner coding channel, try #💻┃unity-talk for non-coding questions.
What have you tried?
I’m new to this stuff just struggling here
My suggestion would be to break the problem down and Google each broken part to see examples.
If you're confused by braces and semicolons, i suggest a basic pure c# course before moving on to unity
ie the following, the range detection, the roaming etc
Hey I wanted help on a dash mechanic for my game, here is how i coded it. I am using Unity 3d. There are two things im having issues with.
- I want to be able to dash in the direction my player is facing, right now, they only dash to the right.
- I want to be able to turn off gravity during the dash, and turn it back on once the dash is completed.
Please let me know if you can help!
Where you set velocity, instead of using the localScale, why not use transform.forward?
how would i use that?
Simply replace transform.localScale.x with transform.forward
so how would you rewrite that line of text?
ok so my game looks like this
im using unity 3d but on a 2d space
when i use forward i launch myself the wrong way
Then try using transform.right
All it did was make me feel silly
The course?
Yep
im looking at this, but im confused on how to implement this into my dashing
🤷♂️
I don't understand
In your coroutine, set it to false when it starts and true right after that second to last waitforseconds
Neither do I why is this stuff so hard to understand
It's a language. Learning any new language (spoken or programming) will seem complex until it begins to click. Then it will feel far less complex
Hey guys. I am having some errors with my code but im unsure how to fix them. this is my code. im tyring to create random movement for a gameobject.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class MovimientoRandom : MonoBehaviour
{
public float Timer;
public int Objetivo;
public float velocidad;
public NavMeshAgent Nav;
public Vector3 Target;
void Start()
{
Nav = gameObject.GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
Timer += Time.deltaTime;
if (Timer >= Objetivo)
{
Objetivo();
Timer = 0;
}
}
void Objetivo()
{
float myX = gameObject.transform.position.x;
float myZ = gameObject.transform.position.z;
float xPos = myX + Random.Range(myX - 100, myX + 100);
float zPos = myZ + Random.Range(myZ - 100, myZ + 100);
Objetivo = new Vector3(xPos, gameObject.transform.position.y, zPos);
Nav.SetDestination(Objetivo);
}
}
im not sure what to exactly type tbh
rb, not Rigidbody
Just like the line above
Rigidbody is the type (a concept)
rb is the specific Rigidbody attached to your player
You have three separate things called Objetivo.
Make those all have unique names first
Ah, two things.
Objectivo is an int at the top, but then you try to set a Vector to it
You need something of the type Vector3 to assign a Vector3 to it
i fucking hate NavMesh
But these aren't even issues with the navmesh
It's with basic c# syntax
These errors would happen even without the navmesh involved at all
this is a weird question, but I wanted some advice. How would you reccomend I go about adding this type of thing into my game? What im specifically referring to is a spike jump, where if you hit down at a spike or enemy, it will propel your character up.
Kinda like a knockback on damage? I would use AddForce in Impulse mode
Or just velocity like your dash, but going up
You already know if you're hitting the spike, since you'd be taking damage. Now instead of taking damage right away, first check if the player is using a down strike. If so, give them upward velocity, if not, take damage as usual.
Oh, to avoid damage. Got it
ye
ok cool
how should i go about making a "strike" ? how would i go about adding a sword, and making it swing. For the controls I want down arrow to be down strike and side arrows for forward strike I dont want anything fancy, something super simple.
Current state of my maze generator. Originally based off of: https://www.youtube.com/watch?v=_aeYq5BmDMg&ab_channel=KetraGames
But then it went through many tweaks. Trying to see what more I can do with it right now. As a player, I feel like something like this would be overwhelming, so I was thinking about encouraging straight pathways more
In this tutorial we're going to look at how to procedurally generate a perfect maze.
The project files are available to our patrons here:
► https://www.patreon.com/posts/84948773
The final script can be found here
► https://dotnetfiddle.net/krlgdG
Help support our work:
► Patreon: https://www.patreon.com/ketragames
Follow us:
► Ketra Games: ...
Oh, I should probably mention I would like advice on how to make it better
Hey, so I have changed my settings, so it should be showing my errors, and I'm still seeing, "No errors" on the dialogue bar. Any advicew is greatly appreciated.
https://gdl.space/fadeleyuma.cs
Can you please scroll these errors to the top?
Wdym by "dialogue bar"?
Actually never mind, you have a semicolon at the end of line 72 @keen hinge
what a crime...
private void OnTriggerEnter(Collider other) // here was a semicolon
{
gameOver = other.gameObject.CompareTag("GameOverTile");
}
```Remove the semicolon, I'd write it like that @keen hinge
i still hate navmesh
So now I only have two errors. I really really appreciate the help.
SerializeField
Not SerializeDField
And nothing is SerializeFieldAttribute
I knew it would be something small like that
I'm going off of the videos my professor has posted in order to make the game, I would assume that it is something he will cover in the future.
This makes me think your IDE is not configured. Did it underline this error?
Or did you only see it in the unity console
The only reason I'm asking here is because hes out of office at the moment.
These errors weren't underlined in your IDE?
I don't believe I have an IDE, And I've attempted to do everything in the guide given by the server.
void OnDisable() // in InputManager class
{
cameraToggle.performed -= CameraControl.Instance.ToggleCamera;
}
```Hey, do you have any idea how can I get rid of null here? `CameraControl` is a singleton, I guess I need it somehow to get destroyed after `InputManager` is being destroyed? It tells me that `CameraControl.Instance` is null
Bruh . . . 🤦♀️
I'm sorry, I'm still learning. Nothing was highlighted by MVS as being improper.
What is MVS ?
Microsoft Visual Studios
Can anyone try to help me understand Persisting Data/Singletons? Trying to have some pickups in a game stay the amount you collected and transfer from scene to scene. (blah blah blah)
It does have errors highlighting, probably shouldn't let you compile this code at all
Some null expert here? 
can somebody help me with this movement that im trying to implement?
Most people call it VS, just so you know. And that is an IDE.
And nothing being underlined means it is not configured
!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
Maybe
If you tell us what you need help with, someone may know.
Look into DontDestroyOnLoad, and additive scene loading
I have this script and i am using the unity input system and i know its getting input correctly but in my script its not assigning the vertical/horizontal input in my script
Show the 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.
Oh... don't crosspost btw. Only one channel per question please
Either this or InputSystem may be best
PlayerManager player;
public float verticalMovement;
public float horizontalMovement;
public float moveAmount;
private Vector3 moveDirection;
[SerializeField] float walkingSpeed = 2f;
[SerializeField] float runningSpeed = 5f;
protected override void Awake()
{
base.Awake();
player = GetComponent<PlayerManager>();
}
public void HandleAllMovement()
{
HandleGroundedMovement();
// Aerial Movement
}
private void GetVerticalHorizontalInput()
{
verticalMovement = PlayerInputManager.instance.verticalInput;
horizontalMovement = PlayerInputManager.instance.horizontalInput;
Debug.Log($"Vertical Input: {verticalMovement}, Horizontal Input: {horizontalMovement}");
// Clamp the movements
}
private void HandleGroundedMovement()
{
GetVerticalHorizontalInput();
moveDirection = PlayerCamera.instance.transform.forward * verticalMovement;
moveDirection += PlayerCamera.instance.transform.right * horizontalMovement;
moveDirection.Normalize();
moveDirection.y = 0;
if(PlayerInputManager.instance.moveAmount > 0.5f)
{
// Move at a running speed
player.characterController.Move(moveDirection * runningSpeed * Time.deltaTime);
}
else if(PlayerInputManager.instance.moveAmount <= 0.5f)
{
// Move at a walking speed
player.characterController.Move(moveDirection * walkingSpeed*Time.deltaTime);
}
}
H e l p
https://gdl.space/acobucajez.cs
So, you have some PlayerInputManager that would probably be the issue
in the GetVerticalHorizontalInput it isnt logging correctly
using UnityEngine;
I don't know what just happened I was trying to get it to underline errors and it did that
And as I said earlier, no such thing as SerializeFieldAttribute
public static PlayerInputManager instance;
PlayerControls playerControls;
[SerializeField] Vector2 movementInputs;
[SerializeField] public float verticalInput;
[SerializeField] public float horizontalInput;
[SerializeField] public float moveAmount;
private void Awake()
{
if(instance == null)
{
instance = this;
}
else
{
Destroy(gameObject);
}
SceneManager.activeSceneChanged += OnSceneChanged;
DontDestroyOnLoad(gameObject);
}
private void Start()
{
DontDestroyOnLoad(gameObject);
instance.enabled = false;
}
private void OnSceneChanged(Scene oldScene, Scene newScene)
{
if(newScene.buildIndex == WorldSaveGameManager.instance.GetWorldSceneIndex())
{
instance.enabled = true;
}
else
{
instance.enabled = false;
}
}
private void OnEnable()
{
if(playerControls == null)
{
playerControls = new PlayerControls();
playerControls.PlayerMovemenyt.Movement.performed += i =>
{
movementInputs = i.ReadValue<Vector2>();
Debug.Log($"Input Received: {movementInputs}");
};
}
playerControls.Enable();
}
private void OnDestroy()
{
SceneManager.activeSceneChanged -= OnSceneChanged;
}
private void Update()
{
HandleMovementInput();
}
private void HandleMovementInput()
{
verticalInput = movementInputs.y;
horizontalInput = movementInputs.x;
moveAmount = Mathf.Clamp01(MathF.Abs(verticalInput) + Mathf.Abs(horizontalInput));
if(moveAmount <= 0.5f && moveAmount > 0)
{
moveAmount = 0.5f;
}
else if(moveAmount >= 0.5f && moveAmount <= 1)
{
moveAmount = 1;
}
}
I am just going off of what my professor has told us to do, he might fix it, or he might make it something
I'm confused, this is code beginner
That is a link to a specific message
Ah, sorry
The one where I told you why you have errors and how to fix it, all in two words 😄
THis is it
Oh, I'm dumb, mixed up people
I'm so sorry I don't understand
Add that line to the top of your script
Ok, so. Just trying to read through it (i'm on my phone. Also, with that length of code you would generally use a paste site like the bot said. That makes it easier to parse).
So you have logs in both scripts. One is saying one value, and the other is saying something different?
the one i posted second is logging 0 but in the other script it logs that it is receiving values so its something with the variables
but idk what
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
what language do i need to learn?
Hmm, that is odd. I would expect it the other way around more. Let me keep looking for a minute
C#
i mean opposite im so stupid
They say C# is difficult
Ohhh, ok. Gotcha
I would disagree. Maybe you were thinking c++ ?
It's harder than some things maybe, but holds your hand a lot
C# probably one of the more beginner friendly languages so good time to start
idk the diference between c# && c++
i only know they have a c at the start
Well, they are simply different languages. Kinda similar. Maybe like spanish and latin
Eh, c would be like latin. C++ is more like Portuguese lol
ooh yeah
c++ is hell
everything is usually built on c++ (well, C rather by influences from concepts from C++)
so you get a little bit out of that learning C# :)
i speak portuguese lol
maybe its a good start
alr alr
I'll try to go from Python to C# then.
I will try to learn
u got this just stick to it!
That is a tough move. Going from dynamically typed to statically typed is a main thing that confuses beginners.
You will get it, but just don't get discouraged by that change
The bad thing is that there aren't many C# courses in Portuguese, and my English isn't the best tbh
but ill try it
Sorry, I keep looking but nothing jumps out at me. I am not sure. Hopefully someone else will see it!
Bro i hate when a tutorial doesnt work when i follow exactly
doing thishttps://www.youtube.com/watch?v=Xg6GvHpWjaE
In this video we begin by building a small play test arena. After, we add Unity's Input system to our project. We then learn how to set up inputs using our newly created input functionality. We end by creating some player classes which will be used to begin controlling our player character.
► Skip Arena Creation 4:38
► Gridbox Prototype Mater...
apps
cool
It is turing complete. So anything
once you learn how to code with the data types usally other languages get a lot easier
databasing is pretty popular with C#, but applications for both desktop and phone appsit's pretty good at too
If I know how to program in Python, I only know Python. If I know how to program in C, I know how to program in all LOOLL
honestly you should learn binary
can i create python libs with c# ?
there's usually libaries for python support. Unity has some but it's not enough to allow you to completely write your games in python. I use it for parsing stuff and editor specific scripting.
what should i do honestly the fact that this didnt work makes me lose motivation
C# or C-Sharp is the programming language behind .NET (dotnet) and the Unity framework. It was created at Microsoft as a C-like object-oriented language and is used to build apps for web, desktop, mobile, and more.
#programming #unity #100SecondsOfCode
🔗 Resources
.NET Install https://dotnet.microsoft.com/download
C# docs https://docs.micros...
It's 135 seconds though, not 100 
(moved that to unitytalk)
Mostly anything. In our age, almost any programming language can do almost anything. And what it can't, it can achieve via native libraries.🤷♂️
Where is HandleAllMovement called from? I assume Update of the parent class?
player manager script
PlayerLocomotionManager playerLocomotionManager;
protected override void Awake()
{
base.Awake();
// Do more stuff only for playerManager
playerLocomotionManager = GetComponent<PlayerLocomotionManager>();
}
protected override void Update()
{
base.Update();
playerLocomotionManager.HandleAllMovement();
}
how do i make anim work? if i click my down arrow key, i want my "DownMelee" animation to trigger
a lot of things arent working so idk how to get it to work
What are they?
Where did you get this code?
im just looking for a way to play my animation
Theirs inherit a Character class.
Lookup a tutorial and follow it exactly as is.
You'll not be able to randomly paste code together and have it working properly without knowing how the code works.
when picking a positive button
how do i select left click
not sure what the exact name for it is
ok sweet
I'm trying to skim through the videos. Which one are you on? I see him adding a lot of this on number 3
It is pretty convoluted code imo haha. Hard to keep it straight
Number 3
Did you read the repository readme? Or watch the video that is linked there?
Should I just completely restart?
im having an issue, where the animation keeps constantly playing, not when i click the down arrow key
Well, I'm not seeing the issue (sorry, I'm also kinda busy at the moment, so I'm not devoting my full attention to it).
I'd say it depends. How much experience do you have? This seems kinda more complex.
I think it would be worth it to start a blank project and just test out the new Input system by itself. Just get something moving around. Then come back and see how it goes. Maybe restart the video series at that point?
Yeah and thank you so much you have already put a lot of time I this
No problem, sorry I couldn't find the issue
No worries
im making a grapple hook in my game and have nerver worked with raycasts before. the code should be taking my player position then making a line to my mouse but When i run this code the raycast that im making is always giving me no hits even if i point my mouse straight at an object with a trigger collider2d.
Input.mousePosition is a screen-space coordinate. You need to convert it to world coordinates with Camera.ScreenToWorldPoint
Or directly use Camera.ScreenPointToRay to get the ray from Input.mousePos
Also ray takes a position and a direction, not two positions
how do i convert mouse position to world coordinates using Camera.ScreenToWorldPoint?
It's pretty simple. cs Vector3 mouseWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
You need a reference to your camera to use it
oh i see also what exactly is the difference between world coordinates and screen space doordinates
Well, screen space coordinates are in the range (0, 0) to (screen width, screen height) in pixels
From corner to corner
World coordinates are, well, just that. Measured in units in the world
oh i see k well ima try using what you told me to do and see if it works and ty for the help
I need help on one more thing.
I only want to be launched up when the sword hits the spikes, not when the player hits the spikes.
How do i go about this?
Put a script on the sword to check collisions, or use a spatial query like raycast when you swing the sword down
I think you can just check the contacts from collision and see which collider was hit
I always forget if it's contact.otherCollider or contact.thisCollider...
I'm assuming that the sword is a child of the player.
If not, do what Aethenosity said
so i did what you told me to do and i changed it from mouse.position to mouseworldpos and i then search up how to convert the pos to a direction like you said it needed to be but the code still doesnt seem to work i even made a debug ray to try seeing the ray but that also isnt working. it keeps giving me nohit
Can you not see the debug ray at all? It's probably because you are giving it 0f as duration
oh let me chaneg that rq
ok im trying to check for collision, the script is currently on the sword, but when it hits the spikes, i get no log message
oh okay i see it now but its just not detection the collisions
The sword has a collider right? and the spikes do too? And NEITHER are a trigger?
Is the ray where you need it to be though?
ya
Show me?
both have box collider, and neither are trigger
@true heart You are currently casting a ray from the grapplestartpos to your camera, pretty much
Hmmmm.. the parent rigidbody should count towards the collision... I think.
One is required for the physics message
it is there its just not detecting it hit anything
Oh, it's a 2D game. You need to use Physics2D.Raycast
oh
At least if your colliders and rigidbodies are 2D versions
ya the yare
Look how the 2D raycast works, it's a bit different but not too much
so do u think there is a way to launch the player, when the child sword hits the spikes?
alright thank you again for the help i was really stuck on this
There is a way to do anything of course
right
lol
i just dont know how to go about this
not sure how to have a child move the parent
Oh well, that part would just be referencing the parent and telling it to addforce to itself
you wouldnt have it directly move, you would call some function on the parent to tell it that it should move
yea addforce, i didnt scroll up to see if this was a rigidbody
in the sword script:
public PlayerScript player;
void OnCollisionEnter(Collision collision)
{
//your check
player.AddForceFromSpikes();
}
player would have a method that just... adds force to itself
I mean, I just wrote my code to be extra clear though
If the sword is a child of the player, it won't work. Collision messages get sent to the object that has the rigidbody
Ok, that's what I was worrying about when the collision didn't work
Thanks for confirming it
Could put the OnCollisionEnter on the player instead and check which self collider was hit from contacts ^
i have never seen that in my life, i have no idea how it works
I was just about to link that haha
Osmals idea is good
if you could walk me through it i would be down
bool isSword;
foreach(var contact in collision.contacts)
{
if(contact.otherCollider.gameObject == swordGameObject)
{
isSword = true;
break;
}
}```
Now do stuff is it's the sword
Again, not sure if contact.otherCollider or contact.thisCollider is the right one
I only remember it being confusingly named
Guys I finally made my fps game multiplayer.....
ok so do i put this text in my sword script, or my player script?
Thanks for the support
Player, OnCollisionEnter
And guys I want to do a system that the mouse would not be locked in the game for first 10 sec how to do that?
See edited answer, use collision.contacts instead
use a coroutine and then lock it after 10 seconds
What's a coroutine ?
ok
I didn't put ()
i just saw
Ok now you need to actually define sword gameobject
you should still use get contacts tbh, .contacts produces garbage iirc
Thanks
how would i do this?
I gtg for a moment, someone else can probably guide you if needed.
True, I went with the simpler solution in this case. GetContacts is more performant.
do you know how to create a variable of type GameObject?
like "public GameObject sword;" ?
yes, now just make sure you use that same sword name in your comparison
after a while of debugging, i have figured out what my issue is and it may be UI related and not Code related, Any thoughts? When testing an image with button component and I set a highlighted color, when i mouse over it, it is not highlighting as if it is not interactable, Im essentially trying to get this OnClick() method to run when i click one of these images set with a Button component
ok did it
whats next
now do your logic if its a sword
wdym
kinda unsure what you're asking, do you have an event system in your scene
thats exactly the problem i think, damn
🤷♂️ its your game, what do you want to do now if you detected its a sword
is this what u mean?
Is there code I can make that would be able to change the Alpha of a UI element?
read the underlined text on that if. If thats the logic you wish to do, then sure. Id check if the tag was "Spike" before all of this though
holy shit thank you
the tag of the spikes is "Spike"
you change the alpha (a) of the color on your UI element.
https://docs.unity3d.com/ScriptReference/Color.html
the code can never reach that inner if statement because you break the loop right before it
yes it is unreachable, if you arent sure what this means i really just advise you do basics of c# before unity
Thanks
do i break before it?
sorry
after it
like that
do yourself a favor and google what break does. Because you did just blindly copy-paste the code into your file
terminates a loop, i was just brain farting tbh
ok so from here
what do i do?
i have bool isSword
but i havent used it
The idea was to check if isSword is true after that foreach loop
You can also do the logic inside the loop like you currently do and get rid of the isSword variable
make the rest of your game?
test if what you have works
it isnt working?
What's not working?
is that a question or a statement, what part specifically isnt working
what debugging steps have you taken, to check which part isnt running
i dont know what to debug
how is this code even checking for my sword child?
is it because the names match?
if you arent sure what any of the code here does, go step by step through each part and try to find what they do on the docs. Go in order, look at what collision is on the docs, look at what the contacts provides as information
ask if you are unable to find anything online
normally id answer, but you should really learn to google without second doubting yourself. you can see the type of the variable when you hover over it in your IDE
Err I'm trying to make it so that an accessory image appears on the UI via alpha, why isn't this working?
What could I use when making a temp variable for alpha?
you need to copy the entire color
ok im reading on it, but i dont know where to start for the debugging, like i said, ive never used this method before, and it sounded like you guys thought it should be working
well realistically any of the people who helped you would have this working. I really feel like you skipped out on the very basics of c# and that is why you are very confused on whats being done.
You'll want to debug anything useful to see what variables are, or if the code is even running.
In the code, you're trying to see if the sword was hit, so one thing could be to debug the .name of the game objects you are comparing. Maybe you are comparing the wrong object.
Next to check the 2nd if statement, debug the tag of the object. If it's what you expect ("Spike") then there must be a problem with how you are adding force. Debug what jumpForce is, or if the rigidbody is the correct object as well
so when you say debug the .name, I triple checked, all of the names are corresponding with each other. for the tag of the object, im not incorrect on it being Spike. for the jump force, i tried changing the value to 2, just to make sure that wasnt the issue. what do you mean by "if the rigidbody is the correct object"
simply just meant are you adding force to the correct rigidbody
show what you debugged in code and the console output if you can then
do i have something wrong here?
yes, sword is a prefab not a gameobject
is that better?
yes
ok it didnt fix anything
it would be even better if you weren't comparing contacts against a specific gameobject and instead using something like a tag or checking if it has a specific component type
this is why you need to Debug your code
pretty sure its to check which collider was hit when there are a few as children
Why not just use on collisionenter?
they are
ah so it's just inherently a design problem 🤷♂️
can't that just be circumvented by doing collider.transform.root tho also / transform.parent
Oh, yeah, i just didnt realize the foreach loop was in it
But..why the foreach loop?
Cant they just compare the tag on collision?
Cause i mean, if you collided with somethin like a spike, it really doesnt matter how many points you've just collided with it, right?
i dont know what you mean by this, they are trying to check if a certain collider was hit when there are multiple as children to 1 rigidbody system
ohh mb I thought you meant colliders
yeah but it would still be better to check a tag or for a component, not compare it to a specific gameobject
im pretty sure Osmal said something awhile ago about needing to do thisCollider instead, which is why i asked to see what their debugs were before. They havent shown any so i assume they did not use debug.log
well they are using otherCollider and while that seems like it would be wrong, it is actually the collider that was hit by the incoming collider
Yeah, thats stupid. Sword are swords and should have their own tag
No need to get unnecessary references
🤔 i guess that can kinda make sense if i squint hard enough
if i use a if stattement and in the statment i write if (this is true || this is true && this is true) does it mean that the first one could be right or the last 2 could be right or does it mean one of the first 2 ones have to be right and the last one also has to be right
it's just weirdly named. otherCollider would be this object's collider in terms of a collision while collision.collider is the incoming object's collider
if it is not debugging, then it is not entering the if statement. I did tell you before a few steps you could take to see which part of the if statement is the problem
That's the whole point here
To differentiate between child colliders
usually you would surround them in extra brackets to avoid this confusion all together
this is probably a stupid one, but none of your colliders are marked as triggers right? because if so it'd be OnTriggerEnter and not OnCollisionEnter
nah
I really do suggest you watch some videos about unity debugging
the whole logic is wrong anyway, the Spike test should be outside the for loop
ok so something is wrong here then?
🗣️ start debugging
literally dont know what to debug here
Bc its such a basic thing to do (in this case) and you're struggling with it. Not saying thats bad, all of us been there
Literally everything that you think could cause the problem
oh i didnt know you could use more brackets in a if statment like that ty
#💻┃code-beginner message
you responded and said that you checked it already. I said to debug it, not look at it with your eyes in inspector
what happens if you do debug.log(collision.contacts) or anything outside of the checks, does it log the collision happening
You should cut the screenshot even more for us to not see any context
*Sarcasm
It shows the value of the contact.OtherCollider.gameObject variable
use a debug.log instead of debug mode for this stuff
because your player is colliding with the floor
It's the name of the colliding object.
gotcha
if you surround that in quotes, itll just be a string
oh mb
How does "Start coroutine" works ?
What is exactly the "method name" input ? A function ?
an IEnumerator
Don't use the overload of StartCoroutine that takes a method name. Use the one that takes an IEnumerator
My goal is to setip a "wait until"
Okay
Im fairly new to c#, how would you explain a IEnumerator ?
Is it just like a Enumerator in cpp ?
Seems a weird concept
It's like a method that unity uses to build a Coroutine class. I don't know the details of it
// calls the coroutine
StartCoroutine(myCoroutine());
private IEnumerator myCoroutine()
{
// do stuff before timer
yield return new WaitForSeconds(//amount of time);
// after timer stuff
}
Anyway this way of handling coroutines is unity-specific @shrewd swift
Okay
that might be enumerations you are thinking of, i havent done cpp in years but i dont recall people saying "enumerators" specifically in that
The annoying thing about me is that i am forced to use the VSGs, so i have to do weird stuff to do it
vertical sleeve gastrectomy?
Why are you forced to use that?
The yield stuff doesn't serms to exist in graph
There's a separate discord for visual scripting #763499475641172029
Studies
that is really unlucky if they dont let you use c#. Maybe use it secretly lol
I a used to use py, cpp and the visual scripting of UE5 (thatbis insanly better than unity)
Yeah ik but its inactive, and most of the time the concepts in c# can be recreated in VS
ok im getting nothing in the console
C# is legit ban'ed lmao
Okay, I'm not sure how coroutines would work in visual scripting. Not a lot of people here use it
is it because im using an animation?
Is this highschool if you dont mind me asking? I cant imagine any reputable place would force visual scripting, its literally just worse and not transferrable as a skillset
IEnumerator is interface, the equivalent of interface in cpp should be pointer to abstract class? cpp doesnt have interface since it allows multiples inheritance
i think you can treat it registers some object that inherits from this abstract class than the unity will run it
potentially but unsure
Try thisCollider instead of otherCollider
I just tested it and thisCollider seems to be the right one.
I think in 2D it was the other way around or something
I also said this twice before and someone else also reminded you about it..
welcome to programming 
@eternal needle @slender nymph Seems like thisCollider is the correct one in ContactPoint
But in 2D it is Collision2D.otherCollider 😵💫
🙏 i hate 2D
I am doing Game Designer studies, we dont have time to learn c# so we go in VS.
The game programers are doing all the real coding
But i am "special" since i already did a lot of programming before entering
hm i see, i guess that makes more sense
Mb i read wrong
whatever you're naming the coroutine
For what is used the yield and waitforseconds?
So yeah after some looking i don't think i can do the IEnumertor stuff.
Since i cant make custom functions but only events
How does the start coroutine works ? In VS there is 2 types
Use the overload that takes an IEnumerator
The string-based one probably uses reflection to find the IEnumerator
Ty there is some useful stuff there
well yeah, that's what the docs are for. providing useful info so you know what you are doing
Ill try, im scared that i cant "create" an IEnum in VS tho
Sometimes some docs page misses some info 💀 (not unity specific)
(With VS they mean visual scripting)
No idea about that
I would imagine that there's another way to wait in visual scripting though
well they can always ask for help with visual scripting in the #763499475641172029 discord 🤷♂️
@slender nymph
Yeah, I linked that before and said that almost no one here uses visual scripting
its inactive
have you even bothered asking for help there? when you do, you need to be patient. visual scripting is not entirely the same as c# and many things will be accomplished differently. that is why there's a separate discussion space for it
I can ask but lots of questions there are left unanswered after weeks
I can still try
Ill look
Googling should be the first thing you do
Im still on my phone
well you could instead spend those weeks waiting for a response by learning how to code in c# then you could get useful help here instead of trying to untangle your spaghetti nodes in the wrong discussion space 🤷♂️
I already done it a few weeks ago and sometimes google cant find the good docs pages
IEnumerator methods are special methods that allow you to return something multiple times with yield return.
One thing to note though is that it doesn't spew all the results all at once, every yield return kinda just freezes the method in its place until the receiver asks for another one.
Read above messages, i would love to use c# but i cant
well this isn't the right place for seeking help with visual scripting 🤷♂️
okay and if you don't know c# or how to convert that to visual scripting how does you asking about visual scripting here help anyone?
And frankly, if you don't have time to learn, I'd look for alternatives.
You'll consistently hit road blocks one after another.
Ty for the answers tho ill retry some stuff when i finished with cooking
Hey there, quick question. Will async/await functions pause whenever you set the Time.timescale to 0 or not?
no
I already tried some weird stuff in VS but there is always a wall somewhere
For that you need either Coroutine, Awaitable or UniTask, I think
Trying to look for easy answers will usually waste your time more than getting something out of it.
Thanks!
even Awaitable (which is still async/await btw) doesn't care about timescale
Im not looking for easy answers .
I always look the whole thing, understanding it than applying
I hate copy paste
Ah, I thought it had the same features as UniTask but apparently not
if you really needed to rely on timescale while waiting for specific amounts of time in an async method and you are on 2023+ you can create a method that returns Awaitable, takes a float param and just awaits Awaitable.NextFrameAsync() until a timer float that you add deltaTime to is equal to or greater than the float you pass
nah, it's really just got a few methods that make waiting on specific things during the frame or bouncing back and forth from the main thread
And async methods give you more control than Coroutines. :p
Guys if im making a pong ai, is it enough to just specify a "good enough" y distance difference between the ball and the ai paddle, to make it so it doesnt always go to the perfect spot?
And just check if the distance is less than that, and if so just stop?
yeah. what i did for mine was make it very accurate but limit its speed so it couldn't always reach the right location in time
Me:
Made the pong have random offset from the ball EVERY second.
why do i keep getting this error when my code seems fine
Also fixed by making the movement exponentially slower the closer it is to the ball.
So it never jitters.
because something on line 35 of MeleeAttack is null
Oh thats actually a good one
Cool. Just use the result of the lerp function as the new input. 
that doesn't mean the object found by your physics query has that component
but its attached to te enemy
Ill keep that in mind lol
stop making assumptions and either print some info about the object detected by your query or use breakpoints and inspect it. because i assure you, the enemy object on line 35 does not have that component when the NRE happens
But I thought programmers always make terrible assumptions. 
what would adding breakpoints to my code do?
When you start, your code literally stops at that point and be able to review every single variable.
Also move one step at a time .
Hello, I'm trying to change the x position of a TMP_Text using it's rectTransform but it's changing it to a completely random value, why is that happening?
dont understand how the code was working fine yesterday, literally didnt even touch it but today there is a problem with it
Here I'm addressing it to be -36, however im getting -576
have you done literally either of the two things i suggested to determine what the source of the issue is?
i added Debug.Log
and what did you print?
ah yes "it aint working" super useful info
does your prefab perhaps have more than one collider on it?
when moving UI objects you should ideally be moving their anchoredPosition
i checked it and it looks like I already looked at it, the weird thing is even if i trigger the "wait until" with a coroutine (so with the check box ticked), it still freezes the whole game
Hi!
we have an assignment to create a VR Application for the ocolus Rift. Everything is working fine but one thing that really does not work is how we are able to display two different things in the VR Googles and on the monitor. Basicly we want one player beeing VR doing stuff and then we want to have another one in front of the computer doing other stuff. We tried to use the multi display stuff which kinda works but only if we have 2 monitors on the computer itself (https://docs.unity3d.com/Manual/MultiDisplay.html) which is not ideal.
We also tried out stuff with setting the one camera depth different and not showing the eyes which kinda worked but had the isseu that we want two different Rendered "Screens" like e.g. Screen 1 is for the Vr googles and Screen 2 is for the normal comupter display. Can anyone help me with that?
Thank you, that fixed it
perhaps you want to ask this in #🥽┃virtual-reality
this is a code channel
is one (or more) of those colliders on a child object that does not have that component attached?
sry i will do that!
okay i re-tested, it works sometimes, looks like depedning of what nodes they are before the "coroutine" mode is lost
in c# is there anything that a coroutine "doesnt handle" ?
i tried using getcomponent but i cant get it working without errors
so share your code and errors
It can do anything a normal function can. Except return a value or use out or ref
there are many, but this is one
GameObject.Find("Avatar").GetComponent<"StarterAssets">().Spawn1();
i changed it to this and its now working, is this efficient code?
also things like
GameObject.Find("Avatar").GetComponent<StarterAssetsInputs>().Spawn1();
i would personally use TryGetComponent instead of a GetComponent followed by a null check
you have yet to share what the error(s) are
sec
The type or namespace name 'StarterAssetsInputs' could not be found (are you missing a using directive or an assembly reference?)
im trying to access a script from a gameobject
configure your !IDE and use the quick actions to import the relevant namespace or fix you spelling errors (if there are any)
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
what
Yeah, pretty much. May I suggest you try out guard clauses?
what part of what i said do you not understand
idk whats the spelling error, but im like 100% sure its a spelling error, or wrongly placed stuff
well if you are certain it is a spelling error, then use a configured IDE to rewrite the line and use the convenient autocomplete suggestions to avoid spelling errors
we aren't your spell check, that's what your tools are for
it's most likely a missing namespace though, which can be easily fixed using the quick actions in a configured IDE
@slender nymph whats that site that allows me to put my code in and i send someone th elink so they can view 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.
be more specific than "isn't working"
whenever i try pick up coins nothing happens
show the Coin class
and are you seeing that coin collected log in the console?
no
you are calling OnCoinCollected after destroy this gameObject, maybe destroy at the end
it doesn't matter
then the issue lies with whatever is calling your Collect method
Scripts do not stop because the component is destroyed, so this code works fine.
oh okay
The only way a script stops prematurely is by exceptions, and intentional things like return;
im using like if collisison with coin , then increment coin count by 1
that tells me almost nothing
because the coins only appear after an enemy is destroyed
Show the code where you are calling the collect method
im sorry idk if this is what you want
that is not where you are calling the method. that is the interface declaration
You need to somehow call the Collect method in your game so the code runs. This can be by another method, or maybe you have a collider that calls it in your game?
this is what i have attached to the coinprefab
okay and where are you calling Collect
just click '2 references' above Collect
and where do you have the Collector class attached? did you put debug log there to see if it's getting called?
also make sure atleast one of the colliders has Rigidbody2D
should i give the coin prefab a rigidbody?
i mean the player has a rigidbody so athat does work
is the debug log getting called?
no
so the Collector doesnt work
is the Collector component actually attached to anything
where did you attach the collector
Hi. I want to change the values: speed and height one key at a time. I tried to use bool, separate void Sit() and void Stay(), but I couldn't. What is the solution?
as in the component?
I don't understand anything
what is void Sit and void Stay
the player
you are already changing height and speed after pressing C key
These are separate voids that you create yourself, and you can already call (activate) them, for example, in void Update. I'm not explaining it well.
show the player's inspector
so just call the voids whenever you want
Yes, but I want to change the button again after 2 clicks and then somehow return the data of the first click
@hardy fox does the player has a collider that is a trigger?
becaues if the Collector is on the player, and it has OnTriggerEnter2D component
that means that the Player has to have a collider marked as isTrigger
if the coin's collider is a trigger the player's doesn't need to be
yes sorry i mean if he has a collider attached to the same GO that the Collector is attached to
this is the lootprefab game object
can you answer the questions
we are asking you?
why does the lootprefab has a collector component
loot should be collectible not a collector that collects coins/loot
I don't have a component called collectible that I can attach to coin
coin is already a collectible by inheriting the interface
Nor do I know what I'm actually doing
🤷
So why isn't it collecting the coins?
do what we said you should do first
and answer the basic questions
Yes, and it's not printing
show where you've put the log
that doesn't tell you whether that method is being called or not
put a log outside of the if statement
but at a guess i'd say you probably need to go through this: https://unity.huh.how/physics-messages
dont really understand what im doing, im trying to understand what exactly u want me to do
we told you exactly what you should do
instead you are doing your own stuff
if you don't understand the help we are giving you should go through the basics of Unity first
otherwise it is impossible for you to even understand the help
no difference
then OnTriggerEnter2D is not being called. go through the steps here #💻┃code-beginner message
you absolutely can
you can, why not
no, it's been that way forever. that's why GetComponent<T> is not constrained to Component
you guys are amazing , its working now
what ended up being the issue?
is there a way to update a dict while a for each loop ?
you cannot modify a collection while enumerating it
if the updated keys were already iterated through
Get the keys as a list, and enumerate that list instead. Then you can update it
is there a trick ?
you can create a copy of keys and values
and iterating over the copy while modifying the original dictionary
player never had the Collector component
It really depends on what you're actually updating
Are you adding stuff? Or modifying existing keys? Removing keys?
subtracting 1 to value
never updating the keys
Yeah so get the keys using dict.Keys and enumerate that
It did but I accidentally turned on is trigger for the Player
you said that the lack of Collector component on the player was an issue
😩 I don't even know, as long as it work
now you are saying the player had the Collector but also had the collider marked as isTrigger
im confused
but unless neither object had a rigidbody that would have been perfectly fine?
Played had RB
so then you don't actually know what the issue was, you just fixed it somehow
unless the player's rb is static
Dynamic
yeah so when i asked you what the issue was your answer should have been "i don't actually know, i just changed things until it started working"
It was a well calculated guess
Does anyone know what causes this rendering bug by left image?
export render result is right image.
this is a code channel
expect render result is right image.
What return type can I use on this so that it stays persistent throughout the game instead of only being able to be used once? I
huh?
Its not returning anything?
So void is fine
I mean, void is the only thing you can use
if you want the method to be reusable for different objects, changing the return type isn't going to do that, unless you want to return whatever is in that DavidStates array
Or you can make it so it returns whatever the davidstates[index] is
And then set the sprite directly with the method
also for the love of god, cache the reference to your components, not the gameobject so you're not calling GetComponent everywhere
I would If I knew, this is for a school project
I'm just using the way the teacher taught me
take the initiative to learn how to reference components and surprise your teacher with knowledge they haven't covered yet
I have to get this project on a usb in like 3ish hrs
I shall once we do another project but for now I don't have time to learn anything now unfortunately
Make a variable like
Image davidSpriteImage;
private void Awake() {
davidSpriteImage = GetComponent<Image>()
}
Then u can just do
davidSpriteImage.sprite = whateverYouWantThatsASpriteOrSomethingLikeThat;
i'd bet they're already serializing GameObject fields so the only change they'd have to make is the type and removing the GetComponent calls
ohhh wow
Also if you wanna see something that'll kill you on the inside right now my gameScript is 1000+ lines of copypaste methods
The oversimplify type of teacher
which ends up stacking up
this is a mess
I have to scroll a marathon to reach a certain scene
But a 1000+ lines of copy pase is the opposite of oversimplyfying
Rather then dumbing it up so that most of the class can understand then
oh god, do you only have one component or something?
It seems like
this is all that's handled before the game starts and then everything else is ran on update()
It's awful
I dont know what they're teaching but im 100% even the teacher has no idea what it is or how to program
So much for 20 years at blizzard according to their credentials
maybe they were a janitor at blizzard
Either the teacher doesn't know or he's picking the inefficient way for the sake of "here take this so you can copy paste and I won't have to teach you until this project is finished"
Naah he dont know
except for their GameObject references lmao
Sometimes I have the thought in the back of my head that there is a probability my teacher is in this server and what if he looks at my msgs and calls out my class 💀
This has to be the most cursed .cs file I've ever seen
Honestly if I made this project larger scale than the time frame would allow the file would be huge
But due to my school-issued usb frying and then apparently the school workstations using an outdated ver of Unity I'm stuck to working on it at home and it's due this morning
Huge? It already is! I've never had a script thats more than at max 500 lines
And even that is pushing it
A lot
I'm gonna hold the world record
Just keep scaling it
The fuck is this
My eyes
You're watching a master at work
Apparently a school project
(it's my first year in this game dev course)
On a positive note, everybody would be too afraid to fire you
LOL
Id get a refund
if I packed this script in a zip it would be a zip bomb in itself
Naah hed get fired in an instant
They would not know what to do with this code
Honestly this is too much I'm completely lost on where I was
I have a class from an UPM package that has an optional name variable serialized.
How do I hide that field in the inspector given that I can't change the code itself?
Why can u not change the code?
is my only option to make a wrapper class?
Is creating a custom inspector for this type an option?
[HideInInspector] but you didn't make this class so in that case you're better off replacing the inspector
Hmm possibly? The message attribute belongs to the T in a List<T>.
so I'm trying to serialize a List<Message> where Message has the attribute that needs to be hidden
If all else fails you could put the package content from the cache into your packages folder and edit it in there.
What's the package?
It's an unofficial package, com.openai.unity https://github.com/RageAgainstThePixel/com.openai.unity
what button is right click on the controller?
im trying to assign an sprite to UI Image through code but i dont know how, can anyone help pls
assign it to the sprite property
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.UI.Image.sprite.html#UnityEngine_UI_Image_sprite
this is a code channel
heey, hi everyone, does someone knows why i can not drag this script into the inspector? pleaasee... help
it's an audio manager asset... but it let me do than on another project... i've removed it like three times from both projects, but in one i can and in another no
probably two separate classes named AudioManager
Make sure the field is of the correct type
Let me both check 🙂
Oh god, it was that! thank you so much!
!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.
Because it's a .txt file.
🤫
Brah, you can't just drop a 500 line long class and ask us why X is not working. Use Debug.Log() until you find the problem and then post the part that matters.
💀 mb gang
forget it
😭
if only there were some way you could share large blocks of code. perhaps even some bot could respond to a command to share instructions for that
of course you still shouldn't just drop 500+ lines with little context
Im having trouble triggering the animation. Animation doesnt launch. I have an enemy and a player. If their colliders collider and player is rolling at the time of colliding, enemy should play the stumble animation. One of them is marked as trigger other is not. One is kinematic other is dynamic, sorting layers for both are the same. For some reason it doesnt work.
in the playerController script:
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.tag == "Enemy" && isRolling)
{
collision.gameObject.GetComponent<Enemy>().Stumble();
}
}
add a Debug.Log() in there to see if the if statement is true
also don't compare tags using string equality, use the CompareTag method instead
its better?
And you should avoid Tags when possible, this will work better:
if (collision.gameObject.TryGetComponent(out Enemy enemy))
{
enemy.Stumble();
}```
yes, it's not only ever so slightly faster, but it also provides relevant errors when a tag just doesn't exist
if statement is true, debug.log works. but the animation doesnt launch
show the Stumble method
public void Stumble()
{
float stumbleTime = 5f;
enemyAnim.SetBool("IsOutOfPlay",true);
new WaitForSeconds(stumbleTime);
enemyAnim.SetBool("IsOutOfPlay", false);
}
You have a little problem here.
ah, youre right that was the problem
ok, now it says coroutine stumble doesnt exist in current context....
collision.gameObject.GetComponent<Enemy>().StartCoroutine(Stumble());
public IEnumerator StumbleAnimation()
{
float stumbleTime = 5f;
enemyAnim.SetBool("IsOutOfPlay",true);
yield return new WaitForSeconds(stumbleTime);
enemyAnim.SetBool("IsOutOfPlay", false);
}
should there be a separate method in Enemy class that starts coroutine and call that separate method?
yes, make the Stumble method start your StumbleAnimation coroutine
but do you know why its impossible to call a public coroutine from another class?
it's not impossible. you just weren't
if you wanted to call StartCoroutine on the Enemy object and pass the Enemy object's StumbleAnimation coroutine, you would do this:
var enemy = collision.gameObject.GetComponent<Enemy>();
enemy.StartCoroutine(enemy.StumbleAnimation());
Hi !
I want to generate a pdf from a string and an image in my app, i tried with Itext but it didn't work, is there an easier way to do so ? Or maybe it's easier to generate a Word file ?