#💻┃code-beginner

1 messages · Page 677 of 1

rich adder
#

do you see this Image itemPreviewImage = itemPreview.GetComponent<Image>();

copper jasper
#

ye

rich adder
#

you are not using the Image from UnityEngine.UI

#

which is what you want

#

delete these

using JetBrains.Rider.Unity.Editor;
using Microsoft.Unity.VisualStudio.Editor;```
#

then put using UnityEngine.UI

copper jasper
#

OH

#

😭

#

Spent all that time for what

#

Well now I gotta get images from the Project folder thing

#

then set them to be the source texture

rich adder
#

put a field for it

#

no need to search the project folder

#

set it in the inspector / drag n drop

copper jasper
#

but then i gotta do that for each item

#

hotbar system

#

like these

#

great now itemPreviewImage.SourceTexture = itemImage;

Source texture has a red line

rich adder
#

where are you getting SourceTexture from

copper jasper
#

the image from earlier

#

u know the one that i couldnt disable

#

i can disable it now but thats all

rich adder
#

sounds made up

copper jasper
sage abyss
#

Hey, guys. I want to rotate a gameobject depending on its velocity (in my case pointer delta), but it's really jaggy. Is there something I do wrong?

twin pivot
#

!code btdubs

eternal falconBOT
rich adder
copper jasper
#

i hope

#

do u think its gonna work

Sprite itemImage = (Sprite)Resources.Load("Assets/UI/Hotbar/itemPreviews/" + item.name + ".png");

#

I hope so

rich adder
copper jasper
#

UnityException: Load is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'InventoryHandler'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ResourcesAPIInternal.Load (System.String path, System.Type systemTypeInstance) (at <0022d4fb3cd44d45a62e51c39f257e7c>:0)
UnityEngine.ResourcesAPI.Load (System.String path, System.Type systemTypeInstance) (at <0022d4fb3cd44d45a62e51c39f257e7c>:0)
UnityEngine.Resources.Load (System.String path, System.Type systemTypeInstance) (at <0022d4fb3cd44d45a62e51c39f257e7c>:0)
UnityEngine.Resources.Load (System.String path) (at <0022d4fb3cd44d45a62e51c39f257e7c>:0)
InventoryHandler..ctor () (at Assets/Scripts/ItemSystem/HotbarHandler.cs:12)

😭

rich adder
#

also just make fields..

rich adder
copper jasper
#

im so lost

rich adder
#

but again you should not do it this way at all

rich adder
#

did you read the docs how Resources.Load works ?

twin pivot
copper jasper
rich adder
copper jasper
#

well i thought it would have been pretty straight forward

#

just a simple load

rich adder
#

it is when you read the docs on how it works.

copper jasper
#

😭

rich adder
#

I mean..it even has examples.. you're doing yourself a disservice

west garnet
#

i dont know if this is the best way to do something but
im making a rpg game for fun and i got different npc with different tasks that they give u so u can get a key ( they all have different scripts )
in each task i thought the best way to make the final gate to open was to comapre if the player had all the bool active
my plan is to make some text on the screen saying something around "you got "amount" of keys" ( aka the bool that i have ) how could i do it?

rich adder
#

a bool per key sounds like a mess

west garnet
rich adder
west garnet
#

that actually sounds better

rich adder
west garnet
#

randomly

rich adder
#

so if its just needs to be 3 keys and you dont care which one i which, and you just need the amount collected, then use a list ye

west garnet
rich adder
#

You could if you want, thats up to you

west garnet
twin pivot
west garnet
#

it does sound better

#

and less complicated

#

but thank you!

rich adder
twin pivot
rich adder
#

wdym extend to array

#

arrays don't extend they are fixed in size, hence the .Length instead of .Count

twin pivot
#

yea but you can extend it in unity

rich adder
#

yeah but you're bound by the inspector to do that, and all is doing is myArray = new bool[newSize]

#

you still need to loop through all of them anyway to check if they are all true

twin pivot
#

🤷 personal preference ig

rich adder
#

kinda lol

untold shore
#

Hey, any input onto this? Thanks UnityChanwow

twin pivot
#

theres a setting in rigid body to enable gravity + theres no code that rotates the GameObject

untold shore
twin pivot
untold shore
#

Currently in tutorial hell, so tutorials on YouTube 😅 never worked on 3d unity before, I’m used to 2d

twin pivot
#

unity has some tutorials to !learn from + u should start with 2d

eternal falconBOT
#

:teacher: Unity Learn ↗

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

untold shore
#

Gotcha! Thank you so much. Will spend some time on there UnityChanThumbsUp

grizzled crag
twin pivot
#

still kinda tutorial hell

grizzled crag
#

well, if you're looking to get out of tutorial hell, I think it's best to have this sort of "end"

#

since it is a pretty comprehensive guide, you shouldn't have to look for any more tutorials, and rely on the documentation from there forward

rich adder
grizzled crag
#

rather than tutorials

rich adder
#

was about say...thats how you get out of tutorial hell when you can interpret the documentation and nothing else

twin pivot
#

the unity documentation is as important as energy drinks for me

grizzled crag
past yarrow
#

Is there a way to write my if statement this way instead of the inverted version of it but without returning anything as here my return statement at the end of my method, it should be a List<Tile but in this if statement I just want to get outside of that if statement to not execute neighbours.Add(tiles....);

So return doesn't work, continue doesn't work, so I'm kinda loosing hope on using a safe guard statement in this case and have to go with the inverted if statement 😬

brave robin
#

if break, continue, or return isn't working for what you need, you can also try goto as a last resort

rocky canyon
#

goto: back to classic

past yarrow
#

Is it what would be practiced in "pro" environement ? Or will "proes" go with the inverted if ?

#

pro env / good practice

brave robin
#

goto is generally avoided by pros, but sometimes the cleanest flow is to jump over everything else and go to the end
And sometimes encasing everything in a bunch of IF cases to do that is uglier than just using a single goto

past yarrow
#

alright, could you gie an example of how a goto works because I never used one please

rocky canyon
#

what im reading is use it if: whenever it's the cleanest and most maintainable way to write something, which is uncommon

brave robin
rocky canyon
#

im slow

brave robin
#

I generally will only use a goto when the destination code is near the end of the method, and I'm using it to jump past something in the fastest and cleanest way
I would never use it to jump backwards, that way lies madness

rocky canyon
#

i see it mentioned alot about "error handling"

brave robin
#

... cast it into the volcano before it is too late

eternal needle
#

you really just shouldnt be using it

rocky canyon
#

ive never seen it in the wild

brave robin
#

I've used it exactly once in my current project. The circumstances where its more readable do exist, its just pretty rare

past yarrow
eternal needle
#

then swap around your logic. why not just check if the value is 0 before any of this?

rocky canyon
#

^ very true..

brave robin
#

Or && the != 0 into the initial IF statement

past yarrow
brave robin
#

But yeah, I think starting off with != 0 is better

eternal needle
#

then yea include it in the first if statement where you want it

#

and make a method so you arent writing the exact same logic 10 times

brave robin
#

also, I think a lot of those IFs should be ELSE IFs

past yarrow
eternal needle
#

making a method for this would just avoid rewriting the same code over and over, but its not required if thats the entire logic

rocky canyon
#

^ i was also going to mention that too but wasnt sure if it was appropriate

#

all those if statements make me think a switch might work well too

eternal needle
#

also youve most definitely been told about the code command before

brave robin
eternal needle
past yarrow
#

!code

eternal falconBOT
eternal needle
#

Btw you can check if the value is 0 before checking its in the grid. It's a micro optimization but that means it wont check the grid everytime if it doesn't have to

past yarrow
past yarrow
eternal needle
#

Right now it'll check if its in the grid everytime, then check if the value is 0 if it was in the grid.
If you check if the value is 0 first, it has a chance to exit that if statement early without checking if its in the grid

past yarrow
#

Oh I see

eternal needle
#

I have no clue why but that site also keeps deleting all the code as I try to scroll on mobile lol. Hopefully it was clear though

past yarrow
#

Like this ? 🙂

eternal needle
#

Yea

brave robin
#

Also, is it possible for multiple IF statements to be true? If not, then you should be using ELSE IF for the extras

eternal needle
#

Its a micro optimization but it could matter in the future if one condition is an expensive operation

past yarrow
#

Argh my code doesn't work, it should reveal those corners as they're non zeros but it doesn't 😬

#

Yellow = Where I pressed
Red = What it revealed

#

It should be like this (with the corners)

brave robin
#

Actually, a cleaner way to do this is to encase it in two FOR loops, one for x and one for y, and then do the IsInGrid check on the x and y coordinates you get from the loops

brave robin
#

x and y going from -1 to 1, and adding that to the coordinate you clicked on to get all possible 9 positions

#

and a check for when both are 0, in case you don't want to do anything when its the exact tile you clicked on

past yarrow
#

I want when I click on a tile with "0" to make it propagate to adjacent tiles but not on diagonales that are 0 and the edges of those 0 that are != 0 but not -1 and the diagonal should work too (I hope it makes sense 😄 )

brave robin
#

nested for loops can achieve that, it removes the need to specify every possible coordinate, and you can put the logic inside for whether to place a tile or not

past yarrow
#

like i < ?

rocky canyon
#

ur grid dimensions right?

past yarrow
#

true

brave robin
#

i = -1; i =< 1; i++
same for j
Since you're adding these to the x and y of the coordinate to get the adjacent ones

past yarrow
#

Oh

brave robin
#

its why I'd call them x and y and not i and j, makes it more clear

rocky canyon
#

ah ya, i was thinkin of the actual grid generation

#

btw, what u making? minesweeper?

past yarrow
past yarrow
#

I think I will go to sleep guys, I'm tired 😄 I hope you're here tomorrow 😛

rocky canyon
#

i tried that once. i got the grid and selection stuff coded out
but i couldn't do the math for filling in the numbers

past yarrow
#

Good night 👋

sour fulcrum
# past yarrow This is the code of generation

Nothing wrong with this but sometimes can be nice to move this logic into it’s own function since it’s kind of it’s owned isolated job. Eg

SpawnNewTile(Tile tilePrefab, Vector2Int index)

Also just another 2 cents that you can take or leave but imo that code is slightly more readable if you do the tile coords and color setting on the tile reference directly thats right there and not via the matrix index reference. (The fact the reference is right there and your not referencing that makes my brain assume the matrix must be pointing to something different)

Final random suggestion that’s more for longterm is having the matrix assignment + coords assignment as a seperate function, so in the future if you ever wanna modify a tile’s position you can use the same central function

random sand
#

any way to only get the rotation values of an animation without a humanoid?

#

also what's the best way to change walking animation up slopes

versed cove
ionic tartan
#

Hello everyonem i'm beginner and i have put some light on my scene and it's look like that, why i have random illumination and it's stop instant idk why ?

keen dew
ionic tartan
keen dew
#

Great, then wait for an answer there

near thicket
#

$code

#

!code

eternal falconBOT
spiral narwhal
#

Can the async scene load create memory leaks like default events? If you don't -= after += I mean.

So compare this:

            var asyncLoad = SceneManager.LoadSceneAsync(deserialisedModel.CurrentSceneName);

            asyncLoad.completed += _ =>
            {
                _gameStateServices.ForEach(service => service.ReadStateFromModel(deserialisedModel));
                asyncLoad.completed -= handler;
            };;

to the clunky unsubscription:

            var asyncLoad = SceneManager.LoadSceneAsync(deserialisedModel.CurrentSceneName);
            Action<AsyncOperation> handler = null;
            handler = _ =>
            {
                _gameStateServices.ForEach(service => service.ReadStateFromModel(deserialisedModel));
                asyncLoad.completed -= handler;
            };
            asyncLoad.completed += handler;
wintry quarry
#

You don't need to unsubscribe unless you're keeping a long running reference to the operation around.

#

Wdym by "vertically across my entire screen"?

topaz mortar
#

thx though

topaz mortar
#

How do I get my healthbars to show up like in League of Legends? They're so stable, don't jitter or move as camera is moving and perfectly follow the units.
I tried it like this healthbar.transform.position = _cam.WorldToScreenPoint(worldPos);
But it keeps moving as I move my camera, it dances left/right up/down a bit.

naive pawn
#

for healthbars like that they'd probably be world-space canvases

#

anyways the issue you're seeing is probably due to stuff being out of order - likely this positioning happening before the camera is positioned

topaz mortar
#

I tried world-space first but that was even worse, since the camera position constantly changes the angle

naive pawn
#

within each frame, the world stuff has to move first, then the camera (if it moves independantly), then stuff that relies on the camera view (like parallax or UI)

but with a world-space canvas you can just sidestep the entire "position is reliant on camera position"

topaz mortar
#

it's better in screen space, but it dances a bit as the camera moves

naive pawn
topaz mortar
topaz mortar
#

lol it has sound from the lol stream I'm watching 😅

naive pawn
#

(there might be a better more built-in solution for this, i'm not a ui guy 😅)

topaz mortar
naive pawn
#

yeah that's just.. not something you can determine?

#

don't trust chatgpt for anything lmao

#

it's gonna tell you everything with confidence whether it's right or not

topaz mortar
#

quick google gives the same result though

naive pawn
#

well i suppose it technically isn't wrong, this one is definitely in screen space lol

naive pawn
#

if not it's probably a guess

#

you could achieve identical results with world space and screen space UI
in fact these terms might not even apply since league uses its own engine

topaz mortar
#

can't find a single tutorial on this stuff that actually works

naive pawn
#

are you trying to fix the original issue or do billboarding or what exactly?

candid garden
#

for persistent data through scenes, for things like the player's party data and unlocks for example, would a persistent scene or don't destroy on load be more ideal and easier to work with as the game grows?

topaz mortar
#

I'm trying to do billboarding now
transform.LookAt(_camTransform.position); is the result in the video
also tried transform.LookAt(_camTransform.position + transform.position); with both + and -, neither work properly

ivory bobcat
#

What's the issue?

#

Can you describe what's expected and what's happening instead?

topaz mortar
#

I'm trying to add healthbars that stay perfectly above their unit, regardless of camera position & angle
Similar to how league of legends does it

sour fulcrum
sour fulcrum
#

rather than the ui being in worldspace directly

topaz mortar
naive pawn
topaz mortar
#

alright let me start over again 😅

naive pawn
topaz mortar
#

This is what I have now: (Quantum, so different update function)

{
    Vector3 offset = new Vector3(0, 3f, 0);
    Vector3 worldPos = transform.position + offset;
    Vector3 screenPos = _cam.WorldToScreenPoint(worldPos);

    healthbar.transform.position = screenPos;
}```
naive pawn
#

