#💻┃code-beginner

1 messages · Page 200 of 1

teal viper
#

Not if you override it.🤷‍♂️

#

Then debug it. What's making it get stuck in the jumping state?

summer stump
#

It's "based on recent edits"
Did you remove any other null checks recently?

tawdry mirage
summer stump
#

Otherwise, yeah, makes no sense

summer stump
drowsy totem
#

I guess this question fits code-beginner best:

I struggle getting intellisense working in VS Code, am I missing something obvious or should I just switch over to Visual Studio?

#

There's the VS Code extensions (Unity, C# Dev kit and C#), then there's the Unity packages (Visual Studio editor, and according to some guides Visual Studio Code editor, but other guides say I shouldn't have that even though it's got VS Code in its name).

north kiln
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

north kiln
#

Visual Studio Code editor
This extension is old and no longer a part of the install, and you should remove it if it's present

#

If you haven't restarted after configuring that may fix it

drowsy totem
#

I've done all the steps mentionedi n that article, set VS Code as the external editor, and also regenerated the project files. Several times.

#

Which one do I have to restart? Unity? VS Code? Both?

summer stump
north kiln
#

Computer

drowsy totem
#

wait what

north kiln
#

Or log out and back in, either one

drowsy totem
#

I got it working, once, without having done that

#

the website you linked to didn't mention having to do that either

summer stump
#

Do it or don't, your choice
Doesn't seem like a big deal to me

drowsy totem
#

I'm not opposed to it, I'm just surprised

#

I didn't test it or think to try it

north kiln
#

When certain things install they want to modify the PATH, which requires logging out

#

if the thing wasn't already configured

drowsy totem
#

sure, but usually you get the "do you want to restart your computer now or later" prompt in those cases

north kiln
drowsy totem
#

And also more lightweight and takes way less disk space

summer stump
drowsy totem
#

Thanks a lot for the tips and the links, I'll look into this and try to figure it out

summer stump
#

Vs code is literally just vs with stuff removed

drowsy totem
#

If I wanted all the missing features, I'd use Visual Studio. I chose VS Code because it's more lightweight

summer stump
#

The debugger is an important one

drowsy totem
#

True, that's a pain

#

Ooh, this could also have been part of it:

#

I just open the script files, not the project, and that could cause all sorts of issues

teal viper
#

To be fair, modifications to PATH are immediate. It's just that running apps and services retrieve them once when launched.

north kiln
drowsy totem
#

But then again, I did get it to work sometimes

teal viper
#

So in most cases it's enough to restart the program that relies on the path variables.

#

Unless they rely on some kind of service or background process that doesn't close with the app.

drowsy totem
#

I considered having to restart Unity Hub...

summer stump
#

You are spawning them every frame

crimson sinew
#

In Update() you don't have any check to stop it from spawning in the next frame

summer stump
#

Update runs every frame

#

Not only do you spawn them every frame, you increase level every frame, which makes you spawn a BIGGER AMOUNT

#

Start runs once in the objects lifetime

crimson sinew
summer stump
#

Start runs once in the objects lifetime
Which... seems like it's what you want

crimson sinew
teal viper
#

Typically, you would check a condition every frame and if it's true you execute some logic.

#

That applies to any feature you might want to implement.

summer stump
crimson sinew
#

Actually

#

I think you can just move the rest of the code in update into your if(asteroidCount == 0) check

#

yeah

#

when you run out of asteroids, it ups the level, and spawns the new ones

#

otherwise, the spawning code doesnt run

#

are there asteroids in your scene intially?

summer stump
#

Is AsteroidCount changed in the inspector?

#

It will take precedence over the initializer

crimson sinew
#

having external addition of your asteroidCount makes the code more confusing honestly

#

Is there a reason you don't just up the counter when you spawn the asteroids?

#

ah ok

rich adder
#

which axis

#

dont send screenshots of code

#

!code

eternal falconBOT
summer stump
rich adder
#

so pass that axis in the new vector3

summer stump
#

You're passing a z of zero into ViewportToWorldPoint

#

You construct a Vector3 with only x and y, so z defaults to 0 afaik

#

And the z is the distance from the camera in this case

#

So 0 distance from the camera is probably not what you want

#

new Vector3(x, y, z)

#

See what you are missing there in all those edge if statements?

#

Yes

#

You have new Vector3(x, y)

#

Yeah, it depends on where you want it

#

You could pass in the players distance from the camera

#

It seems like that's what you'd like?

#

Or maybe the camera near clip plane? And then they fly "out" to the player

#

Always?

#

Hmmm, I may he wrong... because this is an absolute position.
And 0 should put it at the player then...

#

I need to look up the docs for ViewportToWorldSpace

#

Ok ok, yeah, z is distance from camera

#

So you want it to be +13

#

-13 would be behind the camera

#

I think

#

I think this code looks like it expects an orthogonal camera view?

Is this from ChatGPT or something?

#

Ok yeah, it's expecting orthogonal

#

Since that's what makes 2d 2d for the most part

#

I am not sure. You could try setting viewportPosition.z to zero..

#

I dunno though sorry

faint osprey
#

with Random.OnUnitSphere is there any way to increase the radius in which it randomly chooses a location

night mural
prime horizon
#

Guys, I remember not using the old UI of the Editor, but suddenly it changed to this older UI. I'm using Editor 2022.3.15f1

rare basin
#

It is code related channel

#

change your layout

visual hedge
#

Is there new ui? 🙂 Am I missing something?

rare basin
#

no

prime horizon
#

I think it's a bug or smt

rare basin
#

also as i said, this is a code related channel

visual hedge
#

That's not different ui, it's different layout

prime horizon
prime horizon
rare basin
visual hedge
#

Top-right, Layout. Color is the same imo

noble summit
#

what is the easiest networking system for begginers

prime horizon
rare basin
eternal needle
#

all networking solutions have their pros and cons. None are easy

noble summit
#

okay then what is the easiest to just make a test prototype

#

rigidbody -> constraints

fiery notch
#

im using screen wrap, everytime they wrap the screen, they drift 1 unit forward on the z axis

#

im not sure how to fix it

noble summit
#

idk then i just started unity

eternal needle
fiery notch
#
void Update()
    {
        //doing this allows for the screen to wrap with no regards to screen aspect ratio
        Vector3 viewportPosition = Camera.main.WorldToViewportPoint(transform.position);

        //need the ship to wrap on the opposite side it came from
        Vector3 moveAdjustment = Vector3.zero;
        if (viewportPosition.x < 0)
        {
            moveAdjustment.z = 0;
            moveAdjustment.x += 1;
        }
        // need to have the opposite, so if you go the other way, then you will wrap around as well, this prevents you from always spawning on the same side
        else if (viewportPosition.x > 1)
        {
            
            moveAdjustment.x -= 1;
        }
        //this is essentialy the same as left and right screens, except swap out X for Y since you are working with the top and bottom screen.
        else if (viewportPosition.y < 0)
        {
            moveAdjustment.z = 0;
            moveAdjustment.y += 1;
        }
        else if (viewportPosition.y >1)
        {
             moveAdjustment.z = 0;
            moveAdjustment.y -= 1;
        }
        //the reason for doing this method of screen wraping, is to cover for the possibility of hitting two screens at once, such as a corner.

        transform.position = Camera.main.ViewportToWorldPoint(viewportPosition + moveAdjustment);
        if (viewportPosition.z < 0)
        {
            moveAdjustment.z = 0;
        }
        else if (viewportPosition.z > 0)
        {
            moveAdjustment.z = 0;
        }
    }
