#💻┃code-beginner

1 messages · Page 352 of 1

wintry quarry
#

And TextMeshPro etc are also components

dull saffron
#

ohhh yes

#

that makes sense

wintry quarry
#

These are the basic building blocks of Unity

dull saffron
#

that makes a lot of sense tysm

violet glacier
#

Hi, I currently have used object pool for damage popups and it works. However, how do I have the latest popup be on top (sorted on of previous popups). It's currently fetching a gameobject popup that could be before the current fetched popup, making it render behind.

wintry quarry
violet glacier
wintry quarry
#

SpriteRenderer?

#

UI Elements?

#

Something else?

dull saffron
#

ok now i have put a setactive on the game object, how do i call that script in this method?

wintry quarry
violet glacier
wintry quarry
#

ok so it's a MeshRenderer

violet glacier
wintry quarry
#

Oh actually it's a TestMeshPro 3d text

dull saffron
wintry quarry
violet glacier
#

Textmesh pro yes

wintry quarry
dull saffron
#

no but the lose condition is in another script

#

and im activating when the countdown starts

#

not when the game starts

wintry quarry
#

I really don't understand what you're talking about

#

Are you confusing activating the timer with showing the timer UI?

dull saffron
#

yes i mean to show the timer

#

at a certain point

wintry quarry
#

Your question isn't clear to me, nor how your game is supposed to work

dull saffron
#

my bad

violet glacier
silk fossil
#

guys I amade domain expansion and I feel it coming

#

Question: for a scrollbar, how am I supposed to change a variable which is in a different scene from the scrollbar?

wintry quarry
#

This is just a question of "how do I get a reference to a script in another scene"

#

The answer is through any means you wish basically, except direct inspector references

#

that's the only thing you can't do.

#

Everything else is fair game

#

Singletons, FindWithTag

#

etc

silk fossil
#

can I make a script where it calls the variable I need from another script than attatch it for the scrollbar?

wintry quarry
#

You can do whatever you'd like, sure

silk fossil
#

alr tnx

dull saffron
#

ok so thgis is my countdown, and i want to call it in the checkGameOver, because it is the death countdown

hasty sleet
#

Initially, 1 * Time.DeltaTime should just be reduced to Time.DeltaTime

dull saffron
#

why is that

#

oopps

#

caps

hasty sleet
#

1 times any number is the same number

dull saffron
#

oops your right

hasty sleet
#

So Time.DeltaTime times 1 is Time.DeltaTimes

dull saffron
#

but do u know how to call that countdown in the checkGameOver method

hasty sleet
#

If a function returns an IEnumerator value, then you should call it using StartCoroutine(FunctionThatReturnsIEnumerator())

#

But I don't know why it returns an ienumerator

#

CheckGameOver sounds like something that maybe shouldn't need to take 5 seconds of ienumeration

#

Also, StartCount is never used

dull saffron
#

to be honest i watched a tutorial

willow scroll
willow scroll
dull saffron
#

what is your coroutine

willow scroll
dull saffron
#

is it literally a function called "YourCoroutine" or is my coroutine StartCountdown

willow scroll
#

Which you should know more about than me

dull saffron
#

i dont bc i suck bruh

hasty sleet
# dull saffron i dont bc i suck bruh

I recommend you focus on fundamentals, like coding fundamentals (for-loop, while-loop, if-else statmeents), and Unity fundamentals (GameObject vs Transform, Rigidbody, learning transform.translate and rigidbody.move, gameObject.destroy, and more.

#

If you start off past your depth by following tutorials, you'll probably remain confused for a while because you're a few layers deeper than where learning can occur more efficiently.

Once you understand C# syntax and Unity engine basics, you can start messing with more advanced topics and retaining more information

dull saffron
#

ill check those out thanks

onyx tusk
#

how 2 make self-deleting client?

toxic shell
#

Hello, I need help with animation. I got two things. A fireball and explosion. How do i call the explosion after fireball animation?

slender nymph
#

use an animation event

toxic shell
toxic shell
barren meteor
languid spire
barren meteor
#

ok so I am still not sure where to go

#

does my code need changing or some properties from the character

eager spindle
#

use rb.movebody

#

rather than transform.position += ...

#

also having your character move that fast will probably cause issues

#

are you using rigidbody or charactercontroller

barren meteor
#

rigidbody

eager spindle
#

ok use rb movebody + Continuous interpolation

barren meteor
#

do I replace this as well

eager spindle
#

smth like this

#

this is in fixedupdate

barren meteor
#

is this right?

#

because you said rb.movebody before

eager spindle
#

rb moveposiion*

#

also rb moveposition is a function

willow scroll
# barren meteor is this right?

MovePosition moves the Rigidbody to the position, specified in the 1st parameter. It doesn't increase or decrease it by the value. The 1st parameter should include the previous position added to the value

barren meteor
#

what do I add

willow scroll
barren meteor
willow scroll
#

the value should be added to the position

willow scroll
barren meteor
eager spindle
#

? you just add your movement vector to your position

#

its like

#

setting transform.position = value

willow scroll
#

Basically the transform.position in the current frame

barren meteor
#

ok I changed it to this

m_rigidBody.MovePosition(m_rigidBody.position + transform.forward * m_currentV * m_moveSpeed * Time.deltaTime);

and this
m_rigidBody.MovePosition(m_rigidBody.position + m_currentDirection * m_moveSpeed * Time.deltaTime);

I don't think it's right but it doesn't give an error

eager spindle
#

looks correct

#

you'd put this in fixedupdate

#

and use fixedDeltaTime

barren meteor
#

I don't feel a difference between my first code and that code

eager spindle
#

if its still causing issues i have a crude solution

barren meteor
#

ok then

willow scroll
eager spindle
#

change this to 100

eager spindle
#

i thought it was different

willow scroll
#

I also thought some time ago 😉

willow scroll
#

Is the player not being moved?

barren meteor
#

but the player does move

#

I think my terrain is a bit too steep too

#

but thanks guys!

willow scroll
barren meteor
#

also what even is that

eager spindle
#

displaces the player faster

willow scroll
#

The maximum default velocity needed to move a Rigidbody's collider out of another collider's surface penetration. Must be positive.

#

Do you need that?

#

Note: Very large values can introduce instability during collision detection; too small values might cause the collider depenetration to fail.

barren meteor
#

well if I find any other collision issues then I might have to change it

#

but I think it will be fine

willow scroll
#

Leave it 10.

barren meteor
#

what do you mean instability during collision detection

eager spindle
#

the only bad thing is that if your player collides with a barrel or smth the barrel will fly away much more

valid roost
#

How can I fix my sprite from activating the jump animation while standing on an edge

real rock
#

I’m guessing it’s because you set the jump animation whenever the sprite isn’t grounded so just change the logic for either the ground check or the animation

valid roost
#

Alright thanks

topaz arrow
#

Anyone able to provide a basic explanation on why i am unable to use the new input system to move an ingame cursor using the mouse pointer and a gamepad's right stick?

#

maybe im just dumb!

real rock
#

Not without any code or vague insight into your settings

topaz arrow
#

i can answer questions related

#

like how many input actions it has etc.

topaz thistle
#

I've got code that allows a UI to be enabled whenever a trigger is triggered and the key J is hit. However, it works randomly and does not work ever time I hit "J". https://hastebin.com/share/fatohehuve.csharp

topaz arrow
#

i cant see anything from just a quick glance

#

make sure the player is near the merchant bool is true when you press J

topaz thistle
topaz arrow
#

add a

else
{

Debug.LogError("Player is not near merchant!");

}

topaz thistle
languid spire
topaz thistle
topaz arrow
#

thats what i thought , which is why i said move to a normal void Update()

languid spire
topaz thistle
#

Makes sense, mb one sec.

topaz arrow
#

Also heres the relevant screenshot of my cursor controller that im trying to get to work using the new input system

topaz thistle
topaz arrow
languid spire
topaz thistle
topaz arrow
languid spire
#

the rest can stay in Update

topaz arrow
#

i honestly dont know!

i usually use Update() if im running timers or something

languid spire
topaz arrow
#

ahh thats why i rarely use it lol , i dont use physics really

topaz thistle
#

What about my rbG = ...? Should this be in update or fixed?

topaz arrow
#

i guess it would depend how many times you want it to run per frame

languid spire
crisp saddle
#

anyone know what this symbol is?

#

sorry for small image

topaz arrow
#

bracket 0 bracket

languid spire
#

you mean the brackets?

crisp saddle
topaz arrow
languid spire
#

that will be the number zero

topaz arrow
#

looks like a 0

crisp saddle
#

I thought it was the theta symbol

deft grail
crisp saddle
#

thank you though :)