well is the camera positioning also in OnLateUpdateView

topaz mortar
#

it's cinemachine

naive pawn
#

imma be honest i'm not noticing weird positioning

topaz mortar
#

it jumps a little, as I press any direction, for example up, it shoots up a short distance, then goes back down a little
it's hard to notice but something is off

queen adder
naive pawn
topaz mortar
#

I think going with world space would prevent the zoom issue too, so might be better

topaz mortar
naive pawn
#

no you'd have to project the position onto the plane of the screen and then look at that

naive pawn
naive pawn
#

i guess the other thing would be WorldToScreenSpace then ScreenToWorldSpace lol

cosmic charm
#

is copying projects a good practice to learn how to make a video game?

topaz mortar
#

well, depends on how you do it

lilac kelp
#

Yeah its a one of many way to learn the basic but you need to do a lot of those or make your own game and learn as you make the game that way you will learn fast also enjoying the journey

topaz mortar
#

and if I remoe the y freeze, it doesn't update position based on the camera anymore, it kinda just statically floats there not looking like it's above the unit

sour fulcrum
topaz mortar
sour fulcrum
#

Tbh i’m not interested in hearing it from someone actively using chatgpt, respectfully

topaz mortar
#

the best way to learn programming is to watch a tutorial on a piece of code, close or hide the tutorial and try to write it by yourself, never just re-write code you can see, you will learn nothing