#

here is my code for the screen wrap, im not sure how to make it to where when they wrap on teh edge of the screen, they stay on 0 = z

rare basin
#

ok but you do moveAdjustment.z

#

after you change the position aswell

#
  if (viewportPosition.z < 0)
  {
      moveAdjustment.z = 0;
  }
  else if (viewportPosition.z > 0)
  {
      moveAdjustment.z = 0;
  }

these lines could be removed and nothing will change

#

they dont do anything

fiery notch
#

ok

#

whats the next step

#

i accidently just deleted my script folder not paying attention

#

did i just lose everything

rare basin
#

revert it on git

fiery notch
#

im not on githubh

#

im just using unity

rare basin
#

🤷

#

people divide into 2 groups:

  • those who make backup
  • those who will be making backup
#

try CTRL+Z in the file explorer

teal viper
fiery notch
#

yeah i did

#

i found them thank god

#

but im still stuck on my issue, i have no idea where to look to find a solution

eternal needle
#

well fix the bigger issue at hand, that you arent using version control

#

you just had a scare of losing an entire folder

fiery notch
#

right i just made a backup of my project in case on github

#

and saved a copy of the project on my pc

rare basin
#

just use version control

#

and you'll be fine

eternal needle
#

as for your issue, try doing some basic debugging as to why the z value is moving. like log the viewportPosition and moveAdjustment

rare basin
#

as i said already

#

you are modyfing the z

#

after setting the position

#

that if/else could be deleted and nothing will change

#

it's doing nothing right now

#

noone asked you to delete it

#

you dont understand what i am saying

#

read what i wrote

#

read your code again

#

you are modying the transform.position

#

THEN AFTER THAT

#

you are changing the moveAdjustment.z

#

it has no effect at all

#

you are changing moveAdjustment value on Z axis to 0

#

but then you are doing nothing with it

#

yup

#

well it requires just some logic thinking

#

set the Z value BEFORE assigning the transform.position

dim brook
#

i cant change the size of this in battle canvas

rare basin
dim brook
#

yea isnt it a code fix

rare basin
#

do you have any code to share?

dim brook
#

arent u meant to put some script in

rare basin
#

no

dim brook
#

that's what google says

rare basin
#

don't ask non-code related question in code related channel

#

you cannot change size of the canvas

#

unless it's world canvas

#

read again what i wrote

#

your moveAdjustment.z = 0 does NOTHING

#

because you are not USING IT

#

anywhere

#

it's just an empty value

burnt vapor
#

Why are you even helping

rare basin
#

yea im done at this point 😄

burnt vapor
#

This person needs to learn basic c#

rare basin
#

tried my best

burnt vapor
#

Please read the pinned messages for tutorials on using c# @fiery notch

