#💻┃code-beginner

1 messages · Page 299 of 1

slender nymph
#

this is editor stuff for the AI Navigation package. it is not their code

prime cobalt
#

does anyone know wtf a float y is?

slender nymph
#

you're trying to create a tuple there. that isn't how you create an instance of Vector3

prime cobalt
#

How do I change it to be a vector 3?

slender nymph
prime cobalt
#

ooooh my god I forgot to write new vector 3 I'm an idiot

wintry quarry
#

I'm actually confused why it says (float, float y, float) there instead of just (float, float, float)

woeful quest
#

I clicked Box collider beacuse my character kept falling thru the map and then I pressed play and it just said this and it's not loading and i'm worried if it didnt auto save please help me. (By the way I was waching a tutorial on how to fix it and it said to do that and no its just stuck loading)

slender nymph
wintry quarry
#

I guess? Weird behavior

woeful quest
#

!bug

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

winter cedar
#

yeah so i tried everything and its still giving the error

slender nymph
slender nymph
woeful quest
#

AUUUUGH I lost half of my work cause a stupid Unity bug.

slender nymph
#

remember to save often

polar acorn
open vine
#

Is there a built-in solution to cursor.locked not interacting with UI? I have an FPS character and want it to interact with some world space canvases.

winter cedar
slender nymph
#

you should have already checked considering that was literally the first step i said to take

woeful quest
polar acorn
woeful quest
polar acorn
woeful quest
polar acorn
woeful quest
#

I opened it like 2 minutes ago then I closed it and im looking for the Backupscenes now

polar acorn
#

meaning it's cleared out the backup scenes

woeful quest
#

yes after it crashed I opened

polar acorn
#

you have to do it before reopening

woeful quest
#

Nooooo

#

Next time I will do ctrl s before playing

#

or do it from time to time

frigid sequoia
#

Ey, I am planning on adding a "scatter shot effect" along side the main bullet as a powerUp with a variable amount of pellets based on how many copies of the powerUp does it have. And I am wondering... should the logic of how this projectile works be in a prefab that spawns all the pellets or be in the overall method that I use for the player to spawn projectiles. What does make more sense?

woeful quest
frigid sequoia
winter cedar
#

hello?

summer stump
winter cedar
#

yes

summer stump
# winter cedar yes

And when you reopened unity, you got a loading bar that took a while, as the library folder regenerated?

static wolf
#

hi y'all.
i want this train object (which has a trigger boxcollider) to call a shake() method on all the tree prefabs i have around the scene, but for some reason it only recognizes the player and grabbable prefabs. i have no clue why, this is what my tree prefab looks like (it has a box collider), i tried messing with the settings on that but i'm stuck. anyone know why the train wont print the tree objects

short hazel
#

(the collider is also not a trigger collider here)

static wolf
#

i see

#

but whenever i update the values in this tree prefab, it does update all the other instances on the scene

#

even when i enable the trigger collider option for the prefab (which reflects on all the instances in the scene), it still doesn't work

#

here's the code, but the part i care about is just the print line, but since its not printing any of the trees, im assuming theres an issue with the colliders somehow

short hazel
#

First things first, apply the changes to the original prefab anyway, using the "Overrides" dropdown at the top of the Inspector, and try again

#

And for OnTriggerEnter to happen, one of the two objects must have a trigger collider, not the other, and at least one needs a Rigidbody.
Also make sure you're moving the objects in a way that uses the physics engine, by interacting with the Rigidbody for example. Directly modifying the Transform does not use the physics engine.

static wolf
#

Ohhh i see

short hazel
static wolf
#

i didnt know a rigidbody was needed

#

tysm

polar acorn
#

Most people just say "that's too hard I hate reading" and demand we solve it for em

static wolf
vale geode
#

hi, im having dificulties understanding how to acess a script in my game, im working on a enemy ai that uses a StateMachine, the enemy object uses a script for its ai that calls other scripts that are its states, being a patrolState and a attackState, im having dificulties in the attackState script being called, the way its supposed to work is by a canSeePlayer method that uses a ray to detect a player, i have run various debugs log, and it should work since it has all the requirements for the attackState to be called, but i dont really know what to do

lost anvil
#

is it possible to remove a specific item from an array or is a list needed

woeful quest
#

Guys I'm making a Gorilla tag fangame in Unity and whenever I press play the thing falls thru the map and it doesent stay on the ground. Please help

vale geode
woeful quest
polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

short hazel
lost anvil
#

alright thanks

vale geode
woeful quest
#

ok

woeful quest
#

which one?

polar acorn
woeful quest
#

Idk just so I dont fall thru the ground

#

and all the other objects

vale geode
#

box collider and scale it to match the floor

woeful quest
#

ok

#

I'm still falling thru the ground

devout flower
#

Do both things have colliders

polar acorn
woeful quest
devout flower
#

Showing the inspector of both objects might help

woeful quest
#

so i need to add a colider so that?

#

Idk

#

I still fall thru the floor

devout flower
#

So uh

#

I'm not sure about how you set things up

#

But basically

#

I think you should put a collider on literally everything that shouldn't go through things

#

And everything that shouldn't allow things through

woeful quest
#

I pasted in the map from my last attempt because I got something wrong with Photon last time

vale geode
#

on the center of that hole

woeful quest
devout flower
#

Ah i see

woeful quest
#

I do know most of the basics

vale geode
#

the ouside face is where you statnd

polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

short hazel
#

Creating a project involving VR as your very first is pretty much an extremely bad idea

#

Same thing goes for multiplayer

#

(Your VR setup is throwing some errors by the way)

short hazel
#

Well read the error message and you'll se why that is

short hazel
#

Yep. Multiplayer + VR. The combo of death

#

Your VR package is deprecated as per the error:

XRRig has been deprecated. Use the XROrigin component instead.

woeful quest
#

Soo how do I fix that?

short hazel
#

I strongly suggest you follow a basic introductory tutorial to Unity first

vale geode
# woeful quest Soo how do I fix that?

do something simple first like this https://youtu.be/XtQMytORBmM?si=wkUnLm5YnZG5h6q5

🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...

▶ Play video
#

hi, im having dificulties understanding how to acess a script in my game, im working on a enemy ai that uses a StateMachine, the enemy object uses a script for its ai that calls other scripts that are its states, being a patrolState and a attackState, im having dificulties in the attackState script being called, the way its supposed to work is by a canSeePlayer method that uses a ray to detect a player, i have run various debugs log, and it should work since it has all the requirements for the attackState to be called, but i dont really know what to do