cosmic charm
#

like how would I know what draw gizoms is? or how would I know what object pooling is

sour fulcrum
#

Googling 😄

topaz mortar
sour fulcrum
#

Though you don’t need object pooling when starting out

topaz mortar
#

I promise you your brain will remember nearly nothing after a few hours if you just re-write code (or worse copy/paste it) while looking at it

cosmic charm
# sour fulcrum Googling 😄

He is saying that I should write the code myself and hide the code from the tutorial, how can I google something that I don't know anything about, you know?

cosmic charm
#

and I needed that

topaz mortar
#

object pooling is an optimization, you never "need" it

cosmic charm
#

If you mean it like that then yeah it's smart I guess

austere monolith
#

public class PlayerMovement : MonoBehaviour
{
    public float speed = 5f;

    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal") * Time.deltaTime;
        float verticalInput = Input.GetAxis("Vertical") * Time.deltaTime;

        Vector2 movement = new Vector2(horizontalInput, verticalInput);

        rb.linearVelocity = movement * speed;
    }
}

whats wrong?

naive pawn
#

you tell us

#

what's the issue

austere monolith
#

i was bout to

#

my bad

#

lol

#

i cant move up and down

naive pawn
#

do that in your original message lol

naive pawn
austere monolith
#

the component?

naive pawn
#

it has gravity

#

it's gonna try to move down, so you're kinda fighting it

austere monolith
#

How do I remove it? Gravity scale 0?

queen adder
austere monolith
#

public class PlayerMovement : MonoBehaviour
{
    public float speed = 5f;

    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal") * Time.deltaTime;
        float verticalInput = Input.GetAxis("Vertical") * Time.deltaTime;

        Vector2 movement = new Vector2(horizontalInput, verticalInput);

        rb.linearVelocity = movement * speed;
    }
}``` now is there something wrong with the code? i cant even move 😭
naive pawn
#

you only set gravity scale, right

#

try debugging, make sure movement is what you expect

austere monolith
#

public class PlayerMovement : MonoBehaviour
{
    public float speed = 5f;

    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput = Input.GetAxis("Vertical");

        Vector2 movement = new Vector2(horizontalInput, verticalInput * Time.deltaTime);

        rb.linearVelocity = movement * speed;
    }
}``` ok now i can move left & right but still not up and down
#

yeah the verticalInput velocity isnt getting added

#

im printing it now

#

only horizontal is

naive pawn
#

why do you have Time.deltaTime there

austere monolith
#

so it doesnt matter your frame rate

naive pawn
#

it already didn't matter

#

linearVelocity is already unit/second

austere monolith
#

okie thanks it works now

naive pawn
#

Time.deltaTime is a conversion factor between "per second" and "per frame"

austere monolith
#

idk how i didnt know that but ok

#

thanks a lot man

#

ill rmbr next time...

naive pawn
#

your speed is units per second, so if you did the movement manually every frame, you'd need the deltaTime to convert that to units per frame
but velocity is also units per second, so you don't need the conversion in this case

austere monolith
#

i see

past yarrow
#

I just started Unity for today and for some reason the cam is so zoomed in while it wasn't yesterday and didn't touch anything since yesterday 🤔 How to solve that please ?

grand snow
grand snow
#

ortho size if ortho, fov otherwise yes

#

I presumed 2d from how it looks + 2d light

#

If stuff that should draw is just not, your camera may be at Z 0 and your content may be there too. Can be solved by moving the camera back a tad on Z

past yarrow
naive pawn
#

elaborate on how it "doesn't work"

past yarrow
#

nevermind it's because I commented that part to try what was suggested to me

prime mantle
#

Already did this

slender nymph
#

start by getting your !IDE configured then share the code properly

eternal falconBOT
grand snow
#

share code correctly !code

eternal falconBOT
grand snow
#

ha

prime mantle
#

PlayerMovement.cs:

using UnityEngine;
public class PlayerMovement : MonoBehaviour{
    public float speed = 5;
    public Rigidbody2D rb;
    private InputManager inputs;
    Vector2 moveDir;
    bool isMoving;
    void Awake() {
        rb = GetComponent<Rigidbody2D>();
        inputs = GetComponent<InputManager>();
    }
    void Update(){
        moveDir = inputs.moveInput.normalized;
        isMoving = moveDir != Vector2.zero;
        Rotate();
    }
    void FixedUpdate(){
        rb?.MovePosition(rb.position + moveDir * speed * Time.fixedDeltaTime);
    }
    void Rotate(){
        if (isMoving){
            float angle = Mathf.Atan2(moveDir.y, moveDir.x) * Mathf.Rad2Deg - 90f;
            transform.rotation = Quaternion.Euler(0, 0, angle);
        }
    }
}
#

InputManager.cs

using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour{
    public Vector2 moveInput;
    public void OnMove(InputValue input) => moveInput = input.Get<Vector2>();
}
naive pawn
#

start with what boxfriend said

prime mantle
#

Done

#

Now what?

naive pawn
#

so what's the issue exactly?

#

what's not working as expected?

prime mantle
#

The joystick, I can't move it

#

If you see the video, you'll see that the move input variable in the input manager script isn't updating