burnt vapor
hybrid sundial
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    PlayerInput playerInput;
     private void Awake()
    {
        playerInput = new PlayerInput();
        playerInput.Fatlad.Move.started += context => {Debug.Log(context.ReadValue<Vector2>());};
    }
}
``` Im wondering why this is not recognising Fatlad
static cedar
#

The journey.

static bay
#

Sometimes you need a mental refresh.

hybrid sundial
teal viper
hybrid sundial
#

In an action@ap

#

Map

#

Action map

teal viper
#

Take a screenshot

static cedar
teal viper
#

Is the action map compiled into a C# class?🤔
Didn't have the chance to work with it yet.

hybrid sundial
#

yes

#

Im following a tutorial from iheartgamedev

#

It’s a basic character controller

static cedar
#

I only used events and add it from the editor.

hybrid sundial
#

I would do that but this guy is using completely different things

#

And I won’t know what to do

#

If I don’t follow

teal viper
static cedar
#

Unity offered three methods of doing it from the editor.

hybrid sundial
#

I want to learn how to make a character controller and then a hierarchical state machine what recourse would you guys use

static cedar
#

Two of those are shit.

#

1 is very shit. UnityChanLOL

#

I can't point out rn since I'm not in computer.

rare basin
#

because its not inside the if? @fiery notch

#

you only set isAlive to true when you collide with the asteroid

hybrid sundial
rare basin
#

and you do the rest for all other colliders

static cedar
hybrid sundial
#

CodeMonkey did a hierarchical state machine

hybrid sundial
static cedar
#

I learned... The new input system specifically.

teal viper
static cedar
#

Real.

hybrid sundial
#

do you know how to program a state machine now

#

a hierarchical one

teal viper
#

Everyone knows. It's not hard.

static cedar
#

Yes?

#

J-bear is learning it rn I think.
By my own bad advice, I think you can help each other for that matter.

teal viper
#

Or think wether you need it in the first place...

static cedar
#

I'd say it's handy.

teal viper
#

It depends on the context, but I wouldn't never use it for a character controller

hybrid sundial
#

how would you recommend I learn it

teal viper
#

At most, I'd use a simplified version, where I just have a current state enum and update based on it in the character controller

#

Start from learning a normal state machine. If you get it right, implementing a hierarchical one would be easy.

static cedar
#

An enums and a switch case is a valid state machine I think.

teal viper
#

They are. What I mean is that you don't need an elaborate system where each state is a separate class.

rare basin
#

switch and enum based state machine might work for small state machines

#

but imagine when you have a state machine with like 20-25 states

#

and a big switch for that

teal viper
#

Well, you'll be surprised...

#

But some AAA level games have that.

static cedar
#

So it's valid, but for a small scale.

teal viper
#

C++, but still

rare basin
#

it doesn't mean its proper approach

#

just because some AAA level games have that lol

teal viper
#

Point is, it's working.

rare basin
#

sure, didni't say it doesnt

teal viper
#

And it's also matching the state machine definition.

rare basin
#

yup, didin't say it doesnt aswell

static cedar
#

So what is incorrect then?

rare basin
#

that this is a proper approach

#

in a big state machines

static cedar
#

Well I didn't quite say that. UnityChanThink

teal viper
#

"a proper approach" is a really subjective thing when it comes to code architecture

ivory bobcat
#

Well, you're not moving except on z axis to the value zero.

static cedar
#

Is this 2D or 3D?

tender mirage
#

No clue why this isn't working.

rare basin
eternal falconBOT
tender mirage
#

Yeah it wasn't

#

Thank you

ivory bobcat
#

What does it do instead? (Continue to go up or down without constraint?)

#

Try logging the y value before adjustment and after adjustment

#

Or the entire vector..

#

I'm referring to your code.

rare basin
#

just fyi

ivory bobcat
#

Ahh..

static cedar
#

Real.

#

At least they got the spirit.

tender mirage
#

a quick question. I'm using the 2023 build of unity. But visual studio was last updated in 2022

ivory bobcat
#

Well, my advice is to log the view port position before and after adjustment. It would tell you what you've changed that wasn't appropriate other than setting z to zero - which likely isn't the sole issue.

static cedar
tender mirage
ivory bobcat
tender mirage
#

I havn't signed in for instance but i doubt that's the problem.

near wadi
#

it is not

static cedar
#

For starters what's the problem again?

#

IDE not working right yeah?

near wadi
#

i thought autocompletion

ivory bobcat
#

Also, consider removing that else in front of the if statement for checking the y bounds of the view port position.

static cedar
rare basin
#

it is working

#

he's writing code in it 😉

stone lance
rare basin
#

otherwise he would have that error higlighited

#

hence why i told him to configure his ide

stone lance
#

I do understand that, I was just pointing out the error also.

tender mirage
burnt vapor
stone lance
#

You would edit either one so they both match just like you would correct an error in any text file using Word

nimble hinge
#

Lol "placementId cannot be nil or empty"

#

unity made a small typo

ivory bobcat
stone lance
burnt vapor
#

Not sure why you'd argue about a simple rule, configuring it is not hard

#

Having a misconfigured IDE is a bigger issue than whatever they are trying to solve

#

5 minutes of work at most

#

And if they are a troll then it's easy enough to figure out

stone lance
#

Maybe for us. Like I said they just stated they don't know how to change the name of a variable. Obviously they are too new to do the basics yet.

burnt vapor
#

It's literally 5 minutes of work when you use VS and only 4 steps with multiple pictures

#

It literally cannot be made simpler than this

#

Also I haven't seen any posts about issues during configuration so idk why we're assuming there is one

rare basin
#

then don't learn how to code

stone lance
#

Well renaming a variable is very simple too. Even simpler actually. I suspect there could be a language barrier

rare basin
#

fixing his error is not even realted

#

to his ide not being configured

burnt vapor
#

But hey maybe we can ask @tender mirage how the configuration is going instead of bickering about the steps

rare basin
#

so idk what are you talking about

ivory bobcat
rare basin
#

without his IDE configured

nimble hinge
#

Why are you guys arguing

#

What's the point of it

#

One mistake wont do much

#

Anybody knows what this keyboard means?

#

what am i supposed to google

burnt vapor
#

Idk

nimble hinge
#

I'm unsure if it's a keyboard even

burnt vapor
#

Unity editor keyboard icon

#

Doesnt it give a tooltip if you hover over it?

brave compass
#

Have you tried hovering over it to see if there's a tooltip?

stone lance
nimble hinge
#

Doesn't work

#

Oh nevermind

#

I was in playmode that's why

nimble hinge
stone lance
#

Playmode strikes again

ivory bobcat
nimble hinge
#

Sure, I just thought it would impact the code

ivory bobcat
#

How so?

nimble hinge
#

I don't know?

#

That's why i asked

eternal needle
#

if you havent coded anything related to it, then its likely not a coding issue

nimble hinge
#

Well, Fair point. I'm not here to start an argument for it

north scroll
#

hey im trying to implement a movement mechanic for a game using unity's "new" input system and following this guide: https://www.youtube.com/watch?v=ZSP3bFaZm-o

Currently the player can move, but only once when I press the corresponding input key that I set up. I tried playing around with the FixedUpdate() and Im assuming FixedUpdate has something to do with the continious movement I want rather than once per press but not sure how to use it. Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Windows;

public class playerController : MonoBehaviour
{
    [SerializeField] public float walkSpeed;
    [SerializeField] public float dashSpeed;
    [SerializeField] public Vector2 moveVelocity;

    private PlayerControls playerControls;
    private Rigidbody2D rb;

    private void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        playerControls = new PlayerControls();
    }

    private void FixedUpdate()
    {
    }

    private void OnMove(InputValue input)
    {
        rb.velocity = input.Get<Vector2>() * walkSpeed;
    }
}

In this video, I cover everything regarding Unity's New Input System. I walk you through how to actually implement this system as well. It is a bit longer of a video, but it is the most thorough out of all the videos I have seen as well. I started out not knowing how to even use it, to know only using this to control my game. Hope you all enjoy ...

▶ Play video
#

feel free to tag me if you know, ty!

ivory bobcat
north scroll
#

it moves when key is pressed and slows down to a stop

#

so the OnMove() is triggering, but only when I press the key not hold it, and I want it to continiously move while im holding it which is where the FixedUpdate() comes from

#

and I tried changing the interaction in the input system with HOLD but the result is the same, only with a slight delay between the movement and the key press, but that makes sense, as i need to hold it for the OnMove() to trigger in the first place

#

i also tried adding to the FixedUpdate() rb.velocity = moveVelocity so that the rb.velocity changes in fixedupdate to the rb.velocity (and changing moveVelocity inside the OnMove() based off the input to rb.velocity ) but that didnt work either

#

basically I just wanna understand how OnMove() can continue to execute while holding down the key rather than just once

timber tide
north scroll
#

yep

timber tide
#

Usually the idea is you only check when you press and when you unpress the button.

#

as continuous readback is not usually what you try to do

north scroll
timber tide
#

I'm not sure about how it works with analog stuff though.

#

Yeah, exactly

north scroll
#

cuz currently Im using send messages NOT invoke unity events

timber tide
#

It's not like you're giving input of different speeds every frame, so the only thing you care about is when it started, and when you decide to let go of that button.

carmine sierra
#

whats the simplest way to reference the gameObject of a scripts child

hexed terrace
north scroll
#

so i need to change my script to fit with Invoke Unity Events rather than send messages? Then use the OnMove() to change the velocity based off either ctx.performed ?

carmine sierra
hexed terrace
#

If you want to get the component via code, then use GetComponentInChildren<T>() for a single component, or GetComponentsInChildren<T>() if there are multiple of the same component.

timber tide
hexed terrace
#

Send messages.. the thing that uses strings? Never use that

static bay
atomic star
#

Is there a way to attach a
private GameObject gameObject; with private TextMeshProUGUI textMeshPro; in a class Example ?

Or is TextMeshProUGUI itself a game object?

static bay
#

TextMeshProUGUI is a Component

ancient charm
#

hello which channel can i ask for help about scripts?

#

sorry im new here

static bay
#

It's attached TO a gameobject, but I'm not exactly sure what the question is.

north scroll
#

how would I change the script to work with unity events tho? Ive only used send messages, so not sure how to use the callbackcontext, and I didnt quite understand with the documentation

static bay
north scroll
#

not sure what to put in ctx

atomic star
atomic star
#
        GameObject canvas = GameObject.Find("Canvas");
        gameObject.transform.SetParent(canvas.transform);
doesnt work        // gameObject = gameObject.AddComponent<textMeshPro>();
        textMeshPro.text = count.ToString();
        textMeshPro.rectTransform.localPosition = new Vector3(50, 0, 0);

    }```
#

doesnt work // gameObject = gameObject.AddComponent<textMeshPro>(); this doesn't work

hexed terrace
#

textmeshpro isn't what you want

static bay
#

TextMeshProUGUI would be the component you want to add.

hexed terrace
#

Better to use TMP_Text

static bay
hexed terrace
#

Yep, easier to type, remember and it's the base class for TextMeshProUGUI and the 3d one, so can be used for both

fierce shuttle
#

