#πŸ’»β”ƒcode-beginner

1 messages Β· Page 298 of 1

polar acorn
#

Which PlayerCam instance do you want the variable cam to hold?

hexed terrace
#

right mouse click the method/ var/ type -> find references

tawny bolt
polar acorn
tawny bolt
#

sensitivity

polar acorn
#

I don't understand how that answers my question

tawny bolt
#

basicly i want my game to stop responding to my mouse when i pause

#

i tried making sens 0 but it gives me error

polar acorn
#

I'm asking you, which PlayerCam do you want the variable cam to hold a reference to

amber spruce
hexed terrace
visual hedge
# tawny bolt i tried making sens 0 but it gives me error

not so good approach. You could use your update function where the code actually responds to click and make some if statement about when they actually should respond. So basically if you pause, then don't respond. Easy as that?

#

for this you will have to use either some sort of bool like public bool isPaused = false/true; or maybe some statemachine with state like PAUSED: or maybe as you pause the game, you invoke something so it shuts the input down

visual hedge
polar acorn
#

There's a null reference because they don't understand how to reference an object

visual hedge
#

they described their actual problem in the screenshot I just sent )

#

also they told why they get null reference error. And I told them it's because they are approaching the problem from bad side πŸ™‚ But well... how about we are both right?

#

It's just me not "?" your messages

cosmic dagger
visual hedge
#

but they changed their problem and I got a screenshot of it πŸ˜„

#

maybe they understood what they are trying to do while discussing?

#

and had no idea before? Altho Ill go read that initial message )

#

Okay lemme translate that: they wanted to make new instance of their whatever float for the reason: they wanna pause and for that they wanna use another instance of the value for the state where game is paused.
I knwo you guys are all damn smart here. So smart, that you simply don't get what actual beginners and newbies are asking about. Because they themselves have no idea

hexed terrace
#

All they (currently) need to do is assign their cam var..
Then move onto the next issue

polar acorn
cosmic dagger
visual hedge
#

And I don't intend to mean that anyone isn't smart. Actually smart. That's sometimes is a problem. Experienced guys can really have 0 idea what newbie is talking about. I experienced it myself many times.

fickle plume
#

@visual hedge Why are you continuing with this? The issue was already clarified to you.

visual hedge
deft glade
#

hey can someone help me out with a issue im having?\

summer stump
#

No idea if we can until you ask πŸ˜ƒ

deft glade
#

so im following this tutorial https://www.youtube.com/watch?v=XtQMytORBmM and im having trouble with the gameObject step around 20:35

πŸ”΄ 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
rich adder
#

what is "having trouble"

deft glade
#

i cant get a second option to show up in the code component

visual hedge
#

if it's a private "option" then use [SerializeField] on top of it

rich adder
wintry quarry
#

What do you mean by "option" and "second option"?

deft glade
#

a second script

hexed terrace
#

do what he does in the tutorial πŸ€·β€β™‚οΈ

polar acorn
deft glade
#

public GameObject pipe; he types that and it just works

wintry quarry
polar acorn
wintry quarry
#

unless you messed something up

deft glade
#

its not tho

hexed terrace
#

well, he saves it too

rich adder
#

maybe compile errors

wintry quarry
#

Check for errors

hexed terrace
#

he doesn't show, or say, to save the changes to your code

deft glade
hexed terrace
#

ok, so .. let's stop guessing.. and you SHOW us what you've done

deft glade
#

it worked thank you

#

how?

hexed terrace
#

if it works, there's no need to carry on..

visual hedge
#

After you save the script, you wait for unity to compile. After it will update the inspector. Guys in tutorials may have a powerful pc that allows to compile in split of a second, especially if that's simple flappy bird. While your pc may take longer. idk

sinful helm
#

Why does unity tell me my scripts are missing, even though they are in assets, I got my code to work i think, theres no more errors with the code. But unity is telling me it cant find my scripts

wintry quarry
#

find it and remove it

sinful helm
#

Thank you

wintry quarry
polar acorn
# sinful helm

Do you have any compile errors and does the file name match the class name

sinful helm
#

No compile errors, but it is the file name thanks, sorry for asking dumb questions

tawny bolt
snow girder
#

hello

#

im trying to get a model to follow my cameras x rotation but it seems to be spinning forever

#

unless the cameras x is 0

#

the more closer it gets to zero the slower it is

wintry quarry
#

and your last line is the culprit

#

the transform.Rotate. Get rid of that. It makes no sense.

#

It's unclear what p2 is but Rotate is cumulative, not absolute.

snow girder
#

but what else can i use to make the player rotate around the camera

wintry quarry
#

wdym rotate around the camera

#

is this a first person script?

#

SET the rotation, don't add to it.,

snow girder
#

rotation.x = transform.rotation.x

#

does that work

wintry quarry
#

no

#

those are quaternions

#

don't mess with the individual components of them

snow girder
#

well what else could i do

wintry quarry
#

It's hard to say exactly what to do here without knowing:

  • The camera style (FPS? TPS)
  • Which object is which
wintry quarry
#

third person

snow girder
#

fps then

sand frost
#

@wintry quarry do you recommend any coding lessons after finishing the beginner coding and intermediate coding lessons from unity learn

wintry quarry
# snow girder what is tps

the tytpical thing is:

