#💻┃code-beginner

1 messages · Page 61 of 1

slender nymph
#

start by getting your !IDE configured

eternal falconBOT
rich adder
#

ok you probably dont want those in the same statement tho. its not moving because the distance is never above 5

#

can you show me what kind of zoom you are doing with it, maybe there is a better way

twin bolt
#

I added a debug at where i increase the int, and it logs 5 times.

oak cove
#

"User
Error while saving prefab assets/VRTemplateassets/prefabs/setup/complete XR origin set up variant.prefab You are trying to save a prefab with a missing script this is not allowed"

Could someone assist me with this problem, I'm using the VR XR Template for Unity and this keeps popping up, I tried to delete it but thats not a good idea since it removes the entire VR camera, I haven't touched the variant and when I press save project the error pops up, I'm afraid that it will not save my entire project, is this the case or will it only not save that prefab?

twin bolt
#

While all of the texts are null

slender nymph
slender nymph
twin bolt
#

And yes i printed a string, when it increases it.

slender nymph
twin bolt
slender nymph
#

like the string and its length?

twin bolt
slender nymph
#

and you're not using IsNullOrWhitespace then

slender nymph
#

well then whatever character is in there doesn't return true for char.IsWhiteSpace 🤷‍♂️

crude prawn
#

is this how you mean?

slender nymph
#

sure

polar acorn
slender nymph
polar acorn
#

Sorry, java brain, you can just list index to get a char from a string

crude prawn
polar acorn
#

it was exactly that

#

Char 8203

#

U+200B

slender nymph
#

damn tmp adding non-standard whitespace characters

slender nymph
polar acorn
#

It's a non-zero, non-whitespace, non-control invisible character a.k.a. an absolute bastard to find

slender nymph
#

honestly this should be reported as a bug. they shouldn't be using a whitespace character that isn't actually considered whitespace as a placeholder

crude prawn
polar acorn
#

But thankfully very easy to remove, let me go find my solution from the other day

twin bolt
slender nymph
polar acorn
#

I'm opening up my project to find the right way to replace it out, hang on

slender nymph
#

should just be Trim('\u8203') right?

polar acorn
#

.Replace("\u200B", "")

slender nymph
#

ah right, 200B is the unicode for it. 8203 is the actual char value

polar acorn
#

Call that on your string that you get from the input and that'll replace that character with nothing. Then you can IsNullOrWhitespace it

summer stump
summer stump
#

Crazy, I'm glad I saw this conversation!

polar acorn
twin bolt
#

Okay

slender nymph
#

strings are immutable so they cannot be altered in place

slender nymph
rich adder
slender nymph
chilly estuary
#

i'm back with the code guys

#

the rotation point is veeeery buggy

rich adder
#

jesus that GPT code..

#

and its wrong

#

ofc

#

targetPos should be distance from cam

chilly estuary
rich adder
#

Input mouseposition is a vector2

#

well technicaly v3 but its pixel coords

#

Vector3 for "compatibility"

chilly estuary
#

so what should i do

