#💻┃code-beginner

1 messages · Page 337 of 1

nimble apex
#

yeah i found out an error lmao

#

int / int = int💀

#

i gonna kill myself💩

#

i think i will look at it tmr ty

spiral narwhal
#

var layerName = LayerMask.LayerToName(other.callbackLayers.value);

Why is this Layer index out of bounds

#

protected override void OnTriggerEnter2D(Collider2D other)

#

I want to get the layer of the colliding object

keen dew
#

callbackLayers is a LayerMask, not a layer

spiral narwhal
#

Ahhh yes, its gameObject.layer

bold nova
#

I try to launch a misle out of an rpg. I have a bad time understanding how coroutines work. Below a method that starts coroutine that lerps misle object and when its done play particle effect and call other method. But lerping works only if i put playing particles and explode method inside of the coroutine. Otherwise misle explodes instantly at the hit point. Shouldn't those two be called only after coroutine is done??

    public void SetFlying(RPGEffectsManager effects, RaycastHit hit)
    {
        StartCoroutine(Fly(hit,effects));

        effects.PlayExplosionEffect(hit.point, Quaternion.identity);// should be inside coroutine

        Explode(transform.position);// thats too
    }
    private IEnumerator Fly(RaycastHit hit, RPGEffectsManager effects)
    {
        Vector3 startPos = transform.position;

        float distance = Vector3.Distance(transform.position, hit.point);
        float remainingDistance = distance;

        while (remainingDistance > 0)
        {
            float distanceCovered = 1 - (remainingDistance / distance);

            transform.position = Vector3.Lerp(startPos, hit.point,
                distanceCovered);
            remainingDistance -= Time.deltaTime * _speed;

            yield return null;
        }
        transform.position = hit.point;

        
    }
#

So, appareanly coroutines don't suspend the code that goes after them?

keen dew
#

correct

languid spire
#

you do misunderstand coroutines.
when you start a coroutine it will run until the first yield statement. Then the code after the start coroutine will execute

hushed hinge
#

...hello?

burnt vapor
#

I can't make sense of the question, sorry

burnt vapor
#

yield return StartCoroutine(WaitAndPrint(2.0f));, like this for example

bold nova
burnt vapor
#

Works too. Just keep it in mind because it might be better to separate the logic into its own chunks

hushed hinge
# burnt vapor What?

i mentioned down bellow where i mentioned inthe comment there, below the video

hushed hinge
# burnt vapor I can't make sense of the question, sorry

like when i testes in the stage scene, and when i die and respawn, it actually works that i can move around and that i was respawned there, but however. when i was in a different scene, which is a level select scene and when i tested there. clicking on the first level to go over to that scene, and when i die and respawn. I am not respawning anymore
i did say that below the video

iron galleon
#

from this guy

topaz mortar
eternal falconBOT
willow scroll
hexed terrace
topaz mortar
#

or the tutorial is bad/outdated lol

iron galleon
topaz mortar
#

do the code link services add code highlighting or anything to the code?

hexed terrace
hexed terrace
topaz mortar
#

would be lot more readable than that txt I guess?

hushed hinge
willow scroll
#

And the txt has to be downloaded too

iron galleon
hushed hinge
willow scroll
willow scroll
hushed hinge
iron galleon
willow scroll
hushed hinge
verbal dome
#

I see in the video, its a null ref exception.

topaz mortar
hushed hinge
willow scroll
#

You have a NullReferenceException. Is your Singleton null?

willow scroll
willow scroll
hushed hinge
topaz mortar
#

is using Debug.Log a good way to debug code (for beginners) or is there a better way I should be using?

willow scroll
languid spire
willow scroll
real rock
topaz mortar
languid spire
#

in pinned messages

topaz mortar
#

cool thx

willow scroll
hushed hinge
# willow scroll Right, so what is it supposed to mean?

this is a null which is instance, and that line which i was sent to have
PlayerComponents go = PlayerManager.instance.SpawnPlayer(1, PlayerManager.instance.GetPlayer(1).player2D.lastCheckpoint.transform.position);
doe sit have something do do witht he instance null?

willow scroll
#

It's either your PlayerManager or the instance is null

#

Check it out

verbal dome
hushed hinge
hushed hinge
north kiln
willow scroll
# hushed hinge not so much

Imagine, you want to eat an apple, which is on your table. You try to bite it, but you cannot, because this apple doesn't exist on your table. This is what throws you an error.

real rock
willow scroll
limber anchor
#

!ide

eternal falconBOT
willow scroll
hushed hinge
north kiln
#

No

willow scroll
hushed hinge
willow scroll
#

There is also a link on the link they sent

willow scroll
hushed hinge
hushed hinge
hexed terrace
iron galleon
#

so I uh fixed it, but I can only jump in the air

iron galleon
#

imma try another tutorial;

hushed hinge
#

the void awake

hushed hinge
frosty hound
#

@hushed hinge You need to try it instead of sending everything here with a ?

#

If you insist on occupying this entire channel again, make a thread.

hushed hinge
#

singleton

#

there, a thread

#

singleton playermanager

#

made a new one instead

hushed hinge
hexed terrace
#

Others can see when a thread is created, there's no need to tell everyone

misty orchid
#

oof

hushed hinge
ivory bobcat
#

What line is 52?

queen adder
topaz mortar
#

I remember it has something to do with an apple and a table

hushed hinge
hushed hinge
# ivory bobcat What line is 52?

PlayerComponents go = PlayerManager.instance.SpawnPlayer(2, PlayerManager.instance.GetPlayer(2).player2D.lastCheckpoint.transform.position);

topaz mortar
dreamy junco
#

does somebody know why unity playes music so terrible and how to solve it

deft grail
dreamy junco
#

it's like broken, the volume changes and it has that sound as if it would crash

dreamy junco
deft grail
#

maybe its in Update or something and its being spammed play and creating that effect

dreamy junco
#

i'm playing it through code yeah

deft grail
eternal falconBOT
dreamy junco
#
using System.Collections.Generic;
using UnityEngine;

public class MusicScript : MonoBehaviour
{
    public AudioSource source;
    public AudioClip clip;

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

    // Update is called once per frame
    void Update()
    {
        source.PlayOneShot(clip);
    }
}```
deft grail
#

turn of looping on the audio source maybe

dreamy junco
#

it's the same

deft grail
#

take it out of Update

dreamy junco
#

ok

#

it works ty

#

another question: I made Flappy Bird and i added pressure plates that should set a bool to true which is the condition to get the point when you fly through the pipes and this doesn't just increase the score it also sets the bool to false so you have to activate the next plate but the bool changes all the time

dreamy junco
#
    {
        if (collision.gameObject.layer == 6)
        {
            plateActive = true;
            Debug.Log("Treffer!");
            this.gameObject.GetComponent<SpriteRenderer>().sprite = ActivePlate;
        }
    }
}```
#