player.rotation = Quaternion.Euler(0, yRotation, 0);
cam.localRotation = Quaernion.Euler(xRotation, 0, 0);``` assuming the camera is a child of the player
sand frost
#

Instead of unity C#?

#

Isn't .net software

snow girder
sand frost
#

@snow girder hey I'm also 2008

snow girder
#

that's awesome

#

same birthdate

sand frost
#

Birthyear

snow girder
#

same thing

sand frost
#

Ok then

#

Gotta go

wintry quarry
wintry quarry
snow girder
wintry quarry
#

what

#

MouseY

snow girder
#

if im correct y is up and down

#

oh

wintry quarry
snow girder
#

y is left and right?

wintry quarry
#

well actually

#

sorry

snow girder
#

damn when was that

wintry quarry
#

MoujseX would be for the y rotation

wintry quarry
#

x is rotation AROUND the x axis

snow girder
#

oh

#

interesting i never knew it worked like that

wintry quarry
#

moving your mouse side to side should rotate you on the y axis

#

and vice versa

snow girder
#

neat

#

well there's also another issue

#

for some reason the model would just

#

be like a few inches above the collider

#

wait hold on let me make the collider more visible

#

the pink thing is the collider

#

and the player is above that fsr

frigid sequoia
snow girder
#

it didn't happen before

snow girder
#

and even if i do try it snaps back to this

#

if it was this simple why would i bother 😭

covert flower
#

is it possible to change find a script on an object that is disabled

#

and change an int on it

indigo bramble
frigid sequoia
teal viper
snow girder
#

but i don't know the issue

snow girder
frigid sequoia
# snow girder

Any of these seem to move the collider itself. Just the GameObject; isn't it?

indigo bramble
#

anything connected to the collider?

snow girder
#

is that stupid?

indigo bramble
#

you can put the collider on a seperate child game object

frigid sequoia
#

But shouldn't matter

covert flower
frigid sequoia
#

I mean move the collider within the GameObject, like offset it so it stands where you want it to be

snow girder
#

and it did 0

#

as in nothing

indigo bramble
#

usually I put the collider and model seperate from one another and both children to an empty

#

that way you can move the collider around

snow girder
indigo bramble
#

show us the collider component and hierarchy

snow girder
#

did nothing

#

also im trying to say that it worked before without any changes

#

so i think its an issue with code

#

but idk what

deft quarry
#

Hey all, im new to unity! Can someone please attempt to help me fix my camera jitter? It might not even be my camera jittering, but when I move around objects, they jitter and I dont know if its my camera or something else. I've had no luck with finding a solution and frankly I'm at a loss as to where to go next. I've also already tried using cinemachine but I still come up short, and nothing else has worked so far.

PlayerMovement Script : https://gdl.space/kizodiqeri.cpp
Camera Script : https://gdl.space/esadejigib.cpp

More info : https://discord.com/channels/489222168727519232/1226261265110929429

snow girder
#

try normal update

prime cobalt
#

Does anyone know how I can make an enemy using navmesh avoid a dynamically moving area around a player that doesn't have a physical obstacle? My enemies find a random location to move to a certain distance from the player but they just walk right past the player to reach it.

snow girder
teal viper
snow girder
indigo bramble
snow girder
#

i swear it didn't happen like two moments before

#

and it suddenly just happened

teal viper
# snow girder so anyone know why...

I've no clue whatsoever what the issue is and that screenshot doesn't make it any clearer. Maybe try recording a video and provide a proper textual explanation

snow girder
prime cobalt
teal viper
snow girder
#

sorry if that was rude

snow girder
#

it works without an animator?

#

like it doesn't float above collider if there's no animator?

snow girder
#

my code doesn't touch the animator either

#

yet somehow the animation makes it float above the collider

teal viper
#

It matters very much. One is horizontal offset. The other is vertical. Which one is it?

If it's due to the animator, it's probably root motion. Try disabling it.

#

Assuming it's not just an animation issue

snow girder
#

root motion is disabled...

teal viper
#

Then it's an issue with your animation

snow girder
#

hold up let me get a screen shot of the animator

#

and animations

snow girder
deft quarry
snow girder
deft quarry
teal viper
#

Record a video demonstrating the jittering

snow girder
snow girder
#

the animations are perfectly fine

#

why is it doing that

teal viper
snow girder
teal viper
#

And all of them are from mixamo?

snow girder
#

yep

#

i can even give you the exact ones i used

teal viper
#

Ideally,comment out the rotation code entirely for testing.

deft quarry
#

Yeah, moving without rotating causes them to jitter. Rotating without moving is completely fine

woeful quest
#

can someone help me this isn't loading and it just says checking for updates

teal viper
# snow girder yep

Okay. Can you put the animations in different states and try them one by one? Or even just an animator without animations

snow girder
snow girder
woeful quest
snow girder
#

lmfao why he do this with no animations

snow girder
woeful quest
snow girder
#

what version are you on

woeful quest
#

im on the same Unity account on the application and website

snow girder
#

lateast?

woeful quest
#

Oh wait

#

I know

#

1 second

snow girder
#

try this version maybe

teal viper
snow girder
woeful quest
snow girder
#

damn

woeful quest
#

what?

teal viper
snow girder
snow girder
woeful quest
snow girder
teal viper
woeful quest
#

and how do I switch to an older version?

snow girder
#

well yeah

woeful quest
#

Ok

woeful quest
#

Ok

#

done that!

snow girder
#

try it

woeful quest
#

I click on installs and what?

snow girder
snow girder
#

click here and somewhere it should say

woeful quest
#

Wait what

#

Sorry if im acting dumb I just started using Unity 3 or 4 hours ago

teal viper
#

I suggest going through the beginner pathways on unity !learn if that's the case

eternal falconBOT
#

:teacher: Unity Learn β†—

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

woeful quest
#

I found it

teal viper
#

We're not gonna teach you the basics of working with unity here

snow girder
#

i don't think its a code issue

woeful quest
woeful quest
#

ok

#

I will save and do that

snow girder
woeful quest
#

it ain't there

snow girder
teal viper
snow girder
woeful quest
woeful quest
#

ok

woeful quest
#

Don't need to talk btw just share screens maybe?

rich adder
snow girder
teal viper
woeful quest
#

or this one?

snow girder
#

maybe the second one? idk

woeful quest
#

ok

#

I will try it

snow girder
woeful quest
#

Thanks!

snow girder
#

i don't know jack about this 😭

snow girder
#

okay maybe you are right

#

cause when i tried without blend tree

#

the anims

#

the guy still floats

opal scaffold
#

how dose one make it so that a sprite moves when i hit wasd cuz i dont see a premade scrpit for that

teal viper
snow girder
eternal falconBOT
#

:teacher: Unity Learn β†—

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

snow girder
#

so maybe it is the anims

#

but i don't get it though

teal viper
#

There's no premade script

snow girder
#

the animations i took off of mixamo

#

shouldn't it work?

teal viper
teal viper
snow girder
snow girder
teal viper
# snow girder

With the hierarchy and the inspector visible and the character selected.

snow girder
#

sorry sorry

opal scaffold
#

is bolt free

snow girder
#

bro just look it up it doesn't take that much effort

opal scaffold
#

oh shit fr?

snow girder
#

😭

opal scaffold
#

nah fuck the pathways im useing bolt

#

i know how bluebrints work

snow girder
#

well good luck to you i suppose

rich adder
#

visual scripting 🀒

teal viper
#

Set it to 0

snow girder
#

been racking my head over this for like an hour before this

#

gets set to 1 again???

teal viper
#

Expand you collider settings

snow girder
teal viper
woeful quest
#

How do I play my Unity game in VR? cause I got a Quest 3 and a link cable

snow girder
snow girder
teal viper
snow girder
#

but im pretty sure its a plugin

snow girder
woeful quest
snow girder
#

i am actually so stupid

#

im so sorry for making you go through this

teal viper
eternal falconBOT
#

:teacher: Unity Learn β†—

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

snow girder
#

mad respect

woeful quest
brazen canyon
#

Hey guys
I need help a bit
I have a shop, I used SO to load the items in it.
If I click buy something, a different SO will be added to a list of scriptable object for the Inventory.
How do I drag the images, texts and stuff into the element of the list ?

woeful quest
#

lol I selected the wrong project

#

it's okay

whole idol
#

Left is Youtube, right is my screen. So, we does mine not have this mouseWorldCoordinates keyword ? it throws a red squiggly line underneath if i try just to write it in anyways.

summer stump
#

This is not a code question

whole idol
#

because the compiler has no idea what that mouseWorldCoordinate is if I go by that order

#

makes sense

late cairn
#

Hello! πŸ‘‹

Does anyone know a way to get the position of a RectTransform as if it were a direct child of the canvas? I know I can just change the parent and then get the data and change it back but that seems pretty inefficient.

Thanks for your time!

summer stump
late cairn
summer stump
late cairn
summer stump
snow girder
summer stump
late cairn
#

Either way, thanks for your time ❀️

teal viper
snow girder
#

animator. ?

sand frost
#

You again haha

cosmic dagger
sand frost
#

I thought I said that

#

Youre smarter though I'll listen

teal viper
snow girder
#

right

late cairn
# summer stump Well, I could be wrong on it haha

I ended up getting a value that was normalized between -9 and 9 on the x axis, and -5 and 5 on the y. Uncertain how these values were being calculated I didn't want to risk using them in case they were not consistent for different use cases. I'm sticking with just changing the parent, doing my calculations and switching it back. So far the performance hit is negligible. Thanks again!

summer stump
wintry quarry
sand frost
#

Ah ok

#

But it's different though right

#

Console.Writeline is like Debug.Log or something

wintry quarry
#

It's the same language

teal viper
#

Once you know C# good enough, you would know how to use the unity api

sand frost
#

Ah

whole idol
#
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UIElements;

public class PlayerController : NetworkBehaviour
{
    [SerializeField] private float speed = 3f;
    private Camera _mainCamera;
    private Vector3 _mouseInput;
    private void Initialize()
    {
        _mainCamera = Camera.main;
    }
    private void Update()
    {
        if (!Application.isPlaying) return;

        //movement
        Vector2 mousePositionScreen = Input.mousePosition;
        _mainCamera.x = Input.mousePosition.x;
        _mainCamera.y = Input.mousePosition.y;
        _mainCamera.z = Input.mousePosition.z;
        Vector3 mouseWorldCoordinates = _mainCamera.ScreenToWorldPoint(_mouseInput);
        transform.position = Vector3.MoveTowards(transform.position, mouseWorldCoordinates, Time.deltaTime * speed);
        //rotation
        if (mouseWorldCoordinates != transform.position)
        {
            Vector3 targetDirection = mouseWorldCoordinates - transform.position;
            transform.up = targetDirection;
        }

    }   
}
summer stump
sand frost
#

I was looking up my problems on the unity forums and I saw praetor blue answering it

#

Few months ago

summer stump
wintry quarry
whole idol
#

oh i meant to write_mouseInput

wintry quarry
# whole idol oh i meant to write`_mouseInput`

Why do:

        _mouseInput.x = Input.mousePosition.x;
        _mouseInput.y = Input.mousePosition.y;
        _mouseInput.z = Input.mousePosition.z;```
