#💻┃code-beginner

1 messages · Page 391 of 1

polar acorn
#

What is WaitForChangedResult?

hoary light
#

but lets start this on a simple track

timid oriole
lethal swallow
#

mb, didnt realise

hoary light
#

how do i do that pressing anywhere on the screen it spawns an entity

#

bc idk even how to set that up

rich adder
#

yeah you would need to do some position comparison from the WorldPos of mouse

hollow forum
#

what do i do with the velocity then

rocky canyon
#

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

polar acorn
rich adder
timid oriole
rocky canyon
timid oriole
#

I just use waitforseconds so I wanted to nkow what else I could use

rocky canyon
#

then gravity takes over.. and causes a perfect orbit

rocky canyon
hollow forum
#

yea i just realised that

rocky canyon
#

planet.velocity = velocity;

rich adder
# hoary light whats the first step?

first step, getting press button event.
second step, getting world position of mouse
third step, spawn item with Instantiate at mouseworld pos

polar acorn
hollow forum
rocky canyon
#

lmao... idk bro

hoary light
rocky canyon
#

u can find scripts already written if u having this much trouble

hollow forum
#

it sflying off the y axis

timid oriole
hollow forum
#

so i think this means that value is just too big

rich adder
# lethal swallow

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

timid oriole
#

like wait for seconds is useful and all by I feel like there must be more to it

lethal swallow
rich adder
rocky canyon
#

if ur calculations are correct in the start function it shouldn't matter what value u give it

rocky canyon
lethal swallow
polar acorn
#

and you can make custom ones

rich adder
hollow forum
#

its like flickering in position

polar acorn
#

There's a few in the sidebar

lethal swallow
rich adder
slender nymph
rocky canyon
hollow forum
#

i made no changes to your code

rocky canyon
#

can u share the entire code again

rich adder
rocky canyon
#

yea but i think u took half of it and ignored the other half

hollow forum
#
    {
        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);
    }

}
rocky canyon
#

ya see.. ur fixedupdate is jank

hollow forum
#

great.

#

this is my first time embarking on a project on my own

#

no tutorial or anythiong

#

so uhhhh

rocky canyon
#

this code here.. try using it.. put it on a empty gameobject.. and assign ur two planets (the sun is the static one)

rocky canyon
timid oriole
#

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

lethal swallow
#

i've changed the valuse, to no avail

#

speed is staying at 7

#

but still jitterign

rocky canyon
#

Rotations

#

Quaternions are complex

slender nymph
#

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

rocky canyon
#

what u see in the inspector

slender nymph
#

angles in degrees

rocky canyon
#

u see the rotations in euler

#

but behind the scenes its using quaternions

#

exactly

#

x rotation, y rotation, z rotation

rich adder
#

what is the speed of agent magnitude

#

idk if blend tree has this, but check if you might have Transition To Self on

vast sandal
#

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);
        }
    }```
eternal falconBOT
vast sandal
# rich adder its called OnLand event

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?"

rich adder
#

the clip isnt called OnLand

#

I said the event is called OnLand when you find it on the animation clip

vast sandal
rich adder
#

its probably JumpLand

#

doesn't hurt to also check RunNLand too

vast sandal
rich adder
#

is right here

vast sandal
vast sandal
rich adder
#

its probably on all 3 then

rich adder
#

normally its keyframes but yeah animation event is that white slice on the top

hollow forum
vast sandal
rich adder
vast sandal
rich adder
#

np. dont forget to replace it in the animator with the new clones/clips

rocky canyon
#

does exactly what ur trying to do

little moat
#

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);
}

}`

eternal falconBOT
rich adder
#

also you need to configure your IDE

#

it should give you the option to add the namespace for IEnumerator

whole parcel
rich adder
#

oh wait no

#

its ur offset

whole parcel
little moat
rich adder
#

its not configured

whole parcel
#

so i should add a value to all the ghost positions?

summer stump
#

Go on and just ask

little moat
rich adder
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

little moat
rich adder
#

at least the paths aren't

#

thats still vague

#

what exactly you are stuck on

whole parcel
rich adder
#

there is a strange offset

whole parcel
#