#

That's the issue ig

naive pawn
#

oh it's probably not in the code then

#

(could confirm that by adding keyboard bindings and see if those work)

naive pawn
#

if those work fine, then either the joystick isn't hooked up properly, or it doesn't work in the editor for some reason

naive pawn
prime mantle
naive pawn
#

a code issue was a good guess, but it's apparently not the issue

prime mantle
#

i'll ask in input then

naive pawn
#

(make sure the virtual joystick is hooked up correctly)

prime mantle
#

uhhhh ig it is... wait i'm sending screenshots

naive pawn
prime mantle
#

okkk

ivory bobcat
naive pawn
#

they "work" but not as == null as one might expect

ivory bobcat
#

Right, they don't use the custom equality operator

prime mantle
#

so what should i change??

naive pawn
#

remove the ? (?. -> .) and just let it fail-fast if the component is missing

ivory bobcat
#

If the member has a proper reference, you'll not get the Unity missing reference exception

polar acorn
#

Getting rid of errors is not getting rid of problems. If rb is null, it should throw an error. Null checking it gets rid of the error but just buries the problem that's still there

prime mantle
ivory bobcat
#

Not working relative to...?

prime mantle
#

The joystick isn't working

naive pawn
#

it wasn't supposed to fix that

prime mantle
#

Ohhh

naive pawn
#

it was just a separate issue

past yarrow
naive pawn
#

gotta be <= 1

past yarrow
naive pawn
#

yeah

#

you want it to be -1, 0, 1

past yarrow
#

yes

naive pawn
#

if it was < 1 you'd just get -1, 0

past yarrow
#

makes sense

#

Doesn't work 😬

  • Green : When I pressed that tile it only revealed that tile and not the adjacent "0"s
  • Yellow : It revealed that tile + 3 in the red rectangle

I'm kinda confused on this behaviour 🤔

#

I think it's because of the != 0 part

#

yup 👍

past yarrow
rocky canyon
#

i may give it another shot as well. got ur "Easy" message.. ya i was overthinking the number thing

rocky canyon
#

i was completely overthinking it

past yarrow
rocky canyon
#

i was using the bombs to fill in the numbers..

#

i just need to use the squares to look for the bombs

past yarrow
#

huh ? How ?

rocky canyon
#

ya exactly

#

it didnt work that way 😅

past yarrow
#

I don't understand what you mean by that 😄

rocky canyon
#

instead of having each square count around itself for bombs..

#

i was using the bomb spaces to fill in the numbers around it

#

but then if i got to a second bomb in the vicinity of another bomb.. id have to re-do numbers that wer already done.

naive pawn
#

that wouldn't be an issue

rocky canyon
#

a 1 might become a 2.. and then it might even become a 3 later on on the next bomb.. sooo yea i was doing it bass-ackwards

naive pawn
#

it would actually be more performant

rocky canyon
naive pawn
#

well, if the amount of bombs is <= 50%

rocky canyon
#

i might do a side-by side now

#

just as a test

#

💪

naive pawn
#
for each tile:
  if tile is bomb:
    for each neighbor(tile)
      if neighbor is not bomb:
        neighbor.count++
```vs```py
for each tile:
  if tile is not bomb:
    for each neighbor(tile)
      if neighbor is bomb:
        tile.count++
past yarrow
#

I still don't understand it 😄 Do you mean like you generate the value of the grid from top left to bottom right and if your random generator generates a bomb for your current tile, you're kinda stuck for the previous tile that you already set a number for it and the next tiles would have the same issue later ?

naive pawn
past yarrow
rocky canyon
#

ya ya.

#

i could have just skipped the bombs.. b/c they dont need a number

#

but i was filling in the spaces adjacent

#

yea

#

stupid lol

#

(atleast for my ass)... a nested loop is about all i can contend with

#

or to keep straight in my head.. grids are my kryptonite

past yarrow
rocky canyon
#

let me see if i cant find my old code.. im sure it will give someone a laugh

naive pawn
past yarrow
#

not really a laugh but a way to learn 🙂

rocky canyon
#

oh no.. it was one of my first 2D projects.. its def laugh worthy..

#

it was a learning lesson back then

#

now its just disappointing lmao

naive pawn
#

hey i have minesweeper too lol

past yarrow
#

nice 😄

naive pawn
rocky canyon
#

it was either that or "snake"

#

and snake seemed too ez

naive pawn
rocky canyon
#

did u do urs the actual grid ways?

naive pawn
#

i mean tbf i kinda did them for fun, not with the intent of learning

rocky canyon
#

where u add a grid in front and remove a grid in back?

naive pawn
#

they're terrible and that's ok lol

rocky canyon
#

for movement

naive pawn
rocky canyon
#

ya thats the way i wanted to do mine

#

and i kinda felt gate-kept

#

seems like something hard to do

#

snake movement

#

i mean.. tbh i feel i still made the right choice ^ i wouldnt know how to do this even today

#

since we're in beginner code anyone know the psuedo on how to do something like that ^
where the movement of the snake fills in the square ahead of it and removes the square at the end?

naive pawn
#

deque (via linkedlist in c# for example - or List but that doesn't scale well, in theoretical terms)

past yarrow
naive pawn
#

so you can just use the built-in Queue

naive pawn
naive pawn
rocky canyon
#

Snake Movement Grid

austere monolith
potent epoch
#

if anybody like to help just dm me i am stuck hehe

polar acorn
austere monolith
#

oh shoot

austere monolith
polar acorn
#

Well it needs to have some sort of collider to be detected, yes

potent epoch
#

ohh i was making a mp game for mobile trying to dodge the mp coding things so i ended up somewhere with chatgpt"s script i spent one day figuring out this and wasted i cant just drop out from this project even tho its my second project if i give up i dont know ill lose motive or something

austere monolith
#

uh still doesnt work

polar acorn
austere monolith
potent epoch
#

where to get real people ? for free :)

austere monolith
#

ask you questions here lmao

polar acorn
potent epoch
#

ok thanks

#

hey everyone i have a quastion so i was making a mp game for mobile trying to dodge the mp coding things so i ended up somewhere with chatgpt"s script i spent one day figuring out this and wasted i cant just drop out from this project even tho its my second project if i give up i dont know ill lose motive or something if somebody likes to help me (for free) just dm me :)

naive pawn
#

that's.. not really something we can help with

#

no clue what the actual issue is

polar acorn
#

And people aren't going to commit to solving your problem in a DM when you won't even say what it is

austere monolith
#

seems like the only thing its detecting is the player

#

so its having some issue with the layer detecting

austere monolith
#

although layer number 3 is Box

#

and the box object has the layer Box

#

so im not sure currently

#

ill re-check my scripts

potent epoch
# potent epoch hey everyone i have a quastion so i was making a mp game for mobile trying to do...

Hey, I’m using Photon PUN 2 (free) for a mobile multiplayer game.

Each player prefab has a camera and a Canvas with joystick, sprint button, and stamina UI — all inside the prefab.

The player prefab is spawned using PhotonNetwork.Instantiate().

