#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 184 of 1

tepid summit
#

idk

hexed terrace
tepid summit
#

i was just offering ideas

#

so get rid of the down

#

i did

nimble apex
#

if you only take F=ma and terminal velocity into account lol

#

without any other complex stuff

modern sinew
#

Hi all! trying to get a retro 2d platformer to work but have problems with the jump mech; it fails to check that the player is only on the ground when jump is allowed. Also I want the player to jump using the UpArrow && LeftArrow || RightArrow.

I tried several things, the last thing I have worked well if I only checked for ArrowUp for jump but I need the combo to simulate the old game I'm going for. I use Input.GetAxis for horizontal movement. (So this code still enables the player to keep jumping mid air).

`if (hit != null)
{
grounded = true;
}

if (grounded && Input.GetKeyDown(KeyCode.UpArrow) && Input.GetKey(KeyCode.LeftArrow))
{
body.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
grounded = false;
}`

teal viper
hexed terrace
#

(grounded && (uparrow && (leftarrow || rightarrow))

earnest atlas
#

Unity imput system to the resque

#

Set it to return vector and check if its 1,0,1

modern sinew
earnest atlas
#

Why you want exactly those combinations?

hexed terrace
#

because they want to only jump up+left or up+right..

modern sinew
hexed terrace
scarlet skiff
rare basin
scarlet skiff
#

sorry, meant JumpIncrease

rare basin
#

anyway this is terrible architecture, you might want to change it

scarlet skiff
#

ye id need to use loops n such here too

modern sinew
rare basin
#

entire Update() is unreadable

scarlet skiff
#

id just want it working for now

rare basin
scarlet skiff
#

then id clean up

earnest atlas
#

else if ๐Ÿ˜„

scarlet skiff
#

middle parameter is JumpIncrease

rare basin
#

it would

earnest atlas
#

yeah it should

scarlet skiff
#

timeSinceCharge works as it should, and relaod bar value is always at 1 when i test

rare basin
#

Debug.Log it then

#

in the Jump() method

#

clampedForce *= jumpIncrease; after this line

earnest atlas
#

Why Im getting this unity error?

rare basin
#

you already asked that like 3 times last week

#

it's a unity error, you can ignore it

earnest atlas
#

I couldnt have asked it 3 times

#

And its a unity error sure does not sounds convincing

scarlet skiff
#

seems that the jumpIncrease is either 1 or 1.25

#

and i can see why

#

the else if, right?

#

or wait no that doesnt make any sense

modern sinew
waxen aurora
hexed terrace
earnest atlas
modern sinew
# earnest atlas How you are checking ground?

`Vector3 max = box.bounds.max;
Vector3 min = box.bounds.min;
Vector2 corner1 = new Vector2(max.x, min.y - .01f);
Vector2 corner2 = new Vector2(min.x, min.y - .01f);
Collider2D hit = Physics2D.OverlapArea(corner1, corner2);

bool grounded = false;

if (hit != null)
{
grounded = true;
}`

earnest atlas
#

Maybe use rayhit?

#
 private void IsOnGround()
 {
     if (_isGrounded) return; //If grounded just returns. This was made for animator.
     var hit = Physics2D.Raycast(transform.position, _rayDirection, 2, _groundLayer);
     _isGrounded = (hit.collider != null && hit.distance < 0.51f);
     if (!_isGrounded) return;
     _lastPositionOnGround = gameObject.transform.position;
     _animator.SetBool("IsJumping", false);
 }```

This is my rayhit logic with animator changes
#
    private readonly Vector2 _rayDirection = Vector2.down;```
ray direction
modern sinew
earnest atlas
#

So far it have not failed me. You can change hit distance values depending on where is you character center

#

You know how masks work? Your ground is on different layer?

modern sinew
timid saffron
#

ball not visible when this scripts added to it

#

when removed it reappears

earnest atlas
#

ehm

#

you are setting transform to null

#

what was you plan here?

timid saffron
#

Even if i set it to some numbers its the same

timid saffron
#

plan cool

earnest atlas
#

what numbers you were setting it?

timid saffron
#

to make the ball progressively get bigger

timid saffron
#

Ill show you

earnest atlas
#

what did you expect?

#

I think unity just rounded it to 0

#

not like it would be visible anyway

#

transform.localScale

timid saffron
timid saffron
earnest atlas
#

no you are setting it to that value

hexed terrace
#

this is the value you entered, represented differently

timid saffron
gaunt ice
#

no

#

you just set it, nothing got multiplied

earnest atlas
#

Yeah that, if you wanted to multiply it you needed to get original scalke

#

you could have done it like this

earnest atlas
#

transform.localscale *= multiplier

timid saffron
#

i got some parts wrong. it says frame

#

not original size

#

misremember

earnest atlas
#

beware thats gonna make your scale go to infinity

#

If you want to dinamically scale it save starting scale at start

timid saffron
#

why is it different in 2d than 3d?

#

this logic

rare basin
#

it's not

earnest atlas
#

its not?

timid saffron
#

then why couldnt i simply use
public vector2 ball
transform.localscale += ball

earnest atlas
#

it wouldnt multiply the size each second

#

its going to multiply it each frame

gaunt ice
#

2d is 3d without one axis

earnest atlas
#

well 2d is 3d in a trenchcoat

keen dew
#

You can, but that's not what you had. You had = not +=

timid saffron
#

yeah i forgot that

#

@earnest atlas

#

you wrote public int

#

so I cant set the number to 1.2 for example

#

there was another variable that you could do this

rare basin
#

then change it to float?

timid saffron
#

๐Ÿ‘

#

thanks

earnest atlas
#

I didnt write public int

#

most of unity values are float

timid saffron
#

yeah you didnt. my bad. visual studio auto correccted the code i think

rare basin
earnest atlas
#

arent they?

#

I mean if we dont consider classes

#

You can set most of things as float

rare basin
#

such as?

earnest atlas
#

I mean size, dimensions, etc

rare basin
#

ok, thats 1 component

gaunt ice
#

for geometric data

rare basin
#

most of the unity

earnest atlas
#

Let me eat in peace god sake

rare basin
#

but you are calling

earnest atlas
#

tell me what is not int

#

give us a list

rare basin
#

why would i waste time on that?

earnest atlas
#

then why would I waste my time on that too?

rare basin
#

just to prove some random user something

frosty hound
#

Stop bickering

timid saffron
timid saffron
rare basin
#

you have the error in the console

timid saffron
#

operator += is ambiguous on operands of ...

rare basin
#

localScale is Vector3

timid saffron
#

i just used += in my 3d project

#

it didnt give this error

rare basin
#

Changescale is Vector2

#

you need a Vector3 variable to add it to localScale

earnest atlas
#

+=
is value = value + something

#

same with every other

timid saffron
earnest atlas
#

transform.localscale is already a variable

rare basin
#

but what did you do here

earnest atlas
#

you dont need to name it

rare basin
#

why did you add the new keyword

#

and that line in Update() is completely wrong

earnest atlas
#

where is new?

#

Ah i see

#

my guy needs C# guide more then unity

timid saffron
#

Im gonna take courses on it but i gotta finish unity essentials pathway first

#

and they asked me to change 2d ball scale like i did in 3d

earnest atlas
#

you cant finish unity essencials without knowing C#

rare basin
#

create public Vector3 type variable

#

and then add that vector to localScale vector from transform component's property

earnest atlas
#

you are trying to build a roof over un-existing house

timid saffron
#

thats all

vocal mauve
#

Hello everyone i'm a new beginner for unity currently following a tutorial on udemy. Can i ask a question here regarding to a code i wrote that doesn't seem to work like i wanted to?

earnest atlas
#

dont ask to ask if you can ask us an ask

rare basin
#

!code

eternal falconBOT
timid saffron
#

๐Ÿ‘

#

we are good

#

no errors

vocal mauve
#

my question is the i am trying to code in a dot aim mechanic where the sword is thrown in the generated dots arc it should be aimed whereever my mouse is but for some reason it doesn't i have taken a video of it on my phone and i don't know if it is against the rules or not?

earnest atlas
#

i belive u can

timid saffron
#

i think this is it

vocal mauve
hexed terrace
hexed terrace
vocal mauve
#

i see so there is an error in my line 81 and so on i should focus on there

hexed terrace
#

85

vocal mauve
#

Thank you man i will try find a solution over there hope i can ๐Ÿ™‚

vagrant pebble
#

hi i have a problem

#

I have the code that causes the slide to be detected and the lightning to be created in its direction and position
It creates lightning in the wrong place
why is it happening?

rare basin
#

show the code maybe?

#

how can we know what is going on

vagrant pebble
#

ok i send

hexed terrace
#

!code

eternal falconBOT
vagrant pebble
#

!code

eternal falconBOT
vagrant pebble
#

void Update()
{
if (Input.touchCount == 1) // user is touching the screen with a single touch
{
Touch touch = Input.GetTouch(0); // get the touch
if (touch.phase == TouchPhase.Began) //check for the first touch
{
start_t = touch.position;
end_t = touch.position;
}
else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
{
end_t = touch.position;
}
else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
{
end_t = touch.position;
Vector3 direaction = end_t - start_t;
transform.position = direaction;
angle = Vector2.Angle(Vector2.right, direaction);
if (start_t.y > end_t.y && angle > 10 && angle < 100)
{
angle = -angle;
}
else if (start_t.y > end_t.y && angle > 110 && angle < 200)
{
angle = -angle;
}
transform.rotation = Quaternion.Euler(0, 0, angle);
lightning.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle + 90));
Vector3 mousePos = Input.mousePosition;
mousePos.z = distance_z;
MousePosition = mainCamera.ScreenToWorldPoint(mousePos);
MousePosition.z = distance_z;
transform.position = MousePosition;
lightning.transform.position = transform.position;
//efect_lightning.Play();
//StartCoroutine("active_collider");
}
}
}

