#💻┃code-beginner
1 messages · Page 391 of 1
but lets start this on a simple track
I assume when the result changes like a bool changes from true to false or increases or decreases a int value. Unless I misunderstood it
how do i do that pressing anywhere on the screen it spawns an entity
bc idk even how to set that up
yeah you would need to do some position comparison from the WorldPos of mouse
what do i do with the velocity then
remember earlier they were telling you that ur planets axis should face the planet.. (thats being tidal locked) mine doesn't do that.. the transform doesn't rotate.. so i use the tangent to do that
Well, there's nothing in Unity called that, so you had to have found it somewhere. Wherever you found it probably mentions what it does
Well its a series of steps, break it down and start from the first step.
no I was using co routine and was hoering to see some of the options that I could use
do i still do forceadd or sm
whats the first step?
you set the velocity of the planet in start.. (that gives it its initial movement)
I just use waitforseconds so I wanted to nkow what else I could use
then gravity takes over.. and causes a perfect orbit
in start u can set the velocity directly
yea i just realised that
planet.velocity = velocity;
first step, getting press button event.
second step, getting world position of mouse
third step, spawn item with Instantiate at mouseworld pos
So you were looking for things that extend YieldInstruction and found this? Again, it's not Unity so if you found a script somewhere that defines it you're going to have to actually show it
and its flown off the screen
lmao... idk bro
could u be able to vc in like 30 mins? this over text just seems really complicated [this is my first attempt on making a game so yh]
u can find scripts already written if u having this much trouble
it sflying off the y axis
I assumed it was a unity thing I guess but maybe not I don't have a definition I thought it would work the way based of its name
so i think this means that value is just too big
seems ur number is going to 7 then back down to < 7
make the numbers bigger between or find a way to stabilize your move Velocity
or you hardcode their moveSpeed
I'm confused what I should use with co routine besides waitforseconds is there anything else of use ?
like wait for seconds is useful and all by I feel like there must be more to it
so would I just set public int speed = 0;
you find good free assets how do you do it lol
if ur calculations are correct in the start function it shouldn't matter what value u give it
im an asset junkie
i WILL remember that xd
It can use anything that extends YieldInstruction. Unity provides some of them:
https://docs.unity3d.com/ScriptReference/YieldInstruction.html
and you can make custom ones
You could yeah
Probably stabilizing the numbers is also an option
its doing something else now 😿
its like flickering in position
There's a few in the sidebar
sorry for wasting your time, how would I stabilise them? just change/double the values? tysm
for example clamping or rounding or similiar methods
to add on to digi's answer, you can also use yield return null; to wait until the next frame so you could have some loop that does something each frame instead of all in a single frame
oh and another thing.. when i was first learning I would reverse engineer assets to learn.. (to me its easier to see it done first) then try to build it up from scratch
can u share the entire code again
Yeah thats a good way to do, I myself try to make it first if I can so there is no seconds guessing to anything goes wrong I know its just my shitty code xD
yea but i think u took half of it and ignored the other half
{
Vector2 distanceVector = Planet1.transform.position - Planet2.transform.position;
float distance = distanceVector.magnitude;
float orbitalSpeed = Mathf.Sqrt((GravitationalConstant * rb1.mass) / distance);
Vector2 tangent = new Vector2(-distanceVector.y, distanceVector.x).normalized;
rb1.velocity = tangent * orbitalSpeed;
}
// Update is called once per frame
void FixedUpdate()
{
rb1 = Planet1.GetComponent<Rigidbody2D>();
rb2 = Planet2.GetComponent<Rigidbody2D>();
distanceX = (Planet2.transform.position.x - Planet1.transform.position.x);
distanceY = (Planet2.transform.position.y - Planet1.transform.position.y);
if (distanceX < 0){
distanceX = -distanceX;
}
if (distanceY < 0){
distanceY = -distanceY;
}
if (distanceY == 0){
forceY = 0;
} else {
forceY = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceY*distanceY));
}
if (distanceX == 0){
forceX = 0;
} else {
forceX = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceX*distanceX));
}
Vector2 dir = Planet2.transform.position - Planet1.transform.position;
totalForce = new Vector2(forceX, forceY);
Force = dir.normalized * Mathf.Sqrt(forceX*forceX + forceY*forceY);
rb1.AddForce(Force, ForceMode2D.Force);
}
}
ya see.. ur fixedupdate is jank
great.
this is my first time embarking on a project on my own
no tutorial or anythiong
so uhhhh
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
this code here.. try using it.. put it on a empty gameobject.. and assign ur two planets (the sun is the static one)
ya, thats fine.. thats how u learn
so every frame something new would happen
that's pre cool i guess
but WaitUntil could I use that and say something like destroy the player once the death animation is finished playing
sorry, could you point me in the direction of any sources? tysm
i've changed the valuse, to no avail
speed is staying at 7
but still jitterign
all you really need to know is that it is a way to represent a rotation using 4 dimensions. use the helper methods that allow you to use euler angles instead because those will be the angles you are more familiar with
what u see in the inspector
angles in degrees
u see the rotations in euler
but behind the scenes its using quaternions
exactly
x rotation, y rotation, z rotation
show the runtime values
what is the speed of agent magnitude
idk if blend tree has this, but check if you might have Transition To Self on
Where in the animation is this part of code triggered?
Its from the standard Unity Player Controller
```private void OnLand(AnimationEvent animationEvent)
{
if (animationEvent.animatorClipInfo.weight > 0.5f)
{
AudioSource.PlayClipAtPoint(LandingAudioClip, transform.TransformPoint(_controller.center), FootstepAudioVolume);
}
}```
!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.
its called OnLand event
its an animation event, on the animation clip
Well yeah I can read that, too.. but where can I find that animation event?
There is no animation clip called OnLand, and its a bunch of "Events?"
probably on the Landing animation ?
the clip isnt called OnLand
I said the event is called OnLand when you find it on the animation clip
inAir? JumpLand? Run_N_Land?
Isnt there some way to navigate to that? It feels super wrong "seaching" for..
double click animation clip from the animator
its probably JumpLand
doesn't hurt to also check RunNLand too
is right here
Ty! All Events get shown like that?
its probably on all 3 then
yeah , your animation window though is in Curve view for some reason though
normally its keyframes but yeah animation event is that white slice on the top
what does it do
Yeah changed that back.. however I can't open/edit the event, thats because its read only I assume?
Like the whole animation is read only, right?
yea , read only clips can be duplicated to be edited
Ah, tyvm!
np. dont forget to replace it in the animator with the new clones/clips
Hi I need some help I am trying to make a Warning Screen for my Game then for it to move to the next scene but keep getting this error message - CS0246: The type or namespace name 'IEnumerator' could not be found (are you missing a using directive or an assembly reference?)
`Code:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class IntroManager : MonoBehaviour
{
public Text warningText;
public float displayTime = 5.0f; // Time in seconds to display the message
public string nextSceneName = "boot.wsmsg.JP"; // Name of the next scene to load
void Start()
{
StartCoroutine(DisplayWarning());
}
IEnumerator DisplayWarning()
{
warningText.gameObject.SetActive(true); // Show the warning message
yield return new WaitForSeconds(displayTime); // Wait for the specified time
warningText.gameObject.SetActive(false); // Hide the warning message
LoadNextScene(); // Load the next scene
}
void LoadNextScene()
{
// Ensure the next scene is added to the build settings
SceneManager.LoadScene(boot.wsmsg.JP);
}
}`
!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.
also you need to configure your IDE
it should give you the option to add the namespace for IEnumerator
my ghosts are keeping the correct path, but are somewhat offset. why might that be the case?
they are are bigger than the hallways
oh wait no
its ur offset
that's what i thought
Set it to Visual Studio Code ill try find that option
nah you need to configure !vscode
its not configured
so i should add a value to all the ghost positions?
Go on and just ask
Ah I see
Thank you
well it looks like your grid isn't matching up
at least the paths aren't
thats still vague
what exactly you are stuck on
it seems like the paths are correct but just shifted no?
yeah
there is a strange offset
what have you already tried?
#854851968446365696 will show how to ask
We need details, including what you have done to try
it sometimes follows the correct path
but other times it just gets offset
its simple . just add Torrque
AddForce(Vector2.up * jumpHeight, ForceMode.Impulse
AddTorque( rotAngle* rotSpeed, ForceMode.Impulse
Boom here is your Jump flip
'Bird' AnimationEvent has no function name specified!
I don't understand what it wants from me, I don't want an event, all I want is an animation that loops infinitely
it means you have an empty Animation Event with no method assigned
oh god
is there a way to reset trails in code? every time i set a trail as non-emitting and set it as emitting again it leaves a big line from the old place to the new place its annoying
turn it off and on
i think thats how I had to do it
like enabled?
yea
well yeah Im showing you an example I never said copy and paste it
thats not how code works, you dont just paste and it magically works
Yes it does
GD doesn't use physics for rotation anyway, as it would mess up the gameplay
well it helps you see how simple it is to make your rotation jump thing
No one is going to just give you readymade code here
You need to take the directions and research them on your own
ah yeah you know what that makes sense
its been a while since I touched GD
too much reliance on physics it will prob not give the precise control
Really really bad idea
We are not going to be able to help you if you are unwilling to do research to supplement what we say
Doesn't have to be google specifically
basic c# isn't enough to read the API by yourself
you have to know the basics on how Unity Components work
What it most likely does is, while you're airborne rotate, and when you land rotate the icon so it snaps to the ground's orientation.
The airborne part is easy compared to the vector math you need to perform to align yourself with the ground
What's the best way to call a method when a value is minused by 1? Like, when value -1, do this
Would an IF statement work in that way?
Use a property or method to set the value. Call another method based on whatever conditions you want
If its public, you have 0 control over that
just wanted to say something for all us newbs......good job guys. keep at it. despite beating your head against a wall who knows how many times. you got this 😄
A property with a custom setter is the perfect case, it doesn't require you to use another variable that stores the previous value
I have the player health which is 10. Each time the player is hit, 1 point is minused. I want to shake the healthbar whenever the player is hit, but how can I detect whenever 1 value is minused from the total health?
I can't do if(playerhealth-1){..}
Did you skip over the responses above?
Do it in the method that reduces health. If you don't have one, create one. Or use a property
void Damage(int amount)
{
health -= amount;
ShakeBar();
}
This is part of why public variables are bad. You don't get to control stuff like this if random scripts can modify your health without your knowledge
Use a function
That's why it's advised to prefer properties to expose features outside of the class. You use a variable 100 times, and want to do something when you get or set the value? With the property, modify it in one place (in the class that declares said property). With a field, modify it 100 times (at each place you use the field)
Property - a method on roids xD
private int coolProp;
public event Action CoolValueUpdated;
public int MyCoolProp
{
get { return coolProp; }
set
{
if (coolProp != value)
{
coolProp = value;
CoolValueUpdated?.Invoke();
}
}
}```
One thing that they're missing is the ability to subscribe their accessor methods to events/delegates. Like it yells at you if you try
thing.OnValueChanged += myClass.Property.set;
I had to use a full method or lambda from time to time, to be able to do that
this would be godsent
I wanna know the position relative to a transform of a vector, how can i know that? the vector is not linked to any gameobject
InverseTransformPoint maybe ?
Vector3 pos = myTransform.InverseTransformPoint(someWorldPoint);
how do i change the color of the image component?
the property called color
make a reference to the component duh
Button.GetComponent<Image>().color; thats what ive done
Button.GetComponent<Image>().color = Color.red; or this but it doesnt owrk
it should, maybe you grabbed wrong image
or the image is black colored or something
mind you this is simply a TINT not actual coloring
kk
and how do i do that
Specify "doesn't work": are you getting an error, or is the color simply not changing?
it doesnt change
how do you know script is running that part of code
do what exactly? even if its a tint it should still be coloring/working so you got someting else wrong
First, that. Make sure the code is running
Then it most likely needs a sprite to be able to render properly, make sure you have assigned one (even if it's a 1x1 white pixel)
the code is working
im changing code that already works
how do i like change the RBG?
share the code
{
if (Money >= 20 && SpearBought == false)
{
SpearBought = true;
Money -= 20;
SpearButton.GetComponent<Image>().color = Color.red;
SpearButton.GetComponent<Button>().enabled = false;
}
}```
it works
so the button component gets disabled?
show which image you are trying to grab on SpearButton
Note that if there are multiple images, GetComponent will pick one in an order that cannot be determined in advance
so its working ?
no
gotcha
mhm
im only disableing the Button COMPONENT so i shoulod still be ablde to tweak the color
yes and you observed the Button Component actually disabling ?
Okay, and is this screenshot before or after that code runs?
something fishy going on
its just what it looks like when i run the code and what i should look like
after and what should look like
show me
So, this screenshot, was it take before or was it taken after the code you've shown was run
after some checking it does not turn off
after
wait no
im not running anything theere
So then this object is not the one you disabled
how can i check if the game is running? Application.receivedLogMessage or whatever seems to be running even when the editor isnt playing which i dont want
Then one of two things is happening:
- This code isn't running at all
- The object you are looking at is not
SpearButton
Maybe your script is referring to a prefab?
Update?
You can check both of these at once by logging SpearButton inside that function
i thin i might have to reinstall unity before my stuff corrups
my unity crashed i open it back up and now the code runs
var spearButtonImage = SpearBought.GetComponent<Image>();
Debug.Log($"Colo before change {spearButtonImage.color}");
spearButtonImage.color = Color.red;
Debug.Log($"Color after change {spearButtonImage.color}");```
so its working now?
was goinng to suggest you did this.. but if its working then ok
yeah but its working cause myt unity crashed sisnt that bad?
like wont that make it so theres now a risk of my project getting corrupted
its not working because Unity crashed, something else was probably wrong and you didnt notice
but i iddnt change anything
or idk
well when Unity crashes all UNSAVED scene changes get lost
oh
so you probably did something that broke it then got restored to normal
then prolly whilst debugging my sleepy ahh turned of the button comp
yeah touching unity/code tired is never a good time
And in the event you have corrupted the project, just restore it from your last Git commit. That assumes you have a repository for your project (even a local one, pointing to a folder on another drive).
Unity also stores things temporarily as long as you don't load your project again, it can be useful to restore things in case it goes south
Unity crashes have no control over your code though
even on a crash scripts dont get touched
they are just text files open inside a code editor..
no like i prolly didnt save the code tried it and didnt do crap it crashed then i checked on the code and as always i just saved cause i do that like every 30 seconds
only you can know what happen, at least it works 😄
you should probably be using Version Control, wont help with unsaved scene changes but you can "snapshot" your project so you can revert at anypoint or track code changes you're doing
When you use euler angles for a local rotation, it's pretty obvious how to limit rotation in different axes: you just clamp the euler angles (after normalizing them into the -180..180 range)
How can I clamp rotation in different directions when working with Quaternions?
I have a component that combines multiple rotation requests -- so many systems can say "please rotate this thing this much", and it combines those rotations together into a final rotation
I want to clamp the resulting rotation
I can use Quaternion.RotateTowards(Quaternion.identity, targetRotation, angleLimit) to limit the rotation angle
But I'd like to be able to clamp it in different directions, too
I'm not sure if the problem is well-defined in the first place...
maybe I should just turn the quaternion into euler angles and do the clamping there
So the directions you want to clamp are either global X, Y or Z? Not any arbitrary axis?
Not sure I would categorize this as #💻┃code-beginner, btw
It would be local axes.
that's why I'm thinking I might just clamp the euler angles after all 😁
yea, i seen Fen asking a question.. I knew it was gonna be serious
And you want it to be in the order which Unity applies euler angles: Z, X, Y?
and yeah, maybe this is more of a general problem after typing it out, haha
Today I Learned
I think that's what I want! Imagine animating a jaw bone:
- Basically zero roll (your jaw can't do that)
- A little yaw
- Lots of pitch
you're not going to clamp a Quaternion because you have no idea of the values to clamp to
null reference at line 24, whats wrong with this line?
what do you think
no clue
TankManager is not found
thanks
Ouch!
I think I need to play with this problem some more, actually. Now I'm not sure!
I will go mess with it.
i finally got it fixed
Something before a . is null. other isn't, or the error is on the line above. other.gameObject also isn't for the same reason. So, what's left that could be null?
someone already solved my problem
damm the second one gives me the creeps
And now you know how they were able to tell
mission accomplished
he moves too graceful for a skeleton its eery haa
does anyone know can’t i edit my script? I can open it but it’s like i can’t type in it
ya, i really gotta start animating myself.. mixamo animations stand out too much
are you looking at the preview in the inspector..?
show screenshot
you need to open the script file in a script editor
Have you tried cascaudaur ?
actually well just take it to DMS lmao
What is it open in
guys, ngl i don’t know. I’m learning it rn
well learning unity and everything so my bad 🙏
dam this visual studio is old
2019 old af
they have 2022 but anyway VS is getting scrapped in august
get VSCode configured
does having an azerty keyboard affect this?
you tell me
I've seperated the visuals from the logic, so the script is added to the player object, instead of the visual asset
but even when pressing "W" i still get the message "-"
oh dang, RIP Mac
I dont see how if the unicode would not be matched the the proper one
exactly my thought process haha
kind of odd
why would it? it's not like the W key is nonexistant on an azerty keyboard
ah, I think there's a setting for this
really?
interesting
will that allow me to edit it after ?
Project Settings -> Input Manager
Aha, thanks man! :^)
By default, the key codes really correspond to the physical keys on a QWERTY board
You should still be able to edit it regardless
wdym you can't edit it
you can literally edit it in textpad (dont) and it still works
(probably because you usually just care about the block of keys that are classically WASD + its neighbors)
Bit silly that it's implemented that way, but it works now
Hi there! I'm currently getting familiar with the new Input System and I've seen that the documentation isn't much clear regarding the keyboard layout...
thanks @swift crag :)!
np!
apparently its the physical location of the key, doesn't matter the character
learned sum new
i've never needed that before, but i happened to see that while digging around in the input manager at some point
thats balls
Time to buy a qwerty keyboard then haha
nah, u can just change around ur key scheme
should be able to see what gets outputted by using the Listen thing in the new input system window
look, idk if this helps
👻
lol fr..
seems like the program isnt even getting keyboard input
but mouse input is fine?
weird
I blame mac
i second that
or xamarin
I've never tried to use Xamarin Studio (which is what that actually is)
install VSCode and try that lol
since ur on mac i believe VSCode is a better option
now VSCode actually got good
my clueless ass even after cautioning dozens of people to not try to clamp euler angles: i bet i can clamp euler angles
(no dice)
the whole Omnisharp bullshit from before was annoying to deal with
okay okay like i knew i wasn’t going crazy, imma let yall know if i get it to work
yeah, it was a pain in the arse to configure
my suggestion is you configure it with VSCode follow this link
!vscode
VSCode has stolen my heart
I feel responsible 😦
still have both, but i only open Community on accident
as a mildly colorblind person, I hate how similar the logos are
on win is VS only.
on macos VSCode
and as someone who tries to use language to communicate, I hate how similar the names are too
As a not-colorblind person I still can't remember which one is which most of the time
VSCode VSCommunity
yeah microsoft fumbled the naming there
thats how i differientiate
Code Studio or some shit wouldve been better
Visual Studio
Atom 2
that still got VS in it 😦
The name of the "VS Code" product makes the title a little mis-leading. I thought the code for "Visual Studio" was open sourced. Turns out it's just this stripped down editor called "Visual Studio Code".
ElectroCode
haha whole thread dedicated to complaining bout the names
including the usual Orange Site takes
lol
VSCode is a secret plot to sell you on Azure
could be..
fk it, im going back to Sublime
speaking of VSCode.. fun-fact:
this is called the line number Gutter
that was a hell of a search
vscode designers
I had a somewhat similar problem a while ago. I needed to "decompose" a rotation into a pitch and yaw value, so that I could initialize my player input component based on where an entity was looking when you took control of it
^ thats a relateable problem
i had to do something similar when teleporting my player
Vector3 flattened = Vector3.ProjectOnPlane(entity.transform.forward, Vector3.up);
yaw = Vector3.SignedAngle(Vector3.forward, flattened, Vector3.up);
Vector3 rotated = Quaternion.AngleAxis(-yaw, Vector3.up) * entity.transform.forward;
pitch = Vector3.SignedAngle(Vector3.forward, rotated, Vector3.right);
I solved it like so.
Maybe I can do something a bit similar here
my camera would always stay locked to the cursor. even when the player rotated
If I can recover the different components of the rotation, I can clamp those properly
This doesn't calculate roll, but that's just the Z euler angle, innit
SignedAngle! woop woop.. i love that function
gizmo's and handles are ur friend
the next two lines were
they helped me tremendously when visualizing stuff like that
Debug.DrawRay(entity.transform.position, flattened, Color.red, 3f);
Debug.DrawRay(entity.transform.position, rotated, Color.green, 3f);
(:
hell ya
a useful little thing I wrote for this:
just watch out for closures capturing variables in ways you didn't expect...
int x = 1;
DebugDrawer.Instance.RequestAction(() => Gizmos.DrawSphere(Vector3.zero, x));
x = 5; // the sphere's radius is now 5
one error I just noticed is that this doesn't clear the action list if nothing asks for a gizmo on subsequent frames
that logic is necessary because I don't have an "early update" that can clean out the action list before anything else runs
perhaps I should figure out how to do that
You can only draw gizmos in OnDrawGizmos or OnDrawGizmosSelected
So you have to remember the data you want to use to draw the gizmo, and then implement OnDrawGizmos to draw it
true.. but u can queue up data to draw
This lets me just make an anonymous function and run it at the right time
obviously this produces an enormous amount of garbage (one anonymous function per request), but hey, it's editor code
does anyone know why my button doesnt have the
auto generate animatin button
im using the legacy butto
where do you see AutoGenerate Animation button from
like a tuturial
about how to animate ui
this is a code channel, perhaps you could try asking in a more appropriate channel
ohh i never seen this before
oh mb
it only appears if you have Animation selected for the transition type
actually i think i know what the issue is, that button disappears once you've added an animator to the object
ahh I see just noticed that, didnt think button had that built in, thats pretty cool
i usually just make my own buttons with Ipointer interface
Can anyone help me figure out how to make a raycast onto a world space canvas with a render texture then raycast to the equivlent point on the camera the render texture is coming from? So like if I click on a part of the render texture I get the position of what the mouse would be hitting if it wasn't a render texture?
ohhh
let me try
lol, this just blew my brain up
i think i know what u mean you..
Sorry I suck at describing things T_T
yeah Im having a brain fart understanding what you need here
w/e u hit on the render texture u want to transform that into what it would actually hit in the view of the camera doing the render texture
Yeah exactly
like a portal.. if u were raycasting into a portal.. u want the hit of w/e in that portal
sounds complicated
lots of math involved
you have to take texture coordinate of RT and somehow map it to screen
i have scripts that raycast into a 3d environment raycasting from the camera thru the cursor
but never had the render texture part involved
maybe theres some sort of work-around to simplify it so it isn't too math heavy
whats more confusing its a world canvas so that adds some complexity there too
oh yea no doubt
im not even sure how you'd go about that.. it'd just return the entire render texture as ur hit object
get the position of the hit within the rect in the rect's local coordinates, then it should be trivial to convert that to a viewport position for the desired camera
ud have to get a point.. and then evaluate that.. and then transfer that to the camera somehow (maybe the near clipping plane)
you have to raycast onto the canvas
RectTrasnformUtility might be helpful here
raycasting forward or something
nifty functions in there
I have a mouse spirte that follows the cursor but stays within the screen so maybe I can use it's position rather than the actual mouse's or a raycast onto the render texture...
ViewportPointToRay after iirc
er, but it can only go from a screen point to a point in the rectangle
so actually, you won't need that at all
raycast onto the plane of the image, then convert that world space position into the local space of the RectTransform for the image
I'd have to think about that for a bit
that'd give u a good coordinate to work with
Once you're in local space, you can figure out where you are in the rect of the RectTransform
i'd need more than thinking.. i'd need to set up a scene, b/c that'd def be a hands-on type of problem for me
whats the mechanic you're going here ?
seems cool
(the rect is defined in local space)
Is using ternary operator like this terrible practice or 5head practice?
public GameEvent PopEvent(QUEUE_TYPE type)
{
LinkedList<GameEvent> Queue = (type == QUEUE_TYPE.GAME) ? GameEventsQueue : (type == QUEUE_TYPE.BEGIN) ? BeginTurnQueue : (type == QUEUE_TYPE.END) ? EndTurnQueue : null;
if (Queue == null)
{
throw new Exception("Wrong QUEUE_TYPE exception at EnqueueEvent()");
}
GameEvent Event = GameEventsQueue.First.Value;
Queue.RemoveFirst();
UpdateActions();
return Event;
}
Too complicated
if u can read em
I don't know what that does
yeah thats wild
I'd have to roleplay as a C# compiler to parse that correctly
readibility is more important than syntax sugar
that's not syntax sugar
i did a 2 nest and found that atrocious , 3 is just wild looking
that's syntax poison
Just do a switch expression, actually
That'll make it look really nice
yea i agree.. a switch for this
Placing turrets. It's a tower defence game but a lot of it takes place on an in world monitor and then there's fps bits if some enemies slip through
I have 3 queues on my EventsQueue and I want a general Dnqueue() and Dequeue() methods to operatoe over all of them
Syntactic sugar ||in the gas tank||
Instead of making 9 methods
LinkedList<GameEvent> queue = type switch {
QUEUE_TYPE.GAME => GameEventsQueue,
QUEUE_TYPE.BEGIN => BeginTurnQueue,
QUEUE_TYPE.END => EndTurnQueue,
_ => null;
};
this was once a BIG ternary
nicee
people hated on it so now its a switch lol
depends how many ig, sometimes is easier just do a dictionary
sounds good, thx
Or should i just do 9 methods? xD
9 methods makes it simple just witha LOT OF METHODS
Still not optimal. Use an array
ohh i need to do the => to return
dictionary perhaps? or array
Array
i trust steve, i trust navarone too 👇
array is always more efficent than dict
Remember that enums are just ints
If you don't assign them, they're in order starting at 0
fun fact but you could make this look even better using a switch expression
public static Vector3 GetDirection(Direction directon) =>
direction switch
{
Direction.North => Vector3.forward,
Direction.West => Vector3.right,
//etc
_ => Vector3.zero
};
Oh I actually looked at the mouse script since it's been a while since I made it and maybe this screen to local point in rectangle could work even better than viewport point to ray...
Vector3[] array
return array[(int)direction]'
So you could literally just cast the enum to an int and index into the array
ya, thats what i was seeing earlier.. it wasnt until a few weeks ago i realized that => returns values
ive used em to trigger void return functions
but never a return.. and once i realized (game changer)
thats soo hard to read..
lol, no hate just saying
Alright. This is my first time using if and else statements. What am I doing wrong? Even when the player score is equal to or greater than 100 it still logs the else response. ``` public void buttonPressed()
{
if (playerScore >= 100)
{
Debug.Log("Button pressed successfully!");
}
else
{
Debug.Log("You need more coins!");
}
} ```
are u reading the correct playerScore?
static Vector3[] array { Vector3.forward. Vector3.right }
public static Vector3 GetDirection(Direction directon) =>
return array[(int)direction];
who needs a switch ?
are you sure you're logging/saving correct playeScore
it shouldnt else unless its less than 100
debug the player score in ur conditions
and see if its what u expect it should be
where do you add playerScore
big ass 🧠
This is how the player score is calculated:
public void OnClick(InputAction.CallbackContext context)
{
if (!context.started) return;
var rayHit = Physics2D.GetRayIntersection(_mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue()));
if (!rayHit.collider) return;
{
playerScore = playerScore + scoreToAdd;
scoreText.text = playerScore.ToString();
Debug.Log("Point added");
}
Debug.Log("Clicked");
}```
Note that score to add is one
It displays correctly in my text
ok so the other code is in another script?
mmhmm
Yes
then you have 2 copies
you need a reference to this score on this script
ur setting ur text and stuff w/ this one
I think I get it
if you have two boxes, both have apples... If I eat apples in the first box, will the apples in second box be affected?
that is in taht script.. only that script
just because u have another variable called the same thing in the other script.. they're not the same
they wont just copy their values over..
you should use 1
and jsut refernece it from one script or the other
so ur only comparing (1) value.. from (1) variable
in b4 the "whats references"
https://unity.huh.how/references
Yeah I get it. I'm fixing it. The updated score is now a different thing
Thank you! We will see if it works now
hi! im currently doing this course on udemy and these lines of code arent working, they are supposed to pull the character name from my charStats script and put it onto the text box in the ui menu but it just flatout does not work, even though it worked in the video
for (int i = 0; i < statusButtons.Length; i++)
{
statusButtons[i].SetActive(playerStats[i].gameObject.activeInHierarchy);
statusButtons[i].GetComponentInChildren<Text>().text = playerStats[i].charName;
}
well did you check console for errors/script is running
there are two parts to that question
can you screenshot the console in playmode when its supposed to change text
you sure that should be Text not TMP_Text?
that would def throw a nullref
This is using the legacy text
did you use legacy text in your UI
Yes
I bet the script isn't running at all then lol
or have errors collapsed
or statusButtons is empty
Nope no error collapsed
maybe its just not running?
i dont understand why that would be the case though
put a log and find out
Debug log info
and did you fill up statusButtons array?
Even when you think you know the answer 100% you still are suppose to doubt it.
never assume till you got sum concrete numbers
Hey one thing that just striked me
Alright
Should it be the classes responsability to pass its methods the data they need or should it be the methods responsability to already know that at call?
yes, I am at the hospital 🤒
Having to do Stage 2 CPR to survive
IT's horriblee
Tell my mom
Spagheti is great
wdym by "responsibility to already know that at call?"
I OOP words, should I give my methods a parameter or should that parameter be a class property?
so you mean should you change a value via property or a method?
Are you asking about the distinction between..
When i try to put a debug log into the script it comes up with CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement Assembly-CSharp
they are the same thing, well almost
Ok I've tried to fix this an it's a disaster. I'm lost
foo.x = 1;
foo.y = 2;
foo.DoThingWithXAndY();
vs.
foo.DoThing(1, 2);
Data stored in an object should represent some kind of meanignful state
i prefer methods
It depends. Class members can be accessed from the method, so you don't need to pass them into the method. Everything else does need to be passed in.
as long as its property they're both valid though
The point of function parameters is that they're specific to that invocation of the function
I would not do the first example if the only point of x and y was to be used in that method
There's no point to storing x and y
Sounds like a syntax error🤷♂️
Share the code
You're polluting the type with random fields that have no purpose outside of a single method
Like the whole thing?
at least the malfunctioning line..
At least the thing that errors
@rich adder So basically I tried to set playerScore = playerScoreUpdated and then use playerScoreUpdated in the if else statement. Apparently you can't do that. I'm kinda stuck now
Got it, so in the case of a player turn variable, it should be a property then
Thanks for the responses, people!
note that property has a specific meaning in C#
how did you get that from what was said lol
for (int i = 0; i < statusButtons.Length; i++)
{
statusButtons[i].SetActive(playerStats[i].gameObject.activeInHierarchy);
statusButtons[i].GetComponentInChildren<Text>().text = playerStats[i].charName;
}
I'd assume that your ide is also not configured correctly. Can you take a screenshot of the whole code window?
Debug.Log appears nowhere in here.
if you're storing the score in one class. You need to grab that particular score..
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
because i removed it lol
...why?
dont
aren't you asking about that?
My interpretation was that I needed a second variable because I couldn't use that one in two different spots to achieve what I wanted
never remove logs until everything is fully working
Well, we can't help you with it then, can we?
more pertinently, don't delete the part that you're having a problem with...
why couldn't you ? thats the whole point of a player score.. to be shared across scripts with the same value
I don't know. I'm just telling you what I thought I read.
if your score is 12,
your other score in that script is 0
Mhm
Debug.Log;
This is an invalid statement.
You need to actually invoke that method and pass it an argument
nahh. We said simply make a REFERENCE to the script with the score from the one you are trying to do Buy with or whatever ur doing with score >100
I guess your ide is not configured correctly. Take a screenshot of it.
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
playerScore = 10; // <-- this is playerscore of one script
theOtherScript.playerScore; <-- this references the playerScore from that script..
both will debug 10
I was already referencing that score though
its basically the same variable
no you didn't you made a separate copy
I said example before with boxes and apples..
just because they both have apples, doesnt mean eating apples from one box affects other apples
post both scripts !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.
exactly..
one is thisScript.apples;
the other one is thatScript.apples;
naming things the same variable name in separate scripts, does not connect them whatsoever
they belong to different classes
could you imagine if variable names were global 
C# would be utterly useless if fields with the same name were linked
fr
oh god, the horror . . . 😱
it'd be a heck of a challenge
float IhaveRanOutOfNames = 2;
you'd have to do some crazy code gen
I thought that public linked them
Am I missing something big here?
no public just means it can be accessed from elsewhere
That sounds like the same thing
Absolutely not.
its not because it doesnt make it global
public means that any type can see that member
public means the field (variable) can be accessed from outside of the script . . .
does anyone know why when i use a code and copy it perfectly it has an expected error every time.
If you have an instance of Foo, and bar is a public member of Foo, you're allowed to see bar
Here's how you should think about the variable real name. It's namespace.class.variableName.
show us the original, then show us yours . . .
It sounds like you have a very severe misunderstanding of how C# works
what is the error?
how can we possibly know otherwise
see... these are different variables
Public is an accessor, not some linker of multiple instances.
Ah. So it just allows you to use that variable but that doesn't mean that those variables are linked
yes, u have to reference the variable from its class
theClassYouWant.theVariableyouWant;
or method
or any other type that supports access modifiers
(any member)
You'd reference the object instance and access that object's member.
you're not allowed to use it; you are able to access that variable from a different script. each script in Unity is a separate class. you need to reference an instance of that class in order to access public variables—or other members . . .
public InputHandler inputHandler; // Reference to the InputHandler instance
public void ButtonPressed()
{
if (inputHandler.playerScore >= 100) // Access playerScore through the reference
{
Debug.Log("Button pressed successfully!");
}
else
{
Debug.Log("You need more coins!");
}
}``` @bleak glacier
u want to reference your InputHandler.. and then . its variable
ohhhhhh
no need for that one in that button script
❤️
Thank you. I'm still learning so thanks for getting me through this. I didn't know I could do that. That opens possibilities.
very much so
ofc u gotta assign the reference.. in my example im telling it that i want a variable of type InputHandler
but i dont tell it which one..
since its public you can drag the gameobject w/ that class str8 into the component of the other
dam forgot c# only does private on nested classes, interesting
nope looks all fine to me
screenshot it
he must be from Missouri
this channel has ruined us.. (hey i did X, Y, and Z) [show me.. i dont believe you]
screenshot what?
the ide
Your ide, including the solution explorer preferably (assuming this is vs).
the what explorer
sorry im getting so confused
Are you using visual studio?
yes
Well, it is what shows you the files.
But just screenshot the whole thing. We will be able to tell
if you see Miscellaneous Files its not working
i do not see that
well there should be soemthing there..
Just screenshot the editor

guya, i got it to work now. Thanks for all your help
It is configured
Ok, so you do see the red underline
Debug.Log is not a thing
Debug.Log() is
oooooh
yes i did
it requires a parameter
And you likely want to... actually log something
i tried telling everyone that before
methods use ()
now its saying no overload for method "Log" takes 0 arguments
People tell us that all day every day
also what
it requires something in the ()
you have your own Debug class? what is even happening in this SS
what are u expecting it to log? without it
Because usually, when you see it, you know how to fix it. And/or the ide would suggest you the correct syntax and you would auto complete it.
idk man im just following this course ghaha
the course sucks, clearly its not doing its job properly
If the course wrote that, find a different one
did you look at the method in the Unity docs? it explains what it does and has examples for how to use it . . .
Udemy courses are dogshit
i have not
wouldn't that be the first thing to do if you don't understand it?
It should always be step one
- watching the world burn
learning how to write a Debug.Log should've been one of the first lines you learn to write.. Its on par with Console.Write line in c#
idk man this is my first week of scripting
yaya doesn't count when you know what you're doing 😛
Debug.Log("A Custom Message");
Debug.Log(aVariable);
All the paid course are lol
Oop, sorry spawn
^ the first things u shoulda learned
In someone's experienced position how hard is procedural generation with something like tile sets with only a few rules
i dont have a Udemy course.. ur good
check out the unity blogpost about it
https://web.archive.org/web/20230914230942/https://blog.unity.com/engine-platform/procedural-patterns-you-can-use-with-tilemaps-part-1
idk what happen to the old link on the website
I meant about cutting off your pointing haha
lmao it happens all the time
but this has nothing to do with scripting. that's how you search and learn stuff. don't you google/search things you don't know or understand? that's all we're saying . . .
i tried
but it all came up with irrelevant things to the problem i was having
"Unity debug.log" is what I would search. Then find the one that says it is from unity
Scripting or manual. I don't remember a manual page for it, just debugging in general. But unity has those two things for many subjects
what your hunting for + unity always returns decent results
if it doesn't ur bout to make ur own stuff
you dont always find something specific to your problem you have to learn how to break them into smaller more generic easy to solve ones
To start you off, here you go
https://docs.unity3d.com/ScriptReference/Debug.Log.html
Look at the example code and compare it with yours
probably is old code, or they didnt wanna confuse people who actually need the examples
yea unity confuse people ? never..
makes sense
they leave it to the C# docs for that stuff i guess
string interpolation for 1 var is no biggie
($@"TheBestKind");
verbatim
learned that once i started debugging file names..
got tired of escaping all the brackets and slashes
i was testing my code and running the unity project, but it suddenly just closed unity when i didnt save my scene. the scene isn't updated, is there a way to fix this or do i hv to start again
its also a must when doing urls with params
if you arleady opened unity since crash ur screwed
not sure if u can recover it or not.. most likely not
dont reopen your unity, unity has temp scenes if you ran it. google where to find it
^ there ya go
RIP
you're boned
i didnt run tho-
doesn't matter
wow
as soon as u opened it it rebuilt everything
fricking hell.
improve your ctrl + s game
no joke ^ make that muscle memory
im not sure why unity even deletes the temp scene, they really could just keep one around for your last ran scene
make it happen so often u actually screw up by saving things u dont want to 😄
its better than not saving things u shoudlda
literally every app does it..or stores at as .bak
or some shit
yeah typical unity things
simple shit we have to make cause devs were thinking " whatever lol this app wont ever crash"
wonder why it crashed in the first place
infinite loops perhaps
sucks to have to rebuild it but on the bright side of things u'll probably be able to recreate it in half the time
if not less
usually w/ better structure
is there rlly no way to fix it
in the future, save your scene
This was the ticket.
I just added an extra few lines to calculate a roll as well
I can now recover the original X/Y/Z euler angles from a rotation
Vector3 forward = request.localRotationOffset * Vector3.forward;
Vector3 up = request.localRotationOffset * Vector3.up;
Vector3 flattened = Vector3.ProjectOnPlane(forward, Vector3.up);
yaw = Vector3.SignedAngle(Vector3.forward, flattened, Vector3.up);
Vector3 slewed = Quaternion.AngleAxis(-yaw, Vector3.up) * forward;
pitch = Vector3.SignedAngle(Vector3.forward, slewed, Vector3.right);
Vector3 tilted = Quaternion.AngleAxis(-pitch, Vector3.right) * Quaternion.AngleAxis(-yaw, Vector3.up) * up;
roll = Vector3.SignedAngle(Vector3.up, tilted, Vector3.forward);
yaw = yLimits.Clamp(yaw);
pitch = xLimits.Clamp(pitch);
roll = zLimits.Clamp(roll);
request.localRotationOffset = Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(pitch, Vector3.right) * Quaternion.AngleAxis(roll, Vector3.forward);
thats intense
It computes a yaw, then uses that to compute a pitch, then uses both of them to compute a roll
pretty snazzy
you never did mention what this was for..
is that because of NDA stuff? lol
i been trying to use context clues this entire time.. but i got nothing (seen u mention how a jaw works)
the jaw is an actual example
i'm combining multiple sources to get a local rotation and local scale for a transform
oh okay.
i need to enforce some limits on the resulting rotation
so that, say, a character's mouth doesn't flip 180 degrees if they are yelling loudly and also get hurt
yea, i see.. seems like u got a good handle on it
I did some reading and I actually discovered [SerializeField] InputHandler inputHandler; I then just connected the script to the same game object and dragged in the script.
oops, it malfunctions at some angles
time to poke at this some more
lol. Yeah that might have happened. You gave me enough info to be able to go looking for what I needed though. Thank you!
np mate 👍
yeah, just make sure you understand what SerializeField does . . .
It allows variables to be accessed in the inspector right?
it allows private variables to be accessed in the inspector
If a field is serialized by Unity, it is saved as part of scene/prefab data and gets shown in the inspector.
public fields are serialized by default
public variables are already accessible.. and static variables can't be serialized
other fields must have the SerializeField attribute added
it was ill-defined
if you combine four Quaternion.AngleAxis(90, Vector3.forward), you get Quaternion.identity again (since you did a full 360 spin around one axis)
But I want to clamp this so that it just stops at a 45 degree rotation around the Z axis (or whatever my limit is)
Quaternions are actually the wrong choice for this
how to avoid ui interaction when the cursor is set to not visible? I tried using CursorLockMode.Locked but it auto centers my cursor position
maybe disable the event system object?
or turn off raycast on canvas raycaster
^ two solid solutions
loop through all interactables and set interact to false 😬 /s
Will it disable all ui interaction? For example if cursor is set to not visible, then I want to use movement key for interaction
then you might just want to turn off raycaster I think
What's input movement have to do with ui interaction?
ig navigating through the buttons wasd
what does nullreferenceexception mean
You are trying to access something that does not exist
The thing you may WANT to access could exist, but the reference is currently null, because you did not assign the reference properly (or at all)
Hello. I am working on a 2D game. At the moment I am working on the enemy to move towords the player. Which I am trying to do by using the "MoveTowords" function. But since I am instantiating the enemy when the game starts I can't assign the player as the target. It doesn't work. So I tried to turn the player into an asset and tried it. But when I move the player the enemies don't follow it because the player asset isn't updating. Can someone please recomend me a way to fix this problem. (how to make the enemy follow the player?)
this is the error
Ok. Well, the reason is what I said
i tried debug.log at those spots
Look at GameManager line 82
but it didn't help me locate
Not much I can say without seeing the code
pass a reference to the enemies when you spawn them
google is your friend: https://docs.unity3d.com/Manual/NullReferenceException.html
Then that could be null too/instead
Not great naming honestly. Throught it was a bool at first
you need to check every reference variable on that line . . .
im assuming that'll just be all the ghosts?
What?
lemme check that rq
any variable that is a reference type can be null. you need to check if each one is null right before the error line . . .
You mean somehow update the position of the player inside the player asset?
what? no. have whatever spawns your enemies hold a reference to the player. then when it spawns an enemy make it pass the reference to the enemy
in regards to the link i sent, the enemy is the "prefab asset" and the player is the "in-scene component"
var instance = Instantiate(prefab);
instance.player = player;```
is there any reason that Cursor.visible = false; would not be working? Im literally logging its value, its false, and I still see my cursor. Workaround?
have you clicked into the game view window?
private void OnCollisionEnter2D(Collision2D collision)
{
GameObject obj = collision.gameObject;
if (obj.CompareTag("Player"))
{
Debug.Log("asdlkfja");
if (this.ghost_eatable == true)
{
gameManager.GhostEaten(this);
}
else
{
gameManager.PlayerEaten();
}
}
}
this logic for collision doesn't seem to work. is it a problem of my collider components or a problem w my code?
yes
make sure that your objects are set up correctly https://unity.huh.how/physics-messages/2d-physics-messages
I'll try that. Thanks @ivory bobcat & @slender nymph
could it be an issue with the new input system? I am (attempting) to make it invisible/visible onControlsChanged
what objects? 😅
the objects involved in the collision obviously
place a log at the top of the method to make sure the collision occurs. also, you don't need to store the GameObject in a separate variable. just use it with CompareTag . . .
nah, that shouldn't be it. have you confirmed nothing else is changing the visibility anywhere?
ha
right
💀
yeah nothing that I am calling anyway, its the only place I even mention Cursor
sure, but have you actually done anything to confirm that nothing else is changing it
no collision occurs apparently
it very well could be which is why i asked if you actually did anything to confirm it.
Debug.Log(collision.gameObject.tag); didn't output anything
what kind of test are you referring to
now do as boxfriend suggested and make sure the objects (involved in the collision) are set up correctly . . .
a log in any other frame besides the one you change the setting in
oh haha i put istrigger for collider
is this the place that I ask for help with a bugged script?
this is where you can ask for help with your code, yes
yep, its very weird
it just worked for one runtime and then when I ran it again it was no longer working
so is the setting being changed?
I'm working on trying to implement gravity, and if the character jumps I dont want it to pull him down with the negative (Gravitational force) so its supposed to stop sending inputs, but it isn't and still sends them
!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.
and i'll be more specific when i ask this again, are you certain you have clicked into the game view window. and by that i mean clicked anywhere inside the game view window after entering play mode because the editor does not capture the mouse for the game view until you have physically clicked your mouse inside that window
god im such an idiot
no way ive been sitting here trying to figure out why it works half the time
was that directed at me?
Im brand new and dont know how to use that
did you read it?
thank you boxfriend
using System.Collections.Generic;
using UnityEngine;
public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 playerVelocity;
private bool isGrounded;
public float speed = 5f;
public float gravity = -9.8f;
// Start is called before the first frame update
void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
isGrounded = controller.isGrounded;
}
//recieve the inputs for InputManager.cs and apply them to charactercontroller.
public void ProcessMove(Vector2 input)
{
Vector3 moveDirection = Vector3.zero;
moveDirection.x = input.x;
moveDirection.z = input.y;
controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
playerVelocity.y += gravity * Time.deltaTime;
if (isGrounded && playerVelocity.y < 0)
playerVelocity.y = -2f;
controller.Move(playerVelocity * Time.deltaTime);
Debug.Log(playerVelocity.y);
}
}```
I think I did it wrong
make a linebreak after the cs part.. start the code on a new line
It's close enough. But yeah, what spawn said
it is close enuff tho.. we got the idea
To be clear, you want input disabled when jumping?
I want it to stop sending the gravity number to the console
then remove the debug.log call at the end of ProcessMove
ezpz
That is what you called a bug? Just to be clear, that was all that you wanted?
if you only want that log to print while you are falling, then you need to use an if statement
Could be an else specifically. Since you are already doing the if isGrounded check
you could be accelerating upwards and not grounded
technically they'd need an else if, they'd still want to ensure the y velocity is negative
Fair fair
okay basically i want to make it so if you jump, or you're in the air you can't really change your velocity direction as easily oppose to if you're on the ground.
like, if you're in the air being propelled one way, you can't immediately move the opposite direction.
I'm using the move(); method to control my character. How in the world can I get this working if I can't even edit the method? and is there like a tutorial or something I could find on it somewhere?
I use 2 input schemes.. 1 for grounded and 1 for airborne
then add them together before passing them into Move
airVector = Vector3.Lerp(airVector, airVector + airControlVector, playerSettings.airControlStrength * Time.deltaTime);
groundVector = Vector3.Lerp(groundVector, Vector3.zero, playerSettings.momentumDampingSpeed * Time.deltaTime);```
then ofc I dampen them @ different rates
Ever since I took that coding course I'm not even done I'm like 46% done but I can semi reas code now
should I be modifying this somewhere or did you have to make a second custom move method?
also I really appreciate it man i've been thinking about how to do this forever
basically I watched many different videos and read different articles.. and pieced it together.. it was abunch of trial and error
thats what this is.. i add the vectors together.. and then pass 1 vector finalVector into the Move() function
i use inputs -> add em together -> pass into move function
the inputs are dependent on whether im grounded or airborne..
this means when im getting ground input im ignoring air input.. and vice versa and both of em are being dampened independently.. soo my Momentum while grounded slows down alot faster than my Momentum while in the air
if Im running and jump and then press backwards, since they're both added.. i have to cancel out the forward movement before i start going backwards
how to change from a scene to another scene in unity 2d?
you tried typing that into 
Make youtube the third (at least) thing you try. First is googling and looking at the docs. Then googling looking at forums like the link above.
That will get you very far
okay thx for the tip
hey what does ++ do? as in "for(i=0; i<5; i++)"