❌ Problem:
When Player 2 joins, Player 1 freezes — can’t move or look — and logs:

👻 Not my player, disabling input.

It looks like input scripts are disabling themselves due to this check:
if (!pv.IsMine) { ... }

Also: Players aren’t synced. Player 1 sees Player 2's head move, but the controls are hijacked.

✅ What I want:
Each player to have their own camera + UI + input working properly without affecting each other.

Any idea what might be wrong or how to structure this better? (this is not made from chat gpt)

potent epoch
#

U guys are killing me😂

polar acorn
austere monolith
#

oh really now?

austere monolith
#

yeah i looked at that but i didnt see the text i guess

polar acorn
#

There's an OverlapCircleAll that gets back an array of hits

#

You could do that and loop through them, but if you want to look for a specific layer anyway, you should just use a layer mask

austere monolith
#

right so it only detects one object; the closest one? ok, would CircleCast be any different?

polar acorn
#

Circle cast is basically firing a tennis ball in a specific direction. Overlap seems like what you want, you just want to set it up to only be looking for specific layers

austere monolith
#

alright ill try it out and see

#
        {
            if (((1 << hit.gameObject.layer) & interactLayer) != 0)
            {
                pickUpText.SetActive(true);
            }
            else
            {
                pickUpText.SetActive(false);
            }
        }
        else
        {
            pickUpText.SetActive(false);
        }``` seems to work
#

finallyyy, spent an hour on the if statement atwhatcost

grand snow
#

nice one, bitwise operations are a beginner thing

#

It could also be simplified to pickUpText.SetActive(hit != null && (1 << hit.gameObject.layer) & interactLayer) != 0;

#

(use the bool comparison result directly instead of using an if)

pallid nymph
#

(and if you don't want to be a barbarian you'd have 1 or 2 named bool variables to express what the condition means to check 😛 )

grand snow
#

yea its easier to debug if it goes into a bool and then is used. For simpler expressions its probably not needed if variables have good names

muted sapphire
#

Is there a good guide on how to implement dragging in Unity? I've just started trying to make an infinite runner type game but unfortunately, Unity is too complex to allow raw coding and too raw to simply bind an action to drag

#

as in

#

on a phone screen you drag right to move your character a lane right

#

unfortunately i dont know how to tell the scripts to utilize already given or existing variables

#

like touchscreen status

eager elm
muted sapphire
#

meaning i need direct touchscreen compatibility

grand snow
#

checking the last and current input pos gives you a "velocity" which can be used to detect a drag.

muted sapphire
#

its possible, i saw "touch" as an option, but i cant for the life of me figure out if it has "drag" as a preset or if i have to somehow read touch position in a script

muted sapphire
#

im unfamiliar with unitys specific coding

#

i know c

grand snow
#

You can also enable Enhanced touch to get things that work like the old input system touch stuff (do not try first)

#

The new input system way would be to have mouse pos and touch pos go to a vec 2

muted sapphire
#

alright ill check it out

#

sorry if i sound stupid, i code a lot but ive never used unity or ue5 or anything of the sort

#

a little bit of guided godot but thats about it

#

i want to get into making games but unfortunately ue5 is even less beginner friendly so i ended here

grand snow
wintry quarry
#

Or possibly both

muted sapphire
grand snow
#

It does imply you would move something

muted sapphire
grand snow
muted sapphire
#

yeah thats what i did

#

but it means that if the new system is better, i unfortunately cant use the old system just for some singular items

#

has anyone just got a good GENERAL youtube guide series for unity? There's a lot going on that doesn't add up in my head

grand snow
#

There is plenty of content for unity online

grand snow
#

I've done touch swipe detection before so I can give some pointers

muted sapphire
#

Just a quick question because this is gonna come up later: Is it possible to run scenes within scenes?

#

I'd use at least two scenes (Main Menu/Game), maybe more for different submodes within the run like flying or so, and it would require smooth transitioning with scenes

#

like showing a peek of the area within one tab of the main menu

grand snow
#

You can open multiple at once if you load others "additively"

muted sapphire
#

Let me rephrase it more clearly, that was very confusing, sorry

#

You know Subway surfers, yes?

#

The game has its tabs on the bottom and top, and then in the middle it has the animation of the guy spraying

#

then when you tap in the screen in that scene, it fluently goes into the run

#

That i need to do

#

Or rather, want

grand snow
#

I think that is not worth thinking about at this stage for you.
You need to tackle the basics of unity first

#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

muted sapphire
#

Else I end with a mess thats, for example, all in one scene, and it's a hell to seperate it

grand snow
#

Well what you said is possible for sure but I think you should make sure you understand some more fundamental things with unity first

muted sapphire
#

But you are right, i should learn the basics first, i was just hoping that once i get some basics down, it would flow more easily

#

which it might

naive pawn
muted sapphire
#

actually scenes in general are very confusing

naive pawn
#

scenes could be used for this

#

you don't have to

muted sapphire
#

do people just put the entire thing in one scene

naive pawn
#

again this is something that you can worry about later

muted sapphire
#

is that socially acceptable

naive pawn
#

there's many ways to do this, just keep that in the back of your mind when thinking about how it'll flow together

#

don't worry about the specifics just yet

#

get something working before you get something good

#

your first game won't be great, and that's ok - you get experience to make the next ones better

muted sapphire
#

that was why i was making an infinite runner

#

it can be expanded upon

#

and if something good actually comes of it theres plenty of directions one could be used

#

considering i have 0 actual models its just gonna be cube runner anyways

naive pawn
#

being an infinite runner doesn't really affect "it can be expanded upon"

#

anything can be expanded upon in terms of ideas if you're creative enough

muted sapphire
#

and a generally really simple game principle

naive pawn
#

some things can be expanded upon in terms of implementing content depending on how you've designed the underlying systems

#

how the game plays doesn't really affect that

muted sapphire
#

...i really should just start by making a game that uses mouse and keyboard first shouldnt i

wintry quarry
#

You could make the runner game using just wasd controls for now

naive pawn
#

you could just reduce the scope of the project you have

wintry quarry
#

And add touch support later

muted sapphire
#

stuff always turns to a mess sooner or later

#

alright then lets start with the basics

#

So, now a basic question

#

how to i change the x position of a cube within a script

naive pawn
#

have you gone through like, unity essentials, junior programmer

muted sapphire
#

although i might have it somewhere in my page salad

naive pawn
#

aight you should probably go through those !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

muted sapphire
#

unfortunately that link still doesnt work

naive pawn
#

(you can skip parts in unity essentials that you aren't using right now if you want)

muted sapphire
#

thank localization probably

naive pawn
#

wdym by doesn't work?

muted sapphire
#

by that i mean it redirects to a site saying "oops you broke the internet"

#

i assume this is because it autoredirects me to the de website which doesnt exist

#

ignore this

naive pawn
#

it's on de.unity.com or smth?

muted sapphire
naive pawn
#

funnily enough that page loads in english for me

muted sapphire
#

yeah i assumed as much

naive pawn
#

the "click here to go to livehelp" works for me, does that also redirect?

muted sapphire
#

yep

#

sends me to the same page

#

let me vpn and incognito

naive pawn
#

it seems that localization doesn't actually go through /de//ja/other slugs for me

#

perhaps you have a stale cache?

muted sapphire
#

full refresh doesnt help either

#

neither does vpning anywhere

#

so browser change it is

naive pawn
#

full refresh on learn.unity.com/de?

muted sapphire
#

yeah

#

or any other /xx links

naive pawn
#

you'd need a full refresh on learn.unity.com without the /de

onyx geyser
#

i took notes on all the basic things i needed to know, but now my next question is how would i know where they go in a script?

muted sapphire
#

can go to /en with the same result, even in german

naive pawn
#

yeah the localization doesn't actually go through those slugs

muted sapphire
onyx geyser
#

would anyone happen ti have a good tutorial that teaches you how to utilize the things you wrote and learn in what way to write them?

muted sapphire
#

browser change doesnt help either

naive pawn
#

break stuff down into smaller problems, etc

muted sapphire
#

you gotta familiarise yourself with the basics of that

#

or c

#

or c++

#

or really any other programming language

onyx geyser
#

well is there a good way to start at least? like how i would use transform and vector3 in the same statement (presuming i would use them in the same statement)

naive pawn
#

@muted sapphire what about like https://learn.unity.com/pathways

Unity Learn

Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.

muted sapphire
#

theyre all just dialects to one another anyways when dealing with stuff like this

muted sapphire
naive pawn
muted sapphire
naive pawn
muted sapphire
#

what do you want to achieve

muted sapphire
#

NO MATTER who needs homepages

onyx geyser
muted sapphire
#

learn c#

#

or any coding language

#

its very simple

naive pawn
onyx geyser
#

so it's.. less like a puzzle and more like a lego?

muted sapphire
naive pawn
onyx geyser
#

LOL

onyx geyser
muted sapphire
#

You know the unity terms

onyx geyser
#

oh you mean how i know the terms

muted sapphire
#

I know how to code

#

but i havent a damn clue how to make my code tell Unity to do something

onyx geyser
#

yeah, i know a good portion of them and their uses now, i have a bunch of notes on the ones i know at least

#

i sent them to one person, he said they were good, few chop ups here and there

naive pawn
#

great time to pull this out it seems

muted sapphire
#

Language you can learn from youtube to the respective language

#

Logic comes naturally when you begin to understand the syntax and what you actually do

#

Library is what I'm missing in this case, because I can't tell my code to, for example, move a player, but i can perfectly calculate where it's supposed to be

onyx geyser
#

so you have the wood and hammer, you have the blueprint, but you don't have the screws?

muted sapphire
#

I'm missing the specific screws that would put what I've made to the rest of the machination

onyx geyser
#

that makes sense

#

i think i'm gettin an idea

naive pawn
muted sapphire
#

And I still forget the DAMN SEMICOLONS

#

EVERY SINGLE DAMN TIME

onyx geyser
#

even knowing the terms you still have to functionally put them together

naive pawn
onyx geyser
#

i've begun correcting myself on semicolons, capitalization, and spelling, those seem important

muted sapphire
onyx geyser
#

i kept making them when i made that flappy bird tutorial

muted sapphire
#

together with plus and minus errors

naive pawn
#

hm you didn't have autocomplete?

onyx geyser
#

suppose i can see if i can't make pong on my own today rather than follow a tutorial

onyx geyser
muted sapphire
#

but that usually only happens when you do a programmer and just scatter random - signs around your code when stuff doesnt work

naive pawn
#

real

#

i was writing kinematic stuff a few days ago and i just could not get it to work and i checked my math so many times

i had forgotten Time.deltaTime in applying acceleration lmao

onyx geyser
#

can i get my notes judged?

#

i would like my notes judged

naive pawn
#

idk about judging, proofreading maybe

onyx geyser
#

that works

#

just need someone with more experience to look at them and see how well i might've done

#

ofcourse i wrote them IN cs.

naive pawn
#

you probably don't need that Unity.VisualScripting

onyx geyser
#

eh, it came with the thing

#

i never bothered to change it

naive pawn
#

i feel like that'll confuse your future self

muted sapphire
naive pawn
#

if you're writing in c#, you'll generally never touch VisualScripting

muted sapphire
#

VisualScripting is somehow harder than normal scripting

onyx geyser
#

well i have little idea what it is, i just grabbed it from a scipt file in unity and started writing notes

naive pawn
#

visualscripting is unity's block code thing

onyx geyser
#

lets not worry about that top part, it's the notes i wanted proofread, as a beginner with no experinces

eternal needle
#

your IDE might've added it if you tried to use something from the visual scripting namespace, like a class. this happens often

#

your IDE also might have a code cleanup function to remove unused using statements

onyx geyser
#

i think it might be that, i remember having to update my IDE manually and i think i left something unclicked

naive pawn
#
RigidBody2D //a physics body
Transform // the position of the edited object
gameobject //a type that can appear in the inspector?
quaternion.identity //no rotation
vector2-3

you're mixing types and values here - capitalization is important, Transform refers to the class, transform refers to the instance of Transform on the current gameObject

onyx geyser
naive pawn
#

honestly i'd recommend not having this in a .cs file, that way you have more freedom in how you structure your notes
you have if..else, a very fundamental concept, quite far down, separated from for which is in the same category of control flow

onyx geyser
#

i'll only defend myself by saying this is my current understanding of how the terms work

#

otherwise this is pretty sweet

muted sapphire
#

markdown files ftw

muted sapphire
#

alright i checked out the new input system

#

but it seems oddly complicated

naive pawn
#

also this doesn't work

GetComponent(doorlocked = false);

muted sapphire
#

what happens to "getKeyDown" but no we do "horizontalAxis"

onyx geyser
#

yeah i know, thought i put a note saying that it wouldn't work

#

i was just using it as a "this how it would look theorhetically, because i don't know how it actually looks"

muted sapphire
#

What kind of sorcery is that

onyx geyser
#

i intend to come back to this file when i learn more so this is helpful

naive pawn
#

just not for this one

onyx geyser
#

oh, oh yeah wait you're rightr

#

maybe a fore warning at the top would be better

onyx geyser
naive pawn
# muted sapphire markdown files ftw

and yeah, definitely this - would help in structuring your notes a lot
could have separate sections, inline code/codeblocks, lists, checklists

#

i wouldn't use an example for those

onyx geyser
muted sapphire
#

stupid idea

#

but just try coding a calculator in C#

onyx geyser
#

:((

muted sapphire
#

or something

onyx geyser
#

oh

#

LOL

muted sapphire
#

NONONOTHATWASNTWHATIMEANT

#

MYIDEAWASSTUPID

naive pawn
muted sapphire
naive pawn
#

well, if you want to use the new input system, yeah?

muted sapphire
#

or whether i could just make my code check if a key is pressed using it

naive pawn
#

you can do that with either system

muted sapphire
naive pawn
#

it's input

#

that's how it is

onyx geyser
#

welp, time to remake the entirety of the ps2 game 'shadow of the colossus' with my current knowledge.

naive pawn
#

the real world is messy 😭

muted sapphire
naive pawn
#

it won't, they're different kinds of messy

#

orzo and spaghetti don't look that cohesive.. i don't think

eternal needle
muted sapphire
#

alright now, how would i get if "up" is the current state

#

the tutorials are for the old input manager

eternal needle
#

there are tutorials for the new one as well. "new" being a couple years old already

muted sapphire
#

oh yeah i use unity6 btw

naive pawn
#

up just means y will be positive when the binding is triggered

muted sapphire
#

okay, but how do i get that in code

naive pawn
muted sapphire
#

input.Move.y seems a bit excessive

#

and it wont work i can tell you that much

naive pawn
#

new input system is really flexible, hence the "steep learning curve" comment

muted sapphire
#

for now, i just wanna make a cube move whereever i tell it to with my wasd

naive pawn
muted sapphire
#

you speak in riddles

#

maybe im too used to manual this

past yarrow
#

Guys why does it complain when I subscribe to my event and the method is a Coroutine please ? I think I'm missing a StartCoroutine() somewhere but I'm not sure where (it says : Expected a method with 'void OnGameOver()' signature)

naive pawn
muted sapphire
#

Vector2

#

i know what a vector is

naive pawn
muted sapphire
#

but Vector2 specifically

naive pawn
#

same thing for Vector3 but with z added

#

that's as far as unity goes in the core lib

muted sapphire
#

And how would I get the entire "Move" Vector3 (or two, if that is that) from the Input system?

naive pawn
#

it would be the theoretical input.Move from before (it'd just be a Vector2 here, only 2 dims)

#

i'm typing it out give me a sec lol

muted sapphire
#

so "input.Move" describes a 2 dimensional array

#

or returns it

#

makes no real difference but it would force me to use ()

#

well shoot me i dont even have the input system imported

past yarrow
naive pawn
# muted sapphire for now, i just wanna make a cube move whereever i tell it to with my wasd

options, in no particular order (because i don't have the brainpower to sort them right now)

  • InputActionReference as a serialized field, poll that
  • InputActionReference as a serialized field, subscribe to that
  • PlayerInput component with messages
  • PlayerInput component with UnityEvents
  • PlayerInput component with C# Events (not sure what that entails)
  • Generated class, poll that
  • Generated class, subscribe to that
#

you should probably find a tutorial and then just go with whatever that tutorial uses

muted sapphire
#

unfortunately the coding beginner guide on the main page uses input manager

#

how do i import it in the first place?

naive pawn
muted sapphire
#

one dimensional, two element array, im tired sorry

naive pawn
muted sapphire
#

the tutorial is unfortunately being very weird around this corner

naive pawn
#

anyways more realistically input.Move would be an "input action" that you can get stuff from, like GetValue<Vector2>()

muted sapphire
#

ah there, i found some semi decent guide on input system

#

let me copy paste half the code segment and then figure out what it does

naive pawn
past yarrow
naive pawn
#

yes because it's at the end. it'll exit itself

#

you know how you don't need to return void methods?

muted sapphire
#

IT MOVES

naive pawn
#

yeah there's an implicit (aka automatic) return at the end

past yarrow
naive pawn
#

same thing here except with yield break

#

an enumerator is something that gives a sequence of values
when you write a coroutine, you're building that enumerator by specifying the sequence of values
yield adds a step to the sequence
yield return x; adds the value x to the sequence
yield break; specifies the end of the sequence

whole flare
#

Hey everyone!

Is there any possible way to add unity messages(info on Unitys Methods) on Visual Studio Code?

past yarrow
past yarrow
naive pawn
past yarrow
whole flare
#

I mean just to hover on the methods and see documentation

past yarrow
naive pawn
naive pawn
past yarrow
#

I would suggest to switch to Rider, it was the best decision I made 😄

whole flare
# past yarrow

Yeah that works beacuse of the comments /summary, I want just when i hover on to see them like in vs code

naive pawn
#

that's intellisense, not docs

whole flare
#

yeah and in visual studio u get this

past yarrow
naive pawn
#

vscode seems to have these kinds of settings, but there's nothing for c#, so i don't think this is something you can get with the microsoft extensions. maybe there's a thirdparty extension to do that

whole flare
#

u mean dis?

whole flare
past yarrow
naive pawn
#

gotta give some more context here

past yarrow
naive pawn
# whole flare u mean dis?

ah, ok, so they are supported
vscode's, uh, decompilation? just doesn't have very many comments
and messages probably just aren't documented

polar acorn
#

See what it prints right before the error

naive pawn
past yarrow
#

I thought GetActiveScene() returned the name but I had to use name property

#

static variables aren't reset when loading a scene again ?

muted sapphire
#

alright im calling it a day for today, the input system is getting to my head

#

they really arent letting me just get what keys are currently being pressed are they

#

I'd gladly manual the entire movement thing but I can't get it to just give a boolean true for as long as a key is pressed

naive pawn
#

you'd just make a vector out of the 2 axes (for the old one) or take the vector that's the same thing but done for you (for the new one)

past yarrow
wintry quarry
#

When you load a scene non-additively, all other scenes get unloaded

#

Static variables have nothing to do with scenes at all

#

so they're completely unrelated

past yarrow
wintry quarry
#

Didn't you just say it was a static variable?

past yarrow
wintry quarry
#

It's a bit like asking "How come the hat on my head didn't change when I got in a new car?"

past yarrow
#

Oh Ok I understood now

mossy jasper
#

ik its not code related but i cant find the player input script and im on unity 6, i need some help

past yarrow
mossy jasper
past yarrow
mossy jasper
#

Yes im following a tut

past yarrow
mossy jasper
#

YES THATS IT!

past yarrow
#

Go in the top menu > Window > Package Manager > Search for "Input System" > Install it > try to find the script again

mossy jasper
#

ok

#

how do i download it?

past yarrow
#

and search it there

mossy jasper
#

got it, but do i say yes?

past yarrow
mossy jasper
#

ok

mossy jasper
past yarrow
#

!code

eternal falconBOT
past yarrow
#

Before

polar acorn
#

It looks like your Game manager is a singleton but isn't a DDOL, so when you reload the scene it destroys itself

covert obsidian
#

i wanna update a text based on a variable. is the easiest way to do it in the "update" place in the script? i wouldn't think it's good to call it every single frame since the variable isn't gonna change every single frame

slender nymph
#

invoke an event where you set the variable and change the text object only when that event is invoked

covert obsidian
#

that would require sending that event every time the variable is changed, correct?

slender nymph
#

yes

covert obsidian
#

ok, thanks 👍

slender nymph
#

this is easiest done by using a property and changing the variable's value and invoking the event inside the property's setter then just assign to the property everywhere else you are changing the variable instead of assigning to the variable directly

nimble apex
#

can you register async Task into button event?

#

theres a function that must be async Task

#

in login manager

    public async Task GoogleLogin()
    {
        Debug.Log("Google");
    }```