woeful quest
#

Well if im gonna make a new project ima save my map with the FBX tool thing that lets you export objects you made in Unity

rich adder
vale geode
#

how should i send code better?

rich adder
hushed hinge
#

... if anyone knows

lost anvil
vale geode
hushed hinge
summer stump
lost anvil
summer stump
#

Also, try to cache those GetComponent calls

#

Might wanna use an enum instead of using reflection too

#

Now, for the real issue, I am a bit confused. What is the actual problem. And what do the debug logs say?

hushed hinge
lost anvil
#

because that could help

hushed hinge
lost anvil
hushed hinge
summer stump
#

Or width or height?

#

Because you would obviously need to make those....

prime cobalt
#

Does vector3.normalized go from -1 to 1 or just 0 to 1?

prime cobalt
#

ok thanks

summer stump
#

-1 magnitude is not a thing

prime cobalt
#

wait but like if the vector 3 had negatives would they stay as negatives?

summer stump
#

Sorry if I misunderstood you

prime cobalt
#

Oh ok, gotcha.

hushed hinge
summer stump
# hushed hinge nope

Welll... then yeah that code will obviously not work.
That was an example, not something you can copy and paste

hushed hinge
summer stump
vale geode
polar acorn
hushed hinge
polar acorn
summer stump
hushed hinge
polar acorn
# hushed hinge erm

In this script, what are image, width, and height? Where do you define those variables?

hushed hinge
polar acorn
prime cobalt
#

Ok so this may be a little hard to explain but could anyone give any light into what's not working here?
The End of the blue line is supposed to be facing in the direction of the red line with the length of the green line, since the green line and the blue line are supposed to be on the perimeter of the same circle around the object in the middle. r is the distance from the center object to the end of the green line, so it should be the radius. The thing in the center is the "origin" and the thing at the end of the red line is the object running the script so it's where the transform is coming from. I've been trying to get this to work for hours now.

hushed hinge
polar acorn
#

This doesn't seem to have anything to do with what I asked

hushed hinge
polar acorn
polar acorn
#

You have a line that's trying to use image, width, and height. What are those

hushed hinge
#

aren't width and ehight also supposed to be there?

summer stump
#

You have been using c# for quite a while now. You should absolutely know this by now

hushed hinge
polar acorn
hushed hinge
hushed hinge
summer stump
polar acorn
#

Your explanations aren't making sense so let's back up. What is the goal you're actually trying to achieve

tender stag
#

i need a method which is called when the object is created

#

Awake breaks other things

summer stump
#

OnEnable

polar acorn
hushed hinge
polar acorn
#

Which UI Image are you trying to set

tender stag
#

how can i fix this

#

i have an instance of my EquipmentManager

polar acorn
tender stag
#

the instance is set after the other awake

summer stump
# tender stag

Awake for self-reference
Start for external references

frigid sequoia
#

Can I like... intentionally skip the Start() method of a instantiated object?

tender stag
polar acorn
tender stag
#

but what im saying is that start isnt called when an object is created

polar acorn
summer stump
#

Is the object disabled?

tender stag
#

yes

polar acorn
hushed hinge
#

and the reason why the uiimage is that different width size is because it's for when there's 2 players

tender stag
polar acorn
summer stump
hushed hinge
strong wren
polar acorn
rich adder
#

"how do i do that"

polar acorn
#

what does that have to do with anything

frigid sequoia
frigid sequoia
#

Cause I want like spawn several bullets that are slightly modified

polar acorn
#

why are we talking about projectile data

#

when did the conversation become about projectiles

#

Wait, nevermind, I thought you were linedol

#

I'm confusing myself here

frigid sequoia
#

Is the value that I want to be setted on the start of the new instance

#

Don't really know how to work around that

hushed hinge
polar acorn
polar acorn
#

I asked you to reference an image

#

why are we talking about tags

hushed hinge
#

because that image have the tagname "Transition1" so I just wanted that the it's referencing the right image it's supposed to reference

polar acorn
hushed hinge
visual hedge
#

@hushed hinge your width could be modified by transform.localScale.x it's not like per-se modification of width, but you can kinda stretch the image. what's best about it, you don't have to assign the width anywhere. Just assign that image. Which I guess you now have problem with since your variable is private and you can't assign that image in the inspector. Easy solution: [SerializeField] private Image uiImage; and then it's assignable thru inspector.
I am not sure if that's what you are looking for

polar acorn
polar acorn
#

Having inconsistent scales will completely bork your anchoring

strong wren
visual hedge
rich adder
#

sizedelta

visual hedge
frigid sequoia
visual hedge
frigid sequoia
#

Probably should't do that, but I am really struggling to trying to wrap my head about how I want to actually code this

thorn holly
#

welp, ive just learned the hard way to use fixed update for velocity based movement

#

my player was rubberbanding like a game of pong

rich adder
strong wren
polar acorn
visual hedge
polar acorn
frigid sequoia
#

Can I not have an struct parameter as null?

#

Is there something equivalent or is just not supported?

hushed hinge
polar acorn
hushed hinge
summer stump
queen adder
#

UnityChanThink how come "Image change" only gets printed once at 16 seconds? Shouldn't the modulus operator usage here usually make it print at 16, 12, 8, and 4 seconds?

polar acorn
teal viper
queen adder
teal viper
hushed hinge
polar acorn
queen adder
hushed hinge
polar acorn
queen adder
# teal viper Share the new code
using UnityEngine;
using UnityEngine.SceneManagement;

public class Cutscene : MonoBehaviour
{
    public float targetTime = 20.0f;

    private void Update()
    {
        targetTime -= Time.deltaTime;
        int second = (int)targetTime;
        print("time: " + second);

        if (second % 4 == 0)
        {
            print("Image change");
        }

        if (targetTime <= 0.0f)
        {
            TimerEnded();
        }
    }

    private void TimerEnded()
    {
        SceneManager.LoadScene(2);
    }
} 
polar acorn
brave jasper
#

hi guys i have a problem

polar acorn
#
teal viper
queen adder
#

could it be a float/int conversion thing

teal viper
teal viper
brave jasper
#

can i get sameon to strem my project to ??

hushed hinge
polar acorn
brave jasper
#

i have a problem in animation and i dont know howe to slove it

queen adder
rich adder
teal viper
teal viper
#

Disable it

hushed hinge
scarlet skiff
#