AddComponent also returns T provided, you may not be able to set "gameObject" equal to that directly

atomic star
#

but that's not my question i wanna know how to add the textmeshprougui component to the game object i created

#

in the same class

static bay
#

I think I understand the confusion though. They probably don't understand how generics work.

hexed terrace
#

actually, adding the component, you wouldn't use TMP_Text

timber tide
static bay
#

This adds a TextMeshProUGUI component to the gameobject, and then returns a reference to it, which will be stored in the textMeshPro variable for you to manipulate.

atomic star
#

this is the full class I actually want to reference the textMeshPro in the class not create a new variable of TextMeshProUGUI in the constructor

#

let me try that

hexed terrace
#

with the rectTransform you want to set the anchoredPosition not the localPosition

carmine sierra
#

should i reuse as many variables as I can by making them public to other scripts

#

like the mouses position for example

hexed terrace
#

No

static bay
north scroll
static bay
#

Your default for pretty much everything should be private.

carmine sierra
#

why exactly

#

mouseposition will be universal

hexed terrace
#

encapsulation, code tidiness, code readability

#

you should never have public fields (variables)

static bay
#

^ also mouse position can always be accessed from Input.mousePosition no?

#

There's some variable like that

#

Anyway, a big part of keeping your code clean and maintainable is defining how it interacts with other code. Just making everything public can lead to you being unable to track exactly how a value is being changed.

atomic star
hexed terrace
#

@rare basin public fields are bad and shouldn't ever be used, there's no need and can lead to spaghetti code, poor maintainability etc

atomic star
#

Also [SerializeField] is just for debugging and stuff since it makes it easy, mhm?

static bay
static bay
#

So more like "initializing".

static bay
hexed terrace
#

you mean... readonly ?

atomic star
static bay
atomic star
#

can't everything be done with code and private?

hexed terrace
timber tide
#

naughty attributes has a readonly attribute, but otherwise you can make yourself one in a few lines of code

hexed terrace
burnt vapor
static bay
rare basin
static bay
#

Like Mao said there's resources to get behaviour like that.

#

Just odd it isn't in the engine baseline.

fierce shuttle
timber tide
#

unity expects other devs to pick up their slack or stick to custom editor scripts

#

no reason not to have* an easy way to hide and show property fields serialized values

burnt vapor
static bay
#

You know what else is in Unity components but not available as an attribute?

#

Bounds.

hexed terrace
rare basin
static bay
atomic star
#

the highlighted line gives error object reference not set to an instance of an object
What I want to achieve is the numberSpawner class creating a gameObject that is child of canvas in the hierarchy

static bay
#

Anonymous methods, ya tones.

#

But just another method explicitly written out within a method?

static bay
#

Odd shit.

hexed terrace
rare basin
#

you shouldn't use any Find() type methods tbh

north scroll
#

so changing it to invoke unity events and adding the context param in my move(), worked. However, now im trying to implement a jump mechanic and this isnt working and im not sure why

atomic star
static bay
hexed terrace
rare basin
hexed terrace
static bay
#

No but like... in this script, where is the variable gameObject set?

rare basin
hexed terrace
static bay
rare basin
#

oh.. don't use names reserved

#

by Unity

static bay
#

It's fine-ish. We're not in a Monobehaviour class anyway.

rare basin
#

then what is the purpose of gameObject

#

you don't set it anywhere

#

also change the name of that variable

graceful citrus
#

how do i do physics-based spinning on a mesh collider

rare basin
#

as this is misleading and it's a unity reserved name

atomic star
#

I just wanted the gameObject to be the one that has a textMeshProUGUI component attached to it and then i wanted to use that gameObject elsewhere

#

a class having an attribute of gameObject is a bad idea i reckon?

strong wren
#

Is NumberSpawner not a monobehaviour on purpose?

hexed terrace
static bay
static bay
rare basin
static bay
#

Whats the goal here

atomic star
#

i forgor why i even removed it now 💀 so bad

#

guess just testing if it works without monobehavior?

static bay
#

if what works

hexed terrace
#

it needs to be an MB to be in the scene

atomic star
#

because i have another script attached to canvas known as "GameHandler" which is monobehavior

static bay
atomic star
#

i guess i just wanted to make the 2 communicate

#

i saw that too sorry im new lol

hexed terrace
#

accidental click on that emoji ;p

rare basin
#

that doesn't mean NumberSpawner cannot be MB

hexed terrace
#

doesn't mean it needs to be

rare basin
#

didin't say that

strong wren
#

It's also fine to use plain classes like this, but you need to make sure you set the MB stuff you use

hexed terrace
#

but will need to pass in a gameobject to NumberSpawner

static bay
#

Learning and messing arond is part of the process.

atomic star
#

yeah just fing around and finding out im not doing anything big

#

just trying to make smth where i click and a number spawns and goes to 100 and then gets destroyed

#

it did work before when i had a gameObject created inside the constructor but then i was like what if i make a gameObject in the class itself

#

but then i got errors n got confused

graceful citrus
#
    private void OnCollisionStay(Collision collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            transform.eulerAngles += (Vector3.up * timeSpent) * Time.deltaTime;
            timeSpent += Time.deltaTime;
        }
    }
    private void OnCollisionExit(Collision collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            timeSpent = 0;
        }
    }

will this code stay the same between refresh-rates

static bay
#

It's important to remember that variables are sort of just "boxes" for things. They need to be filled with the right thing if you want to do operations with them.

#

If they're empty, then their value is "null".

#

Which is why you get those "null reference" exceptions.

#

Or object reference exceptions.

static bay
#

And then tried to do things with an empty box.

halcyon summit
#

In code I'm changing the colour of a material for UI re-skin purposes (material.color = newColour;) and most UI elements are changing their colours accordingly - but some aren't. I've checked that they're using the Material, and also can see that the Material object in the Project window is updating to the new colour.. Is there something that forces a UI element to refresh its material?

north scroll
#

my addforce isnt working on my jump method, any ideas?

#

The debug log hits tho

rare basin
#

then it is working

#

assuming you dont have any errors in the console

hexed terrace
#

what value is jump force

north scroll
#

okk... then its not working how I want it to. The player is not moving up when I hit the button

#

100

#

the value is 100 currently

hexed terrace
#

also, moveVelocity will set your Y value to whatever that is, overriding your jump.. probably..

rare basin
#

thats what i wanted to say

north scroll
#

I see. I added that because the current Move function only applies once without adding that in the FixedUpdate. It only moves once when I press it, but when I hold it, it still only counts as a press and moves once

rare basin
#

debug your velocity of that rigidbody

#

in the inspector

north scroll
#

im not sure what u mean by "in the inspector". Do I add a debug.log after the addforce in jump with "rb.velocity" ?

rare basin
#

no, enable debug mode

#

in the inspector

#

you can see velocity in there

#

not sure if you even need debug mode

#

under nifo there is velocity

north scroll
#

this is the debug log i got when I added it to the jump method. In the rigidbody info inspector thing, the Y velocity changes quickly ( i cant see the value cuz its too fast) then drops back down to 0

atomic star
#