in another UI
```cs
    private void Awake()
    {   GoogleLogin.onClick.AddListener(LoginManager.Instance.GoogleLogin);
    }```
#

i guess i just turn it into void thenatwhatcost

muted sapphire
#

If I could just get an output telling me if a key is pressed or not my life would be much easier

burnt vapor
onyx geyser
#

would there be any particular reason that, when a bounce physics matieral is applied to a rigidbody2D and box collider, upon making contact with a wall, it's speed seems to multiply excessively?

burnt vapor
#

If so, it's a matter of picking which one to use and then using it. Not much else to it

#

Preferably the new system

onyx geyser
muted sapphire
burnt vapor
#

It is

#

I mean, in comparison the new one is set up much better and allows for cross input much better

muted sapphire
#

But I'm currently at a point where I'd rather manual the motion outputs in my code than actually fight with the motion system

burnt vapor
#

You can use the old one, especially if you purely use just a keyboard

muted sapphire
burnt vapor
#

Then I'd do it correctly and use the new one from the very start

#

TBH even if you dont need cross input the new system is better

#

Just shoots yourself in the foot once you do need it somewhere

muted sapphire
#

depressing, the new one is kinda weird when using simple movement

#

its an infinite runner, its literally got three possible states plus height

burnt vapor
#

The idea is the same, I don't see how simple movement makes a difference