is there an effecient way to tell code to run only once when its something that u have to run in update? usually i just create a new bool for just that where the bool starts off as true, and if true, the code runs the thing i only need to be run once then sets the bool to false

polar acorn
brave jasper
frosty hound
hushed hinge
polar acorn
scarlet skiff
brave jasper
#

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerController : MonoBehaviour
{
Animator anim;
Rigidbody rb; // Declare a Rigidbody variable

// Start is called before the first frame update
void Start()
{
    anim = GetComponent<Animator>();
    rb = GetComponent<Rigidbody>(); // Get the Rigidbody component
}

// Update is called once per frame
void Update()
{
    // Check if the Rigidbody component exists
    if (rb != null)
    {
        // Access the velocity only if the Rigidbody component exists
        anim.SetFloat("Speed", rb.velocity.x);
    }
    Debug.Log("Speed: " + anim.GetFloat("Speed"));

}

}`

scarlet skiff
#

like here, in the else if (hasBeenBlocked)
I want it to set speed to 0 once, then start doing this new movement it does if the object has been blocked

rich adder
summer stump
scarlet skiff
frosty hound
#

Is there an actual issue with how you have it? Are you just asking if it's a bad performance thing?

frosty hound
#

It's fine

scarlet skiff
#

i just dont like creating a new bool if it has 1 small use

polar acorn
frosty hound
#

It will have zero affect in your performance

scarlet skiff
#

ye but the code becomes more cluttered i feel like

#

or is that just me

polar acorn
frosty hound
#

Well, that's not a performance thing, that's an architectural thing.

brave jasper
scarlet skiff
frosty hound
#

And, sure, you could clean it up with work. Character Controllers are difficult to keep looking nice, it takes experience to know how to properly break it apart.

#

In the end, as long as it works. 🤷‍♂️

hushed hinge
teal viper
scarlet skiff
polar acorn
scarlet skiff
# brave jasper

reading the error message should give you the info you need

queen adder
ripe shard
scarlet skiff
queen adder
#

I was wondering what that number in the hundreds was next to each message and assumed it was the amount of frames between each second ig those were the amount of messages haha

hushed hinge
brave jasper
scarlet skiff
#

is a UI thing

#

you mgiht be thinking of Sprite ?

hushed hinge
#

it is an UI

polar acorn
brave jasper
north kiln
brave jasper
scarlet skiff
summer stump
polar acorn
teal viper
scarlet skiff
# brave jasper

Sorry i meant inspector, can you show what components you have?

hushed hinge
summer stump
#

At all

#

The issue is where you put the = sign

#

why do you think it goes on the right?

#

instead of the left

#

Well, I guess you are trying to assign the IMAGE to something (so I guess the rectTransform is part of the issue)

polar acorn
queen adder
# queen adder holy crap it's printing a gazillion times LOL

how do I get "image change" to print only once at exactly multiples of 4? Here's what I tried

targetTime -= Time.deltaTime;
int second = (int)targetTime % 60;
print("time: " + second);
if (second % 4 == 0)
{
  for (int j = 0; j < 1; j++)
  {
      print("Image change");
  }
}
polar acorn
hushed hinge
polar acorn
summer stump
# hushed hinge

you are trying to assign the IMAGE to something (so I guess the rectTransform is part of the issue)

polar acorn
#

Just a little bit more, transition1 is an Image, so you have to store an Image in it. Now, how would you get an Image Component from an object

polar acorn
summer stump
hushed hinge
#

ok

polar acorn
#

Now

#

you have a variable

#

that holds a reference to the Image component on the object tagged "Transition1"

#

This took like two hours so I honestly do not remember what you were trying to do with it

hushed hinge
#

oh my god, yeah, ok, now I need to figure out with changing the image width size

summer stump
polar acorn
summer stump
#

Wasn't that the error?

scarlet skiff
#

as the error mentioned

summer stump
brave jasper
polar acorn
brave jasper
summer stump
#

It is looking on the shirt, so it doesn't matter if it's on Idle

brave jasper
#

so add animator to all the object on player

summer stump
#

To find the animator in the right place

#

Why is PlayerController on the shirt in the first place?

brave jasper
#

this is player controller

summer stump
# brave jasper

Yes. GetComponent gets the component ONLY from the object this script is attached to

#

I think this is an important question:

Why is PlayerController on the shirt in the first place?

brave jasper
#

what i changet to

brave jasper
#

i can change it ?

summer stump
summer stump
#

You can do whatever you want

brave jasper
#

ah you talk about the script

#

bro, i searched for 1 week and the problem is PlayerController on the shirt

#

it solved but i want something more

hushed hinge
summer stump
polar acorn
brave jasper
#

what about that

hushed hinge
brave jasper
#

i think this chat is not for animation

summer stump
#

And you only set it when Rigidbody is not null

#

So, I think perhaps there is no rigidbody on that object?

brave jasper
summer stump
summer stump
brave jasper
#

i think no

summer stump
#

You have a CharacterController, which is incompatible with a rigidbody

#

Your Mouvement component has a speed, use that instead

hushed hinge
summer stump
#

Ah wait. Tell me you didn't forget to assign the variables....

#

The int and float types default to 0, so if you forgot, then you are assigning 0 to width and height

brave jasper
#

so what next

summer stump
#

You literally responded to the message where I said you cannot do that

brave jasper
summer stump
brave jasper
#

ok

summer stump
#

You have a CharacterController, which is incompatible with a rigidbody

#

Your Mouvement component has a speed, use that instead

summer stump
#

This is the most absolutely basic thing you need to know how to do

hushed hinge
summer stump
#

That is assuming you are in Main

#

Which you are not. You are in a class

#

Just assign it in the initializer or via the inspector

#

Or in Start/awake

brave jasper
summer stump
hushed hinge
summer stump
#

Ok perfect.

summer stump
#

Not your x and y variables

#

So yeah, those would still be 0

hushed hinge
summer stump
#

There ya go

#

No idea why you wouldn't just do int x = 1280; but sure, it works

brave jasper
#

that what appened

summer stump
polar acorn
brave jasper
summer stump
#

I beleive it is not called Mouvement

#

Look at your class

#

C# is case-sensitive

teal viper
#

What about the intellisense?notlikethis

brave jasper
summer stump
silent dove
#

uhh could i get a bit of help with having my code play audio?
im trying to have a thing where when in this case the laser hits the enemy, it makes a sound along with the animation i have for an explosion, as well as removing the laser and enemy
i've tried to implement things from tutorials i've seen, but i kept getting a "cannot play a disabled audio" error, and looking through people saying the same thing none of the solutions for them worked for me?

#

this is the code as it is before trying to add audio, i followed a tutorial that i thought would work, with playing an audio clip when a collision happens, but i think it's due to the laser being destroyed when it hits an enemy, and so it isnt able to make the audio? i'm not entirely sure i'm new to unity, so a lot of what i get is from tutorials so im not the best at figuring out whats wrong with it

whole idol
#

Yo, Im following unity's official tutorials like someone recommended here, at first the quality looked amazing, but theyre kinda overexplaining the most basic things Ive already discovered on youtube, anyway heres a physics related problem I got, so why does this wooden obstacle always back down in place like this instead of being kicked forward like a soccer ball after the truck hits it? It's supposed to go side ways not say in one place and return to its original position right? wtf

brave jasper
#

but i have a probelm

#

the code does do anithing

summer stump
brave jasper
#

yes

summer stump
#

Ah yeah, I see the getComponent call

brave jasper
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerController : MonoBehaviour
{
Animator anim;
float curSpeedX;

// Start is called before the first frame update
void Start()
{
    anim = GetComponent<Animator>();
}

// Update is called once per frame
void Update()
{
    // Access the curSpeedX variable directly
    anim.SetFloat("Speed", curSpeedX);
    Debug.Log("Speed: " + curSpeedX);
}

}

summer stump
#

Oh. Ok, so you just got rid of the mouvement reference

#

So this will basically do nothing except set the speed one time

brave jasper
#

so how i can fix it

summer stump
#

Unless you set curSpeedX externally

brave jasper
summer stump
#

Go back to referencing mouvement and use that speed 🤷‍♂️

whole idol
#

this anyone knows?

summer stump
#

Try lowering it 🤷‍♂️

whole idol
#

ok

summer stump
#

Ah, I see you tried that in the video...

silent dove
brave jasper
#

replace the referencing mouvement by Speed

#

that what you say right ?

summer stump
#

You had walkSpeed and runSpeed if I remember correctly

brave jasper
brave jasper
summer stump
brave jasper
#

finally!! the cod work

summer stump
whole idol
#

nope

#

but it looks like something like the box is hitting into something like an invisible wall

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Translate(transform.forward * Time.deltaTime * 20);
    }
}

#

this is my script by the way

#

could it in any way be related to this method that im using?

#

i changed it to ```c#
void Update()
{
transform.Translate(Vector3.forward * Time.deltaTime * 20);
}