languid spire
#

no, that would be strange to use as an indexer

topaz thistle
#

The debug statement on line 104 appears

#

But the actual UI does not

deft grail
#

are you setting it to false somewhere else right after/same time

topaz arrow
#

i do stuff like store a list of something and then ill create a method to get the IndexOf(item) to get the index then i can do the opposite to get the item again by doing listToAccess[indexfrombefore]

topaz thistle
#

OK, so it is appearing, but I guess for only a split second

topaz arrow
#

combine this with saving and loading its nice

topaz thistle
#

For some reason, it appears and dissapears instantly

languid spire
# topaz thistle For some reason, it appears and dissapears instantly

read and weep

if (Input.GetKeyDown(KeyCode.J) && isPlayerNearMerchant)
        {
            merchantUI.SetActive(true); // Player entering Merchant UI
            Debug.Log("WOKRS YESSSS");
        }

        if (Input.GetKeyDown(KeyCode.J) && isPlayerNearMerchant && merchantUI.activeSelf == true)
        {
            merchantUI.SetActive(false); // Player exiting Merchant UI
        }
deft grail
topaz thistle
#

Yeah, I did. That's how I figured that out.

#

I've noticed some games are able to make it so that If I click a button, it opens until I click it again.

#

How could I do this?

languid spire
#

add an else statement

sly peak
#

would someone be able to help me figure out what these errors are cause by and how i can fix them?

deft grail
languid spire
#

or

if (Input.GetKeyDown(KeyCode.J) && isPlayerNearMerchant)
        {
            merchantUI.SetActive(!merchantUI.activeSelf); // Player entering Merchant UI
            Debug.Log("WOKRS YESSSS");
        }

sly peak
topaz thistle
deft grail
topaz thistle
sly peak
deft grail
sly peak
#

you fixed both errors

queen adder
#
    public void OnPointerEnter(PointerEventData eventData)
    {

        transform.localPosition += new Vector3(0, hoverOffset, 0);

    }

    public void OnPointerExit(PointerEventData eventData)
    {
        transform.localPosition -= new Vector3(0, hoverOffset, 0);
    }

How can I move the object while its in a horizontal layout group?

#

Currently it does not move at all, I assume its the group thats overriding it

deft grail
queen adder
#

oh

hexed terrace
#

and .anchoredPosition

#

You won't be able to move anything while the layout group is in control though. Either disable it when moving things, or move a child of the thing you want to move

brisk flume
#

hi i just have a question
i have 0 knowledge about code and i tried to learn how to code c# for the untiy engine via tutorials but i get stuck in what is known as " tutorial hell" ending up not knowing a how to do to a single thing

so is the first step learning how to code c# through making games or should i learn c# alone first

hexed terrace
#

It'd be good to know the basics of C# first.. like what's a class, type, method, param, variable, accessor, property, field.. etc

vocal sail
#
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.AI;

public class MonsterMovement : MonoBehaviour {

    [SerializeField] private MainManager mainManager;
    private Transform playerPosition;
    [SerializeField] public NavMeshAgent agent;
    [SerializeField] public float baseSpeed = 3.5f;
    [SerializeField] public float speedMultiplier = 1.0f;

    private void Start() {
        mainManager = FindObjectOfType<MainManager>().mainManager;
        playerPosition = FindObjectOfType<PlayerMovement>().transform;
        agent = GetComponent<NavMeshAgent>();

        mainManager.OnGameStart += GameStart;
        mainManager.OnFreezeRemove += ResetSpeed;

        agent.speed = baseSpeed;
    }

