#💻┃code-beginner

1 messages · Page 654 of 1

waxen adder
#

In one of your older images, I noticed it was off

dry cloak
#

ahah

#

now its working

waxen adder
#

Alright, now we can see the raycast

#

Back to the original problem xd

dry cloak
#

okay, so i think the raycast is spawning under the ground'

#

when sliding

waxen adder
#

Oh yeah, it's getting offset pretty hard there

dry cloak
#

also another couple problems i have once were done with this

waxen adder
#

How about when just standing?

dry cloak
waxen adder
#

Yeah that looks good

dry cloak
#

i might have found a solution

#

so my playerobj is where the camera is tied too

#

for height things

#

and its also what the raycast is tied too

#

so if i raise it up, is should in also rais where the raycast spawn

#

wait not the player obj

waxen adder
#

While that would work for now, I don't think that would solve the problem forever

worthy tundra
#

how do i toggle specific layers from the camera from a script?

i have special effects that are under specific layers (fx a on layer 1, fx b on layer 2 etc)

i want a script that can toggle these effects on and off, how do i do that?

waxen adder
#

Something's coming to mind. Click the object when standing and when sliding

#

Show images for both

dry cloak
#

kk

waxen adder
#

Yeah, so you see right there? The transform position is at the bottom of the standing guy, and, well in nowhere land when sliding

dry cloak
#

yeah

waxen adder
#

I think there's a button you can click to change that, i forget what

dry cloak
#

the raycast should be spawning from the same spot no matter what right?

waxen adder
#

Ah ok, so look to the far left from where you clicked gizmos, across the screen basically

#

You'll see something saying "pivot"

#

Click it, and switch to center

dry cloak
#

done

#

now what

#

that moved the raycast up by like 4 centimeeters

waxen adder
#

Take a look at the gizmos and stuff again

#

Oh wait for real?

dry cloak
#

yeah

waxen adder
#

Show images?

dry cloak
waxen adder
#

You switched it to center right?

dry cloak
#

center

#

acutlly the ray doesnt move

#

the arrow that moves it does

waxen adder
#

Can I see your character hierarchy?

dry cloak
waxen adder
#

Show me the inspector side of "Player"

dry cloak
waxen adder
#

Show me the inspector side of "PlayerObj"

dry cloak
waxen adder
#

Hm ok, let's clean this up a bit

#

First things first, make sure the scene is saved

#

In case you want to try something else later

dry cloak
#

saved

#

i cant really get rid of any of the childs, as they are used in the Camera holder and player cam scripts

#

it avoids prolbems when the camera is directly attached to the player itself

waxen adder
#

Keep in mind that you may run into some errors and stuff as we do this depending on how you got your scripts set up. Ignore for now, until we get done

#

On Player, remove the capsule mesh filter and rigidbody

#

Reset its transform > right click transform > reset

dry cloak
#

done

waxen adder
#

Ok now for PlayerObj

#

Let's reset it's transform, and then set y to 1

dry cloak
#

doone

waxen adder
#

Any errors as of right now?

dry cloak
#

no

waxen adder
#

Ok, take a look at the raycasts and stuff again

#

I think it should be better now

dry cloak
#

ran it got an error

#

MissingComponentException: There is no 'Rigidbody' attached to the "Player" game object, but a script is trying to access it.

waxen adder
#

Ah right

#

Add a rigidbody component to PlayerObj

#

Now I gotta think

dry cloak
#

raycasts are still doing the same thing

#

sort of

waxen adder
#

Just to make sure this lands right, make rb public

dry cloak
#

can you wait like 45 min?

#

i need to go take care of somthing

#

i can @ you when back if your fine with that

waxen adder
#

Sure, just ping me when back yeah

#

I might not be able to respond right away tho

worthy tundra
waxen adder
#

^ That I sadly don't know how to do, but I hope someone manages to help you!

worthy tundra
rocky canyon
#

allz ud need to do is change the Culling layers right?

worthy tundra
worthy tundra
rocky canyon
#

and just change out the entire mask w/ those layermasks

worthy tundra
rocky canyon
#

ya, then u'd want to do the bitshifting stuff

#

im just telling u how I would handle it

#

im bad at that othe stuff.. sooo u'd need someone else to chime in

worthy tundra
rocky canyon
worthy tundra
#

i dont trust ai

rocky canyon
#

its Google's Overview.. it just uses all the sources from the search query..

#

here

worthy tundra
rocky canyon
#

the sources came from UnityDiscussions

#

ya, i dont trust AI either.. (coding with it).. but for search engine queries.. its literally using the results it finds and just giving u overview

#

anyway.. best of luck with the bitshifting 🍀

worthy tundra
#

thanks

rocky canyon
echo cradle
#

i'm going for pixel perfect movement but the players box collider keeps passing though walls only going up. I'm using rule tiles, should I just trash this project and start something new?

wintry quarry
#

try setting Rigidbody velocity

#

also make sure your colliders and Rigidbodies are configured properly

echo cradle
#

i'm going for pixel perfect movement but the players box collider keeps passing though walls only going up.

wintry quarry
#

(not kinematic, not triggers)

echo cradle
#

are uyopui just NOT allowed to use colliders if you want a pixel game?

wintry quarry
#

Who said that?

echo cradle
#

you?

#

jsut now?

wintry quarry
#

When did I say that?

#

I never said that

#

reread what I wrote

echo cradle
#

your code is moving objects in ways that don't respect collisions
try setting Rigidbody velocity

#

i am trying for pixel perfect movement

wintry quarry
#

nothing there says you can't use colliders

echo cradle
#

so why. isn't. it.working jsut one way?

wintry quarry
#

Because you are moving your objects in ways that bypass collisions

#

like I said

#
            _boxCol.transform.position = Vector3.MoveTowards(_boxCol.transform.position, targetPos, _speed * Time.deltaTime);
#

You are directly moving the Transform

#

you can't do that

#

if you want collisions

#

MovePosition also doesn't respect collisions:

