#💻┃code-beginner

1 messages · Page 392 of 1

willow scroll
#

So it goes:

  • i = 0. Is 0 smaller than 5? Yes. Fine.
  • Execute the scope inside of the condition with i = 0
  • The scope is executed. Now i++, which is i += 1, so 0 + 1 = 1. Is 1 smaller than 5? Yes.
  • Repeat until 4 + 1 = 5.
  • Is 5 smaller than 5? No. Stop the loop.
willow scroll
#

These are all the same

ivory bobcat
#

Note that in the context of your for loop and as the sole statement for the iterator, it'll produce the same behavior - relative to having the symbols before/after then variable.

arctic ibex
#

Is there an easy way to lerp two objects at the same time in one script? I'm trying to lerp both ends of a line renderer in different directions. Is it easier to just have 2 line renders?

ivory bobcat
arctic ibex
#

alright, I'll try that

#

But will they lerp at the same time?

ivory bobcat
arctic ibex
#

Wouldn't they lerp 1 after another?

ivory bobcat
#

Also, if you don't care about the transition process, maybe simply have the points move towards the targets.

ivory bobcat
# arctic ibex Wouldn't they lerp 1 after another?

Code either happens and finishes immediately or returns control to not finish immediately. You'd lerp/move the other point then - assuming you're actually lerping and not just setting your position to your destination.

vernal bone
#

I have a question.
I've seen a couple of times thing, where some random parts of code is encased in asterisks(*), like:

points *+= diff;*
or
var particle = particles*;*

What's the point of this?

Edit: formatting is hard

ivory bobcat
#

There's a += b that is a shorthand for a = a + b.

vernal bone
#

could it be some formatting error? because both examples are from discussion.unity

ivory bobcat
#

As for the second example, you may need to cache materials, particles or other values to be modified and later assign back to those properties - they're not directly modifiable like members of the Transform. For example:cs var position = transform.position; position.x += ... position.y = ... transform.position = position;

ivory bobcat
vernal bone
fringe plover
#

Can someone rate this code?

#

maybe there is a way to make it better?

burnt vapor
#

Generally your code should have a single happy flow that ends at the bottom. Right now your ends somewhere in the middle

#

If you reverse your if-statements you can create guard clauses that make it clear what is being checked against, and what action is taken when this fails

#

Especially in your case it really avoids nesting your code multiple times

languid spire
teal viper
# fringe plover Can someone rate this code?

You could have a bool reset= true declared at the start of the method and set it to false when you don't want to reset. Then at the end check the bool and reset if needed.
Or even better, just return of you don't want to reset.

That would save you from writing a Matroshka like that.

rich mountain
fringe plover
#

my own code, didnt watch any tutorials like 6 months

timid bridge
astral falcon
#

Is there an option to not round values when converted ToString("F2")? Just want to kinda cut off the value, not round it

#

Well I guess, truncate is my only option and no tostring parameter

languid spire
carmine elbow
#

Trying to create an Audio Manager, would using enums that correspond to the sounds be better, or just ids?

willow scroll
cosmic oxide
#

Hi, Unity is not detecting key presses on my system. Any help?

languid spire
cosmic oxide
#

Ok got it.

tender stag
#

i have this discord activity script

#

but when i stop the game it just stays instead of disappearing

halcyon geyser
#
private void OnApplicationQuit()
    {
        if (discord != null)
        {
            discord.Dispose();
            discord = null;
        }
    }
#

Maybe simply add this?

tender stag
#

i tried but then for some reason it doesnt even turn on

#

wait its not working either way now

halcyon geyser
#

idk bout that

willow scroll
tender stag
#

yeah i just found out

#

its really cool

willow scroll
tender stag
#

no its something else now

willow scroll
#

But you're saying it's not working?

#

Where is the error thrown?

tender stag
willow scroll
tender stag
#

this guy didnt

#

it was working a minute ago

#

and now it aint

#

i didnt even do anything

willow scroll
tender stag
#

well yeah cause it worked

#

until it didnt

willow scroll
#

I'm not sure when it appears, but it should work by only doing that

brave compass
#

It could be because the first session is still undisposed. You may have to restart the editor or Discord to fix it.

#

Discord thinks the same app is trying to initialize twice, because the first session never stopped.

tender stag
#

even when i try to run the game with discord closed its the same error

brave compass
#

Are you testing in the editor in playmode?

tender stag
#

yes

brave compass
#

Have you tried restarting the editor?

tender stag
#

couple of times

errant niche
#

can you recommend me any good beginners tutorials for scripting, so i can learn and understand what the things do?

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

errant niche
#

thanks

tender stag
errant niche
swift crag
#

It's probably actually a very very small number

#

like 3.5063e-6

errant niche
#

ok

swift crag
#

the end is being cut off because the field is too narrow

swift crag
#

0.0000035063

errant niche
#

but sometimes my jump doesnt work because i use this to figure out if im on the ground: grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);

#

and for some reason because of that i cant jump sometimes

#

but with such a small number it shouldnt really matter

#

so then thats probably something else i did wrong

swift crag
#

You should raise the starting point of the raycast a bit

#

Change this from "Center" to "Pivot"

#

That will show you the actual position of the Player object

errant niche
#

ok ill do that

swift crag
#

I think your raycast is sometimes starting inside or below the ground

errant niche
#

ok

swift crag
#

for a raycast starting at the bottom of the player, I'd do something more like

errant niche
#

but then the raycast doesnt need to be half the players height and just a little bit

swift crag
#

transform.position + Vector3.up * 0.1f for the starting point and 0.2f for the range

errant niche
#

ok

errant niche
#

ok thank you

#

it works just like i want it to now 😄

swift crag
#

Also, to help catch this kind of problem, you can use Debug.DrawLine or Debug.DrawRay

#
Debug.DrawRay(transform.position, Vector3.down * (playerHeight * 0.5f + 0.2f));
#

This will draw a line for one frame that shows what the raycast is doing

#
Debug.DrawLine(transform.position, transform.position + Vector3.down * (playerHeight * 0.5f + 0.2f));
#

an equivalent use of DrawLine

errant niche
#

rb.velocity = new Vector3(rb.velocity.x, 0f, rb.velocity.z);

rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
is there any issue with this code? my jump isnt working

#

it jumps sometimes but sometimes just wont respond

#