i agree

#

how to fix

#

🤔

spare mountain
#

what have you already tried?

summer stump
whole parcel
#

but other times it just gets offset

rich adder
#

its simple . just add Torrque

whole parcel
#

google

rich adder
#

AddForce(Vector2.up * jumpHeight, ForceMode.Impulse
AddTorque( rotAngle* rotSpeed, ForceMode.Impulse
Boom here is your Jump flip

abstract oyster
#

'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

rich adder
abstract oyster
#

oh god

stuck palm
#

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

rich adder
#

i think thats how I had to do it

stuck palm
rich adder
#

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

summer stump
#

Yes it does

short hazel
#

GD doesn't use physics for rotation anyway, as it would mess up the gameplay

rich adder
#

well it helps you see how simple it is to make your rotation jump thing

summer stump
#

No one is going to just give you readymade code here
You need to take the directions and research them on your own

rich adder
#

its been a while since I touched GD

#

too much reliance on physics it will prob not give the precise control

summer stump
#

Really really bad idea

rich adder
#

start with unity learn courses first

#

get the fundamentals then make your chosen game

summer stump
#

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

rich adder
#

basic c# isn't enough to read the API by yourself
you have to know the basics on how Unity Components work

short hazel
#

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

west sonnet
#

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?

eternal needle
#

If its public, you have 0 control over that

stark marsh
#

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 😄

short hazel
#

A property with a custom setter is the perfect case, it doesn't require you to use another variable that stores the previous value

west sonnet
#

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){..}

eternal needle
#

Did you skip over the responses above?

short hazel
#

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();
}
wintry quarry
#

Use a function

short hazel
#

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)