#

Vector3

#

Why doesn't it go forward?

cosmic dagger
whole idol
summer stump
wintry quarry
#

That tutorial is garbage

#

It tells you to use translate and shows physics interactions

#

It's not their fault

#

It's a bad tutorial

frigid sequoia
# frigid sequoia I kinda want to not set the projectileData to the playerController, but instead ...

I ended up just... checking for one of the values inside the struct to see if it was 0 (aka not setted), that would mean the struct is not set yet. So I just check for that before setting it to the playerController.playerProjectileData. That way I can set it when instantiating a new projectile and will skip this step enterely. Just is someone ever want to know about that, which I doubt, but there it is. I just answered my own question

whole idol
cosmic dagger
whole idol
#

thats what the car does

#

the box has no transform.forward

#

it has a rigid body and a mesh collider

#

and so does the car

#

have these components

summer stump
frigid sequoia
#

Pretty sure I did that tutorial and found no issues whatsoever. What's going wrong?

cosmic dagger
whole idol
#

yeah but which object?

#

are you talking about the obstacles? or the truck?

cosmic dagger
#

which object for what? i was merely answering your question . . .

whole idol
#

you didnt answer my question at all lol

#

my question is why do the boxes stay in place

#

instead of being shot forward

#

I just finished the tutorial where he explains the truck script

#

but he doesnt explain why my obstacles just stay in place

#

his seem to work differently

#

and i did exactly the same steps he followed

cosmic dagger
#

the boxes will shoot forward if a strong enough force pushes it . . .

whole idol
#

i got 1000 mass on the truck rn

#

boxes got only like 20 mass

frigid sequoia
#

That's just how physics work, make it go faster or the box has less mass if you want them to gain more force on collision

cosmic dagger
#

i don't tinker with mass. are you using velocity or force to move the truck?

frigid sequoia
#

You can also change the physic material of the boxes, you might like to add some bounciness there

frigid sequoia
# whole idol

Translate moves the object in that direction that much amount each frame, but it doesn't apply any physics, it is just basically changing It position constantly, making it have no force whatsoever on the the boxes, they are just being gently pushed away by the colliders and rigidbodies, but there is no velocity

obsidian granite
# whole idol

Transform.Translate is the same as transform.position +=

#

no physics are used

#

it's just a rigid "go here to there"

whole idol
#

yeah

#

im following the tutorial

obsidian granite
#

tutorial is bad if it's telling you to transform.translate for physics

ionic loom
#

Translate doesn’t use physics

obsidian granite
#

you can use rigidbody.moveposition

ionic loom
#

Why tf would the tutorial say that

obsidian granite
#

or any of the similar methods

#

for physics

whole idol
#
Unity Learn

Overview: In this lesson you will make your driving simulator come alive. First you will write your very first lines of code in C#, changing the vehicle’s position and allowing it to move forward. Next you will add physics components to your objects, allowing them to collide with one another. Lastly, you will learn how to duplicate objects in t...

#

its literally on Unity's official course itself

obsidian granite
#

this is so sad

#

yeah you never want to do that because transform.translate sets the position directly without consideration for physics

#

you can try to set the collision mode on the colliders to continuous and see if that helps

#

or lower the speed of the truck

frigid sequoia
brisk sigil
#

is it possible to use unity to decompile a game

obsidian granite
#

you can decompile a game and then open it in unity

#

but unity itself doesn't decompile

brisk sigil
#

ok

whole idol
whole idol
#

hopefully that wont cause problems as i continue on with the tutorial forward right?

brisk sigil
#

is there a way to decompile a game

whole idol
#

my physics dont work exactly the same as his

obsidian granite
#

but the ethics are questionable on that

brisk sigil
#

wdym

cosmic dagger
frigid sequoia
#

Just don't that your own, you are not supposed to

obsidian granite
#

for some random dude on the internet to open it up

#

and see exactly how everything that you worked for works

#

to get access to all the assets, all the code, etc

brisk sigil
whole idol
obsidian granite
brisk sigil
#

ok