if (Input.GetKey(jumpKey) && readyToJump && grounded)
{
readyToJump = false;
Jump();

  Invoke(nameof(ResetJump), jumpCooldown);

}

swift crag
#

make sure that your code is actually running with a Debug.Log

errant niche
#

Ok

#

How do I use that?

swift crag
wintry quarry
errant niche
#

Thanks

flat leaf
#

Hey folks, I'm trying to create a game similar to "Mushroom wars". I don't know how to select building and sending troops to another building in better way. Could you suggest smth regarding it?

wintry quarry
timid oriole
#

Can someone take a look at my code the instructions are in there

latent magnet
#
Build.framework.js.gz:10 RuntimeError: null function or function signature mismatch
    at Image_set_sprite_mC0C248340BA27AAEE56855A3FAFA0D8CA12956DE (Build.wasm.gz:0x45f0f0)
    at U3CLoadImageU3Ed__1_MoveNext_m6D83251DF156589F38D586F36FAF7346023AA45F (Build.wasm.gz:0x9b6b7b)
    at SetupCoroutine_InvokeMoveNext_m72FC77384CAC3133B6EE650E0581D055B34B2F5F (Build.wasm.gz:0x5d2f9c)

attempted to load a texture from url
not sure what this error means

timid oriole
#

use gdl paste don't paste code in here

#

Clogs it up

latent magnet
#

currently using a webgl build

#

so the exception seems a bit obfuscated with (Build.wasm.gz:numbers)

#

that's why i dont get it

cosmic dagger
# timid oriole https://gdl.space/ecemubixiz.cs

playerCamera is already a Transform; there is no need to do playerCamera.transform.position. basically, you're saying transform.transform.position. the rayCast variable as a float is confusing because it's a distance, no?

timid oriole
#

true yeah

cosmic dagger
#

to help with the first part, search: unity how to set parent. that's an easy one . . .

timid oriole
#

I know how to set parent

#

I'm saying how to get access to the object im looking at

#

and setting that one a parent specfically

cosmic dagger
#

sure, well, do you know what this line does? hit.collider.CompareTag() . . .

dreamy dune
#

!code

eternal falconBOT
flint python
#

Hello, I am trying to get the object when the cursor hovers over it. I tried void OnPointerEnter(PointerEventData eventData):

when using eventData.hovered[eventData.hovered.Count - 1], I am worry about the size of list could affect the game, just assuming, not sure if it can be an issue

Is there another method to achieve the goal? or methods to optimize the hovered list, if it is a problem I should worry about. Thanks

dreamy dune
willow scroll
#

You can also check if the object is being hovered with the mouse methods or by checking if the cursor is within the object's bounds

willow scroll
bleak glacier
#

I tried using thread.sleep and I clearly don't understand how it works. How do I achieve a sleep in this part of my code without all of my code sleeping? ```
void Update()
{
Thread.Sleep(1000);
inputHandler.playerScore = inputHandler.playerScore + idleBonus;
Debug.Log("Idle score added");
}

swift crag
#

You don't.

#

You can never block the main thread. That freezes your entire game.

#

Ever. Don't try to do it.

#

now, there are alternatives!

#

this lets you run an enumerator method over many frames

#

But you will never be able to make Update "wait"

cosmic dagger
#

Coroutines have entered the chat!

swift crag
#

A very very common error I see is:

void Update() {
  int x = 1;
  StartCoroutine(Wait());
  x = 2; // this runs immediately
}

IEnumerator Wait() {
  yield return new WaitForSeconds(1f);
}
#

You'll simply start a coroutine that waits 1 second, then does nothing

bleak glacier
#

These look kind of scary

#

Guess I'll have to watch a few videos

swift crag
#

It explains how to use them.