this is the plate script

#
    {
        if (collision.gameObject.layer == 3 && active.plateActive && status.birdIsAlive)
        {
            logic.addScore(1);
            active.plateActive = false;
            Debug.Log("Punkt erzielt!");
        }
    }
}```
#

this it the pipemiddlescript

deft grail
#

why do you have 2 scripts

#

just do a OnTriggerEnter and Exit

dreamy junco
#

i've got 2 scripts cause the pipe has to collide with the bird and the plate with the arrow that is shot by the bird

#

i have already tried to change it to exit it doesn't change the problem

deft grail
#

why does the pipe have to collide with the bird? it just needs to collide with the plate from what i understand

dreamy junco
#

wait i'll send a recording

deft grail
#

use a .mp4 or upload to streamable/youtube or something

dreamy junco
deft grail
timber tide
#

flabby birb

dreamy junco
#

the problem with the bool chaning is that sometimes i get a point without the plate beeing active and sometimes it's reversed

#

the strange thing is: with the first pipe there is no problem at the beginning of the game it's only false then it's only true when the plate is active

#

wait i'll show the log

#

how to show the log obs only records the gameview

deft grail
#

record your screen

#

or screenshot the log

dreamy junco
#

ok wait

#

this is at the beginning

deft grail
#

dont do it in Update

#

do it in useful positions, like when you collide etc

dreamy junco
#

and this is when the first plate gets activated

#

what should i do in useful positions?

deft grail
#

log what you need

#

the bool, the score, whatever is valuable at that point

dreamy junco
#

the plateActive bool is displayed

#

and it's changing

#

the interesting thing is that the log shows always the same order of false and true only once a second one of the lines changes

#

and if the last one is true the score will be increased if not it won't

#

do you know why the bool is changing all the time

ruby python
#

Would anyone know if for loops are more efficient than foreach loops? I was watching a video a couple of days ago and the guy mentioned that foreach add to the whole garbage collection thing, but I've never heard that before so was just curious.

languid spire
ruby python
#

Okay cool. Thanks 🙂

timber tide
#

forloop is best loop

brave compass
ruby python
#

Okay thanks fellas 🙂 Much appreciated. 🙂

cosmic dagger
#

i'm all for one, not all foreach . . .

swift crag
#

List<T> has a struct-based enumerator that doesn't produce any garbage

#

I ran into an interesting issue once where a library that provided non-GC equivalents to LINQ methods was...producing garbage

#

its own struct enumerator type (or was it the enumerable type?) was getting boxed

swift crag
polar acorn
brave compass
swift crag
#

Instead of IEnumerable<T>, it builds up a terrifyingly complicated struct type

#

no garbage, no virtual method calls, no mercy

polar acorn
swift crag
#
            var res = acc;

            while (prev.enumerator.MoveNext())
                res = agg.Invoke(res, prev.enumerator.Current);

I replaced a foreach with this to get rid of that bit of garbage.

This looks evil because it's just kind of ... accessing an enumerator, but that's how the RefLinqEnumerable type works. GetEnumerator() just returns an enumerator field

#

hey, it hasn't failed yet 😁

#

i've been tilting-at-windmills to get my allocations as low as possible

#

so that I can crank up the complexity of my AI system and generate more garbage

swift crag
#

to efficiently implement a pool, use a pool

spiral narwhal
#

For a platformer I want to add head collision evasion. How can I cast a raycast to check if there would be a collider that is not a trigger?

swift crag
#

You can explicitly ask to not hit triggers.

#

see queryTriggerInteraction

spiral narwhal
#

Ah I see cheers

brave compass
# swift crag no garbage, no virtual method calls, no mercy

I'd be curious how this performance in IL2CPP. I'm all for generics abuse to avoid allocations, but it can generate a lot of code. Before shared generics for value types was an option in IL2CPP, I was getting failed builds because all my generics abuse was generating 9+ **giga**bytes of generated .cpp files. Full Generic Sharing fixed that, but there's some reduced runtime performance that comes with that.

swift crag
#

I hadn't heard of full generic sharing; that's neat

#

I haven't done much with IL2CPP yet (partially beacuse it was blowing up on my macbook until recently...)

#

right now i'm more worried about creating 3 quadrillion shader variants

spiral narwhal
swift crag
#

Raycast2D uses a more complex ContactFilter2D struct

#

You can create an instance that does nothing with ContactFilter2D.NoFilter()

#

Then you can set properties on it to add some rules

#

note that the default ContactFilter2D doesn't mean "no filtering"

#

notably, its layer mask is empty

buoyant knot
#

i made a public static class with specific public static readonly ContactFilter2D, so I could use throughought project, and update as new layers/etc are added. It has been very convenient.

#

(And i recommend this strat)

#

it might actually be public static readonly LayerMask, and public static ContactFilter2D with private setter public getter

spiral narwhal
#

Think I got it!

#

Just wondering why the array is not out, wouldn't that make more sense?
Physics2D.Raycast(transform.position, Vector2.up, _headEvasionFilter, out RaycastHit2D[] hits, _headEvasionRange);

swift crag
#

it doesn't assign a new array into your variable

#

it modifies the contents of your array

#

assigning a new array would defeat the purpose, since it would have to allocate a new array and generate garbage

spiral narwhal
#

Huh? I thought it gives me an array of all hits it finds

swift crag
#

It fills your array.

#

It would give you an array if it had the out parameter, yes

#

but it doesn't!

dreamy junco
#

so i guess i won't find a solution for my plateActive problem. but when i put the music in the start function how to make it loop

spiral narwhal
#

So RaycastHit2D[] hits = { }; would be fine?

swift crag
#

no, because that'd be an empty array

#

arrays can't change size

#

it would write zero hits into your array

spiral narwhal
#

But how would I know the size in a dynamic game

swift crag
#

There's another variant of the method that takes a List<RaycastHit2D>. I find that more convenient.

swift crag
#

maybe 8 or something

teal viper
swift crag
spiral narwhal
#

So for my case where I just want to detect if the player would hit his head, a size of one would suffice

swift crag
#

I'm not sure if it guarantees that it fills the array in order

#

I know that some methods make no guarantees about that

#

Although, it would be kind of hard to use Raycast if it gave results in random order

languid spire
spiral narwhal
#

And how do I check if it worked?
if (hits[0].)

swift crag
#

look at the return type of the method.

spiral narwhal
#

Ah so if return > 0

#

But then I absolutely do not even need the array

brave compass
swift crag
#

the problem is that this doesn't let you tell it to use triggers

#

it doesn't take a ContactFilter2D

#

(and then change it back afterwards!)

#

alternatively, just use an array of one element and don't worry about it

spiral narwhal
#

Hold on, I do NOT want it to include triggers

#

Just actual collisions

swift crag
spiral narwhal
#

So I did it right?

swift crag
#

I don't know what you wrote

spiral narwhal
#
        private ContactFilter2D _headEvasionFilter = new ContactFilter2D().NoFilter();

// AWAKE
            _headEvasionFilter.useTriggers = false;

// JUMP METHOD
            if (_enableHeadEvasion)
            {
                var hits = new RaycastHit2D[1];
                var amountOfWrittenHits = Physics2D.Raycast(transform.position, Vector2.up, _headEvasionFilter, hits,
                    _headEvasionRange);

                if (amountOfWrittenHits > 0)
                {
                    // The player WOULD hit his head, so perform evasion to guide them
                }
            }
dreamy junco
#

when i put my music in update it sounds terrible but when i put it in start it doesn't loop

#
{
    public AudioSource source;
    public AudioClip clip;

    // Start is called before the first frame update
    void Start()
    {
        source.PlayOneShot(clip);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}```