rare basin
vagrant pebble
#

i didnt understand

#

i dont know english very well

rare basin
#

so you didint understand and just decided to send it anyway in a wrong way

vagrant pebble
#

oh i got it

#

'''

void Update()
{
    if (Input.touchCount == 1) // user is touching the screen with a single touch
    {
        Touch touch = Input.GetTouch(0); // get the touch
        if (touch.phase == TouchPhase.Began) //check for the first touch
        {
            start_t = touch.position;
            end_t = touch.position;
        }
        else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
        {
            end_t = touch.position;
        }
        else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
        {
            end_t = touch.position;
            Vector3 direaction = end_t - start_t;
            transform.position = direaction;
            angle = Vector2.Angle(Vector2.right, direaction);
            if (start_t.y > end_t.y && angle > 10 && angle < 100)
            {
                angle = -angle;
            }
            else if (start_t.y > end_t.y && angle > 110 && angle < 200)
            {
                angle = -angle;
            }
            transform.rotation = Quaternion.Euler(0, 0, angle);
            lightning.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle + 90));
            Vector3 mousePos = Input.mousePosition;
            mousePos.z = distance_z;
            MousePosition = mainCamera.ScreenToWorldPoint(mousePos);
            MousePosition.z = distance_z;
            transform.position = MousePosition;
            lightning.transform.position = transform.position;
            //efect_lightning.Play();
            //StartCoroutine("active_collider");      
        }
    }
}

'''

#

like this?

rare basin
#

no

#

!code