vast sandal
#
private void LookInCameraDirection()
    {
        if (!characterController.velocity.AlmostZero())
        {
            //// Vector Solution working
            //Vector3 characterV = characterTransform.transform.eulerAngles;
            //Vector3 cinemachineCameraV = cinemachineCamera.transform.eulerAngles;
            //Vector3 rotation = new Vector3(characterV.z, cinemachineCameraV.y, characterV.z);
            //characterTransform.transform.eulerAngles = Vector3.RotateTowards(characterV, rotation, 360f, 360f);

            //Quaternion Solution
            Quaternion characterQ = characterTransform.transform.rotation;
            Quaternion cinemachineCameraQ = cinemachineCamera.transform.rotation;
            Quaternion rotation = Quaternion.RotateTowards(characterQ, cinemachineCameraQ, 360f * Time.deltaTime);
            characterTransform.transform.rotation = rotation;


        }
    }```

Im trying to rotate the character according to the cameras y axis..
The commented vector solution works, but has polarity inversion problems.. 
Thus im trying to make the quaternion stuff work.. it works fine, but its not just rotating in y-axis, but all 3 axis.. how can I fix that?
lethal swallow
timid oriole
#

I wrote the code im familiar with what I wrote in there the only part I dont get is getting access to the objects components with the tag item without direvctly dragging and dropping that item in the inspector

#

Would I say like object = object.GetComponent<RigidBody>();

languid spire
#

no.

RigidBody rb = object.GetComponent<RigidBody>();
late burrow
#

is there anything bad with running a code that will error a lot inside a try

languid spire
#

yes, try catch is very expensive

late burrow
#

is there something cheap where i can ignore errors then

cosmic dagger
languid spire
#

NO. Errors should never be ignored

late burrow
#

its just sake of not if != null

#

for 20 times

languid spire
#

So do that and don't be lazy

cosmic dagger
cosmic dagger
willow scroll
bleak glacier
willow scroll
bleak glacier
willow scroll
languid spire
#

that makes absolutely no sense

willow scroll
#

And your WaitForSeconds is returned after the actual code logic, which makes your Coroutine do nothing after waiting for 1 second

bleak glacier
willow scroll
willow scroll
languid spire
bleak glacier
willow scroll
bleak glacier
willow scroll
#

Consider learning basic C# syntax first

bleak glacier
#

So I'm picking up on what information I need along the way

timid oriole
bleak glacier
# willow scroll "tutorial hell"?

Tutorial Hell is a state of perpetual learning, often marked by the consumption of one tutorial after another without putting acquired knowledge into practice.

cosmic dagger
languid spire
cosmic dagger
#

hit is a struct, so it can never be null . . .

timid oriole
#

uh oh

cosmic dagger
#

haha, i hear an echo . . .

timid oriole
#

Why do I need to check if its null? I've never done this befoore can't I just use an else statement ?

cosmic dagger
dreamy dune
#

best to use charachtercontroler movement or rigidbody movement?

cosmic dagger
willow scroll
dreamy dune
timid oriole
#

Yeah is that not what hit.collider does? It checks if the ray is hitting something then if it is checks if the name inside of the () in comparetag

#

and if it is not hitting anything its null?

languid spire
#

and you cannot check the name of something that is null

willow scroll
timid oriole
#

yeah exactly

#

so this is where im lost now because that makes sense to me why do I have to check if hit.collider == null

willow scroll
broken cargo
cosmic dagger
# timid oriole yeah exactly

when you do hit.collider.CompareTag("Item"), you are accessing collider (assuming it exists), but if it is null, you will receive a null reference exception . . .

broken cargo
timid oriole
#

yes I understand that part

#

but how do I access an object that has the tag item

#

rigidbody and collider inside of that if statement

willow scroll
gaunt ice
#

hitinfo has a transform member

cosmic dagger
timid oriole
#

ohh I see

#

So it gets access to whatever is in there basedd off what its hitting

#

so I could do something like Rigidbody rb = GetComponent<RigidBody>(); Then do rb.isKinematic = true; then repeat for collider?

broken cargo
# willow scroll What do you mean?

I just checked the docs. You are right that it can be null. But it is easier to check the return of the Raycast method than do a null check. So there is no reason to acces hit information if you didn't hit anything

cosmic dagger
timid oriole
#

that would be inside the if hit.collider

cosmic dagger
#

a bool is easier to check than a null reference . . .

cosmic dagger
timid oriole
#

dangit

willow scroll
cosmic dagger
timid oriole
#

mulitple times

cosmic dagger
summer stump
timid oriole
timid oriole
#

may have been looking at physics thisi entire time

#

Yeah I was looking at physics.raycast before

cosmic dagger
#

it's not that hard to tell if you're looking at the correct docs. the name of the class or struct is in bold at the top . . .

#

how, we mentioned RaycastHit docs multiple times . . .

timid oriole
#

Thought it was the same thing at first

willow scroll
# timid oriole like this https://gdl.space/qezayuteva.cs

Want to set itemContainer as a parent of object that has tag "Item" that my raycast hit

itemContainer.SetParent(hit.transform);

Then want to set Items position equal to itemContainers position

hit.transform.position = itemContainer.transform.position;

then want to make the item I picked up isKinematic

hit.rigidbody.isKinematic = true;

Then make it so its now isTrigger

hit.collider.isTrigger = true;
subtle mist
#

hey guys, I have a small question about audio in unity
basically, I want my weapon to constantly make sound depending on the amount of charge it has (more charge means higher pitch)
what'd be the correct way to implement it?

timid oriole
#

But could I have it so When I Input.GetKeyDown(KeyCode.E)){ && hit.collider or not possible ?

#

because it looks like hit.collider would set this to the case anytime its hit or am I mistaken?

cosmic dagger
#

when charge is at its lowest the pitch can be normal or a lesser (min) value. when the charge is full, the pitch will be at the highest (max) value . . .

timid oriole
# willow scroll What does it mean?

If I want it so this code hit. whatever is only ran if I click e and my raj is hitting couldn't I use something like if (hit.collider.Compare.Tag("Item") && Input.GetKeyDown(KeyCode.E)) { then put the code you put inside so it will only run if I click e and my ray is hitting the object

willow scroll
cosmic dagger
willow scroll
broken cargo
timid oriole
timid oriole
#

Should I always check for inputs before another condition is met is that good practice?

dreamy dune
#

!code

willow scroll
eternal falconBOT
broken cargo
cosmic dagger
timid oriole
#

makes sense yeah

dreamy dune
#

https://gdl.space/hutusaxoya.cpp

ayone can help me why my cinemachine camera is not moving properly with where i am watching while when i have only regular camera it works perfect

willow scroll
#

So 0f - 1f

bleak glacier
#

What am I missing here? I'm trying to learn coroutines and I think I'm missing something.

    {   
        StartCoroutine(scoreAdd());
    }```
``` IEnumerator scoreAdd()
        {
            for(;;)
            {
        inputHandler.playerScore = inputHandler.playerScore + idleBonus;
        Debug.Log("Idle score added");   
        yield return new WaitForSeconds(1f);
            }
        
        }```
willow scroll
broken cargo
cosmic dagger
bleak glacier
swift crag
#

Show your entire script.

#

!code

eternal falconBOT
swift crag
#

We need to see the context in which you wrote these methods

broken cargo
timid oriole
cosmic dagger
bleak glacier
willow scroll
willow scroll
bleak glacier
willow scroll
#

It doesn't matter whether you have a Unity Message at the top or bottom of the script. It's called anyway

bleak glacier
swift crag
cosmic dagger
swift crag
#

the order you declare methods in is completely irrelevant

willow scroll
#

Now I'm interested how you have fixed it by, as you say, changing the position of the method

swift crag
bleak glacier
#

Syntax

swift crag
#

note that the line number of Start is completely irrelevant

bleak glacier
#

It ended up getting lumped in with something else though

swift crag
#

it's the fact that you declared it inside of a method that caused a problem

cosmic dagger
#

that's definitely a local function . . .

cosmic dagger
#

take the time to make sure your code format, variables, etc., are correct. it makes code flow and readability much easier . . .

remote osprey
#

hello

#

I have a question about the Factory pattern

#

If I can make an abstract factory for my factories

#

does that mean that I can make an Abstract FActory for any kind of factory in the project?

#

Or is that too much abstraction?

broken cargo
remote osprey
#

So it may be better to make abstract factories for each "thing" in my project, for example

#

An abstract Events factory, then an abstract Cards factory, etc...

swift crag
#

a factory to do what, exactly

remote osprey
#

I'm making a card game, so I need to create a lot of cards and a lot of Events, which are objects that encompass behaviour

broken cargo
swift crag
#

what am I even supposed to do with an abstract card factory

remote osprey
#

Create any card with it

swift crag
#

why can't I just instantiate a card prefab and then pass it some data?

remote osprey
#

Because that would need a huge switch case, and I want to avoid it

#

Tbh, the factory would probably do that

swift crag
#

no, you just pass the card some data, and it configures itself based on that data

#