polar acorn
polar acorn
dreamy junco
#

i don't know it worked

polar acorn
#

Do you know what one-shot means

dreamy junco
#

i am new to unity

#

no i don't

polar acorn
#

This isn't a unity thing, this is an English thing

#

One Shot means exactly that. It plays once

#

Regardless of loop settings

languid spire
#

@dreamy junco you know that Update runs every frame right?

rich adder
#

would be wild not knowing considering the comment above it lol

languid spire
#

what? You expect people to READ, silly you

dreamy junco
polar acorn
dreamy junco
#

it then sounds terrible

polar acorn
#

that's probably not what you want

dreamy junco
#

yeah

languid spire
polar acorn
#

So, start it once, and don't use the method that specifically ignores looping settings

brazen canyon
#

Hey guys, is it necessary for a game object to have collider to be hit by raycast ?

umbral bough
#

Hi, I ran into a similar issue before and couldn't figure it out.
I am rotating an object and the script I have works fine for the most part.
Issue is when I go < -90 or > 90 degrees on X axis.
It inverts the rotation applied to the object.
This causes fast switching as it's constantly going below and above the said number or just inverted rotation till you get out of that range(depending on the implementation).
I am really bad at math and this seems to be related to how quaternions work(I could be wrong) so I'd really appreciate somebody helping me figure this out.
I'd be glad to provide a short video showcase if the issue is unclear.
Here's the script and thanks in advance!

GitHub

Conquer The Astrid. Contribute to nnra6864/ConquerTheAstrid development by creating an account on GitHub.

rich adder
real rock
umbral bough
real rock
#

Well you can internally clamp it to loop from 360 to 0 or whatever is needed but it’s because 270 is also -90, and the quaternion system is just the “shortest” rotation which sometimes translates weirdly to eular

#

But the variable is the best way I’m aware of and isn’t going to impact anything realistically

umbral bough
#

I see, so understanding why exactly it's happening would require additional math knowledge(specifically quaternions and to euler conversion), thanks anyways, imma just go the easy route ig

real rock
#

Specifically into quaternions and quaternion-eular math yes

#

Something I have little personal knowledge in yet lol

tropic siren
#

Hey! Beginner here
I'm making a marble game where I want to make the camera follow the marble from behind always, no matter where it goes or how it rotates. I suppose the best way to achieve this is to take where the rigidbody is moving (so velocity?), flip that and add it to the marbles position, with a bit of distance and height added we have the cameras position? Or am I overcomplicating things and there is a way simpler way to do this

amber veldt
#

Hey guys, do anyone have extensive documentation on the unity tilemap components ans related? All I found was a single page on it...

robust pecan
wintry quarry
#

you don't need FreeLook

#

FreeLook is for like a 3rd person shooter

robust pecan
tropic siren
#

I did give Cinemachine a shot but got completely lost on what things to set and use, but I will give it another shot, thanks!

wintry quarry
tropic siren
#

Ohh, I guess I will look at a few tutorials to see how it works, thank you

iron galleon
wintry quarry
iron galleon
#

it's the exact same script?

wintry quarry
#

PlayerMovement and PlayerMovementAdvanced?

iron galleon
#

oh wait mb

#

wrong one

#

sorry

wintry quarry
#

looks pretty clear you're putting a bool somewhere that a float is expected and vice versa though

#

Is this up to date? Line 94 is empty

iron galleon
#

yeah

wintry quarry
#

Make sure your script files are saved and then shjow the full error message

iron galleon
#

I even tried copying the exact same script

polar acorn
tropic siren
iron galleon
#

what the hell

wintry quarry
iron galleon
#

goddam

#

guess I have to rewrite the entire thing

wintry quarry
tropic siren
#

hmm im currently trying transposer with world space as binding mode

polar acorn
#

Syntax errors beget syntax errors

tropic siren
#

hmm yea but it doesnt follow behind it

#

maybe damping problem?

wintry quarry
#

it will follow with whatever offset you set

iron galleon
#

nvm

#

visual studio trippin

#

but I can't fix these 2

wintry quarry
iron galleon
#

I tried ||

wintry quarry
#

it should be a bool

iron galleon
#

dude the other one says readyTojump is a bool

#

wtf???

wintry quarry
#

that does not say that

#

that is saying that false is a bool

iron galleon
#

ohhhh

wintry quarry
#

right click on readyToJump and click "Go To Declaration" or whatever it's called

iron galleon
#

fuck im dumb

#

now it's just saying this

wintry quarry
#

looks like your MyInput function is expecting a bool parameter

#

but your GetReadyToJump function returns a float

#

you're again trying to shove a square peg in a round hole

polar acorn
iron galleon
#

input expects a bool but get ready to jump is a float

brazen canyon
#

https://poki.com/en/g/longcat
Hey guys, I was told to remake this game, but not using collider, and in 2D
I used to make a game like this.
But that game required collider

polar acorn
wintry quarry
polar acorn
#

Should MyInput expect a float, or should GetReadyToJump return a bool? Only you can decide

iron galleon
#

finally fixed it

#

thanks

brazen canyon
brazen canyon
wintry quarry
wintry quarry
#

you just have a 2d grid

#

and you check if the space is occupied or not

polar acorn
#

If a cell has something in it, then that'd be a collision

brazen canyon
wintry quarry
#

imagine:

bool[,] grid = new bool[10,10];

// Is space 4, 5 occupied?
bool isOccupied = grid[4, 5];

// mark position 1, 3 as occupied:
grid[1, 3] = true;

// mark position 6, 3 as NOT occupied:
grid[6, 3] = false;
#

in reality you'd probably use something a little fancier than bool but this is the simple base case.

brazen canyon
wintry quarry
#

it's not really... a special thing you'd learn about on Youtube

polar acorn
#

It's just a grid

#

a 2D array

#

It's not a Unity component or anything

brazen canyon
#

Okay so ...
I have a 2D array, I each element is a block
I spawn the blocks based on the array ?

chrome tide
wintry quarry
#

so i'm just checking if it's true/false

#

bool cannot be null

chrome tide
wintry quarry
#