    private void GameStart() {
        InvokeRepeating("UpdateDestination", 0.5f, 0.5f);
        StartCoroutine(PassiveSpeedUp());
    }

    private void UpdateDestination() {
        agent.SetDestination(playerPosition.position);
    }

    private void OnTriggerEnter(Collider other) {
        if (other.CompareTag("Player")) {
            mainManager.PlayerCaught();
        }
    }

    private IEnumerator PassiveSpeedUp() {
        while (speedMultiplier < 2) {
            speedMultiplier += 0.2f;
            agent.speed = baseSpeed * speedMultiplier;
            Debug.Log("SpeedMult: " + speedMultiplier);
            yield return new WaitForSeconds(1.0f);
        }
        Debug.Log("Reached Full Speed");
    }

    private void ResetSpeed() {
        bool flag = false;
        if (speedMultiplier < 2) {
            flag = true;
        }
        speedMultiplier = 0f;
        agent.speed = baseSpeed;
        if (flag) {
            StartCoroutine(PassiveSpeedUp());
        }
    }
}```
Here is my code, I aim to make a npc do a linear speed increase using coroutine, but the script ends up make the speed multiplier bounce around and invokes the log inside multiple times instead of output it once a second. What could be the problem?
#

the log output looks like this, not sure why the IEnumerator invokes more than once? I have no idea why, I appreciates any help.

hexed terrace
#

Either GameStart() or ResetSpeed() is being called multiple times

vocal sail
#

hmm I've checked that I used a event system calls OnGameStart event on Start(), and Reset Speed() is only called when player collides to a object which I checked isn't on my test run at all

#

and the logs go skyrocked 2 seconds since start

hexed terrace
#

uncollapse you're logs, and follow the stack trace... you'll see where things are coming from

#

but from the code you've shared, only those two places call the coroutine.. so for all we can see, one or both of those two must be getting called multiple times

vocal sail
#

I found the problem I was checking if the npc is freezed in a update function

#

I can solve the rest of the problem myself, appreciated for the help

kindred halo
#
transform.Rotate(Vector3.left * mouseY);
transform.Rotate(Vector3.up * mouseX);```
can we clamp these values?
wintry quarry
#

Not while using that technique

languid spire
slender nymph
kindred halo
languid spire
kindred halo
keen dew
#

Clamping mouseX doesn't do anything useful

languid spire
#

Absolutely, I suspect he wants to clamp the resulting rotation which as @wintry quarry said' you cant get there from here' (sorry for the paraphrase)

#

typical XY problem

languid spire
kindred halo
slender nymph
#

don't multiply mouse input by deltaTime, it is already framerate independent so doing that multiplication just ends up making it stuttery

languid spire
#

and that answers my question, how?

languid spire
real rock
#

So try and clearly lay out what you want the camera to do and how you expect it to behave because a lot of people have this issue aswell 🙂

kindred halo
languid spire
real rock
languid spire
kindred halo
languid spire
kindred halo
languid spire
kindred halo
real rock
#

Yes and no

slender nymph
#

maybe someday they'll bother to take my advice

real rock
#

Same method but with some logic in the middle, loads of people have solved this issue so I seriously recommend searching it

languid spire
languid spire
kindred halo
languid spire
real rock
#

I was about to say not sure how that would be any easier than a quaternion at that point hehe

frail laurel
#

but how do i make it?

wintry quarry
#

Disable it

frail laurel
#

after it dies?

wintry quarry
#

Yes

frail laurel
#

i tried adding but the script still doesn't disable

wintry quarry
#

it's unclear what other wscripts this is interacting with

#

i.e. which script is actually handling the input and calling these functions?

#

that's the one you should be disabling

frail laurel
#

how do i fix this

wintry quarry
#

no idea what that is

swift crag
#

Is there any more text in the console? Look at the bottom half.

#

I think I remember seeing this once...

#

ah, it's because this is from native code

#

SUCCEEDED is a macro in windows code that you can use to check if an operationg succeeded

topaz thistle
#

I just got this error when trying to open my html file in my build. Urgent. Trying to submit for Game Jam

swift crag
#

the error explains the problem

#

Your browser will not let a webpage open other files on your computer

#

using Build and Run will start a web server to play the game for you

#

alternatively, you can upload it to something like Itch and play it on there

wintry quarry
#

( you can also use any other wweb server you want, including nginx etc)

swift crag
#

python -m http.server my mostly beloved

topaz thistle
#

Sorry if I seem rushy, submission is due in 25mins

swift crag
#

before you do that: do you have python installed on your computer?

topaz thistle
#

Yes

swift crag
#

you can check by opening Powershell and running python

#

okay -- go to your built game and shift-right-click an empty spot in explorer

#

an option to open a powershell window should appear

#

(or maybe a command prompt window)

topaz thistle
#

The issue is not viewing my game

#

The issue is the judges viewing the game

#

If they have to go through all of this, they won't judge it

swift crag
#

Uploading it to Itch would make it easy, then

topaz thistle
#

How do i do that without the zip-download method?

swift crag
#

you can configure your project to be played in-browser

topaz thistle
#

Where is that?

swift crag
#

you'll have to actually create a project on Itch first

topaz thistle
#

Yup

#

Sorry, first time using itch

swift crag
#

"Kind of project" is one of the settings when creating the project (you can also change it after creation)

#

zip up the entire build directory and upload it

topaz thistle
#

GOT IT

#

One issue

#

How do i change the size?

#

It's zoomed in

#