I haven't ever really felt the urge to use the factory pattern

remote osprey
#

But then I'd need to tell apart which card data is being passed, hence a switch statement

#

it's what I"m currently doing ni my code

#

but it's bloaty and I don't like it

#

Same with my Events system

swift crag
#

so the card (a MonoBehaviour that's part of a prefab) can configure itself when given the card data

#

(gotta scram!)

remote osprey
#

Ok, I'm gonna think about what you said and see if I can make something simple in my project!

#

Thanks for the reply!

ruby python
remote osprey
#

My biggest beef is finding a nice way to compose card effects

#

I think that cards are not the problem

ruby python
#

How do you mean?

remote osprey
#

Cause I turned all my card effects into Events

#

But creating the Events is being a problem

#

It's beggining to turn into an ultimate spaghetti

ruby python
#

What do you mean by effects?

remote osprey
#

So I'm having to rethink things

remote osprey
#

Card does X when played, Y at start of turn

ruby python
#

Ah okay. I get what you mean.

remote osprey
#

I'm trying to separate my code nicely, but it gets more and mroe compelx the more I try haha

ruby python
#

I don't think events are necessary if honest.

#

You could create a seperate public script that 'manages' the cards effects (maybe a singleton, not sure), and every time you play a card you just call a relevant method inside of said script to modify values (ie, if it's an 'attack' card, send damage, hit chance, crit chance etc. to AttackCard() method and have that modify the player/enemy stats?

timid oriole
remote osprey
#

Hence, turning actions into objecst

#

It's called the Command Pattern ( I just read about it yday lol)

slender nymph
summer stump
#

And the object name

ruby python
slender nymph
#

log

timid oriole
#

Debug.Log(item?);

remote osprey
#

I'd say the more you know the better

slender nymph
ruby python
#

You've got 3 'checks' in there, raycast, collision and keypress, so you need to debug each one to see which one is 'missing'

timid oriole
#

Debug.Log(hit);?

summer stump
#

The learn.unity site would have taught how to log values....

But hit is the struct containing information you need. Access values from it

summer stump
timid oriole
#

.collider I guess

#

to see what collider itshitting

summer stump
#

.tag as well as .name

ruby python
#

Debug.Log("I have hit xxx using raycast/collision/keypress") kind of thing.

slender nymph
ruby python
#

I did say 'kind of thing' 😉

timid oriole
#

What the hell kinda raycast is this.

summer stump
#

One where you are moving the origin point and direction

timid oriole
#

the origin is my camera

#

So I guess its normal?

rich adder
ruby python
#

Looks like you've got a line gizmo rendering and it's rendering a new line everytime the ray is fired (every frame?)

rich adder
#

just has a longer duration on ray

ruby python
#

So yeah, that looks like it's working as it should to me.

timid oriole
#

is that because of that rayCast line

#

the duration

rich adder
#

thats the duration yes

#

if you want to draw length you multiply it in the direction

ruby python
#

I thought that was the length of the ray?

summer stump
#

rayCast is the duration... rayCast is not a good name for that variable

rich adder
#

there is no length param (only on raycast)

timid oriole
#

how do I know what direction its going?

#

do I juse use dir?

rich adder
#

that is a direction

summer stump
ruby python
#

Sorry, was thinking of the actual raycast coding, not the drawline.

timid oriole
#

ah

whole parcel
#

im trying to play a death animation after player collides w enemy. https://gdl.space/ufoyozorof.cs this is my code. rn it just keeps on going infinitely rather than only once.

#

the death animation going on infinitely

#

rather than switching back to the idle one

#

btw i created my own animationSprite class

#

rather than using animator

#

💀

timid oriole
#

just a guess

slender nymph
whole parcel
#

like i created my own class

rich adder
#

can you send the code

timid oriole
rich adder
#

which object has this script

timid oriole
#

player

slender nymph
#

you put the log inside the inner if statement

rich adder
#

cause its using its forward not the camera

timid oriole
#

its using the camera no?

slender nymph
#

don't do that since that if is clearly not ending up as true and you are trying to figure out why

rich adder
#

put the raycast direction from camera.forward

timid oriole
#

oh dangit

#

u right

#

I had the transform.forward and it was going off my player not my camera

#

big oopsie

rich adder
# timid oriole big oopsie

also this should be
Debug.DrawRay(playerCamera.transform.position, playerCamera.transform.forward * rayCast, Color.red);

#

that name is atrocious though

#

call it rayLength or some shit..

timid oriole
#

true

#

do u guys know how to dock it so its split screen

rocky canyon
#

dock what?

timid oriole
#

the game and scene view

rich adder
timid oriole
#

to the scene?

rich adder
#

you will see it will snap

rocky canyon
rich adder
#

move it around

rocky canyon
#

now my layout is busted

rich adder
#

or is it still transform.forward

timid oriole
#

yeah

#

playerCamera

rich adder
timid oriole
rich adder
#

so u didnt change it for raycast?

timid oriole
#

wym

slender nymph
#

and they didn't bother moving the log either

rich adder
#

yeah the gizmos is still wrong

rocky canyon
#

gizmo shows playerCamera.forward

#

ur raycast is transform.forward

timid oriole
#

I'm confused now.

rich adder
#

what Transform did you drag into playerCamera

timid oriole
#

the camera

#

attatched to the player as a child

rich adder
#

no i mean in the field of inspector

timid oriole
#

What did I drag into the transform in the inspector ?

slender nymph
timid oriole
#

oh shit

#

I thought I changed it

#

my bad guys I changed the origin on the debug lol

rich adder
#

wouldn't the Debug at least be correct forward ? Assuming playerCamera was actually linked to camera

timid oriole
#

fixed it

rocky canyon
#

i thought it was butter 🧈

rocky canyon
rich adder
rocky canyon
#

i thought it was gonna be the same as Default

#

sooo im good 👍

timid oriole
#

would I use an else if for a drop or another if you guys think

rocky canyon
#

sorry, come again?

timid oriole
#

me?

rich adder
#

you would store the item you grabbed which you did not do

summer stump
rocky canyon
#

ohh its item_pickup.

timid oriole
rich adder
#

also hit.rigidbody.isKinematic = true; is a NullRef waiting to happen

rocky canyon
#

sorry i didnt have context.. i udnerstand now

summer stump
rocky canyon
#

everything you hit will not have a rigidbody.

#

if it doesn't its gonna error

timid oriole
timid oriole
#

but I thought only If I click E

summer stump
rocky canyon
#

yes u need to check if it has a rigidbody first

#

and then check if that rigidbody is kinematic

rich adder
#

at least the ones with "item" tag

rocky canyon
timid oriole
#

yeah that's fine because I have three conditions if !itemHeldd, InputE and hit.collider no?

rocky canyon
#

colliders can exist w/o rigidbodies

rich adder
#

you should lookup a simple pickup video

rocky canyon
#

you'll see..

rich adder
#

you need to store the item you grabbed into a reference so you can do stuff with it

timid oriole
#

Well in theory its easy just disable collider when u pickup and make it kinematic so it doesn't fall out of your hands and when you have itemheld true and input G renable rigidybody and collider no?

rich adder
timid oriole
rich adder
#

they are seperate components

rich adder
#

you only need colliders for raycast

rocky canyon
#

CachedInteractable is my variable i store..

timid oriole
#

Yes but i still want to disable gravity when I pick it up so it doesn't fall out of my hands no?

rich adder
#

if you grabbablle items have rigidbodies you can just store it as a Rigidbody

rocky canyon
#

disable gravity.. make it kinematic

#

both are similar in terms of what ur doing

timid oriole
rich adder
timid oriole
#

or do I have to instialize it somewhere

rich adder
#

if it doesnt it will null ref

rocky canyon
#

u can't reference your HIT outside the scope of ur raycast

rich adder
#

also ur not storing it

rocky canyon
#

so if u wanna use it somewhere else

#

u want ane xtra variable

rich adder
#

how you plan on enabling kinematic back to false on that same object ?

timid oriole
#

When ItemHeld && Input G renable collider so doesn't fall through map and rigidbody so it can fall to ground

rocky canyon
timid oriole
#

rigidbody.kinimatic = false?

rich adder
#

and what is rigidbody ?

timid oriole
#

a component attatched to the object im holding

rocky canyon
rich adder
rich adder
timid oriole
#

Gold bar

rich adder
timid oriole
#

because itemHeld is true

#

oh no wait that doesn't make sense

rocky canyon
#

that only knows there is an item

#

not which one it is

timid oriole
#

yeah

rocky canyon
#

i think its clicking now

timid oriole
#

yep.

#

so is it even possible or should I scrap and start all over

rocky canyon
#

yes its possible.. no u shouldnt start over

#

unless u like pain

rich adder
#

no one saying its not possible obv is possible

timid oriole
#

oh

rocky canyon
#

you just need an extra variable..

rich adder
#

you have to understand how to store references to things

summer stump
rocky canyon
#

RIGIDBODYIPICKEDUP = theRigidbodyYOuHit;

timid oriole
#

how to store a reference?

rocky canyon
rich adder
rocky canyon
#

make 1 like all these

summer stump
rich adder
#

make a variable for it first

timid oriole
#

so I create another variable for each of the components

rich adder
#

Rigidbody should be fine

rocky canyon
#

just 1 ^

#

Rigidbody StoredRigidbody;

#

StoredRigidbody = rigidbodyYouHitDuringYourRaycast;

summer stump
#

Just the one they keep saying over and over

rich adder
#

Rigidbody heldItem;

pine bone
#

Hello, i'm making a 2d platformer game and i'm having some issues with resolution. When i build the game and play normally without changing the resolution, the guns work fine. However if i change the resolution the game doesnt accept any inputs to the guns anymore

timid oriole
rich adder
timid oriole
#

or start

rich adder
#

its not going be touched in the inspector

rocky canyon
rich adder
#

you are using it as a storage bin

rocky canyon
#

it would be when u hit it with ur raycast + push E

#

or w/e

#

when u ray hits the thingy... store the thingy

timid oriole
#

sure

rocky canyon
#

lmao

timid oriole
#

but what information am I updating when that code runs

#

is it a bool, a numerical value

rich adder
#

when you find said item, you assign it to the itemHeld

rocky canyon
#

^ your gonna be manipulating the RIgidbody's parameters.. soo u store a rigidbody this

timid oriole
#

interesting so something like

#

storedRb = itemEquip.Child?

rich adder
#

huh ? whats itemEquip

timid oriole
#

sorry meant itemcontainer

rich adder
#

no need

#

item container is not a rigidbdoy

#

it just holds it..

timid oriole
#

Yes but

#

the issue is I have 8 things tagged item so do I need one for each?

rocky canyon
#
            if (Input.GetKey(KeyCode.E) && hit.collider.CompareTag("Item"))
            {
                Debug.Log(hit);

                // Store the Rigidbody of the hit item
                itemRigidbody = hit.rigidbody;

                // Set item as child of itemContainer and adjust its properties
                hit.transform.SetParent(itemContainer.transform);
                hit.transform.position = itemContainer.transform.position;
                itemRigidbody.isKinematic = true;
                hit.collider.isTrigger = true;
                itemHeld = true;
            }```
rich adder
rocky canyon
#

if they all have rigidbodies the code will work for all of em

timid oriole
#

oh

rocky canyon
#

your only gonna be holding 1 at a time yes?

timid oriole
#

yes

#

okay so

#

rigidbody that I created is empty

#

and basically the item we hit

rocky canyon
#

see here? this happens when u click..

#

NOW you have that reference..

timid oriole
#

we are taking its rigidbody and storing it in there so i can later drop it?

rich adder
#

/ Store the Rigidbody of the hit item
itemRigidbody = hit.rigidbody;

if(!itemRigidbody) return 😏

rocky canyon
#

when u Drop it however you do.. u can just use itemRigidbody.isKinematic = back to false

#

drop it

#

set itemHeld back to false..

#

etc

timid oriole
#

so same thing for collider to then no?

#

don't I need a refernce

rich adder
timid oriole
#

and store it like we did with rb

rich adder
#

but you already have rigidbody to grab collider from

rocky canyon
#

^ magic

rich adder
#

myrigidbody.TryGetComponent(out Collider col)

timid oriole
#

you can grab a collider through a rigidbody?

rocky canyon
#

u can attempt to grab anything from anything

timid oriole
#

that is some magic indeed

timid oriole
#

rb = Getcomponent<BoxCollider>();

rocky canyon
#

if ur rigidbody also has an Image Component u can say myRigidbody.GetComponent<Image>();

rich adder
rocky canyon
#

and grab an image from it

timid oriole
rich adder
#
if(myrigidbody.TryGetComponent(out Collider col))
col.isTrigger = false;
timid oriole
#

so does tryGetComponent just grab it and store it

rich adder
rocky canyon
#

itemRigidbody = hit.rigidbody; this part of ur code can error... say u hit a collider that doesn't have a rigidbody..

#

you'd need to check if it actually has one before u assign it..

#

w/ a TryGet it does it all in 1 step

timid oriole
#

Tryget sounds a bit confusing lol I've only used Get

rich adder
#

its the same thing but with a null check

#

thats why the operation returns a bool

rocky canyon
#
                 // Try to get the Rigidbody component from the hit object
                if (hit.transform.TryGetComponent<Rigidbody>(out itemRigidbody))
                {
#

like so

#

if theres a rigidbody it automatically assigns it to itemRigidbody if theres not. it does nothing

timid oriole
#

So that would be inside the if Input blablablah ?

rocky canyon
#

inside ur raycast and input stuff

#

yes

rich adder
#

that goes when you try to assign it

rocky canyon
timid oriole
#

what does the out repersent

rich adder
#

its a way to return values from a method without changing the actual return method type
so you can return multuple values and still reutrn 1 value from method
In this case bool is method return type and out gets the component found if any

rocky canyon
#

i have a Rigidbody reference called itemRigidbody .. it just assigns it to that variable

timid oriole
#

I see

rocky canyon
wintry quarry
timid oriole
#

so basically just says if its not null slap it onto itemrigidbody the component?

rocky canyon
#

exactly..

timid oriole
#

and if it doesn't have one don't do anything

rocky canyon
#

yup

#

that way u wont get errors when ur trying to set isKinematic on a collider that didnt have a rigidbody inthe first place

#

or something close to that

timid oriole
#

what is this part then col.isTrigger = false;?

rich adder
#

its trygetcomponent that prevents that

rocky canyon
#

or ignores it?

rich adder
#

does it or it skips the whole operation if its fals on tryget

rocky canyon
#

liek say i already had a reference in there.. and i tryget on a object w/o one

#

would it reset it to null.. or leave it how it was?

rich adder
#

if im not mistaken it will not touch the field at all

rocky canyon
#

i ask b/c i manually set it to null

rocky canyon
rich adder
rocky canyon
#

cool cool.. im smarter than i think i am sometimes

#

😅

timid oriole
#

like this?*

rich adder
rocky canyon
#

way too low in the function

timid oriole
#

oh

rocky canyon
#

u should do it before u do any of this stuff

timid oriole
#

that makes sense

#

how can it alter values it doesn't have access to

summer stump
# timid oriole like this?*

That log should be BEFORE the if statement, as box said a long time ago.
You may not need it anymore, but it is not super useful there

Just something to know for the future

rocky canyon
#

and instead of hit.rigidbody.. u can just use storedRB.isKinematic etc

rich adder
# timid oriole oh

also the type here is already implied as being Rigidbody through the variable you are assigning to out, you dont need the <Rigidbody>

rocky canyon
#

use the variable u stored

#

not the hit

#

only use the hit to store the RB

timid oriole
rocky canyon
#

how long have u been workin in unity? how many lessons have you done?

summer stump
timid oriole
rocky canyon
#

oh okay.. i was just curious

timid oriole
#

yep lol still fairly new just setting a goal to make a game once a week

#

as long as I'm learning something new yk

rich adder
#

storeRB = hit.rigidbody defeats the whole point of doing a tryget lol

timid oriole
#

oh?

rich adder
#

the out automatically assigns it

timid oriole
#

ahh

#

yes

rocky canyon
#

peep this for a second..

        if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, rayCast))
        {
            if (Input.GetKey(KeyCode.E) && hit.collider.CompareTag("Item"))
            {
                Debug.Log(hit);

                // Try to get the Rigidbody component from the hit object
                if (hit.transform.TryGetComponent<Rigidbody>(out storedRb))
                {
                    // Get the Collider component from the stored Rigidbody
                    storedCollider = storedRb.GetComponent<Collider>();

                    // Set item as child of itemContainer and adjust its properties
                    hit.transform.SetParent(itemContainer.transform);
                    hit.transform.position = itemContainer.transform.position;
                    storedRb.isKinematic = true;

                    // Ensure the collider is retrieved and set its properties
                    if (storedCollider != null)
                    {
                        storedCollider.isTrigger = true;
                    }

                    itemHeld = true;
                }
                else
                {
                    Debug.LogWarning("Hit object does not have a Rigidbody component.");
                }
            }
        }```
#

ofc thats way more complicated than it even needs to be.. but my own example uses interfaces

#

that'd be even more confusing

timid oriole
#

we are assigning collider to rigidbody?

rocky canyon
#

storedCollider is a collider..

#

storedRB is a rigibdoy

timid oriole
#

yeah but you said storedcollider = storeRb no?

rocky canyon
#

this sets a collider to the Rigidbody's collider

#

it sets the left side to equal the right side

#

this = that; <--- this becomes the value of that

summer stump
#

If you just store the hit, you will have access to both

rocky canyon
#

^ big brain

timid oriole
#

yeah I know that part im confused how you can assign two different components to equal that

rocky canyon
#

RaycastHit myStoredHit;

summer stump
rocky canyon
#

get the collider from the rigidbody ^

#

2 weeks i figured you'd know what GetComponent does pretty well

#

one of the first things i learned after Debugging ofc

rocky canyon
timid oriole
#

okay how are we getting a collider from a rigidbody if it doesn't even have a collider yet ?

rocky canyon
#

it'd be so simple to store the hit and get everything you need from the hit

timid oriole
#

because we are getting it in the same line

rocky canyon
#

so it isnt a problem

rich adder
rocky canyon
#

but we run getcomponents anyway..

#

idk. TryGets are way better.. but can they get implemented

#

thats teh question

rich adder
#

but now everytime you gotta change something you have to run GetComponent

rocky canyon
#

ok fair.. 🙌

rich adder
#

I def do keep a field for raycast hit though

#

especially for gizmos n stuff

dusty shell
#

If an object has multiple colliders, is there a way to know which is colliding?

rocky canyon
#

we DUMPED alot of info on Nicholas

rich adder
rocky canyon
#

yea, im hoping he can find a method that works for him

rich adder
summer stump
timid oriole
#

I'm honestly very confused but understand the general sentiment of storing components using hit or tryGet

summer stump
#

You can check some property of it like radius if they are different

rocky canyon
dusty shell
summer stump
rich adder
timid oriole
dusty shell
rocky canyon
#

what navarone just said is the general purpose of the info dump.

summer stump
timid oriole
rocky canyon
#

if u try to store a rigidbody.. you need to check if it even exists before using it...

#

tryget helps u avoid having extra if conditionals

#

to check if != null

rich adder
rocky canyon
timid oriole
#

if out assigns it

rocky canyon
#

you just plop in one of ur own variables

#

and it'll get assigned

#

you then have that variable to use all thruout ur script

rich adder
timid oriole
#

no i mean like we use out variable name to assign it in the parameters

#

is there an In instead of out

#

would it take it away

rocky canyon
#

if u dont want it anymore u just set it to null manually

rich adder
#

there is a in keyword but its not for what you think

rocky canyon
#

else { storedRB = null; }

timid oriole
rocky canyon
#

thats if u miss a raycast for example

rich adder
#

yes the TryGet returns a bool

#

also you can check there

rocky canyon
#

if it doesnt hit anything clear out ur storedRb

#

for the next time u try

summer stump
#

out Type name makes a new local variable, unrelated to anything else

out existingName assigns it to an existing variable

rocky canyon
#

^ heck yea

summer stump
timid oriole
#

the first one because you couldn't access it outside of that area?

rocky canyon
#

yea thats something to think about

#

it'd be local to taht function

summer stump
#

That is the point of local variables. Why would that be bad?

#

It is good if you don't want to access it outside of there.

#

Bad if you DO want to

rocky canyon
#

but if u wanted it to be accessible thru the entire script u'd use the existing variable.

#

its just choices

rich adder
#

you dont always need to assign a field if ur doing a one time thing

timid oriole
rich adder
#

maybe a health hit or something

rich adder
#

including if statement

rocky canyon
#

local would be within the brackets it got assigned in

#

{ to --> }

rich adder
#

but it wont work outside statement cause it will be null anyway

summer stump
timid oriole
rocky canyon
#

{ scope }

rich adder
#

using it outside of if statement would not make sense

summer stump
rocky canyon
#

waht bout the else of that if

timid oriole
slender nymph
#

technically it would be accessible throughout the rest of the scope that the if statement is in, not just the if statement's own scope

rocky canyon
#

ya,,, thats what i was thinking

summer stump
#

Yeah, I was trying to think of how to explain that and kept restarting. That is better

rich adder
#

it will just be worthless to use cause it could be empty

rocky canyon
#

ur IDE will let u know when u try

timid oriole
#

so the entire method that its located in

summer stump
rich adder
summer stump
#

The outer scope holding the if, if you write it in the condition

slender nymph
#

i frequently use TryGetComponent as a guard clause like

public void Foo()
{
  if(!TryGetComponent(out Bar bar)
    return;

  bar.DoStuff();
}
rocky canyon
#

heheh..

rich adder
#

I should do this more, it would clean up my TryGet

rocky canyon
#

Round [2]! Fight

timid oriole
#

so this would work then void MrPotato()
{

if (can < bigCan)
{
vector3 potato;

}
potato = null?
}

rich adder
#

I like early return pattern anyway no idea why i didn't think of that lol

slender nymph
cosmic dagger
#

early return is life . . .

timid oriole
timid oriole
#

only game objects and things that exist makes sense

slender nymph
timid oriole
#

like components too

summer stump
#
void MyMethod() 
{
  if (x == null)
  {
    if (Raycast(out Foo bar)
    {

    }
   < accessible here
  }
  < not here
}

timid oriole
swift crag
rocky canyon
#
void MrPotato()
{
    Vector3 potato = Vector3.zero;

    if (can < bigCan)
    {
        potato = new Vector3(1, 1, 1);
    }
    else
    {
        potato = Vector3.zero;
    }
}```
#

if u declare potato before the if.. u can use it in the if and the else

#

and even after the else

rocky canyon
#

nick said it not me

#

¯_(ツ)_/¯

#

lol

rich adder
#

if(potatoes < needed) // famine

timid oriole
#

I want to make a game out of this genius concept

rocky canyon
#

go for it

#

need a potato model?

timid oriole
#

navarone will hit me with a copyright strike

rocky canyon
#

most likely

timid oriole
rocky canyon
#

hey! me too

timid oriole
#

I'll make it a sparkly potato and turn the specular up

rich adder
timid oriole
rich adder
rocky canyon
#

is that perpetual energy potato?

timid oriole
#

I think they use that in space don't they because they don't have power there like as a power supply of sorts

rich adder
rocky canyon
#

ahhh portal references

rich adder
#

actually let me not topic lol

rocky canyon
#

never played 😄 im aware of the cake

rich adder
#

they have a special circle in hell for you xD

rocky canyon
#

😈

rich adder
#

if not one of the best puzzle games made

timid oriole
#

what's portal lol?

rich adder
timid oriole
#

reminds me of minecraft a bit based off the video

timid oriole
rich adder
#

funny

rocky canyon
rich adder
timid oriole
rich adder
ashen ridge
#

how can i pass more than 1 argument using an slider ui?

timid oriole
summer stump
rocky canyon
#

he meant Zoomer i believe 😛

rich adder
timid oriole
#

ohh

slender nymph
rocky canyon
#

ohh this is osmething i need to know 👀

timid oriole
#

I don't use social media besides youtube but I saw moist critical react to skibidi toilet. I feel bad for the up and coming generation im 19 so i experinced peek gaming aka mario galaxy & pokemon platnium

rocky canyon
#

i gamed in black and white >8)

summer stump
#

I am so sad right now, that either of those games are considered peak gaming

timid oriole
rocky canyon
timid oriole
summer stump
rich adder
rocky canyon
# timid oriole I wonder what gamin was like back then fr

Glider is a Macintosh game written by John Calhoun. The first version of the game was released in 1989. The main task is simply to avoid a collision with the floor or obstacles such as furniture. A puzzle element has been added to the game in the form of switches that control air vents, lighting, and even enemies.

Please like this video and sub...

▶ Play video
timid oriole
timid oriole
rocky canyon
#

lol.. they were maxing out their RAM on those games

rich adder
timid oriole
#

gam dev back then must have been real rough

#

oh

swift crag
#

Programming for old consoles is particularly interesting.

rocky canyon
swift crag
#

Lots of very severe design constraints.

timid oriole
#

didn't they make a show for that on netflix

rocky canyon
#

designing with constraints always ends up awesome

ocean blaze
#

hey does anyone no how to temp stop an animation im changing my font for my game and it has resizing animations and is a little buggy but i wanna keep but wanna stop temp anyone know?

timid oriole
#

my younger sister loves it

#

unless its something diff

rich adder
#

idk if they remade it or playing the OG

chrome shadow
#

hi guys what is the error in this code? :

    TextMeshPro txt = Layer1.GetComponentsInChildren<TextMeshPro>();
#

i already got
using TMPro;

rocky canyon
#

its TMP_Text

chrome shadow
#

its still not working

swift crag
#

TextMeshPro is a valid type name

#

What is the problem?

rocky canyon
swift crag
#

"It's not working" is not helpful

chrome shadow
swift crag
#

Read the error.

rocky canyon
swift crag
#

TextMeshPro and TextMeshProUGUI are the concrete component types.

#

TMP_Text is a parent of both

summer stump
#

Ah, box got it. ComponentS
That returns an array

rocky canyon
slender nymph
#

TextMeshPro is the non-ui tmp text

cosmic dagger
#

that's the 3d text version . . .

rocky canyon
#

thanks, noted it

chrome shadow
#

what does the [] represent

rocky canyon
#

its an array

summer stump
#

An array

cosmic dagger
#

an array . . .

chrome shadow
#

ah

#

thanks

rocky canyon
#

[TripleKill]

late burrow
#

how to compare types including parents

rich adder
#

you mean like is ?

languid spire
wintry quarry
#

Usually with is

late burrow
#

yeah but it only checks for exact type

wintry quarry
late burrow
#

yeah i wasnt sure if isassignablefrom works

wintry quarry
#

No is works for child types

#

You can do if (someRigidbody is Component c)

late burrow
#

so any array type would match with system.array and everything would match system.object

#

that way of compatibility

languid spire
stuck palm
#

how can i serialise a scriptable object?

slender nymph
slender nymph
slender nymph
#

create a class or struct to hold the data that you want to write to disk and serialize that. then just save/load that data to/from the SO at runtime

stuck palm
#

don't actually need to serialise the whole thing

slender nymph
#

i don't see how that is relevant to serializing a scriptable object 🤔

stuck palm
bleak glacier
#

I also have a little problem of my own. I found this code that uses the new input system to detect when a collider is clicked. The issue is I don't know how to make the script detect which collider it is clicking. It only detects that a collider was clicked.

    private void Awake()
    {
        _mainCamera = Camera.main;
    }


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

I'm assuming it has something to do with the line if (!rayHit.collider) return;

slender nymph
#

that is the check to see if nothing was hit. the rayHit variable contains info on what was hit and if the code after that line is running that means something was hit

bleak glacier
slender nymph
#

don't just blindly copy code. actually look at what it does and research methods used

bleak glacier
minor crown
#

My character's feet are sliding on the ground behind the body, what could it be. I'm making a Ragdoll player and using a configurable joint for that.

polar acorn
slender nymph
summer stump
#

Have you profiled?

lusty nest
short tusk
#

Hey all, just following the tutorial on Junior Programming and all is well except when it came to the step of changing the player controls to make the vehicle I am working on actually turn rather than just slide left and right. I have checked my code and this line provided in the example seems to work for them but does nothing for me. Anything I am missing?
This is the line that seems to do nothing.
transform.Rotate(Vector3.up, Time.deltaTime * turnSpeed * horizontalInput);

rocky canyon
#

whats ur turn speed?

#

if the code is the same, its probably that ur setup is a bit different than theres

short tusk
#

Was set to 0, tried changing it in the code but maybe need to change in Unity rather?

rocky canyon
#

check inspector values, ur hierarchy, and the components on the objcts

#

yes, change it in unity inspector

#

the inspector value overwritse the coded value

whole parcel
#

i have a tilemap of pellet rule tiles. how would i access the gameobject for each pellet in code?

short tusk
#

Yep that did it, it was working but since turn speed was zero it wasnt moving. Thank you thank you!
Quick follow up question though, why does it seem in the tutorial they are hard coding these values? They clearly set turnSpeed = 45.0f but you are right they then change the inspector value as well. Whats the point in coding that value then?

remote osprey
#

Feels like I'm abusing this chat but

#

When should I do a factory pattern as an interface vs an abstract class?

#

I have no idea how to predict if I i'll need to use properties in my factories later on

#

Plus, should I make my factory methods static?

#

That seems so much easier

#

Everywhere I look people are saying to do one or the other, it' been very confusing

rocky canyon
#

once u save it tho... and change it the 2nd time. that value in the inspector wont change on its own

whole parcel
#

what's an invalidcastexception

#

nvm fixed

languid spire
rocky canyon
#

note this doesnt apply to changing it during runtime

#

if u change the variable in ur code it will change in the inspector (at runtime)

whole parcel
#

right

#

👍

iron wing
#

hi. im still having a lot of trouble making limited air control for my character controller using the move(); method

slender nymph
rocky canyon
#

its a pretty complicated system for CC.. like i said yesterday.. its gonna take a while to get it working the way u want

#

the key is groundMovement + airMovement <-- pass the result of both vectors into the Move() function

#

and ur calculating them differently.. (airMovment has a slower speed) both are being dampened (trying to get to zero).. soo if u were running and jump and then release the keys.. you still move forward a bit.. until the dampen slows u down enough to stop moving forward (airMovement gets to 0)

vast sandal
#

Is there any Vector3 of an object with the (transform.right, transform.up, transform.forward) axis?

rocky canyon
#

how can 1 vector be 3 different directions?

slender nymph
vast sandal
vast sandal
slender nymph
#

use transform.TransformDirection to convert your input from local space to world space relative to the transfor you call that method on

rocky canyon
#

Camera.main.transform.forward;

swift crag
#
foo.forward
foo.TransformDirection(Vector3.forward)

these are equivalent!

vast sandal
#

could you elaborate?
Im working with a rigid body component and was trying to use playerRigidBody.linearVelocity = movementVelocity;

swift crag
#

figure out what your frame of reference is and use its transform to turn your movement input into a world-space direction

vast sandal