rich adder
#

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();
         }
     }
 }```
short hazel
#

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

fallen apex
#

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

rich adder
#

InverseTransformPoint maybe ?

fallen apex
#

i will try that

#

thanks

rich adder
#

Vector3 pos = myTransform.InverseTransformPoint(someWorldPoint);

strong wren
#

how do i change the color of the image component?

rich adder
#

make a reference to the component duh

strong wren
#

Button.GetComponent<Image>().color; thats what ive done

#

Button.GetComponent<Image>().color = Color.red; or this but it doesnt owrk

rich adder
#

or the image is black colored or something

#

mind you this is simply a TINT not actual coloring

strong wren
#

and how do i do that

short hazel
#

Specify "doesn't work": are you getting an error, or is the color simply not changing?

rich adder
#

how do you know script is running that part of code

rich adder
short hazel
#

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)

strong wren
#

im changing code that already works

#

how do i like change the RBG?

rich adder
strong wren
# rich adder 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

rich adder
strong wren
#

yes

#

its a 1 time uise button

rich adder
#

show which image you are trying to grab on SpearButton

strong wren
short hazel
#

Note that if there are multiple images, GetComponent will pick one in an order that cannot be determined in advance

rich adder
strong wren
rich adder
#

wdym no

#

its red

strong wren
#

the red one is an exmaple is what it should look like

#

its an example

rich adder
#

gotcha

strong wren
#

mhm

rich adder
#

like the object itself

strong wren
#

im only disableing the Button COMPONENT so i shoulod still be ablde to tweak the color

rich adder
#

yes and you observed the Button Component actually disabling ?

polar acorn
# strong wren

Okay, and is this screenshot before or after that code runs?

rich adder
#

something fishy going on

polar acorn
#

Then what is it

strong wren
#

its just what it looks like when i run the code and what i should look like

#

after and what should look like

rich adder
polar acorn
# strong wren

So, this screenshot, was it take before or was it taken after the code you've shown was run

strong wren
strong wren
#

im not running anything theere

polar acorn
stuck palm
#

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

polar acorn
short hazel
#

Maybe your script is referring to a prefab?

polar acorn
#

You can check both of these at once by logging SpearButton inside that function

strong wren
#

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

rich adder
#
          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
strong wren
#

like wont that make it so theres now a risk of my project getting corrupted

rich adder
strong wren
#

or idk

rich adder
strong wren
#

oh

rich adder
#

so you probably did something that broke it then got restored to normal

strong wren
#

then prolly whilst debugging my sleepy ahh turned of the button comp

rich adder
#

yeah touching unity/code tired is never a good time

strong wren
#

i tihk i know what happened

#

i think i didnt save the code 😭

short hazel
#

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

rich adder
#

even on a crash scripts dont get touched

#

they are just text files open inside a code editor..

strong wren
rich adder
#

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

swift crag
#

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

brave compass
swift crag
#

that's why I'm thinking I might just clamp the euler angles after all 😁

rocky canyon
#

yea, i seen Fen asking a question.. I knew it was gonna be serious

rich adder
#

lol

brave compass
swift crag
swift crag
languid spire
#

you're not going to clamp a Quaternion because you have no idea of the values to clamp to

celest holly
#

null reference at line 24, whats wrong with this line?

rich adder
celest holly
#

no clue

rich adder
#

TankManager is not found

celest holly
#

thanks

rich adder
swift crag
#

I will go mess with it.

rocky canyon
polar acorn
celest holly
rich adder
polar acorn
rocky canyon
rich adder
#

he moves too graceful for a skeleton its eery haa

cunning silo
#

does anyone know can’t i edit my script? I can open it but it’s like i can’t type in it

rocky canyon
swift crag
swift crag
#

you need to open the script file in a script editor

rich adder
#

actually well just take it to DMS lmao

cunning silo
#

guys, ngl i don’t know. I’m learning it rn

#

well learning unity and everything so my bad 🙏

rich adder
#

2019 old af

#

they have 2022 but anyway VS is getting scrapped in august

#

get VSCode configured

rigid owl
#

does having an azerty keyboard affect this?

rich adder
rigid owl
#

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 "-"

rocky canyon
rich adder
#

I dont see how if the unicode would not be matched the the proper one

rigid owl
#

kind of odd

slender nymph
swift crag
#

ah, I think there's a setting for this

rigid owl
swift crag
rich adder
#

interesting

cunning silo
swift crag
#

Project Settings -> Input Manager

rigid owl
#

Aha, thanks man! :^)

swift crag
#

By default, the key codes really correspond to the physical keys on a QWERTY board

rich adder
#

wdym you can't edit it
you can literally edit it in textpad (dont) and it still works

swift crag
#

(probably because you usually just care about the block of keys that are classically WASD + its neighbors)

rigid owl
rocky canyon
rigid owl
#

thanks @swift crag :)!

swift crag
#

np!

rocky canyon
#

apparently its the physical location of the key, doesn't matter the character

rich adder
#

learned sum new

swift crag
#

i've never needed that before, but i happened to see that while digging around in the input manager at some point

rich adder
#

thats balls

rigid owl
rocky canyon
#

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

rocky canyon
#

👻

rich adder
#

but yeah thats something busted

rocky canyon
#

lol fr..

#

seems like the program isnt even getting keyboard input

#

but mouse input is fine?

#

weird

polar acorn
#

I blame mac

rocky canyon
#

i second that

rich adder
#

or xamarin

swift crag
#

I've never tried to use Xamarin Studio (which is what that actually is)

#

install VSCode and try that lol

rich adder
#

it was hell

#

better than VSCode at the time

rocky canyon
#

since ur on mac i believe VSCode is a better option

rich adder
#

now VSCode actually got good

swift crag
#

(no dice)

rich adder
#

the whole Omnisharp bullshit from before was annoying to deal with

cunning silo
#

okay okay like i knew i wasn’t going crazy, imma let yall know if i get it to work

swift crag
rich adder
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

rocky canyon
#

VSCode has stolen my heart

rich adder
#

I feel responsible 😦

rocky canyon
#

still have both, but i only open Community on accident

swift crag
#

as a mildly colorblind person, I hate how similar the logos are

rich adder
swift crag
#

and as someone who tries to use language to communicate, I hate how similar the names are too

polar acorn
rocky canyon
#

VSCode VSCommunity

rich adder
#

yeah microsoft fumbled the naming there

rocky canyon
#

thats how i differientiate

rich adder
#

Code Studio or some shit wouldve been better

swift crag
#

Visual Studio
Atom 2

rich adder
#

that still got VS in it 😦

rocky canyon
#
hasenj

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".

rich adder
#

ElectroCode

rocky canyon
#

haha whole thread dedicated to complaining bout the names

swift crag
#

lol

#

VSCode is a secret plot to sell you on Azure

rocky canyon
#

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

rich adder
#

vscode designers

swift crag
rocky canyon
#

^ thats a relateable problem

#

i had to do something similar when teleporting my player

swift crag
#
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

rocky canyon
#

my camera would always stay locked to the cursor. even when the player rotated

swift crag
#

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

rocky canyon
#

SignedAngle! woop woop.. i love that function

swift crag
#

(maybe)

#

I have to admit that I'm still a bit fuzzy on all of this

rocky canyon
#

gizmo's and handles are ur friend

swift crag
#

the next two lines were

rocky canyon
#

they helped me tremendously when visualizing stuff like that

swift crag
#
          Debug.DrawRay(entity.transform.position, flattened, Color.red, 3f);
            Debug.DrawRay(entity.transform.position, rotated, Color.green, 3f);
#

(:

rocky canyon
#

hell ya

swift crag
rocky canyon
#

handle text OP

swift crag
#

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
rocky canyon
#

yoink

swift crag
#

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

rocky canyon
#

what are you trying to do anyway?

#

the long game i guess

swift crag
#

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

rocky canyon
#

true.. but u can queue up data to draw

swift crag
#

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

keen rampart
#

does anyone know why my button doesnt have the

#

auto generate animatin button

#

im using the legacy butto

rich adder
keen rampart
#

like a tuturial

#

about how to animate ui

slender nymph
rich adder
slender nymph
slender nymph
# keen rampart

actually i think i know what the issue is, that button disappears once you've added an animator to the object

rich adder
#

i usually just make my own buttons with Ipointer interface

prime cobalt
#

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?

rocky canyon
#

i think i know what u mean you..

prime cobalt
#

Sorry I suck at describing things T_T

rich adder
rocky canyon
#

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

prime cobalt
#

Yeah exactly

rocky canyon
#

like a portal.. if u were raycasting into a portal.. u want the hit of w/e in that portal

#

sounds complicated

rich adder
#

lots of math involved

#

you have to take texture coordinate of RT and somehow map it to screen

rocky canyon
#

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

rich adder
#

whats more confusing its a world canvas so that adds some complexity there too

rocky canyon
#

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

slender nymph
#

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

rocky canyon
#

ud have to get a point.. and then evaluate that.. and then transfer that to the camera somehow (maybe the near clipping plane)

rich adder
#

you have to raycast onto the canvas

swift crag
#

RectTrasnformUtility might be helpful here

rocky canyon
#

raycasting forward or something

rocky canyon
prime cobalt
#

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...

rich adder
#

ViewportPointToRay after iirc

swift crag
#

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

rocky canyon
#

that'd give u a good coordinate to work with

swift crag
rocky canyon
#

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

rich adder
#

seems cool

swift crag
#

(the rect is defined in local space)

remote osprey
#

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;
    }
swift crag
#

Too complicated

rocky canyon
#

if u can read em

swift crag
#

I don't know what that does

swift crag
#

I'd have to roleplay as a C# compiler to parse that correctly

rocky canyon
#

readibility is more important than syntax sugar

swift crag
#

that's not syntax sugar

rich adder
#

i did a 2 nest and found that atrocious , 3 is just wild looking

swift crag
#

that's syntax poison

#

Just do a switch expression, actually

#

That'll make it look really nice

rocky canyon
#

yea i agree.. a switch for this

prime cobalt
remote osprey
#

I have 3 queues on my EventsQueue and I want a general Dnqueue() and Dequeue() methods to operatoe over all of them

polar acorn
swift crag
#
LinkedList<GameEvent> queue = type switch {
  QUEUE_TYPE.GAME => GameEventsQueue,
  QUEUE_TYPE.BEGIN => BeginTurnQueue,
  QUEUE_TYPE.END => EndTurnQueue,
  _ => null;
};
rocky canyon
#

this was once a BIG ternary

rocky canyon
#

people hated on it so now its a switch lol

rich adder
rocky canyon
#

pretty sure u were one of navarone

#

😛

remote osprey
#

Or should i just do 9 methods? xD

#

9 methods makes it simple just witha LOT OF METHODS

languid spire
rocky canyon
#

ohh i need to do the => to return

rocky canyon
languid spire
#

Array

rocky canyon
#

i trust steve, i trust navarone too 👇

rich adder
#

array is always more efficent than dict

polar acorn
#

If you don't assign them, they're in order starting at 0

slender nymph
# rocky canyon this was once a *BIG* ternary

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
  };
prime cobalt
#

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...

languid spire
#

Vector3[] array
return array[(int)direction]'

polar acorn
#

So you could literally just cast the enum to an int and index into the array

rocky canyon
#

ive used em to trigger void return functions

#

but never a return.. and once i realized (game changer)

rocky canyon
#

lol, no hate just saying

bleak glacier
#

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!");
}

}   ```
rocky canyon
#