WHAT THE HEELL
wasn't private GameObject _gameObject; isn't _gameObject supposed to be an object of GameObject?? and isn't it supposed to be used after it has been defined in the class
gosh i feel so stupid this was the reason i wasted 4 hours

#

this gives no errors now

rare basin
#

why are you doing = new GameObject();

#

that will create a new, empty game object

#

is that what you want?

atomic star
#

nvm

#

my bad

#

so in an example class if I define "private GameObject _gameObject"
It will be an empty GameObject associated with that class

#

how come even renaming it give null exception

north kiln
#

It's a slot to hold a gameobject

#

if you have not put one there, it's null

atomic star
#

What makes it show up in hierarchy?

north kiln
#

Entirely unrelated

atomic star
#

oh

carmine sierra
#

is it fine to split up things which could be in one script into multiple if it helps read better, or should I use a script to it's fullest

north kiln
#

Something will appear in the Inspector as a slot if it's serializable

timber tide
#

split up

atomic star
carmine sierra
#

how can I get the component of a child while naming what child I want to get the component of

north scroll
#

so how would I change it to go up cuz this isnt working either

visual hedge
visual hedge
#

not saying it will work, it will at least compile 😄

north scroll
#

sry typo, still not working. it says velocity cant be changed cuz its not a variable

carmine sierra
carmine sierra
north scroll
#

but i mainly want to understand why this isnt working

#

which is what I had before

night mural
#

read the link vertx sent you

timber tide
north scroll
#

like I dont understand why addforce isnt making it jump when pressing the input i have

north kiln
carmine sierra
timber tide
#

well, GetComponent will be the way without a direct reference

north scroll
#

well I added that because the Move function only moved once when pressed, even if I held it. I had to repeatedly press it in order for the player to move

night mural
north kiln
#

you can use transform.Find, but why would you do that garbage when you can just serialize a reference

north scroll
#

but if that interferes with the jump, im not sure how to fix both

carmine sierra
#

mb im stupid

north kiln
#

Personally I wouldn't be writing a player controller from scratch without a tutorial unless you're familiar with how to interleave this stuff properly

#

there are so many tutorials, example controllers, etc, etc

north scroll
#

well i was trying to use this: https://www.youtube.com/watch?v=ZSP3bFaZm-o

In this video, I cover everything regarding Unity's New Input System. I walk you through how to actually implement this system as well. It is a bit longer of a video, but it is the most thorough out of all the videos I have seen as well. I started out not knowing how to even use it, to know only using this to control my game. Hope you all enjoy ...

▶ Play video
#

which went pretty in depth

carmine sierra
#

I have two sprites which rotate towards the mouses position, but how can I stretch it to the point where it reaches the mouse

#

the pivot isn't centralised

north scroll
#

but with the same code, it worked, but im assuming the creator didnt mention it only moved once. They didnt talk about fixed update or anything. I also have been searching a few tutorials but some of then get too confusing when I try implementing other mechanics I want for my game

#

so im trying to go slowly implementing each mechanic making sure I understand what is exactly happening

hexed terrace
#

You're just doing it wrong

north scroll
#

so yea, removing the continious resetting of the velocity in fixedUpdate allows me to jump, but without it, my move() doesnt work continiously. I would have to keep pressing it instead of just holding it

hexed terrace
#

The video ends with him being able to jump and move, and hasn't used any Updates

#

Re-do the video and watch closelierly to see what you missed/ did differently

north scroll
#

well I dont want to copy his exact script, im just trying to understand the new input system in its entirety. Ive watched it more than a few times, but now im stuck cuz from what Im understanding, this should work, but its not, im stuck, and thats why im asking here for help

hexed terrace
#

You don't understand it

atomic star
#
{

    public NumberSpawner()
    {
        Debug.Log("Called Constructor!");
    }
}```
```public class GameHandler : MonoBehaviour
{
    private NumberSpawner numberSpawner;
}

the debug.log isn't showing, the constructor isn't called?

hexed terrace
north scroll
#

i have to repeatedly press it, and he doesnt address this issue I have

hexed terrace
#

because there isn't an issue to work around

#

You've done something differently to him.

north scroll
# hexed terrace You've done something differently to him.

i know, and the difference is im trying to get the move() to work with holding as opposed to continiously pressing the input button. And I dont want that, I want to be able to just hold, where as his just does move() when pressing it

#

with this channel, I was able to fix that with adding something to the fixedUpdate(), but now my jump mechanic doesnt work

hexed terrace
#

I know what you want. You have implemented something different to him.. if you know what this difference is, go change to the same as him

#

Updates shouldn't really be used with the new input system, they're not needed

north scroll
#

well the fixedUpdate() change worked for me. And the unity docs mentioned fixedupdate should be used when working with physics based movement, which I am. If I shouldnt use updates, what should I use ?

hexed terrace
#

Show a screenshot of your entire player actions window... make sure to select one of the movement keys

hexed terrace
#

the 2d vector

timber tide
#

I do poll in update for some mouse stuff using the event system, but I think it's because there's some conflictions with the IDrag interfaces or something. I forget.

north scroll
hexed terrace
#

are A and D set to hold?

north scroll
#

basically the jump mechanic works if I dont use fixedUpdate() for movement (my fixedUpdate() continiously resets the velocity)

if I dont use fixedUpdate(), the move only works once per press, not holding the input key. (idk why addforce isnt working tbh)

If I can get one, I cant get the other. Ive tried multiple interactions (hold, press), but they are not doing it either

#

so I doubt its the inputActions, its the logic, but I cant see what it is

hexed terrace
#

then copy the tutorial and it'll become probably obvious ¯_(ツ)_/¯

north scroll
#

its not becoming obvious. Like I said, ive watched it multiple times, followed it exactly once and works just like his does, but his movement is not what I want atm. I started from scratch to just start at a ground level so I can get the mechanic I want, but this is what Im trying to fix now

night sparrow
#

I have created a Bullet system

Using RigidBody and a Sphere and set Bullet speed to 65

Any think I can improve this code

using UnityEngine;

public class Bullet : MonoBehaviour
{
    Rigidbody rb;
    [SerializeField] float bulletSpeed;