silent dove
# silent dove this is the full script, just not sure if there's a way i could add a way for it...

im still not entirely sure with this, if somebody could help me out i'd appreciate it, it's the main problem im having right now (though i expected it to be the easier thing to do)
but i followed the tutorial, and this is my code, just adding an AudioSource and having it play,
but i think it's not wanting to work because the script is on a prefab, meaning i guess when its trying to play the sound its also having the prefab be deleted, so i'm not sure how to go about implementing a way to have it play the sound even if the prefab is destroyed?

obsidian granite
teal viper
whole idol
#

his seem to work perfect although he said somewhere in a random moment in the tutorial " im just switching to an ANCIENT version of unity right now" because reasons 😄

frigid sequoia
cosmic dagger
obsidian granite
#

do the official unity tutorials work? idk i don't think i've ever watched like a tutorial to learn a game engine or new framework that really worked

#

i just mess around and when i don't know how to do something i look it up

#

and then i learned how to do it

cosmic dagger
brisk sigil
#

ok I'll make sure to try that

obsidian granite
#

i don't want to post my question to multiple channels but general is getting no activity 😭

frigid sequoia
silent dove
teal viper
frigid sequoia
whole idol
silent dove
#

in the game, the player shoots a laser, which is what this code is for, and so when the laser collides with an enemy, it plays an animation and destroys both the laser and the enemy

#

im hoping to have it play a sound around that time, which is why i wouldnt mind just making the laser still exist, just not be visible and not collide with anything for a few seconds

obsidian granite
frigid sequoia
silent dove
#

im just not sure how to implement that, i'm kind of new to unity, i just started it for this semester, and i havent gotten a good grasp on it i feel like

frigid sequoia
obsidian granite
frigid sequoia
silent dove
#

that might work too

obsidian granite
#

i'm sure there's a better solution, but it's low IQ as hell and it works for me

silent dove
#

i wanted to add some other features, but i kind of had to simplify them since its kinda complex for me

obsidian granite
#

@summer stump how come?

obsidian granite
#

see there's always a better solution

frigid sequoia
#

Pretty sure the pros have an entire sound manager with an event system that tells them when and where an specific sound should be played but...

#

I am not that 🤷🏻

silent dove
#

ah so instead of just audioPlayer.Play() do audioPlayer.PlayClipAtPoint ?

obsidian granite
#

so don't call it on whatever object you have

#

call it on the AudioSource class itself

summer stump
frigid sequoia
obsidian granite
frigid sequoia
#

Destroy(gameObject, [delayTime])

summer stump
obsidian granite
summer stump
#

Destroy with a timer would work too though

obsidian granite
silent dove
#

im not sure how to do that sort of stuff i can check it out, but first i'll look at PlayClipAtPoint and see if i get the audio playing from that

frigid sequoia
obsidian granite
summer stump
obsidian granite
#

what would the point be of implementing your own destroy timer if the method does it all for you?

summer stump
obsidian granite
obsidian granite
#

it was not

#

it was a genuine expression of me realizing the difference

#

hm, seems kind of asinine to keep the same object tho

#

i mean, i guess you get the performance benefit of not creating a new object

#

but at that point you're splitting hairs

frigid sequoia
#

I mean, as everything here, you can get pretty similar results with very different ways

#

There is no correct way, just the ones that do work and the ones that don't

summer stump
obsidian granite
summer stump
#

They have to wait for the animation too already

summer stump
#

Lasers

obsidian granite
#

yeah, but their game is not going to be having performance issues

silent dove
obsidian granite
frigid sequoia
#

I literally have no idea if even "hiding the object" would requiere less procesing that instantiating a new one with just a new audio clip, seems pretty insignificant difference in performance to me

summer stump
obsidian granite
#

1st arg is the sound, 2nd is the position, 3rd is volume optional

silent dove
#

yeah, okay so transform.position should be fine i think

frigid sequoia
#

And I have never resched to the point that I need to use the profiler, yet

obsidian granite
#

i've needed to use it before to see where memory leaks were happening (because i'm stupid and my code looks like a 3 year old wrote it)

silent dove
#

now im getting and error
"Member 'AudioSource.PlayClipAtPoint(AudioClip, Vector3)' cannot be accessed with an instance reference; qualify it with a type name instead"

frigid sequoia
obsidian granite
#

it's a static method

silent dove
#

oh

obsidian granite
#

you can't call it on an instance of an object

#

call it on the class

summer stump
frigid sequoia
summer stump
obsidian granite
silent dove
#

i saw the code example, but im not entirely sure uh, you said call it on the class?

silent dove
summer stump
#

I dunno the scope of the game 🤷‍♂️

obsidian granite
summer stump
frigid sequoia
strong wren
hardy mist
#

does invalid scene equal non-existent scene?

silent dove
#

wait idk if im thinking of it right, im not sure what the class is exactly? at least in this code, would i put a new if statement in the update?

frigid sequoia
silent dove
#

im not sure where in the code i would put it i guess?

summer stump
summer stump
summer stump
#

Is it from a build, an error in code, trying to open a scene asset? Where

hardy mist
silent dove
#

that's where i had it

hot lily
#

i feel like an idiot but what's the difference between controllerMove and controllerMoveInAir?

#

ie which one should I actually use?

summer stump
silent dove
#

the if statement is for seeing if the laser has hit an enemy, so then it does all of the other things

summer stump
silent dove
#

and i tried to put the playclipatpoint there, but it came up with that error since its a private void right?
this is the code rn

#

oh

summer stump
hot lily
silent dove
# silent dove

or is it because i have the audiosource and audioclip not in the if statement?

#

im not entirely sure if thats what is needed for it to work

summer stump
# silent dove

PlayClipAtPoint is static. You are using audioSource (a reference) instead of AudioSource (the type)

summer stump
#

Does PlayMaker have a discord?

hot lily
#

huh so move in air is not something that's native to unity*? i'll ask them about it

summer stump
hardy mist
#

I don't have any errors, I'm just trying to create a safe unload method

summer stump
hardy mist
summer stump
#

Well, you haven't really explained in which cases a scene should be unloaded. Just "when it is loaded" but that doesn't make sense, because then you would just immediately unload any scene you load

You can do it however you want, so there is NO "should"
It is not an answerable question

hot lily
hardy mist
silent dove
#

ahh nice okay cool

#

its working now, thank you, i think i can use that to make the other sounds i'll need work too thank you so much, sorry i didnt get what you meant at first

hardy mist
# summer stump What?

