#💻┃code-beginner
1 messages · Page 681 of 1
prove it
then u have the gizmos enabled in the game-view
never seen it tho
the game is running and i can see them
you've messed something up with your canvas then since that would not be the position of either of those objects in game view if it were a screen space overlay canvas
show the actual canvas component
public class EnterCommand : MonoBehaviour
{
[SerializeField] private TMP_InputField commandField;
private Dictionary<string, Action> _commands;
private String command;
private void Start()
{
_commands = new Dictionary<string, Action>()
{
{ "givemoney", GiveMoney }
};
}
public void CommandEntered()
{
command = commandField.text.ToLower();
if (_commands.ContainsKey(command))
{
_commands[command].Invoke();
}
else
{
Debug.Log($"There`s no command named: {command}");
}
commandField.text = "";
}
private void GiveMoney()
{
String[] parameters = command.Split(' ');
FindFirstObjectByType<PlayerScript>().Money += Convert.ToInt16(parameters[2]);
}
} does someone know why its not detecting the command???
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
so this is a screen space overlay canvas. which means what you are seeing in game view is either something else or a unity bug. if that isn't a different object then restart the editor
i restarted the editor but i can still see them
did you bother confirming you were actually looking at the right object inspector first?
this was the gizmo button i was mentioning just in case.. couldnt actually tell by ur screenshot
even with gizmos enabled that shouldn't appear in the position they've shown
ooo
when i pressed that button the lines disappeared thank you!
that's just hiding the issue, not actually fixing it
theres two different buttons for each window
game view and scene view
ya true..
unless that number is actually a world-space object
it doesnt make sense
but i think it may not actually be part of the canvas
the corner of a screenspace overlay canvas wouldn't be in the center of the screen in game view though
ya true.. this is what i was expecting to see
can u show ur number object in the hiearchy
i am basically making flappy bird but he has a gun
just to humor us
number object?
the 0
expand the folded objects
can u show the Text (Legacy) selection in the inspector?
you'd probably need to use a world space canvas for the number (and then that type of canvas does align in ur camera like normal objects)...
you'd then just change the sorting layer so its behind the pipes
or just move it behind it.
it just moved..
select it and press F while hovering the scene view
it'll focus on where it is
where 🙏 🙏🙏🙏
you'll have to position it wherever ur pipes and gamefield is
hey i got things going again, but i keep getting a error here with both phrases: CharacterControls
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Windows;
public class characterMovement : MonoBehaviour
{
//variable to store character animator component
Animator animator;
//variable to store optimized setter/getter IDs
int isWalkingHash;
int isRunningHash;
PlayerInput input;
// variables to track movement and input state
Vector2 currentMovement;
bool movementPressed;
bool runPressed;
void Awake()
{
input = new PlayerInput();
input.actions.CharacterControls.performed += ctx =>
{
currentMovement = ctx.ReadValue<Vector2>();
movementPressed = currentMovement.x != 0 || currentMovement.y != 0;
};
input.CharacterControls.Run.performed += ctx => runPressed = ctx.ReadValueAsButton();
}
void Start()
{
//set the animator reference
animator = GetComponent<Animator>();
//set the ID references
isWalkingHash = Animator.StringToHash("iswalking");
isRunningHash = Animator.StringToHash("isRunning");
}
void Update()
{
HandleMovement();
}
void HandleMovement()
{
bool isRunning = animator.GetBool(isRunningHash);
bool isWalking = animator.GetBool(isWalkingHash);
if (movementPressed && !isWalking)
{
animator.SetBool(isWalkingHash, true);
}
if (!movementPressed && isWalking)
{
animator.SetBool(isWalkingHash, false);
}
if ((movementPressed && runPressed) && !isRunning){
{
animator.SetBool(isWalkingHash, true);
}
if ((movementPressed && runPressed) && !isRunning){
{
animator.SetBool(isWalkingHash, false);
}
}
void OnEnable()
{
input.actions.Enable();
}
void OnDisable()
{
input.actions.Disable();
}
}
is there a way to fix this so i can make my model to move around using a controller? I have been on this for a day now and i am stuck
ur game is way down here..
from the image that means in this view its WAY WAY WAY on the top right corner OFF the screen
b/c screenspace canvases work differently than worldspace canvases
a screenspace canvas is always that BIG square off to the side.. (ur game camera doesnt actual render it.. it gets renderered on top of wat the camera sees)
while a worldspace canvas does matter b/c the camera must be looking at it..
if u adjust ur game-view you'll notice that the bounds of the UI Canvas adjusts with it (if its set to scale correctly)... again having nothing really to do with the actual game stuff and the camera-view
Like i keep getting this error and i dont know why. I am following a tutorial to the letter:
those errors are related to the input system.. its looking for actions u havent set up... or not named the same
in the tutorial he should have a section where he sets those up
oh ok
I’m not sure which ones they would be referring to is.
it'd be something like that ^ this is a screenshot of the default ones that come in some of the unity projects but im not sure if they're using those
or they made their own or modified them a bit
im sure its in there tho.. ofc the inputs aren't really the main focus if ur doing animation..
you can use the old input system.. Input.GetKeyDown type stuff just as easily..
looks like you didn't follow the tutorial
my bad then
im not 💯 thats the problem..
but if ur following a tutorial. and ur not naming things the exact same as the tutorial it'll not work the same
unless u keep track of what u renamed.. and when they use their version.. u swap out and use ur renamed version..
Well I thought I was naming it correctly, but yeah I’m still getting a error in my code even after changing it to Character Controls
What else can I check?
does anyone why this might be happening
what, the spinning?
It's because you didn't constrain the rotation on your Rigidbody2d
but also - shouldnt the player be dying when you collide anyway?
no
counts to 9
then resets to 1
and doesn't add to the score anymore
So can no one help?
i am stil following the tutorial
my guess it's it's actually trying to display 10, 11, 12 but you made the text object too small so there's no room to show the second digit
ah ok
this is what i get in the debug menu
pretty sure this is all because you didn't capitalize stuff correctly
the tutorial is adding extra confusing by naming their input actions asset "PlayerInput", which conflicts with the name of a common componnent from the INputSystem itself
but you seem to have named yours "player input" or "playerinput" instead of PlayerInput
In fact this is happening which is 😵💫
anyway - do you have an IDE which is properly showing you errors and making autocomplete suggestions?
Because it seems like you probably don't
I don’t believe so
depending on how beginner u are it may actually be better to just restart
I don’t wanna restart
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
• :question: Other/None
well get ready to experience game-dev first hand 💪 😅
why doesn't this work
hover it and read what it says
You should start by mousing over the error to see what the problem is
but if this is for the problem above with the text sizing
I don't understand why you are doing this
this is not needed
you needn't change anything in the code
just make the text object larger
i wanna center it because when it goes over 10 it just looks bad
It should be the latest version of visual studio code 2022
Is that a question?
i wanna change it's x position
Yes?
you just need to change the alignment settings on it
you don't need to do anything in code
I don't understand what you are asking
I’m just not understanding what you are asking
I wasn't asking, I was telling you to configure your IDE
to center it when it's less than 10 the x postition has to be 85
just change the alignment settings
make it centered
or make it larger^
also.. pro-tip.. when ur designing UI type out the MAX amount of characters u expect to have
like right here? i thought this was fine
and then design THAT to fit
you need to follow the full instructions in the link I sent. That menu is only one part of it
how
With the buttons I showed you above
i sound so stupid omg
everytime ur like.. well. dang i dont know how to do that..
take a step back.. look around ur environment..
and then if u cant figure it out carry on with ur question 😅
best way to learn imo is just fiddling with stuff
Ctrl+Z is my partner in crime...
- what does this button do.. <Ohh crap>
- Ctrl+Z, welp now I know... lol
If there wasnt undo world would be hard mode
but it already is updated?
there are more steps, keep going through all of them
But I don’t see anything else I can do? I already checked everywhere in the package manager, it wouldn’t let me check in the help > check for updates.
did you do this whole part??
Yes I did that a while ago
and you still don't get errors and autocomplete in VS?
Can you showe a screenshot of your VS window?
looks like it's working fine
Yes but I keep getting that error and it won’t let me use it
but yeah your code is using the PlayerInput component class
not your generated C# class
Like I mentioned above you're getting confused because of how the tutorial stupidly named things
go look at the generated C# class file
The one at the path you set here
wait
also
The Player Input?
why are you doing input.actions.CharacterControls?
There's no way the tutorial is doing that
the tutorial almost certainly has input.CharacterControls
(which will also not work if you're not using the generated class)
yeah scroll down to where it actually defines the class
Sorry where would that be exactly?
where it says public class <class name here>
He didn’t edit this file so I assumed that I wasn’t supposed to edit it
you aren't supposd to edit it
I'm just showing you why what you did is wrong
and why it's not working
See how theis class is named Playerinput?
And your code is using PlayerInput
notice the differently capitalized i?
you are trying to use the wrong thing in your other code, partially because you named your actions asset differently from the tutorial
which lead to this class being named differently
snowball effect
With the added confusion of the fact that PlayerInput is a built in component in the Input System
So this is partially the tutorial's fault for naming things poorly, and partially your fault for not following the tutorial precisely
So wait in the character Movement document I need to change to Player input for all of the Player Inputs?
Why not just go back
and change the name of your actions asset
so it's the same as the tutorial
anywhere the code references it it must be referenced the correct way..
ur either changing everything to match what u made..
or ur changing what u made to match everything else
hence why i said earlier it might be better to start over.. b/c
it actually might be quicker in all honesty lol
I don’t wanna start over tho
u dont have to retype every script.. just change the parts that need it
i meant basically going back to the start and seeing where u went wrong.. remedying it one step at a time
So wait is that why CharacterControls is having issues or a part of it?
as said u can just chagne the input stuff to what it needs to be.. regenerate ur class or however they do in the tutorial.. and then u could go and change ur focus to the console.. see what errors u have after having the correct input system set up
Again, it's having issues because you used the wrong name
fix that, and it will work
ya, anything with input is gonna be messed up for now
Okay where do I fix it in the code.
you don't fix it in the code
fix the name of your input actions asset
make the input work w/ the code lol ^
so that it's the same as the tutorial
this thing
this is what you need to rename
make it so it is named the same as what the tutorial named it
Okay it’s named as the tutorial but it’s still getting errors
show what you did and what errors you are getting
also which tutorial is this?
Learn to move characters in Unity 3D with this beginner-friendly explanation of Unity's new input system and root motion!
With this deep dive tutorial, you will not only have a better understanding of root motion and Unity's new input system, but you will also have an animated character by the end of the video!
SUPPORT THE CHANNEL:
💛 http...
yeah notice they have input.CharacterControls not input.actions.CharacterControls
also - this tutorial kinda sucks
Right yes I changed that
they are not following C# naming conventions
I see
and they uselessly did using UnityEngine.InputSystem - notice it's greyed out because they're not actually using that
it's just adding to the confusion
and makes me think further they don't know what they're doing
I’ve been going through this these tutorials for like 2 months now
And no one ever said anything about it before when I posted here
¯_(ツ)_/¯
Okay here is the vid I made for the naming conventions
I’m not sure what to do now. I just wanted this to be a few fixes and get my character moving
Looks like you still have input.actions in the code which is not correct
and is not in the tutorial
What about Run and performed?
what about them?
I removed actions, but I’m still getting errors
what errors
I can't see your screen
I can't see what errors you have if you don't show them
the top one you did not copy the tutorial code correctly
The bottom one you will need to actually tell me what the error is
because this is just a screenshot of a squiggly red line
oh look
from your screenshot above
once again a problem that you didn't name things the same as the tutorial
The tutorial named it Run, you named yours run
Things are case sensitive! visual studio should have given you suggestions as you typed so you can avoid mistakes
im getting this error now in a seperate C# script
yeah because now you have the issue that this PlayerInput variable is actually SUPPOSED to be the UnityEngine.InputSystem.PlayerInput type
It can, I don’t know how helpful they are
I see so what can I do?
Also it's C# not C+
they are very helpful to me
Wlel you could change the type of this one variable to explicitly be UnityEngine.InputSystem.PlayerInput
but it's weirtd that you even have this code here
Where exactly?
it seems like you're mixing up code from two different tutorials probably?
where you define the variable, naturally
that's where you declare the type
Possibly, I did a lot of stuff before this
I don’t understand why it’s attaching to that third person controller
Basically your project is in a weird state - you have multiple scripts doing completely different workflows for handling input
Okay where is that variable that is defined?
How should I know
it's wherever you define this variable
higher up in this script, presumably
Looks like its the unity third person controller and it appears to have been pre set up with movement input so I can only presume its been broken by the action changes
Yes at the top there is where you declared the variable
well it's broken because the type here is PlayerInput which again is ambiguous between your generated class name and the built in component
since the generated class lives in the global namespace it's just always picking that
Are you even using this script anymore?
Oh good spot. I was checking the actual type: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_currentControlScheme
Didn't you write a different script for controlling the character?
If you're not using this script anymore you should just delete it
otherwise - you can change that variable to use the UnityEngine.InputSystem.PlayerInput class explicitly
I am not using it anymore because I remember now. It’s apart of a little game I made using a keyboard. I had to double check so maybe just deleting it would be better.
If you're not using it, deleting it will be simpler than fixing the errors
how do i use the locked function in unity
which one? theres dozens of locks..
Hey everyone. I've been working on this arcade game and I'm having trouble getting the 2D navmesh to work for the enemy AI. Right now when I hit play the enemy switches to the wrong plane and isn't visible by the player
I've tried rotating the surface to XY in the navigation surface component and then baking it but that hasnt worked
why not rotate the pizza slice as a child object
- Agent < move this
- Gfx < rotate this to align towards camera
Does anyone by chance have a code example of using the new input system to interact with an object?
On phone right now, but the official docs have you covered on this!
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
im too dumb to look at that lol
Then you're going to have a hard time doing anything . . .
Confirmed i know
If you can't understand tutorials then I dunno how someone would be able to teach you lol
Then why would you understand it if we say it
We're also just text on a screen you know
Questions
Yes we answer those. You have actually ask some first though
i was looking into OnParticleTrigger and was a bit confused by the documentation. is it supposed to be the OnTriggerEnter variation of OnParticleCollision? if so, it would be possible to use OnParticleTrigger to inflict damage on enemies/mobs, right?
Early morning math issues. lol.
I need to remap values of 0 to areaHeight, to 0 to 90 (ie 0 to 2000 to 0 - 90) but my brain is failing. Any help please? 🫣
inverselerp then lerp?
coming back from developing after a few years. is there a new way to do rb.drag?
it corrects when you try to in visual studio I think
Created a script for player movement. I am getting a lot of visual stuttering. Any clue what the issue might be?
Code:
public class playerMovement : MonoBehaviour
{
InputAction moveAction;
InputAction jumpAction;
[SerializeField] private Rigidbody rb;
[SerializeField] private BoxCollider bc;
[SerializeField] private float movementSense = 3.33f;
[SerializeField] private float lookSense = 1f;
private Vector3 force;
private void Start()
{
// Find the references to the "Move" and "Jump" actions
moveAction = InputSystem.actions.FindAction("Move");
jumpAction = InputSystem.actions.FindAction("Jump");
rb.linearDamping = 10f;
}
void Update()
{
Vector2 moveValue = moveAction.ReadValue<Vector2>();
force = new Vector3(moveValue.x, 0f, moveValue.y);
}
private void FixedUpdate()
{
if (jumpAction.IsPressed() && isGrounded())
{
rb.AddForce(Vector3.up * 5f, ForceMode.Impulse);
Debug.Log("jumped");
}
rb.AddRelativeForce(force * movementSense, ForceMode.VelocityChange);
}
private bool isGrounded()
{
return Physics.Raycast(transform.position + Vector3.up, Vector3.down, 1f);
}
}
newValue = oldValue / areaHeight * 90;
if oldValue and areaHeight are ints then you need to cast to float first
Thank you, silly brain failing me on a saturday morning. lol.
help my play again button isn't working
is the button click triggered? use a debug
i still need help
if you don´t know the button is working use a debug log inside the Restart Method
narrow down your problem
!learn, you lack basic unity knowledge
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
If it logs, then it works. If it doesn't log, then it doesn't work.
if (button == clicked) { Debug.log("clicked")}
That's not gonna compile.
And no, you don't need an if statement
then what do i write
More math brain failure.....
Would somebody be willing to take a look at this If declaration and see if I'm doing it right?
values are between 0 and 90 and I'm checking if my newLatitudeMin/newLatitudeMax variables fall within the min/max range. And also doing the negative (0 to -90)
if (rule.Latitude.Max < newLatitudeMax && rule.Latitude.Max > newLatitudeMin
||
-rule.Latitude.Max > -newLatitudeMax && -rule.Latitude.Max < newLatitudeMin
)
i made this editor and runtime so i can press it while the game is paused
but when i press it it doesn't show up on the Console
In that case, the button isn't being pressed
Does it change color to what you have defined?
pressing and being triggered are different things
i didn't define a color for it when being pressed
why is my button not buttoning
Question, probably stupid, but is the script the one on the object, or the one you have in your assets?
If you even have one on the object that is
I don't think canvas UI works in the editor(outside play)
Test in play mode.
btw that's an if statement, declarations are different things
Yeah I know, just couldn't think of the word. lol.
what exactly is the intention?
what's the input, which are constants
(if they're nonnegative, why check for negatives?)
If the 'new' min and max value are between the min/max values of rule.latitude >> Do things
I have xml data that I'm reading in to a scriptable object, and the min/max values in the rules are between 0 & 90, so I also need to check for the negative to properly assign latitude values in both the northern and southern 'hemispheres' of my game world.
and the "new min/max" can be negative?
are you supposed to be using rule.Latitude.Min in some of those spots?
Oh wait, hang on. I just realised that it's totally wrong. lol.
newMin and newMax are 'converted' from the 0-90 value in the rule.LatitudeMin/Max to the world values (currently set temporarily to 4096, so if rule.LatitudeMax is 90, newLatitudeMax is 4096) so I'm using completely the wrong things in the if statement. lol.
For context I'm using this.
https://assetstore.unity.com/packages/tools/terrain/procedural-terrain-painter-188357
And this script is hooking into it and generating the layers and rules (that govern the splatmaps), but it doesn't have a rule for latitude, so this is just a simple if statement to check the latitude from the xml that I have and simple turning of the other 'rule' layers (height and slope).
<Rule>
<Layer Material="Snow"/>
<Height Min="0.0" Max="1.0"/>
<Latitude Min="80" Max="90"/>
<Slope Min="0" Max="30"/>
</Rule>
Example of a rule in the xml
the one on the object
My brain hurts. lol.
Sort of thinking out loud atm.
But I need to make an if statement that enables my terrainLayer rules between the values of rule.Latitude.Min and rule.Latitude.Max, otherwise disable them.
why is my button not working
still doesn't work
can i screen share with one of you
No.
But go over the steps in this page:
https://unity.huh.how/ugui/input-issues
i'll send a video then
did someone figure out what's wrong
It's very clearly not being pressed, pressed color is a darker shade, but the button never changes, and by what I see, you need to go over the steps here: https://unity.huh.how/ugui/input-issues
There is a reason it isn't detecting it, and it can be found at that link (At least from my view)
It's not being interacted with at all, it's not changing colour when you rollover. How big are your other UI elements?
can you disable the Image componenet on your Play Again gameObject and try it again?
so how do i press it? i keep left clicking it
Read it, and check it all
You can also try what the others said if that doesn't work, but I suspect it's something that is on that page
none of them are touching the button
i tried disabling the image and that still didn't work
Check you container object (game over screen)
do u have event system in hierarchy
no
it appeared before but i deleted it
then add it thats why it doesnt work
Exactly what they would've added if they didn't ignore me 😭
LMAO. Missed that one myself.
how do i add it
well you need the event system..
Please listen, click the blue text: https://unity.huh.how/ugui/input-issues
add game object UI/Event system
Not trying to be a dick, but
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Should've listened
dammit. lol.
it should not be possible to remove the event system but some things are weird in unity
Yeah tbh, I've always thought that it should kinda be something that's there in the background anyway
how do i get that score number behind the pipes
Set its sorting layer to one below the pipes sorting layer (I think)
you can simply change their hierarchy order
fr?
imma try that
doesn't work
i also tried doing this, but it still doesn't work
in the hierarchy, you simply move them up and down( if you have seperate gameobjects)
the pipe isn't in the heirarchy, it spawns after you open the game
it is a prefab that spawns when you play the game
tried doing that but everything falls crumbling down (not literally)
do i just make the z value in the negatives?
also doesn't work
Is it a 2d object? Show the inspector property for the pipe object
There ought to be something more than that.. without a renderer there wouldn't be anything drawn to the scene..
it is a prefab
Doesn't matter
the renderer is on the children
Show us the child then
In the renderer component. There should be some sorting order value. I'm on mobile and it's quite difficult to see.
Order in layer
Set it to 1 if you want that object in front of all the objects with order in layer to be 0 (I think)
ok
The canvas renderer would have one too. Try modifying the value to be different from the canvas' value.
doesn't work
Gotta be more descriptive, did it do anything? if so, what did it do?
"Doesn't work" is too vague for us to determine why it didn't work, if it did nothing, then it's probably the wrong option/other objects aren't a lower value than what you set
the text is still in front
And what is the texts order in layer value?
Show us the canvas' inspector
Changing it means it's 1 in the pipe sorting layer, not 1 in the UI sorting layer
Should be fine, sort order is 0
And I'm pretty sure that's just the order the canvases render but I might be wrong
Change render mode from overlay to camera world
then?
It's flappy bird, doing that would make it be a bit wacky
I believe it's meant to be world space, not pixel space (camera space)
Make sure the game still functions as intended just in case
i put the camera in the "render camera"
and made the z axis of the text -1
now it's behind the pipes
note that using a world space canvas is what was suggested when you asked about this yesterday
yea but i used a screen space camera instead
and here: #💻┃code-beginner message
please excuse me guys if i sound stupid or do stupid stuff i am a beginner after all
🙏 🙏 🙏
I would just recommend listening to people, you ignored me earlier despite having the solution (and dlitch too), and now it seems you also ignored these others as well 😭
i basically did that but with screen space camera
instead of just throwing a bunch of shit at the wall and seeing what sticks, you should take the advice you've been given multiple times and go through the pathways on the unity !learn site to actually learn what you are doing
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
but i hate reading
btw the learn site is down ( for me at least in germany)
i like trying stuff until it works
https://paste.ofcode.org/fg6Tq96XjePH6TtbZT58pH
How can I prevent it from creating overlapping walls or make it create walls every 2 unit because they are 2 units wide.
then you're going to fail
Well you gotta do things you hate sometimes
anyone else having problems to see the learn site
Nope, mine seems to be working just fine
nope, it's working for me. try clearing cache
tried
Strange, maybe swap browsers?
what's the issue
it is down
that can mean a lot of things
the NX Finished probe/domain thing?
a cloudflare 522?
a 404?
an hsts error?
i ask because if it's a 404 then it might just be a bad redirect rather than it actually being down
and there's /de in the url?
yeah, thats the bad redirect
yeah it mus be somehthing with the redirection to the de
it's trying to redirect for localization but localization doesn't use that slug
well it used to work , i am only asking because someon else told me they cant see the page also from germany
remove the /de from the url then when the page loads scroll all the way down and select your preferred language
last i remember, the issue was learn.unity.com/ redirecting to learn.unity.com/de
it auto redirects to the de and no way to avoid it
@frail hawk
does that workaround work
allright
should probably submit a support ticket about that to ensure that unity is aware this is happening then
let us wait a little bit., might be some temp problem
oh now i read the previous messages, you are right
Hey so, i am a beginner. I wanted to do a 2d Top down based game (like pokemon).Right now i try to figure out how to make a scene swich in unity. So i can interact with an NPC or get another Trigger wich starts a TurnBased battle. What do i need to look up for this or are they any videos. Dont found much related to this.
Could anyone explain this to me please, as it seems like a very bizarre thing.
This is how the SO's get created.
Slope layerSlope = ScriptableObject.CreateInstance<Slope>();
the method expects a Type object as the first parameter, not a type. you can get the Type object for a specific type using typeof
You need to insert Slope as a Type object, not the type itself . . .
but also you should ideally be using the generic overload rather than that one anyway
Right okay, it's just for editor useage, as on second run the SO's break everything. lol.
can someone take a look?
You'll need to modify the code so that it places the walls every 2 units... If you did write that code it should be very easy for you.🤷♂️
I didnt completely write it myself
Took some parts from examples and modified it.
Ok, then you'll need to read and understand how it works.
I will try
But what can solve that?
I tried removing walls that collide with more than 1 wall but that didnt do anything
Code does what it’s told. Either you don’t know how to tell it something or you don’t know how to obtain what that something is via code
You gotta figure out which of those is your current problem
Having a quick look at the code, you create positions for each wall and add them to a list. You'll just need to modify the logic that calculates these positions.
im sorry for bothering yall, but is there something im supposed to do to not have my bottom function grayed out? in the tutorial im following it is working fine, but when i tried, even fixing some errors i did find, the editor dont even aknowledge errors or anything, the collision function just doesnt work
im sorry if its a stupid question
ooh
what are these icon called? - Texture2D icon = EditorGUIUtility.IconContent("sv_label_x").image as Texture2D; for the bigger ones but i need the dots
thanks!
i thought it would notify me for commiting such a blatant error, i need to be more aware
Try asking in #↕️┃editor-extensions. They'll know more . . .
mhm alright ty
Hi, I am trying to store references to my input actions in the inspector so they don't have to be initialized every time the game runs but this resets every time I reload the scene
https://hastebin.com/share/cavifoyija.csharp
Am I doing something wrong or is this just a limitation of the input system?
Please @ me and thanks in advance!
Please set the PATH to a dotnet host that matches the architecture x64. An incorrect architecture will cause instability for the extension ms-dotnettools.csharp.
should I be worried about this?
I'm getting this in vscode ever since I installed C# extension
did u install the correct one? did u install the 32 bit version on accident?
Installed from vscode
they showed me the version for the sdk
well i dont know a whole lot bout the .net sdks and stuff but the error would lead me to believe its the wrong versioning
it did not throw any error because it could be just a void you declared that is named OnColisionStay2d witht he given parameters
yeh, i understood it after thinking about it, itssomething i have to be very aware of
Guys There is a button animation which is at a button and whenever the player hover the button an animation plays but when the player clicks to the button before the buttonhover animation is finished stays the button big cuz the anim couldnt finish itself. What should i do?
if click -> snap to final size
is there any shorter or better tactic?
or change around the logic so the animation finishes regardless
well ty
why does mine onclick function doesnt work
You need to get your !IDE configured 👇
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
• :question: Other/None
i already configured it
it was not configured in the screenshot you sent
if you are certain you have actually followed all of the instructions, then go through these steps to figure out what you overlooked https://unity.huh.how/ide-configuration/visual-studio-code#if-you-are-experiencing-issues
i did everything i need to do
do you have a collider on your gameObject and is this script on your desired gameobject to detect the OnMouseDown?
and as boxfriends said, it is crucial to have your IDE working properply along with intellisense
in fact, it is a requirement to have it configured to get help here
yeah i already pointed it out
you should read that too 😉
i did and this is why i answered
hey i want to make a bush in my 2d topdown game where you can click on the bush to collect berries from it. how can i check the mouse position and if it overlaps the collider of the bush?
you could use the OnMouseDown on your sprite
how does that work?
oh ty this looks unexpectedly easy
make sure to put a 2d collider on your sprite if you haven´t yet
yeah i should also be able to combine it with a trigger circle collider around my player for limiting the reach right?
doesn´t sound like the best approach but you could simply check distance between both objects with this https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Vector2.Distance.html
really many ways to do that, it is up to you
ty for the help
i am glad i could help
Is there a way to make for certain cells in a tilemap have some tag or something reconocible by code?
For example here, how can I make to detect that the cell is sand and not grass?
You can read which tile it is from the Tilemap
With GetTile
Yeah, but then I would hava a list with all the tiles that are grass
wouldn't that be expensive?
There should be another way
How many different grass tiles do you have?
No it wouldn't be very expensive, you could just have a dictionary of the tile to the type or to a list of tags
Dictionary lookups are essentially free
do not ever worry about performance unless you are creating a specific game that aims to really hit the performance limit or already experiencing sharp fps drop
I need help, with my Movement/Locomotion, I have it so when you hit your controller trigger that hand gets ancorder and you can rotate your body around your hand (0 like gravity not to strong)
How would i make it so i can hold trigger puch or and let go of the tigger and i kindda jump on ait? I have tried this but i go in the wrong direction etc.
Wat
can you show the setup / explain better what you are trying to do ?
You can have custom Tiles btw and only check its type , they are similiar to scriptable objects that they can contain fields/variables
eg
if(tilemap.GetTile<BoardTile>().TileType == TileType.Sand)
etc
public class BoardTile : Tile {
public TileType TileType;
}```
That sounds interesting
I’ll check that
Thanks
don't forget you need
[CreateAssetMenu] to create a new tiletype
Hey guys, how do I make an enemy attack only once per swing in Unity?
I have a skeleton that chases the player and flashes a hitbox when close to attack. But right now, it deals damage multiple times per swing (based on frame rate). How can I make it only hit the player once per attack?
Here's the attack sequence code I currently have:
private void HandleAttack()
{
animator.SetBool("isAttacking", true);
attackTimer -= Time.deltaTime;
if (attackTimer <= 0)
{
Attack();
attackTimer = 0.78f;
animator.SetBool("isAttacking", false);
}
}
private void Attack()
{
StartCoroutine(FlashAttackHitbox());
}
private IEnumerator FlashAttackHitbox()
{
canDamage = true;
attackCollider.enabled = true;
yield return new WaitForSeconds(0.1f); // short hit window
attackCollider.enabled = false;
canDamage = false;
}
private void OnTriggerEnter2D(Collider2D other)
{
if (canDamage)
{
canDamage = false;
if (other.CompareTag("Player"))
{
PlayerHealth playerHealth = other.GetComponent<PlayerHealth>();
if (playerHealth != null)
{
playerHealth.TakeDamage(attackDamage);
Debug.Log("Player hit by skeleton.");
}
}
}
}```
probably should consider starting the coroutiune if can damage
you might have multiple coroutines running
nothing here should be dependent on framerate afaik
but coroutines can be overlapped without checks there is no limit to how man times you can run them
would i put the if statement within the flashattackhitbox function or within the attack funciton you think?
up to you .. maybe you can even do
attackTimer <= 0 && canDamage```
or actually yeah put it before StartCorutine
if(!canDamage) return;
StartCoroutine(
it was still causing multiple hits after implementing your change but changing the "yield return new WaitForSeconds(0.1f);" value from 0.1f to 0.01f worked!
hmm that sounds like it might be covering a bigger logic issue though, the time is shorter sure but why is called multiple times is the main concern
very true... idk why it's being called multiple times 😵
yeah , put some logs and see where its being called multiple times
oop, forgot to say thank you nav!
how can i access the Image from a script?
public Image promptBacking;
the hierarchy wont accept it
thats the way to do it..
wdym "the hierarchy wont accept it"
which namespace did you use for it
using UnityEngine.UI;
namespace?
the script has no namespace
unless oyu mean that
using statements use namespaces yes
ah alright
is the script on an actual gameobject ?
in the scene ? and is Image in the scene too
what happens when you drag the Backing object in the ladderPromptSpace image field
nothing
the thing under the cursor just goes back to the hierarchy
and i restarted unity
hover ur Image reference make sure its the UnityEngine.UI. one
I guess we will never know 
screenshots were too cryptic anyway
Hey,
Why the attribute InspectorName() doesn't work for my variables MINES_AMOUNT, GRID_WIDTH and GRID_HEIGHT please ?
This seems to be for enum value names. Not field names.
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/InspectorNameAttribute.html
oh ok, is there an equivalent but for fields please ?
Not that I know. You could do it via a custom editor/property drawer.
But to be honest, I'd just name your fields properly. Is there any reason for them to be named like that?
Because that's how usually I name constants, thought I think in Unity it doesn't like to Serialize consts 😬
You'd need to write a custom editor or use a plugin like Odin
Those aren't constants
These are not constants though.
I have Odin, let me install it for this project
they were at first then I had an issue and had to remove the const keyword, let me try again to see if I can reproduce the issue 👍
If it's regarding serialization, then you can't serialize constants. That's the whole point of them - they remain constant.
but where do I set its initial value ?
In code
argh
so I can't make them "const" because I need to see them in inspector but at the same time I don't want to be able to change them through code, so I guess I have to go for readOnly ?
even with readonly it complains 😦
You could have a getter property pointing to the serialized field.
mhhh
Though, you will need to remember only to use the property.
yeah 😬
Well I won't make it const nor readonly, and will make it lower case to see it displayed properly in inspector
Wait, how does FormerlySerializedAs() work ?
There's only 1 parameter being oldName so how does it get the new name that I want 🤔
The new name is the actual name that you change.
change where ? 🤔
In code..
If you change the name of a field but want to preserve the previously serialized value, you use that attribute and put the old name as the argument.
wait, so if it displays still as MINES_AMOUNT instead of Mines Amount, I'm really confused
Then there's no point in using that attribute
oh ok
to keep MINES_AMOUNT in code but displays Mines Amount in Inspector
I don't think that's how it works.
oh ok 👍
Im having some trouble making a project, every time I try to make one using the 2D (built in render pipeline) or Universal 2D, it gives me the "Failed to decompress", Am I missing something, thanks in advance
Failed to decompress what? Where do you see that? Does that actually affect your project in any way?
The 2D template
That only answers one of my questions
oh sorry, i have to recreate it real quick
After this happens, it doesn't allow me to use the project at all
It's likely a corrupt editor installation.
Try reinstalling the edior and pay attention to any issues/errors in the process.
What happens if I use previously serialisedfield attribute while still also having that previous field existing? Does it deserialize to both?
No idea, try it and let us know
Maybe an error
Nothing good certainly
Will do later today 😄
It’s not something I wanna do but it’s an established released api thing so I’m very restricted on options
I need help, with my Movement/Locomotion, I have it so when you hit your controller trigger that hand gets ancorder and you can rotate your body around your hand (0 like gravity not to strong)
How would i make it so i can hold trigger puch or and let go of the tigger and i kindda jump on ait? I have tried this but i go in the wrong direction etc.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
Guys I struggle making my grid generate in the center, how can I do that please ?
Like depending on the FOV of the Camera, the grid size, etc... the grid isn't in the middle of the screen, big grids have their right side outside of the visible part, so I can't press those tiles there making the game unfinishable 😬
What's the best approach to make it adapt to the screen size and be in the middle of the screen please.
Here's my code : https://paste.mod.gg/ujggasskdyjt/0
A tool for sharing your source code with the world!
that seems to have worked, thank you
how do i fix it
According to the server rules, you need to configure your !ide
Other than that, Media isn't part of the System namespace
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
• :question: Other/None
Is this unity related? If yes, then why not just use a unity player?
Is there any reason you need to use that api?
yes
i just forgot about this player
how do i make the background music stop when the game over screen appears
Call Stop on the audio source component🤷♂️
how
Exactly how dlich stated it, I really do recommend going through the pathways at !learn as we've told you many times, it'll help a lot (I get you dislike reading, but it'll help a lot)
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Just call Stop the same way you call Play
But I really do recommend heading to learn, give it a shot at least
Yeah I really do think you need to go to the learning pathways
🙏
i tried making a stopbackground music function but idk how to use it
doesnt work
You need to put (); at the end there.
Thx
You need to learn C# basics.
i already did, i just got confused here
i know how to write a function and use it i just got confused for a second
but you're right i still need to learn a lot of stuff
Then you should know that it's called a method, not a function in C#.
i got confused again, i learnt python first
i thought they were called the same in both languages
Stopping a sound abruptly may introduce audible popping/clicking... you can fade out the volume before stopping, but that's more advanced. If you don't hear anything it may be fine.
No they were not. You need to go through the C# basics properly.
Thank you for helping me! 🙏
I will go over the basics again!
can somebody help me? im in the rollaball tutorial and i wrote the script exactly as it shows to move the ball yet when I press play it shows all compiler errors...
ALL compiler errors? What all compiler errors?
all compiler errors have to be fixed before you can enter
@teal viper
Well Does it show you the errors?
Check console
Did you not look at the console?
idk im a beginner
You should learn how the unity interface works before getting into the programming part
it shows this
Then !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
bro its from a tutorial im learning
yet i have that error
wdym
who makes a game about blue balls in his spare time
Ok, read the errors. The first one is pretty much self explanatory.
TIP: case(upper/lower) matters in C#.
ill revise it again
Go back to the tutorial and compare your code.
yep
I need help, with my Movement/Locomotion, I have it so when you hit your controller trigger that hand gets ancorder and you can rotate your body around your hand (0 like gravity not to strong)
How would i make it so i can hold trigger puch or and let go of the tigger and i kindda jump on ait? I have tried this but i go in the wrong direction etc.
hell yeah now i have blue balls
guys, I am trying to make a pong game but I can't get the movement to be how I want it. I want it to be so when the player presses a button and keeps pressing it the paddles move up or down as long as the button is pressed, BUT I also want them to stop the moment players takes their hands off. I tried velocity, transform and stuff, but the paddles only move once or keep moving due to velocity or force. I hope I could be clear. I would appreciate any help
if ur using old input system store the input.getaxis value in a variable and have a script that checks it
sorry massive migraine laptop lights hurt
What do I do if my application works on my device, but does some functions do not work on another user's device
basically its just, click button and things are supposed to move and make next page button active, but it does not work for my friend
is this code related btw? or this problem varies?
try deleting and posting this to #💻┃unity-talk
i would rather use the new one but lemme give it a try thank you
use new one in that case
this method of approaching it is just held together by hopes and dreams
why does this happen
i am trying to make a main menu button and this is the script but it doesn't work idk why
It's just LoadScene("Menu")
GetSceneByName only works with scenes that are already loaded
Anyone please ? 🙂 ☝️
sounds like a #📲┃ui-ux thing - make sure you've set your anchors and pivots correctly to keep the board centered
Both on the Tile should be set to centered ? what about the construction of the grid itself ?
I'm moving to #📲┃ui-ux
Hi, im trying to make a game using cinemachine follow camera, i'm trying to fit two "rooms" in a single scene where the player can transition from one room to another using a trigger. However, i'm having problems because the cinemachine confiner only accepts one collider, i decided to try switching the confiner in code, but it seems that while the cinemachine camera DID move when changing rooms, the main camera itself doesn't, am i doing something wrong and is there a better approach than this? Thanks in advance
put one cinemachine camera in each room and switch which one is active by enabling/disabling them or by setting priority. You won't need to mess with confiners or colliders etc in code.
hiii,
so basically I tried installing unity but I have no clue what I'm doing. The tutorial I tried to follow used code that I don't think works in unity 6; I have been trying to figure out how to take player inputs but it all just isn't making sense to me, and I'm certain I keep finding different ways to do things. I know how OOP and C# work, but I'm at a loss when it comes to using it with unity. Can someone please explain how to take player inputs and why it works? Also, how do you link, like, code to assets?
If you're doing a tutorial you should use the same Unity version as the tutorial to avoid confusion
ig that makes sense... shoudve thought of that
does a function refer to something else specific in that case? I usually use them interchangeably in other languages but not sure about c#
I use field and attribute interchangeably too in other languages but I know attributes are something different in c#
i mean they are still functions, just not free functions
afaik methods are just a subset of functions
functions are either methods or free functions
free functions being functions not associated with a class? Can you even do that in C#?
Would be awesome if so
not really
i guess maybe you could consider delegates/local functions as "free", but maybe that should just be called a separate type of function
Gotcha
Yeah that's kinda how I've been doin functional stuff, not really local but I just have a class with only static pure methods
native C# question, is iparsable supported by unity?
i want to make a generic getter function
if you'd look at the documentation page for it you'd see it is only available in .net 7 and above
hey im trying to make a clickable bush where you can harvest berrys when clicking in a certain range to it but i get a nullReferenceException on line 17. could anyone explain why this could be happening?
using Unity.VisualScripting;
using UnityEngine;
public class BushManager : MonoBehaviour
{
[SerializeField] private float pickUpRange;
[SerializeField] private float growTime;
private bool berriesReady = true;
void PickUp()
{
}
private void OnMouseDown()
{
float distanceX = transform.position.x - GameObject.FindGameObjectWithTag("Player").transform.position.x;
float distanceY = transform.position.y - GameObject.FindGameObjectWithTag("Player").transform.position.y;
float distance = Mathf.Sqrt(distanceX * distanceX + distanceY * distanceY);
if (gameObject.GetComponentInChildren<Transform>().CompareTag("Berry") && distance <= pickUpRange && berriesReady)
{
}
}
private void Grow()
{
}
}
which one is line 17
also use some variables
don't do FindGameObjectWithTag twice lol
also are you working in 2d or 3d?
float distanceX = transform.position.x - GameObject.FindGameObjectWithTag("Player").transform.position.x;
2d
Then the Find is failing.
Don't use Find. Make a variable and drag your reference in
and then you can do Vector2.Distance(transform.position - player.transform.position) instead of doing the hypot yourself
ok i why is it failing tho?
there's no gameobject with that tag, presumably
gameObject.GetComponentInChildren<Transform>().CompareTag("Berry")
this also doesn't really make sense.
it is i have the tag on my player
why?
it'll just get the current transform
and does the player exist in the scene at the time the function was called?
yes
show its inspector
Because there is nothing in the scene with that tag
oh shit i was 100% sure i added the tag my bad
You still shouldn't be using FindGameObjectWithTag
yeah, they're pretty fragile
And especially not twice
ok ill try to avoid it
just use a reference, possibly a serialized one, or perhaps a singleton or a physics query if there's gonna be a ton of these
anyways about this
are you trying to check if a child object exists, or what exactly?
i want to get the child which is an overlayed texture which should be deactivated when picking up the berries and activated when they grow. havent implemented that yet tho
use a serialized reference for that
CompareTag wouldn't work and GetComponentInChildren<Transform> wouldn't get the right component anyways
serialized reference?
a public or [SerializeField] field that you drag the relevant object into
ahh ok never heard the serialized before sry
hi, im currently trying to make a dialogue system similar to that of undertale. i already have it working so that it displays text whenever you interact with a character through a list of strings. how would i go on about adding dialogue choices to this system?
Maybe you could make it a list of structs instead of just strings - you could define a struct like
public struct Dialogue
{
public string message;
public string[] choices;
}
Then if choices is empty, you know it's a normal message without dialogue choices, otherwise if choices has stuff in it, then you display those as choices!
(nice pfp btw)
sorry im a bit confused, would the choices array be the name of possible choices or would it contain the actual dialogue the character would speak given the choice? (p.s, thank you ^ ^ i love radiohead)
Back when I was more active in another discord server, whenever dialogues were mentioned, people would suggest looking into Ink and Yarn (Spinner?). Those are pre-made dialogue systems that integrate with Unity.
oh, okay i'll check those out thank you
I think it's good to try your own though just as a good way to learn!
Good question! I was thinking more like it would just show the two different options, but now that you mention it they would need to result in different dialogue branches
So maybe it would be better to model it as sort of like a linked list
I.e.
public struct Dialogue
{
public string message;
public Dialogue[] choices;
}
i agree, structured practice.. best way to find out what u need more practie with is just trying
(this would be a tree, not a linked list)
i mean a linkedlist is just a unary tree...
True!
i keep reading LinkedIn
okay, i'll try this approach out. thank you!
hard to navigate and consumes a lot of resources? sounds about right
lol
unary?
lol 🫡 til
-# imma take this oppurtunity to mention for no particular reason that ts has a quaternary operator
huh what's the quaternary? can't find any hits on google lol
quaternary would be 4 operands, it's A extends B ? C : D
the struct there is definitely not needed (and doesnt have any justification behind it). I would define this as a scriptable object.
this lets you also drag in choices in inspector. itll be a lot easier down the road
no-one calls it that (it's referred to as a "conditional type"), but it's just a neat bit of technical trivia i keep around
Ah yeah, idk I would have thought that's just a composition of the conditional and extends
Like I guess you could have a 5-ary just by doing A ? B ? C : D : E
i mean it is the intent but:
- there isn't any other check to use with a conditional
- extends can't be used on its own in a type, it's only for conditionals (and constraints/inheritance, but that's a different context)
- most AST parsers parse the entire thing as a quaternary operator, rather than a conditional with an
extendsclause as the condition- you can't put parens on the condition
wizard stuff, got it
A ? B ? C : D : E does decompose into A ? (B ? C : D) : E though, so it's really just 2 ternary operators used together
you can't separate any part of the conditional type
Oh got it, right I forgot this is separate from the other uses of extends
Ugh I love the ts type system
ikr 😄
it's saying "the name 'playerdamage' does not exist in the current context" i don't see what's wrong please help private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player"){ other.GetComponent<PlayerController>().DamageTaken(playerdamage); Debug.Log("Player Hit"); } } // this is on one script public void DamageTaken(float playerdamage){ PlayerHealth -= playerdamage; if (PlayerHealth <=0f){ Debug.Log("Player Dead"); } }// this is on the other Please help
well then it doesn't exist
that's what the error says
yeah but how does it not exist
first off, where is the error showing up
in this line other.GetComponent<PlayerController>().DamageTaken(playerdamage);
i have no clue in the universe why
maybe because it doesn't exist?
like the error said lol
if you think it exists, where did you define it
i feel like i defined it in this line public void DamageTaken(float playerdamage){
that's not in this context though
What you defined there was a parameter - in the context you're using it where you're getting the error, it's basically like you're saying you have a variable called playerdamage that you're passing into DamageTaken
and it'll get ASSIGNED to playerdamage (the one u made in the function float..)
ohhhhhhhh🗣️
DamageTaken(float playerdamage) means playerdamage exists in the context of DamageTaken (and its class)
the error is in the context of OnTriggerEnter2D and its class
the error says that playerdamage doesn't exist there
float anyNumber;
void CallDamageFunction()
{
Damage(anyNumber);
}
public void Damage(float playerDamage)
{
health -= playerDamage;
}```
ya, playerDamage is a basically a local variable to the Damage() function
it doesn't exist outside of it
wait
so would DamageTaken be anyNumber
well when i run it there's no errors but the player doesnt take damage
basically these are teh same.. (whatever u call the function with becomes that local variable (w/e u named it)
but this has zero to do with the naming of anything
u can pass in any variable.. any value.. as long as its a
theres no value here
do some debugging, see where the code reaches and doesn't reach
so if u copied and pasted exactly
it wont
its basically 0 unless u define it as being something else
float anyNumber = 10f; <-- if u declared it like this.. and then called Damage(anyNumber)
oh so would anyNumber == 10f work i'm so confused about numbers in coding
it'd delete 10 from health
well == is a comparison.. not an assignment
oh fr?
or you can have it serialized so you can modify it in the inspector so you don't have to recompile every time you change the value
float anyNumber;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
// pressing space sets number to 10 and calls function
anyNumber = 10f;
Damage(anyNumber);
}
if (Input.GetKeyDown(KeyCode.Return))
{
// pressing enter sets number to 20 and calls function
anyNumber = 20f;
Damage(anyNumber);
}
}```
heres a decent example
too
so something like [SerializeField] float anyNumber?
; at the end but yea
and name it better lol
the thing is is that i'm trying to get an enemy to damage the player
and it's still not working 😭 i am extremely confused
show your current !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
youll need to DEBUG
like chris mentioned
- check if the function is being called
- check if the values are expected
- etc
but yea show ur code so far : #💻┃code-beginner message
i gotta start being more creative with my examples that way we can get some crazy code later on in the day >8)
A tool for sharing your source code with the world!
ohh jeez
A tool for sharing your source code with the world!
ur IDE should look like its having a rager..
with red and yellow squiglies everywhere
wth is ide
the thing u code in
ahh nvm its fine
ur brackets are all just bunched up at the end
lol
that threw me off
triple brackets ftw
brackets
ohh i see now
can you show the console after u expect the code to run?
which logs do u get and which logs do u dont get?
add a log outside of the if statement
as the first thing the method does
u should get rid of htis function
and that variable..
no reason to have that in the player code
i suspect the tag isn't matching
^ yea its probably a collision issue
hold up let me check the tags
if (other.tag == "Player") and an alternative for this is just if(other.CompareTag("Player"))
and OnTrigger only works with Triggers
if ur Player or w/e ur touching for damage isnt a trigger (which i wouldnt see why it would be) that function isnt gonna run either
wait isnt it oncollisionenter