    private void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.velocity = transform.forward * bulletSpeed;
    }

    void OnCollisionEnter(Collision collision)
    {
        Destroy(gameObject);
        if (collision != null && collision.gameObject != null)
        {

            if (collision.gameObject.CompareTag("Enemy"))
            {
                Debug.Log("Enemy!");
                Rigidbody enemyRigidbody = collision.rigidbody;
                if (enemyRigidbody != null)
                {
                    enemyRigidbody.AddForce(transform.forward * 500);
                }
            }
        }

    }
}```
hexed terrace
#

A skybox material is added to the light settings for the scene

#

also, what's the code question here?

round musk
#

So ,I should add the skybox component in directional light rather than on camera?

carmine sierra
#

Band_L.localScale.z = lengthToBand_L;

What could be wrong? Band_L is a transform and lengthToBand_L is a float which takes a magnitude

hexed terrace
languid spire
tender mirage
#

Help. i cannot run my game.

north kiln
eternal falconBOT
north kiln
#

then fix the underlined errors

tender mirage
north kiln
#

If your IDE is configured the errors will be underlined in red

#

and you will have proper code autocomplete

tender mirage
shell sorrel
#

read the guide posted above

north kiln
#

There are many more steps than just "update"

shell sorrel
#

its not just about the version but how its configured

noble summit
#

i keep getting spammed [Collab] Collab service is deprecated and has been replaced with PlasticSCM how do i stop this

noble summit
#

ok

#

how do i turn it off

north kiln
#

Follow the link and read what I posted

noble summit
#

ok i fixed it

toxic frigate
#

so im trynna make a game where when the player destroys an obstacle, they're supposed to get the buff corresponding to it (the buff will be displayed on the obstacle)
How do I go about implementing this considering I have spawner(s) in place which constantly generate obstacles at random time instances (like how do I have each obstacle generated assigned a buff to it and how do I randomise say multiple buffs for each obstacle spawned)

thorn holly
atomic star
#

if PlayerScript playerscript;
then why do we have to playerscript = GetComponent<PlayerScript>(); as well when playerscript is already PlayerScript?

north kiln
#

Defining a reference doesn't magically assign it. Which PlayerScript would it refer to if it did? Would it just guess?

shell sorrel
tender mirage
shell sorrel
#

!ide

eternal falconBOT
thorn holly
shell sorrel
thorn holly
#

Follow the steps for whatever code editor you’re setting up

rare basin
#

he was instructed to configure his IDE yesterday

#

aswell

tender mirage
#

is the configuration fixed now?

#

I'm guessing these are just the errors

rare basin
#

then you are showing unity console screenshot

stone lance
#

Can you show a screenshot of Visual Studio

tender mirage
north kiln
#

Hooray

#

Now finish writing your incomplete script

thorn holly
#

Nice job, seems configured to me

tender mirage
#

A babies first step indeed.

thorn holly
#

Something I’ve been wondering about c# is why functions aren’t auto declared async. I mean, they’re the same thing up until you say await, so…

rare basin
#

very incorrect

thorn holly
#

Aren’t async functions synchronous until you write await?

north kiln
#

Remove the word async and compare the two lowered pieces of code

shell sorrel
#

even if it was the same code, i like that it enforces in the signature if its aloud to await or not

#

and makes it hard for someone to accidnelty add one to a function that is not called in a way where that would be a good idea

#

but also the generated il is totally different

north kiln
#

It would definitely have mixed messages in a codebase, with usage being very unclear

toxic frigate
tender mirage
#

Hmmm still seems to not like being ran.

shell sorrel
#

did you add it to a object

hexed terrace
#

did you save it

tender mirage
#

yup

#

save i sure did

cosmic dagger
#

is the GameObject active?

shell sorrel
#

and assign the rigidbdy to it

thorn holly
#

Did you assign the rigidbody?

cosmic dagger
#

does it have a Rigidbody?

tender mirage
#

oh the heck. my object was deleted

#

thank you.

thorn holly
tender mirage
atomic star
#

What are use cases for "internal" ?

thorn holly
buoyant knot
stone lance
thorn holly
toxic frigate
# tender mirage

you prolly need to drag your birdie in unity into the empty field of rigidbody iirc

stone lance
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

tender mirage
#

That's what i'm doing

shell sorrel
buoyant knot
#

and it is pointless to describe the use cases until you know how assemblies work

thorn holly
shell sorrel
#

like i have a npc behaviour editor i made, as its own assembly that uses it heavily, so it does not need to expose implementation details to the user of it

toxic frigate
# tender mirage That's what i'm doing

Also I think you're getting this from Game Maker's Toolkit's flappy bird tutorial so I'd say try going through each thing slowly coz he kinda really zooms through stuff (it was where I started too just see each thing thoroughly)
As for the error its prolly jus the drag n drop thing i mentioned within the Unity console

buoyant knot
#

imagine you have a package, that is one assembly. Internal lets all scripts in the package use it as though it is public, but blocks anything from outside the package from using it

tender mirage
toxic frigate
buoyant knot
toxic frigate
#

ye

buoyant knot
#

scriptable objects are a type of class where the instance is written into a file

#

you can make .asset files for that scriptable object; and it functions as an instance that you can reference

shell sorrel
#

its like a way to make your own custom asset file types

buoyant knot
#

the main use case is for immutable data. Like if you have a class to hold parameters for guns/enemies/characters, that should be an SO (scriptable object)

toxic frigate
#

i see

buoyant knot
#

SOs behave weirdly with instantiation. so 2 rules of thumb:

  1. Avoid instantiating SOs during runtime. You want to use CreateAssetMenu in editor.
  2. Avoid modifying the values in an SO at runtime.
buoyant knot
hexed terrace
#

What weird behaviour do SO's have with instantiation?

toxic frigate
#

ite I'll try reading into SOs beforehand so i dont mess up my stuff and decide whether to do it safe or go with this

buoyant knot
#

almost all fields in my SOs are defined like this:
[field:SerializeField] public int myValue {get; private set;}

noble summit
#

what does SO mean

shell sorrel
buoyant knot
cosmic dagger
shell sorrel
#

also you need to explicitly call destroy like its a GO

noble summit
buoyant knot
#

no

cosmic dagger
buoyant knot
#

ScriptableObject is a class

rare basin
buoyant knot
shell sorrel
cosmic dagger
buoyant knot
#

and in build, every time you open the application, SOs are effectively reset to whatever was there when the application was built

#

this is very different from editor mode, where modifying an SO in play mode of editor can permanently write to SOs

tender mirage
#

i did it YESS

buoyant knot
#

this is why you should avoid modifying SOs at runtime

#

right now, all my SOs have all properties/fields with only private setters. NO public setters

#

i made that mistake once of having a public field in an SO, and I paid for it dearly

shell sorrel
noble summit
#

how do i make fishnet work with different devices, it is only working for windows on my computer

timber tide
#

They have a discord

graceful citrus
#
GetComponent<Rigidbody>().AddTorque(GetComponent<Rigidbody>().angularVelocity * 5, ForceMode.Force);

im trying to make the rotation force of a rigidbody exponentially increase. i tried using this, but it does nothing. what do i do?

verbal dome
shell sorrel
#

also please cache the Rigidbody to a field

#

both for code readablity and not having multiple get components per frame go off

cosmic dagger
shell sorrel
#

all of this GetComponent<Rigidbody>().AddTorque(GetComponent<Rigidbody>().angularVelocity * 5, ForceMode.Force);
could just be
_rb.AddTorque(_rb.angularVelocity * 5, ForceMode.Force);

#

but yeah like mentioned if starting for still, 0 * 5 is still zero

cosmic dagger
#

you can even remove the ForceMode since Force is the default . . .

rare basin
buoyant knot
#

it’s his thing

rare basin
#

alr

buoyant knot
#

unless I make it mine…

rare basin
#

you made it wrong . . .

cosmic dagger
#

well at first it was "...", but then i received ". . ." for leveling up. i'm not sure if they're is anything afterwards. depends if i can keep climbing the ladder . . .

polar acorn
hexed terrace
cosmic dagger
cosmic dagger
timber tide
#

the real deal is adding your signature after every discord message

  • mao
cosmic dagger
#

i like it . . .

graceful citrus
verbal dome
#

What is making it spin?

graceful citrus
#

jumping into it

#

its a roundabouut

verbal dome
#

Have you confirmed that the code is running? Because it should go crazy pretty fast

#

Check your rigidbody's angularDrag too

#

It will slow down rotation

graceful citrus
#

but its not, going crazy fast

verbal dome
#

angular drag, not angular velocity

graceful citrus
#

oh angular drag

graceful citrus
#

i set it to 0

verbal dome
#

Idk then, maybe some other code is modifying its rotation or angular velocity

graceful citrus
verbal dome
#

Most likely

graceful citrus
#

the point is its a roundabout on a playground, that should go stupidly fast

#

the code is running, i checked with a debug.log

verbal dome
#

Show the settings for the hinge joint?

graceful citrus
verbal dome
# graceful citrus

That looks ok. I think the angular velocity just gets way too large and the physics system limits it

#

Or it's just spinning so insanely fast that it looks like it's spinning slow

#

I just tested with code similiar to yours and it reaches maximum (0, 150, 0) angular velocity

#

It looks like it is spinning slow but it really isn't

final kestrel
#

The sources I am following say using strings in any means is bad practice because it wont throw an error. How do I check the tags if im not to use strings for example. other.tag == "Player". Whats the better version of this?

languid spire
#

CompareTag()

buoyant knot
#

CompareTag is better, but doesn’t actually fix the core issue where the argument is a string

final kestrel
#

compare tag is asking for string no?

buoyant knot
#

The package I linked autogenerates static classes with public const strings that you can use to compare string and layer names

final kestrel
#

Ah okay I'll check it out thanks.

buoyant knot
#

so instead of gameObject.CompareTag(“Player”);
it would be
gameObject.CompareTag(Tags.PLAYER);

languid spire
final kestrel
#

Ahh makes sense. Thanks for the answers.

buoyant knot
#

== and CompareTag become equivalent with the Tags class because the Tags class cannot contain constants that are invalid tags

final kestrel
buoyant knot
#

Tags only exists with that package

final kestrel
#

wait nevermind its my fault.

#

aahh

buoyant knot
#

the package contains a source generator to automatically create a file for a class called Tags

#

and same for Layers

verbal dome
final kestrel
#

It isnt bad or anything if i get used to using it right?

scarlet skiff
#

anyone knows why reloading scripts takes such a long time? didnt use to be that way for me but now 1:30 to 2:00 is what it takes and thats just wild

buoyant knot
final kestrel
#

yes

buoyant knot
#

the worst you’d do is update the Tags class yourself

#

in a scenario where you have been using it, and then the package gets nuked

final kestrel
#

Okay thanks all for your time. Also, Happy valentines day!!

buoyant knot
#

which only requires small effort when new Tags/Layers are defined

noble summit
#

how do you run commands in the console

shell sorrel
#

what unity calls the console is really just a log viewer

noble summit
#

in the tutorial im watching he has this console menu thing in the game view

shell sorrel
#

would have to see it to know what, but chances are that is something added

noble summit
#

❤ Watch my FREE Complete Multiplayer Course https://www.youtube.com/watch?v=7glCsF9fv3s
✅ Learn more about Relay and UGS https://on.unity.com/3tQZLLW
📝 Relay Docs https://on.unity.com/3OjXL8z
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
👇 Click on Show More
🎮 Ge...

▶ Play video
#

also doesnt show how to get the ui

graceful citrus
#

i tried using a motor to set the speed to be super high and it worked, so it isn't reaching a limit

verbal dome
#

I didn't say it was spinning slowly

graceful citrus
#

its definitively very slow

#

different issue. this is a script to return a vector3 (ying). if it doesn't hit anything, it will just set ying to the end of the raycast, but if it does it should set to the point it hits.

        if (Physics.Raycast(pivotTran.position, pivotTran.position + pivotTran.TransformDirection(0, 0, -1), out hit, 8, layerMask))
        {
            ying = hit.point;
        }
        else
        {
            ying = pivotTran.position + pivotTran.TransformDirection(0, 0, -8);
        }

it only seems to set ying to the end of the raycast, regardless of whether or not it hits. im unsure what to do

wintry quarry
wind raptor
#

Is it possible to pass a normal array as an argument so that the receiving function can only read the array elements? Like is there some keyword I can prefix it with so that the array is readonly in that given context, but not others?

wintry quarry
#

btw pivotTran.TransformDirection(0, 0, -1) is excessive - you can just use -pivotTrans.forward)

wintry quarry
#

Or IEnumerable

#

it depends if you need random access or just iteration

graceful citrus
#

adding debug.logs for some reason, fixed it?

graceful citrus
swift crag
#

I've seen that happen a few times. This usually means that...

  • you hadn't recompiled
  • you have something random / execution-order dependent
#

or, option 3:

#
  • your debug statement changed the meaning of the rest of the code
wind raptor
#

Sorry, I had it slightly wrong. It wouldn't be passed as a parameter. But maybe it doesn't matter.

private byte[] buffer = new byte[4]; // should be modifiable elsewhere
public byte[] getBuffer() // whoever calls this should not be able to modify any elements
{
    return buffer;
}
toxic frigate
# buoyant knot the main use case is for immutable data. Like if you have a class to hold parame...

ok so to put it into some context (might not be absolutely right but just the idea i got from reading this and online)
SOs are basically a separate abstract class that basically hold all the base values/parameters (like in my case the player stats, obstacle hitpoints and stats, projectile stats etc should all be an SO)
These values are not to be messed with directly during runtime within the SO, however I should be able to call em someplace else and edit/add onto them (say buffs/debuffs) in that specific called instance and after runtime is over, the base stats are remain unchanged/reset as a separate and safe entity

(Please correct if im not wrong just trynna make some basic layman context/sense here)

wintry quarry
graceful citrus
wintry quarry
graceful citrus
#

because i've saved and reloaded many times

#

i've had this issue for about a week and i only realised now i should change it

graceful citrus
#

now i just need to figure out why this:

rb.AddTorque(rb.angularVelocity, ForceMode.Force);

isn't doing anything

wintry quarry
#

why are you using angularVelocity as a parameter to AddTorque?

#

Also if the angular velocity is currently 0 then there will be 0 torque

#

this is similar to rb.AddForce(rb.velocity) which also doesn't make sense

graceful citrus
#

because its moving

#

@wintry quarry its spinning

#

but i want it to spin even more

toxic frigate
graceful citrus
#

exponentially so

wintry quarry
#

or in FixedUpdate for example

graceful citrus
#

oncollisionstay

wintry quarry
#

then it should work

graceful citrus
#

and i have debugged it, so i know its being fired

#

it debug.logs

wintry quarry
#

but depending on the moment of inertia

graceful citrus
#

but its not really speeding up at all

wintry quarry
#

that might be very small torque

graceful citrus
#

well it is moving

wintry quarry
#

log the angular velocity each frame

graceful citrus
#

i know because im slamming the player into it

wintry quarry
#

also your angular drag might be overwhelming the tiny torque

wintry quarry
#

then log it each time

#

see if it's changing

#

with and without the torque

buoyant knot
#

it’s worth mentioning that constant torque means velocity changes linearly

graceful citrus
#

all i want is for the thing to speed up its spinning when the player touches it

buoyant knot
#

if torque is proportional to angular velocity, then angular velocity will change quadratically, which is probably not what you want

autumn tusk
#

how do i inherit a collider from its parent for a child script

buoyant knot
autumn tusk
#

basically

buoyant knot
#

you can’t inherit colliders

autumn tusk
wintry quarry
autumn tusk
#

basically a locked door system

#

if you touch the object and you have a key to unlock it, it destroys the instance

buoyant knot
#

what does any of this have to do with inheritting colliders

autumn tusk
#

i thought i could put all the scripting in the form of a child object

#

basically i slot the child into an already existing object

wintry quarry
#

generally interactions between objects works best with scripts on the root objects of interacting entities

#

putting scripts on child objects tends to add complication when they need to interact with the rest of the world

buoyant knot
#

if the child object is just an extension of the parent, to help organize hitboxes etc, then you probably do not want a script

#

but if the child collider has the same layer collision properties, and unique logic for just itself that let it be managed like a truly separate thing, then it should have a script

#

eg my players and enemies all have a little trigger hitbox inside them to know if they are being squished by solids. This hitbox usually has its own script, as the behaviour is generic, regardless of what it is on

toxic frigate
#

[CreateAssetMenu(fileName = "HP", menuName = "ScriptableObjects/SpawnManagerScriptableObject", order = 1)]
public class SpawnManagerScriptableObject : ScriptableObject
{

    public float hp;
    public float maxhp;
    public float minhp;

}```
@buoyant knot this is basically how to make a SO for hitpoints right? (sorry for excessive pings just wanna get this over with)
Now I can just call this SO elsewhere whenever I need the HP values (say under Player and/or Obstacles)
wintry quarry
#