eternal falconBOT
rare basin
#
`
#

'

#

2 different characters

vagrant pebble
#

Oh

#


    void Update()
    {
        if (Input.touchCount == 1) // user is touching the screen with a single touch
        {
            Touch touch = Input.GetTouch(0); // get the touch
            if (touch.phase == TouchPhase.Began) //check for the first touch
            {
                start_t = touch.position;
                end_t = touch.position;
            }
            else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
            {
                end_t = touch.position;
            }
            else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
            {
                end_t = touch.position;
                Vector3 direaction = end_t - start_t;
                transform.position = direaction;
                angle = Vector2.Angle(Vector2.right, direaction);
                if (start_t.y > end_t.y && angle > 10 && angle < 100)
                {
                    angle = -angle;
                }
                else if (start_t.y > end_t.y && angle > 110 && angle < 200)
                {
                    angle = -angle;
                }
                transform.rotation = Quaternion.Euler(0, 0, angle);
                lightning.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle + 90));
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = distance_z;
                MousePosition = mainCamera.ScreenToWorldPoint(mousePos);
                MousePosition.z = distance_z;
                transform.position = MousePosition;
                lightning.transform.position = transform.position;
                //efect_lightning.Play();
                //StartCoroutine("active_collider");      
            }
        }
    }


#

Here we go

#

Right?

north kiln
#

You can edit your posts instead of keeping massive blocks of incorrectly formatted text around notlikethis

rare basin
#

that's too easy

vagrant pebble
#

Sorry about that I'm not very good at these things

#

So you can help me?

frigid sequoia
#

Can I like... create a method constructor that shares values with another one but is different? Like I want a method to generate a random position in a plane around a point and one constructor is min and max distance and I want another to be like max distance and a random Y offset; and they are all floats, so... is there a way to do this or do I have to just create another method for it?

earnest atlas
#

wdym?

#

example

rare basin
#

with different overload

#

public Vector3 GenerateRandomPosition(Vector3 center, float maxDistance, bool useRandomYOffset)

#

public Vector3 GenerateRandomPosition(Vector3 center, float minDistance, float maxDistance)

#

you can create as many overloads as you want

frigid sequoia
#

These are the ones I have, I want to add one that is just min and max distance; but there is already one with 2 floats as given values

rare basin
#

or you can use default parameter values

#

right, so you can just shorten it

#

to 1 function

#

public Vector3 GenerateRandomPosition(Vector3 center, float maxDistance, bool useRandomYOffset = false)

rare basin
#

you can shorten aswell by using default parameters

frigid sequoia
#

Sure, I am having issues visualizing it rn, could you make an example with my parameters pls?

rare basin
#

public Vector3 GenerateRandomPosition(float maxDistance = -1, float minDistance = -1, float randomYValue = -1)

#

for instance

#

then just check if a certain float isnt -1

#

and you can call that function whatever way you want

#
GenerateRandomPosition(); //all floats -1
GenerateRandomPosition(10); // maxDistance  will be 10
GenerateRandomPosition(10,10); //max and min distanec will be 10
#

etc

late bobcat
frigid sequoia
#

So I would have some conditionals to check the given values, and for example all -1 would return like nothing at all?

rare basin
#

but yes you'd need some conditional checks

#

otherwise it would apply the default value

#

which is -1

frigid sequoia
#

Yeah, I am not using negatives for these one, so -1 doing nothing is what I am gonna do, thxs ๐Ÿ˜„

open apex
#

In this specific code, they are using string.format for a clock
how does {0:00} and {1:00} work together? I am very confused

#

it works like this

rare basin
#

you can lookup string.Format() docs

open apex
earnest atlas
#

Ah that 1 is placeholder index

#

at least this what Ive gotten

#

So if u want hours,minutes,seconds you will write {0:00}:{1:00}:{2:00}

open apex
#

that makes more sense

#

so the 1 is a placeholder for the next value

#

alright

earnest atlas
#

No, its just an index

open apex
#

aha

#

this stuff is really cool

#

I have been going over it for 10 minutes

#

it has really interesting properties

#

I was trying to create a variable in which I will hold for how many minutes the player has played the game

#

I realized it's easier if I just withold the information at what time he started playing and at what time he stopped

earnest atlas
#

delta time is not that variable

charred spoke
#

Why?

fierce shuttle
# late bobcat guys my game is dropping fps sometimes and spiking, i think it has something to ...

You could check the Profiler, maybe with "Deep Profile" on to see where you might be causing GC.Alloc to happen most often, if you suspect its a memory leak you should be able to see how much memory is being allocated, but it may not track down which script could be causing the leak, do you maybe have any events you subscribed to and did not unsubscribe or do any expensive operations in Update somewhere?

open apex
rare basin
earnest atlas
#

elapsedTime += deltaTime

#

havent seen +

open apex
#

so I cannot save "currentTime" and than do maths on it later on?

charred spoke
#

Your previous approach of adding up delta time was perfectly valid

earnest atlas
#

Forgor to limit spawn to 1 ๐Ÿ™‚

earnest atlas
rare basin
earnest atlas
#

Im just gonna block you ๐Ÿ™‚

rare basin
#

lol ๐Ÿคก

scarlet skiff
#

debug.log says its false, even when i dont move and still am touching the ground, i have an idle animation, but it doesnt move the players feet, but could its movements somehow trigger on colliosion exit?

rare basin
#

why do you keep checking things by name

#

that is a terrible idea

#

and which debug log? there isn't any

scarlet skiff
#

yes yes, ill work on that later, even my teacher told me to make names into variable on some sort of general static manager

scarlet skiff
rare basin
#

no, don't use names at all

#

to check for things

scarlet skiff
#

and is run in update

#

i understand tag can be more effecient, but im only gonna have one void

rare basin
scarlet skiff
rare basin
#

so share all the related code, not the code that isn't even related to the issue

scarlet skiff
rare basin
#

and what is the issue?

scarlet skiff
#

while still touching the ground, isTouchingGround gets set to false

buoyant knot
#

source: I do the same thing

rare basin
#

not neccesairly

#

you can set it to true on enter

#

and to false on exit

buoyant knot
#

not good enough

rare basin
#

no difference

buoyant knot
#

big difference

rare basin
#

such as?

buoyant knot
#

different things can happen that cause you to change your grounding variables in between, that need to be set correct when touching ground

#

such as if you jump when in contact with ceiling

earnest atlas
#

Im using raycast to check if Im on ground.

scarlet skiff
#

i never set my grounded variable anywhere

buoyant knot
#

or jump off floor while in contact with the same collider as a wall

scarlet skiff
#

except in thsoe 2 methods

buoyant knot
#

i have that sort of thing too. Iโ€™m telling you that you will want to check OnCollisionStay

rare basin
#

never had any issues and did a lot of projects without it

#

for ground checks, still I don't see any big difference like you said

scarlet skiff
#

commenting it out makes it always trye, so ye this was the problem

buoyant knot
rare basin
#

it's more of a design/architectuer issue

#

than the enter/exit implementation

#

all my Ground objects have IWalkable interface

buoyant knot
#

if you have a collider that can function as both wall and floor, you will have a problem

rare basin
#

why would I have such collider

#

separete one for wall, and separete one for ground

buoyant knot
#

because boxes have 4 sides lmao

rare basin
#

i don't get what you are saying

#

you talk about ceiling for example?

#

that it can be a wall and a floor at the same time?

buoyant knot
#

maybe it makes more sense for 3D, but for 2D sidescroller, you can easily touch a polygonal collider as you pass over a vertex

rare basin
#

still don't get it, since your ground check collider is on your feets

#

if you mean that i can somehow "touch" the ground while jumping and that will count as isGrounded = true

#

then you can just add if(!isJumping)

buoyant knot
#

this is what happens

#

first frame make contact as wall at side. next frame make contact as ground. That calls oncollisionStay

#

2D sidescroller

#

the box is not made of 4 edge colliders. it is one box collider

#

i can go into more detail later. but if you do ground checks by collision callbacks, you really need to check oncollisionstay

open apex
#

Why wouldn't my code work?

#

It start from 0 again when the scene gets loaded

frosty hound
#

Of course it resets, because you're starting Timer at 1 when this monobehaviour is initialized

#

Which will happen each time the scene is loaded

open apex
frosty hound
#

Yes of course

frigid sequoia
#

I am really confused rn; I have a Empty Prefab that just drops coins, this it meant to be called when a enemy dies; the enemy, tells the CoinDropManager what value it needs to drop changing a value, just as it is instantiated. The CoinDropManager, spawn coins prefabs and tells them a random position at which to transtion to over 1 sec, this is directly managed by the CoinDropManager and not the coins. So the enemy is destroyed with a bit of a delay after instatiating the CoinDropManager (0.2sec), the CoinDropManager has Coroutine in start that waits for a instant before dropping the coins (to let time to the enemy to set the value it actually has to drop), then in that same coroutine tells the CoinDropManager to be destroyed after 5 second (more than enough to make the position transition). So the issue is, the enemies sometimes drop the coins correctly and other they disappear mid animation, telling this error. What is happening and why it only happening sometimes?

frosty hound
#

Think through your logic a little bit

open apex
frosty hound
#

You have a brain for a reason

#

Every update you're saving the value of Timer (rounded)

#

If your Timer starts at 1 each time this object is initialized, what's the first value its going to save?

frosty hound
open apex
#

But I get confused when I am actually trying to do it

frosty hound
buoyant knot
# scarlet skiff so like this?

Make a separate method for โ€œCheckTouchGround(Collision2D collision)โ€ to reset everything centrally. you will later add more things to it for purposes of coyote time, one way platforms, etc. Both collision enter and stay should call this method so that what you do when touching ground stays consistent

open apex
#

the script it going to run everytime the scene loads, how can I make it run only when the game starts and not save it everytime?

#

These kind of things confuses me

frosty hound
frigid sequoia
frosty hound
#

No, they'll go in the root

frigid sequoia
frosty hound
#

Can you share your !code?

eternal falconBOT
frigid sequoia
#

This is the CoinDropManager

#

This is the relevant method from the enemy

buoyant knot
#

Also, you do not need to make separate functions for CheckGroundEnter and CheckGroundStay. OnCollisionEnter and OnCollisionStay should both call OnCheckGround

scarlet skiff
buoyant knot
#

OnCollisionEnter and OnCollisionStay both need to call a common method that just checks ground contact in a Collision2D

#

whether you made this ground contact in Enter vs Stay should not matter

#

but both enter and stay callbacks need to send you to the ground check

#

does that make sense?

#

later on, your ground check will get more complicated. You will have more variables, and more shit to manage/juggle. If you have two separate functions for enter and stay that are supposed to do the same thing, it is very likely that at some point, you will change one without properly changing the other.

#

I think your current GroundColStay would be the exact function I am calling CheckTouchGround

open apex
#

I understand everything, but what is #region PlayerPrefs keys and #endergion?

frosty hound
frigid sequoia
frosty hound
#

And how long is the time on a coin?

frigid sequoia
#

In fact the coins have a spawn animation and a despawn animation, they cannot despawn during the spawn animation at all

frosty hound
#

Your error suggests that a coin is being destroyed somehow, during the process of being transitioned

frosty hound
#

Which means you need to start digging ๐Ÿ˜›

swift crag
#

It lets you fold the region up

frosty hound
#

Do you have legacy code for destroying coins as a test? Keypress? When the player touches them? Or is there a chance that it is in fact, not always over 10 seconds for them to self destroy?

swift crag
#

It's strictly for organization. It doesn't mean anything to the compiler.

swift crag
#

actually, I don't think #endregion even needs a name

#

Oh god I found the Visual Basic docs while looking this up

frigid sequoia
#

They have a timer that starts ticking when they spawn, after it ends they satart a fadingin&out animation, which speed up every iteration, when it is fast enough, they are just destroyed

swift crag
#

Okay, yes, you don't provide a name when ending a region

frigid sequoia
#

They are also destroyed when the players touches them

open apex
frigid sequoia
buoyant knot
#

@scarlet skiff if you need to know more details, ping me later

frosty hound
#

Overall, you're relying on three different timers I can count alone, to all sync up perfectly. That's a recipe for disaster.

frigid sequoia
#

They are dissapearing way out of pickup range

#

But yeah, I have made a conditional to stop the spawn transition if the item somehow becomes null

frosty hound
#

You can avoid the root of the issue as much as you want, but the fact of the matter is your coins are destroying themselves before the coroutine moving them completes. How that happens, at this point I don't know. You can find it and bandaid fix it, or you can resolve the actual architecturalissue, it's really up to you.

open apex
#

@frosty hound Thanks for the help, I knew what the problem was but I was thinking that I could be wrong the whole time. So I thought it would be better for me to ask for help.

#

I fixed it ๐Ÿ˜Ž

swift crag
#

Bit of an annoyance with localization: I have an entry in a string table that's just a variable. The variable is another LocalizedString. It's not assigned by default; it gets something assigned when I use it.

#

This causes the editor to complain that it can't find a translation.

#

I presume it's because it gets an empty string.

#

I guess I should just assign some default value for that variable, so that this thing never evaluates to an empty string?

frigid sequoia
#

Like how else can I do this?

frosty hound
#

Without completely overhauling the general flow:

  1. Don't use coroutines

  2. Your CoinManager just needs to spawn in the [x] coins. It should then tell each coin where they should land. It shouldn't be responsible for moving them. So, once all [x] coins are spawned, the manager object can destroy itself (technically, you can just use an actual CoinManager singleton in your scene to do this instead of spawning a new one each time)

  3. Each coin will be provided their target position from the manager that spawned them.

  4. Each coin will move to that target position in their Update function. And when they've reached that position, begin counting down their timer in the Update function.

  5. If the timer reaches 0, destroy self

  6. If the player gets the coin first, destroy self

#

That way, regardless of how this coin is destroyed, it won't throw some error because nothing externally is referencing it.

buoyant knot
#

everything osteel is saying is right

#

one minor modification: When you plan to destroy self, call instead a โ€œDestroyCoin()โ€ method, and have DestroyCoin call Destroy

#

This will make it easier to set up object pooling in the future, or at the very least control timing

swift crag
#

It's also nice for when you realize you need to do other stuff when the coin is destroyed

#

immediately, rather than waiting for OnDestroy to run at the end of the frame

#

that also gives you a single place where you can say "actually, no, I won't be destroyed"

buoyant knot
#

all this is true

earnest atlas
#

no u in unity

frigid sequoia
#

Like I mean, yeah probably a general spawn coind manager for the entire scene; but I though it was way easier to just spawn an empty that spawned objects on its own

#

The timing between the transitions is not an issue whatsoever

#

Like it could be more organized, but is working just fine

#

The CoinManager prefab is working perfectly on its own

#

Just when the enemy spawn it is giving issues

tall storm
#

how can i increase gravity in a rigidbody

frigid sequoia
#

So I am guessing this has something to do with the step of instantiating the CoinDropManagger it self

faint sluice
tall storm
rich adder
tall storm
#

I just started unity, until now ive been making games in godot

rich adder
tall storm
#

ooh ok

#

@rich adder btw what would be the steps in coding a gun

#

like a pistol

frosty hound
#

Would be faster to find a tutorial on that

tall storm
#

oh ok

rich adder
#

learn how to instantiate, or raycasts etc.

tall storm
#

yea i found one from "Brackeys"

#

damn nvm its 6 years old stuff probably changed

rich adder
#

nothing really changed in 6 years

tall storm
#

oh so its good? with raycasts

rich adder
#

the code is exactly the same

#

just UI changes

tall storm
#

alr

rich adder
#

the only code that wont work is if you find a Unity tutorial that still uses UnityScript (Javascript-like code)

tall storm
#

๐Ÿ‘

#

I have an idea in mind but I first wanna learn the basics before making it

open apex
#
using UnityEngine.UI;

public class KamuSpotu : MonoBehaviour
{
    public Text text;
    public float printTime;

    void Start()
    {
        printTime = PlayerPrefs.GetInt("Timerr");
        printTime = printTime.ToString();

        text.text = "Just wasted",printTime.ToString(),  "minutes of your life. lmao";
    }

}

I am trying to make it so it prints the time, at first it didn't allow me to directly print it so I tried to convert it to a string and now it's not allowing me to converts the Integer to a string.

hexed terrace
#

printTime = printTime.ToString();
why would you even try to do this line?

open apex
#

my bad

open apex
rich adder
#

so make a variable for string..

hexed terrace
#

yes, obviously, but you don't need that line at all

#

you convert it to string on the text.text line

open apex
#

I tried to print it

#

It gave me an error

rich adder
#

text.text = $"bla bla bla {printTime} something"

open apex
tall storm
#

i just found this tutorial for shading an outliner and he creates a "Unlit Shader Graph" or something like that but i cant find it anywhere

hexed terrace
rich adder
#

ya

hexed terrace
#

gah, edit ;p

open apex
#

Ok

#

I will try that

open apex
#

text.text = "Just wasted",printTime.ToString(), "minutes of your life. lmao";
But why does this not work?

rich adder
#

ur missing +

hexed terrace
#

because it's completely the wrong syntax

rich adder
#

not commas

hexed terrace
#

you don't use , at all in string creation like that

open apex
#

oh

rich adder
open apex
open apex
#

I did replace the comma with a + before, but I replaced only one comma ๐Ÿ˜” and I was wondering why it wouldn't work

tall storm
#

yo navarone

open apex
#

I was born a programmer ๐Ÿ˜Ž

#

hah

tall storm
tall storm
open apex
tall storm
#

oh ok

open apex
#

this seems to related to UI

tall storm
#

its shading

open apex
#

or design

tall storm
#

but in the video he creates smth but its no longer in this version

open apex
#

send me the video

tall storm
#

alr

#

how to make outline shader in unity, outline shader unity, outline unity, unity outline, unity outline shader tutorial, unity gameobject outline, stroke unity, unity shader, unity how to make outline, unity easiest way, game development, game dev

============================================
๐Ÿ”ดCREDITS๐Ÿ”ด
============================================...

โ–ถ Play video
hexed terrace
open apex
#

what are the minutes

rich adder
#

You already want to work on shaders? you just started ๐Ÿ˜†

tall storm
#

r shaders complicated?

rich adder
#

yes but shadergraph makes it easier

tall storm
#

in the video he makes a "Unlit Shader Graph" or smth like that but i cant find it anywhere

rich adder
#

probably because you dont have the package

tall storm
#

Package? Like the input system one?

#

ooooh now i think i know how to get it

#

thanks

rich adder
#

why would the input system have anything to do with it

tall storm
rich adder
#

why would that be related to shader package lol

tall storm
#

idk but its a package

#

found it

rich adder
#

okk lol this isnt guess work

tall storm
#

thanks

rich adder
#

usually its included already in URP and HDRP

#

are you using BIRP?

tall storm
#

idk

#

i just created an empty 3d project

rich adder
#

just 3d , yes thats BIRP (built in render pipeline)

tall storm
#

a simple one

scarlet skiff
tall storm
#

oh ok

scarlet skiff
#

also for some reason i can triple jump now instead of double jump

#

i could just set the jump counter to one, which then would prob mean double jump but yk better to find out why

buoyant knot
livid frigate
#

Hi guys, how to make a game like Mini Metro?

buoyant knot
#

maybe itโ€™s time to set up coyote time

scarlet skiff
#

but i mean, its not that bad with it? splitting things up could make it a lil more effecient

#

but idk

scarlet skiff
buoyant knot
#

trust me, it will make coyote time simpler

#

coyote time is an amount of time where you are no longer grounded but allowed to jump

tall storm
#

yay i found it, the shader graph

#

thanks

buoyant knot
#

like wile e coyote, who would stand in midair for a bit

#

any good platformer needs coyote time. usually just a few frames

#

iโ€™ll explain how to set this up real quick

golden ermine
#

Hi, this is my script for car, but for some reason, whatever motor strength I put my car always goes same speed and I want it to go faster. This is my car script: https://hastebin.com/share/cemihocuni.csharp

scarlet skiff
buoyant knot
#

this will fix everything

#

right now you have
private bool isGrounded = false;
I want you to change it to this:

private float timeLastGrounded = -1f;
private bool IsGrounded => Time.time < timeLastGrounded + COYOTE_TIME;```
#