if it was an array of a class you could certianly use null to represent unoccupied

#

in general you're right, you can only check the value at a particular index in the array. The semantics of that depend on what kind of thing is stored in the array.

spiral narwhal
#

Is the [Min] attribute actually enforced?
Cause I can set values less than that in the inspector fields

languid spire
polar acorn
wintry quarry
#

only a [Range]

brazen canyon
wintry quarry
#

Well I mean you'd have to actually go and define what a "block" is

languid spire
primal narwhal
#

!ide

eternal falconBOT
polar acorn
wintry quarry
#

if it's not you could report a bug

languid spire
spiral narwhal
#

Mm yes it seems bugged then

carmine elm
#

how can i access workloads tab on vistual studio code if already have it installed?

brazen canyon
brazen canyon
wintry quarry
#

yes

brazen canyon
#

Thank you

dreamy junco
#

i've made a sound that plays when you press a button but the quit game button and the play button don't make a sound cause the game is quit or restarted

#

is there an easy solution

wintry quarry
#

this means either additive scene loading/unloading, or the use of DDOL objects

languid spire
dreamy junco
#

i'll make a delay so it doesn't quit instantly

brazen canyon
#

Huh ?

carmine elm
#

the tab where i can install the unity things for visual studio i forgot to check them when i installed it

dreamy junco
#

my invoke doesn't work it doesn't delay my function

wintry quarry
#

you'd have to show your code

modest dust
#

Well, share the code then

wintry quarry
#

and explain what it's doing instead

dreamy junco
#
    {
        Invoke("invoke", 1000);
    }

    void invoke()
    {
        source.Play();
    }```
modest dust
#

You.. delay the sound.

#

Not the quit/play functionality

#

And Invoke takes time in seconds

dreamy junco
#

oh i'm such an idiot sry

stuck phoenix
#

Maybe someone have suggestion. I'm working on my thesis that is 3D game. I added lockers system where player can hide inside it, basically just pressing E for interaction and then player camera turns off and camera inside locker turns on, very basic. But I duplicated few more lockers and on first enter to locker it does not turn the right camera on and only if you exit and re enter locker you get right lockers view.

limber anchor
#

Hello I am trying to write my first 3d player movement script but I got my movent almost done but just added my jump function but now I can move whilst in air but not when on the ground whilst in air
I am not getting any errors (and yes I debuged Grounded grounded = true when on the ground)
code: https://paste.ofcode.org/B8CvgS2xizvmPME5jKrTZ8

final totem
#

i just wanna trigger an audio source with an auido clip inside cant i just play instead of playclipatpoint?

wintry quarry
wintry quarry
limber anchor
#

My moventscript includes aircontrol so when I am in the air the player can move but when on the ground I cant move

wintry quarry
#

ps:
GroundCheckTransform = GroundCheck.GetComponent<Transform>();
can just be
GroundCheckTransform = GroundCheck.transform;
Or better yet - just assign the Transform directly in the inspector.

wintry quarry
limber anchor
willow scroll
rich adder
lapis beacon
#

Heyy quick question - does anyone know a good Unity tutorial for kind of beginners??

bronze zenith
#

how do i make it so i cna crouch

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
lapis beacon
#

Thanks! Ive tried some before ill try out more tho

bronze zenith
rich adder
willow scroll
rich adder
#

Welcome to part 4 of this on-going first person controller series, int this episode we're going to be covering how to crouch and stand effectively while also amending our movement speed WHILE we're crouching and also taking into consideration any obstacles above us before we stand back up!

Join me and learn your way through the Unity Game Engin...

▶ Play video
#

they even do the Lerp correctly

lapis beacon
rich adder
lapis beacon
final totem
#

why my funciton dont show here?

rich adder
#

because you dragged script from Project view
not the object that has the script

polar acorn
#

Drag in an object with the script on it

final totem
#

ah i hjave to drag the game object

#

thanks yall

#

how do i send the value of the slider here tho?

rich adder
#

if it doesn't show then i dont think you can do that via that component

polar acorn
#

It will be the top section in the menu

final totem
#

i think this not the way

hushed hinge
#

I am so stuck...

rich adder
rich adder
#

there should be one next to the Volume that says Dynamic

hushed hinge
final totem
rich adder
#

just a joke

hushed hinge
rich adder
hushed hinge
rich adder
#

Ahh ok good to know lol

hushed hinge
# rich adder why can't you assign anything

I don't know, I know I have the data, but I can't assign it in the level select scene (it is that the players in the gameplay scene are assigned, but not in the level select*

rich adder
#

yes you cannot assign objects from one scene with objects in another

rich adder
#

you need to make a singleton

#

oh there ya go

real rock
rich adder
#

yea

real rock
#

huh... good to know

rich adder
#

this goes into good details on the matter

hushed hinge
rich adder
#

use a separate project if you must practice

#

keep practicing how Singleton will work

real rock
#

so just to double check, if I declare a singleton in scene A and do stuff with it, I can reference it in scene B and the data will only stop persisting after a restart?

rich adder
#

the data would only persists if singleton is in DDOl

rocky canyon
#

well a singleton gets transfered over to the new scene with a DontDestroyOnLoad

rich adder
#

otherwise unity likes to destroy objects on scene changes

real rock
#

OH

#

ok I was going to say lol

hushed hinge
# rich adder I'm kinda jumping in here so I'm not sure what You did and didn't do. I have to ...
public PlayerComponents GetPlayer(int playerNum)
    {
        if (playerNum == 1) return playerOne;
        else return playerTwo;
    }

    private void OnEnable()
    {
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
    private void OnDisable()
    {
        SceneManager.sceneLoaded -= OnSceneLoaded;
    }
    private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        // Call your function here
        YourFunction();
    }

    private void YourFunction()
    {
        GameObject.FindGameObjectWithTag("Player");
        GameObject.FindGameObjectWithTag("Player 2");
    }
real rock
#

still handy but closer to the behaviour I expected

rich adder
#

singleton just makes it possible to be easy to access because instance is Static

#

which is through the whole Program

rocky canyon
acoustic arch
#

for my enemy AI how often should my enemy check for actions and chose an action, should i have it check every 3 seconds or is there other ways to do this better?

hushed hinge
rocky canyon
# rocky canyon
public class OSSManager : MonoBehaviour
{
    private void Awake()
    {
        DontDestroyOnLoad(this);
    }
}```
hushed hinge
real rock
#

should probably DDOL some of the scripts I have now I think about it...

rich adder
#

singleton is a pattern

rocky canyon
rich adder
#

this aint it

#

FindGameObjectWithTag will not work across scenes