For a locked door I would tend to have a setup like this:

Door - (Door script, Rigidbody)
  - Door visuals (Collider, Renderer)

in the OnCollisionEnter I'd basically do collision.collider.GetComponentInParent<Door>() then interact with the Door if it exists

cosmic dagger
wintry quarry
#

either that or make it not serialized

#

if you want to go with the "atoms" pattern

buoyant knot
toxic frigate
#

i see

buoyant knot
#

imagine a single .asset file being like the definition of the parameters that make up a Pikachu

#

and a different .asset for Shellder

#

the values in the .asset should NOT change during runtime

cosmic dagger
#

i see a lot of people use config and data for SO naming, like: EntityConfig, EntityData . . .

buoyant knot
#

I call one EntityData, because that is an SO that is very generic, on anything that is an actor in the game

#

i also have separate EnemyMovementData, to store parameters specific to enemy movement

toxic frigate
#

No errors in making the SO so far, gonna try implementing this into the game and will be back if any other error

buoyant knot
#

because not every entity has movement behaviour

#

just remember:
[field:SerializeField] public int maxHp {get; private set; }

#

very important pattern for SOs

#

it lets you save data, publicly read it, and block things from trying to modify it

mild osprey
#

Why am I being yelled at? Trying to make my propeller spin

verbal dome
eternal falconBOT
cosmic dagger
eternal falconBOT
rich adder
swift crag
#