When you can just do
```cs
        _mouseInput = Input.mousePosition;```??
whole idol
#
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UIElements;

public class PlayerController : NetworkBehaviour
{
    [SerializeField] private float speed = 3f;
    private Camera _mainCamera;
    private Vector3 _mouseInput;
    private void Initialize()
    {
        _mainCamera = Camera.main;
    }

    public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();
        Initialize();
    }
    private void Update()
    {
        if (!Application.isPlaying) return;

        //movement
        Vector2 mousePositionScreen = Input.mousePosition;
        _mouseInput = Input.mousePosition;
        Vector3 mouseWorldCoordinates = _mainCamera.ScreenToWorldPoint(_mouseInput);
        transform.position = Vector3.MoveTowards(transform.position, mouseWorldCoordinates, Time.deltaTime * speed);
        //rotation
        if (mouseWorldCoordinates != transform.position)
        {
            Vector3 targetDirection = mouseWorldCoordinates - transform.position;
            transform.up = targetDirection;
        }

    }   
}

NullReferenceException: Object reference not set to an instance of an object
PlayerController.Update () (at Assets/_Scripts/PlayerController.cs:21)

teal viper
#

Or rather, maybe you shouldn't be doing networking on your current level.

#

Read the error. It tells you what line exactly is the problem. Check all the reference type variables on that line to find which one is being null and make sure that it's assigned.

honest vault
#

!code

eternal falconBOT
whole idol
teal viper
eternal falconBOT
#

:teacher: Unity Learn β†—

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

whole idol
#

first time Im actually clicking that link

edgy forge
#

I'm trying to understand how yield and async operations work.

        //Check the download size
        AsyncOperationHandle<long> getDownloadSize1 = Addressables.GetDownloadSizeAsync("Base");
        yield return getDownloadSize1;
        if (getDownloadSize1.Result > 0) bundles.Add("Base");```
my assumption is that the code execution waits at yield until `GetDownloadSizeAsync` has finished. is that correct?
#

that's not what it's doing for me, how is this meant to work? my downloads don't wait until they're finished and it continues on and fails before the assets are downloaded

teal viper
#

In fact, it's probably not valid anyway.

#

Check the AsyncOperationHandle documentation

#

Ah, okay, if it is in a coroutine it is valid.

#

Is it?

timber tide
#

or good way to test it is to not yield and see if your program locks up haha

edgy forge
#

what is yielding exactly?

#

is it a synonym for "wait"?

#

what I'm seeing right now is it spits out 0% downloaded then tries to instantiate the asset I told it to acquire dependencies for

polar acorn
# edgy forge what is yielding exactly?

It has a meaning in normal C# but in Coroutine terms it means "Wait until the given condition is true before resuming". The default action is "next frame" which would be yield return null. Once the wait condition is up, it resumes right where it left off with the next line. So a yield return new WaitForSeconds(3) would pick up on the next line 3 seconds later.

edgy forge
#

is the "wait" context inside the coroutine function, or in the thing calling it?

timber tide
#

in this case it basically is doing a little work, exiting the code, then picking off where it was last frame. Well, there's some internal operations going on here too done by unity too, but it is checking every frame if it is done.

edgy forge
#

I only have one coroutine so I guess that's why it's all failing

timber tide
#

otherwise your program would become unresponsive

edgy forge
#

I think I need to redesign my loader completely :/

teal viper
#

Maybe share the whole function that this code belongs to...

edgy forge
#

I think I know how to visualise this now though, thank you

#

it's not a function, it's multiple classes and scenes

#

like I said, redesign

teal viper
#

In C# any code like that needs to be in a function/method. It can't be outside.

edgy forge
#

that's not what I meant....

teal viper
#

Then share the method

edgy forge
#

no

#

the code we're talking about is in different places and it's not worth sharing

#

as we're finished here you don't need to interrogate it

teal viper
#

Surely the code that you shared earlier is in one specific place. Can you not share more of it..?

edgy forge
#

it's... not.

#

no

#

I'm going back to improve it and reorganise it

teal viper
#

Aight, you do you then...

edgy forge
#

thanks for the help @timber tide

wraith hornet
#

how can i make my game start ? my player run using update so i want to it start running only if i click "play" btn. I only know setting time step to 0

#

do u guys know better methods ?

eternal needle
wraith hornet
#

i just hide the menu canvas

eternal needle
wraith hornet
#

hmm. thanks, u are right

abstract finch
#

Is it a good idea to create a class that specifically handles the death of enemies? Since enemies dying usually turns off their update loops and logic, or is it better just use use a state machine?

crimson sinew
#

and then all the real enemy classes do whatever they do on top of the code that handles death and health and whatever

timber tide
abstract finch
timber tide
#
public class EnemyManager
{
  public void AddStatMod(StatModSO mod) { }
  public void RemoveStatMod(StatModSO mod) { }
  private void RequestEnemy(EnemySO enemySO) { }
  public void ReturnEnemyToPool(Enemy enemy) { }
}```
#