real rock
rich adder
polar acorn
rich adder
rocky canyon
#
using UnityEngine;
public class TestScript : Singleton<TestScript>
``` simple as this
rich adder
#

so back at square one

polar acorn
#

And after 11 hours I refuse to tell them how to assign it

lunar hollow
#

Smoothdamp Calls interfere with eachother.

polar acorn
#

Because it should not have come to this

real rock
rich adder
hushed hinge
rocky canyon
hushed hinge
polar acorn
#

Instead of trying to start the whole debugging process over again with new people you could just actually do what you were told to do

#

You're going to have to do that either way

hushed hinge
polar acorn
polar acorn
#

So assign them there

#

Like I said five fucking hours ago

frosty hound
#

Use your thread please

#

Don't spill it out here

polar acorn
#

There's no need for any thread or any more posts on it. You literally have the answer

#

you just have to assign the variables to the data you've gotten

#

No more questions on this. Don't rope random people into starting the entire goddamn process over because you don't know how to assign a variable. You aren't gonna know how to do it in six hours of spawn or nav debugging the same goddamn steps either

hushed hinge
polar acorn
#

how could that mean anything else

#

Now, back into the thread and woe betide anyone who follows you into it

real rock
#

darn (no gif)

fluid glen
#

Ok @polar acorn

#

Could I have some help

real rock
#

don't crosspost

fluid glen
#

Whenevr I try install xr plug-in management it always has an error

#

I need help with that

rich adder
fluid glen
#

Sorry.

rich adder
#

especially in the field of dev

real rock
fluid glen
#

Sorry ill let you know what the error is lol.

#

Basically saying ‘buildtargetgroup’ does not contain a definition for ‘VisionOS’

rich adder
#

hard to say without knowing what exactly you've done, what you're trying to do etc.
read the #854851968446365696 on the DOs

fluid glen
#

What I’m trying to do is install the XR plug-in management

real rock
#

I think the others did most of the work tbh so if you didn't thank them already I would

fluid glen
small mantle
#

I'm fairly new to the Input System. I followed a tutorial and they gave me this code: ```cs
InputAction jumpAction;
void JumpTriggered(){get; set;}

    void Awake(){
        jumpAction.performed += context => JumpTriggered = true;
        jumpAction.canceled += context => JumpTriggered = false;
    }```

It works and is really good if I wanted to hold a button down. But I don't want that. How can I make it just perform once (Like I need to tap it instead)?

rich adder
fluid glen
hushed hinge
rich adder
fluid glen
#

Oh mb.

#

Should I download lts instead?

swift crag
rich adder
swift crag
#

note that the performed event will only fire once until you've released the button and pressed it again

rich adder
#

2023 isnt a thing anymore anyway, Unity is now either LTS 2022 or 6 preview

fluid glen
#

Ok which one is lts?

fluid glen
#

The 6 with loads of 0s lol

rich adder
swift crag
fluid glen
#

Ok

swift crag
#

i'm guessing your project contains code that is still using the old name

fluid glen
blissful spindle
#

Hi everyone, just wanna ask how do I put some kind of force to this instantiated object(static speed<not slowing down>)? https://hatebin.com/elilkacipu

rich adder
#

yeah but be aware, downgrading a project isn't easy

#

might break all of packages

languid spire
rich adder
carmine elm
#

cannot press ui buttons and idk what i m doing wrong?

rich adder
#

debug it with Event System in playmode

swift crag
#

inspecting the Event System object (which should have an Event System component on it) will let you see what you're hovering over, yes

#

assuming you are not using the new input system, which doesn't tell you that, for some reason

#

you probably have a large UI element that's blocking the other buttons

blissful spindle
swift crag
#

(even though it may not visibly cover the buttons)

carmine elm
blissful spindle
languid spire
#

that is what setting a velocity does, like cruise control on a car

swift crag
#

you should see some information about the currently selected game object, as well as what you are hovering over

fluid glen
#

Which 2022 should I do.

swift crag
#

the latest LTS release.

#

it will be suggested by the Hub

blissful spindle
swift crag
#

Instead of referencing it as a GameObject, reference it as a Rigidbody

#

This will work as long as there is a Rigidbody on the root object of your prefab.

#

Now you'll get a Rigidbody back from Instantiate.

small mantle
blissful spindle
swift crag
swift crag
#

call it Bullet

swift crag
#

compare this to a method, which has a name

#

It's equivalent to writing this method out

blissful spindle
swift crag
#
void SomeMethod(InputAction.CallbackContext context)
{
  JumpTriggered = true;
}
swift crag
#
jumpAction.performed += SomeMethod;
#

Same idea.

#

So, instead of just setting a field to true, you can do whatever you want in there

#

One thing to note: subscribing with an anonymous function means you can't unsubscribe later

small mantle
swift crag
#
foo.performed += what => how;
foo.performed -= what => how;

This doesn't work. The two anonymous functions are different objects.

swift crag
#

(notably, if you have Domain Reload disabled, you have to clean up after yourself between play sessions)

#

you also might want to unsubscribe when the behaviour is disabled

#
void OnEnable()
{
  action.performed += HandleAction;
}

void OnDisable()
{
  action.performed -= HandleAction;
}

void HandleAction(InputAction.CallbackContext ctx)
{
  // whatever
}
#

like so

#

OnEnable runs immediately after Awake, so this has roughly the same timing as doing it in Awake

#

(unlike Start, which runs a frame later)

swift crag
#

oh wait, I just realized something

small mantle
#

If I want to just have it happen at a tap, what should go here then? ```cs
jumpAction.performed += here?

swift crag
#

you're subscribing every single frame

small mantle
#

No

languid spire
#

Oh yes you are. See the little + = in there?

swift crag
#

performed isn't a boolean, as you observed

#

and += would be the wrong syntax for doing something conditionally anyway

small mantle
swift crag
#

the code you sent does not indicate this

#

if that code is inaccurate, then please show us your current code

languid spire
# small mantle It is in Awake()

?

void Update(){
            jumpAction.performed += context => JumpTriggered = true;
            jumpAction.canceled += context => JumpTriggered = false;
        }
small mantle
#
private void Awake() {
        RegisterInputActions();
    }void RegisterInputActions() {
        moveAction.performed += context => MoveInput = context.ReadValue<Vector2>();
        moveAction.canceled += context => MoveInput = Vector2.zero;

        jumpAction.performed += context => JumpTriggered = true;
        jumpAction.canceled += context => JumpTriggered = false;

    }
#

This is the code this

swift crag
#

don't try to be clever when sharing code. copy-paste it directly.

languid spire
#

you are just wasting our time

swift crag
#

share the entire script so i can see what you're doing !code

eternal falconBOT
small mantle
#

Which do I use? this

swift crag
#

any link works

#

it has a pleasant background color

#

the bot message has several choices because sometimes the sites break

swift crag
#

okay, so you're enabling the actions in OnEnable and disabling the actions in OnDisable

#

reasonable enough

#

note that this is separate from subscribing to performed (and maybe unsubscribing from it later)

#

Disabling the action means the input system completely stops thinking about it

#

nothing happens

small mantle
swift crag
#

and "stops telling me about that" in OnDisable