are u reading the correct playerScore?

languid spire
#
static Vector3[] array { Vector3.forward. Vector3.right }
public static Vector3 GetDirection(Direction directon) =>
  return array[(int)direction];

who needs a switch ?

rich adder
rocky canyon
#

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

rich adder
#

where do you add playerScore

bleak glacier
#

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

rocky canyon
#

ya, but is that the same playerScore as this one?

#

i doubting

rich adder
rocky canyon
#

mmhmm

bleak glacier
rich adder
#

then you have 2 copies

rocky canyon
#

u have (2) versions

#

ur setting the text from one

#

but the other one u dont update

rich adder
#

you need a reference to this score on this script

bleak glacier
#

Alright I'm sorry but I'm a little confused

#

Oh wait

rocky canyon
#

ur setting ur text and stuff w/ this one

bleak glacier
#

I think I get it

rich adder
rocky canyon
#

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

rich adder
bleak glacier
#

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

near onyx
#

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;
}

rich adder
near onyx
#

No it donest show an error

#

thats why im getting so confused haha

rich adder
#

there are two parts to that question

rich adder
languid spire
rich adder
#

that would def throw a nullref

near onyx
languid spire
#

did you use legacy text in your UI

near onyx
#

Yes

rich adder
#

I bet the script isn't running at all then lol