when you would set isGrounded to true, you instead set timeLastGrounded to Time.time

#

this is the timestamp of the last time we were on the floor

#

checking collision exit from ground is also not needed anymore because we do not need to set a flag to false. And instead of isGrounded as a bool field, we now have IsGrounded as a bool property that automatically checks the timestamp to see if we should count as being grounded or not.

#

do you understand what I am getting at, and why Iโ€™m doing it this way?

sand crest
#

Hi guys Saket here, I wanted to ask some doubts about my project, where can I post those doubts?

wintry quarry
wintry quarry
#

"doubt" is the Indian-English version of "question"

tall storm
#

yooooo navarone i did it

#

look

sand crest
sand crest
frigid sequoia
#

In my experience most doubts relate to code in one way or another....

sand crest
#

yeah exactly

rich adder
#

well you're in a code channel. ask away

sand crest
#

Ah I will need to phrase it in a proper way, will take some time lol

buoyant knot
frigid sequoia
#

About my previous issue, is there a way of calling a Debug.Log when an object is destroyed? Cause that would help a lot debugging

tall storm
#

How can i enable antialiasing in my project

queen adder
#

Hello! How can I see the unity console in a Dev Build (with errors, since thats what I wanna find)

summer stump
frigid sequoia
rich adder
tall storm
#