_rigidbody.MovePosition(_boxCol.transform.position);```
echo cradle
#

ok. HOW do i wnat collsiions in a pixle art game wher i want pixle perfectt collsions

wintry quarry
#

Well it really depends how the game works

#

is it like Pokemon where you can only move on a grid?

echo cradle
#

yes

wintry quarry
#

then there's no need for colliders at all

#

You just need to keep track of which grid positions are walkable and which aren't walkable

#

and don't allow the player to walk to any non-walkable coordinates

echo cradle
#

ok, is there any resources for adding that to rule tiles?

wintry quarry
#

no physics components at all

#

rule tiles are for graphics

#

tilemaps are for graphics

echo cradle
#

you got a youtuber that does this?

wintry quarry
#

no

twin pivot
#

My best solution is having an if statement for the x value and nest another one for the y value

echo cradle
#

so what do i do? trash this whole project and find SOMEONE that can code this basci fuckign game correctly?

twin pivot
#

!learn how to code

eternal falconBOT
#

:teacher: Unity Learn ↗

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

echo cradle
#

ya no one in this discord CAN apparently

twin pivot
#

People here help others for free

#

Why are you expecting more

rich adder
dry cloak
#

@waxen adder

tall delta
#

plenty

dry cloak
#

back

lethal meadow
#

if people are trying to help and you're the problem dont be rude lmao

dry cloak
#

oop

#

nvm

worthy tundra
dry cloak
#

just noticed

twin pivot
#

This may be a bit stupid but couldnt you also just disable and enable its parent?

dry cloak
#

@waxen adder what if i just cast a seprate raycast when sliding?

echo cradle
echo cradle
lethal meadow
#

youve been given help

#

offered alternatives

dry cloak
#

of course right?

frigid sequoia
#

Can I search for script references on the editor?

#

Like "is there any object currently using this script?"

teal viper
frigid sequoia
#

Oh, right, it does. Does that effect prefabs or only in scene?

teal viper
#

I'm not sure. I'd assume it would list both prefabs and scenes.

#

There might be an option in the editor itself too, though I don't remember for sure.

high summit
#

So i'm new and working on my first game, Having an issue with raycasting, I followed a tutorial from someone online (Probably not the best idea) but that's how we learn right?

https://streamable.com/0g1buc

I'm having this very specific issue with it, As you can see it works flawless, Unless. I look at the object, and slowly back up without moving off the object lol. Super weird.
(can share code if needed)

Watch "raycast" on Streamable.

▶ Play video
high summit
#

Whats the best way to share code here?

#

I know people prefer specific pastebins etc

teal viper
#

!code

eternal falconBOT
high summit
#

Thanks! hopefully that worked

#

That's the Interactor script

#

Then each object that i want interactable just has a

public void Interact()
#

And


public class clipboardinteract : MonoBehaviour, IInteractable
#

(The interactor script lives on the main camera) from the unity assets first person controller)

teal viper
high summit
#

nothing shows to console as far as i'm aware

#

let me quickly check

#

nope console is clean

teal viper
#

Aah, actually nvm. The issue is that you only disable the text when there is a hit

#

You need to handle a case where the raycast does not hit anything at all

high summit
#

I dont fully understand c# yet obviously but

#

isnt that whats happening here? with the else

#

in the vid you can see, if i move to the left or right of the object, the text vanishes fine as it should

#

It's only when I keep it in my direct line of sight, Back up SLOWLY, get behind the range of 3 while still looking at it, it doesnt remove itself

polar acorn
wintry quarry
# high summit

You're only handling the case when you hit something that doesn't have the interactable component on it

You're not handling the case where you didn't hit anything at all

high summit
#

Ohhh

high summit
#

Like when i'm backing up i'm hitting nothing

#

I'm tryna think of the logic of how this would work then

#

Not sure if it would be something like 'null or 'void'

#

Like what is 'nothing' in this instance?

polar acorn
#

You appear to be changing the name you're assiging a variable to

#

which can be literally anything you want

high summit
#

Oh wait

teal viper
#

Honestly, if you're following a tutorial, they should have it covered. Unless it's a very bad tutorial

high summit
#

Yeah it didnt cover it and I forgot which one it was now I kinda shot myself in the foot

#
#

Found it

teal viper
#

Ok, look at the raycast documentation and investigate what happens if it doesn't hit anything.

teal viper
high summit
#

I'm sure this is whats is happening in my code

#

I'll check the docs though

teal viper
#

Why are you looking at the forums. Why are you not looking at the documentation as I suggested?

high summit
#

had a look through and seemed to have fixed it with this

#

It's weird because I assumed the 'else' would do exactly what the if line below it does

#

because it's the else from the original if

sour fulcrum
#

the undefined state is here

#

you have an else if you hit something and it wasn't an interactable

#

but not an else if you didn't hit something

high summit
#

Ohhhh

high summit
sour fulcrum
#

no worries

#

not ideal in all cases but a suggestion here to get you thinking is if this is in update or something you can simplify the logic by just disabling it first unconditionally

#

eg.

MyInteractFunction()

interactText.setactive(false)

if (various stuff)
interactText.SetActive(true)

high summit
#

Yeah, It's funny because, I have worked with python and java and I'm not sure why I didnt see that

#

Must be brain tired

sour fulcrum
#

sometimes it just be like that

crisp vortex
#

yo is copy and pasting a movement script a bad thing as a beginner?

teal viper
high summit
#

Howdy anybody know what a 'script' is in this instance?

#

It's hard to explain one moment

wintry quarry
#

You are supposed to write the actual type you are trying to reference

#

the class name for example

#

not "Script"

high summit
#

I mean what is a script though

#

a gameobject maskes sense

#

so does audio source

wintry quarry
#

Every time you write a MonoBehaviour class you are defining a type of component that can go on a GameObject

high summit
#

I need to drag that playerinput into the 'script' option

wintry quarry
#

That screenshot is showing two components

#

a PlayerInput and a pausescript

wintry quarry
high summit
#

Thanks again

#

Slight issue with cursor when pausing

#

I have a script when my game starts that disabled the cursor (which works great)

#

however when I pause I need to show the cursor

#

and then hide it when unpause

#

What happens is when I press escape to pause (in game view) this pulls me out of focus of the game, So i cant tell if the cursor actually appears. and then when I click back in, I dont have a cursor, but void Pause has 100% been ran

wintry quarry
#

For testing in the editor usually you want to bind things to a different key other than escape, since the Unity Editor uses that key for taking focus out of the game window

high summit
#

Good idea i'll try that real quick 😄

wintry quarry
high summit
#

Doesnt that just freeze it in place?

#

Oh nvm

#

i cant read

#

hmm thats interesting

#

on start i set

#
 Cursor.lockState = CursorLockMode.Confined;
#

but i still have a moveable cursor in game

wintry quarry
#

confined means you have a moveable cursor, it just can't leave the game window

#

you want Locked generally for a first person game

high summit
#

This is so perfect. Yeah with the way I was going to do it, it would have been like tabbing out of the game with the mouse moving out the window

#

but now it's confined on pause

#

Thanks sm

frigid sequoia
#

Is there really no better way of doing this when calling a method from a button?

wintry quarry
#

but if you want to do it in the inspector you either have different functions or you pass the int parameter in in the inspector

rich adder
#
[SerializeField] private int commandId
public void CallCommand()
{
  commands[commandId];
}```
wintry quarry
#

that works too - the buttons would subscribe the onClick to that function onthemselves^

frigid sequoia
frigid sequoia
rich adder
wintry quarry
frigid sequoia
#

Mmm, my grasp on eventListeners is like null, aren't button on themselves eventListeners already?

wintry quarry
#

I'm not sure what you mean by that

#

We're talking about listeners for when the button is clicked.

#

Isn't that what you're interested in?

rich adder
#

it links a method to the event "OnClick"

frigid sequoia
#

Yes, but I didn't even knew you could pass parameters with eventListeners if you set them through code instead of setting them on the editor with the OnClick event

rich adder
#

its just a UnityEvent , in the inspector is the same you can pass or link dynamic values

frigid sequoia
#

So I were to run that on editor, would that show in the methods called by the Onclick?

rich adder
#

not sure what you mean

frigid sequoia
#

If I do AddListener on code and run that on editor to add a listener to a particular button and pass it a parameter would it show here?

rich adder
hazy cliff
#

what causes a sound to not work?

#

through code

frigid sequoia
hazy cliff
wintry quarry
# hazy cliff

Do you have an audio listener in the scene?
Is it anywhere near the audio source?
Do you have sound enabled in your game view?

#

Oh also when and where in your code are you calling Play?
Are you doing it in Update?

frigid sequoia
#

I venture to say you are destroying the "gem" on pickup, thus destroying the audio source and stopping it inmediatly

wintry quarry
#

oh that too^^

frigid sequoia
#

Create an emtpy prefab holding the sound and destroy it after a few seconds

#

Not the most optimal, but the simplest

wintry quarry
#

Or use AudioSource.PlayClipAtPoint

frigid sequoia
wintry quarry
#

yes, to avoid lambda variable capture

#

which would make this not work properly

#

without that, all of the buttons would use the highest number in the array when you clicked them

#

because that's the final value the i variable has.

frigid sequoia
#

Mmmm, pretty sure I have it used it wrong some times before then

#

I use the i a bunch of times for final values on these

wintry quarry
#

it depends what you're doing. This is a very specific case involving creating a lambda in the loop that makes it necessary

frigid sequoia
#