#

But maybe you can share your code and it can be reviewed

muted sapphire
#

Because it feels overly complicated

#

No like I have no idea what I'm doing with the new movement system

#

But so far I've gotten Vector2s out of jt

onyx geyser
#

isn't it literally a getkey(KeyCode.W)

muted sapphire
#

Which is way unnecessary for a movement system with three states plus height

muted sapphire
onyx geyser
#

then multiplying the movement by whatever public int/float you use

#

then multiplying by Deltatime so it doesn't turn into fallout 76

#

(context, in fallout 76, movement was directly tied to framerate, which meant if you looked down on at the floor to unload everything, you moved faster.)

muted sapphire
onyx geyser
#

it could also be that the movement script isn't connected to your Rigidbody or whatever you decide to use

burnt vapor
#

This won't work for touch screen

onyx geyser
#

the way i'm using it?

#

ohhh

#

ok

muted sapphire
#

It just seems overly complicated to run a whole input system for something that can be "0, 1 and -1"

burnt vapor
#

I'd dive in and learn the new input system considering it's good knowledge and you will always use it in your games. Even if it gets a bit more complicated

onyx geyser
#

well, as far as i know, it's more complex to make actually running it easier, say if you wanted to use a controller or something like that you could easier attune it, right?

muted sapphire
#

