#💻┃code-beginner
1 messages · Page 182 of 1
Hi! I'm trying to make an "enemy" attack something and then right after, bounce back from the target to then go back and attack again. Here's the code I have on the enemy right now:
using System.Collections.Generic;
using UnityEngine;
public class enemyBehavior : MonoBehaviour
{
[SerializeField] float speed = 5;
[SerializeField] float damage = -1;
[SerializeField] string damageTag = "TownHall";
Rigidbody2D rb;
Transform target;
Vector2 moveDirection;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void Start()
{
rb = GetComponent<Rigidbody2D>();
target = GameObject.Find("TownHall").transform;
}
void Update()
{
rb.velocity = transform.right * speed;
if (target)
{
Vector3 direction = (target.position - transform.position).normalized;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
moveDirection = direction;
}
}
private void FixedUpdate()
{
if (target)
{
rb.velocity = new Vector2(moveDirection.x, moveDirection.y) * speed;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag(damageTag))
{
collision.gameObject.GetComponent<Health>().AddHitpoints(damage);
rb.velocity = new Vector2(0, rb.velocity.y);
}
}
}
And here's the object in unity if that's any useful stuff too:
Also, it's a 2D game
What's the question/problem?
I want to make it bounce back from the target when an attack has been executed
That's not a question
Ok, how can I make that happen?
What does your code do now?
Right now it just collides and stays there right next to the target
And deals damage once
Add a variable that tracks the enemy state, if it's attacking or bouncing back. After attack change it to bouncing-back state. Have it do in Update either the attack or the bounce back behavior depending on the variable.
is there a way to hold the execution of the program until the INT variable reaches the value 0 or whichever value i want?
similar to the iEnumerator waituntil or waithold?
while loop?
You can just stop it with if(true) where its getting a call from
Hi. Does anyone know how to save changes to an InputActionMap (new input system) please?
Well basically save the changes done to an InputActionMap at runtime😅
Wait do you mean change bindings?
Like I made a rebind system but now I need to save it and load it when the run ends/starts
How to convert Vector3 to Quaternion?
the Vector3 is not euler angle, but a direction which transform is facing, or transform.forward.
This probably then will be of help
yeah. But like not using the default rebinding system because that was very limited, so I kinda had to make my own
the thing is that I didn't use that😅
I'll see if it works
Well I hadnt had experience with that. I could help with setting it up but so far has no reasons to rebind it
https://forum.unity.com/threads/new-inputsystem-make-a-rebind-system.1124350/
Maybe this has your answer?
Quaternion.LookRotation
the binding are saved as json
so you can save the new binding as a json
then load the jason in your LoadGame() functions
like, with the default unity rebinding system you can't create composite bindings or new bindings, so I basically had to do it using something like the following:
reference.action.AddCompositeBinding("ButtonWithTwoModifiers")
.With("Modifier1", list[0].inputControls[0].path, "", "ExtraInfo(inf=42)")
.With("Modifier2", list[1].inputControls[0].path)
.With("Button", list[2].inputControls[0].path);
hmmm. With this or...?
if you cant remap directly, maybe make a manager that take the input and points to another action
probably a dictionary
maybe you'd have to create a whole new map if you want to do it that way
So like making a whole new input system basically?
like the thing is that with what I have right now it works for the run, but it doesn't save
well, that's how you would do it with the original input system, I'd just map keycodes to actions
i don't follow you. Difference in what way? I can see that they're different.
that not how it works at all with new input system
i mean the approach you suggested
you can very much make a system like that and I do it for hotkeys
redButton.name may not be "redButton"
he now wants to saved the remapped inputs and load them
replace the actions binding with the saved one
right, which I gave a suggestion just remap them on load
is it how you should do it? I'm not sure. Can you do it that way? Sure, why not
like the problem basically is that I wanted the player to be able to create multiple key combinations for the same action, like some games do, so the player had to be able to add bew bindings, not just modify existing ones😅
every dictionary can be saved as a list of structs that can be a kvp for your dictionary
where you pass this tilemap.cellbounds i want to test this solution too
okay, and then how would you attach your dictionayr
to the newi nput system
what values whould i give to area
can i tell vsc do undefine UNITY_EDITOR?
in the call to GetTileBlock it takes a BoundsInt parameter
Why not? If A always maps to method1, you then can decide what action method1 should produce
then it's making your own entire input system
yeah i saw but when we declared "area" as BoundsInt we didnt give it any value
you don't need to change the subscription model, only the behavior of which the methods should produce
yeah but key name is a string in your website also in the code you showed me: Color color = PlayerPrefs.Get<Color>("key");
and isn't there a way to just apply those changes to the "action prefab" basically?
but the input deteciton is done
throught the InputAsset
so if you replace "A" to "B" keys in your dictionayr
you also need to replace it in the InputAsset
please learn at least a little C#. A string variable or a constant string are the same damn thing
how can you connect that
you cannot have "A" in InputAsset, and "B" in your custom map dictionary
you need to replace binding on each action
otherwise SkipLetter in this case won't be triggered
Press key1 on keyboard -> goes into hotkey1 method -> hotkey1 maps to the action hotbar2
so how do you want to trigger SkipLetter based on your custom input map dictionary
i have a game idea but i dont know how to make it 😦
so it detected key1 press
you and a million other people !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thats why am here?
i want it to wait until the value reaches 0.
for example there are 5 enemies on the scene. i want it to wait until enemies is 0 so it spawn more or do other actions.
if i use if statement then it moves on and doesn't wait for enemies to reach 0.
in a code channel?
wdym?
i just want to share my idea and to learn where to start
ok, i tried this before Color color = PlayerPrefs.Get<Color>(redButton.name); , or this Color color = PlayerPrefs.Get<Color>(redButton); none of them works
yes, and instead of using hotbar1 action, you do the comparison in the method to check the action. It works, but if you want to change the map internally that's fine too, but otherwise it's quick and easy solution to rebinding
if(enemys==0) do something
define 'none of them works'
that's terrible approach
it's not remapping at all
But it is, you just have an extra comparison down the line
did you work with new input system?
it's how you do rebinding with the original system
neither of those worked
the old system*
1 extra comparison isn't going to break your game x_x
but that won't even work...
but I do it for my hotkeys!
i want to trigger SkipLetter function
this is worse than pulling teeth. In what way 'not worked'
but you are using old input system...
not im not I'm using the new input
because I don't need to make a whole new map when I can save some json and read from that
no one told anything about creating a whole new map
you can just save json
and load the json and replace bindings
instead of doing some extra dictionary and internal comparisions
you can just replace the actual binding to different keys
oh so you can just make the action into a string to save it as json?
for example i get an error when i typed this "Color color = PlayerPrefs.Get<Color>(redButton);"
Error CS0103 The name 'redButton' does not exist in the current context Assembly-CSharp C:\Users\Ömer\Desktop\2d Samurai Game\Assets\Scripts\StatExchangeMenu.cs 33 Active
either way its a solution and I decide to just keep the method names discreet enough to be reused
the entire GameInput.cs class is a json
you just save the bindings json you have
then you load it and replace
and how do you actually save it as json? like what is the function in order to for example debug it in the console?
really! Then you are obviously doing this is the wrong place. Seriously, you should be able to understand and resolve errors like this yourself
iirc you can do sth like
okay thanks, lemme try it real quick, thanks
public InputActionAsset myAsset;
public void SaveBinds()
{
string bindData = myAsset.ToJson();
}
and myAsset.FromJson();
then on the entier action binding set you just do
actionSet.LoadFromJson(loadedJson);
unity has all the methods for it
if I had a more analog specific game I would probably just rebind it since that is continous input, but for key presses I just used what I did in my previous system and it works fine
googled "unity new input system save binding as json", plenty of examples @glossy eagle
Listen i know why i get this error. But i asked you before if i should type this line in the awake method and you said yes. If i cannot enter it as a string should i declare those variables in the awake method or before the awake method? Or do i need to write that code in a seperate method and call it in the Awake. Like i did for the floats. The example in your website is not like this, or i cannot see the similarity
Listen, I am not going to think for you. If you know so little about programming in c# I suggest you stop what you are doing and go and learn it
And I said you should call Get in the Awake method, not type this line in the Awake method
I didn't ask you to think for me. What i am doing right now is learning. I don't want to watch 150 hours of udemy C# courses, i learn by making games. You also told me before that this is the best time to learn
tbh you can avoid all this grief and implement a separate script as I said above
that is exactly what you are doing, you are not thinking yourself about what you are doing or how to do it. I wonder if you even understand one single line of the code that you have
You're not learning. You're just smashing random lines of code together and praying that it works.
This will not help you.
If you want to learn to write C# while creating games, then use !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Since when does playerprefs have a generic Get?
he's using my asset
Ah, okay
which I sincerely regret recommending to him
I was wondering why no one was calling out that as an error
Now my problem is my character teleport when i jump and he fall too fast someone have some tips to have a better gravity ? my gravity is 9.81 and jumpForce = 10
you're multiplying moveDirection by playerSpeed
but moveDirection.y might be way larger than 1
I would do moveDirection *= playerSpeed; before setting moveDirection.y = ySpeed;
The gravity look better but the jump look like a teleport and its not high
Show your new code.
You were right, it was as easy as saving it as json and doing some more simple stuff, thank you so much 😄 (and thanks Mao too, gave me some ideas too)
how do you make a collider work as a collider but not push things with rigidbody 2d?
you can control whether or not a 2D collider can apply force, IIRC
However, I don't think this is going to let the collider function as a platform at all
But I'm not sure! I don't do much 2D
maybe it will indeed give you a thing you can stand on, but that can't push you if it moves into you
Note that this is a pretty new feature. It's only in 2022.2 or later
I don't see anything obviously wrong here.
what if i make it a trigger
and use the thingie method, like ocllision but for triggers
then it will be able to produce OnTriggerEnter/etc. messages
but it won't physically interact with anything
cool, nice thanks
Whaat. Is there a 3D equivalent of this? I want
Note that a jump is going to be very fast at the start
Nope
The associated script can not be loaded. Please fix any compile errors and assign a valid script.
What does your console say
conveniently cropped out the bit that shows that types of logs are hidden and how many there are
Make sure you haven't hidden errors in the top right of the console
and what is the full filename? it's cropped out in this pic
Hm, make sure the script is saved then restart unity. Compilation seems to be stuck in something
and what happens when you remove and readd it? whoops missed the from
Oh. Spelling error
Those names don't match and I couldn't notice in the original screenshot with it cropped
damn
Oh
It looked kosher on the original screenshot but I didn't check too closely
Warnings dont lie
aö sorry guyz I am burned out I guess
it wa s simple mistake I couldnt fix it for 10 mins
void Start()
{
_enemyController = GetComponentInParent<EnemyController>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.layer != _playerMask) return;
_enemyController.TriggeredByPlayer = true;
}
void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.layer != _playerMask) return;
_enemyController.TriggeredByPlayer = false;
}
I have this code just to detect player in region. For some reason its not really working?
OnTrigger calls are not being performed
Collider settings
You are comparkng a layer to a mask it seems
Yeah but issue its not even getting a call
Not the same thing even though both can be represented as ints
How do you know
use a physics query like an overlapbox or something instead of relying on trigger messages. but also if you want to rely on trigger messages, then check this: https://unity.huh.how/physics-messages
because Im debuggin it and its not getting a call
Okay so it's not hitting any break points in those functions, that would indeed mean it's not getting called
not if you're using 2d
"I wonder if you even understand one single line of the code that you have" Ok this was belittling and discouraging. I couldn't have gotten even this far, if i don't understand a single line of code. There are some subjects which i have less understanding than others, this doesn't mean that i know nothing about coding. There are 8 games i released on itch.io so far. Game development is not just about coding. This was really disappointing. There's nothing more to talk about
The Three Commandments of OnTriggerEnter2D:
- Thou Shalt have a 2D Collider on each object
- Thou Shalt tick
isTriggeron at least one of them - Thou Shalt have a 2D Rigidbody on at least one of them
Player has rb, collision is trigger
Both have collision
I mean similar code I have to pick crystals is working
Are you moving the player via rigidbody?
That doesn't provide physics messages
that's also going to confuse the physics system in general
I should use rb to move player?
(and it won't work at all if you turn on interpolation)
You need to use the rigidbody to move if you want the rigidbody to know when it moves into something
Can you tell me how you reached that conclusion? Do me a favor and easy on the assumptions huh. I already compeleted all the unity learn pathways btw
void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("Player")) return;
GameController.Instance.Score++;
Destroy(gameObject);
}```
This is practically same code
I can change the tag from player to layer
i'm operating on the information you've provided me
if you want me to come to a different conclusion, provide more flattering information
Wich one of 2 I need?
oh that's a neat method
I need to call this function on FixedUpdate like ray hit?
"Need" is a bit strong, but "should" definitely applies
btw do I need to make Update, Awake, etc private?
No. Unity doesn't care about the access modifier
doesn't matter but I usually make them protected
Some Unity code makes those methods protected
see Selectable for an example
It'll have things like protected virtual void Start() so that you can override the methods in child classes
Unity uses reflection to yank those methods out of the object, no matter what the access modifier is
What means min deapth?
read the documentation
what do the docs say
The docs explain every parameter
Only include objects with a Z coordinate (depth) greater than or equal to this value.
triple jinx
surprised it even has depth
It is useful for 2D.
But if you aren't explicitly putting objects are different depths, you can ignore it
I mean if everything is on same Z
It's literally the 2D version of the function
2D is really 3D ;)
That is not always the case
Well, not really.
The physics engine is completely different
it's Box2D instead of PhysX (or whatever nvidia's thing is)
look at your build report -- it's in the editor log after a build runs
why my portal and pyramid not visibl
It's much more like three 2D's in a trenchcoat when it comes to Transforms, though
Unity projects big
you forgot to remove the line of code that says to make your game 1gb big
It lists every asset that made it into the build.
Note that there will be a baseline size for a game -- Unity needs to include...
- its own code
- its own assets
this is a code channel
Unity takes like like 400 gbs of my drive out of like 10 different projects/editor versions
Unity projects indeed big
Are you talking about the built game or the project?
You can delete Library, temp, logs
oh that's expected
It will clear up a lot of space
Unity needs a lot of space for imported data, temporary files...
also, this is not a code question, so it should be in #💻┃unity-talk
What operations are calculation heavy from unity?
any terrible find operation in update
So every good coder should always use as much find as posible
enjoy searching through tree gameobject #1352
Yeah I suspected that find is iterating through all objects
Is it fine to use at start to reach some component?
Or there is better way when you cant serialize it?
There is usually a better way
Find is never necessary
Calling Find just once could cause a small hitch if you have lots of objects
Square root is pretty bad but it can be necessary
How would i go about making a navmesh on a map that is instantiated around 3 seconds after start
why this no work, the gameobject has an isTrigger collider^
and the ground has just a collider
neither got rigidbody2d
You can bake navmeshsurfaces at runtime
That last line
that is why 'no rigidbody'
but... i i check if they have collided using their collider not using their rigidbody
Collider2D collision
How have you managed that
That'd be a pretty fancy function to achieve that
so... at least one must have a rigidbody?
If you need it to be still set the rigid body to static
this is the same as having no rigidbody when it comes to collision/trigger messages
Im having an issue. I serialized PLayer object on prefab with transfrom but aparently transform is not getting updated positions... So this happend
left birdies. How to add player from the level to serialize
Or get his transform?
prefabs cannot reference in-scene objects. which i'm fairly sure you've been told before.
so your prefab is probably referencing another prefab. which, notably, does not exist in the scene
I was infact not
okay appearanlty a rigidbody with a trigger collider was the combo that i needed
set gravity to 0
and ye thr arrows dont push things
should be making it kinematic if you wish to control it completely through script
Well I fixed prefab issue
hi everyone. i need help with making api. may someone dm me and help...?
rude
But accurate
not rude, true
😦
Asking for someone's direct undivided attention before you've even actually asked your question is also rude, by the way
what they mean is it's not likely someone will dm you before even knowing what your issue is. just ask your question here and you might get help sooner
start with what you're trying to achieve
but i need to make it for my school project
and what means school project 😄
Yes.
ok.
Do you mean the Unity API? Or you need to make an API for your game for some reason? Which API are you talking about?
Was wondering why my kill floor is not working.
That small square is my hotbox 🙂
Unity api.
!docs
There ya go
The rest of the lava is perfectly safe, but stay away from this particular square meter of lava. It's particularly hot.
They're called land mines
Thats not a bug, thats a feature
Fair
devs should just add kill walls into every Out of bounds areas
this gonna fix all speedrunners
@languid spire I managed to do it with the help of your tool but with a different code. I thank you for that. But you hurt me
@swift crag you too
Okay.
help I accidently crashed my project and now i couldnt opened a new instance for the same project
how to fix?
i'd give my computer a restart first
already restart and even quit the program, yet it still persist
"quit the program"?
from task manager and exiting the unity hub, both doesnt work
but you restarted your computer
make sure the Temp folder in your project is deleted
there should be nothing to quit at that point
after that, I'd guess there's a lockfile, yeah
uh...i double checked, guess the files are also lost
its all became empty
no way to recover?
without version control/backup? no
Open your scene
you're in the wrong scene
its all empty, nvm, please teach me how to avoid this happen again, how to set up backup or version control?
did you open correct project?
learn git
or svn or whatever you want
Show what's in the root Assets folder
{
Debug.Log(currentState);
if (currentState == State.Running)
{
Vector3 direction = (_target.position - transform.position).normalized;
_rigidbody.AddForce(direction * moveSpeed);
SetAnimationState("Run");
}
}``` my npc wont move stays in current spot can also confirm the debug shows current stat as running
oh its there, thanks, guess its not all lost
so log direction and movespeed as well
Are you overwriting the velocity
Personally I would suggest looking into github, gitlab or bitbucket, all great git solutions for backing up your project, then get either "Github for Desktop" or my personal favorite "SourceTree" and get familiar with "push", "pull" and "commit", there are other things that can be useful to learn later like merging, diffing and branching, but those first 3 are the ones youll use the most often (watching a tutorial on how to use git can help) - this is not the only approach but I think github + sourcetree/github for desktop is a good start to get familiar with source control in general and is relatively easy to setup - just remember to actually push commits to your git/repo often so you always have a mostly-latest version you can pull from
I'll keep that in mind for my next project, btw I had a question, my camera cant detect my sprite renderer. Any idea whats wrong?
Is it actually in front of the camera
i have no idea
Switch into 3D mode and check
Sorry i ended up ditching it and going to transform.position instead for time being. Sorry for wasting your time
When you click the camera, you will see a box
Is the sprite inside the box
Can't be sure from this angle, but with that selected you should be able to rotate around and see if it's in view
oh got it thanks
For FSMs, is it good practice to make a bunch of states for small states, like transitions, or should bigger states group in those smaller states?
substates are fine
What’s a substate?
A state that is a child of another state
A state inside a state
So say I have a thing where a button comes in, player selects a button, and button comes out, and then it repeats that 5 times with different buttons. So I would make a state for each of the five things, and then in each of those, I make three substates: the buttons coming in, the button getting selected, and then the buttons going out?
hey dose somebody use an addon to visual studio that will show you options that could follow
example: collision. body colider contacts ...?
just like examples
Are you just asking about autocomplete in VS?
If you don't have it you haven't set up VS properly
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
ok i try to set it up thx
You can probably reuse this button class and extend from it in this case as their states are similar but with different implementations.
Alr thx
I think I understand substates now
So use states for big general tasks
And substates for each step of that task
Right?
There's a lot of definitions for state and statemachines, but ideally you do want to design your logic by grouping behaviors, but that's not always the easiest approach
This sounds reasonable, yes.
If you're in a sub-state, you're also in the parent state
I usually stick to major -> minor states and no more, as branching out can dilute the logic
as far as something like a character controller or pathfinding logic machines go
I have a 3D model, downloaded an animation from internet all works nicely, the problem is that im want an fps game and when i parent the camera to the head bone it is shaky because of the animation. Would it be ok if i did a script that would constantly update the camera position to the head bone?
I had that exact problem.
Most of the camera-shake was from rotation, not translation
So I just have a script that, in LateUpdate, sets the camera's world rotation (transform.rotation) to where it should be pointing
Now the camera is only moving, not moving and rotating
I also use IK to make the head rotate in the direction the player is trying to look, which prevents the camera from getting way out of alignment with your head.
It's still not as clean as just having the camera floating in space. Most games don't show a first-person body (or fake it) for a reason!
i mean if it works, ill give it a try, thanks
i wanna set a bool to be true after a 1 second wait inside one of the methods i have, i was thinking i could use invoke then put the string of a newly made method that does nothing except set the bools value to true.. but.. there has to be a better way, a way that doesnt involve making a whole new method just for that..?
you have to run some code later, so you have to have a method to call
of course, you could also just check in Update or something
coroutine
float delayTime;
public void SetDelay() {
delayTime = Time.time + 1;
}
void Update() {
if (delayTime <= Time.time) {
// whatever
}
}
but this way you are wasting performance on this update loop that's gonna be always running and checking the if condition each frame. coroutine is way better for performance, isnt it?
Starting a coroutine creates garbage, since you have to create the IEnumerator. Unity will also create a Coroutine object.
Then it'll have to check if the coroutine should get MoveNext() called on it
its a part of a method, i cannot use update for this one
It looks like native code does that when you use WaitForSeconds, so I don't know exactly how that works behind the scenes
none of this really matters unless you've got thousands of these things, though
you want to go with whatever is easiest to understand
that reminds me, what resources do we have when it comes to pooling coroutines if that's even possible
Coroutines can't be pooled
some of my object pools require some coroutines to sort out stuff before being dequeued
IEnumerator can't be reset so it can't be reused
i just wanted so the player doesnt move left or right which immedietly overwrites the velocity
Dang, well that's something I'll probably look into redesigning in the future then
guess it depends if polling in update is more performative than creating the coroutines
interesting. and its impossible to create a coroutine once at the start and reuse it?
it's all internal stuff
Just have it running indefinitely.
include the ever-dreaded IntPtr
then again this method has a hit on performance
It's got an initial cost but that isn't anything too expensive. The GC on freeing it has a cost though.
what's that? 😱
it's a number that can be used as a pointer
god I love the new numeric interfaces
they make the documentation look so good
Something that should tell you, 'if I am using this I should be writing C++'
Lmao
It offers the utilization of yielding instructions. You ought not be worried about performance but rather maintainability.
That's actually a pretty interesting idea. Maybe have it sleep every few seconds and check if capacity is low enough.
Of course, cache objects where ever possible though.
an indefinitely running coroutine only has initial cost?
Hello, I've been working on a function where the "Pickup" void is triggered by touching an object tagged "Pistol." The goal is to change a bool from false to true. In my world, there are two guns: a prop gun and a real gun, with the latter being a child of the player. Initially, the real gun doesn't appear, and the prop gun's role is to delete itself upon player touch. Subsequently, the real gun should appear and become shootable when the "showRealGun" bool is true. I'm currently facing a challenge in changing the bool from false to true in the script. I've spent about an hour searching for a solution but haven't found one. If you, the person reading this, have an easier or better solution, please let me know.
Only? 🤔
yeah u said its got an initial cost but i would assume having it running its code every frame also has cost
trying to problem solve somthing here and im lost. i have a bit of code that if the distance is less then 2 attack else continue to chase the player. Well when its in attack stage, i want to work out if the enemy hit the player first or the player hit the enemy first. The thing is there is a sphere that works out if player is inside to do this chasing and hitting like so ``` private void OnTriggerStay(Collider other)
{
if (other.CompareTag("Player"))
{
float distance = Vector3.Distance(transform.position, other.transform.position);
if (distance < 2f)
{
_canChase = false;
_rigidbody.velocity = Vector3.zero;
currentState = State.Attacking;
}
else if (distance > 3.5)
{
_canChase = true;
}
}
}``` Also the weapon is nested inside the npc script. How can i work out who hit who first when they dont share the same script. also my trigger stay is always checking tag player. if that makes sence
hello trying to code on my own since the pathway ended. I did position and scale scripts alright but stuck here.
is there any way to make 2 objects whoich both have colliders and rigidbodies2d to not collide with eachother besides using layers?
I'm referring to the construction of the coroutine. The statements inside are those that are necessary and unavoidable - the code you're wanting to execute...
Focus on maintainability unless performance is an absolute must.
rotation property isn't a Vector3
Physics/Physics2D.IgnoreCollision
Lets you specify 2 colliders
Seems like you've the idea there, so what's preventing you from changing the bool in PickUp()?
Use Quaternion Euler https://docs.unity3d.com/ScriptReference/Quaternion.Euler.html
I thought rotation hapens in 3d so I used that
alright, and im guessing if i have a coroutine that i have to use often, then only having one coroutine with a "while (true)" loop is better because garbage collection is way worse?
and also
transform.rotation = Quaternion.Euler(new Vector3(0, 0, rotationChange));
in update, right?
oh nvm i see u alr said that
FYI you can also do transform.eulerAngles = new Vector3(...). Same thing
I tried using "ShowRealGun = true" but id didnt work and then I found on reddit and yt videos "SetBool("ShowRealGun", true)" but it didnt work at all and Im asking for help in the unity discord
What you see in the inspector isn't what the rotation property holds. The rotation property holds a Quaternion, which is completely different from a Vector3. Their only similarities are the x, y and z components - in name. Quaternion would have a w component and the values it hold are not Euler values.
Need to show your code then instead of images
!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.
okay just need to add this?
its ok now
or should i change public vector3 too
you can directly serialize a Quaternion if you want
it shows up as the familiar Euler angles
If you aren't starting up coroutines every frame or have a lot, there shouldn't be much issue. Caching the yield instructions are a necessary though.
I'm referring to..cs var wait = new WaitForSeconds(...); while(isRunning) { ... yield return wait; }
I use this to make a character's mouth open and close, for example
ty
Hi guys, how to make melee and range combat system in 2d?
I just do Quaternion.Lerp(closedRotation, openRotation, amount)
oh damn, thanks for letting me know. where do you even learn something like that? caching yield instructions, i mean
You learn a lot of little things once you start getting picky about creating garbage
note that you can't save WaitForSecondsRealtime, because that one stores the remaining time directly in the object
go figure
really at this point I am doing more c++ than c#
even events are creating too much garbo
nah, all tutorials in yourube are weird
I read this but Im too beginner for this for now
Did you look up what parameters Quaternion.Lerp uses
there was an easier way in unity essentials pathwayü
okay ill see
What are you trying to do?
are you actually trying to make an object rotate between a start and end rotation?
i was just showing an example of how you can serialize Quaternions.
Im trying to make object rotate endlessly as long as the game runs
bro i keep getting this error sometimes even tho i know for a fact it has a reference
then why are you copying code that I said was used to rotate between two points? :p
So why are you trying to lerp
(also, I lied; I was using Slerp)
Something on line 38 of Archery.cs is null but you're trying to use it anyway
Something doesn't have a reference
Perhaps you have multiple instances of the same class.
well I dont even know what lerp means so thats why I guess
can u elabroate
So why are you trying to use it
transform.rotation *= Quaternion.Euler(Time.deltaTime, 0, 0);```
perhaps you have more than one Archery component in the scene.
what goes here
What do you want to go there?
For what purpose
What are you trying to make a variable of
What are you trying to expose to the inspector and other classes?
so you sent "transform.rotation *= Quaternion.Euler(Time.deltaTime, 0, 0);"
you don't just put stuff there for no reason
you add fields if you want to store a value
figure out what value you actually need first
perhaps the rotation speed?
its not built in
yes, because there isn't literally a RotationSpeed type
public Vector3 direction;
public float speed = 1f;``````cs
transform.rotation *= Quaternion.Euler(direction * speed * Time.deltaTime);```
speed is a number. so, float.
okay but someone said not to use vector3 with rotation so I was confuesd
Quaternion.Euler converts Vector3 (euler) to Quaternion
okay works. sorry i took so much of ur time
Every archer has this, but their spawner automatically gives them a reference to it
Prove it by logging the variable immediately before you use it.
it's also possible that something else is null
if (foo.bar.baz.buz && a.b.c.d.e.f.g)
Maybe you ought to look up a tutorial. This is the beginner coding channel but there seems to be some confusion as to the suggestions made.
They were to inform you that rotation is a Quaternion and not a Vector3. You can still use Euler values with a Vector3 but you'd need to convert to a Quaternion before assigning it to the rotation property.
lots of places for a NullReferenceException here
How about show the line that throws the error
how to make the code recognize the height? please provide the code if possible
What is y
show !code
More context would be necessary.
No you provide 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 dear
yes there was some confusion. Because Im following unity essential pathway and the things like quaternion and euler are new to me. also I will ask one last thing and go. You added direction variable in the beginning in this code:
"public Vector3 direction;
public float speed = 1f;
transform.rotation *= Quaternion.Euler(direction * speed * Time.deltaTime);"
but never used. can I ask why?
What is any of this
I'm not sure what you mean by "never used".
direction and speed are both clearly being used there
idk how to provide height so i just bashed it
not refferred
the height of what?
you can't just declare a pile of variables and hope Unity puts meaningful values in them
okay so they are built in then
None of this makes even the slightest bit of sense, what are you even trying to do
camera?
no, they're both declared
they're fields on the class
to code sometimes I just smash my head on the keyboard and hope for the best
okay, so there are several major problems with your code:
yis declared as anobject, which is incredibly vague. this can store anything.- you've got several lines of code just...sitting there outside of a method
y -= -6;y += 2;
this doesn't make any sense whatsoever
You're missing an asterisk (*) between direction and speed.
They're both declared as public and the later code illustrates them being used in your Update method.
that got eaten by discord formatting
so how do I provide height then
um yeah. I think you edited the code I didnt reedit it in my visual studio
I see direction var being used there now
mine was like this the first time i copied but its ok now 👍
no, you didn't copy the rest of the code
yeah my bad. I just realized it wasnt edited
I couldnt copy it properly 😄 but anyway happy learning see you till next time 🙂
You can't have statements outside of a method body
I would have just linked a c# video and called it a day but you guys are too nice
you've declared like three variables named variations of "height offset"
good way to know for sure their IDE is not configured ontop of everything else
is that even an IDE
They prob using Notepadd++
Maybe a printscreen of GDL space
it's very messed up
the longer I stare the worse it gets 
private readonly object y is my personal favorite
So player is null. Show where you set player
Okay, so where do you set this.player
(IN A HURRY) Hello! How can I quickly check if an object exists in the scene using GameObject.Find()?
"QUICKLY, CHECK THE DOCS!!"
After setting the player in this code (which you're doing twice by the way for whatever reason) add this log:
Debug.Log($"{gameObject.name} is passing the player value of {player} to {archer.gameObject.name}, which is now {archer.player}", this);
if I use GameObject.Find("name") != null it doesnt work
wait lemme see
Besides the fact that it's not by far the best way to check if something exists, it depends on when you check that
current code
Awake()
No point in finding itself.
It is, without a doubt, definitely going to be finding an object in that case
You can absolutely ignore that entire else block it is physically impossible to happen
its in dontdestroyonload and when I go back to the same scene I get duplicates
this is what it says when the code decides to run
So why not use Instance instead of find
Okay, and there's no error there
So what's the problem
its that sometimes this gives an error
like find if the same instance already exists?
sometimes somehow its null
So show the console when the error happens
No, just check if Instance is set
Since it should be static
how could I do that
I sent two links
If Instance == null
did u even look
ty, imma try it
First, read the links nav sent
i read
happened again
It would be null if the object isn't present in the active scene. Note that the object must be active for you to be able to find it with Find.
the player is always in the scene
it works, you're a lifesaver!
Is he active?
so is the spawner
So then it seems that UpdateTargetPos is being called on a different archer than the one that got the value set. Let's add in another log there as the very first line:
Debug.Log($"{gameObject.name} is updating target pos. Player is {player}", this);
uhh how do i check that, or what does it mean exactly
That is literally straight from the second link nav sent...
Unity.huh.how is great
you mean here?
if error occurs
if it doesnt
seems that i try to spawn in the archer too fast after the scene is laoded, thats when it happens i think
So you have at least one clone that has a null player
Show full !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.
Archery: https://paste.mod.gg/khylquxdbxii/0
Archer spawner: https://paste.mod.gg/hetwqoundmld/1
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
You have three different kinds of timers in this one object
You have an invoke, a couroutine, and an Update timer
My guess is the Invoke is to blame for this
You should probably stick to one kind, and if you're willing to do Update timers it's probably that one
pipe move script: https://gdl.space/ovagaluzim.cpp
pipe spawn script: https://gdl.space/ozecexicaf.cs
Things work, but after a few minutes of destroying object, errors came out, pipe also doesnt spawned on top
did you read the error?
I've been trying to fix it and I had no idea what to do, I got zero foundation on coding, been changing codes here and there
Still read, because there is a lot more to it than that one line
you cannot GetComponent on a destroyed gameobject
See what line the error is on. You're trying to reference something that's already been destroyed
newPipe.GetComponent<PipeMoveScript>(); this probably trying to get it from newPipe that was destroyed
Followed tutorial for that, but this is what I get, if you get a good suggestion for a basic one ill look it up
this one?
And a poorer understanding that will harm you in the long run
tutorials dont teach you well
yes
You should google your error. It's very common, see if you can understand that.
but they each have their own thing
Yes and that's the problem
InvokeRepeating(nameof(UpdateTargetPos), 0, 0.8f)
Though you should probably learn coroutines
That is entirely my point... but ok....
There is a coroutine in there
and an update timer
😮
copying&pasting code from a tutorial blindly wont teach you anythhing
I dont see they spoon fed though
writing Instance == null by itself isn't a spoon feed lol
they would have to know what Instance is and why its assigned null
There's a bit of a difference between invoke and a coroutine: https://www.codinblack.com/how-to-run-a-method-at-certain-time-intervals-in-unity/
The last difference between Invoke and Coroutine which we will cover is the execution condition after the deactivation of the object. Invoke and InvokeRepeating do not stop after the game object is deactivated. On the other hand, this not true for coroutines. They stop after the game object is deactivated or destroyed. Therefore, you should use Invoke or InvokeRepeating, if you would like your method to continue running, even though the object is deactivated after the method is triggered.
where can I get a reliable foundation study mat if you had any suggestion, the ones I had is all scattered knowledge
check the pins
in this channel
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
ok so my thought process is this:
i use invoke cuz id want the position to be updated once every 0.8sewc rather than in update cuz thats too often, i suppose i could avoid it by using a float name;
set it to Time.time in start()
and in update, i update the position inside a if (name + 0.8 <= Time.time)
and inside it i det name back to current Time.time
i thought the invoke would be cleaner tho
as for the croutine, its cuz the archers attack is a bit unique, he choses 3 random palces around the players position and spawns targets, and only does the actual attack part after a second, so the player has time to dodge.
i could avoid invoke but i wouldnt know how to do it in any other way than it is rn with the 1 sec delayed part of the attack
Invoke and InvokeRepeating do not stop after the game object is deactivated
i assume deactivated means destroyed (cuz says "deactivated or destroyed" later on), which means that it will keep updating the position of the player for the dead arche,r but since the archer is no longer there it causes an error?
I'd avoid using invoke unless what you're doing has no dependency on any other objects in the scene.
👍
did i get this right tho?
Deactivate refers to the state of the game object - active and inactive: https://docs.unity3d.com/Manual/DeactivatingGameObjects.html
InvokeRepeating sucks, use coroutine
what if you have 10 arrows?
terrible architecture
yea i getchu... code needs to be cleaned up
i was thinking once i got everything right, i can try to make this work as a loop
or at least the basics of the archer
The standard response to code like this is:
If you find yourself numbering variables, use a list or array
yeah, you might have a max of a number 2, for non alloc stuff maybe.
just a quick hypothetical
if you've coded something and it works fine
but then you want to hook it up to UI so that it comes with visuals in some way
would you need to rewrite the original code in any way
or would you just add new lines to it
if the answer is "depends" then just give any examples you can think of where you would need to do so
define "well"
and if you did your code poorly, then yes
open closed principle
....define "open closed principle"
In object-oriented programming, the open–closed principle (OCP) states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification";
that is, such an entity can allow its behaviour to be extended without modifying its source code.
The name open–closed principle has been used in two ways. Both ...
If you did your code well, then it will follow the open closed principle. And therefore require no modification to the source code
if you need to modify the source code to extend it, then you’ve been a very naughty boy
this guy's hair looklike a brillo pad
It wouldn't be that different using a list... the process/migration that iscs for(int i = 0; i < targets.Count; ++i) { var arrow = Instantiate(...); arrow.archery = archery; arrow.targetsPosition = targets[i].transform.position; Destroy(targets[i]); } targets.Clear();
that's sarcastic right
I meant, having to change too much
i think xaxup’s code was trying to illustrate the architecture being bad
what if they have 10 arrows?
Not referring to acceptance 
Definitely not acceptable.
Ah, thought that was the OPs code.
How can i simulate a push to a character controller ? like a push from an explosion or something like that
you'd have to introduce your own concept of "Velocity" into your movement script. Then have the explosion affect the velocity
For a character controller, you'll have to manually calculate out the velocity change and apply it over several frames to the Controller
You get movement super easy with a CC but it means you have to do the math for physics manually
Break down the problem.
Definition of a push:
- Direction
- Force
Thx for help
new versions doesnt have microgames for the tutorial session, should I download the old version??
2021 has them
Or I think you can download them from the Asset Store
where is asset store again?
If you google "unity asset store" it will come up
is that a serious question
I think it might be assets.unity.com or something
I always just google it though lol
just losing hope :/
perfect time for that meme "First time ? "
Hah, look at this nerd they still have hope
well I had hope today, didin't see any chat-gpt shit
or maybe i missed it 😄
Having issues with jumping in my game. When I jump and move it is doing weird behaviour as seen in video
!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.
Using transform.position and addforce at the same time
I see you try to get around that by using the current y position in direction, but that won't cut it
Edit: actually, looking at the video, maybe it's an issue with being grounded
How do you check if you're grounded?
just to an oncollisionenter check and if it enters on grounded is set to true
That is tough to get right (i prefer raycasting or overlaps). But is that cube set to the tag or whatever you use to check that OnCollisionEnter is hitting ground?
Good Afternoon, I have a little question i think. I want to make an Attack move. While the Player is attacking he cant move. But how do i do that. Like where can i see or check when the played Animation is over?
Need some help with my 2d endless runner game. I have enemiesmovement script attached to each enemy, inside my update function i have this:
I don't have a tag set for it so is grounded should be set to true no matter what
But when i call this function, the enemies don't freeze
just use the AnimationState
Is it a Class?
So that sounds like the issue then
main issue for me though is the rotation that happens when I am jumping
Thank you very much!
this is the method you want
https://docs.unity3d.com/ScriptReference/AnimatorStateInfo.IsName.html
Ok, and how do you get direction?
As Xaxup said, share the whole code properly
using the value taken from new input system
hold on I'll try now
Thanks 🙂
Anyone know how to fix this?
https://gdl.space/saxekupuwe.cs for character controller
then you have something else overriding it?
or that method never runs
Its not character controller
Im not sure, am i right in attaching the script to the actual enemy itself?
it's just what i named that class
That's a common name for that
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMovement : MonoBehaviour
{
[SerializeField] float EnemySpeed;
private Rigidbody2D rb2d;
[SerializeField] private bool frozen = false;
// Start is called before the first frame update
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
EnemySpeed = 1.5f;
}
// Update is called once per frame
void Update()
{
if (!frozen)
{
transform.Translate(-1 * (EnemySpeed * Time.deltaTime), 0f, 0f);
}
}
public void SetSpeed(float speed)
{
EnemySpeed = speed;
}
public void Freeze()
{
Debug.Log("Enemy Frozen");
frozen = true;
}
public void Resume()
{
frozen = false;
}
}
This is the whole class
where/how do you call Freeze
and are you certain that method runs?
does Debug.Log("Enemy Frozen"); work ?
btw are you aware the EnemySpeed will always be 1.5f no matter what you set in the inspector
oh ok , and where do you call Resume
also from the player class, inside the resume function
they set it through a method so it doesn't matter I think
I want the speed to always be 1.5
I feel like you just need to get take the x and z from your direction vector when setting the transform.forward. then use the transform.position.y for the y value?
To be clear, the issue is that it leans back when jumping, right?
where does your player get a reference to enemyMovement? Is there only ONE Enemy in the game?? How would this work for multiple enemies?
Am i right in putting the movement script on the Enemy?
There are lots of different enemies
That spawn randomly
Seems like you're probably calling Freeze/Resume on the prefab and not an any actual enemies in the scene
yes it still leans back even when I don't set the transform.forward at all. it leans back as soon as I move in a direction
well calling Freeze/Resume on ONE reference isn't going to affect all of them
public EnemyMovement enemyMovement;
This is my reference
they each have their own frozen variable
I know
Yeah, i thought that would be the problem
Ok hmmmm. I have to head out in a minute, but I'll look again when I can
It would probably be better to have some kind of centralized Enemy Manager that handles whether the enemies are frozen or not.
no worries thanks anyway i'll try figure it out in the meantime
I have an enemyspawner gameobject
Could probably be the same thing that spawns the enemies
yeah
Actually, I wonder if it's from the animation actually. Check the animation for if it changes the rotation by accident
I will try, thanks
animations are happening in a child object
but weirdly enough it does seem to slightly affect the rotation of the parent object
lets say I have a game object. and I want an if statement that checks if the gameobject has 1 child. how would i do that
how can I get a few references of scripts and thru the inspector choose a method from those scripts like a unity event?
transform holds all the children
if(transform.childCount == 1) // do sum
Why does OnTriggerEnter work even if the script is disabled?
I get error "cannot take the address of the given expression"
whats the formatting for sending code in discord
!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.
thank you
script disabled or the gameobject ?
Script
Instead, i just made a variable from inside the player class, with a getter function, then inside of the enemymovement script, i just put inside the update only move if the player.getMoveState = false etc and it works
its because I want to use unity event in a prefab but using a object in the scene
public Animator animatorVariableName2;
public GameObject Player;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (animatorVariableName2.GetCurrentAnimatorStateInfo(0).IsName("New State")) & (Player.transform.childCount == 1)
{
if (Input.GetMouseButtonDown(0))
{
StartCoroutine(BallMelee1());
}
}
a Unity event
the issue is the player transform part
I cant a prefab cant get a reference from a scene object
&& is for AND
& is something else
its lacking a parenthesis at the end of the line
it should work after
u have extra parenthesis
well closed early )
I tried using the AnimatorStateInfo.IsTag but it seems to not work? Do I miss something? My Tag i gave my Animation is called Attack. Anyone have an Idea?
if (animatorVariableName2.GetCurrentAnimatorStateInfo(0).IsName("New State") &&(Player.transform.childCount == 1))
{
}```
instead of (animatorVariableName2.GetCurrentAnimatorStateInfo(0).IsName("New State"))
alright let me try that
am i missing something? shouldnt this destroy both the thing that interacted with the gameobject that has this script and the gameobject itself?
exactly
can I use it by taking the reference script from its own script
what does it do
alright that worked thanks so much :)
you "Inject" the component you need
hmmm, I'll look into it
The script
checking anything by name is a terrible idea
dont do it
thats the one with OnTrigger enter?
yeah
ah yes
you can literally check for Fireball component here instead of checking name == "fireball"
Is there any way to make it not work anymore unless it is the first time?
make a bool?
i could check with tag as well actually, idk why i didnt do that
I think disabling script only gets rid of the Unity events but not sure on the physics one
should i do that instead?
Sure
as i said
you can literally check for Fireball component here instead of checking name == "fireball"
I was looking at singletons and can they be used to choose from the inspector a method?
I did that, but this trigger gets HP out of the player. And it somehows get 2 or even 4 HP out of the player instead of 1
because getting the reference itself isnt the problem
no, why would you need that
I mean you can
because its a powerup script and I want every powerup to do something different
he probably mean
subscribing a method from the singleton to unity event
via inspector
(ignore the destroy at the end)
OHHHH
yah like that, can I not assign it from a reference already in the script?
try it and see youroself?
tysm
I did and I got no clue
like it didnt work
maybe I need to make it public
i have no clue what do you mean at this point
also I prefer not to nest my bools when possible in something like that its cleaner to do
if(wasTriggered) return;
//rest of the code inside OnTrigger```
like this?
OK so Im trying for each powerup to do something different one can access the player health, other can access the player controller etc. So what I want is to have like a unity event so once you pick up the powerup it calls a method from one of the scripts
makes sense
IPowerup interface
PerformPowerup() method inside
then when you interact with the IPowerup, execute it's PerformPowerup() method
and each powerup can have different logic inside PerformPowerup()
how do i destroy both the fireball and the object that his this script tho?
the object that his this script?
this is part os a script attached to a game object
like that
none of them get destroyed
then its not getting called
then this code isn't running
Can I prevent that my Trigger can be buffered?
How to count the direction of the perpendicular from hit point of ray?
How do i create an animation parameter for my script?
also i have this, maybe somehow it causes that? but i mean even if isReflected is true, it still doesnt destroy em
not a code related question
in the fireball script, diff script
If the collisions are ignored then you're not going to get collisions
u could technically make a parameter via code tho, right? 🧐
I feel like that shouldn't need to be explained
yes BUT even if isReflected is set to true, meaning the if statement doesnt run
it still ignores
for the animator?
You access paramter conditions through code
no clue tbh
In an editor script possibly but that would be #↕️┃editor-extensions
and create
Do you ever tell it to stop ignoring collisions
You can talk about coding in #🏃┃animation
Ah, yeah #↕️┃editor-extensions may be best for this
In my Game you cant Attack while walking but if you try to it will happen right after you stopped running. Can I prevent that? I use a Trigger for this
Just did, nobody is replying :(
oh so the ignore thingie is pretty much a set and done type of thing
you literally asked 2 minutes ago
It's been 2 minutes?
Wait a day, and try again
Just asking because I'm trying to make his condition for my walking anim
disable Wait For Exit Time
Dude I have the patience and attention span, I'm just saying 💀💀
i think this is simple enough to find a tutorial about
So just make the parameter in the animator
you can just before the first if
if(!shotgunAnimator) return;
and get rid of that doubled if statements inside
But i think i need that because the Attack animaiton shoudlnt be canceled you know?
And if everyone stopped posting every fucking question in #💻┃code-beginner then maybe there'd be more people in other channels answering stuff
But I don't have the paramters tab, or the layers tab to be frank
How to count the direction of the perpendicular from hit point of ray?
Why're you blaming me tho
cuz you are one of them
Im not sure then what ur asking lol
I literally posted it in animation I just thought this could be relevant to code as well 💀
Wait I give you an Example
count ?
google first, ask second
I did...
what did you google
how to add parameter to animator in unity
literally first 5 links
I want that when te Player decides to Attack the Full Animation is played and you cannot cancel it with anything. I use a Trigger for that. The problem is while you run i diasbled it so the animation will not play while moving. BUT after you stop moving it works like a bufered attack and will come out after you stand still. I dont want that. I want to like deactivate the buffer.
I literally have the param it just doesn't recognize it
More screenshots if you'd like
how did you disable it while moving
Dude, the paramter is LITERALLY visible in the top right
You simply cant because there is no connection between attack and moving
It's late and I've been trying to figure out the problem for the past 20 minutes so I got frustrated
Thanks for pointing it out