rich adder
#
Vector3 mouseWorldPos = Camera.main.WorldToScreenPoint(Input.mousePosition);
        mouseWorldPos.z = distanceFromCam;```
#

direction prob needs .normalized too

rich adder
#

You're not familiar with your own code, and you won't know what to do with it when it breaks

chilly estuary
rich adder
#

are you working in 2D?

chilly estuary
#

yeah

rich adder
#

so why don't you look at old forums of unity that has been asked how to do this a billion times

#

read what actual people are saying

rich adder
viral hemlock
#

quick question what is the difference between LoadScene and LoadSceneAsync

rich adder
viral hemlock
#

what does async change

rich adder
#

it runs async, parallel

#

in the background

viral hemlock
#

oh ok

rich adder
#

so you can implement loading screens or something because you have "progress" till its done doing task

#

some stuff that takes time is better to use async

#

like doing large operations that can hang UI

pliant oyster
#

How do I switch my entire game to Mono audio via code?

rich adder
pliant oyster
#

I don't know what that means. I want the user to be able to press a button and have the audio switch to mono, and they can press the button again to put it back to stereo

rich adder
#

I don't think you can natively change stereo to mono in unity without Fmod

pliant oyster
#

Okay, I'll try

raw hamlet
#

How do I reference a prefab with a gameobject?

summer stump
raw hamlet
#

I keep getting this error

summer stump
#

Or better yet, use the thing you want to reference

raw hamlet
#

in the inspector

summer stump
#

And what are you trying to drag in?

#

Hopefully not a scene object into a prefab

raw hamlet
rich adder
#

that wont work

raw hamlet
#

I know you can't do it but what is the workaround it?

summer stump
summer stump
rich adder
rich adder
#

see example ^

raw hamlet
#

I already read the link but i didn't understand it

#

that is why i came here

rich adder
summer stump
rich adder
#

true, provide context to what your code does/needs to do

raw hamlet
#

Im trying to get a variable from the obstaclespawner script

#

this is the scene object

#

this is the prefab

summer stump
rich adder
summer stump
raw hamlet
#
Instantiate(obstacle, new Vector3(9, pos * 4.5f, -1), Quaternion.identity);

this is how i spawned it

rich adder
#

using the keyword this

summer stump
#
ScriptIWant newThing = Instantiate(thing);
newThing.variableICareAbout = value;
slender nymph
raw hamlet
#

but as i said i didn't understand it

rich adder
#

yeah think they're confused by Transform, you can also pass other types like a script

raw hamlet
#

thank you for your help tho

raw hamlet
summer stump
#

You can drag in a prefab with that script, instantiate it, and it'll copy everything on the attached gameobject

raw hamlet
#
DestroyOutOfBounds destroyOutOfBounds = Instantiate(obstacle, new Vector3(9, pos * 4.5f, -1), Quaternion.identity);
``` like this?
summer stump
raw hamlet
rich adder
#
 public class ObjSpawner :MonoBehaviour
    {
        public void Spawn()
        {
            var myObj = Instantiate(etc.)
                myObj.Init(this);
        }
    }
    public class DestroyOutOfBounds : MonoBehaviour
    {
        ObjSpawner _objSpawner;
        public void Init(ObjSpawner spawner)
        {
            _objSpawner = spawned;
        }
    }```
another example
raw hamlet
summer stump
# raw hamlet

Then no, change it from GameObject to DestroyOutOfBounds like I said

summer stump
rich adder
summer stump
# raw hamlet why the _ before variables?
public DestroyOutOfBounds prefab;

void SpawnMethod()
{
DestroyOutOfBounds newThing = Instantiate(prefab);
newThing.variableICareAbout = value;
}

Maybe that's clearer?

raw hamlet
#

so it is giving me an error

summer stump
raw hamlet
#

I don't know how to make it the same like you said

rich adder
#

you change the original declared type

raw hamlet
#
public class ObstacleSpawner : MonoBehaviour
{
    // Start is called before the first frame update
    public float spawnInterval = 2;
    public float timeSinceSpawned = 0;
    public GameObject obstacle;
    public int counter = 0;
    int pos;
    public int scoreCounter = 0;
    public DestroyOutOfBounds prefab;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        timeSinceSpawned -= Time.deltaTime;
        if (timeSinceSpawned < 0)
        {
            if (counter == 10)
            {
                counter = 0;
                spawnInterval -= 0.1f;
            }
            timeSinceSpawned = spawnInterval;
            int choice = Random.Range(1, 3);
            if (choice == 1)
            {
                pos = 1;
            }
            else if (choice == 2)
            {
                pos = -1;
            }
            DestroyOutOfBounds prefab = Instantiate(obstacle, new Vector3(9, pos * 4.5f, -1), Quaternion.identity);
            counter += 1;
        }

    }
}
rich adder
#

u switched them

summer stump
#

Change obstacle to DestroyOutOfBounds

#

You can drag a gameObject into that as long as it has that script

rich adder
#

I think obstacle and prefab might be diff things

summer stump
#
public class ObstacleSpawner : MonoBehaviour
{
    // Start is called before the first frame update
    public float spawnInterval = 2;
    public float timeSinceSpawned = 0;
    public DestroyOutOfBounds obstacle;
    public int counter = 0;
    int pos;
    public int scoreCounter = 0;
    public DestroyOutOfBounds prefab;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        timeSinceSpawned -= Time.deltaTime;
        if (timeSinceSpawned < 0)
        {
            if (counter == 10)
            {
                counter = 0;
                spawnInterval -= 0.1f;
            }
            timeSinceSpawned = spawnInterval;
            int choice = Random.Range(1, 3);
            if (choice == 1)
            {
                pos = 1;
            }
            else if (choice == 2)
            {
                pos = -1;
            }
            DestroyOutOfBounds prefab = Instantiate(obstacle, new Vector3(9, pos * 4.5f, -1), Quaternion.identity);
            counter += 1;
        }

    }
}
rich adder
#

prefab needs to be named something like currentObject or instance

#

w/e

summer stump
rich adder
#

DestroyOutOfBounds destroyOutOfBoundsInstance = Instantiate(prefab, new Vector3(9, pos * 4.5f, -1), Quaternion.identity);

summer stump
#

Makes waaay more sense 👆

raw hamlet
summer stump
#

If not then why use that as the type?

rich adder
#

why does destroyOutOfBoundsInstance care about scoreCounter anyway ?

raw hamlet
raw hamlet
summer stump
#

Sounds like you want an event

rich adder
#

gotcha. so just make a method to call

summer stump
#

And subscribe to it when you instantiate the obstacle

rich adder
#

this^ although events for them rn might be 🤯

summer stump
rich adder
#

please dont keep score in ObstacleSpawner next time

#

just made everything so much more confusing

raw hamlet
#

Ok sorry

rich adder
#

its ok. just remember every script should serve one purpose (for the most part when possible)

#

ObstacleSpawner spawns obs, it should not care abbout score , thats for ScoreManager

#

which could be in this case even a singleton

#

otherwise atm you pass ObstacleSpawner reference on spawn and call method or just do obstacleSpawner.score++
Shown here
#💻┃code-beginner message

raw hamlet
#

ok

rich adder
static cedar
rich adder
#

eh sometimes , I do it some times I don't. its no big deal.
Makes finding a variable in IDE that much faster

static cedar
#

Personally, if i want to find smth, i usually just hover over a variable. UnityChanThink

rich adder
#

no I mean as you're typing

#

sometimes intellicode suggests a class or something unrelated as you type a variable name

#

as soon as you do _

#

intellisense brings up all your private vars

raw hamlet
#

I have a text for gameover

#

I want to hide it at the start but not disable it

#

I already tried setactive but it disables the whole thing

static cedar
raw hamlet
#

how do i make it so only the Text part is disabled?

static cedar
#

In script?

teal viper
slender nymph
teal viper
slender nymph
rich adder
raw hamlet
#

i guess it is blurry

rich adder
#

without _

#

it still brings async as keyword

#

too slow

static cedar
rich adder
#

we each have our preferences and workflows 🙂
i just found it personally speed up mine

static cedar
amber dome
#

how to send image message?

#

How to fix this?

static cedar
amber dome
rich adder
#

idk I never used debugger on VSCode so I couldn't tell ya

#

VS is plug n go

rich adder
amber dome
lucid jetty
#

hello i have a problem with my ai he is walking towards waypoints but when i want him to go to the chase state and i stand next to him he is getting stuck even when i made the code that you needs to follow me but still he is stuck how can i fix that?

rich adder
amber dome
#

was working properly, it stopped suddenly.

amber dome
rich adder
#

you shown vscode

amber dome
#

Are you talking about Visual Studio Community?

rich adder
amber dome
#

ohhhhh, right

#

I've tried using that one too, but it still has the same error.

rich adder
#

use link website for code

!code

eternal falconBOT
amber dome
lucid jetty
static cedar
#

Oh, it's C++? UnityChanThink

rich adder
#

nah it just chose that for some reason

static cedar
#

Actually, it's probably just set to that.

slender nymph
#

no, that's just hastebin guessing the language incorrectly

summer stump
#

It's like 99% of the time what hastebin guesses in my experience

static cedar
#

The colour highlighting close enough. UnityChanSleepy

lucid jetty
rich adder
rich adder
lucid jetty
#

nope

summer stump
rich adder
#

FSM built in animator
I never used it myself though

amber dome
rich adder
eternal falconBOT
summer stump
#

Huh, ok

lucid jetty
rich adder
#

can you share the tut

lucid jetty
rich adder
lucid jetty
#

yes

rich adder
#

also screenshot your ChaseState inspector

#

put a Debug.Log inside Update of chasestate script

amber dome
#

Is that right?

rich adder
summer stump
amber dome
rich adder
rich adder
summer stump
summer stump
# amber dome

Remove the one on top (both use the one on bottom), but yeah 2.0.22 is good

slender nymph
#

are there any errors in the vs code console?

lucid jetty
summer stump
slender nymph
amber dome
#

I installed it exactly.

summer stump
# amber dome

Restart your computer
If that doesn't work, you're gonna have to find and download the sdk manually

rich adder
amber dome
#

in CMD I can use the dotnet commands, but in vscode it keeps showing up.

summer stump
summer stump
amber dome
#

But now dotnet is working properly.

rich adder
#

its cutoff

amber dome
#

Is the latest version of dotnet not supported by Unity?

summer stump
amber dome
#

I downloaded version 7.0

summer stump
amber dome
#

Are errors linked to this?

rich adder
summer stump
lucid jetty
rich adder
#

include past ones

summer stump
rich adder
#

oh ok lol
someone said they installed the SDK from site and then it started working

amber dome
#

I don't understand why this happened suddenly.

#

For now, I'm going to give up.

#

Thank you all for your support!

lucid jetty
rich adder
amber dome
#

To use Unity, do I have to define a version that is supported?

#

On Godot, the same error is also occurring, so initially I thought it was on dotnet itself.

rich adder
#

this has nothing to do with unity itself

#

its the extensions in VSCode that are shite

#

they haven't reached 1.0v afaik

#

and will be buggy for a long time

#

Visual Studio is better because its a mature code editor

amber dome
#

No way to code within Unity? no support from External IDES.

rich adder
#

I told you how

#

what dont you get?

summer stump
rich adder
#

visualstudio > vscode

amber dome
#

I'll try again, though, in Visual Studio.

amber dome
#

"Assembly-CSharp (Incompatible)"

#

what?

rich adder
slender nymph
#

Reload With Dependencies

amber dome
#

i'm noob.

slender nymph
#

right click it and select Reload With Dependencies

#

this is assuming you've actually done the rest of the configuration steps, of course

amber dome
slender nymph
amber dome
#

And how do I find this unloaded assembly?

slender nymph
#

you do have eyes, right?

static cedar
#

I think it's more that he doesn't really know what the assembly is. UnityChanThink

amber dome
#

I did here already, has an option to download

slender nymph
#

the option, when viewed in English is Reload With Dependencies. i do not read the language your IDE is currently set to so i cannot provide more information beyond that

amber dome
#

I've already managed to reload the dependencies

#

What should I do now?

slender nymph
#

does it work?

amber dome
slender nymph
#

what are you referring to?

rich adder
amber dome
rich adder
#

is it still saying Incompatible ?

amber dome
#

no

#

After I reloaded it disappeared.

slender nymph
#

then congrats, it works

rich adder
#

ok so now it says ?

#

good

amber dome
rich adder
#

now you have a real code editor

amber dome
slender nymph
#

that's just to use the debugger

#

you enter play mode from within unity

#

and to see your log you need to actually have your component attached to an active object in your scene

rich adder
#

lol have you been trying to run playmode from editor this whole time ?

rich adder
#

oh well something positive you got a working IDE now

#

future headaches avoided

amber dome
#

yes, now I've got it.

#

I never use VSCode again. 😦

slender nymph
#

now you should start with some beginner unity courses like the pathways on the unity !learn site to learn how to correctly use the editor 😉

eternal falconBOT
#

:teacher: Unity Learn ↗

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

amber dome
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

marble horizon
#

how do i disable a collider on an object in code?

silver dock
#

how do i add visual tap/click feedbacks? there is like no video for it on youtube at all

rich adder
silver dock
#

is it cause the whole game is played on UI canvas?

rich adder
#

UI canvas positions are diff than world pos

silver dock
rich adder
#

it should still work tho

rich adder
silver dock
rich adder
frozen dagger
#

how to set rotation?

rich adder
frozen dagger
#

what?

rich adder
frozen dagger
#

ok ill try

#

bruh, i wanted to set value, not add it every time

rich adder
ivory bobcat
reef patio
#

!code

eternal falconBOT
reef patio
#

and here are the errors

#

basically im trying to create a script with some custom sprites

ivory bobcat
#

Duplicate script or rename bug

reef patio
#

what?

polar acorn
#

Do you have these errors in unity or just the ide

reef patio
#

in the IDE

#

ill check Unity

#

ok fixed

#

I understand now Dalphat

ruby gull
#

I am watching a youtube tutorial and this is how the tutorial makes sure the player moves with the moving platform. But something smells here, setting the platform to be the parent of the player feels like a really bad practice. Is my hunch right?

reef patio
#

does anyone have a link for a 2d movement lesson?

#

the script I shown was some dud

summer stump
# reef patio the script I shown was some dud

Honestly, that doesn't look too bad. I like that you tried those variants of movement. One thing with the velocity (variant 2) is that you may want to have the y velocity be set to its own y velocity or a negative number to avoid floating in the air.

When you use Get for the input and use that directly, it will be setting your y velocity to 0 every frame. 0 velocity meaning trying to not move up or down.

Now, some 2d is just walking on the ground all over (like pokemon style maps/movement), but a platformer would have obvious issues with that

reef patio
#

The whole plot of script lead to a 2d sprite moving on its own.

summer stump
#

Hmmm... i am not quite sure what that means..

reef patio
#

The character I set does not connect right to the player animations, he just moves on its own without me typing a key.

#

I can show a video.

summer stump
#

Ah, you should have the SetFloat methods outside the if check

#

You only set the float when it is NOT 0
But you want it to STOP sometimes, so you need it to be set when it IS 0 too

Something like this (untested, and doesn't address the issue with Y velocity I mentioned above):
https://paste.ofcode.org/ts3KyPKq8XaWWh5TLJAs3U

eternal needle
# ruby gull I am watching a youtube tutorial and this is how the tutorial makes sure the pla...

its something that works purely for the purpose of the tutorial, which is what most tutorials are for. This would also break rigidbody movement (since directly updating transform does not respect physics).
The whole collision.gameObject.name part is pretty bad too, you dont want to rely on the name of the object. You could do layer based stuff, or whatever else to extend this to work on other objects as well.
Parenting an object will also affect rotation and scale so thats also a negative

ruby gull
silver dock
charred spoke
reef patio
eternal needle
ruby gull
#

alright thanks for the help, guess I'll also need to change how the moving platforms work, cause right now I am updating their positions directly in the script, instead of using physics

charred spoke
#

You can just calculate a velocity from that and pass it to the player

#

You dont need a rb per platform doing unnecessary calculations

ruby gull
#

thx

eternal needle
#

you dont have to use physics, but just some movement that respects collisions in your world. Like casting along an area to see if you can move there is valid

summer stump
summer stump
reef patio
#

Ok he stopped.

#

But he is not able to move.

summer stump
reef patio
summer stump
# reef patio

You have no Input Action Asset, and thus no OnMovement message is being sent

#

Do you have an Input action asset created? You just have to drag it into that top box

reef patio
#

No.

tepid cobalt
reef patio
#

I have that.

tepid cobalt
summer stump
# tepid cobalt

What they had already wouldn't show without that, just fyi

rich adder
#

click Create Actions

#

its better

#

it makes default wasd

reef patio
#

Ok I created one.

tepid cobalt
#

no one is really helping him so i stepped in

#

Its only when the wrong stuff is given people speak up lmao

#

I should do it more often

#

lets help him

summer stump
#

I was in the middle of helping

rich adder
tepid cobalt
#

triggered lmao

summer stump
#

Stop or leave.

summer stump
reef patio
#

Ok.

#

Action Maps _ Movement > "New action" +

summer stump
rich adder
reef patio
#

I can't find that.

summer stump
reef patio
#

Oh that one.

#

Ok, done.

rich adder
#

looks like you already created on before clicking it?

reef patio
#

is that ready?

summer stump
#

Instead of OnMovement

#

The default action is called Move I guess, thus the need for the change

reef patio
#

Which code?

summer stump
reef patio
#

Oh, the script?

#

Ok, done.

summer stump
reef patio
#

Nope.

#

I may have lost my animator scripts.

#

Theirs a console problem.

summer stump
reef patio
#

Ok, found it.

#

I was able to change the direction.

#

Then a error appeared.

#

I deleted "IsWalking".

summer stump
# reef patio

Looks like the animator is just not set up. You have an event with no listener

#

And I guess that would explain the warning haha

reef patio
#

That's the animator.

#

It should have some done for directional looking.

#

The 4 directions.

pine bay
#

Hey, I want ask. So i have an inventory system in my game. At first I have two object that can pickup to my inventory. a cutter and a soda can. I pick the two object to my inventory, as you can see in the image. Then, when i exit the game and play it again. All my item change into soda can.

summer stump
#

Seems like that may be an issue.

#

Is the SodaCan of type pickup?

pine bay
summer stump
summer stump
# pine bay yes the sodaCan type pickUp

So then I'm not sure what is expected in the LoadInventory method.
It finds a single random PickupInstance (a sodacan in this case) and loads that into every slot

pine bay
summer stump
#

And yeah, calling Find to get a random instance is not a good way to go about this

#

You could save a string, or an enum, or even an int. Just something to represent what was in the slot

#

Then you load that value and populate it properly

pine bay
summer stump
trail glacier
#

does anyone know why the sprite editor doesnt work it doesnt give an error message

frozen dagger
#

!code

eternal falconBOT
frozen dagger
#

https://hatebin.com/jfijhbmtey
I tried everything, but it uses 2 jumps what making it jump higher, when i dont move its ok, but after moving it always jumping 2 times and making it jump really high
before moving it -1 remaining jumps, but after moving it -2 remaining jumps

#

alr, i found what this bug is only on keyboard, when i press button on UI its ok

weak talon
#

I am trying to make my character sword hitbox chane rotation when attacking is false

    if (attacking == false)
    {
        if (Input.GetKey(KeyCode.D))
        {
            gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
            facingRight = true;
            facingLeft = false;
        }
        if (Input.GetKey(KeyCode.A))
        {
            gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 180f);
            facingLeft = true;
            facingRight = false;
        }
        if (Input.GetKey(KeyCode.W))
        {
            gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
            facingUp = true;
            facingDown = false;
        }
        if (Input.GetKey(KeyCode.S) && pScript.canJump == false)
        {
            gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 270f);
            facingDown = true;
            facingUp = false;
        }
    }

this script some how does not work though can anyone help

gaunt ice
#

the sword can only facing one direction, so you should reset all the directions no just the opposite direction
consider translation from left to up, you set down=false but not left

#

btw you can use a enum not four bools

stoic lichen
#

Hey guys!
I am working on an AR app for Google Play store and Apple app store and it is huge as it includes a lot of 3d models and meshes.

I tried using the Play Asset Delivery Package to create my App Bundle but the Upfront Asset Pack created is larger than 1GB which is the limit.

Can someone help me with this? I have already completed development and just need to publish now.

weak talon
gaunt ice
#

you can still change transform or other components of inactive gameobject from other scripts
but the update on inactive gameobject will not be called

weak talon
#

ok thank you

compact ibex
#

Hi, i would like to extract the coordinates of a vector from another one in an efficient way, for example if the player transform.forward = (1,0.5,1) and the transform.up = (0,1,0) then by extracting the up from the forward, we would have something like extractedDirection = (1,0,1) - so basically setting 1 coordinate to 0 depending on the up vector.

gaunt ice
#

it seems that you set the only one component to be 0 based on the non zero component of up vector
how about if you have a up vector eg (0.316, 0, 0.948), so which component of (1,0.5,1) will you set to 0?

#

are you trying to project a vector to a plane formed by transform.up? i dont understand what you mean actually

compact ibex
compact ibex
#

but you can also think about it like trying to point a vector towards the red cube and then negating the up component

#

which ever of these to is more efficient and easier to do

gaunt ice
#

just A-B and set y=0 if the transform.up always (0,1,0)
a faster way is to calculate x and z components only

compact ibex
gaunt ice
#

so only one component will be 1 if my understanding is correct?
check which component is non-zero and calculate the remaining two components

compact ibex
#

actually i found a good way to do it :
Vector3 directionVect = (targetPoint - transform.position);
Vector3 factor = Vector3.one - transform.up;
direction = Vector3.Scale(directionVect, factor);

solar heron
#

can anyone help me? im trying to make a Tower Defence game on 2D and is trying to make a remove tool and for some reason it not colliding? I am very confused, the part has a collider and everything here has a collider. I can send you the code here:

using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Remove : MonoBehaviour
{
    [SerializeField] bool isTouching = false; 
    // this is just a test to see if collisions work
    public void OnTriggerEnter2D(Collider2D obj)
    {
        if (obj.gameObject.CompareTag("RemoveTool"))
        {
            isTouching = true;
        }
        

    }
    public void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("RemoveTool"))
        {
            isTouching = false;
        }
    }
}
gaunt ice
#

how about the Rigidbody2D

solar heron
#

oh you need a rigidbody2d?

#

ty

vital sail
#

Anyone who can help me..? 😭 About Coroutine Error...

#

Another error was Coroutine couldn't be started because the the game object is inactive!...

but not now. I don't know why

short hazel
#

The error you screenshot is internal to Unity, it does not come from your own code, you can ignore it

#

And the error about the coroutine is pretty self-explanatory, you cannot start a coroutine on an object that's inactive

vital sail
timber tide
solar heron
short hazel
timber tide
solar heron
timber tide
#

Overlap circle may be ideal then and you can cast it at your pointer with different radius

solar heron
#

Please explain this to me like i know nothing because i have no idea what you just said lol

timber tide
#

Have you used any sort of raycasting before?

solar heron
timber tide
#

Right, so overlapcircle basically just detects all colliders at a given point in a specific radius

solar heron
#

wdym like a trigger?

timber tide
#

You give it a point in world space, and the radius of the circle. When it detects colliders you'll get an array of gameobjects that were within the radius. In this case you can check if there's currently objects occupying a space.

solar heron
#

i am gonna save this for later thank you, ill try to fix this and if it doesnt work ill use this

timber tide
#

Probably look around for better examples since the documentation stinks ;)

solar heron
#

I dont want an aoe thing, i wanna delete an object 1 by 1 but thanks for the info

timber tide
#

If you're trying to detect an area to put a unit down you'll need a way to check it first and this is what you'd probably want to use.

ruby python
#

!code

eternal falconBOT
ruby python
#

Happy Saturday all, I'm having a little trouble figuring out where to disable an object in my scene, would someone mind taking a look and pointing me in the right direction please? 🙂

RaycastHit weaponHit;
                if (Physics.Raycast(firingPoint.transform.position, firingPoint.transform.TransformDirection(Vector3.forward), out weaponHit, weaponRange, weaponImpactMask))
                {
                    Debug.Log("Hit - " + weaponHit.transform.gameObject.name);
                    Vector3 hitPoint = weaponHit.point;

                    if (weaponHit.transform.gameObject.CompareTag("EnemyCollider"))
                    {

                        MimicSpace.Mimic currentMimic = weaponHit.transform.parent.GetComponent<MimicSpace.Mimic>();
                        GameObject healthBar = currentMimic.transform.FindChild("MimicHealth").gameObject;
                        healthBar.SetActive(true);
                        if (currentMimic != null)
                        {
                            currentMimic.TakeDamage(damageDealt);
                        }
                    }
                    AdjustWaterStreamLength();
                }
                else
                {
                    AdjustWaterStreamLength();
                }

Basically I need the health bar to disappear when the ray is no longer hitting it.

timber tide
#

Why not just deactive it in the else statement there?

ruby python
#

It doesn't exist in the else.

keen dew
#

Make healthBar a field instead of a local variable, then it does

timber tide
#

You could poll each enemy independently to just set their hp bar off too, but this requires some ordering on the execution of the updates to work.

ruby python
#

Hmmm, I guess it would probably be easier to put the enable/disable code on the enemy itself, maybe compare currentHealth to previousHealth? Unless there's a way that I can have the enemy detect when it's hit by the raycast?

timber tide
#

Some ideas I'm thinking too is that you could create a buffer such that it stores the most current enemy you've have highlighted, and when you target a new enemy then you'd set the previous enemy healthbar to off and enable the new enemy's bar.

#

Would eliminate any polling

#

Well, I guess you'd have to check if you're currently highlighting anything.

ruby python
#

Hmm.....okay, this is what I'm trying on my enemy script. It enables fine but doesn't disable, so I'm not sure on the logic....

public void TakeDamage(float damageAmount)
        {
            float previousHealth = health;
            health -= damageAmount;

            if (previousHealth > health)
            {
                mimicHealthDisplay.SetActive(true);
            }

            if (previousHealth == health)
            {
                mimicHealthDisplay.SetActive(false);
            }

            mimicHealthBar.rectTransform.localScale = new Vector3(health / 100, 1, 1);

            if (health <= 0f)
            {
                DestroyMimic("Shot");
            }
        }
gaunt ice
#

previous health never == health unless damage is 0

ruby python
#

Yeah I realised the 'SetActive(false)' will never be called in this method. lol. I hate game logic sometimes.

timber tide
#
Mimic currentTarget;

private void RaycastMethod()
{
  ...
  
    if (weaponHit.transform.gameObject.CompareTag("EnemyCollider"))
    {

        MimicSpace.Mimic currentMimic = weaponHit.transform.parent.GetComponent<MimicSpace.Mimic>();
          
        if (currentMimic != null)
        {
          ChangeTargetHealthbar(currentMimic);
          currentMimic.TakeDamage(damageDealt);
        }
    }
}

private void ChangeTargetHealthbar(Mimic newTarget)
{
    currentTarget.healthbar.gameobject.SetActive(false);
    currentTarget = newTarget;
    currentTarget.healthbar.gameobject.SetActive(true);
}```
#