#

or have errors collapsed

#

or statusButtons is empty

near onyx
#

Nope no error collapsed

#

maybe its just not running?

#

i dont understand why that would be the case though

rich adder
#

put a log and find out

teal viper
#

Debug log info

rich adder
#

and did you fill up statusButtons array?

slender bridge
rich adder
#

never assume till you got sum concrete numbers

remote osprey
#

Hey one thing that just striked me

near onyx
#

Alright

rich adder
#

did it hurt?

remote osprey
remote osprey
#

Having to do Stage 2 CPR to survive

#

IT's horriblee

#

Tell my mom

#

Spagheti is great

rich adder
remote osprey
#

I OOP words, should I give my methods a parameter or should that parameter be a class property?

rich adder
#

so you mean should you change a value via property or a method?

swift crag
#

Are you asking about the distinction between..

near onyx
#

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

rich adder
#

they are the same thing, well almost

bleak glacier
swift crag
#
foo.x = 1;
foo.y = 2;
foo.DoThingWithXAndY();

vs.

foo.DoThing(1, 2);
remote osprey
#

YEpp

#

Which one should i use?

#

which is better?

swift crag
#

Data stored in an object should represent some kind of meanignful state

rich adder
#

i prefer methods

teal viper
rich adder
#

as long as its property they're both valid though

swift crag
#

The point of function parameters is that they're specific to that invocation of the function

swift crag
#

There's no point to storing x and y

teal viper
#

Share the code

swift crag
near onyx
swift crag
#

at least the malfunctioning line..

teal viper
bleak glacier
#

@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

remote osprey
#

Got it, so in the case of a player turn variable, it should be a property then

#

Thanks for the responses, people!

swift crag
rich adder
near onyx
# teal viper At least the thing that errors