(Don't judge my trash game xD)

swift crag
#

adjust the viewport dimensions

#

1280x720 is reasonable

topaz thistle
#

Thank you so much!

normal juniper
#

Im an absolute beginner and have a big problem...
Im trying to learn by doing with Youtube tuto. and I don't know why I can't fill code automatically as shown in the Video. The video also shows that I should use “Assembly-CSharp” as a script. Please help me

eternal falconBOT
normal juniper
hexed terrace
eternal falconBOT
#
Visual Studio guide

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

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

hexed terrace
#

configure your VS

fluid remnant
#

after many years in Unity, don't think this has happened before. What is going on here?


    private IEnumerator Start()
    {
        yield return new WaitForFixedUpdate();
        endP = target.position;

    }
 private void OnDrawGizmos()
    {
        if (Application.isPlaying)
        {
            Gizmos.color = Color.yellow;
            Gizmos.DrawSphere(startP, 0.24f);

            Gizmos.color = Color.red;
            Gizmos.DrawSphere(endP, 0.24f);
        }
    }```
Why is the red dot all the way out here?
wintry quarry
fluid remnant
#

yeah but how?

hexed terrace
#

because you put it there somehow

fluid remnant
#

target.position is the object I have selected

wintry quarry
fluid remnant
#

Pivot/Local

wintry quarry
#

Make sure it's set to Pivot

#

Ok good.

fluid remnant
#

Unity 6 bug?

hexed terrace
#

unlikely

wintry quarry
#

So perhaps your object has moved since Start ran, that seems most likely

fluid remnant
#

weird. I also set wait for fixed update just in case

#

also disabled its agent, same problem

teal viper
fluid remnant
#

to be honest, idk what else I could share. I never had such a basic issue before

#

that's all there is to the code and the scene is basic

languid spire
teal viper
fluid remnant
teal viper
fluid remnant
#

sure but startP is kinda irrelevant

teal viper
#

And endP

#

Or rather, what is assigned to it.

fluid remnant
teal viper
#

What is target? Where do you set it?

languid spire
fluid remnant
#

I am basically trying to do what Navmesh link does, but placing start/end dynamically instead of scene view

#

the 'something' method I have commented out in the code sent, it was originally in Start until things went, well weird.

teal viper
fluid remnant
#

like this?

teal viper
#

With the object selected

fluid remnant
#

you can see the yellow is the Vector3.zero since it has not assigned pos.
The red position, no idea why that is there

#

curious I'm gonna try this same code on 2022

languid spire
#

why is Start a Coroutine? you do know it only runs once

wintry quarry
#

Which is the capsule

#

It's some other object

fluid remnant
wintry quarry
#

called TestNavLinkCreation

#

where is the TestNavLinkCreation object

fluid remnant
teal viper
#

Interesting.🤔

teal viper
fluid remnant
#

sure, a ray or a line ?

teal viper
#

Line

fluid remnant
#

well isn't that interesting

teal viper
#

And the red gizmo is still far away?

fluid remnant
#

yup

#
  private void Update()
    {
        Debug.DrawLine(transform.position, target.position);
        Debug.DrawLine(transform.position, endP);
    }```
#

hmm let me try to assign endP in update

#

wtf

#
  private void Update()
    {
        endP = target.position;
        Debug.DrawLine(transform.position, target.position);
        Debug.DrawLine(transform.position, endP);
    }```
wintry quarry
#

why not just use target.position in the first place

#

why cache it

fluid remnant
#

I need to do some fancy stuff with it, mainly NavMesh.SamplePosition etc.

teal viper
fluid remnant
#

oh sorry i thought I sent ss

queen adder
#

We need game developers for a game called "Mortal Company" on the playstore made by unity, you should be experienced with coding in unity, you sadly won't be paid yet until the game gets famous.

dm me for more information

fluid remnant
#

this is after assigning endP = target.position in update

hexed terrace
teal viper
eternal falconBOT
fluid remnant
queen adder
languid spire
queen adder
#

ok

hexed terrace
fluid remnant
fluid remnant
#

since its back assigned in update , I will try moving target and see what happens

fluid remnant
#

I know right!

#

wtf this is like unity 101 stuff making me go looney

teal viper
#

There must be some simple reason that happens that were missing.

fluid remnant
#

when I move target

#

some freaky shit going on

rocky canyon
#

yup.. it appears that way.. i'd walk ur way backwards and test 1 thing at a time until u can figure out what thing causes the odd behaviour

teal viper
#

I guess, wouldn't change much

fluid remnant
#

with Target selected?

teal viper
#

Yes

rocky canyon
#

are we seeing Unity's NavMesh Gizmo's or are these custom Gizmo's

fluid remnant
#

they are simple Gizmos.DrawSphere

rocky canyon
#

and the lines too? soo they're from your method?

fluid remnant
hexed terrace
#

scroll up spawn

fluid remnant
#

pivot at same location

rocky canyon
#

just brain storming.. alot of times theres guys that will draw gizmo's that are different from their logic..

#

without noticing..

verbal dome
#

Could try setting Gizmos.matrix = Matrix4x4.Identity before drawing

#

In case its using some other matrix

rocky canyon
#

not saying thats what u did, but im just throwing out ideas

teal viper
rocky canyon
hexed terrace
rich adder
#

same code in unity 2022

#

on a diff pc so same account sorry

#

m1nd is my account as well but at work , sorry for confusion lol

teal viper
#

Do the gizmos draw in local space?

rocky canyon
#

ohhhh!! we have a spy

rich adder
rocky canyon
#

shoulda led with you being navarone... that way we're not making bias'd newbie assumptions

rich adder
teal viper
verbal dome
#

Have you tried resetting unity? Sometimes gizmos just get messed up

rocky canyon
#

mmhmm.. i read thru it all.. i can't see anything wrong

hexed terrace
rocky canyon
rich adder
#

now I showed on my pc unity 2022 same code

rocky canyon
#

ohh right right.. nvm

verbal dome
hexed terrace
#

both are incorrectly drawn, but in different ways

rich adder
#

oh its lowercase 😛
edit: didn't help though

rocky canyon
hexed terrace
rocky canyon
#

for some reason those images are [ ... ] dots

rich adder
#

I used unity over 3 years, never seen this before

rocky canyon
#

my discord acting goofy this morning

rocky canyon
rich adder
#

has to be because drawline is going to the correct spot

#

wish we had Debug.DrawSphere or whatever

#

but as you can see

 var newObj = new GameObject("Hellothere");
newObj.transform.position = startP;``` I tried this
and it does the same weird shit, when i press F to focus its far away
#

the Z position is like stuck somehow..

willow breach
#

how can i debugg unity on vscode? i tried doezen launch.json but all fails

valid roost
valid roost
#

can anyone help me fix this i have no clue why my character phases through the ground

willow breach
valid roost
#

wym

rich adder
valid roost
#

okay

verbal dome
#

Might wanna use continuous collision detection

#

If 2d has that

rich adder
valid roost
#

i'll give it a go

verbal dome
rich adder
valid roost
#

mhm

rocky canyon
valid roost
rocky canyon
#

has to be something to do with the navmesh / agents right?

willow breach
verbal dome
#

Does target have a navmesh agent? Or what object

rich adder
frail laurel
#

how to make a timer when the game would start the timer would be 30 seconds and the player has to push the obstacle within 30 seconds if he pushes the obstacle the timer would add 5 seconds and diffrent time in each level i got 3 levels

rich adder
verbal dome
#

An agent could very well mess with transform.position

deft grail
rich adder
willow breach
rich adder
#

Oh fuck

#

im dumb as hell

#

consolation, I'm glad my eyes aren't the only ones missing carrots today...

#

sorry every1

rich adder
willow breach
valid roost
#

does anyone have any idea of a fix

rich adder
#

this?

willow breach
#

yes

rocky canyon
rich adder
# valid roost

mate when you post a problem you have to send code too, we cannot guess

rich adder
rocky canyon
#

what was it?

rich adder
#

my brain aint braining this morning

rocky canyon
#

lmao.. ohh that issue

rocky canyon
#

yea, they need a fix for that

rocky canyon
#

haha!

willow breach
rich adder
rocky canyon
rich adder
valid roost
rocky canyon
#

@rich adder since ur here.. do u know how to solve this?
not really broken or anything.. but being used to VStudio I regularly type void out of habit..

rich adder
#

its not like "smart snippets" or something

rocky canyon
#

ya, thats my solution too.. but since i still do it 2/5 times i wondered if i could change a setting or something to deal

frail laurel
rich adder
rocky canyon
#

👍 alright.. atleast im in good company..

#

was just checking

rich adder
#

haha yeah one of the few things that annoys me about vscode but its worth it more than VS mac

rocky canyon
#

i been lately omitting private access modifier

rich adder
willow breach
#

i have been tryign to make this work for 2h but cant understand why its parsing it to empty strings and 0 numbers...
and cant seem to get the debugger working to check whats wrong..
can anyone help? 🙏🏼
https://codeshare.io/8Xqr0B

valid roost
rocky canyon
#

but i guess its better practice to keep them around

#

i could go and edit the snippets to remove em i guess

rich adder
rocky canyon
#

composite

valid roost
#

alright thanks

rich adder
#

i think you're seeing the infamous ghost collisions

valid roost
#

i see

rocky canyon
#

in 2D theres also a Polygon(al) collider

#

might be what we're thinking of

valid roost
rocky canyon
#

it'd be 1 solid collider for each platform..

#

vs abunch of tile/square colliders.. which controller tend to get stuck on

rich adder
#

but it doesn't mark it as kinematic / static

rocky canyon
#

just untick Simulated

#

or remove the RB

rich adder
#

I think you need RB for composite to work

rocky canyon
#

or static/kinematic

rich adder
#

yeah use static

rocky canyon
valid roost
#

I have RB

#

to my player

#

and platform

#

im pretty sure

rich adder
#

the player is irrelevant

rocky canyon
#

well thats fine.. just tick it as not simulated or mark it as static or kinematic like me and nav suggested

rich adder
#

when you added composite collider it adds the rigidbody, just mark it as static

rocky canyon
#

(the platform not the player)

valid roost
#

where do i do that

rocky canyon
#

static = solid objects in scene that dont move.. (a tree for example)

rich adder
rocky canyon
#

on the rigidbody

valid roost
#

ohh

#

right

rocky canyon
#

it is called Composite collider 👍

#

search results make u think it could be called Polygon collider

valid roost
#

oh now

#

my player just falls out of the map

rocky canyon
#

mark it as not simulated

rich adder
rocky canyon
#

and leave it non-static

valid roost
rich adder
#

I think you do want simulation just static though

#

thats what makes it participate in collisions with physics

#

it just wont move since its "Static"

rocky canyon
#

why his player falling thru i reckon?

rich adder
#

rn cause its not simulated

valid roost
#

alright ticking simulated fixed it

rich adder
#

so its not even part of physics scene

rocky canyon
#

ohh i thought he had it marked simulated

#

good job team!

rich adder
#

afaik Unity does 2 scenes, one for physics simulations and one for showing the transforms / visuals etc..

valid roost
#

thank you both anyway

rocky canyon
#

😄 i just sitting in the spectator stands..

#

shouting absurdities

valid roost
#

sigh

#

it still gets stuck

rich adder
#

dang

#

thats all i know in terms of 2D and tiles :\

rocky canyon
#

my 2D scene is set up a little less than useful

rocky canyon
#

seems to be as easy as ticking a box on ur tilemap collider 2d component

rich adder
#

ah yes make sure that is ticked

valid roost
#

mhm but i dont see that option at all

rich adder
#

right there

valid roost
#

OH

rocky canyon
#

lol.. 👀

valid roost
#

im blind

#

LMFAO

rich adder
#

happen to me before too no worries on a much bigger scale 😛

rocky canyon
#

<insert t-rex gif>

stand perfectly still, it won't see us.

rich adder
#

🦖

rocky canyon
rich adder
#

but but 2...is right next to 3.. :ahh

#

ima just blame my dyslexia lol

rocky canyon
#

i know i know.. its okay...
no one will know..

valid roost
#

🙇🏻‍♂️

rich adder
#

it work?

valid roost
#

mhm

#

it did

#

thank you both

rich adder
#

aye 🥳

#

teamwork make da dream work

willow breach
rich adder
#

updated all the packages etc.

#

a lot has changed since VSCode and unity was a thing

willow breach
rich adder
#

not really

#

vscode is as lightweight as you can get imo

#

are you using the new Unity vscode plugin and the latest Visual Studio Editor package ?

rocky canyon
#

When we type a function its implicity private so for example
void TakeDamage() is the same as private void TakeDamage();
Now, with an interface is it opposite?

namespace SPWN
{
    public interface IInteractable
    { void Interact(); } // this is implicitly public??
}```
rich adder
#

right

rocky canyon
#

good to know

frail laurel
#

Need help with the script timer the seconds going so slow and it says 29,9f seconds i want it to only say 30 seconds then 29 seconds and it supposted when player pushes the obstacle the timer would add 5 seconds https://hastebin.com/share/abuyizevep.csharp https://hastebin.com/share/etozupetag.csharp pls help 🙂

willow breach
rich adder
#

ohh

#

wrong package

#

Visual Studio Code Editor needs to be removed

#

you need Visual Studio Editor

#

to be at least 2.0.20

willow breach
rich adder
#

yes

#

then show your External Tools page in unity
you should have Vscode selected and have its version shown there

dusty shell
#

Could someone help me figure out touch input, or at least where to start

rich adder
#

also now with new input system you got new ways to do it

dusty shell
#

I wanna make a mobile platformer

#

But can't figure out how to add touch movement

rich adder
dusty shell
willow breach
#

its the latest

rich adder
#

anyway you can untick all those except first two

#

try Regen Project files

willow breach
#

same issue ):

#

this is so frustrating...

rich adder
#

have you like, tried to search it ?

#

for the error i mean

willow breach
#

for 2 hours

rich adder
#

could be a bug

willow breach
#

its a very generic error, doesnt say much

rich adder
#

are you on windows or mac?

willow breach
#

windows

rich adder
#

could be a permission issue

willow breach
#

the ports are open on the FW

rich adder
#

I think it tries to start like a mini server or somethinglike that

#

Closed both VS code unity (this fixes the attachment issue but not when it locks up unity)

#

try the logging

willow breach
#

yeah, but didnt help

rich adder
#

yea its weird, we have the same versions it seems but mine works fine

#

I think only time debugger wast working for me in VScode was back when it was going through old way with disabling modern .net or whatever

#

back then it was only c# extension and some hail marys

willow breach
rich adder
#

NullReferenceException: Object reference not set to an instance of an object. niceee

willow breach
#

is it from my code? or some configuration?

rich adder
#

doubt it, do you attach it while unity simulation is running already ?

willow breach
#

tried eiter way

rich adder
#

I wonder what its trying to reference

#

Im gonna chalk it up to OS being dookie. Windows been slipping since 7

willow breach
#

ill ask on redit maybe someone know

rich adder
#

must be permission related / network

#

the miniserver or whatever its trying to do with localhost

willow breach
#

i think so too but i checked the FW and vscode have all the ports open

dusty shell
#

This might be a dumb question but how do I read this values?

swift crag
#

what is the context?

#

where is this screenshot from?

dusty shell
#

the documentation for touch input

hallow totem
#
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    private CharacterController controller;
    public float speed = 12f;

    Vector3 velocity;

    private Vector3 lastPosition = new Vector3(0f,0f,0f);


    void Start()
    {
        controller = GetComponent<CharacterController>();    
    }

    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * z + transform.forward * -x;
        controller.Move(move * speed * Time.deltaTime);
    }
}
using System.Collections.Generic;
using UnityEngine;

public class MouseMovement : MonoBehaviour
{
    public float mouseSensitivity = 100f;
    float yRotation = 0f;
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;

        yRotation += mouseX;

        transform.localRotation = Quaternion.Euler(0f, yRotation, 0f);
    }
}

Any idea why my character swerves to the sides while going backward? It didn't happen when I was testing it in the preview window but when I did a build it started doing so.

wintry quarry
hallow totem
#

What should I be doing then?

wintry quarry
#

not multiplying moouse input by Time.deltaTime

#

You're doing a thing. You should be not doing that thing instead.

#

Specifically here:

float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;```
rich adder
wintry quarry
#

(you will need to reduce the value of mouseSensitivity in the inspector by a lot to compensate, perhaps down to like 1)

frail laurel
#

Is there anyone who understand timer scripts?

rich adder
#

or is your rotations just placed inverted

rich adder
hallow totem
#

I'm not sure honestly, when I followed the tutorial they were inverted so I swapped it around.

hallow totem
#

They aren't inverted anymore but even after deleting the multiplication it still swerves while going backwards.

rich adder
polar acorn
# frail laurel here

If you don't want any decimal places, don't include them in your number format string

dusty shell
polar acorn
#

.ToString("0") will just display the whole numbers

#

you could also cast to int before printing

hallow totem
#

Uh, sec, let me convert that to mp4.

rich adder
hallow totem
frail laurel
dusty shell
polar acorn
frail laurel
#

done

#

now works propretly thanks

hallow totem
honest haven
#

hi im using additive scene loading but when i instanciate a object some time it does it to the wrong scene public void PlayParticleEffect(GameObject effectPrefab) { if (effectPrefab != null) { if (effectPrefab == groundSmokePuff) { GameObject effectInstance = Instantiate(effectPrefab, this.transform.position + transform.up * 0.53f, Quaternion.identity); Destroy(effectInstance, effectInstance.GetComponent<ParticleSystem>().main.duration); } else { GameObject effectInstance = Instantiate(effectPrefab, this.transform.position, Quaternion.identity); Destroy(effectInstance, effectInstance.GetComponent<ParticleSystem>().main.duration); } } }

mystic carbon
#

hey guys quick question, for some reason I cant find the save settings button on the player settings tab..
I can change it, but as soon as I rehit the play button, it default back

#

I am trying to allow unsafe code.

honest haven
#

so the one i highlighted should be in the battle scene

dull saffron
#

im still having trouble inserting this countDown method into another script at this same point in time

wintry quarry
dull saffron
#

oh yeah

wintry quarry
#

it's unclear what you are trying to do

dull saffron
#

i meant

#

the startCount method within that class

wintry quarry
#

YOu mean StartCount?

dull saffron
#

yes

wintry quarry
#

You want to call StartCount?

dull saffron
#

i do in another class

wintry quarry
#

Do the same thing you did there

#

you need a reference to the countDown script instance

#

and then you call StartCount on it

#

BTW in C# best practice is to name your classes with PascalCase not camelCase

#

Your current naming causes confusion

dull saffron
#

got it

wintry quarry
#

same for methods

dull saffron
#

so you know in a game when youre about to lose, lets say you reach the limit and you dont lose immediately, it gives you like 5 seconds to get below the limit before you lose

#

thats basically what im doing

wintry quarry
#

I mean it doesn't really matter, we're talking about the basics of referencing and calling methods here

#

If you want to call a method on a script, you need a reference to an instance of that script, and you call the method on that reference

dull saffron
#

okay ll check that out

#

thanks

dull saffron
wintry quarry
#

You haven't actually explained at all what issue you're having

#

You just said

im still having trouble inserting this countDown method into another script
But you didn't go into any details about what kind of trouble

dull saffron
#

im not sure how to reference it properly

#

thats my issue

wintry quarry
#

Why not just do what you did before

#

you said you did it once already

#

Basic primer on references^

sterile plover
#

how can i make my cam.transform.Translate use the currentZoom for a max and a minimum zoom ????

rich adder
#

also can you send the current code via links

#

also show your character's gizmos/pivots

wintry quarry
sterile plover
hallow totem
wintry quarry
#

how so?

hallow totem
frail laurel
#

How to make when gameOverUI shows the playercontroller script would disable

rich adder
wintry quarry
#

Anyway, no you can't clamp with transform.Translate. You would have to change how you're doing it to set the position directly yourself and clamp those positions independently.

#

or just clamp the position after Translating. Your choice.

rich adder
sterile plover
# sterile plover cause the fov making the zoom look weird

like i just want to make the camera nearer from my player beceause its a 3rd person camera game if i zoom with fov it will be weird (already tried it) and i would like to make the camera rotate infront of the direction im zooming in, so if i use fov it will zoom in the horizon and i wont be able to see my player

sterile plover
wintry quarry
wintry quarry
rich adder
#

^^ at least for movement and stuff

#

not sure what changing FOV is doing rn that is "Weird"

wintry quarry
#

You can build a house with your bare hands but it's way easier if you use the right tools.

wintry quarry
rich adder
#

have to know what exactly is front/back etc.. on player

sterile plover
rich adder
#

thats what zooming is though
its how real camera works anyway, you can't zoom easy without increasing the mm of the camera which reduces the "wide" angle you see with lower mm cameras

wintry quarry
#

regardless

#

just use Cinemachine

#

Make two virtual cameras with your two desired configurations and switch between them

sterile plover
rich adder
#

yeah two cameras with cinemachine then, each one at your desired distance / fovs
it automagically handles the smoothing, you can adjust that

rich adder
# hallow totem

oof so your forward is transform.right
(ideally should be the blue arrow transform.forward)

#

also send the current move script via links !code

eternal falconBOT
hallow totem
sterile plover
# wintry quarry Make two virtual cameras with your two desired configurations and switch between...

my camera only does 4 thing : it is always tilt to the bottom a little like isometric games

  • freecam where you can move freely in horizontals axis
  • rotate around on y axis
  • lock in the player instead of freecam
  • "zoom" where you can make the camera nearer or further from the direction the camera facing in

idk if i explained well again but the camera does nearly the same thing as BG3 camera with a sort of isometric camera that you can zoom to make it more like a horizontal camera and still move the camera freely, can i make this with one cinemachine camera you think ?? (cause i switch to cinemachine i could just remake the whole camera system and make it better anyway)

rich adder
hallow totem
#

Sure.

magic panther
#

real quick, why is the out RaycastHit hitInfo not working?

onFloor = Physics.Raycast(transform.position, new Vector3(0f, -1f, 0f), playerSize / 2 + 0.25f, out RaycastHit hitInfo);
hallow totem
swift crag
#

what does "not working" mean?

magic panther
#

an error

swift crag
#

hat trick

wintry quarry
rich adder
#

error tells you whats wrong

swift crag
polar acorn
swift crag
#

outsped 😎

magic panther
#

yes, a layermask, from what I see, but I don't need it. What do I write in there, then?

swift crag
#

that is not the fourth argument when using the version that provides a RaycastHit

short hazel
#

There are multiple overloads, scroll down the page

swift crag
#

you will want to look at the one that actually gives you a RaycastHit, yes

rich adder
magic panther
#

oooooh

#

I think I see it

#

hold up

magic panther
rich adder
#

new Vector3(0f, -1f, 0f) this can just be Vector3.down :p

regal bear
#

Hey, beginner developer, just doing my first project, i really enjoyed Database management gui like Navicat, HeidiSQL etc. Im just making a singleplayer game so i don't have any databases. but is there something like these? Create, edit data in like a table? For example items for an RPG game, monsters, weapon damage, level req etc..

rich adder
#

like excel ?

hallow totem
#

Then again it doesn't really happen if I play in the preview window so I'm not sure how helpful this is.

rich adder
#

wdym in the preview window

main anchor
#

so how could i potentially fix this?

regal bear
short hazel
regal bear
rich adder
#

only if you put them in a db otherwise you have to make your own

short hazel
#

Nothing built-in

magic panther
#

(wall script is empty, unused

magic panther
#

first two arguments are correct

rich adder
#

check the signature mate

#

the docs or your IDE should tell you

wintry quarry
short hazel
#

Look at the documentation, it's a bit different

magic panther
#

where is the documentation? Is there a shortcut in visual studio?

rich adder
#

you can hover the function it tells you all the signatures

hallow totem
rich adder
hallow totem
#

Yup.

magic panther
rich adder
#

do you have a controller maybe causing stick drift ? @hallow totem

#

although i think unity would read controller too

short hazel
magic panther
#

oh

#

so now I check if there is a collided object?

short hazel
#

Example has that

#

Scroll down

rich adder
#

iirc you can directly do
grounded = Physics2D.Raycast etc.
if(grounded!=null)

hallow totem
magic panther
#
        RaycastHit hitFloor = Physics2D.Raycast(transform.position, new Vector2(0f, -1f), playerSize / 2 + 0.25f);
        onFloor = hitFloor != null;
#

something is very wrong here

rich adder
#

RayacastHit2D

wintry quarry
#

RaycastHit2D*

rich adder
#

noone saw that 😛

magic panther
#

my bad

#

lemme test it

wintry quarry
#

but really - you can just do cs onFloor = Physics2D.Raycast(...)

#

you don't need the intermediate variable

#

RaycastHit2D is implicitly converted to bool.

magic panther
#

I need the hit object data

#

Also how do I check if something was hit? If It's bool, I want it to be the hit object, and onFloor to be whether the object exists or not

wintry quarry
rich adder
short hazel
rocky canyon
# main anchor so how could i potentially fix this?

make the thing smaller..
whatever detecting when you become grounded be it,

  • raycast
  • sphere collider
  • or w/e
    so it doesn't actually become grounded until ur just above the ground..
    that should make it so when the anti-gravity effect goes into affect you're about to collide with the ground anyway
prime cobalt
#

How do I set which virtualcam the cinemachine brain is tageting in programming? I want to make sure in multiplayer the camera is following the correct player's cinemachine virtual cam.

rich adder
#

nothing to do with multiplayer, that has to do with who controls the owner of cam

hallow totem
rich adder
#

each player has their own cinemachine brain

rich adder
#

would be the quickest and "dirty" way

#

probably overkill rn though, you just need to debug the move values and see if its the one causing movement

prime cobalt
# rich adder the cinemachine cares about priority

So if I raise the priority of the cinemachine they control and don't make that variable spread to other players then it'll follow then it'll follow the correct one? I'll try that. Sorry this netcode stuff melts my brain it's hard.

wintry quarry
wintry quarry
rich adder
wintry quarry
#

Often, you should destroy such extra cameras as part of the initialization of "other player" objects

rich adder
#

are you Instantiating the players with their own cams ?

#

cause yea you would have to delete it if its IsOwner == false

prime cobalt
rich adder
rocky canyon
# rocky canyon make the thing smaller.. whatever detecting when you become grounded be it, - ra...

@main anchor adding to that, I know it's possible because my Character Controller also uses a function to apply a different gravity when grounded ** vs** when not grounded

    private void ApplyGravity()
    {
        if (characterController.isGrounded && gravitySim < playerSettings.gravity)
            gravitySim = playerSettings.gravity;

        gravitySim += playerSettings.gravity * Time.deltaTime;
    }

gravitySim is the Y velocity being added to the CC via the Move(); function, and
playerSettings.gravity is my desired gravity, I tend to use -10.5f

rich adder
#

characterController.isGrounded 😬

#

I guess it works for basic use cases but that thing does suck

dull saffron
#

i have a new idea, i want to play an audio clip at this point, how do i do that?

rich adder
#

also whats good with that formatting

rocky canyon
rocky canyon
#

bout the only reason I have it is for my little head bob when you land from jumping 😄

rocky canyon
#

but it uses raycasts instead of spheres

rich adder
rocky canyon
rich adder
rocky canyon
# rich adder `characterController.isGrounded` 😬

oh yea, keep in mind My prototype projects are all open-sourced free or custom assets..
i don't usually show my production stuff in here too often..

my production controller also uses raycasts but its a bit more advanced 😉

rich adder
#

woa look at that fancy inspector

rocky canyon
#

the guy thats typing right now..

#

he's the one that inspired that head bob thing

rich adder
honest haven
#
    {
        if (hammerValue >= 1f)
        {
            return 0;
        }
        if (hammerValue <= 0.745f)
        {
            return 1;
        }
        if (hammerValue > 0.745f && hammerValue <= 0.833f)
        {
            return 8;
        }
        if (hammerValue > 0.833f && hammerValue <= 0.915f)
        {
            return 14;
        }
        if (hammerValue > 0.915f && hammerValue < 1f)
        {
            return 8;
        }

        return 0; 
    }``` i seemed to have copied the slider values but in game play if i hit say just under 0.833f it returns 14 rather then 8. am i doing anything wrong here.
rich adder
#

why are there such specific values esp with floats

delicate portal
honest haven
rich adder
#

for all you know it could be 0.83399
which could be bigger than assuming it was 0.833000

rocky canyon
honest haven
#

well i was moving the slider to get it to line up with my eyes

short hazel
rich adder
honest haven
short hazel
#

Whatever you're passing as an argument to that method is not what you're expecting it to be

rich adder
honest haven
short hazel
honest haven
#

thank you

rocky canyon
#

don't judge. i had to search my garbage bin to find it 😅 MODULUS no where to be found

honest haven
rich adder
short hazel
#

The compiler will then use top-level statements to execute your code

rich adder
#

you should also debug.log in unity what the actual value you're getting

rocky canyon
rocky canyon
#

no! idk why people keep saying that..
its completely different.. and completely original

#

lol

rich adder
#

lmao that cannon ricochet

#

11/10 game was too realistic

honest haven
#

this is the first time i have ever seen you helpers show of some game stuff its cool

rocky canyon
rocky canyon
rich adder
#

haha yea

rocky canyon
rich adder
rocky canyon
#

also, i dont wanna reveal any 1,000,000 dollar game idea by accident ya, know 😄

frail laurel
rocky canyon
honest haven
eternal falconBOT
silk night
rich adder
rocky canyon
honest haven
#

nice sounds good.

rocky canyon
rich adder
rocky canyon
rich adder
rocky canyon
#

i just did the 3d models for that one

honest haven
#

do you win any prizes for gamejams

rocky canyon
rich adder
#

has an interesting aesthetic

rocky canyon
#

kosmiq is the space shooter im working on

rocky canyon
rich adder
#

delorean ayooo

rocky canyon
rich adder
#

oh right its dolerito

#

delorean's cousin

rocky canyon
#

yea that'll work.

honest haven
rocky canyon
#

whats wrong with it?

#

you mean the one u just posted about?

rocky canyon
rich adder
rocky canyon
#

ya, dudes come a long way in here

#

for sure

honest haven
#

cheers, were on like year 4 haha

rocky canyon
#

it happens, i've pushed back my release date 2 times already

#

it says Spring or Summer of 2025 for now.. 🤞

honest haven
#

i spent the first 3 years doing it in 2d and then changed lol

honest haven
rocky canyon
#

ouch

#

good thing about that tho, is u probably have a pretty nice 2d template u can work from now

dull saffron
#

how do i play an audio source at this point ?

rocky canyon
#

audioSourceReference.Play();
audioSourceReference.PlayOneShot();