small mantle
#

Are you saying that the issue is within OnEnable and OnDisable?

swift crag
#

I see a problem with your code, although I thought you were just unsure about how to run some code in response to the performed event

#

the problem is that you never unsubsribe from those actions

#

suppose PlayerInputHandler turns on in scene A and subscribes to the events

#

then you switch to scene B

#

the old PlayerInputHandler is still subscribed to those events

#

In this case, I don't think it's going to cause any errors (all you do is store things in fields when the events are raised)

#

it is a "leak", though

small mantle
swift crag
#

the old PlayerInputHandler object will stick around forever

#

again, not exactly life-threatening

#

(from Unity's point of view, it's been destroyed -- but the C# object is still there!)

small mantle
swift crag
#

Ah, if it's a singleton in DontDestroyOnLoad, then this is fine

#

which I just noticed 😛

small mantle
#

So what can I do to make it tap only?

swift crag
#

so you want nothing to happen at all if you press and hold?

#

or do you just want one thing to happen?

small mantle
swift crag
#

I see.

#

So there are a few options here

#

One would be to have the player controller code set JumpTriggered back to false after using it

final totem
#

is there a funciton to completely restart the level, like reload it?

swift crag
#

Another would be to have an "On Jump" event on the player input handler. You would invoke it when the action is performed

#

The player code could then subscribe to the event.

small mantle
swift crag
#
if (input.JumpTriggered) {
  // do a jump
}
#

you can just set JumpTriggered back to false here

small mantle
small mantle
swift crag
#

which is exactly what you're looking for

#

note that SceneManager is in UnityEngine.SceneManagement, so you will need to add

#
using UnityEngine.SceneManagement;
#

Your IDE should suggest this.

small mantle
swift crag
#

that's exactly what i wrote, just with a different name :p

#

so i don't see a problem

small mantle
swift crag
#

Yes. I am talking about that boolean field.

#

The input action isn't involved here at all

small mantle
#

The InputAction is only effected here in the PlayerInputHandlerScriptcs jumpAction.performed += context => JumpTriggered = true; jumpAction.canceled += context => JumpTriggered = false; No where else

wintry quarry
#

use Update

swift crag
wintry quarry
#

or just do the thing in the performed callback

small mantle
wintry quarry
#

instead of using a bool like this

#

using a bool like this is not helping you

swift crag
#

I'm not talking about jumpAction at all. I'm talking about JumpTriggered.

wintry quarry
#
jumpAction.performed += context => // Actually do the jump here;```
swift crag
#

and yes, I think it'd make more sense for the PlayerInputHandler to just do something directly in response to the jump action being performed

small mantle
swift crag
#

(it can raise its own event that other things subscribe to)

wintry quarry
small mantle
wintry quarry
small mantle
#

To check if I pressed "jump" key

wintry quarry
#

to do what? To do the jump?

#

Just have the other script listen to the event

#

or make your own event here

#

OnJump

#

Invoke it here and have the other script listen to that

#

A bool variable doesn't make sense unless it's like a continuous thing

swift crag
#

It would be nice if you could press jump a few frames before hitting the ground.

wintry quarry
#

or if you make a method like this to consume it:

public bool TryConsumeJump() {
  bool toReturn = _isJumping;
  _isJumping = false;
  return toReturn;
}```
small mantle
swift crag
#

okay, so just do inputHandler.JumpTriggered = false; and you're done

#

that's what I was suggesting earlier

wintry quarry
#

And do:
if (groundRememberTime < rememberTimeStop && inputHandler.TryConsumeJump()) {

#

Fen's idea works too

small mantle
swift crag
#

by literally writing that exact line of code

#

jumpAction and JumpTriggered are two different variables

small mantle
swift crag
#

is that the code I told you to write?

swift crag
small mantle
#

What solution did you send?

small mantle
#

that would go into my JumpScript?

#

I don't understand on where you are saying to put that code

swift crag
#

Correct. It would reset inputHandler.JumpTriggered back to false after performing a jump.

wintry quarry
#

when you jump of course

small mantle
#

I understand now! Thanks for the help both of you. UnityChanThumbsUp

acoustic arch
#

!code

eternal falconBOT
acoustic arch
#

this is my enemy AI script, on line 73 the 2nd time the enemy attempts to make an action i get a null reference

#

but it should already be set from the functions that run prior in the battle runtime -

#
    void enemyRun()
    {
        enemyai.fillActions();
        Action action = enemyai.ChooseAction();
        //if (action != null) { Debug.Log(action); }
        enemyai.PerformAction(action);
    }
slender nymph
#

you probably have null entries in your actions list

acoustic arch
#

it checks the action before adding it if their null

slender nymph
#

remember, calling Add on a list does not replace any of the already null elements in it, it adds new elements to the list

slender nymph
acoustic arch
#

so i need to do some kind of Remove

#

list.Remove?

slender nymph
#

yes

acoustic arch
#

ill try it out

slender nymph
#

also that loop in your Reset method is pointless, just clear the list

acoustic arch
#

oh wait yeah i just saw

#

list.RemoveAll

slender nymph
#

List.Clear

acoustic arch
#

whats the difference

slender nymph
#

did you bother looking at what RemoveAll does?

acoustic arch
#

oh RemoveAll takes a type

#

to match

#

yo wtf

slender nymph
acoustic arch
#

oh something new to learn

slender nymph
#
  1. get your !IDE configured
  2. that is not the correct way to share !code
  3. rotate the bullet to face the gun's direction when you spawn it
eternal falconBOT
slender nymph
#

damn, dyno doesn't like two commands in one message. !IDE

eternal falconBOT
spiral narwhal
#

Why is this always false?

slender nymph
#

if _isGrounded is true it won't evaluate that. so the only time that can be evaluated is when _isGrounded is false

#

did you bother reading point 3 in my original message? and did you configure your IDE yet?

spiral narwhal
#

Oh because || immediately exits the call

acoustic arch
# slender nymph List.Clear

it worked, but if an invokerepeating starts after something is == true while in Update, will it keep running even if that is set to false?

#

cause thats whats happening to me

onyx cove
#

Hello is there an other way than transform.forward to get the orientation of a gameObject? because the forward is a vector and for example I don't know if it's facing me or not

slender nymph
polar acorn
wintry quarry
#

You would absolutely use transform.forward

#

A vector is exactly what you need

onyx cove
wintry quarry
polar acorn
slender nymph
#

the only time you wouldn't use transform.forward to get the direction an object is facing is when that object does not point along the Z axis (such as in 2d where objects typically point along the Y or X axes)

onyx cove
#

it returns this vector no ?

polar acorn
onyx cove
#

but even if it is oriented down it will return the same vector

polar acorn
#

It will return the object's forward direction

onyx cove
#

oh ok

#

thank you

slender nymph
#

set your tool handle to Local instead of Global and you'll see the object's actual forward direction

#

because it seems that the tool handle's orientation is confusing you when it comes to the actual orientation of the object

wintry quarry
#

If it's a 2D game you might want the red arrow which is transform.right

onyx cove
wintry quarry
#

Ok then yes use forward

next bolt
#

Hi I'm making a 2d game rn and I'm having trouble with a slider. I've made those before but for some reason it's not working. Ik its not the int because i see the health going down but the slider isnt moving

polar acorn
#

Show !code

eternal falconBOT
slender nymph
#

if the slider is for a health bar, i'd recommend using a filled image instead. but yeah, gotta show relevant code

next bolt
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; //for text

public class Bosscontroller : MonoBehaviour {

public int health;
public int dropdmg;
public float velocity;
public Slider healthBar;

public bool candrop;
public bool restart = true;


Animator anim;
Rigidbody2D rb2d;
AudioSource aud;
// Use this for initialization
void Start () {
    //componants
    rb2d = GetComponent<Rigidbody2D>();
    anim = GetComponent<Animator>();
    aud = GetComponent<AudioSource>();
    //health bar stuff
    healthBar = Instantiate(healthBar);
    healthBar.maxValue = health;
    healthBar.value = health;
    //put in an for loop in an if

    if (GameObject.Find("Player").GetComponent<Bossplayer>().hp >= 0)
    {
        //pause
        Hover();
        
        
    }
}

// Update is called once per frame
void Update () {
    healthBar.value = health;
    //keep from falling off
    //check for edge platform
    
    
}

void OnTriggerEnter2D(Collider2D other)
{
    if (other.tag == "Projectile")
    {
        Destroy(other.gameObject);//destroy bullet


        health--;

        if (health <= 0)
        {
            Destroy(healthBar.gameObject);
            Destroy(gameObject);
        }
    }

}
ivory bobcat
#

Specifically, the first section Large Code Blocks

eternal falconBOT
next bolt
#

i clicked the 2nd link

#

and pasted it

ivory bobcat
#

There should be a save button on the site.

rocky canyon
#

well we need the link it generates after u press the save button

ivory bobcat
#

Then copy the url here <link>

next bolt
#

oh i see

ivory bobcat
#

We get line numbers, some kind of syntax highlighting and whatnot. Much more legible.

slender nymph
#

i'd bet you are actually trying to use the existing slider rather than a clone of it

next bolt
#

yes i dragged that into the scene so it is a child of the canvas

#

theres no clone of it

slender nymph
#

but you Instantiate a new one and use that new one. so there is a clone of it

#

remove line 28

polar acorn
#

The game's already running by then

next bolt
#

@slender nymph that fixed it thank u

#

can you also have a look at my method hover real quick? i think the issue is the x value isnt changing even though ik it is because it's coming from another script

untold patrol
#

Currently trying to create a system similar to black ops zombies where you have to collects different parts from places around the map and once you have collected all of them can build an item with. im trying to find a guide or any of sort of tutorial on how i would go about this but cant really find anything. if anyone has any knowladge and could point me in the right direction that would be much appricated. thanks.

stuck palm
#

how can i check in code if a particle system is emitting but its paused?

#

nvm found it

#

isPaused

slender nymph
slender nymph
next bolt
#

the x value is taking the transform position of the player(which is tracked in update in another script) and teleporting above the postion of the player and then it drops

#

@slender nymph

slender nymph
#

that doesn't really answer any of what i asked

untold patrol
slender nymph
#

no tutorial is ever going to be exactly what you want. you need to watch the tutorial and understand what it does and why then adapt that knowledge to make what you want

next bolt
#

ok the method is supposed to bring the enemy over the player but after the first time he just teleports to the same spot. It's supoosed to move where the player is moving

slender nymph
#

but you set the x value to 0 then immediately use that value as the global position instead of getting the player's actual position

next bolt
#

Thank you so much bro

#

that fixed it i really appreciate it

rich adder
untold patrol
#

trying to import a map/level/scene from one project to another. it has a lot of differenet prefabs and stuff and materials. i tried importing the entire scene but everything goes pink and materials arent showing up and it just keeps breaking every time i try and import it. not quite sure if theres a better way to do it but most places ive looked say to just drag and drop from one project to another but isnt working

stuck palm
#

is there an unscaled update i can use?

rich adder
#

wdym by that

rich adder
stuck palm
#

just wondering if that was possible

rich adder
#

Update has nothing to do with that

#

FixedUpdate would

stuck palm
#

oh okay

#

thats fine then

#

thanks

#

i thought default update was also scaled with timesacle

rich adder
#

You could use Time.unscaledDeltaTime for anything else

stuck palm
#

okay

#

thank you 😄

acoustic arch
#

am i able to use waituntil bool == true without using a coroutine

rich adder
acoustic arch
#

invoke repeat kinda bad for this

#

i'm new to coroutine and asynchronous

#

sort of new

eternal needle
#

invoke and invokerepeat are mostly bad in general. you can explain the logic you're trying to do, and itll be way easier to help set it up with a coroutine

rich adder
eternal needle
#

just a note, coroutine and async are completely different

slender nymph
acoustic arch
#

alright i'm currently afk in heading back to pc now, i'll show the functions that need to be run for the enemy AI

acoustic arch
#

the script the repeat is in is large i'll cut off the unimportant bits real quick

eternal needle
#

ok surely we dont need to see every single one of these, when the question is just about converting invoke repeating to a coroutine 😅

acoustic arch
#

yeah only bother with the first

#

the others are if you need to see them

teal viper
#

No coroutines or invoke needed in this case.

acoustic arch
shrewd gazelle
#

Hello everyone does anyone of a way whete if I delete a unity project that it get completly deleted meaning that everything is gone including the scrips. Just to explain what Im trying to do im making a full platform game usually I like to name my scripts simple things like movement or health but when I delete the unity project so I can practice the platform again the scripts stay in the pc so anyone know how to make everything deleted when a project is deleted just so that I can save time instead of having to go after things and delete them one by one

slender nymph
#

the scripts are just files within your project folder. so if you delete the entire project folder, that includes deleting your scripts

eternal needle
teal viper
shrewd gazelle
slender nymph
#

how can you tell

rocky canyon
#

the only thing left behind would be the temp files in ur %appdata% folder..

shrewd gazelle
#

I search the name the visual studio script is still there

rocky canyon
#

if u delete the folder where are ur files sticking around??

acoustic arch
shrewd gazelle
#

Visual studio

teal viper
acoustic arch
#

i could easily make it wait till it's at the right energy before using it, but it would lock the enemy ai up from changing

slender nymph
teal viper
rocky canyon
#

if u close VisualStudio.. and reopen it.. it wont find no scripts.. the .sln file won't be able to be found after the project folder is deleted

shrewd gazelle
#

Ill try making a game again and close visual and come back to you guys

#

But thanks for the info

rocky canyon
#

this is the file that keeps up with ur scripts names and whatnot..

#

it should also get deleted when the project folder is deleted

eternal needle
# acoustic arch got any idea how to make the ai wait for the energy bar to be at the right amoun...

there is probably a lot of code id have to look through to even understand your setup. The basic idea would be that you have one central place where AI can choose their abilities. Then compare the current energy to how much an ability would take.
If you want to add features like waiting for a certain ability, even though it is able to use another then this is gonna be a lot more complicated and i probably cant help with that

teal viper
acoustic arch
teal viper
magic pendant
#

Hello people, I don't know if it is the corresponding channel (I hope so) but what is the best way to open a prefab door? I feel that when I rotate in Y the door is super narrow and looks weird hahaha. How do you do it? or the best way to do it.

deft grail
magic pendant
deft grail
#

and try rotating that

small mantle
#

I am trying to implement a Platform type of obstacle. I want the player to be able to jump through it One Way. This was easy with the Platformer Effector. However when I hold the "jump key" the Player after passing the obstacle launches up again, as if it was jumping again. This happens because the Player gets in contact with the Platform which has a layer that lets the player jump. This is not what I want, as I want the Player to land, then be able to jump. The solution is simple, make the "jump input" false when the player presses it, however it isn't what I need. I also want the Player to hold jump to give a high jump. How can I solve this issue?

Code```cs
private void FixedUpdate() {
//Regular Jump
if (isGrounded && inputHandler.JumpTriggered) {
Jump();
}
// Make jump input false when falling
if (rb.velocity.y < 0.0f) {
inputHandler.JumpTriggered = false;
}
// Short Jump Logic
if (rb.velocity.y > 0.0f && !inputHandler.JumpTriggered) {

        rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * jumpCutMultiplier);
    }
    
}
void Jump() {
    rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}```
acoustic arch
#

my enemy ai kinda works it actually attacks now 😱

twilit pilot
small mantle
twilit pilot
#

I don't see what holding jump for a higher jump has to do with that

small mantle
#

What solution do you have? @twilit pilot

twilit pilot
#

as an idea, perhaps consider what it means to be "isGrounded" - if you're moving upwards, you're probably not grounded yet

small mantle
twilit pilot
#

did you not write the code that decides when you're grounded?

small mantle
twilit pilot
#

yes, this is what you could consider changing so it properly matches your idea of what being grounded, and able to jump, actually means

#

as you've found this is going to be set to true if you're jumping through the platform

#

but why would you be grounded if you're still moving up?

#

how can you land on a surface if you're moving up?

#

an alternative could be to fix your inputs to differentiate between being pressed and being held, so regular jumps wont interfere with holding at all

small mantle
#

@twilit pilot I found an easy solution, but am not sure if it may be dept for later. Anyways this is what I did cs if (isGrounded && rb.velocity.y < 1.0f) { jumps = 0; } Essentially I just needed to lock jumping with a variable, and every time you jump you add to this "jumps" variable. The jump code cannot jump if it already has "jumps" = 1. So this code above just checks if the Palyer is on the ground and the velocity in the Y axis is less than 1.

#

You helped me realize it was the isGrounded variable that caused this issue. Thank you! UnityChanThumbsUp

nimble apex
#
screen.resolutions``` allows u to get supported resolutions to the device itself