for (int i = 0; i < statusButtons.Length; i++)
{
statusButtons[i].SetActive(playerStats[i].gameObject.activeInHierarchy);
statusButtons[i].GetComponentInChildren<Text>().text = playerStats[i].charName;
}

teal viper
swift crag
rich adder
eternal falconBOT
near onyx
swift crag
#

...why?

rich adder
swift crag
#

aren't you asking about that?

bleak glacier
rich adder
teal viper
swift crag
rich adder
near onyx
bleak glacier
rich adder
#

if your score is 12,
your other score in that script is 0

bleak glacier
#

Mhm

swift crag
#

You need to actually invoke that method and pass it an argument

rich adder
teal viper
eternal falconBOT
rocky canyon
#

playerScore = 10; // <-- this is playerscore of one script
theOtherScript.playerScore; <-- this references the playerScore from that script..

#

both will debug 10

bleak glacier
rocky canyon
#

its basically the same variable

rich adder
#

I said example before with boxes and apples..

#

just because they both have apples, doesnt mean eating apples from one box affects other apples

rocky canyon
#

post both scripts !code

eternal falconBOT
rocky canyon
rich adder
#

naming things the same variable name in separate scripts, does not connect them whatsoever

rocky canyon
#

they belong to different classes

rich adder
#

could you imagine if variable names were global UnityChanPanicWork

swift crag
#

C# would be utterly useless if fields with the same name were linked

rich adder
#

fr

cosmic dagger
#

oh god, the horror . . . 😱

rocky canyon
rich adder
#

float IhaveRanOutOfNames = 2;

swift crag
#

you'd have to do some crazy code gen

bleak glacier
#

Am I missing something big here?

rich adder
bleak glacier
swift crag
rich adder
swift crag
#

public means that any type can see that member

cosmic dagger
edgy geyser
#

does anyone know why when i use a code and copy it perfectly it has an expected error every time.

swift crag
#

If you have an instance of Foo, and bar is a public member of Foo, you're allowed to see bar

teal viper
cosmic dagger
swift crag
#

It sounds like you have a very severe misunderstanding of how C# works

rocky canyon
rich adder
rocky canyon
#

see... these are different variables

ivory bobcat
bleak glacier
rocky canyon
#

yes, u have to reference the variable from its class

#

theClassYouWant.theVariableyouWant;

rich adder
#

or any other type that supports access modifiers

swift crag
#

(any member)

ivory bobcat
#

You'd reference the object instance and access that object's member.

cosmic dagger
rocky canyon
#
   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

rocky canyon
#

no need for that one in that button script

bleak glacier
#

❤️

#

Thank you. I'm still learning so thanks for getting me through this. I didn't know I could do that. That opens possibilities.

rocky canyon
#

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

rich adder
#

dam forgot c# only does private on nested classes, interesting

near onyx
rich adder
rocky canyon
#

he must be from Missouri

#

this channel has ruined us.. (hey i did X, Y, and Z) [show me.. i dont believe you]

near onyx
rich adder
summer stump
near onyx
#

sorry im getting so confused

summer stump
near onyx
#

yes

summer stump
#

Well, it is what shows you the files.
But just screenshot the whole thing. We will be able to tell

rocky canyon
#

if you see Miscellaneous Files its not working

near onyx
rocky canyon
#

well there should be soemthing there..

summer stump
rocky canyon
cunning silo
#

guya, i got it to work now. Thanks for all your help

near onyx
rocky canyon
#

congratulations

summer stump
#

It is configured

teal viper
#

Ok, so you do see the red underline

summer stump
#

Debug.Log is not a thing
Debug.Log() is

near onyx
#

oooooh

near onyx
rocky canyon
#

it requires a parameter

summer stump
#

And you likely want to... actually log something

near onyx
#

i tried telling everyone that before

rich adder
#

methods use ()

rocky canyon
#

thats why visual aids are important

#

took all of 4 seconds

near onyx
#

now its saying no overload for method "Log" takes 0 arguments

summer stump
rich adder
#

also what

rocky canyon
#

it requires something in the ()

rich adder
#

you have your own Debug class? what is even happening in this SS

rocky canyon
#

what are u expecting it to log? without it