some ideas what your manager would do

#

And on your enemy something like:

public class Enemy
{
    public void ReturnEnemyToPool()
    {
        GameManager.Instance.EnemyManager.ReturnEnemyToPool(this);
        //Remove StatMods and such (could do this in the manager too)
    }
}```
eternal needle
hoary gull
hoary gull
rich adder
hoary gull
rich adder
#

did you change the script since error?

#

clear errors and run again, just to get fresh error line

hoary gull
hoary gull
rich adder
#

line 31 and 32 don't match anything here

#

select error, screenshot the full stack in console window

hoary gull
#

Although I'm pretty sleepy right now, it's 2am where I live, do you mind if I add you to talk to you after this?

rich adder
#

You may post this question tomorrow, there will be many people around to help
(btw check that you have items in array of questions or no copies with empty)

livid path
#

Hi. Is there any chance that I can draw IMGUI outside of MonoBehaviour?

ruby python
#

Hi all,

Would someone be willing to take a quick look at this and see where my mistake is please? I think it's something to do with where I'm setting isFiring = false, but I'm a little lost. At the moment, the missile Swarm only fires once (correct number of missiles spawn etc). There should be a delay before the player can fire the next swarm (3 seconds currently), but it's behaving as though the isFiring bool is never set to false πŸ˜•

https://hastebin.com/share/quxexiyice.csharp

timber tide
#

isFiring gets set to true after the first missile is fired

#

er, false

ruby python
#

I just debugged the bool and it seems to be working fine (gets set back to false when it should), so I'm at a bit of a loss tbh as to what's actually happening when I press Space the second time.

timber tide
#

Ah, ok sorry reading the logic wrong here. Thinking you invoke the coroutine in the forloop

#

so, you set shooting to true, shoot a missile and pause some amount of times, then you pause another time after the forloop and set shooting to false.

ruby python
#

Shooting = true, fire x amount of missiles, delay for 3 seconds, set shooting = false is what supposed to be happening. (Can only fire again once shooting = false, and enemy count = grid cellcount.

timber tide
#

if you haven't, start using the vs debugger and run through your code step by step

fossil drum
ruby python
timber tide
#

I was going to suggest just yield StartCoroutine from the first

#

but I don't think it makes a difference as it seems fine as is to me

fossil drum
#

Well I'm unsure what happens without yielding the other coroutine.
The first coroutine ends, so what happens with the other one? Does it end prematurely?
I think the yielding is better, or just put the code at the end of the first coroutine. Not sure why it's nested at all.

ruby python
#

Yeah I figured it out, turns out it was nothing to do with the code I posted. lol. It was how I was handling the enemyList. All fixed now and works as intended πŸ™‚

#

Thank you though πŸ™‚

ebon quartz
#

can someone tell why is my code wrong?

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

public class SpawnManager : MonoBehaviour
{
    public GameObject[] animalPrefabs;
    private float spawnRangeX = 20;
    private float spawnPosZ = 20;
    private float startDelay = 2;
    private float spawnInterval = 1.5f;

    // Start is called before the first frame update
    void Start()
    {
        InvokeRepeating("SpawnRandomAnimal", startDelay, spawnInterval);
    }

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

    void SpawnRandomAnimal()
        {
            int animalIndex = Random.Range(0, animalPrefabs.Length);
            Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), 0, spawnPosZ);

            Instantiate(animalPrefabs[animalIndex], spawnPos, animalPrefabs[animalIndex].transform.rotation);
        }
    }
}```
#

Every time I try to invoke the SpawnRandomAnimal it just repeats this in the console and idk what I am doing.

ruby python
ebon quartz
terse gazelle
# ebon quartz

DonΒ΄t forget to remove the dot between GetComponent and < as well

ruby python
#

a Vector3 needs 3 floats, x, y, z

queen adder
ebon quartz
queen adder
#

One more thing.

#

Instead of using Vector3, try using Vector2.

#

Vector2 uses only X and Y

ebon quartz
terse gazelle
#

don't think that will work - position only takes in a Vector3 iirc. Might be better off doing ``new Vector3(coordenada_x_camera, transform.position.y, 0f);`

queen adder
#

Dang.

ebon quartz
ruby python
#

I think the camera does need a Vector3.z component even if it's a 2D game?

#

Because the camera still exists in 3D space.

ebon quartz
ruby python
#

Could be wrong tought tbh, I don't do 2D. lol.

ebon quartz
#

you are right

#

one more thing, why does my platform look weird?

ruby python
#

Yeah, so just add ((camera)).position.z to your Vector3 and I think that'll be fine.

#

Looks like you may have weird 'edge' pixels on your sprite?

ebon quartz
#

it isnt suppossed to be like that

ruby python
#

Photoshop has a habit on some images of kind've adding transparency on the very edge pixels.

ebon quartz
#

i didnt make these assets, the tutorial guy told us to do it like this

#

and it looks good in the tutorial guy

ruby python
#

Okay, well it looks like you're 'stretching' your sprites, so their edges are going to be 'mushed' up.

ebon quartz
#

ohhh ok

#

how do i fix that?

queen adder
#

That is my advice.

ebon quartz
queen adder
#

dang.

ruby python
#

Keep the dimensions of the sprites the same as the tutorial. While you're learning don't change anything at all, do the tutorial 1-1, best advice I can give.

queen adder
#