syntax errors, you mean

#

the compiler doesn't care if your code is horrifically formatted, but it does care if what you wrote isn't valid C# at all

#
int x =                     3; // bad formatting
int x = ; // bad syntax
#

syntax errors will be highlighted by your IDE, assuming that it is set up correctly

mild osprey
mild osprey
#

Or maybe I understand and have forgotten

verbal dome
#

Nothing to do with formatting

swift crag
cosmic dagger
swift crag
#

thus the compiler yells at me

verbal dome
cosmic dagger
swift crag
#

no, I would not call a syntax error a "formatting error"

rich adder
#

not formatted for PC xD
jk ofc

cosmic dagger
#

yeah, i joke. it was wrong . . .

mild osprey
#

And the external tools keep changing back to default rather than staying on VS

cosmic dagger
mild osprey
cosmic dagger
mild osprey
carmine sierra
#

!code

eternal falconBOT
rich adder
mild osprey
carmine sierra
#

how could I start to go about creating two separate sprites which scale to the mouse. My current code is this . I just need a pointer since im pretty lost with my current knowledge:

public class StretchToMouse : MonoBehaviour
{
    Vector3 mouseWorldPosition;
    [SerializeField] Camera firingCamera;
    [SerializeField] WeaponFire weaponFire;
    [SerializeField]Transform Band_L;
    [SerializeField]Transform Band_R;
    Vector2 lPos;
    Vector2 rPos;
    float maxLength;

    void Start()
    {
        maxLength = weaponFire.maxLength;
    }
    Vector3 GetMousePos()
    {
        mouseWorldPosition = firingCamera.ScreenToWorldPoint(Input.mousePosition);
        mouseWorldPosition.z = 0f;
        return mouseWorldPosition;
    }

    // Update is called once per frame
    void Update()
    {
        GetMousePos();
        Vector2 Ldirection = new Vector2(mouseWorldPosition.x = Band_L.position.x, mouseWorldPosition.y - Band_L.position.y);
        Vector2 Rdirection = new Vector2(mouseWorldPosition.x = Band_R.position.x, mouseWorldPosition.y - Band_R.position.y);
        Band_L.up = Ldirection;
        Band_R.up = Rdirection;
        lPos = Band_L.transform.position;
        rPos = Band_R.transform.position;
        float lengthtoBand_L = mouseWorldPosition.magnitude - lPos.magnitude;
        float lengthtoBand_R = mouseWorldPosition.magnitude - rPos.magnitude;
        float diffbetweenBands = lengthtoBand_R - lengthtoBand_L;
        if (lengthtoBand_L <= maxLength)
        {
            Band_L.localScale.z = lengthToBand_L;
        }  
    }
}

cosmic dagger
mild osprey
toxic frigate
#

help, its not letting me drag the hitpoints script (the script I made into a SO) into the ES slot (an instance I made for SpawnManagerScriptableObject)

cosmic dagger
mild osprey
mild osprey
verbal dome
cosmic dagger
mild osprey
cosmic dagger
cosmic dagger
mild osprey
mild osprey
rich adder
#

you lack fundamentals

mild osprey
rich adder
#

dont get so defensive

mild osprey
#

Junior programmer.

mild osprey
rich adder
#

knowing the correct syntax is part of coding

cosmic dagger
mild osprey
swift crag
#

so which editor are you currently using?

rich adder
rich adder
#

bro what

swift crag
#

lay off

cosmic dagger
mild osprey
rich adder
swift crag
#

it also covers the basics of programming.

#

you're new, so you're not familiar with how to ask questions

#

that's fine.

mild osprey
#

Didn't have any problems up until coding a spinning propeller. Managed to fix all the errors that the plane challenge threw at me

cosmic dagger
swift crag
#

Visual Studio, not Visual Studio Code, correct?

#

great naming convention, I know

cosmic dagger
#

facts . . .

noble summit
#

vscode solos

summer stump
swift crag
#

the icons do not help at all

hexed terrace
#

blue is VSC, purple is VS

swift crag
#

oh god they have different colors?

#

i'm red-green colorblind

rich adder
#

rip