So is there a proper handbook to it?

#

the new movement system i mean

onyx geyser
#

unless i'm big stupid, that's just the idea i got from others who were talking about it

muted sapphire
onyx geyser
#

i'm still trying to figure out why my ball is increasing in speed, or if there is a way to put a cap on it

muted sapphire
#

Oh i might be able to help with that, that seems like a coding issue

#

What exactly is the problem?

onyx geyser
#

it hits a wall, and it's speed seems to double

#

just, y'know, nyoom

muted sapphire
#

you willing to send the code?

onyx geyser
#

{
bool isRight = UnityEngine.Random.value >= 0.5;

float xVelocity = -1f;

if (isRight == true)
{
    xVelocity = 1f;
}

float yVelocity = UnityEngine.Random.Range(-1, 1);


rb.velocity = new Vector2(xVelocity = Flyspeed, yVelocity = Flyspeed);

}

#

just something i followed from a small tutorial

#

kind of using it as a test to see how much i actually understand

#

doesn't seem to fly in any random direction either, which sucks, but that's less important

muted sapphire
#

okay so let me go through this snippet

#

first you randomize if it goes left or right

#

or how far it goes right

burnt vapor
#

Randomized left or right

onyx geyser
#

randomize left or right?

burnt vapor
#

I won't comment on the quality of this code

muted sapphire
#

yeah thats unitys own feature cant really work on that

onyx geyser
#

LOL, guess the tutorial i followed wasn't very good (go figure)

muted sapphire
#

wait what the hell

#

why is a >= chained with a = in a single statement

#

and why does it work

burnt vapor
#

These are basic comparisons

#

>= means "larger or equal to"

onyx geyser
#

which is probably the area that it can travel to

muted sapphire
onyx geyser
#

right?

muted sapphire
#

Sorry, I'm not used to C#, I was expecting a () around the comparison to recieve a boolean

onyx geyser
#

with isRight being a general direction it can travel in? i assume?

muted sapphire
#

at least that's what I would'vs done

onyx geyser
#

i wish some of these tutorials described what they were doing

muted sapphire
#

I should read a short booklet on C# someday so I know its exclusive terminology

#

like -1f and 1f (which i assume is just to make it be a float value)

onyx geyser
#

actually, do i even need isRight?

#

since it's all seemingly handled by rb.velocity

#

unless that's me being dumb again

muted sapphire
#

you do

#

it's used in the calculation of xvelocity

#

which is used in the calculation of rb.velocity

onyx geyser
#

doesn't seem to be very random

as it swings straight out or slightly down (which i assume is the .5 at work)

muted sapphire
#

actually hold on

burnt vapor
muted sapphire
#

you set it to "Flyspeed"

onyx geyser
#

so change the speed in which it flys-

#

oh

#

well hang on

muted sapphire
#

you arent using your values at all

#

you're just using Flyspeed

onyx geyser
#

yeah i see that

#

i wonder why that was the way it was in the tutorial

muted sapphire
#

you might wanna xVelocity*=Flyspeed

#

or if that isn't a thing in C# xVelocity=xVelocity*Flyspeed

onyx geyser
#

heheh

#

the first one didn't do anything

#

what would xVelocity=xVelocity do?

muted sapphire
#

well what is Flyspeed

#

what value

onyx geyser
#

it's the speed at which the ping pong ball flys

#

flies

#

set to.. currently 3

#

but i have a range on it that lets me change it

#

unless it is that range that is causing it go faster

muted sapphire
#

okay hold on that entire code is a bit wonky

#

I need a second to work with that

muted sapphire
#

which i think should be correct

#

I love how the x value is randomized by this unnecessarily complicated snippet but then y value just gets a one liner

onyx geyser
#

other way around?

#

but yeah i thought that was weird

#

also it's still increasing in speed

#

wish there was a way to lock the speed at which it's velocity increases

#

because it's going absolutely nuts

sour fulcrum
#

logically

onyx geyser
#

probably keeping at a singular consistent number right?

sour fulcrum
#

do you want to lock the velocity, or how much it increases by

onyx geyser
#

well, that's the problem i ended up with when trying to find it, by locking it, it'll never increase to it's maximum

#

so i guess i want to limit, not lock

muted sapphire
onyx geyser
#

it's a simple invisible box collider

#

that's all

muted sapphire
#

and there we leave my expertise again

onyx geyser
#

pfff

onyx geyser
#

thinking about it, i can probably do a reverse flyspeed if/else, just need to figure out how to write it, but it may be easier to find a set of words to actually lock at a certain speed.

lusty star
#

so i have this problem where when i auto complete code it doesnt add the right amount of space

muted sapphire
#

what do you mean? looks good to me

#

I'm like 90% sure C# doesnt watch syntax