teal viper
# near onyx yes i did

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.

near onyx
rich adder
summer stump
cosmic dagger
rich adder
#

Udemy courses are dogshit

cosmic dagger
summer stump
rocky canyon
rich adder
# near onyx i have not

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#

near onyx
rich adder
rocky canyon
#

Debug.Log("A Custom Message");
Debug.Log(aVariable);

summer stump
rocky canyon
#

^ the first things u shoulda learned

timid oriole
#

In someone's experienced position how hard is procedural generation with something like tile sets with only a few rules

rocky canyon
summer stump
rocky canyon
#

lmao it happens all the time

cosmic dagger
near onyx
#

but it all came up with irrelevant things to the problem i was having

summer stump
# near onyx i tried

"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

rocky canyon
#

what your hunting for + unity always returns decent results

#

if it doesn't ur bout to make ur own stuff

rich adder
summer stump
rocky canyon
#

where tf is the string interpolation unity

eternal needle
#

probably is old code, or they didnt wanna confuse people who actually need the examples

rich adder
#

yea unity confuse people ? never..

rocky canyon
#

they leave it to the C# docs for that stuff i guess

rich adder
#

string interpolation for 1 var is no biggie

rocky canyon
#

($@"TheBestKind");

#

verbatim

#

learned that once i started debugging file names..

#

got tired of escaping all the brackets and slashes

whole parcel
#

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

rich adder
rich adder
rocky canyon
#

not sure if u can recover it or not.. most likely not

eternal needle
rocky canyon
#

^ there ya go

whole parcel
#

i alr opened it

#

😭

rocky canyon
#

RIP

rich adder
#

you're boned

whole parcel
#

i didnt run tho-

rocky canyon
#

doesn't matter

whole parcel
#

wow

rocky canyon
#

as soon as u opened it it rebuilt everything

whole parcel
#

fricking hell.

rich adder
#

improve your ctrl + s game

rocky canyon
#

no joke ^ make that muscle memory

eternal needle
#

im not sure why unity even deletes the temp scene, they really could just keep one around for your last ran scene

rocky canyon
#

make it happen so often u actually screw up by saving things u dont want to 😄

#

its better than not saving things u shoudlda

rich adder
#

or some shit

rocky canyon
#

sounds like an opportunity

#

for an asset

rich adder
#

yeah typical unity things

#

simple shit we have to make cause devs were thinking " whatever lol this app wont ever crash"

rocky canyon
#

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

whole parcel
#

is there rlly no way to fix it

swift crag
#

in the future, save your scene

swift crag
#

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

rocky canyon
#

the projectonplane?

#

i mean the flattening part

swift crag
#
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);
rocky canyon
#

thats intense

swift crag
#

It computes a yaw, then uses that to compute a pitch, then uses both of them to compute a roll

rocky canyon
#

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)

swift crag
#

the jaw is an actual example

#

i'm combining multiple sources to get a local rotation and local scale for a transform

rocky canyon
#

oh okay.

swift crag
#

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

rocky canyon
#

yea, i see.. seems like u got a good handle on it

bleak glacier
rocky canyon
#

yes thats teh best way

#

i didnt wanna mention it b/c i didnt want to confuse u

swift crag
#

time to poke at this some more

bleak glacier
rocky canyon
#

np mate 👍

cosmic dagger
bleak glacier
rocky canyon
#

it allows private variables to be accessed in the inspector

swift crag
#

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

rocky canyon
#

public variables are already accessible.. and static variables can't be serialized

swift crag
#

other fields must have the SerializeField attribute added

swift crag
#

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

flint python
#

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

rich adder
#

or turn off raycast on canvas raycaster

rocky canyon
#

^ two solid solutions

rich adder
#

loop through all interactables and set interact to false 😬 /s

flint python
#

Will it disable all ui interaction? For example if cursor is set to not visible, then I want to use movement key for interaction

rich adder
ivory bobcat
rich adder
#

ig navigating through the buttons wasd

flint python
#

Yea^

#

Thanks all

whole parcel
#

what does nullreferenceexception mean

summer stump
craggy coyote
#

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?)

summer stump
whole parcel
#