oh sorry

buoyant knot
#

easiest way to explain coyote time: How long does the coyote have in midair before he starts falling? Let him jump until then.

queen adder
summer stump
frigid sequoia
queen adder
#

bruh why does everyone ignore my issue

summer stump
summer stump
buoyant knot
#

and we are having like 4 different convos on this channel at once

queen adder
summer stump
polar acorn
rich adder
polar acorn
rich adder
#

ใƒฝ(ใ€‚_ยฐ)ใƒŽ

queen adder
buoyant knot
#

progress

polar acorn
buoyant knot
summer stump
queen adder
summer stump
buoyant knot
#

Yeah, iโ€™m just blocking him. Too little time for people who refuse to learn.

frigid sequoia
#

Okey, so trying to replicate my issue with the CoinDropManager, I think it had to do not with the movement transtion but with this particular line

stray pumice
#

what would be the best way to make a line of code wait.

buoyant knot
stray pumice
#

thanks

buoyant knot
#

but probably coroutine

frigid sequoia
swift crag
frigid sequoia
#

I don't know how this can be

swift crag
#

A common misconception:

void Update() {
  StartCoroutine(ThisTakesAWhile());
  Debug.Log("Hi");
}

This immediately logs "Hi". Starting a coroutine will not block the Update method.

buoyant knot
#