I want to create a method to unload a scene safely, if it exists. That is the only relevant info.
It can exist. It cannot exist. It is not a subscene, so whether other scenes exist is irrelevant. Since other scenes don't affect this one

summer stump
hardy mist
hardy mist
hardy mist
eternal needle
#

seems like an odd thing to need at all

hardy mist
summer stump
eternal needle
hardy mist
hardy mist
eternal needle
hardy mist
eternal needle
#

iirc loading a scene with LoadSceneMode.Single should unload all the other scenes for you

summer stump
#

But that is kind of the point of that

abstract finch
#

Is this possible or should I just convert teh structs to classes?
-Make an array of structs
-Check if a struct is null
-Allow the struct to become null in the array.

summer stump
#

You could declare it nullable. But better might be to have a bool field called initialized or something

#

What would be the purpose of checking if it is null though? Because there may be a better way to handle it

abstract finch
#

So I have an array of 5 ragdoll infos.

#

Aftera certain period of time I want them to become null

#

but actually my approach is wrong, i could just use Time.time to structure it differently

#

ill figure it out thanks

nimble apex
#

can i ignore multiple layers on raycast hit?

#

lets say i have to ignore no.17 and 18 layers

abstract finch
#

are you using layermask?

wintry quarry
deft glade
#

this is the place where i ask for help on code right?

#

simple code*

summer stump
deft glade
#

im trying to make my sprite move continually but right now it only moves once when i click the button i assigned it to, how do i make it move without stopping.
void Update()
{
if (Input.GetKeyDown(KeyCode.RightArrow) == true)
{
myrigidbody.velocity = Vector3.right * givenvalue;
}

}

}
that is the code im using
"givenvalue" is just move speed

summer stump
#

Instead of GetKeyDown

deft glade
#

thank you!

wintry quarry
#

Velocity would otherwise stick

summer stump
#

Yeah, I should have read further. I jumped when I saw GetKeyDown

wintry quarry
#

(not accounting for friction etc)

summer stump
#

So, check any other code for velocity =
That would be the first thing to check at least

deft glade
#

public float givenvalue; my velocity is tied to this so i can see in game to make small tweaks quickly

wintry quarry
#

It could also be an issue of friction in which case you need to deal with the friction either with a custom physics material or just by doing what aethenosity said

wintry quarry
deft glade
#

sry, im really new.

#

this is my first game ive made without a step-step guide

dark hatch
#

i have an item class, having some data in it. the item class has one instance for each item, so i want to hardcode these instances and then reference it from other scripts. but, my item class has a sprite property (an image used for UI of that item), which i can't assign in a static script. any workaround?

wintry quarry
#

That's exactly what they're for

dark hatch
#

ok

#

thanks

dark hatch
wintry quarry
#

What do you mean by "static script"? Why do you need a "static script"?

#

Everything is possible

dark hatch
#

static class, my bad

wintry quarry
#

Same question

dark hatch
#

what about using a scriptableobject data in another scriptableobject?

wintry quarry
#

If you're using a static class as a beginner you're doing something wrong, to be perfectly honest

dark hatch
#

i've been using static classes for referencing, so switched one script to scriptableobject now requires me to make each on a scriptableobject

#

not that bad though

wintry quarry
#

You almost definitely didn't use a static class though. You probably have a static reference field. Static class is a different concept

summer stump
dark hatch
#

how do i serialise a jagged array

wintry quarry
dark hatch
summer stump
#

Which part do you not know?

wintry quarry
#
[Serializable]
public class Container {
  public int[] data;
}

public Container[] containers;```
#

Literally an array of objects containing arrays

native seal
summer stump
#

For referencing 😭

native seal
#

how would there be multiple items then 😆

eternal needle
native seal
#

yikes

fossil tree
#

hi i try to make a turret placement system with raycast 3D in unity but i try to make that dont put my turret if the ray touch a "obstacle" object the code:

{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity);

    foreach (RaycastHit hit in hits)
    {
        if (!hit.collider.CompareTag("Obstacle"));
        {
        if (hit.collider != null && hit.collider.CompareTag("map"))
        {
            tourelle1Renderer.material.SetColor("_Color", Color.green);
            Vector3 turretPosition = hit.point;
            Vector3 turretOffset = new Vector3(0f, -0.5f, 0f); 

            turretPosition += turretOffset;

            transform.position = turretPosition;

            if (Input.GetButtonDown("Fire1"))
            {
                Destroy(gameObject);
                putTurret1 = true;
            }

            if (putTurret1)
            {
                Instantiate(tourelle1placable, transform.position, Quaternion.identity);
            }
            
        
            break;
        
        }
        }
    
    }
}```
fossil tree
eternal needle
fossil tree
#

for getting the first thing i hit

eternal needle
fossil tree
#

like that ? RaycastHit[] hits = Physics.Raycast(ray, Mathf.Infinity);

eternal needle
fossil tree
#

oh i see

hot lily
# hot lily

After a few fruitless searches
Anyone know what Controller Move In Air is? It just exists and my only asset used is Playmaker

fossil tree
eternal needle
fossil tree
#

its ai i dont understand anything to raycast bro xd

#

i have try many tutorial

eternal needle
#

you dont even know what the code is doing, obviously its not gonna work

eternal needle
fossil tree
eternal needle
sand condor
#

Is there a way to expose this function to a UnityEvent? ScreenPosition is a public enum that is markes as serializable.

public void MoveRectToTheOutside(ScreenPosition targetScreen)
{
  MoveOutSide((int)targetScreen, null);
}

The function should move the RectTransform outside of the screen, but exactly one screen above/to the right/below/to the left. I'd like to pick the direction in the inspector via a UnityEvent on my button-component, but the function does not show up. I am using Unity 2020.3.12f1 but will probably upgrade to the newest 2022-LTS version soon.

long jacinth
fossil tree
sand condor
long jacinth
#

so when the charachter jump its supposed to disable the box collider and swap the tile texture

#

if (Input.GetButtonUp("Jump"))
{
if(RedOn)
{
RedOn = false;
}
else
{
RedOn = true;
}
}

#

this is the code for jump

#