Now that I thinking about it, for how it's setup now, those buttons can be destroyed and created a bunch of times, would I have to remove the previous listeners or it's fine?

wintry quarry
#

you wouldn't have to remove the listeners

twin sierra
#

does anyone know why does it define infinity? i just put an "Random.Range(-15f, 15f)" as for the Y axis

#

code in question:

wintry quarry
#

The error tells you where to look - Move_Pipes.cs, line 20

#

Also !code

eternal falconBOT
twin sierra
#

oh thx

#
public class Move_Pipes : MonoBehaviour
{
    public float MoveSpeed = 5f;
    public float Dead_Zone = -45f;

    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < Dead_Zone)
        {
            Destroy(gameObject);
        }
        transform.position = transform.position + new Vector3(-1 * MoveSpeed * Time.deltaTime, transform.position.y, 0);
    }
}```
#

here is the right script:

wintry quarry
#

it's going to get very large, very fast

#

hence the infinity

#

if you don't want to change the y position, you would add 0 to the y

#

like you are doing with z

twin sierra
wintry quarry
#

those are the same thing

#

not changing

#

use 0 there, not transform.position.y

twin sierra
#

so if i set 0 it wont change?

wintry quarry
#

anything + 0 is the thing you started with

#

notice this is a vector you are ADDING to the position

#

you are not SETTING the position to this vector

#

pay careful attention to the code.

acoustic belfry
#

inside a prefab i can reference each object?
i mean, i know you can't reference a prefab as different objects/prefabs, but one children of a prefab can reference it sibling?

i mean cuz i want to make an Enemy that throws projectiles at you, and if one touches you it TPs to you (like an Ender Perl, huh). So my plan was just referencing to the Enemy and changing it Transform.Position to the Player's Transform.Position and thats it, and it would be A LOT easier if it were done using referencing, u know the
[Serialized] Privated Gameobject Enemyname;
thing

wintry quarry
acoustic belfry
#

nice, thanks :3

wintry quarry
twin sierra
acoustic belfry
twin sierra
#

how can i fix this? it says it's inaccessible because of "protection level"

public Ui_Manager manager;
void Start()
{
    manager = GameObject.FindGameObjectWithTag("Logic").GetComponent<Ui_Manager>();
}

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

void OnTriggerEnter2D(Collider2D collision)
{
    manager.AddScore();
}
wintry quarry
twin sierra
wintry quarry
#

because with the code as you shared it, you wouldn't get that error

twin sierra
wintry quarry
frigid sequoia
#

Should I worry much about doing this instead of adding a simple int counter on something that happens relatively frequently or it's fine?

#

The components get added from outside, but I am trying to not add variables that are redundant cause I am getting confused enough already lol

teal viper
frigid sequoia
#

A counter that basically goes ++ when adding component from outside and -- when removing it

teal viper
#

What's the purpose of it? I don't see how it's related to the shared code

frigid sequoia
#

I am getting the amount of components of the type command on an object, since they are meant to be capped, so whenver I add one I check how many it has already

wintry quarry
teal viper
frigid sequoia
wintry quarry
#

if you're doing this often, it can be very bad

#

GetComponents<> returns a freshly allocated array

teal viper
wintry quarry
#

so that could be a ton of garbage collection

frigid sequoia
teal viper
frigid sequoia
wintry quarry
#

once every 2 seconds is not bad

#

once every frame is bad

frigid sequoia
#

Kk, should be okeish then

frigid sequoia
#

Mmmm.... What am I messing up here? I never got these before

keen cargo
#

Seems like an unity editor bug, try restarting

frigid sequoia
#

Okay, so the error was that I am trying to add items from the top list to the bottom one 1 by 1 without ever removing the top one since, it's a reference. And it does so, but... beggining from the second item, they get.... removed from the original list? How can I even be doing that? It's trying to fins stuff that does no longer exists, that was the error

unique slate
#

Im kinda struggling with buffs and combo triggers.
Lets say i have 4 heroes. Hero 1 has a passive skill that says he gets healed by 5 if another hero deals a critical strike.
How would i implement this? Is there a way to make that skill listen for crits?

unique slate
#

Will look into it, thanks!

thick spoke
#

yall, when i bake in navmesh surface, it doesnt show me what i baked, usually there is a blue highlighted area what i baked, but i cant see it rn, any ideas?

#

i just had gizmos off...

twin pivot
#

Will remember that for my own navmesh

chrome apex
#

How do I rotate something over time in eulers? I just can't do it

#

I tried 500 different methods and none of them work

grand snow
#

its quite easy so no idea what you were doing

chrome apex
#

I want to rotate something by X degrees on just one of the axes

#

that's al

#

I can't do it

grand snow
#

you need something like a coroutine to animate it from some rotation to another

#

or you use an animation

chrome apex
#

yes I have that

#

a coroutine

#

The newest method rotates me by 180 degrees which is an incorrect value

#

tried other methods, they either gave me no rotation or random rotations

grand snow
chrome apex
#

!code

eternal falconBOT
chrome apex
#
 randomTilt = Random.Range(40f, 65f);
        Vector3 targetPosition = new Vector3(Camera.transform.localPosition.x, 0.59f, Camera.transform.localPosition.z);
        
        float deltaZ = Mathf.DeltaAngle(Camera.transform.localEulerAngles.z, randomTilt);
        Vector3 targetRotation = new Vector3(Camera.transform.localEulerAngles.x, Camera.transform.localEulerAngles.x, deltaZ);

        while ((Camera.transform.localPosition.y - 0.59f) > 0.002f && (Camera.transform.localEulerAngles.z - deltaZ) > 0.2f)
        {
            Camera.transform.localPosition = Vector3.MoveTowards(Camera.transform.localPosition, targetPosition, 0.1f * Time.deltaTime);
            //Camera.transform.Rotate(Vector3.forward * (10f * Time.deltaTime), Space.Self);
            Camera.transform.localRotation = Quaternion.Euler(Vector3.Lerp(Camera.transform.localEulerAngles, targetRotation, 1f * Time.deltaTime));
            yield return null;
        }

That's the relevant part

grand snow
#

An example of linearly going from 1 rotation to another correctly

private IEnumerator Rotate(Vector3 from, Vector3 to)
{
    Quaternion fromQuat = Quaternion.Euler(from);
    Quaternion toQuat = Quaternion.Euler(to);

    float t = 0f;
    while (t < 1f)
    {
        t += Time.deltaTime;
        transform.rotation = Quaternion.Lerp(fromQuat, toQuat, t);
        yield return null;
    }
}
#

Your rotation lerp is doing 1 * delta (for some reason) so its going to only slowly move to your target rotation and never reach it

chrome apex
#

well it doesn't do that

#

it just turns me pretty fast and reaches 179 for some reason

#

without delta angel, it worked but from the wrong side

#

oh and it sometimes rotates the wrong axis from reason

grand snow
#

Camera.transform.localRotation = Quaternion.Euler(Vector3.Lerp(Camera.transform.localEulerAngles, targetRotation, 1f * Time.deltaTime));
This is bad because your from rotation is the current rotation, not the original start when the anim began. And your lerp factor is delta time.
In my example, we keep the start rotation and end rotation constant and we lerp to the goal over 1 second.

chrome apex
#

ahhhh you're right

#

I need start rotation

grand snow
#

your lerp factor is still wrong though, it needs to go from 0 to 1 over the time frame you desire

#

doing Lerp(5, 10, Time.deltaTime) for example each frame will just give the same ish result cus delta time is gonna be like 0.016

chrome apex
naive pawn
#

yes

queen adder
#

one question is making a lot of function for like the most things like Movement() and CheckForGround() exc

#

good or bad?

naive pawn
#

neither

#

functions are generally for 2 things, reducing repeated code, and separating out independant subsections of complex code

#

(aside from providing functions for other classes or actions)

#

so if your function doesn't fall into those categories, it may be unnecessary; but that doesn't make it automatically bad

grand snow
chrome apex
#
Quaternion targetRotation = Quaternion.Euler(0, 0, randomTilt);

        while ((Camera.transform.localPosition.y - 0.59f) > 0.002f && (Quaternion.Angle(Camera.transform.localRotation , targetRotation) > 0.1f));
        {
            Camera.transform.localPosition = Vector3.MoveTowards(Camera.transform.localPosition, targetPosition, 0.1f * Time.deltaTime);
            //Camera.transform.Rotate(Vector3.forward * (10f * Time.deltaTime), Space.Self);
            //Camera.transform.localRotation = Quaternion.Euler(Vector3.Lerp(Camera.transform.localEulerAngles, targetRotation, 1f * Time.deltaTime));*/
            Camera.transform.localRotation = Quaternion.RotateTowards(Camera.transform.localRotation, targetRotation, 1f * Time.deltaTime);
            yield return null;

grand snow
#

Infinite loop is a likely cause.
In my example I forgot to put the yield in btw

chrome apex
#

well I used yield

#

I didn't copy it

#

but there's a curly brace after null

#

OK I'm stupid

#

I put a semicolon after while

#

intellisense didn't even care about that one, the weirdo

#

ok fixed but it doesn't rotate

#

man I hate rotation

#

so unintuitive

naive pawn
chrome apex
#

but I'm back to not rotating now

naive pawn
chrome apex
#

yes

naive pawn
#

weird

chrome apex
#

it gave me a green squiggly underline

#

like it's not an error but incomplete

#

misunderstood the context or somethign

#

anyway, now fixed for good, my speed was far too low

#

but I still hate rotation

spice elk
#

Hallo, I want to trigger an event when a specific message was send in my youtube livestream chat. Does anyone know how to use the Youtube Api and search for a specific word in a comment in Unity?

sour fulcrum
golden stump
#

Hello I'm creating an RPG and I want to create a transition between my overworld and the battle scene. When the battle scene loads however I am unable to interact with buttons to perform commands. The battle starts when the player makes contact with the enemy. Can anyone help I'm really stuck

sour fulcrum
#

im not sure what that file is meant to be but thats useless to anyone

#

you need to post code

#

and the error

keen cargo
#

i think its the literal scene file bigsob

#

but yes post !code and maybe some more details of what the scene looks like in your editor

eternal falconBOT
golden stump
#

oh sorry Im an extreme novice. this is what my battle scene looks like

grand snow
golden stump
#

I have an event system for both my overworld and battle scene but not really sure what to do

#

can i post videos here

grand snow
#

Yes

golden stump
#

Heres the video. As you can see, when I try to interact with the buttons the mouse just dissapears.

#

I created a transition script but I don't know what else I can do.

#

Thanks for the help in advance. This is really draining me

#

The battle scene works perfectly when I play it from it's scene. It's just when it transitions

keen dew
golden stump
#

Alright How would I change it?

keen dew
#

Well how do you hide it?

golden stump
#

Nevermind I got it to work. Thank you so much

#

Though is there any reason as to why the screen goes darker when it transitions?

analog pivot
#

ugh why is code so... hard im not feeling my exp bar irl with it going up

rare basin
#

xd

grand snow
frigid sequoia
grand snow
#

You can use Remove() to remove the first matching element in a list OR RemoveAt() to remove the specific index.
The list elements AFTER the element removed get moved up to fill the empty space.

frigid sequoia
#

Yeah, it's checking the command list to get the lowest id value on those, then looking for that value to get what command should be next to move into the active commands list, then it adds it to the active commands, but I am somehow removing item from the command list when it shouldn't be the case, that list should never be modified

grand snow
#

Is this in play mode or edit mode?

frigid sequoia
#

I was actually trying to make the command list readonly but I am too dumb to get the right declaration for that I guess lol

grand snow
grand snow
frigid sequoia
#

Yeah, I have gone throught where the code os going a bunch of times and added logs, but... I don't see anything that could remove items from the list with the methods I am calling

grand snow
#

You will put a break point where this process begins and step though and check what is actually happening

#

instead of shit logs and guessing afterwards wtf is wrong 🙃

frigid sequoia
#

Mmmm... I guess I would place a breakpoint on each execution, but... I don't think I'll be able to catch anything with that either

#

I think I am calling something else, but not sure how, or what

grand snow
#

a breakpoint when hit will pause execution and from there you can step forward a line manually and inspect stuff. You can then "Continue" to unpause execution and go back to normal

#

You should share your current code if you still need help with it

surreal sundial
#

is this a good idea for multiple objects

#

sometimes objects with the script attached don't work

teal viper
surreal sundial
#

i think it has to do with the collider

teal viper
surreal sundial
#

yeah it was a collider i forgot to remove, i'm already using raycast for a few different things so i'm gonna avoid it

near thicket
#

I don't have any compiler errors

ripe shard
high summit
#

Made a button on a pause menu to go back to the menu

    public void OnStart()
    {

        SceneManager.LoadScene("menu");
    }

It works, Switches to menu, But when I then go back to the game (aka start the main game scene again) my character controller cannot move? I can look around with the mouse, but not move around with WASD, any ideas?

#

To start the game in the main menu I have

    public void OnStart()
    {

        SceneManager.LoadScene("main");
    }
ripe shard
rose burrow
#

error CS1061: 'PlayerInput.OnFootActions' does not contain a definition for 'Look' and no accessible extension method 'Look' accepting a first argument of type 'PlayerInput.OnFootActions' could be found (are you missing a using directive or an assembly reference?)

I followed this youtube tutorial https://www.youtube.com/watch?v=rJqP5EesxLk&list=PLGUw8UNswJEOv8c5ZcoHarbON6mIEUFBC and I cant seem to find out whats wrong with my code

The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.

I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!

Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...

▶ Play video
eternal falconBOT
high summit
#

here we go

#

At the end i cannot move at all just with the mouse

rose burrow
#

I need help fixing this compiler error

high summit
#

I'm an idiot.. my pause menu sets time to 0.. but then if you click return to menu it leaves the time at 0 lol

#

Thats why i cant move

#

(fixed)

twin sierra
#

hi! i needed an quick help, i wanted an object to rotate around an empty object i made, and for it i used the "transform.rotateAround" function, i put the transform position of the other object in the 1'st paremeter and in the second i up "Vector3.up" and the third as "20 * Time.deltaTime", i started the game and the object suposed to rotate around the middle one disapiers.

Script:

public GameObject Middle;
// Start being used as test
void Start()
{
    transform.RotateAround(Middle.transform.position, Vector3.up, 20 * Time.deltaTime);
}

Screenshots:

night mural
twin sierra
#

i used the code the docs put

night mural
#

yours isn't in update though

#

they're also rotating around the 3d world's Y axis

#

does that make sense for your game?

twin sierra
#

oh

twin sierra
#

im trying to build an copy of the tap game

#

it rotates and you have to tap on an ball that apears randomly

#

but even when the game is not running the sprite dosent show up

#

the red one

#

maybe an render issue?

#

fixed it

#

camera Z axis was 0

#

put it on -10 and it got back to normal

high summit
#

Urgh goofed up my project

#

Ignore that wrong channel

#

Is there a channel for

#

'fixing unity things'

#

Not code but like... to do with URP etc

slender nymph
#

also finish a thought before sending a message, no need to spread a single thought across 3 messages

tender gazelle
#

Does Anybody maybe know how to fix my enemy, so that he patrols a area and doesn't just walk in one direction all the time?

slender nymph
#

!code

eternal falconBOT
slender nymph
#

also get your !IDE configured 👇

eternal falconBOT
harsh haven
#

Ok so

#

Im just trying to make a scoring system for when a wave a blocks gets past the player, count up by 1

#

i clone a whole bunch of block projectiles, so i would need a reference to those blocks to get their transform so i can see if they have gone low enough to count as a passed wave

#

the block is a prefab

halcyon linden
#

can someone help me out with a vr horror game?

harsh haven
#

And i assume things aren't working because im using clones

#

or something

naive pawn
harsh haven
#

Heres the score code

naive pawn
eternal falconBOT
naive pawn
#

configure your ide

#

anyways you should probably decentralize it a bit; step away from the code and think about design

harsh haven
#

im aware theres more ways to deal with this issue but i kind of want to know what the issue with my current approach is

#

Heres the block code

naive pawn
#

please share your !code properly

eternal falconBOT
harsh haven
#

I used Debug.Log and waveNum does increase as the waves fall

#
using UnityEngine;

public class Block : MonoBehaviour
{

    public int waveNum;
    void Start()
    {
        
        GetComponent<Rigidbody2D>().gravityScale += Time.timeSinceLevelLoad / 15f;
    }

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

        if (transform.position.y < -2)
        {
            waveNum++;
            Destroy(gameObject);

        }
    }
}
#

Heres the Block code

naive pawn
# naive pawn anyways you should probably decentralize it a bit; step away from the code and t...

there should be a single "score" counter, that's correct as is - score should be centralized, there should only be 1 central score

but since there are multiple blocks that are created dynamically, that shouldn't be centralized; each block should be able to know when it's passed the threshold (perhaps passing that into a script on the prefab) and then just inform the centralized score that something should change

harsh haven
naive pawn
harsh haven
#

I did this at first, i agree its the better approach and had another issue

#

Let me send that too

harsh haven
#

and dragging into the scene wouldn't do anything cause im still cloning it

#

Give me 1 minute to get my other approach

#

Ok so i tried referening the score TextMesh from the BlockSpawner

halcyon linden
#

im using an old version of gtag as a base, trying to make an entity that goes toward the player, no anims, just flying, and will do a jumpscare and close the game after. its gonna be a rare 1/100 every hour chance

harsh haven
#

the blockspawner would increase the waveNum variable, and the Textmseh would get that variable

#

however in the unity inspector, everytime I dragged in my Score textmesh on the canvas

#

it did not recognize it and said type mismatch

#

which confused me cause in blockspawner i have public Score waveNum

naive pawn
harsh haven
#

so dragging in the score textmesh should be the same type??

naive pawn
#

im confused

harsh haven
#

I was too thats why i did other crappy method

naive pawn
#

"the score textmesh" as in, the object that has.. just the textmesh?

harsh haven
#

yea just this score

naive pawn
#

and does that gameobject have the Score script..?

harsh haven
#

yes

#

sometimes i would delete on the blockspanwer inspector, and i was able to drag the score script successfully

#

but i would run and it would change to the type mismatch

naive pawn
#

are you currently back to that version of code

#

(btw, why are you adding to the gravity scale like that? you're adding snap, the 4th derivative of time)

harsh haven
#

Idk lol im new

harsh haven
#

cause i still want to know why that wasn't working

#

Ah

#

this 3rd approach is having the exact same issue

#

so this works for demonstration too

naive pawn
#

make sure you've saved and recompiled all scripts

harsh haven
#

Yep i have

#

alright sending a few things rn

#
using UnityEngine;

public class Block : MonoBehaviour
{

    public Score scoring;
    void Start()
    {
        
        GetComponent<Rigidbody2D>().gravityScale += Time.timeSinceLevelLoad / 15f;
    }

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

        if (transform.position.y < -2)
        {
            scoring.IncreaseScore();
            Destroy(gameObject);

        }
    }
}
#
using TMPro;
using UnityEngine;

public class Score : MonoBehaviour
{
    public TextMeshProUGUI score;
    public int currentScore;
    //public BlockSpawner currentSpawner;

    // Update is called once per frame
    void Update()
    {
        score.text = currentScore.ToString();
        if (currentScore < 0)
        {
            score.text = "0";
        }
    }
    
    public void IncreaseScore()
    {
        currentScore++;
    }
}
#

BlockSpawner script no longer relevant

#

This is where you can see the block prefab with its script in the inspector

#

I drag in my score Text mesh

naive pawn
#

oh, you're trying to reference something in the scene through a prefab

#

yeah one sec

harsh haven
#

Ah

naive pawn
harsh haven
#

thank you!

naive pawn
#

assign the Score in the BlockSpawner instead, and then assign that to the Blocks when you instantiate them

harsh haven
#

so prefabs can never reference something in the scene?

naive pawn
#

yeah, since prefabs exist outside scenes

harsh haven
#

makes sense

naive pawn
#

sorry that took so long, this isn't a super rare issue, i just haven't had to help anyone with this issue yet lol

harsh haven
#

nah i really really appreciate it and i wanted to get all my approaches out there too

#

so i could like fully understand this stuff

frigid sequoia
#

How is this failing just sometimes? I don't get it

#

The command that I am telling it remove is on the list 100%

#

It even happens if I use Clear() instead, how?

naive pawn
frigid sequoia
#

Yeah, but the error happens, precisely when it is NOT

naive pawn
#

try adding a print after the Remove call?

frigid sequoia
#

Like it removes it properly when it works, but not when failing

naive pawn
#

see if that's logged when the error happens

#

thonk you sure this is a beginner issue lol

frigid sequoia
frigid sequoia
#

Pretty sure it's me using a loop wrong somewhere, but I am unable to find it

grand snow
# frigid sequoia ????? How?

Ive never seen these serialization errors, perhaps you need to reset the component and re assign stuff and see if it helps
something is messed up, runtime changes should be just fine

#

Or... just stop having the active list serialized

frigid sequoia
#

Why would it showing in the inspector cause issues?

#

Isn't that what serialized is for?

grand snow
#

I presume the issue is you remove an element but the inspector still shows it. The error logged also mentions this list and element 0 so its surely related.

#

So a potential solution is to use [NonSerialized] so its not fucked with

naive pawn
frigid sequoia
#

I don't think the editor should be trying to do anything, no

naive pawn
#

me neither, i agree it's weird

grand snow
#

thats why i think the component needs a reset (via ... menu) or remove and re add it

frigid sequoia
#

Could it be that I am destroying the object before removing it from the list sometimes somehow?

#

Cause shouldn't be the case

#

Removed the component, added it back in, didn't seem to work, I just edited a freaking log string after that and now it doesn't show..... Aaaah, why??? I am so confused!!

naive pawn
#

editor issues be like

earnest wind
#

uhm this is pretty weird

public void Test()
    {
        Testing = !Testing;
        Debug.Log($"Testing is {Testing}");
        if(!Testing)
        {
            StopTest();
        }
        else 
        {
            StartCoroutine(StartTest());
        }
    }
private void StopTest()
    {
        Debug.Log("Ended Testing");
    }

And the result of debug.log is!! HUH?

slender nymph
#

consider printing the value of Testing in your StopTest method. also check the stack trace

earnest wind
#

got me scared lol

frigid sequoia
#

Could this be removing from the commands list on way a that I do not understand?

#

Cause the idea was to create a copy of it to get which ones are on the commands list but not on the inactive commands list

polar loom
#

just started scripting today, would this work?

frigid sequoia
polar loom
#

i mean the header

frigid sequoia
#

Not as a comment and not with nothing below it

polar loom
#

yeah i just wanted to see if it would show in unity

polar loom
frigid sequoia
#

Pretty much anything you find on your first google search would work

polar loom
#

cause a lot of the tuts i find just teach you to copy what they put and not actually learn

frigid sequoia
#

Go to Unity Learn, it's pretty decent to learn the basics

#

But, again, any youtube vid would do the trick

polar loom
#

thanks

#

watching a tut now

polar loom
#

so when i boot my game up it will display hello in the console

#

it worked!!!! finally my first code that I made

meager siren
#
void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.freezeRotation = true;
        cameraTransform = Camera.main.transform;

        // Hides the mouse
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;

        // Enable interpolation for smoother visual movement
        rb.interpolation = RigidbodyInterpolation.Interpolate;
    }

    void Update()
    {
        RotateCamera();
        MyInput();
        grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);

        if (grounded)
            rb.linearDamping = groundDrag;
        else
            rb.linearDamping = 0;
    }

    void FixedUpdate()
    {
        MovePlayer();
        SpeedControl();
    }

    private void RotateCamera()
    {
        float horizontalInput = Input.GetAxis("Mouse X") * mouseSensitivity;
        transform.Rotate(0, horizontalInput, 0);

        float verticalInput = -Input.GetAxis("Mouse Y") * mouseSensitivity;
        targetVerticalRotation += verticalInput;
        targetVerticalRotation = Mathf.Clamp(targetVerticalRotation, -90f, 90f);

        // Smooth the vertical rotation using Lerp
        verticalRotation = Mathf.Lerp(verticalRotation, targetVerticalRotation, Time.deltaTime * 10f);
        cameraTransform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
    }

    private void MyInput()
    {
        horizontalInput = Input.GetAxisRaw("Horizontal");
        verticalinput = Input.GetAxisRaw("Vertical");
    }

    private void MovePlayer()
    {
        // calculate movement direction
        moveDirection = orientation.forward * verticalinput + orientation.right * horizontalInput;

        rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);
    }

    private void SpeedControl()
    {
        Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z); 
        if (flatVel.magnitude > moveSpeed)
        {
            Vector3 limitedVel = flatVel.normalized * moveSpeed;
            rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
        }
    }

anyone know why its so jittery? im still learning the components, statements and syntax for Unityengine, and It itself and I can figure out why its so jittery, i can send a ss of my player as well

novel nymph
#

Unity keeps giving me these errors but there is nothing wrong with the game, can anybody please tell me how to fix this?

wintry quarry
wintry quarry
meager siren
#

hold on, what did i do to my code yesterday

#

gimme a second

#

now my player aint moving

#

what did i do 😭

meager siren
polar loom
#

does anyone have an extra horror ai script? i cant seem to find any

harsh haven
#

got the strangest error ever going on rn

harsh haven
#

So heres my blockspawner

#
using UnityEngine;
using TMPro;

public class BlockSpawner : MonoBehaviour
{

    public Transform[] spawnPoints;

    public Block blockPrefab;

    private float timeToSpawn = 2f;
    public float timeBetweenWaves = 1f;

    private Score scoreCounter;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Update()
    {
        
        if (Time.time >= timeToSpawn)
        {
            SpawnBlocks();
            timeToSpawn = Time.time + timeBetweenWaves;
        }
    }

    public void SpawnBlocks()
    {
        int randomIndex = Random.Range(0, spawnPoints.Length);

        for (int i=0; i<spawnPoints.Length; i++)
        {
            if (randomIndex != i)
            {
                Block blockInstance = Instantiate(blockPrefab, spawnPoints[i].position, Quaternion.identity);
                blockInstance.Initialise(scoreCounter);
            }
        }
    }
}
#

Here's my block code

#
using UnityEngine;

public class Block : MonoBehaviour
{

    private Score score;
    void Start()
    {
        
        GetComponent<Rigidbody2D>().gravityScale += Time.timeSinceLevelLoad / 15f;
    }

    // Update is called once per frame
    void Update()
    {
    if (transform.position.y < -2)
        {
            Destroy(gameObject);

        }
    }

    public void Initialise(Score scoreCounter)
    {
        score = scoreCounter;
        //score.IncreaseScore();
    }
}
#
using TMPro;
using UnityEngine;

public class Score : MonoBehaviour
{
    public TextMeshProUGUI score;
    public int currentScore;
    //public BlockSpawner currentSpawner;

    // Update is called once per frame
    void Update()
    {
        score.text = currentScore.ToString();
        if (currentScore < 0)
        {
            score.text = "0";
        }
    }
    
    public void IncreaseScore()
    {
        currentScore++;
    }
}
#

and here my Score code

#

This shouldn't work, but i just wanted to get all the referencing setup properly

#

anyway... if you look at the commented code in the Block scrip

#

if i uncomment that... which should just run the IncreaseScore method, increasing that random integer by 1 for score

#

it literally causes my blocks to infinetly clone every frame and glitch out the whole game???

#

I have absolutely no idea whats going in, my code seems like it would just be increasing an integer meant for a text after Initialising

pliant abyss
#

Non-looping animation firing twice

wintry quarry
harsh haven
wintry quarry
harsh haven
#

the block spawner script on the block itself

wintry quarry
harsh haven
#

It doesn't clone infinetely unless i uncomment that one line

#

And i have no idea how that line could be related when its controlling an integer only used for the textmesh

wintry quarry
#

and show us which object we're actually looking at

harsh haven
wintry quarry
# harsh haven And i have no idea how that line could be related when its controlling an intege...

my theory about the infinite spawning is this:

  • You never assigned a value to your scoreCounter variable in the BlockSpawner script
  • Therefore you are going to get a NullReferenceException in the Initialize function when you call score.increaseScore();
  • That means the timeToSpawn = Time.time + timeBetweenWaves; line is never running
  • That means you will call SpawnBlocks every frame because the timer is never updated.
#

that's your issue

#

in fact I'm 100% certain

#

So my advice:

  • Pay attention to your console window, it's telling you important errors you are ignoring.
harsh haven
#

should i make my scoreCounter variable public in blockspawner

wintry quarry
#

I know the first bullet point is true because it's a private variable and never assigned in the code

harsh haven
#

Yea actually

#

ur right

#

why is it private

wintry quarry
harsh haven
#

it has no idea what Score to Initialize righT?

queen adder
#

how do i fix this?

wintry quarry
harsh haven
#

thank u haha

wintry quarry
#

also you need to configure your IDE

#

!ide

eternal falconBOT
queen adder
wintry quarry
#

get it configured immediately

queen adder
meager siren
# harsh haven

Random suggestion, you should put your scripts in a “Scripts” folder so its more organized. Just a suggestion.

frigid sequoia
#

Massively ashamed of this snipet lol

#

Can I not do this better??

teal viper
#

And if you do, calling it on the parent should be enough

frigid sequoia
#

I am adding stuff to the layout and it's not updating properly

#

I am calling the parent to update in cascade cause apparently it does not do that by default

teal viper
frigid sequoia
#

Many of those, yes

teal viper
#

Well, then perhaps rethink this setup. They're not intended to be used together

frigid sequoia
#

Quite literally falls over without those

teal viper
#

Falls over?

wintry quarry
teal viper
#

Anyway, you should probably take it to #📲┃ui-ux if you want to fix your ui properly.

queen adder
#

Hey privateIK isnt found and i imported System.Collections.Generic

#

using UnityEngine;
using System.Collections.Generic;
public class PlayerGunSelector : MonoBehaviour
{
[SerializeField]
private GunType Gun;
[SerializeField]
private Transform GunParent;
[SerializeField]
private List<GunScriptableObject> Guns;
[SerializeField]
private PlayerIK InverseKinematics;
}

frigid sequoia
#

Like these, it tells me I should not use them together, but if don't add the content Size Fitter it does not occupy any space on the layout and everything overlaps on it

wintry quarry
queen adder
#

Invserse Kinematics

wintry quarry
#

Ok but what does that have to do with the code you posted

queen adder
#

no i meant PlayerIK

wintry quarry
#

What does System.Collections.Generic have to do with anything?

#

It certainly doesn't contain anything called PlayerIK

queen adder
#

yea i see i fixed it

teal viper
#

Maybe someone in ui channel can guide you better on this, but having these components on the same object is definitely not a solution.

frigid sequoia
#

Not how it's intended to work, but works for me

teal viper
#

Well, it forces you to do weird and unreliable stuff like forcing the UI to rebuild

#

It might have other issues and/or work differently on different platforms/in the build.

frigid sequoia
#

It's consistent if you tell the parent to be reloaded, it does always the same thing

#

But surely, I am using it wrong and should learn it better

safe root
#

What is the best way loop for enemy spawning?

#

For a wave base game

frigid sequoia
safe root
frigid sequoia
#

Well, then just call them each X seconds or make a pattern, or even make the intervals and quantity of enemies random, there is a bunch of ways

safe root
#

But what loop works best for that?

frigid sequoia
#

What are u ven asking there? Just drop it in update and make a timer

safe root
#

Well I need more control of it. Right now i'm trying to use a Enumerator but they spawn way to fast even tho I have a spawn interval

sour fulcrum
#

What control do you need

safe root
#

Where to spawn, how long to wait, making sure they don't spawn inside a object, etc

wintry quarry
#

those all sound like separate concerns

sour fulcrum
#

Ensuring where they spawn and ensuring they have space to spawn is not related to what loop you would want to use

safe root
#

Fair, but still knowing the best for it would be nice

wintry quarry
#

there is no "best" in general, it's going to boil down to your specific requirements and needs here.

#

The first step is figuring out how to express those requirements.

For example: "I want to spawn one enemy every 5 seconds"

frigid sequoia
#

Like, it depends 100% on the design of what kind of game you want to do and "a best loop" may not even exist, multiple are equally valid

safe root
wintry quarry
#

that will wait just one frame

#

you would need yield return new WaitForSeconds(SpawnInterval);

safe root
#

Oh yeah

#

Sorry

queen adder
#

Hey it says i have an error while shooting my gun and i dont see any errors

#

everything here is set too

sour fulcrum
#

We can’t see what line is 41

#

Nor can we see the gun scriptableobject

queen adder
#

line 41 is ShootSytem.play();

queen adder
polar acorn
queen adder
polar acorn
sour fulcrum
polar acorn
queen adder
frigid sequoia
#

How could I remove interaction over a whole menu under a given condition?

#

Like remove the pointer events on X objects directly

queen adder
#

for shootsystem its a particle system and i already added a value so i dont understand how could it be null and even if i do set for the shootsystem to work even if its null i get this error which i set up when the gun is not null

polar acorn
#

So, what's in Guns

polar acorn
frigid sequoia
queen adder
frigid sequoia
polar acorn
queen adder
#

dang ill have to write more lines of code to fix this issue

muted flax
#

hello, i want to ask
the Container is just empty object
why when I click the object, nothing happens
the code is still empty

private void OnMouseDown() {
    Debug.Log("Coin collected!");
}
teal viper
safe root
#

How do I change my Vector2 to instead go X and Z instead of X and Y?

keen dew
#

You have to convert it to a Vector3 that has Z set to the Vector2's Y. Also note that multiplying the result of Random.insideUnitCircle with the position doesn't make much sense.

#
public Vector3 RandomPointInAnnulus(Vector3 origin, float minRadius, float maxRadius)
{
    Vector2 randomDirection = Random.insideUnitCircle.normalized;
    float randomDistance = Random.Range(minRadius, maxRadius);
    Vector3 point = origin + new Vector3(randomDirection.x, 0, randomDirection.y) * randomDistance;

    return point;
}
safe root
keen dew
#

Which part?

safe root
#

Why mutilplying it doesn't make sense

keen dew
#

The object's current position doesn't have anything to do with generating a random direction so the result is nonsense

#

Imagine for example if the object is at (0, 0) then multiplying the direction with it would always result in (0, 0)

safe root
#

Yeah, that makes a lot more sense

muted flax
safe root
#

Or if it's the mouse, the mouse is over the coin

lean cipher
keen dew
#

!code

eternal falconBOT
lean cipher
#
public class Program
{
    public static void Main(string[] args)
    {
        System.Console.WriteLine("Hello, World!");
    }
}
#

YUR

#

thank you

nimble apex
#

its still in planning stage, but i planned to save down input action mapping as json data , and reapply when user login or when its needed

#

if i gonna let users to customize their keybinds

#

this thing should be saved locally, not on server, waste of space

#

so does other player related stuff like setting preferences

stuck field
nimble apex
#

especially on input system part

stuck field
nimble apex
#

good 👍

#

ty

glossy crystal
#

Hello, Is there a tutorial that introduces the very basics? I've followed along but I don't understand where is the entry point of the game?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

glossy crystal
#

Yes I'm following one now, the roguelike but I don't get how the unity engine knows what classes govern what

#

what is the entry point, what monobehavior is, etc

stuck field
#

Modifiers, like public, internal, private

sour fulcrum
#

It doesn't, that's up to you to decide overall

stuck field
#

Monobehaviour is a class that unity uses to determine objects

#

Or something

sour fulcrum
#

components

stuck field
#

Yeah, gives access to unity functions like Start, Update, Awake, stuff like that

sour fulcrum
#

you'd probably have to ask more specific questions or theoretical examples to help get can understanding of what your looking for specifically here

glossy crystal
#

Okay thank you, I'll try to come up with a more specific one

#

Okay so like: Right now, I have a PlayerCharacter gameobject, a BoardManager, and a GameManager which governs both the player and the board (via composition).
1st question: In the inspector tab for the GameManager class, do only player controller show up and board manager because they inherit from MonoBehavior? And TurnManager is just a c# class, carrying some data unrelated to Unity?
2nd: How does unity know which file is the entry point for my "game"? I could have multiple GameManager gameobjects, and how would it know which one to draw to the screen?

#

where do I just go to learn about this basic workflow stuff instead of following a guide to make a basic game and learn some of this on the side?

stuck field
#

I think you're going about this all the wrong way

glossy crystal
#

what is the correct way? sry im new

sour fulcrum
#

playercontroller and boardmanager show up because you assumably have them using the public accessor. If a field is marked as public or explicitly via [SerializeField] and supports serialization and inspector display Unity will show it in the inspector like that. This is supported by unity kind of on a case by case basis but supports a majority of types (a big outlier for example are dictionaries)

Unity doesn't know nor care about an entry point for your game. having a "GameManager" object is an interpretation you have made up which is fine but doesn't have any actual standing in the context of Unity. (also drawing to the screen is irrelevant in this question).

Anything deriving from MonoBehaviour recieves the Awake and Start call when they are first created and enabled for the first time. This is the most common entry point to start composing a system of your choosing. (but not the only way)

glossy crystal
#

Okay so things that inherit from monobehavior will implicitly support inspector display? And I have to do it manually for c# classes?

#

TurnManager there was public, so this is the only difference

sour fulcrum
#

usually yeah. for base/poco classes you will need to explicitly mark the class with a [System.Serializable] attribute in order for Unity to show and serialize them. You may also need to mark the field using them with [SerializeReference] depending on your usecase and expectations

safe root
#

I forgot how but how do I get this Random.range to also work as a int for the if statment?

sour fulcrum
#

If your coming into Unity new with prior c# experience it may be worth trying to use MonoBehaviours as much as possible to get comfortable with the Unity workflow (but base/poco class usage is totally valid overall ofc)

glossy crystal
#

Okay, thank you! that clears up my questions and yes I will try to use monobehaviors more to get used to it

sour fulcrum
#

no worries

#

a majority of people end up using some form of a singleton pattern to create those kind of gamemanagers and such

#

makes things a lot easier

shut swallow
safe root
shut swallow
#

var randomInteger = Random.Range(0, Enemies.Length)

#

and whenever you need a new randomInteger, set the variable again when called

safe root
#

Well the same problem happens

stuck field
#

What is the problem

safe root
#

I need the var to be a int not a Gameobject

stuck field
shut swallow
#

persumably that if you repeat call on while loops you should get a new number every tick the code was ran

stuck field
sour fulcrum
#

@glossy crystal this is super generic but just a super duper rough example of using a singleton along with an objects awake call to get some form of workflow going

public class GameManager : MonoBehaviour
{
    private static GameManager _instance;
    public static GameManager Instance
    {
        get
        {
            if (_instance == null)
                _instance = Object.FindFirstObjectByType<GameManager>();
            return (_instance);
        }
    }

    public List<MyContentExample> AllActiveContents { get; private set; } = new List<MyContentExample>();

    public void RegisterContent(MyContentExample content)
    {
        //stuff with content
        allActiveContents.Add(content);
    }
}
public class MyContentExample : MonoBehaviour
{
    private void Awake()
    {
        GameManager.Instance.RegisterContent(this);
    }
}
shut swallow
#

float?

stuck field
#

I'm not looking for anything

#

What do you want your code to do?

safe root
#

Never mind, I figured what I did wrong

shut swallow
shut swallow
stuck field
#

Partially my fault for not realizing you weren't the same person

shut swallow
#

🫠

safe root
# stuck field What do **you** want your code to do?

So I want the code to to a assigned number which equals a certain enemy. I want to use this number to select what enemies going the spawn and what how far they'll spawn compared to other as well later. Where i'll be setting different spawn times

stuck field
#

Possibly due to your math, slideFriction might be going up rather than down and it moves you that way

safe root
shut swallow
#

then you can perserve the number for calculations but also get a new random number later

stuck field
safe root
#

But how would I turn that number back into the array so I can get it

stuck field
#

array[number]

#

That will return the object at index of number in the array

#

It's the same thing you are doing right now

safe root
#

Oh, let me try that then

#

I probably being stupid but what am I doing wrong

stuck field
#

Everything

safe root
#

Makes sense

#

So what's all wrong

stuck field
safe root
shut swallow
stuck field
# safe root I know everything that I tried before

Well you can't really go:

GameObject enemyToSpawn

You can go

(GameObject)enemyToSpawn however it's redundant since to convert to a GameObject, it would already need to be something similar, in which case you can just put enemyToSpawn

safe root
#

I know that but it doesn't exist in the curent context. So there is something that I need to put before it.

stuck field
shut swallow
#

ight thanks

stuck field
# shut swallow ight thanks

Also, remember to delete your post from in here if you are gonna ask in there as it's a recent post, just to prevent multiple answers, confusion, and such

stuck field
#

Putting something before it, same issue, it won't exist

#

The variable doesn't exist

shut swallow
#

yea originally i asked in general but seems like no response so tried my luck here

teal viper
sour fulcrum
#

darks advice is really weird ngl

sour fulcrum
#

the logic is the wrong way around

stuck field
#

Oh yeah

#

Oops

safe root
stuck field
#

Well, you can go over it, then put it to use right as you are going over it

#

Code along with the basics, test it out, then continue

teal viper
#

And yeah, perhaps go over variable assignment as well

twin pivot
sour fulcrum
#

what is numOfDialogue set to

wintry quarry
twin pivot
#

i only have 2 and the other one is disabled

wintry quarry
#

Double check

#

Search the hierarchy

#

With t: npc_text_controller

twin pivot
#

well i do have this

sour fulcrum
#

and show the full npc controller inspector + full npcdata inspector

silver gale
#

hello! unsure if this would be a good place, i want to add like a model that goes under the road like a support bridge or beams maybe? any ideas?

#

thought maybe it would be coding

sour fulcrum
#

its not coding

twin pivot
wintry quarry
sour fulcrum
warped kindle
#

Im following a tutorial in youtube but I cant put CounterTopPoint into that script

wintry quarry
#

Print all the information out including the name of the object, the array length, the value you're accessing, etc

warped kindle
twin pivot
sour fulcrum
#

ah, did not see that, apologies

#

can you show both screenshots of the inspectors

#

full

twin pivot
#

both npcs?

sour fulcrum
#

the npcdata in question and the npc controller

#

text controller

#

nitpicking but its weird that you have a NPC_Controller class referenced to as an npcData but it's not an issue

twin pivot
#

the script controls the npcs but it also stores the data within

#

looks like numofQDialogue is going to 2 for some reason

#

turns out i had referenced the wrong array - fixed, thank you for your help

twin pivot
eternal falconBOT
#

:teacher: Unity Learn ↗

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

golden stump
#

How can I post code blocks/files onto here? I'm having trouble saving and loading the position of the player character

slender nymph
#

!code

eternal falconBOT
golden stump
#

I used paste.mod, Do i just post the link to it here?

slender nymph
#

oh dear god

#

please please don't use playerprefs for save data, especially not like this. playerprefs isn't really meant for that despite the many tutorials that teach it as an easy way to save data

#

you should look into serializing to json and writing to a file instead of using playerprefs

golden stump
#

Alright then I'll look it up thanks

slender nymph
#

oh and just so you are aware, quaternions are not angles in X,Y,Z with a 1 as the W

golden stump
#

God what kind of tutorial was I following 😭

#

Just wasted two hours on my project

grand snow
#

It's easy to convert to and from euler angles

#

Just don't mess with a quaternion thinking it's xyz in degrees cus it's not

golden stump
#

Alright then

grand snow
tender gazelle
#

if i may ask?

slender nymph
#

it is instructions for posting code in this server

tender gazelle
#

Got it👍

slender nymph
#

note how the instructions for correctly posting code do not include screenshots of your code

tender gazelle
#

Okay👍

slender nymph
#

and make sure to follow the instructions for configuring vs code as having a configured IDE is a requirement for receiving help with your code here

tender gazelle
#

I tried clicking on the links nut it doesnt take me anywhere🤔 What should i do?

slender nymph
#

wdym it doesn't take you anywhere?

tender gazelle
#

So yk theres like links in the message

#

tried clicking it

#

doesnt bring me to anysite

slender nymph
#

that sounds like an issue with your stuff 🤷‍♂️ dunno what to tell you

tender gazelle
#

😔 👍

glossy crystal
#

Hello, I'm wondering why nothing shows up here, but I can still manually drag a prefab in from the projects tab and it works?

grand snow
#

Unity shit

#

I have wondered the same but I think it doesn't work properly with monobehavious as technically the prefabs are of type game object

sour fulcrum
#

if you turn on the advanced selector it supports a lot of those unsupported cases iirc but needs time to bake/index your project compared to how instant the default one is

glossy crystal
#

Hm I turned it on but still doesn't seem to show up, I have the filter for this, and my prefab has the required component, am I doing something wrong?

slender nymph
#

Indexing is still in progress.

glossy crystal
#

oh

#

sorry I can't read sadok

grand snow
#

It used to not even say the second part so you wouldn't know

#

And for some reason the default operation is to select the asset and not open which baffles me

digital haven
#

I’m working on a beginner level game with the rollaball unity learn guide.

I got up to the point of where I’m baking a navmesh for the ground to work for the enemy agent object but it feels like it’s not loading at all. Any advice I could use to make it run faster or any settings I could be missing?

twin pivot
#

pls screenshot instead of using a phone

plucky sage
#

I'm having an issue where my configuration struct is assigned factory values in the unity editor, but in runtime it won't reference the actual factroy objects.