i think you have some deeper issues

swift crag
#

You can, however, write code that "waits" inside the coroutine

polar acorn
tall storm
#

How can i add headbob to my player?

frigid sequoia
rich adder
frigid sequoia
frigid sequoia
low path
#

getting a component will reutrn null if that copmonent does not exist

rich adder
polar acorn
cobalt creek
#

how do i use function in namespace without adding the component (
eg,

comp = gameObject.AddComponent<nsClass>();
comp.doFunc();

does it have to be compiled to a dll to avoid that or is there better way?

frigid sequoia
#

Okey, that was probably the issue then

polar acorn
swift crag
polar acorn
#

You seem to be using the word "namespace" for something that a namespace is not

swift crag
#

if the component doesn't exist, you can't use the component's methods

low path
#

can you give an example of what you want to be able to do?

rich adder
cobalt creek
#

ok thank everyone, maybe i am confusing myself

swift crag
#

Explain your actual problem, not your attempted solution.

cobalt creek
swift crag
#

That's forbidden.

#

You can't construct a MonoBehaviour instance

#

Explain your actual problem.

cobalt creek
#

ok so actual problem is i dont know how to add component from namespace using AddComponent properly

#

it appear red with squiggly line

swift crag
#

i don't think it's in a different namespace

rich adder
cobalt creek
cobalt creek
swift crag
#

then write out the full name: Name.Space.nsClass

#

There's nothing special about using it with AddComponent

cobalt creek
#

ok

polar acorn
cobalt creek
#

got it

craggy oxide
#

How would I slow down a player's fall speed? I'm tryna make an Apex Legends type of thing where you skydive and then automatically slow down when you're about to land

rich adder
#

my eyesssss

craggy oxide
#

what?

rich adder
#

u just burnt my cornea :;(

craggy oxide
#

why?

rich adder
#

๐Ÿ”ฆ mode

polar acorn
craggy oxide
#

eh, i use discord dark mode and stuff, i just prefer light mode for visual studio, helps me think clearer

rich adder
craggy oxide
#

i'm a beginner (although i passed the unity learn beginner script course so im not completely new)

craggy oxide
#

alright ill look up raycasting

rich adder
#

cause if you have uneven ground the distance changes

craggy oxide
#

trueeee

#

alright thanks

rich adder
#
if(Physics.Raycast(transform.position, Vector3.down, out var raycastResult))
{
    if(raycastResult.distance <= distanceFromGround)
    {
        //slow down  speed
    }
}```
Something like that
summer stump
craggy oxide
#

gotta learn it sometime anyway ๐Ÿคทโ€โ™‚๏ธ

swift crag
#

the signature of the Raycast method makes it easy to plug in nonsense arguments

#

cool tip: use named arguments

rich adder
#

layerMask: myRaycastLayer

swift crag
#
        Physics.Raycast(origin: transform.position, direction: Vector3.forward, maxDistance: 1f, layerMask: LayerMask.GetMask("Target"))
#

or maybe

scarlet skiff
swift crag
#
        Physics.Raycast(origin: transform.position,
                        direction: Vector3.forward,
                        maxDistance: 1f,
                        layerMask: LayerMask.GetMask("Target"))
#

I'll sometimes wrap the arguments when it gets too long

scarlet skiff
#

also very sorry for the late reply i had to leave abruptly

faint sluice
rich adder
swift crag
#

oh wait

#

duh

faint sluice
#

Out raycasthit hit

rich adder
#

RaycastHit lol

swift crag
#

i forgor

#
Physics.Raycast(origin: transform.position,
                direction: Vector3.forward,
                hitInfo: out var hit,
                maxDistance: 1f,
                layerMask: LayerMask.GetMask("Target"))
#

Without named arguments, this looks more like:

#
        Physics.Raycast(transform.position,
                        Vector3.forward,
                        out var hit,
                        1f,
                        LayerMask.GetMask("Target"))
#

It's easy to screw up and pass a layer mask into maxDistance

rich adder
#

oh right its hitInfo:

#

duh

swift crag
#

a LayerMask converts to an int, which converts to a float

#

and now you've made a raycast with a max length of...some random integer

faint sluice
rich adder
#

dang..

swift crag
#

maxDistance does not have a default argument

#

it's just a bunch of overloads

rich adder
#

Oh forgot maxDistance

#

right

faint sluice
#

15 overloads Jesus Christ

rich adder
#

interesting signature... ๐Ÿ˜ตโ€๐Ÿ’ซ

    public static bool Raycast(Ray ray, out RaycastHit hitInfo, [UnityEngine.Internal.DefaultValue("Mathf.Infinity")] float maxDistance, [UnityEngine.Internal.DefaultValue("DefaultRaycastLayers")] int layerMask, [UnityEngine.Internal.DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
    {
        return defaultPhysicsScene.Raycast(ray.origin, ray.direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
    }```
swift crag
#

oh yeah

#

this has caused Hilarious Problems in the past

buoyant knot
#

meaning we can jump anytime within that window, even if we arenโ€™t actually grounded

polar acorn
#

!code

eternal falconBOT
crisp comet
#

i am trying to display a score on my canvas UI and the script wont recognise the text game object I am trying to use to display the score

queen adder
#

Anyone know why the camera could be shaking like this?

polar acorn
crisp comet
#

will try and check online

#

Yes! I thinnk it is legacy @polar acorn

polar acorn
#

You have at least one score manager with no Text component on it

crisp comet
scarlet skiff
crisp comet
#

scoreText is not assigned!
UnityEngine.Debug:LogError (object)
ScoreManager:Awake () (at Assets/3d platformer/scriptzzz/ScoreManager.cs:20)

scarlet skiff
#

wait i think i get it now

polar acorn
#

Are you spawning them at runtime

scarlet skiff
# scarlet skiff wait i think i get it *now*

when we touch ground we are only grounded for a specific amount of time, but since we have onCollision stay it keeps setting resetting the time.time and therefore we stay grounded

crisp comet
crisp comet
#

when my player 'picks up' an object with the "coin" tag on it

crisp comet
polar acorn
rare basin
#

also there is no need to update the score every frame

#

just update it when you pickup the coin

#

Mathf.Round(scoreCount); that is also unneccessary

#

scoreCount is a int

stray pumice
rare basin
#

so what are you rounding here? @crisp comet

crisp comet
polar acorn
buoyant knot
#

Coroutines can be held as a variable and canceled partway through

stray pumice
#

Yes but coroutines paused my whole game for somereason

buoyant knot
#

that isnโ€™t the coroutineโ€™s fault

stray pumice
buoyant knot
#

i reiterate, that is not the coroutineโ€™s fault

polar acorn
#

It's almost certainly the code inside it

#

show it

stray pumice
#

i already delted it

#

its ok

buoyant knot
#

i recommend avoiding invoke in place of a coroutine

rare basin
#

a while loop ig

buoyant knot
#

especially donโ€™t use invoke when you canโ€™t figure out how to make a coroutine work

cosmic quail
crisp comet
polar acorn
buoyant knot
cosmic quail
buoyant knot
#

yep

#

invoke calls a method by string

#

you are literally sifting through the names of the different members of the class to find the method. Instead of just having a pointer built in to send you directly to the function

#

every single time you call invoke

#

you also open yourself up to Invoke(โ€œCheckGrondStateโ€)

#

unless you use nameof, and anyone who knows to use nameof knows not to use Invoke anyway

cosmic quail
#

thats good to know, thanks! i've never used it anyway but after hearing coroutines cause garbage collection i had a thought that invoke may be better then. glad i found out the truth

polar acorn
#

The best way to handle timers is to do it manually in Update using deltaTime and math. Coroutines give up some of that performance for code cleanliness, and there's a certain point where code cleanliness is worth the sacrifice

buoyant knot
#

coroutines cause garbage collection because you need to instantiate new WaitForXXX objects every time you delay a part of the coroutine to the next frame

polar acorn
#

it's a miniscule cost for a pretty sizeable gain

ashen wind
#

I'm trying to set a tile of my tilemap with a new sprite like this

gs.tilemap.SetTile(coords, paving_tile);

but even though both tiles are made from sprites that are the exact same size, the new one is a lot bigger. I can't figure out why this would be

polar acorn
#

Compared to the significant gain over Invoke

buoyant knot
#

coroutines have a small garbage collection cost, which is only a problem if you spam them everywhere in a game

ashen wind
#

does setTile automatically rescale or something?

buoyant knot
#

no

#

Tilemaps are usually going to be on a child of an object with a Grid component

#

grid defines size

#

tilemap basically holds tiledata on a matrix. grid lets you move between cell space and world space

ashen wind
#

so its something in my tilemap settings?

buoyant knot
#

check your Grid

ashen wind
#

I just don't understand how if they're the same size sprite it would be different for the new one

#

so I'm not even sure what I'm looking for

buoyant knot
#

did you make a single tile

#

each sprite as one tile

ashen wind
#

what do you mean

buoyant knot
#

tilemaps can only set tiles

#

you need a tile

#

how did you make the tile

ashen wind
#

I created a .asset file

buoyant knot
#

what

ashen wind
buoyant knot
#

oh, youโ€™re doing it that way

tall storm
#

Hello, could someone help me with this script? The particles arent playing

void Die()
{
    onDeadParticles.Play();
    Destroy(gameObject);
}```
buoyant knot
#

you can drag a sprite to a tilepallete to automatically make a simple Tile btw

languid spire
buoyant knot
#

how big is each sprite in resolution

tall storm
buoyant knot
#

when you sliced it

polar acorn
tall storm
#

its a child of "Enemy" and the script is in enemy

languid spire
rare basin
#

and maybe they are unparented

tall storm
#

but i want the particles to play after the enemy dissapears

polar acorn
languid spire
#

bet, the particlesystem is on gameObject

polar acorn
rare basin
#

or figure other way of doing that

tall storm
#

and what about the position

rare basin
#

what about it

tall storm
#

how do i set the particles to play in the center of the enemy

rare basin
#

the same way you are doing it right now

#

just unparent it

#

before destroying gameObject

tall storm
#

ooh, and the parent should be SampleScene?

polar acorn
#

The parent should be nothing

tall storm
#

oh ok

rare basin
tall storm
#

i set the parent to null

#

it works

#

thanks

buoyant knot
# ashen wind
  1. when you sliced it, are the regions for each tile the same pixel-wise?
  2. are you comparing two different tiles on the same tilemap? Or are you comparing sizes when putting them on different tilemaps
ashen wind
#

they look the size on the tilemap, but not in game

#

oh wait

#

maybe the farm is bigger in the tilemap

buoyant knot
#

do you have two tilemaps?

#

and is the right side a tilemap or tile palette?

ashen wind
#

nope, only one. the right side is a tile palette, sorry

buoyant knot
#

a tile palette is just going to show you the tiles

#

one tile per cell

#

did you slice the sprites for each tile?

ashen wind
buoyant knot
#

thatโ€™s your problem then lmao

#

for this sort of thing, iโ€™m expecting multiple tiles to be in one PNG file

#

in unity, go to that PNG file, set sprite mode to Multiple, point filter, no compression. Then go to sprite editor

#

then draw a little box (which should be the same size every time) around the area that should be the sprite for the one tile.

#

click in the little green highlight square to see the name etc, change the name to be something useful. Save

#

now when you look at the PNG in unityโ€™s project view, it should show a little tab of multiple images, one for each sprite that you just sliced

ashen wind
buoyant knot
#

nope

#

each PNG should contain MULTIPLE tiles. otherwise you will make your life more complex with tons of tiny little files

#

and tracking them down and all that shit. trust me, it is better to slice.

ashen wind
#

that seems like a lot of work for no reason

queen adder
#

Thats what a spritesheet is

buoyant knot
#

you donโ€™t need to, but itโ€™s prettt weird to have made so many separate image files in the first place

#

A typical file used to make tiles typically looks like this. all in one file

#

you do not want to mess with this exact same file into like 100 separate PNGs

queen adder
#

Thats where the slicing part comes in.

buoyant knot
#

slicing is where you define each little region to be a separate sprite

ashen wind
#

ok, i've made a spritesheet

buoyant knot
#

since you had your farm and grass in separate files, I bet they had different resolutions

#

ie different pixel x pixel measurements

#

(which is really bad)

buoyant knot
#

also there is an auto slice function in unity. If you ever use it, ALWAYS set it to โ€œSafeโ€ mode, or else it will delete your old sprites, and break anything that references those sprites you just deleted

#

i donโ€™t know why this is not default

earnest atlas
#

_target = GameObject.Find("Player").GetComponent<Transform>();

Will this give me transform position of object in real time?

rare basin
#

don't ever use any Find methods

ashen wind
#

this look right?

earnest atlas
#

Serializing playfield player GameObject is not fun in mutliple entities

tall storm
#

How do i check if a particlesystem is done playing

earnest atlas
tall storm
rare basin
#

dont use is alive

#

use isPlaying

scarlet skiff
#

why does give an error, i do infact give it an object reference..

earnest atlas
#
private ParticleSystem _particleSystem;

void Start()
{
    _particleSystem = GetComponent<ParticleSystem>();
    StartCoroutine(DestroyAfterParticleEffect());
}

private IEnumerator DestroyAfterParticleEffect()
{
    while (_particleSystem.isPlaying)
    {
        yield return null;
    }
    Destroy(gameObject);
}```

I have this class in all effects
#

So far it worked fine

rare basin
#

you are using isPlaying

#

but you suggested him to use IsAlive()

tall storm
buoyant knot
# ashen wind

โ€œmethodโ€ should always be set to โ€œsafeโ€

polar acorn
rare basin
#

now a property

scarlet skiff
buoyant knot
#

also 360 x 360 is massive for a tilemap

queen adder
scarlet skiff
#

and ot gets passed from that script to the initiated bomber

polar acorn
tall storm
#

oh isPlaying works

#

thanks

buoyant knot
#

if you you have a 1080p display, and your tiles are 360x360, then that image will get compressed if you try to show an area taller than 3 tiles.

#

which is very bad

rare basin
scarlet skiff
buoyant knot
#

standard tile sizes are 16x16 or 32x32. Maaaaybe 64x64 for some really chonky stuff, but 360x360 is not going to end well for you, @ashen wind

polar acorn
crisp comet
scarlet skiff
late burrow
#

can i make my custom variable have required input when creating new() one

polar acorn
queen adder
#

You start the coroutine inside of Bombardment as soon as the game starts but u only assign PlayerMov on a Button press inside of the Update Function inside of the BomberSpawner class

scarlet skiff
scarlet skiff
polar acorn
queen adder
#

Again u dont

polar acorn
#

Also what is this

#

Why does Bombardment have a reference to itself

#

that is never used

scarlet skiff
polar acorn
scarlet skiff
#

bomber.playerMov = this.playerMov

polar acorn
#

nothing in this sets the playerMov of a Bombardment

polar acorn
#

Not a Movement

rare basin
#

why did you name the Movement type variable

#

bomber

#

it is sooo confusing

#

also what is this line

#

bombardment.bombardment = this.bombardment

scarlet skiff
#

i put the bomber prefab there, but movement script can be shared with bomber and archer

rare basin
scarlet skiff
polar acorn
#

Where are you setting playerMov on a Bombardment

scarlet skiff
#

im not rly sure what u mean now ๐Ÿ˜ฐ

Bombardment has: public PlayerMovement playerMov;

which is only given a reference upon initiation

#

via the spawner

#

which has its refrence from the inspector

rare basin
#

yes but where do you assign

#

the playerMov from the Bombardment class

#

through inspector?

scarlet skiff
#

ye the spawner has it

rare basin
#

stop

#

listen to what we say

#

no one asked you about the bomber spawner script

#

Bombardment class has a playerMov variable

#

where do you assign it?

queen adder
#

Thats BomberSpawner

#

Not Bombardment

#

Bombardment is the one with the NRE

rare basin
#

where do you assign playerMov of the BOMBARDMENT

scarlet skiff
#

in the BomberSpawner script.... ...? is that wha u mean? sorry bro i dont get it

queen adder
#

Thats not bombardment

#

Thats a movement class

polar acorn
queen adder
#

Those arent the same class

polar acorn
#

Where in the spawner do you set it

queen adder
#

You never assign the Bombardment.playerMov you Think you did

scarlet skiff
#

should i be doing this instead?

bombardment.playerMov = this.playerMov;

#

or both

#

probably

polar acorn
#

But where are you even getting this bombardment from anyway

#

You aren't spawning it

#

And you said there's none in the scene

#

So what is this bombardment

scarlet skiff
#

i think i got conused cuz both movement and bombradment had a variable that does the same thignb with the same name

rare basin
#

thats why i said this is a terrible idea

#

to name your Movement a bomber

scarlet skiff
queen adder
#

Yeah^^^

#

It was throwing us off

rare basin
#

as a Movement

polar acorn
honest haven
#

Im using Time.timescale = 0 to take a chunck of my game pausing away. but i want the animator on the player to play. so on the player controller under update im doing _animator.Update(Time.deltaTime * 1f); but its not working. what am i doing wrong

cosmic quail
summer stump
cosmic quail
# honest haven Im using Time.timescale = 0 to take a chunck of my game pausing away. but i want...

theres tutorials for playing animators while game is paused btw like this https://www.youtube.com/watch?v=mwNlOrD6vFM

Be sure to check out my Unity for Complete Beginners course on Udemy here: https://www.udemy.com/course/learning-unity-and-c-for-complete-beginners/?referralCode=23B51187C8A97B78D1CF

In this video I will show you a fast Unity tip on how you can play animations in regular time when you alter the timescale of your game. Changing the update mode o...

โ–ถ Play video
honest haven
#

cheers

rare basin
#

timeScale-independent

honest haven
#

thank you

silver flicker
#

Hey, can anyone explain / give me a video explaining how to find the displacement of a 2d object through recording 2 positions (specifically the recording of the 2 positions) I've tried searching for it but nothing explaining the recording of 2 positions

buoyant knot
#

wdym? just have a component record current position in LateUpdate or something.

silver flicker
#

Lateupdate ill look that up thanks

buoyant knot
#

you will possibly want to do this in FixedUpdate after physics sim, tho

silver flicker
#

should physics calculations always be recorded in fixed?

buoyant knot
#

in my case, i call Physics2D.Simulate manually, so I can call code naturally right after all collision callbacks are done. This lets me call an event action called OnAfterCollisionCallbacks

silver flicker
#

ok cool

buoyant knot
#

do not do any physics in update.

silver flicker
#

ok thats all i need

#

tysm

buoyant knot
#

sure

#

btw you need to set Physics2D similation mode to script to do it that way

#

Physics2D does not want you to call Simulate unless you set that mode

silver flicker
#

oh ok