if(RedOn)
{
Tilemap RedTile = RedGrid.GetComponent<Tilemap>();
Tilemap BlueTile = BlueGrid.GetComponent<Tilemap>();
RedGrid.GetComponent<TilemapCollider2D>().enabled = true;
BlueGrid.GetComponent<TilemapCollider2D>().enabled = false;
RedTile.SwapTile(TileGrid,Tile);
BlueTile.SwapTile(Tile,TileGrid);
}
else
{
Tilemap RedTile = RedGrid.GetComponent<Tilemap>();
Tilemap BlueTile = BlueGrid.GetComponent<Tilemap>();
RedGrid.GetComponent<TilemapCollider2D>().enabled = false;
BlueGrid.GetComponent<TilemapCollider2D>().enabled = true;
RedTile.SwapTile(Tile,TileGrid);
BlueTile.SwapTile(TileGrid,Tile);
}

#

code for switching the tile

#

but as you can see it only turns off the box collider and doesnt switch the tile texture

south sky
#

How do you pause the animation during runtime, I wanna test soemthing

south sky
# long jacinth so when the charachter jump its supposed to disable the box collider and swap th...
if (Input.GetButtonUp("Jump"))
        {
            if(RedOn)
            {
                RedOn = false;
            }
            else
            {
                RedOn = true;
            }
        }
this is the code for jump
if(RedOn)
        {
            Tilemap RedTile =  RedGrid.GetComponent<Tilemap>();
            Tilemap BlueTile =  BlueGrid.GetComponent<Tilemap>();
            RedGrid.GetComponent<TilemapCollider2D>().enabled = true;
            BlueGrid.GetComponent<TilemapCollider2D>().enabled = false;
            RedTile.SwapTile(TileGrid,Tile);
            BlueTile.SwapTile(Tile,TileGrid);
        }
        else
        {
            Tilemap RedTile =  RedGrid.GetComponent<Tilemap>();
            Tilemap BlueTile =  BlueGrid.GetComponent<Tilemap>();
            RedGrid.GetComponent<TilemapCollider2D>().enabled = false;
            BlueGrid.GetComponent<TilemapCollider2D>().enabled = true;
            RedTile.SwapTile(Tile,TileGrid);
            BlueTile.SwapTile(TileGrid,Tile);
        }
hidden sleet
#

Is the order in which stuff is picked up in physics.SphereOverlap ordered by how close it is to the centre of the sphere?

hexed terrace
hot lily
#

For health systems which i believe the health variables should be best kept as private integers,

  • I should have a maxHP component and a currentHP component for sanity's sake, correct?
  • If this health value should be able to be influenced by equipment and level etc., is it possible to affect this maxHP component by another script, or I should put those variables that would affect maxHP into the same script?
  • Does using [SerializeField] allow other scripts to reference private values, or they must be a public value regardless?
wintry quarry
# hot lily For health systems which i believe the health variables should be best kept as p...

Are you confusing "property" or "field" with "component"?

  • yes you would need to separately track max and current HP

  • if you want it to be modifiable by things you'll need to have a slightly more complex system with temporary modifiers that can be added or removed (and perhaps permanent ones too like leveling)

  • SerializeField makes the field serialized. It doesn't make it public. It's highly discouraged to use public fields.

hot lily
#

it's been 3000 years since i touched unity so i kinda don't remember how to do things already

How do I get and utilize integers that are supposed to be private if it's not possible to access it from other scripts?

wintry quarry
#

not really even a Unity thing

#

just a general OOP thing

hot lily
#

ah alright

#

thanks

tall delta
wintry quarry
#

you can and should make your fields private

#

even if you want them accessed by other scripts

#

a public field is completely open to unfettered manipulation from the outside

#

with an accessor you can carefully control the access as you choose

tall delta
#

yeah, I'm gonna have to disagree on that one

wintry quarry
#

Feel free to disagree

burnt vapor
#

Public fields are bad practice. Do yourself a favor and keep your code readable by exposing as little as possible.

#

If you need to expose variables, use a getter-property

tall delta
#

there is no functionally difference between this:

public int MyIn;

and this:

public int MyIn { get; set;}

unless you are using a library that relies on the auto-generated code for reflection / weaving purposes.

burnt vapor
#

This is why you don't use a setter in the property

#

Also there is a difference, properties are expected to be the thing you set, and your IDE actually documents what things access it

#

With a field this is guesswork, or manual searching

#

Pretty much everything in c# assumes you work with properties when it comes to setting and reading data.

tall delta
#

c# as a languages makes no assumptions like that

#

but you might

hot lily
#