If you can target multiple mimics at once and you want to see all their healthbars my other idea is to do a coroutine instead and make their health appear for a set amount of time as you damage them, refreshing the coroutine on each hit.

ruby python
#

It's just one at a time (essentially point and click/hold)

#

gimme a couple of minutes.

silent idol
#

https://pastebin.com/fYgxmGqS

Is there a way to only make the wall move forwards on the X axis? It is moving on the Y axis now and it looks weird.

#

I know the script is handling stuff it shouldn't, but this is a testing script. Everything else will be subsumed into the Scene Change Event System later

thorn holly
#

So it moves down towards it

silent idol
hexed terrace
#

just don't change the value of Y

thorn holly
silent idol
thorn holly
#

Yes, that will basically set the x to your old code and lock the y to whatever is was at the moment

hexed terrace
#

a more readable way

var newPosition = new Vector2(player.transform.position.x, transform.position.y);
transform.position = new Vector2(Vector2.MoveTowards(this.transform.position, newPosition, monsterSpeed * Time.deltaTime);```
thorn holly
#

Yeah ^

silent idol
#

Thanks

cinder plover
#

Why does the mesh not go invisible?

fossil drum
cinder plover
#

I do here, and the debug log is in the command prompt

#

like i get the message it activated

fossil drum
#

Then add Debug.Log("Activated", gameObject); then you can click the log and see what gameobjects renderer get enabled and disabled.

fossil drum
#

Strange that it prints twice, but you can click it and see what object got disabled.

cinder plover
#

Nah i just didnt remove the first log

#

it activated once

#

and when i click on it nothing happens

#

nvm

#

but how does this help me

fossil drum
#

Yeah, that one should get disabled then.

cinder plover
fossil drum
cinder plover
#

i dont think so

#

should this uncheck?

ivory bobcat
#

Well that's the point. Verify it.

cinder plover
#

cuz it doesnt

ivory bobcat
fossil drum
#

These are components you want to disable.

cinder plover
#

yeah it doesnt disable

ivory bobcat
#

You wouldn't disable an object. You'd deactivate an object.

#

The components should have been disabled.

cinder plover
#

what do i do if they werent disabled

ivory bobcat
#

Figure out why. The code says they were during runtime/execution

fossil drum
cinder plover
#

i only call it once

ivory bobcat
#

Log something more relevant

#

The state of the components

fossil drum
#

What my guess is, is that SkinnedMeshRenderer derives from Renderer, and you get the same component, and disable and enable that one.
But you could check that with the logs.

fast oracle
#

For some reason this code is making my gameobject move directly up even when I rotate it

fossil drum
ivory bobcat
gaunt ice
#

you should use transform.up

cinder plover
#

Im dumb af

ivory bobcat
#

Thought that was intentional

cinder plover
#

Lmao i just missed one number

thorny garnet
#

i am a noob and i have a couple questions [:

gaunt ice
#

just ask

fast oracle
thorny garnet
#

the event functions of Update and FixedUpdate confuse me, i know that framerate can vary wildly on machines so why would anyone use Update instead of FixedUpdate

dry smelt
#

About to get a laptop with rtx 4050, is this good enough for Unity. I’m buying a new laptop and wanted to know

ivory bobcat
rich adder
#

yes its good enough

gaunt ice
#

you are using vector3.up which is in the world space, so you need to use transform.up in local space and it will be affected by rotation (after translated to world space) instead of vector3.up

fast oracle
#

It kept rotating back to 0

gaunt ice
#

position+=transform.up.....

ivory bobcat
thorny garnet
fast oracle
#

Thanks this got it working

fossil drum
cinder plover
swift crag
#

It looks to me like you have a SkinnedMeshRenderer

#

Renderer is a parent class for many different kinds of renderers.

#

MeshRenderer, SkinnedMeshRenderer, TrailRenderer, LineRenderer, SpriteRenderer, and ParticleSystemRenderer, off the top of my head

#

If you ask for a Renderer, Unity will find the first component that you could store into a Renderer variable

#

since SkinnedMeshRenderer is a child of Renderer, you'll get that

#

If there's another Renderer component on the object, then you might get that instead

#

I don't see one, though.

#

So I would expect for this code:

myRenderer.enabled = !myRenderer.enabled;
myRenderer2.enabled = !myRenderer2.enabled;

...to turn the skinned mesh renderer off, then back on

abstract finch
#
    {
        float duration = 1.5f;
        var startRot = target.rotation; // current rotation
        for (float timer = 0; timer < duration; timer += Time.deltaTime)
        {
            target.rotation = Quaternion.Slerp(startRot, endRot, timer / duration);
            yield return 0;
        }
    }```
what does the yield return 0 in the last line actually mean?
swift crag
#

It's going to be equivalent to yield return null;.

#

you know how some types have a <T> in them, like List<T> ?

#

so List<int> is a list of integers

#

IEnumerator doesn't have that. It doesn't tell you what type the enumerator gives you

#

You can yield pretty much whatever you want

#

yield return "BOO!"; is completely valid

wintry quarry
swift crag
#

Unity will look at the value and, if it's one of a small set of special types, do something with it

#

a WaitForSeconds will make it wait for the given duration before checking the coroutine again

#

I don't believe Unity has any special behavior for integers.

#

So it'll be just like returning a null.

swift crag
abstract finch
swift crag
#
using System.Collections;
using System.Collections.Generic;
#

IEnumerator isn't generic. It's from System.Collections

swift crag
abstract finch
swift crag
abstract finch
#

even though this looks cleaner is this actually better than a while loop with an if else statement?

swift crag
#
for (int i = 0; i < 10; ++i)
{
  ...
}

{
  int i = 0;
  while (i < 10)
  {
    ++i;
    ...
  }
}
#

These two chunks are equivalent.

ivory bobcat
#

Note that timer will exit before it's equal to or greater than duration

swift crag
#

If you're in a situation where a for loop makes sense, go with the for loop

swift crag
#

Might I suggest this instead?

#
float timer = 0;
while (timer < duration) {
  timer = Mathf.MoveTowards(timer, duration, Time.deltaTime);
  target.rotation = Quaternion.Slerp(startRot, endRot, timer / duration);
}
tepid cobalt
#

beep beep

swift crag
#

Although, I think Slerp is clamped anyway

#

so you could just do

#
float timer = 0;
while (timer < duration) {
  timer += Time.deltaTime;
  target.rotation = Quaternion.Slerp(startRot, endRot, timer / duration);
}
swift crag
abstract finch
swift crag
#

I like to use MoveTowards instead of adding + clamping

swift crag
#

but there's the tiny catch

#

the for loop will add to timer, then check if it's still less than duration

swift crag
abstract finch
swift crag
ivory bobcat
#

If you do the for loop approach, you'd simply need one last assignment to the expected value after the loop.

swift crag
#

I usually do it like this

#
float t = 0;

while (t < 1) {
  t += Time.deltaTime / duration;
  ...
}
#

t ranges from 0 to 1

abstract finch
swift crag
#

well, where did you put that?

#

show me the code

abstract finch
#
    {
        float time = 0;
        Quaternion startRot = _transform.localRotation;
        while (time < duration)
        {
            _targetRotation = Quaternion.Lerp(startRot, targetRot, time * speed/duration);
            time += Time.deltaTime / time;
            yield return null;
        }
        _targetRotation = targetRot;
    }```
#

I also would like to ask if I could implement an animation curve here to ease out the speed

swift crag
#

having both speed and duration is weird

swift crag
#

it'll remap the linear value of t into a different shape

swift crag
#

Also, you're factoring speed in wrongly.

#
_targetRotation = Quaternion.Lerp(startRot, targetRot, time * speed/duration);
#

Suppose speed is 0.5

#

time / duration is going to range from 0 to 1

#

since you're running the loop until time >= duration

#

So on the very last iteration of the loop, let's say time equals duration

#

time / duration is 1.

#

speed * 1 is now 0.5

#

that's the value that goes into the lerp. the rotation will be halfway between startRot and targetRot

#

then the loop terminates and you snap to targetRot

abstract finch
#

thats whats happening actually

swift crag
#

speed should be used on the next line: time += Time.deltaTime * speed / duration;

#

oh, and that line is also wrong

#

time += Time.deltaTime / time;

#

that's going to divide by zero, since time starts out at 0

#

I presume you wanted to divide by duration

abstract finch
#

im testing now with the fixes you suggestedd

#

and its working as intended now thanks

desert elm
#

Unity keeps throwing up an error that it expects get or a set accessor in the Target = mousePos
Is this a problem that needs to be fixed or just a recommendation from unity?

swift crag
#

capitalization counts!

hexed terrace
#

That VS doesn't look configured

#

!vs

eternal falconBOT
#
Visual Studio guide

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

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

swift crag
#

and yes

#

configure your code editor.

#

It should be highlighting that error.

hexed terrace
#

and the method declaration

swift crag
#

I...completely glossed over that

#

That's why it's talking about a "get or set accessor"

#
public void Florp
{
  get => blorps - 3;
  set => blorps = value * 2;
}
#

a property might look like this

#

the compiler was expecting you to define get and set accessors

#

Whenever you see an error that talks about something being "expected", you have a syntax problem.

static cedar
#

Missing bracket errors tend to point at random stuff or drag more errors.

swift crag
#

the parser sees what looks like a property declaration, but then crashes into a value that makes no sense in a property declaration

desert elm
swift crag
#

have you configured your code editor?

vagrant lynx
#

How should I use the parameter named x and y inside a blend tree in code ??

swift crag
#

you must have a working code editor to receive help.

desert elm
#

nvm I
didnt notice that I didnt add brackets sorry

desert elm
swift crag
#

So it's now highlighting the error?

vagrant lynx
#

I mean how to set values of the blend tree parameters from the code ??

#

):

swift crag
#

notice how the blend tree uses two animator parameters

vagrant lynx
#

I was watching tutorials on this but I found myself just copying what the tutorial showed and now I can't understand how they did it...... 🙂

timber tide
#

Watch it agian

vagrant lynx
#

Ok

queen adder
#

Most of the tutorials wont tell anything about the code they wrote. Maybe the coding part is the thing that makes you struggle?

queen adder
swift crag
thin sedge
#

Hi! I'm currently trying to make a sort of "collectible item" in the same sort of way that coins work in the Super Mario Bros. games. for my platformer game. And of course, it doesn't work. I would really appreciate any help I can get and am willing to give any info needed

thorn holly
thin sedge
#

I did manage to make a sort of object that got destroyed when the player touched the collider, but then when I tried to get the score function to work it was like walking into a wall. Then I tried to use a sort of score version I used for another game which was a space shooter-ish thing and it didn't work either

#

So I'm trying to get the score to work essentially

rich adder
#

didn't work isnt very helpful, show the scripts

thorn holly
swift crag
thin sedge
swift crag
#

!code

eternal falconBOT
thin sedge
#

(I kind of have it in my trash bin right now)

swift crag
#

If you're struggling with implementing stuff in general, then you should use something like !learn to get some basic experience

eternal falconBOT
#

:teacher: Unity Learn ↗

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

swift crag
#

i.e. if you have no clue how you'd increase a score counter in the first place

thin sedge
#

I'll just start over and reach the same issue and come back then. luckily, I didn't save after the issue

tepid cobalt
#

Just play garrysmod for a while then come back

thin sedge
tepid cobalt
#

can you use wiremod?

thin sedge
tepid cobalt
#

just some tools to get you on the path to self elevation if you're not into hard core studying

vagrant lynx
#

This is just increasing the value of the parameter "y" instantly to the value.
How to increase it constantly for that smooth motion ??

thin sedge
#

But I'm learning

tepid cobalt
#

all good man i just found playing around with the source engine and lua for 10yrs helped me get into game dev

#

i had to focus on an it career to make money quickly and get a house, now i can relax and study dev and not have to like... worry about a job its pretty good

#

so all i could do was play gmod

vagrant lynx
grim stream
#

Whats the class name for Text mech pro text?

wintry quarry
#

TMP_Text

languid spire
#

TMP_Text

placid wraith
#

Hey, im new to coding and im following a beginner tutorial using Csharp. I keep getting "cannot implicitly convert type 'string' to 'UnityEngine.Ui.Text" error on line 15 and im not sure why. Can someone help me

#

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

public class LogicScript : MonoBehaviour
{
public int playerScore;
public Text scoreText;

[ContextMenu("Increase Score")]

public void addScore()
{
playerScore = playerScore + 1;
scoreText = playerScore.ToString(); - error here
}

}

languid spire
#

scoreText.text

#

you need to set the text property of the scoreText instance

amber dome
#

text

#

the correct is:
scoreText.text = playerScore.ToString();

placid wraith
#

ohhhhh

#

crap sorry im new i see the problem

#

thanks

vagrant lynx
#

Okay so, my problem is fixed now. The problem was I wasn't able to reference parameters in vs code. I did it now 😌
Thanks for your support
@swift crag @queen adder

swift crag
#

Yeah -- parameters don't apper as members of the animator

#

after all, all that C# knows is that you have an Animator

#

unity doesn't generate special versions of the Animator or anything

sage mirage
#

Hello, guys! I have a question. I want to save my options settings on my game, so when I am getting back to my main menu scene to have for example Main menu music volume to be saved. I know there is player prefs to do that but could you please give me some help for that? Check here my code

{
    public Slider mainMenuVolumeSlider;


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void SaveOptions()
    {
        PlayerPrefs.SetFloat("Volume", mainMenuVolumeSlider.value);
        PlayerPrefs.Save();
    }

    public void LoadOptions()
    {
        if (PlayerPrefs.HasKey("Volume"))
        {
            float Volume = PlayerPrefs.GetFloat("Volume");
            mainMenuVolumeSlider.value = Volume;
        }
    }
}```
fossil drum
sage mirage
tulip stag
#

When writing code that interacts with the gameobject that very code is attached to, what's the difference between using this.[bla bla bla] and gameObject.[bla bla bla]

gaunt ice
#

this. is not gameobject. and not interchangable most of the time

tulip stag
#

Yes, this is why I'm asking you what is the difference

gaunt ice
#

gameobject is a property while "this" is referring the instance itself

summer stump
tulip stag
#

So for me to use this. as gameobject. I'd need to use this.gameObject.[bla bla bla]? Which would defeat the whole purpose?

summer stump
tulip stag
#

Yeah

#

Understood

fossil drum
# sage mirage Alright! I have ``options scene`` when I am entering on it and want to do some c...

Hmm, as far as I know, most people have a GameManager script and object that holds the data that all scenes use.
That GameManager is DontDestroyOnLoad and only 1 of them exists in your game, so in your Options scene you write stuff to it, and in your Main Menu Scene it still exists with the changed values where you can still call it.
You could of course do it your way of saving to preferences first, then loading the Main Scene again, and let that read the preferences again when you load the scene. UnityChanThink

quasi rose
#

I have several tpLocation empty objects, they're all 0,0,0 for rotation. I need to sometimes subtract 5 from the x, and other times subtract 5 from the z in order to position some objects. Is there a way to make this uniform so that it's always the x or always the z (without changing gameworld)?

gaunt ice
#

cant understand, why you need to randomly subtract 5 from either x or z to position (place?) some objects? or you want to place them according to some objects?

zenith cypress
steady isle
#

how can i set an enemy's rotation to rotate towards the player

quasi rose
quasi rose
zenith cypress
#

Could you not just get the normalized direction to the boat from the point, offset by some dock amount, and position it? If not, can you show an example of the boat pulling up -> where it should end up?

quasi rose
#

So I have the tpLocations all about same distance from water, hence the -5 to put boat back just a bit.

#

Example of another spot:

#

But see depending on where you arrive, the tpLocation x/z differ.

zenith cypress
#

The direction approach seems like it would work fine here. Or just rotate the tp location to face toward the water and use that to offset.

verbal dome
steady isle
#

3d

verbal dome
#

It's a pretty common thing so did you google first?

steady isle
#

sry that was unspecific

steady isle
#

prolly should have lol

verbal dome
#

Try something then ask here if you have problems

quasi rose
#

thanks gotta mess with it a bit

#

@zenith cypress

    private void RepositionJetski(Transform tpLocation)
    {
        Vector3 offsetDirection = (tpLocation.position - transform.position).normalized;
        Vector3 newPosition = tpLocation.position + offsetDirection * -5f;
        Quaternion newRotation = Quaternion.Euler(0f, 180f, 0f);
        transform.SetPositionAndRotation(newPosition, newRotation);
    }
zenith cypress
#

Is there a reason you can't rotate the tp location btw?

quasi rose
#

They are a child of a container that is 000

zenith cypress
#

Then you are in global space, switch to local space

quasi rose
#

woah

#

how many years wtf

quasi rose
zenith cypress
#

Hm? It just shows local info in gizmos/tools

quasi rose
#

Is other code going to be borked if i was (unknowingly) relying on it to be global?

#

Oh ok

steady isle
#

why is the movetowards showing as an error

solemn fractal
#

hey guys, I am spawning enemies of the same type using the same prefab, but if I want to spawn a dif enemy I basically just use a scriptable object to control their dif, Hp, exp, etc.. But my prob is if I spawn enemies of the same time, lets say 4 goblins. If I hit 1 goblin and deal 2 damage it is dealing damage to all the others goblins. and not just for that object that was spawned. how can i fix that?

zenith cypress
#

So yeah you can rotate that and use the direction of that tp point to put it wherever you want it now. And can even use that direction to orient the jetski if you want.

summer stump
#

Hovering over it will tell you why it's underlined

quasi rose
zenith cypress
solemn fractal
#

How to fix that?

steady isle
quasi rose
summer stump
zenith cypress
summer stump
# steady isle ok

To be clear. MoveTowards is a method that moves from a position to another position, and that's what the first two arguments are. So you don't separate out the x, y, and z components. You use the WHOLE vector

solemn fractal
#

!code

eternal falconBOT
sick star
#

How would I make the colors on the left have a random pattern that doesn't repeat?
For example: Red, Green, Blue OR Blue Red Green, Etc
But never Red Red Green or any other repeating colors

eager elm
solid verge
#

for some reason AddForce does not work on my prefab

#

nvm my sprite had a problem

#

Why does it not Instansiate my prefab at the location it's supposed to be instansiated

fossil drum
solid verge
#

ye hold on

#
public Rigidbody2D bullet;
public Transform BarrelEnd;

void Update()
{
    if (Input.GetButtonDown("Fire1"))
    {

        Instantiate(bullet, BarrelEnd.position, BarrelEnd.rotation).AddForce(BarrelEnd.right * 350f);
    }
}
#

maybe it's because the bullet in my prefab is place somewhere else

#

but that isn't the case

#

cause it should be moved

#

oh wait

#

nvm i don't know what to do

#

it only works if it's not a prefab but a gameobject

#

but i do not know where to hide the unused gamobject

fossil drum
solid verge
#

oh

#

inspector

#

my fault

fossil drum
#

Make sure both Bullets have the position on 0, 0, 0.

solid verge
#

kinda fixed

#

idk i just deleted and removed some components

#

same as cooking just i don't burn the house on this one

#

anyways thanks for making me go to inspector

fossil drum
steady isle
#

For when i press "w", it moves me in only one direction, not forward in the way i'm facing. This is happening with "'d" for moving right, "a" for moving left, and "s" for moving back

#

Should i be using a different command

eager elm
#

change Vector3.forward to transform.forward

steady isle
steady isle
#

it just has an error

fossil drum
#

transform.right should be fine

slender nymph
#

well transform.left and tranform.back do not exist

eager elm
fossil drum
#

-transform.right is left

steady isle
#

got

#

ty

solid verge
cinder plover
#

What does this error mean

steady isle
#

the thing is im tryna get it to go in the direction im facing, not just based on the x, y, and z axis

slender nymph
fossil drum
eager elm
steady isle
#

sec

cinder plover
#

Fixed that and got a new error

#

still the same error

slender nymph
#

also your current yield is absolutely pointless since yielding only delays execution of the current coroutine

#

nothing prevents that coroutine from being started multiple times

fossil drum
#

Oh, mine has nothing to do with the Fire error 🤦‍♂️

eager elm
#

that entire thing is super messed up as well. The waiting doesn't do anything since nothing comes after

steady isle
solid verge
#

i wanna know cause idk how to do that

#

or on pointerenter event?

eager elm
steady isle
eager elm
#

add a reference to the camera's transform in your movement script and change transform.forward with myCamerasTransform.forward

steady isle
#

so my reference wuold be public gameObject myCamera;

eager elm
#

no, public Transform myCamerasTransform;

steady isle
slender nymph
#

the yield is entirely pointless. you're also not even starting the coroutine correctly anyway

cinder plover
#

ah

steady isle
#

So the movement works but now when i look down and click "s" it makes my character jump because its -forward, and in that case forward is down. The opposite of down is up so it makes me jump high. How do i fix this issue now lol

eager elm
eager elm
solemn fractal
#

Hey guys I want to create a way that when I hit the enemy the amount of damage that I dealt will pop up above his hear and desappear 1sec later or so. What is the best way to do this? create a child Cavas UItext? Is there a way to make it spawn a UI text everytime using instanteate or anything like that?

minor hemlock
#

I need help making a sound play when an object hits the ground

#

what is the code fr that?

slender nymph
minor hemlock
#

I already have a sound that plays when the object hits the player

#

Im trying to make a different one

slender nymph
#

okay, so use the same logic there to play a sound when it hits the ground

minor hemlock
#

Im trying 😢

#

idk it just didnt work

slender nymph
#

then show what you've tried if you need help with it

eager elm
# steady isle w h a t
Vector3 fixedVelocity = myCamerasTransform.forward;
fixedVelocity.y = 0;
fixedVelocity = fixedVelocity.normalized;

rb.velocity = fixedVelocity;
//for forward
minor hemlock
#

ill try again

verbal dome
minor hemlock
#

I followeds this weird tutorial

#

idk if its the best way

verbal dome
#

@solemn fractal Could use a coroutine to spawn, animate and then disable the spawned UI text

solemn fractal
minor hemlock
#

its just
public AudioSource audioPlayer;

minor hemlock
#

if (collision.gameObject.CompareTag("Object"))

audioplayer.Play();
#

thats the one I used before

#

@slender nymph

slender nymph
#

show what you have tried for the current thing you are doing

#

i don't care what your other working code looks like. show the code that does not work

steady isle
eager elm
eager elm
solemn fractal
steady isle
raw hamlet
#

for the Update function, there is a FixedUpdate that runs after Update, what is the equivalent for Start?

slender nymph
#

FixedUpdate does not run after Update

#

but there is Awake which happens before Start