everyone gone now :(

#

fixed it

ebon quartz
queen adder
#

i accidently put the code in update

ruby python
queen adder
#

srry-

ruby python
#

Nah sokay, cool that you figured it out for yourself πŸ™‚

flint rose
#

I finally created my fist game UnityChanCelebrate it was not that hard except for the fact that I kept forgetting to build it 4 times so I had to start overπŸ˜…

burnt vapor
eternal falconBOT
maiden parcel
#

hey there, i got a code problem and i dont know why is having this error

#

it says that is in that line

slender nymph
#

either your AudioSource variable is null or it has no clip assigned to it

maiden parcel
#

i have assigned

slender nymph
#

oh and you also need to pay attention to the warnings in your IDE because that Play call is irrelevant to the if statement

slender nymph
# maiden parcel

either you reassign it in the code or you have more than one component where one of them does not have it assigned

visual hedge
maiden parcel
visual hedge
#

semicolon means " ; "

maiden parcel
#

i wanna if an object colission, the audio reproduces

long jacinth
maiden parcel
visual hedge
slender nymph
slender nymph
eternal falconBOT
#
πŸ“ Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

maiden parcel
visual hedge
# maiden parcel it says that is in that line
if (collision.gameObject)
  {
  Dano.Play();
  }

And please don't get me wrong, but I am strongly against language specific symbols. I guess none would like to work with a code if methods would be called in let's say arabic or chinese.

maiden parcel
#

sorry

visual hedge
#

How savage would that be?

  void εšι‚£δ»ΆδΊ‹()
  {
  }

?

swift elbow
visual hedge
#

nah, don't be sorry. It's just kind of friendly suggestion to not use language specific symbols

swift elbow
visual hedge
#

Nah it's addressed to Sasaki person πŸ™‚

swift elbow
#

how much coding knowledge do you have?

maiden parcel
visual hedge
#

they don't know why. Because common knowledge is that every line of code should end with semicolon I think or jsut a typo πŸ™‚

swift elbow
maiden parcel
#

i mean, we are studyng animation and 3D, and they want we to program a game with 0 knowledge of coding

visual hedge
#

oh... okay... anyways, the semicolon, the first one, should not be there

swift elbow
visual hedge
#

other than that I am not sure if the collision.gameObject part is correct

swift elbow
maiden parcel
visual hedge
#

post the problem and people will decide if they can

swift elbow
#

dont ask just to ask, post your question in detail

maiden parcel
slender nymph
#

then do so

visual hedge
swift elbow
maiden parcel
#

they only teached us about the lenguage (sush a what is void, if loop...)

#

nothing more

visual hedge
#

there's no if loop

swift elbow
visual hedge
#

theres for each and for loop

swift elbow
maiden parcel
visual hedge
#

what is your code now?

maiden parcel
slender nymph
# maiden parcel

look at that, you finally showed your code and proved i was right all along! you are reassigning your Dano variable in Start

visual hedge
maiden parcel
visual hedge
#

yours won't work like you intend it if you don't use the built in unity method

maiden parcel
#

i mean colision

visual hedge
#

yes, so you should use the built in collision detection method

swift elbow
#

a trigger is a type of collision

maiden parcel
#

oh

slender nymph
visual hedge
#
    void OnTriggerEnter(Collider other)
    {
    }
``` this is the method... and it will work for 3d object.
slender nymph
#

the only things wrong with their code are the reassignment of Dano in Start since they assigned it in the inspector. and the if statement inside of OnCollisionEnter is pointless since it's just nullchecking the colliding object which can never be null

visual hedge
#

that was next thing I was going to point out

slender nymph
#

well considering that won't work with their current setup since OnCollisionEnter is working just fine, the entire suggestion is wrong

visual hedge
#

yeah, entire. Starting with suggesting to remove the semicolon πŸ™‚

maiden parcel
#

im lost right know notlikethis

swift elbow
slender nymph
#

ignore almost everything that TylerWin suggested

visual hedge
#

one more pro than another. Love to correct others rather than involve themselves and help people πŸ™‚

slender nymph
#

except i was the one helping with their issue

visual hedge
#

said 0 words about semicolon ) A+ help

slender nymph
#

just because i didn't specifically say the word semicolon (which by the way was entirely unrelated to their issue and did not change the logic in any way) does not mean i didn't point out that mistake. i pointed it out before you
#πŸ’»β”ƒcode-beginner message

visual hedge
#

get a cookie πŸ˜‰

#

Have a nice day

slender nymph
#

if you are going to help people, at least focus on the actual issue before derailing the entire conversation for another mistake and then suggesting that they should be using OnTriggerEnter instead of OnCollisionEnter when their OnCollisionEnter method is already working just fine

swift elbow
#

prob dont know tag useages

slender nymph
#

that's not what an XY Problem is

slender nymph
# maiden parcel you mean like this?

yes. your previous if statement was just checking that collision.gameObject was not null, but it's not possible for it to be null there
though you do probably want some other logic there such as checking a tag or for a component if you don't want the sound to play every time it collides

queen adder
#

Hey, I'm trying to make a cutscene scene consisting of 5 frames that change every 4 seconds. Currently my plan is to import the frames with an array, iterate through, and modify the z position of the first frame, then the second frame and so on to have them transition until the timer reaches zero and the scene is loaded. What would be the best way to achieve this intended behavior, since it seems like I can't modify the z-position of the image?

swift elbow
swift elbow
maiden parcel
slender nymph
#

cool then that should work just fine

#

unless of course this is on the player and it can collide with things like the ground or environment without getting hurt

visual hedge
#

@slender nymph you are totally right. This is exactly what was causing that exception error.
Still... don't you think it was useful to ask them (what I did) why is the semicolon in there and also suggest for them to use proper unity method for collision detection?
I mean you are right to pick up on me, no questions asked, but I mean...

slender nymph
maiden parcel
#

it still having the error πŸ˜…

slender nymph
#

did you remove the line from the Start method?

maiden parcel
#

i got it like this

#

i dont know if that what you mean

slender nymph
#

yes, make sure you have saved and unity recompiled. and make sure that the AudioSource is still assigned in the inspector

#

if it is and you still receive the error then you have a copy of the component in the scene without it assigned

maiden parcel
#

it works

#

thanks you all πŸ₯Ί

visual hedge
#

yaay πŸ™‚

maiden parcel
#

sorry for inconvenience, im really lost at this

swift elbow
visual hedge
final kestrel
#

I have a prefab with some serialized stuff in it. Do I have to everytime assign the things whenever I drag and drop the prefab into my scene?

swift elbow
#

if they are scene objects, then yes. If they are prefab references, then no

slender nymph
final kestrel
#

All right thanks.

burnt mantle
#

Hi guys how to set position to localPosition when setting parent, like i have an object and i want to stick it to an other object

slender nymph
#

how to set position to localPosition when setting parent
could you elaborate on what exactly you mean by this

burnt mantle
slender nymph
#

when you call SetParent pass true for the worldPositionStays

burnt mantle
#

its not working the object is too low in y axis

slender nymph
#

if it's position is changing at all when doing that then something else is affecting the position and you would need to show code and how the objects are set up

slender nymph
#

unrelated to the issue, but you should be using the CompareTag method rather than string equality to check an object's tag

#

and please show how these objects are set up and if you could, a video (or at least some screenshots) of the issue

slender nymph
#

like the inspectors for these objects. you know, how they are set up in the scene

burnt mantle
hexed terrace
#

if you just do what's asked, you'll get your problem solved quicker

astral cedar
#

the last line of code at 46, cs private void OnCollisionEnter2D(Collision2D collision) {}, doesnt turn cs OnCollisionEnter2D() as blue but as yellow

swift elbow
eternal falconBOT
astral cedar
#

i tried

slender nymph
swift elbow
#

ah sorry i just realized youre talking about color, nvm then

spiral narwhal
#

Do you guys name variables specific to your game, or try to abstract the names away as much as possible?
For example, in my game, I have a variable fuelPower, which essentially is just mana. Should I name it mana instead in case the name changes in the future?

swift elbow
#

if you encounter name changes, change it in your script at the same time as in your scene

#

(so you dont lose track)

hexed terrace
#

why would you use mana, if mana isn't a thing in your game? You use names that make sense to what you're developing

slender nymph
swift elbow
hexed terrace
cosmic dagger
spiral narwhal
#

It's a card game in a sci-fi setting. So players DO have literal mana to spend on cards each turn :D It's just that it is represented as "fuel power" for the setting

#

And maybe that name will change, not because of the variable itself, but because of the lore, setting, etc.

tall delta
# spiral narwhal Do you guys name variables specific to your game, or try to abstract the names a...

if it's a generic class/lib that you plan to reuse, then try and keep the names generic too.
IE: I have a Health script I've reused many times, but in the game, 'health' might be time, energy, mana etc, etc.

other than that I find that keeping it consistent is the best way to keep your 'mental map' of the code up to date.
so in your case if you call it mana in the script, then have a FuelPowerUIComponent, and a PowerTracker component etc, etc, then you end up with 4-5 different names for the same concept, and that can become confusing quick.

swift elbow
spiral narwhal
#

Okay gotcha guys, thanks

astral cedar
slender nymph
#

is the tutorial using visual studio rather than vs code? because visual studio will highligh unity messages as blue. i don't think vs code does, but if it is configured then it is already working correctly

hexed terrace
#

It depends on your settings, and which IDE you use, by default it's yellow in VSC

#

I'm gonna go ahead and say that the person making that tutorial doesn't know what they're talking about

astral cedar
#

im gonna send a screenshot and tell me if is VS studio or not, sorry for that

slender nymph
#

all that really matters here is that vs code is configured

wanton canyon
#

OK so putting being held within an if statement did help, there's just a weird thing where if you pick up a slime while looking down it is sideways thonk (being held works by becoming a temporary child of the player, going into a grab slot. and looking at the player main camera)

astral cedar
slender nymph
# astral cedar

yes, this is visual studio not vs code. in visual studio unity messages like Awake, Update, and OnCollisionEnter are highlighted in blue when configured correctly

astral cedar
#

ok thank you

hexed terrace
#

as long as when you type "oncol" intellisens pops up with suggested completes.. don't worry about the colour

timber tide
#

the goal is to try to get the child to rotate only on the y

timber tide
#

but it looks like when childing and doing lookrotation it's introducing some roll into the equation

wanton canyon
#

yeah I wish there was a way to make its roll set but the only thing I came across was freezing rigidbody rotation and that wont work

timber tide
#

I dealt with a similar situation quite a while ago and kinda just played with a bunch of ideas until I got it

#

angleaxis can help too, as you can manually set the rotation per axis, but it's a bit of work

timber tide
# wanton canyon

try resetting the child rotation before childing too for the heck of it

#

really odd it is introducing roll

#

lookrotation by default will rotate using y axis using world up

wanton canyon
#

yeah that's there to get the slime to look at ya

wanton canyon
timber tide
#

here's a better idea. When you pick up the object, reset the position and rotation to zero/identity, now offset the postion of the child by an amount of units on the local z

#

this should now offset the object directly in front of you with similar rotations, now by using lookrotation, or angleaxis on the y, rotate it towards the character

#

from there, play around with your offsets, you can probably offset it a bit more to the x+ axis local to keep it on the side a bit like you're doing too, and then using lookrotation then

timber tide
scarlet skiff
#

im no good at math but this shouldnt be 0

swift elbow
#

i think its because you are using int values

wintry quarry
#

5 / 10 is 0 with a remainder of 5

scarlet skiff
#

so 10 should be 10f?

hexed terrace
#

yep

wintry quarry
#

Also if you want the random number to be a float the inputs need to be floats too

#

right now you'll only get 4 5 or 6 precisely

amber spruce
#

hey so i want to store the current scene and then load it later how would i do this i tried just saving it as a Scene variable it doesnt seem to work though

wintry quarry
scarlet skiff
amber spruce
wintry quarry
#

just the name of it?

#

Or the actual state of the scene?

wintry quarry
#

with all the objects as they are

amber spruce
wintry quarry
#

you can't just take a snapshot

amber spruce
#

so i can go back to that scene

wintry quarry
#

currentScene.name

#

or currentScene.buildIndex

amber spruce
#
SceneManager.LoadScene(saveObject.currentScene.name);

so this?

wintry quarry
wintry quarry
#

saveObject.sceneName

#

don't save the Scene object it's not particularly useful to you

wanton canyon
amber spruce
wintry quarry
#

yes

timber tide
wanton canyon
#

ah crap, sorry read that wrong

timber tide
#

Im feeling like it's just too close to the pivot and getting a zero direction

#

I would try to get it working without offset the pos on the x or y first

wanton canyon
#

got it, gotta brb rq then will update

timber tide
#

If you want it closer to the camera, you may want to make an empty gameobject behind the camera to look at

sinful helm
#

Could anyone help me with my code, the floats and all show up, it just wont work, and i dont know which parts not working

sinful helm
swift elbow
#

!code

eternal falconBOT
sinful helm
#

like that?

hexed terrace
#

now explain the issue

sinful helm
#

The character wont jump, I am not getting an error from unity, and i dont know the language well enough to be able to spot whats wrong, it might be line 15

#

never mind sorry, as i posted it i saw that i hadnt put the true value in

hexed terrace
#

This is pointless btw

if (grounded) {} 
else if (!grounded) {}

You can just do

if (grounded) {}
else {}

Because if grounded is false, then it won't pass the first condition, so it's else will.. as a bool can only be true or false

sinful helm
#

Thank you, I'll change that now

swift elbow
halcyon geyser
#
if(!grounded) { return; }
swift elbow
#

you should consider just calling a func that changes the bools value to its opposite by using readyToJump != readyToJump

#

this will let you be much more organized

hexed terrace
sinful helm
#

Thank you

wanton canyon
#

@timber tide OK yeah it is further from the player now

stuck palm
#

what happens if i start a coroutine on a gameobject then start the same coroutien again?

frosty hound
#

It runs two of them

willow scroll
stuck palm
willow scroll
frosty hound
#

Yes, that's what StopCoroutine is for

stuck palm
timber tide
#

could always comment out lookrotation and apply the child and offset, go back to scene, and spin it on the y to see if it's correct

signal dew
#

Hi i wanted to find a tutorial for a game mechanic like the one described in the screenshot for my cooking game but i am just not able to find one. Maybe someone here can find one or at least knows the name of that type of mechanic.

willow scroll
swift elbow
signal dew
# willow scroll Could you send the Stack Overflow link?
swift elbow
signal dew
#

yes exactly!

swift elbow
#

i really cant remember what the game is called and i cant find it πŸ€·β€β™‚οΈ

dusky coral
#

I am not able to install unity editor I am getting error how to solve it

Editor application

Install failed: Validation Failed

swift elbow
eternal falconBOT
#
When Unity fails to install checklist
  • Make sure you have enough space including on C: drive.
  • Check that it's not being blocked by antivirus/security programs.
  • Look through the logs for a real reason why the setup fails they are pinned [here](#πŸ’»β”ƒunity-talk message).

If you still have issues, perform a clean install in another location:

  • Install the Hub and Unity in a non-system drive or a clean new folder in the root of C: drive.
  • Failing that use the recovery Refresh option or reinstall OS entirely then repeat the previous step.
hexed terrace
#

Went through 6.5 pages on the asset store to find it, because I couldn't remember the name

dusky coral
#

getting this error i have around 200gb space in my drive

slender nymph
eternal falconBOT
#
When Unity fails to install checklist
  • Make sure you have enough space including on C: drive.
  • Check that it's not being blocked by antivirus/security programs.
  • Look through the logs for a real reason why the setup fails they are pinned [here](#πŸ’»β”ƒunity-talk message).

If you still have issues, perform a clean install in another location:

  • Install the Hub and Unity in a non-system drive or a clean new folder in the root of C: drive.
  • Failing that use the recovery Refresh option or reinstall OS entirely then repeat the previous step.
wanton canyon
# timber tide try getting it to rotate nicely without the x/y offset

It feels like part of the issue is if I offset the rotation, it will, but depending on how much it decided to be rotated already thonk Like I grab the slime from the side and it's rotated a little. I grab it looking down and it's upside down instead of sideways. Anyway building and testing commenting out lookrotation with a manual rotation offset

wanton canyon
#

yeah it is still rotating when I pick it up... ahhhhhhhhhh

signal dew
slender nymph
#

you don't change it. you can AddListener via code to subscribe the one you want subscribed and you can RemoveListener to remove subscribed methods (this cannot remove persistent listeners)

#

lol they deleted it as i answered

tender stag
tender stag
tired spear
#

can anyone help me with an error i have?

swift crag
#

perhaps if you share it (:

tired spear
#

ok can anyone help whit this error im very new to this so this is my error: Library\PackageCache\com.unity.ai.navigation@1.1.5\Editor\NavMeshAssetManager.cs(172,65): error CS1061: 'NavMeshSurface' does not contain a definition for 'IsPartOfPrefab' and no accessible extension method 'IsPartOfPrefab' accepting a first argument of type 'NavMeshSurface' could be found (are you missing a using directive or an assembly reference?)

slender nymph
#

make sure your packages are up to date, and if the issue persists after updating then close the project, delete the Library folder from within your project (only that folder and its contents) then open unity again and it will regenerate the cache

tired spear
#

ok thanks

edgy prism
#

Just ran into this funny error I asumme just do what it says on the tin but im curious why its happening in the first place

polar acorn
#

Probably a prefab

edgy prism
polar acorn
swift crag
#

it's probably not what you meant to do, no

wanton canyon
#

figured it out!!! it was beacuse I started this using LookAt I believe. I just deleted everything and then set it locally manually. @timber tide in case you wanted to know

edgy prism
polar acorn
#

If you want to destroy the copy, you would need to call destroy on that, not the prefab it was copied from

edgy prism
stuck palm
#
Quaternion cameraTargetRotation = Quaternion.Euler(0f, 180f, 0f);
            cameraContainer.transform.rotation = cameraTargetRotation;

Quaternion cameraTargetRotation = Quaternion.Euler(0f, 0f, 0f);
            cameraContainer.transform.rotation = cameraTargetRotation;

why does 180f translate to y = -180 and 0f translate to y = 180f?

slender nymph
#

eulerAngles for a quaternion are interpreted at the time they are accessed. there are any number of values that can express the same rotation, do not rely on specific values to be displayed/returned

stuck palm
swift crag
#

you don't

#

The editor does store euler angles strictly for the purpose of letting you type something like 3600 into the rotation field, but those aren't actually used by the Transform component

#

When you construct a quaternion out of euler angles, that quaternion has no memory of the euler angles you used

swift crag
eternal needle
#

If you're relying on specific euler angles, then keep track of the euler angles yourself. The conversion of euler to quaternion to euler will always eventually give you different values that lead to the same rotation

swift crag
#

(you're setting world-space rotations, and the inspector shows local-space rotations, so having a parent matters here)

stuck palm
#

im trying to get a camera to always face one way when the character faces another way

swift crag
#

a transform with Quaternion.identity for its world-space rotation (which is what Quaternion.Euler(0,0,0) gives you) will face world +Z

rigid jay
#

Hello everyone! I'm new here. So I am starting my first First Person Movement and Camera, is there anyone who could help with that?

#

I have the camera and Capsule set up already.

slender nymph
#

what help are you looking for? if you are looking for someone to guide you through creating those, then find a tutorial. if you need help with your implementation then show your code and describe the issue you are experiencing with it

eternal falconBOT
#

:teacher: Unity Learn β†—

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

rigid jay
#

Thank you!

timber tide
#

Usually you can just use render objects and disable writing to depth

wanton canyon
#

yeah there are a few issues around rendering... their outline disappears when looking at the water as well

timber tide
#

Then switch layers when picking them up

stuck palm
#

is there a way to keep reference to an object afters its been destroyed like a character for example?

public class MatchTrackerData
{
    public Character player1;
    public Character player2;
    public Character player3;
    public Character player4;

    public Character winner;
}
polar acorn
#

If it's been destroyed what are you trying to reference

stuck palm
#

from each character

polar acorn
slender nymph
stuck palm
#

i thought it would be easier to just keep a copy of the character class

#

but i forgot when it gets destroyed t he reference is useless

slender nymph
#

you can create a class or struct that contains the data for a single player and pass that around when necessary for each player

raw aspen
#

im trying to invoke this unityevent but when i add the scriptable object i get nullreferenceerror. i thought i could call scriptable object public methods like this. what am i doing wrong?

slender nymph
#

you can, the error is likely inside that Raise method

#

or perhaps somewhere else entirely, you'd have to show the error message

summer stump
# stuck palm that works

Just keep in mind, any time you feel like numbering your variables (player1Kills), something is going wrong.

raw aspen
#

the raise method is empty though its just for the listeners to do something off it

#

when i only have the fence wall setactive false i get no errors

slender nymph
#

so you have nothing at all inside of VoidEventSO.Raise? not even an event invocation in there?

raw aspen
#

sorry youre right here is the code

slender nymph
#

yeah so then something subscribed to that event is what is throwing the NRE

raw aspen
#

ohhh because the object which has the listener is disabled?

slender nymph
#

a disabled object would not throw an exception just because it is disabled. whatever code is running as a result of that event being invoked is throwing the exception

raw aspen
#

tyvm ill look into it

wintry quarry
raw aspen
#

i see it

slender nymph
#

your error is on line 34 of QuestAnimationManager

raw aspen
#

ty its clear now

green copper
#

if I have the inventorySlot script referenced, can I change the color of the image component? Or do I also need to get the image or gameobject directly?

cinder crag
#

im a bit confused and lsot , how can i get rid of this warning 😭

#

nvm saw

#

the problem

#

mb

sharp copper
rich adder
swift crag
#

You should always try to use serialized references instead of a bunch of GetComponent calls

#

It's fine to create components whose only real job is to be a bag of references

#

(you'll often wind up adding functionality to them later)

green copper
#

There has to be a more effective way of doing code on inventory slots corresponding to numpad keys, but I cannot think of it

#

I want the player to be able to tap the button to build the blueprint, and hold it down to self destruct the building

rich adder
#

new input system would probably be less of a pain, aside from initial learning curve

languid saffron
#

My game object won't disable on collision, I've tried multiple methods like disabling the game object with a certain tag on collision.

carmine sierra
#

thanks but they told me that already

languid saffron
#

I'm pretty new to unity

rich adder
languid spire
polar acorn
rich adder
#

also not sure what goal of that collision one is...if powerup collides with powerup then destroy the other?

scarlet skiff
#

bro how du u freeze x rotation via code? rb component

#

the docs arent really helping

scarlet skiff
#

how do i make it use the 2d one

#

do i just add (Rigidbody2D)

#

idk

final yoke
#

hey yall im trying to change a text but the console said i did not refer to it in the editor (even tho i did) i usually solve this issue by refering to a tag in the code editor which works with object but i dnt know ho to apply it to tect any ideas ?

wintry quarry
#

Write the 2D one lol

rich adder
#

there is no rotation on x for RB2D

scarlet skiff
#

its position no roation

#

i basically dont want it to move "left" or "right"

rich adder
#

well u said rotation

wintry quarry
#

Why'd you say rotation then

summer stump
scarlet skiff
scarlet skiff
#

lol

rich adder
#

always check the docs

wintry quarry
#

The error message also said the right thing

rich adder
summer stump
#

That took forever to upload!

scarlet skiff
#

oh dang

#

alrighty noted

potent tangle
#

What is the best way to design a point and click locomotion?
Nav Mesh?

And if the character needs to walk around objects, should they be a Rigid Body or Character Controller?

rich adder
#

yes navmesh

#

they even have the example for it inside docs

potent tangle
queen adder
#

Hello, I'm trying to make a sprite flip using it's rotation with the animation controller, but I'm having some struggle

honest haven
#

Hi im trying to add a particle to the players weapon game object. The code works, but the issue i have is the particle follows the game object, which is correct becuase its a child of weapon. But how can i stop that i just want the particle of the weapon container to be the starting point ```public void MeleeParticleEffect(GameObject effectPrefab)
{
GameObject activeWeapon = FindActiveWeapon(weaponHolder);

    if (effectPrefab != null && activeWeapon != null)
    {
        GameObject effectInstance = Instantiate(effectPrefab, weaponHolder.transform.position, weaponHolder.transform.rotation, weaponHolder.transform);
        effectInstance.transform.localPosition = Vector3.zero;
        Destroy(effectInstance, effectInstance.GetComponent<ParticleSystem>().main.duration);
    }
}```
rich adder
# queen adder

whats the problem? what are we looking at? whats supposed to happen?

queen adder
#

So basically after it finishes the "flip" animation it returns to the normal animation, but it flips back to the right, is there any way to keep the rotation to the left?

rich adder
#

keep a bool that tracks your facing direction

#

like IsFacingRight

#

or something

wintry quarry
queen adder
#

I tried using a float that stores the horizontal input, but then it just keeps flipping continously

rich adder
#

or something

#

it would not constantly flip

#

triggers would

spiral narwhal
honest haven
queen adder
#

Doesn't even work with bool

rich adder
#

I would suggest studying up the animator further

honest haven
wintry quarry
queen adder
honest haven
rich adder
#

its confusing cause its new, look at multiple sources and eventually it looks less scary

queen adder
#

Thanks anyway

rich adder
#

sry but idk what you're looking for, if explain it further will just confuse you and i dont feel like going back n forth to give a crash course on animator

swift crag
#

A two-dimensional list gives you an adjacency list, where each vertex in the graph has a list of vertices that it connects to

#

a 2D array is closer to an adjacency matrix, which would be a bool[][] that tells you if two vertices have an edge between them

#

I tend to do adjacency lists. They're particularly good for sparse graphs

#

if each galaxy only connects to a few other galaxies, then it's very efficiecnt to have each galaxy store its neighbors

fast glade
#

Im creating a mobile shooter and on my right stick i want to rotate and shoot. Everything works so far, but when i shoot, i have to tap the button. How can i repeat my code as long as im holding the button down? Im triggering the Input Action with the Unity "On-Screen Button" script

wintry quarry
#

the input system is for handling input not driving game logic.

winter cedar
#

!code

eternal falconBOT
fast glade
winter cedar
#

So when i try to load up my project it just gives me a this error that i cant fix here's the part of the code to it

            else if (surface.IsPartOfPrefab())
            {
                var prefabStage = PrefabStageUtility.GetPrefabStage(surface.gameObject);
#if UNITY_2020_1_OR_NEWER
                var assetPath = prefabStage.assetPath;
#else
                var assetPath = prefabStage.prefabAssetPath;
#endif
                if (!string.IsNullOrEmpty(assetPath))
                {
                    var prefabDirectoryName = Path.GetDirectoryName(assetPath);
                    if (!string.IsNullOrEmpty(prefabDirectoryName))
                        targetPath = prefabDirectoryName;
                }
            }
languid spire
winter cedar
#

unity.ai.navigation@1.1.5\Editor\NavMeshAssetManager.cs(47,30): error CS1061: 'NavMeshSurface' does not contain a definition for 'IsPartOfPrefab' and no accessible extension method 'IsPartOfPrefab' accepting a first argument of type 'NavMeshSurface' could be found (are you missing a using directive or an assembly reference?)
there

languid spire
slender nymph
winter cedar
slender nymph
# winter cedar i didnt

right but you're posting the code here and asking for help with it as if you intend to attempt to fix it yourself. follow the steps i just gave you to fix it

languid spire