what about unsupported resolutions?
#

like if im using a mac or a PC, it will only pass landscape resolutions

but what about portrait one?

teal viper
nimble apex
#

the games im going to make is a cross platform apps, it can be played on PC or on mac as well , not only for smartphones

but my team was asked to make the app being able to have "landscape" and "portrait" behaviour on mac/PC as well

#

we wont accept letting users to resize it, if they allow us to do i dont even need to bother with this

rocky canyon
#

playing games on PC in portrait mode.. thats interesting

eternal needle
#

can you not just set whatever resolution you want? if its windowed mode especially

nimble apex
#

our current way is to "give a bunch of resolutions to users , and let them choose, whatever platform they wanna play"

#

thats it lol

#

little bit offtopic but it is also normal in those famous games right?

#

if u choose windowed mode, tho portrait simulation part is quite weird lmao

eternal needle
#

if you arent on windowed mode, its gonna look like complete ass

nimble apex
rocky canyon
#

designing a game in general that works in both portrait and landscape would be a heck of a task from the get go..

nimble apex
#

so its still not too bad lol

rocky canyon
#

i couldn't imagine it being a good game catering to both

#

just an opinion ofc

eternal needle
#

unless the user like really wants this on the side of their screen, which most games handle by letting them resize as they want

#

which also is only available in windowed mode