i tried debug.log at those spots

summer stump
#

Look at GameManager line 82

whole parcel
#

but it didn't help me locate

summer stump
whole parcel
summer stump
#

That index of ghosts is null

#

What is GhostFrightened?

whole parcel
#

ghostFrightened is an object

summer stump
#

Then that could be null too/instead

#

Not great naming honestly. Throught it was a bool at first

cosmic dagger
# whole parcel

you need to check every reference variable on that line . . .

whole parcel
#

im assuming that'll just be all the ghosts?

summer stump
#

What?

whole parcel
cosmic dagger
#

any variable that is a reference type can be null. you need to check if each one is null right before the error line . . .

whole parcel
#

oh haha

#

i only put the ref onto one of the ghosts!

#

it's working now thanks guys!

craggy coyote
slender nymph
#

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"

ivory bobcat
#
var instance = Instantiate(prefab);
instance.player = player;```
outer coral
#

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?

slender nymph
#

have you clicked into the game view window?

whole parcel
#
    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?

craggy coyote
#

I'll try that. Thanks @ivory bobcat & @slender nymph

outer coral
slender nymph
#

the objects involved in the collision obviously

cosmic dagger
slender nymph
outer coral
slender nymph
#

sure, but have you actually done anything to confirm that nothing else is changing it

outer coral
#

yes

#

unless its something that I didn't code

#

which idk what would be doing it then

whole parcel
slender nymph
whole parcel
#

Debug.Log(collision.gameObject.tag); didn't output anything

outer coral
#

what kind of test are you referring to

cosmic dagger
slender nymph
whole parcel
shadow osprey
#

is this the place that I ask for help with a bugged script?

slender nymph
#

this is where you can ask for help with your code, yes

outer coral
#

it just worked for one runtime and then when I ran it again it was no longer working

slender nymph
#

so is the setting being changed?

outer coral
#

but the log is correct

#

yes

#

says false every frame and cursor still there

shadow osprey
#

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

outer coral
#

!code

eternal falconBOT
slender nymph
# outer coral says false every frame and cursor still there

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

outer coral
#

god im such an idiot

#

no way ive been sitting here trying to figure out why it works half the time

shadow osprey
#

Im brand new and dont know how to use that

slender nymph
#

did you read it?

outer coral
#

thank you boxfriend

shadow osprey
#
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

rocky canyon
#

make a linebreak after the cs part.. start the code on a new line

summer stump
rocky canyon
#

it is close enuff tho.. we got the idea

summer stump
#

To be clear, you want input disabled when jumping?

shadow osprey
#

I want it to stop sending the gravity number to the console

slender nymph
#

then remove the debug.log call at the end of ProcessMove

rocky canyon
#

this ezpz

summer stump
#

That is what you called a bug? Just to be clear, that was all that you wanted?

shadow osprey
#

not a bug sorry

#

but I need it to send while im falling

slender nymph
#

if you only want that log to print while you are falling, then you need to use an if statement

summer stump
#

Could be an else specifically. Since you are already doing the if isGrounded check

rocky canyon
#

you could be accelerating upwards and not grounded

slender nymph
#

technically they'd need an else if, they'd still want to ensure the y velocity is negative

rocky canyon
#

hmm preview not working on certain scripts

iron wing
#

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?

jaunty bone
#

How do I tell my friend to just work at fastfood

rocky canyon
#

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
jaunty bone
#

Ever since I took that coding course I'm not even done I'm like 46% done but I can semi reas code now

iron wing
# rocky canyon

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

rocky canyon
#

basically I watched many different videos and read different articles.. and pieced it together.. it was abunch of trial and error

rocky canyon
#

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

jagged socket
#

how to change from a scene to another scene in unity 2d?

rich adder
jagged socket
#

to youtube but bad tut

#

i`m still searching

summer stump
#

That will get you very far

jagged socket
#

okay thx for the tip

arctic ibex
#

hey what does ++ do? as in "for(i=0; i<5; i++)"

languid spire
#

i++ is the same as i = i + 1

#

so it is an increment by 1 AFTER evaluation
++i is the same but incremented BEFORE evaluation