an additional question
I understand that maxHP should be private, but what about currentHP? is it also beneficial to make a private+getter or just set it public (since it's likely it will fluctuate across the game)?

teal viper
burnt vapor
vernal minnow
#

A game controller should be able to handle most if not all of your variables

wintry quarry
#

For something like MaxHealth you don't want people meddling with it from outside

burnt vapor
wintry quarry
#

it should be

[SerializeField]
private int _maxHealth;
public int MaxHealth => _maxHealth;```
#

or using private setter

#

but likely you'd want an event etc on the setter. This gives you the fine grained control over the thing you need.

vernal minnow
wintry quarry
burnt vapor
vernal minnow
#

Ok, public variables occasionally won't update when you change the code in the script

burnt vapor
#

They don't randomly refuse to change, I don't know what you mean

wintry quarry
burnt vapor
#

Do you mean setting a value which is not reflected in the editor?

wintry quarry
#

that's an expected consequence of serializing something

#

there's nothing "occasional" about it though, it's completely well defined behavior

vernal minnow
#

The editor doesn't like to update variables when the script changes

wintry quarry
#

Of course not. It respects your serialized value

#

as it should

#

That would be crazy if it overwrote all of your assets

burnt vapor
#

Pretty sure you can reset a component's context in the editor if you want them updated

#

Then it would overwrite it

vernal minnow
#

Dang, I was hoping to see the variables without locking them in the editor

teal viper
#

Locking?🤔

vernal minnow
#

Regardless of how I modify the variables in the script, unless I set an on start function to fix all of them, I have to either reset the script or remove and re-add the variables to get them changed in the editor

#

I'll just swap to non serialized privates ig

teal viper
hot lily
teal viper
#

It's supposed to be a default value for each component. Not something you change periodically

hot lily
#

thx btw

vernal minnow
#

I like to test them while it's running, and when I find a value I like, I usually want to hardcode the value so I don't lose it

burnt vapor
hot lily
#

thx

burnt vapor
#

If you want you could get rid of this if you really care with aggressive inlining

hidden sleet
#

so I've got this code here which properly updates a progress bar, ```cs
public Image barImage;
[Range(0f, 1f)]
public float fillAmount;

public void GradualBarUpdate(float fillValue, float fillDuration, bool tapers)
{
barImage.gameObject.SetActive(true);
StartCoroutine(SmoothUpdateProgressBar(fillValue, fillDuration, false));
}

public IEnumerator SmoothUpdateProgressBar(float fillValue, float fillDuration, bool tapers)
{
barImage.gameObject.SetActive(true);
float elapsedTime = 0f;
float startFillAmount = barImage.fillAmount;

    while (elapsedTime < fillDuration)
    {
        float t = elapsedTime / fillDuration;
        fillAmount = Mathf.Lerp(startFillAmount, fillValue, t);
        Mathf.Clamp(fillAmount, 0F, 1F);
        barImage.fillAmount = fillAmount;

        yield return null;
        elapsedTime += Time.deltaTime;
    }

    barImage.fillAmount = fillValue;

    if (barImage.fillAmount >= 0.97F)
    {
        BarHasFilled();
    }
}
It works, which is great, but my initial approach didn't work, it just updated instantly and I wanted to double check why. I thought that how I used time.Deltatime here would be enough to show a smooth update, but it didn't work as I expected. What am I misunderstanding that led to my first approach not working?

```cs
public void GradualBarUpdate(float fillValue, float fillDuration, bool tapers)
    {
        barImage.gameObject.SetActive(true);
        float elapsedTime = 0f;
        float startFillAmount = barImage.fillAmount;

        while (elapsedTime < fillDuration)
        {
            float t = elapsedTime / fillDuration;
            fillAmount = Mathf.Lerp(startFillAmount, fillValue, t);
            Mathf.Clamp(fillAmount, 0F, 1F);
            barImage.fillAmount = fillAmount;

            elapsedTime += Time.deltaTime;
        }

        if (barImage.fillAmount >= 0.97F)
        {
            BarHasFilled();
        }
    }
wintry quarry
#

Also your Mathf.Clamp(fillAmount, 0F, 1F); line isn't doing anything whatsoever

#

anyway all this code is pretty massively overcomplicated I'd say

hidden sleet
#

On another object's interact method, so this will be when you are in proximity and have pressed E once ```cs
public class MainObjective : MonoBehaviour, IInteractable
{

public ProgressBar interactionProgressBar;

private void Awake()
{
interactionProgressBar.OnBarFilled += ProgressComplete

}

public void Interact()
{
    interactionProgressBar.GradualBarUpdate(1F, 2F, false);
}

}

wintry quarry
#
float targetFill;
float currentFill;

void Update() {
  currentFill = Mathf.MoveTowards(currentFill, targetFill, fillSpeed * Time.deltaTime);
  barImage.fillAmount = currentFill;
}

public void SetFillAmount(float fillAmount) {
  targetFill = fillAmount;
}```

I would just do this^ much simpler. No coroutines. Less code.
hidden sleet
#

I just didn't really want to put it in update since it follows the process of 'Press e -> Start filling -> Finish Filling -> Destroy ui element' having it constantly update seemed a bit redundant

wintry quarry
#

so have it disable itself when it reaches the fill amount

#

¯_(ツ)_/¯

#

(and re-enable when setting a fill amount)

#

you can use that logic for the event handling too.

#
float targetFill;
float currentFill;

void Update() {
  currentFill = Mathf.MoveTowards(currentFill, targetFill, fillSpeed * Time.deltaTime);
  barImage.fillAmount = currentFill;
  if (currentFill == targetFill) {
    enabled = false;
    OnBarFilled?.invoke();
  }
}

public void SetFillAmount(float fillAmount) {
  targetFill = fillAmount;
  enabled = true;
}```
hidden sleet
#

is .MoveTowards much different to lerp?

wintry quarry
#

the way you're using Lerp they will do the same exact thing

#

just constant linear motion

wintry quarry
#

that led to the loop just running to completion instantly

hidden sleet
#

so it's not got enough time between runs to actually see the bar move

wintry quarry
#

I mean it all happens within a single frame.

#

There's not enough time sure but also the game doesn't even render until the end of the frame

hidden sleet
#

ah, I gotcha

#

does enabled here replace how you'd use gameobject.SetActive?

south sky
#

Yo guys I want to add velocity to a character upwards but using AddForce is wrong as it adds force based on the players velocity but I want the force to be fixed. Anyway to do that?

wintry quarry
#

SetActive activates/deactivates a GameObject

#

enabled just enables or disables the script

wintry quarry
#

And what do you mean by "I want the force to be fixed"?

hidden sleet
wintry quarry
#

AddForce does exactly whatever you tell it to.

hidden sleet
#

ah, that's good to know

wintry quarry
hidden sleet
#

if a gameobject is set to inactive I take it that isn't just 'not visible', but cannot do anything

south sky
long jacinth
wintry quarry
south sky
rapid zodiac
#

I was making a 2d game like flappy bird as my first project. I wanted to add an invincibility potion where after the bird comes in contact with the box collider of the potion sprite, the box collider of the pipes are turned off for some time. Can anybody tell me which unity function can be used to accomplish this?

long jacinth
#

can someone pls tell me why this happens

south sky
long jacinth
#

whats the shortcut?

timber tide
south sky
south sky
long jacinth
#

doesnt work for me

#

xbox gamebar right

south sky
rapid zodiac
timber tide
#

Yeah that would be easier, but ideally you just flip a bool like canDamage = false

next haven
#

if i change a value (like SubEntityData) inside originalProfile, will it also change the one inside blackboard.AttackProfile

wintry quarry
next haven
wintry quarry
#

that's all

#

So again it sounds like you don't wish to add a force

#

it sounds like you wish to set the y velocity

#
myRb.velocityY = whatever;```
#

(assuming you're in Unity 2023+)

south sky
south sky
#

I love you

long jacinth
#

guys pls help me or is this not a beginner problem

south sky
long jacinth
#

ok i will see

wintry quarry
#

this means taking concrete debugging steps to see what's going wrong. Log statements, attaching a debugger, etc. to test your assumptions and see what's going wrong.

south sky
#

Is it different?

wintry quarry
#
myRb.velocity = new(myRb.velocity.x, whatever);```
#

just a little less nice

cinder crag
#

why does this keep appearing, im lost ngl

wintry quarry
#

read the error message
the error tells you which script and line number to look at

south sky
wintry quarry
#

You need to look at WeaponUI.cs Line 15 @cinder crag

long jacinth
next haven
long jacinth
#

i got no errors

#

even with full log

long jacinth
#

hmmm so i put debug.log

#

but how do i see if it while in the build