nimble apex
#

i just gonna walk the old way

#
      //portrait resolution : 3/4 (0.75) only , based on provided landscape resolutions, calculated only
      //landscape resolution : 16/9 (1.7777...) only
      if (1.76f <= ((float)r.width / (float)r.height) && ((float)r.width / (float)r.height) <= 1.78f)
      {
        int portraitHeight = Mathf.RoundToInt(r.width * 1.33333333f);

        landscapeResolutions.Add(r);

        if (GameManager.Instance.isLandscape)
        {
          newOptionData = new OptionData(GetResolutionText(r));
        }

        //calculate portrait resolution
        Resolution generatedRes = new Resolution();
        generatedRes.width = r.width;
        generatedRes.height = portraitHeight;

        portraitResolutions.Add(generatedRes);

        if (!GameManager.Instance.isLandscape)
        {
          newOptionData = new OptionData(GetResolutionText(generatedRes));
        }
      }```
#

basically, in landscape mode, filter all non 16/9 resolutions

#

if in portrait mode, based on obtained 16/9 resolutions , calculate it to make it into a 3/4 resolution

topaz mortar
#

An apple a day keeps the NullReferenceError away!

willow scroll
topaz mortar
#

Trying to find a bug in some complex combat logic for 2 days, found 7 other major bugs before finally finding the one I was looking for 😆

zinc shuttle
#

need help with code
can i paste code here

modest dust
#

Describe what kind of help you need and paste your !code after reading the bot message below

eternal falconBOT
modest dust
#

... read the bot message.

modest dust
#

And now read it again

#

You're closer but still not quite there.

zinc shuttle
#

small question
no errors

modest dust
#

Yeah, but first format your code correctly or use a paste site.

languid spire
#

definitely, use a paste site

modest dust
#

```cs
Your code here
```

zinc shuttle
#

the if statement in the code execute all 5 kills together how can i prevent that

modest dust
#

Use else if and take a C# course if you didn't know about that

languid spire
modest dust
#

Or that

#

Also all of these have a common bit, which is collision.gameObject.CompareTag("Enemy")

zinc shuttle
languid spire
#

@zinc shuttle Pro tip. Whenever you find yourself writing code like that, with lots of copy/paste. It means you should be using an Array

modest dust
stuck crest
#

hello guys

#

i cant seem to use raycast for checking if my player is grounded or not