#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 407 of 1

rocky canyon
#

ya, i can imagine.. i build my levels with a big buffer zone.. and wide open so i dont have to deal with that

#

actually i only do first person.. soo idk what tf im talkin about ๐Ÿ˜„

half egret
#

Easy solution to camera avoidance, stencil buffer to keyhole the player no matter what's in the way. Like NWN:EE does it

#

not "easy" but a fun one

rocky canyon
#

urp?

half egret
#

not mine, it's from neverwinter nights, 20 year old game ๐Ÿ˜ญ

#

runs on aurora

rocky canyon
#

ohh booo ur tricking us

rocky canyon
#

i can barely read sorry ๐Ÿ˜„

half egret
#

S'all good, wish I was that clean with my stencils ๐Ÿ˜„

rocky canyon
#

i see picture and go "whoo.. picture.."

rocky canyon
half egret
#

Though the initial stage of the project was a pain because uhh, I went URP->HDRP->URP

#

Had to convert all my assets twice

#

next time: branch it

rocky canyon
#

i barely been giving my production progress any attention

#

took me a long time to get a menu and save system working..

#

now im thinking my list of scene indices is a bad choice.. since now i need a cutscene to stick in place of element 1

#

and soooo all the others would need dropped down a spot

#

thats gonna be bad to work w/

rocky canyon
#

unless u specifically need something from HDRP like volumetrics

half egret
#

I really wanted volumetrics, but the lack of support for a lot of existing unity tooling (E.g. terrain tools being severely messed up) was enough for me to scrap volumetrics and instead rely on screenspace fog.

rocky canyon
#

use third party volumetrics

half egret
#

I couuuuuuuuuuuld, it's not a bad idea.

#

hmmm i'll look around

#

I've seen really good URP volumetric solutions

rocky canyon
half egret
#

But they've usually been OTT for my purposes

rocky canyon
#

i tend to tint my fog to match the very bottom of the skybox (horizon)

#

loooks good.. but also looks "samey"

rocky canyon
half egret
rocky canyon
#

but im down w/ that.. i bought my character controller.. i see it as an investment for systems that are heavily relied on

rocky canyon
#

havent decided how to texture just yet

#

i wrote this soo long ago.. im lost

#

commentless

#

why tf am i passing in a scene and not using it ๐Ÿค”

#

ohh nvm thats a unity function

#
    public int[] GetSceneIndex = new int[12]
    { 2,3,4,5,6,7,8,9,10,11,12,13 };

    public int GetSceneIndexFromChapter(int chapter)
    {
        if(chapter >= 0 && chapter < GetSceneIndex.Length)
        {
            return GetSceneIndex[chapter];
        }
        else
        {
            Dbug.Error("Chapter can't be converted to scene");
            LOAD.ShowErrorScreen();
            return -1;
        }
    }```
#

gross lol

#

i musta been high when i wrote this.. ๐Ÿซฃ

#

honestly dont know how to fix it...

#

welp, ignore me.. i was rambling.. i have to take a minute to figure out how i wrote this.. and the flow it takes

cosmic dagger
queen adder
#

Hey guys, I'm making a cookie clicker like system where a building generates a bps (butter per second) and adds it to a stack in the game manager with the other buildings, and the game manager uses that total bps to generate butter per second.

#

In my Game Manager, I have this code:

        get { return baseBpsStack; }
        set { BaseBpsStack = value; RefreshBaseBps(); }
    }
    
    public float BaseBps{
        get { return baseBps; }
        set { baseBps = value; }
    }
    
    public float score;

    public List<float> baseBpsStack;
#

And I have a script called SpawnButterOverTime which is attached to every building that spawns in butter. Every building also has a building script.
Here is the building script:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class Building : MonoBehaviour
{
    public ShopItem itemData;

    public GameObject itemIcon;
    public GameObject itemNameText;
    public GameObject itemCostText;
    public GameObject itemAmountText;

    [HideInInspector] public string name;
    [HideInInspector] public float cost;
    public int amount {
        get { return Amount; }
        set {
            Amount = value;
            if(itemData.bps > 0){
                GetComponent<SpawnButterOverTime>().CalculateBps();
            }
        }
    }

    public int Amount;

    void Awake()
    {
        name = itemData.itemName;
        cost = itemData.itemCost;
        amount = itemData.itemAmount;
        itemNameText.GetComponent<TextMeshProUGUI>().SetText(name);
        itemCostText.GetComponent<TextMeshProUGUI>().SetText(cost.ToString());
        itemAmountText.GetComponent<TextMeshProUGUI>().SetText(amount.ToString());
        itemIcon.GetComponent<Image>().sprite = itemData.itemIcon;    
    }

    void Update()
    {
        
    }
}
#

And here is the SpawnButterOverTime script:

using System.Collections.Generic;
using UnityEngine;

public class SpawnButterOverTime : MonoBehaviour
{
    [SerializeField] Building buildingInstance;

    [HideInInspector] public float bps{
        get{ return BPS; }
        set{
            Debug.Log(GameManager.Instance.BaseBpsStack);
            if(GameManager.Instance.BaseBpsStack.Contains(bps)){
                GameManager.Instance.BaseBpsStack.Remove(bps);
            }
            BPS = value; 
            RefreshBuildingBps(); 
            GameManager.Instance.RefreshBaseBps();
        }
    }

    [HideInInspector] public float BPS;

    void Start(){
        CalculateBps();
    }

    public void CalculateBps(){
        bps = GetComponent<Building>().itemData.bps * GetComponent<Building>().amount;
    }

    void RefreshBuildingBps()
    {
        GameManager.Instance.BaseBpsStack.Add(bps);
    }
}
#

The problem I have is that whenever I run the code, it generates this output:

#

I have 3 building objects placed down thus 3 building script instances, thus I think each error is only occuring once in the building script.

#

Does anyone know why I may be getting this error?

rocky canyon
#

and i can only imagine how that'd end up the more scenes i have to add to it

#

but i have to get there first.. gotta follow the flow of the game-manager.. im not very good w/ breakpoints

#

if i write all these out on scratch paper i can probably keep up with them and update it just here and there

rocky canyon
#

the code is trying to access something that isn't assigned correctly

#

line 12 of SpawnButterOverTime

#

bps = GetComponent<Building>().itemData.bps * GetComponent<Building>().amount; what is this syntax? im not even familiar w/ that

#

ohh nvm its two values being multiplied ๐Ÿคฆโ€โ™‚๏ธ lol

queen adder
#

ohhh sorry ๐Ÿ˜ญ

rocky canyon
#

lol, dont be sorry

queen adder
rocky canyon
#

whats line 12?

queen adder
#

the debug.log

cosmic dagger
rocky canyon
#

but ive never used one.. soo ๐Ÿ€

cosmic dagger
rocky canyon
#

thats good enough for me โค๏ธ

queen adder
# rocky canyon whats line 12?

i have a scriptable object that holds their data and i calculate bps based off of their multipliers in the scriptable, that's what the line is for. But line 12 apparently is the debug.log. Even if i remove the debug.log it still says line 12.

#

clicking on the error again gives me this

rocky canyon
#

yea, its not actually 12.. it might be a little before or after

queen adder
#

yeah

#

this is the whole error

rocky canyon
#

CalculateBps is ur error

queen adder
#

that's the thing

#

it fails once and works later

cosmic dagger
# queen adder

No need for [HideInInspector] for the bps property as properties don't appear in the inspector unless you manually add an attribute . . .

queen adder
#

here it's giving me correct values

rocky canyon
#

i do that too.. for editor stuff i assign a texture publicly and then hide it

queen adder
#

is it because it can't detect the list?

#

i'm trying to debug log the list but it's not coming up

rocky canyon
#

but i coulda just used the Debug version of the inspector to assign it i guess

rocky canyon
queen adder
#

yes

#

but the list is correct

#

after failing once

rocky canyon
#

weird that its working and failing

#

yea

queen adder
#

this is where i define the list

#

no no it's not working and failing

#

it's failing and working

rocky canyon
#

ohh my bad lol

queen adder
#

lol

#

for some reason

#

trying to access the list is giving it an error

#

but why can it not access this list?

#

until later?

rocky canyon
#

maybe its not initialized yet.. and then it is?

#

just spitballing

queen adder
#

but the code above is initializing it at the very start

#

the baseBpsStack;

#

and when i go into my inspector the buildings script is automatically disabled on runtime

cosmic dagger
queen adder
#

ohhh i gotchu

#

i'll remove it, thank you

slender nymph
#

That's declaration not initialization

queen adder
#

this line of code is giving me the error

slender nymph
#

Then GameManager.Instance is null

queen adder
#

No it is not

#

Debug logging GameManager.Instance gives me a return

cosmic dagger
queen adder
#

That is not null

#

No not at all

#

This is also how it's being defined

slender nymph
cosmic dagger
#

That's the only common denominator between that line and the debug log line . . .

rocky canyon
#

debug the value of GameManager and Instance b4 the debug

#

and see for sure

queen adder
#

Alright

#

Alr now i'll log it twice

rocky canyon
#

nice! lol

cosmic dagger
#

Just check the value of both. There's obviously an error and we can't do anything but wait until you tell/show us . . .

rocky canyon
#

๐Ÿ‘€

queen adder
#

You're right

rocky canyon
#

usually we are ๐Ÿ˜‰

queen adder
#

Ummmm why is it null ๐Ÿ’€

rocky canyon
#

good question

slender nymph
#

Because you are accessing it before Awake has run on that component

rocky canyon
#

mmhmm.. i concur

queen adder
rocky canyon
#

i change my execution orders manually

#

buuut... theres better ways

slender nymph
#

Access the Instance property no sooner than in Start

rocky canyon
#

i had a hell of a problem with this kind of stuff as soon as i start making real game managers..

queen adder
#

Ohhhhhh that's cool

#

Alright let's see now

rocky canyon
#

๐Ÿคž

queen adder
#

It works ๐Ÿ˜„

#

When i earn 10000000 dollars from this game I'll dedicate it to you guys
fr

rocky canyon
#

screenshotted

queen adder
#

Yes

cosmic dagger
rocky canyon
#

lesson is.. never assume things

#

yes exactly!

queen adder
#

Yeah alright

rocky canyon
#

debug stuff regardless

queen adder
#

I will never make this mistake again โ˜ ๏ธ

rocky canyon
#

good luck w/ ur next section

queen adder
#

thanks bro

#

butter clicker all the way

rocky canyon
#

heck ya! w/e that means ๐Ÿคฃ

queen adder
#

lol ๐Ÿ˜‚

rocky canyon
#

chatgpt roasting me

#

his code is still subpar.. mines better.. ofc

queen adder
#

Lol

#

Does anyone know why changing a value in inspector doesn't trigger the set or get property

rocky canyon
#

u need to use Editor OnValidate() type stuff i believe

queen adder
#

Ohhhh

slender nymph
#

why would it? it's the backing field that is serialized and being edited in the inspector, not the property

rocky canyon
#

might be able to rig something up to do it

#

maybe not tho.. im not big into getters and setters yet

queen adder
#

i'll see might not be worth it to go through that

#

but i'll check it out

#

thanks bro

rocky canyon
#

i like editor scripting ๐Ÿ™‚ its a good change of pace

cosmic dagger
foggy void
#

I have a gameobject called "Load" and this "Load" has a component called "Thing". "Thing" creates a gameobject primitive cube. And that works just fine. But if I have it create another primitive cube. A crash occurs. Does anyone have any ideas?

namespace Redacted
{
    class Thing : MonoBehaviour
    {
        private GameObject leftPlatform;
        private GameObject rightPlatform;

        public void Start()
        {
            if (Redacted != null)
            {
                leftPlatform = GameObject.CreatePrimitive(PrimitiveType.Cube);
                leftPlatform.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                leftPlatform.transform.position = GorillaLocomotion.Player.Instance.leftControllerTransform.position;
                leftPlatform.transform.rotation = GorillaLocomotion.Player.Instance.leftControllerTransform.rotation * Quaternion.Euler(0f, 0f, -90f);
                leftPlatform.SetActive(false);

                rightPlatform = GameObject.CreatePrimitive(PrimitiveType.Cube);
                rightPlatform.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                rightPlatform.transform.position = GorillaLocomotion.Player.Instance.rightControllerTransform.position;
                rightPlatform.transform.rotation = GorillaLocomotion.Player.Instance.rightControllerTransform.rotation * Quaternion.Euler(0f, 0f, -90f);
                rightPlatform.SetActive(false);
            }
        }```
#

(More towards modding but it follows the same principles)

#

Perhaps components just cant host multiple gameobjects or I have some kind of name looping over?

rocky canyon
#

thats the problem

sick storm
#

can anyone help me with fixing my walljump code

#

i have got it to work

#

but it works like half the time

#

or pretty much randomly

rich adder
sick storm
#

do you want me to just copy and paste it

graceful crescent
#

!code

eternal falconBOT
graceful crescent
#

Do something like this

sick storm
cosmic dagger
# sick storm

Read the link and use the websites listed to post code . . .

rich adder
graceful crescent
sick storm
#

will post soon

#

dw i got you guys now

graceful crescent
#

ighty

#

we'll wait

sick storm
#

(in like an hour sorry)

wanton kraken
#

anyone got an idea as to why my player character (smiley) won't properly collide with the obstacles (red)? please ignore the horrible temporary assets lmao

#

to be clear, it should be colliding fully with the obstacles. but instead of bumping into the sides of them, it's only bumping into the middle :l

foggy void
#

If I create 2 gameobjects within the same script it causes a crash but I tried seperating it into 2 different scripts and it worked

rich adder
wanton kraken
#

this is true, i'm rather confused

#

it being my first time with a tilemap doesn't help much lol

rocky canyon
#

if you have colliders and rigidbodies on em i could guess that ur using translation to move it maybe?

wanton kraken
#

not sure? i'm moving the character by adding force relative to it's position

rich adder
wanton kraken
#

you got it. please no flaming

#

if (Input.GetKey(KeyCode.W) == true) {
Player.AddRelativeForce(Vector3.up * MoveSpeed);
}

#

this is the code to move the player up, super simple

rocky canyon
#

oh. yea thats fine.. wouldnt cause a no-collision situation

rich adder
wanton kraken
#

player collider seems fine

rich adder
#

ah well

#

fine?

wanton kraken
#

oh shit

#

i misread that. well then

#

hold on a moment lmao

#

why is the answer to my problems always my own stupidity

cosmic dagger
wanton kraken
#

i don't know lmao, i suppose that's the problem? hold on

#

its ok now... we dont talk about that

#

thank you for fixing my stupidity once again navarone

cosmic dagger
#

collision will only occur with the box. anything else will pass through other objects . . .

wanton kraken
#

the fun never stops around here

wanton kraken
keen palm
#

how can i slow down - boost speed with CharacterController.velocity just like Rigidbody.velocity

eternal needle
#

If you want to move it further, give it a vector with higher magnitude

sick storm
#

here is the code for my walljump

#

it works randomly

#

i don't think it is any collision issues

#

could someone please help?

sick storm
graceful crescent
#

Have you tried putting the if (isJumping) code in an Update void?
This might be a contributing reason as to why the wall-jump code works randomly.

#

@sick storm

sick storm
#

Yeah

#

It let me jump all the time

#

But i would only jump up

#

Straight up

#

And the wall jump would happen randomly

#

Like the fixed update

#

While fixed update only lets me wall jump but randomly

graceful crescent
#

Have you tried doing the WallJump() function in Update()?
FixedUpdate only runs under a specific rate provided in the editor
Maybe try doing the function in Update (called every frame)

sick storm
#

Did that

#

But it wprked the same as fixed update

#

I tried both at the same time

#

Didnt work

#

Tried just not having it as a function and putting it in update

graceful crescent
#

have you also checked your colliders?
This can affect the script too

#

if not then i advise checking

sick storm
#

I put a debug message to tell me when im wall sliding

#

And it always says i am when hugging a wall

#

Which means all i have to do is press jump

#

But thay works half of the time

#

And the wallslide code works

graceful crescent
#

Maybe you can set a ground check
So that the function will only trigger when you're not grounded

#

as in, standing on ground

sick storm
#

I tried that

#

Same resuly

#

I put a ground check in the if statement but nothing changed

graceful crescent
#

Does the problem still persist even after recompiling or restarting the editor?

sick storm
#

Yeah

graceful crescent
#

is this scene 3d? i'll try to recreate the problem myself with the code provided

sick storm
#

2d

graceful crescent
#

ahh alright

sick storm
#

Thanks

#

I have tried sooo much

graceful crescent
#

can you send scene view of the player in DMs?

#

imma see what i can do

sick storm
#

Yeah alr

graceful crescent
#

Also noticed you're using Visual Scripting too

sick storm
#

Yeah

severe spear
eager spindle
#

we dont know what your vsc config looks like so we're not sure how to help

severe spear
#

wait

fossil drum
#

!ide

eternal falconBOT
fossil drum
#

Ah that's the same one, it's updated.

severe spear
eager spindle
#

do you really love vsc that much

raw token
severe spear
eager spindle
#

huh

#

whats the error there

#

do you have enough ram for it

inner fiber
#

Hi, I downloaded for the first time and I can't open a new project

severe spear
eager spindle
#

yes

#

min 8

snow merlin
#

hey all. i have a mega basic character script, nothing fancy at all. i can walk lol.

What would be the best way to apply a talent/skill to my character? should i make my talents scriptable objects and add them to a list on the player character? that's kind of what im going for, but i cant make the selected talent scriptable objects actually apply to the player currently - so i was wondering if there was another 'best practice way' or if i should stick to this until it works.

I'm pretty new to all of this, i don't know whats best from a design perspective.

severe spear
raw token
eager spindle
#

like how do the functions in your scriptable object apply to the player

chrome pilot
#

Do you think it makes sense to learn normal C# and then switch to Unity C#?

eager spindle
#

yes

#

you should have a good grasp on c# and what object oriented programming is, itll make your life in unity much easier

chrome pilot
#

Thanks for your assistance.

severe spear
raw token
severe spear
raw token
# severe spear is there a solution for this?

I'm not really sure... I use VS for Unity, myself - when I started the VSC extension was unmaintained and lacked debugger support, so I defaulted to VS and never gave VSC a run...

The only things I could think to do in your situation are just generic steps which I'm sure you've already tried - removing the VSC extension, removing the Unity package, and taking it from the top, ensuring that you're using the Visual Studio Editor >= 2.0.20 package (and I guess that the Visual Studio Code Editor package is not installed). Then rebooting all the things.

It's uber weird that that you intellisense only seems to work for some of the core types, but not others :/

magic panther
#

Unity is telling me it doesn't register either the rooms or roomIds of the rooms list. I have no idea what might be causing this issue.
roomManager script -> https://gdl.space/erudahisig.cs

#

actually it might be the ids

halcyon geyser
#

if u double click the eroor what line of code does it show you?

magic panther
#

line 47. The sort

#

I thought it's becuase I'm not assigning the roomIds, but even in that case it should at least tell me there cannot be any duplicate ids

halcyon geyser
#

Where do you assign the rooms?

magic panther
#

I added this line but it did nothing -> room.roomClone.roomId = room.roomId;

magic panther
#

of the roomManager

keen dew
#

put

if(room.roomId == null)
{
    Debug.LogError($"Room {room.name} doesn't have an id");
}

inside the initialRooms loop

magic panther
#

at the start?

keen dew
#

Wherever you want

magic panther
#

ill run it

keen dew
#

well if it's an int it can't be null

magic panther
#

it can be 0, also

keen dew
#

0 doesn't throw a NRE

magic panther
#

also the rooms have an id always as it's manually added in their serialize thing

#

what I'm doing rn is making the roomManager operate on copies instead of originals

#

before all worked as intended

#

so no need to worry about the original rooms

#

the copies are messing something up with the sorts

keen dew
#

The rooms list is public, is it empty in the inspector?

magic panther
#

it's not

#

(this is at the moment the error occurs)

keen dew
#

Is it empty when the game is not running

magic panther
#

yes. It's all added in the awake

keen dew
#

Did you check?

magic panther
#

now I did. I deleted the first three things, I have no idea why they were there

#

the list was supposed to be empty

#

so far after I launched the game there's no error

#

lemme test it and see

#

well good news is the rooms operate properly. But I have one question, if you're still here

magic panther
#

What line can remove any missing elements from a list?

frank zodiac
#

experience is more important than skill

#

but yeah it is good to have an understanding of OOP ofc

#

just not required in my opinion

magic panther
eternal needle
frank zodiac
magic panther
#

if you have experience you have skill, if you have skill you have experience, they're linked, I assure you. As you get experience from something you don't know anything about, you'll start to know some things about it. Same way as to get skill you need to do the thing in which you want skill so that's experience

#

tf am I saying

eternal needle
frank zodiac
magic panther
#

why is this not working???

hexed terrace
#

Deleting a gameobject doesn't remove the element from a list, that index just becomes null.

#

You don't do anything to remove an element of rooms

magic panther
#

so what should I do to delete it?

hexed terrace
#

you need a ref to the Room type and then google -> how to remove element from list c#

magic panther
#

.RemoveAt() is what I found

hexed terrace
#

that requires the index, there's also another way

magic panther
#

is this better?

hexed terrace
#

what does your test show

magic panther
#

still a missing room

#

damn

hexed terrace
#

before the if
Debug.Log($"room is null : {rooms[i] == null}");

magic panther
eager spindle
#

I'm not too sure bout this but the room is not null, the reference is still set. The object is gone though

magic panther
#

so should I destroy the originRoom entirely, not the gameObject?

hexed terrace
#

You need to remove it from the list before destroying it

magic panther
#

oh

#

might work, one sec

#

like this?

hexed terrace
#

seems more like you want to remove currentRoom though.. as that's the one being destroyed

magic panther
#

yeah, my bad

#

alright, everything works fine

#

thanks for helping me end a 2 days long headache

frank zodiac
#

does order in layer affect collision?

brave compass
frank zodiac
#

i have one projectile which is a trigger and a player thats not a trigger

#

i changed the projectile to 2 order of layer and player 1

#

suddenly collision stopped working

rare basin
#

sorting layers are render order only

#

collisions are based upon layer collision matrix

dreamy dune
#

hello, does using new inputsystem change something about the movement itself or only the way it registers input?

languid spire
#

the data itself remains unchanged

late burrow
#

so static variable acts as global variable defined at top?

eager spindle
#

i guess so

#

but not really

#

static variables are variables in a class that arent attached to an object

eager spindle
#

c++ has both static variables and global variables though

eternal needle
swift crag
#

As in, how do you serialize references to scenes?

#

The Scene type itself represents a loaded scene, so it's not appropriate. I use a "SceneField" class I grabbed from the forums a while ago

#

It references a scene asset and copies the path of the asset into itself

eager spindle
#

you can resource.load it and see what type comes up

#

imma give it a try

#

@swift crag UnityEditor.SceneAsset

#

editor only thing

#

unity will scream if you build using that

swift crag
#

Yeah, thatโ€™s what the SceneField class uses

icy junco
#

Does having big scripts slow down the speed

cosmic dagger
honest trench
#

howdy, I have this code that rotates a object and it works good but it lags the game alot. no idea why? its not the object as when i turn the script off no lag, but when the thing starts rotating i get 5 fps, if anyone has any idea why pls lmk, would be appreciated :)


public class RotateObject : MonoBehaviour
{
    public float rotationSpeed = 100f; // Rotation speed in degrees per second
    public bool clockwise = true;      // Direction of rotation

    void FixedUpdate()
    {
        // Determine the direction of rotation
        float direction = clockwise ? -1f : 1f;

        // Calculate the rotation amount for this fixed frame
        float rotationAmount = direction * rotationSpeed * Time.fixedDeltaTime;

        // Apply the rotation to the GameObject
        transform.Rotate(0f, 0f, rotationAmount);
    }
}```
icy junco
#

So if it handels like a lot of different actions in one script it wont affect it ?

cosmic dagger
harsh drift
#

List<int> numList = basicNumList;
numList.Remove(1); its why deleting the element of basicNumList?

languid spire
harsh drift
#

im need the Remove. but my problem is: not need to delete in basicNumList

swift crag
languid spire
#

but they are the same thing

swift crag
#

if you want to create a new list that contains the same elements as another list, there's a constructor for that

harsh drift
#

ok thx

harsh drift
#

other variables not have this method

languid spire
swift crag
#

"variables" don't have methods or constructors or anything else

#

perhaps you can show what you're trying to do

languid spire
harsh drift
#

dont know. im reconstruct the list and its working now

bitter stone
#

Hello there, im currently having a problem with my character controller. Im trying to create a character with topdown movement locked to the camera, however, the code for the rotation doesnt work properly for me. Whenever i rotate, my character makes weird and drastic movements and snaps from one position to another. Furthermore, I know that the issue is with the code for the rotation, as without it, the character moves as expected. Does anyone know whatยดs wrong?
(My code is down below, along with a video showcasing the issue)

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

public class CodeController : MonoBehaviour
{
    public float f_speed;
    private Vector2 move;

    public void OnMove(InputAction.CallbackContext context)
    {
        move = context.ReadValue<Vector2>();
    }

    void Update()
    {
        movePlayer();
 
    }

    public void movePlayer()
    {
        Vector3 movement = new Vector3(move.x, 0f, move.y);

        if (movement != Vector3.zero)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(movement), 0.15f);
        }

        transform.Translate(movement * f_speed * Time.deltaTime, Space.World);
    }
}```
wanton kraken
#

how can i make a kinematic game object collide with a static tile map collider?

long igloo
#

yo, HOW DO I MAKE MY FUNNY BEAN MOVE! I've been coding for days and i cant even make a feckn camera move even a lil! If anyone is wondering here is my code. I've mad two C# scripts

#

public float sensX;
public float sensy;

public Transform orientation

float xRotation;
float yRotation;

private void start()
{
cursor.lockstate = cursorLockMode.Locked;
cursor.visible = false;
}

private void update()
{
// get mouse input
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;

xRotation -= mouseY;
xRotation = mathf.Clamp(xRotation, -90, 90f);

// rotate cam and orientation
transform.rotation = Quaernion.Euler(xrotation, YRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);

}

#

this is the first

eternal falconBOT
long igloo
polar acorn
long igloo
polar acorn
#

with formatted or external code

long igloo
#

i just got on the server less than a minute brotha. chill your beans

wanton kraken
#

yes, but he did explain how to format it. so you should try that my friend

polar acorn
wanton kraken
long igloo
polar acorn
long igloo
long igloo
#

//public float sensX;
public float sensy;

public Transform orientation

float xRotation;
float yRotation;

private void start()
{
cursor.lockstate = cursorLockMode.Locked;
cursor.visible = false;
}

private void update()
{
// get mouse input
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;

xRotation -= mouseY;
xRotation = mathf.Clamp(xRotation, -90, 90f);

// rotate cam and orientation
transform.rotation = Quaernion.Euler(xrotation, YRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);

}

eternal falconBOT
long igloo
polar acorn
#

You didn't do anything

#

You just pasted the code raw again

long igloo
#

yes i did

#

i added these things//

#

these //

swift crag
#

// Your code here is a placeholder

wanton kraken
#

dude

#

you canโ€™t be serious right now

polar acorn
wanton kraken
#

seriously

#

with love man

#

cmon

long igloo
#

i just don't know what a backquote is

fickle plume
polar acorn
long igloo
#

these??? '''

polar acorn
#

Just use one of the bin sites

#

If you're getting filtered by copy-pasting this is going to be difficult

long igloo
#

where tf is it on my keyboard????

#

i am going to have an aneurism

languid spire
#

if you have a US keyboard it is top left below the Esc key (don't use shift)

summer stump
long igloo
#

public float sensX;
public float sensy;

public Transform orientation

float xRotation;
float yRotation;

private void start()
{
cursor.lockstate = cursorLockMode.Locked;
cursor.visible = false;
}

private void update()
{
// get mouse input
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;

xRotation -= mouseY;
xRotation = mathf.Clamp(xRotation, -90, 90f);

// rotate cam and orientation
transform.rotation = Quaernion.Euler(xrotation, YRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);

}

eternal falconBOT
long igloo
fickle plume
#

@long igloo Copy this and put your code inside, where it says "code here"

long igloo
#

thta's an image

polar acorn
#

This can't be easier

fickle plume
long igloo
polar acorn
#

I refuse to believe this is a real person

fickle plume
#

I'm going to mute you if you continue trolling

long igloo
#

I'm not trolling

#

i swear to god i'm just really really stupid

upper salmon
#

!code

eternal falconBOT
polar acorn
#

Are you part of that uncontacted tribe off the coast of India that keeps spearing journalists to death

fickle plume
summer stump
#

Copy and paste the BOT message

long igloo
#
// public float sensX;
public float sensy;

public Transform orientation

float xRotation;
float yRotation;

private void start()
{
    cursor.lockstate = cursorLockMode.Locked;
    cursor.visible = false;
}

private void update()
{
    // get mouse input
    float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
    float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
    yRotation += mouseX;

    xRotation -= mouseY;
    xRotation = mathf.Clamp(xRotation, -90, 90f);

    // rotate cam and orientation
    transform.rotation = Quaernion.Euler(xrotation, YRotation, 0);
    orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
tulip prairie
#

sorry absolute beginner here but unity isn't letting me build my game pls help

long igloo
#

that's all i needed to hear

polar acorn
polar acorn
#

Second, are you calling start or update anywhere?

long igloo
long igloo
polar acorn
#

If that's not a compile error then you must have a class by that name

long igloo
#

is that in the debug thing

polar acorn
#

It's in your code

#

Either that's a compile error you've failed to mention, or you made a class Quaernion

long igloo
#

do i just type in Quaernion?

polar acorn
#

What is a Quaernion

summer stump
#

No, you wrote Quaernion

#

Which is not a thing

polar acorn
#

You are trying to use it

#

what is it

summer stump
#

You misspelled it

polar acorn
#

that's not a thing that exists

#

It's remarkably similar to a thing that exists, but, and I quote:

#

Which means that you must have a class by that name

#

so show it

summer stump
#

Look at the word on the next line after it

#

That one has the right spelling

long igloo
polar acorn
#

Show wherever you've defined Quaernion

#

Or, you can admit you made a spelling mistake instead of insisting you didn't when I can fucking see it right in front of me

toxic canopy
#

lmao

polar acorn
fickle plume
#

@long igloo Can you screenshot your IDE with this script?

long igloo
polar acorn
# long igloo ๐Ÿ—ฟ

Okay, here's how you fix your code. Take your hard drive, wipe it, and donate to those less fortunate because you're not gonna need it

summer stump
fickle plume
#

You should confirtm installed IDE first the rest will be easier

summer stump
#

Fix the spelling

#

That is it

polar acorn
long igloo
polar acorn
#

I didn't think this would be the hard part

polar acorn
eternal falconBOT
long igloo
#

MVS isn't there, do i press other?

polar acorn
#

...MSV?

summer stump
long igloo
toxic canopy
#

its right there

long igloo
#

it's subposed to be red right?

tulip prairie
polar acorn
polar acorn
frosty hound
#

@long igloo Make a thread so you're not flooding this channel with this ridiculousness. Anyone who wants to humour you can do so in your thread.

tulip prairie
polar acorn
#

It's a generated folder so you won't lose any progress (as long as you just delete Library), it's just a thing that lets your project boot faster

long igloo
#

i didn't put it in my code like that it was just a discord message

polar acorn
river quiver
#

when i load the scene after dying the saved high score resets back to 0 even though i saved it using playerprefs

long igloo
river quiver
polar acorn
eternal falconBOT
river quiver
river quiver
#

or should i not use playerprefs

polar acorn
polar acorn
#

Yeah, SetInt is fine, that one takes the value you want to store as the second parameter

#

But GetInt is slightly different

river quiver
#

yeah i didnt process the fact it returns the value

#

mb

#

thanks

#

works

surreal wagon
#

im trying to make a save/load position which will save the scene you're on and what your position is on that scene, the problem is that when i load the scene it won't also load the position, I've tried it without loaidng the scene and it saves my position just fine. Is there a way to fix this?

swift crag
#

First, log the pos you calculate to make sure it's sane

tulip prairie
swift crag
#

If it looks fine, then explain how your character moves. You might need to set your position in a different way.

surreal wagon
surreal wagon
swift crag
#

Given the names of the folders, are those editor tools?

#

You may just need to throw them into a folder named Editor

#

That keeps them from being included in a build.

polar acorn
#

Yeah, you have a lot of Editor scripts that aren't being excluded from the build

tulip prairie
#

yeah just noticed that i had these turned off๐Ÿฅฒ

atomic holly
#

Hello,
I follow a tutorial to create a 2D game on Unity and now I create my game. I try to create my inventory system but I have question. In my tutorial, he does a script for scriptableObject for all items availaible in the game. Is it better to create 1 scripte for all items in the game or different scripts for different kind of items (weapons, armors, potion...)

polar acorn
atomic holly
#

How can I create child items in the SO script ?

summer stump
#

Same as any class

#

public class Thing : ScriptableObject

public class SpecificThing : Thing

atomic holly
#

So, is it okay to do this ?

using UnityEngine;

[CreateAssetMenu(fileName = "Item", menuName = "Inventory/Item")]
public class Item : ScriptableObject
{
    public int id;
    public string itemName;
    public string description;
    public Sprite itemImage;

    public class Weapons : Item
    {
        public int damage;
        public int reach;
        public int cadence;
        public int lachose;
    }

    public class Armors : Item
    {
        public int armor;
    }
}
summer stump
#

Weapons and Armors would be better OUTSIDE of the Item class

#

[CreateAssetMenu(fileName = "Item", menuName = "Inventory/Item")]
public class Item : ScriptableObject
{
    public int id;
    public string itemName;
    public string description;
    public Sprite itemImage;
}
public class Weapons : Item
{
    public int damage;
    public int reach;
    public int cadence;
    public int lachose;
}

public class Armors : Item
{
    public int armor;
}
atomic holly
#

Ohhh okay I see

#

Thanks a lot guys

rocky canyon
#

u making an inventory system?

atomic holly
rocky canyon
#

ohh cool good luck mate ๐Ÿ€

atomic holly
#

ANd another question, I see on internet some people using abstract for the class, why ?

rocky canyon
#

abstract classes can allow u to to for example define a function that must be present..

summer stump
rocky canyon
#

in all inheritanced ones.. but u could overload.. to change the behaviour

#

public abstract void Use();

    public override void Use()
    {
        Debug.Log("Using weapon: " + itemName);
    }```
#
    public override void Use()
    {
        Debug.Log("Wearing armor: " + itemName);
    }```
atomic holly
#

So we use abstract when it depends of an other class ?

rocky canyon
#

An abstract class is a class that cannot be instantiated directly. It can contain both abstract methods (which have no implementation) and non-abstract methods (which have an implementation). Abstract classes are used as a base class for other classes.

atomic holly
#

Okay, I think I understand

rocky canyon
#

idk yea lol ๐Ÿ˜…

#

i use interfaces more often than abstract classes

#

but im sure im stilll just learning as well and will refine that once it clicks more

vale bronze
#

What does this + symbol mean? its the only object that acts strangely in multiplayer. it teleports to the center for 1 screen but is fine for the other. Also, nothing useful on google about it that I could find

burnt vapor
# atomic holly ANd another question, I see on internet some people using abstract for the class...

Look up abstract, virtual, override, sealed and new keyword. Abstract indicates that there must be an implementation added before something can be used. When it's on a class, this class must be inherited from in order to be used. When it's on a method/property, the class must be inherited from and you must implement the given abstract properties/classes. A class in this case is always abstract. If a property/method is abstract, it has no body.

virtual/override is only possible on method/property level. A class by default is always virtual and does not have to be specified. virtual is the same as abstract, but the implementation is optional. The body of a property/method will always be defined, and might be empty.

If you want to override a property/method that is abstract/virtual, it must contain the override keyword. This indicates it is being overridden. This does not have to be done for a class.

If you want to override a property/method that does not have abstract/virtual, it can contain the new keyword. This means the original method is no longer shown when you use the inheriting class. It is optional but the compiler will inform you to add it.

If you don't want to allow a property/method/class to be overridden if this is allowed, then you can add the sealed keyword. This means the property/method/class cannot be overridden and the compiler will throw an exception if you inherit anyway.

polar acorn
tulip prairie
swift crag
#

you probably have an issue with your UI anchors

#

Show me the inspector for the button object.

tulip prairie
swift crag
#

It's anchored to the center of its parent right now.

#

However, the X and Y positions are really small, so it's not like it's going to fly way off the screen if your resolution changes

#

the Z position of -2000 is interesting, though...

#

Also, try changing the resolution of the Game view (it's a dropdown in the top left corner). This may reveal the problem in-editor.

tulip prairie
#

this button wasn't there before i just added it maybe that was the issue ? im gonna try and build it again and see

swift crag
#

But I'd expect that to break in-editor too

regal bear
#

Hello, im just getting started with 3d unity, (not for real project, just for some hobby experiments). I created playermovement, works fine, but if i jump to for example a mountain, i can't move if the slope is too deep, but when i jump i can reach top of the mountain cuz my character bottom stick to it. Whats wrong? I guess my character should just slide down

swift crag
nova rapids
#

Hellooooo

#

You know how like, when you start typing and vscode auto suggests the possible things, i don't know what they are called

#

But it's not showing up

polar acorn
eternal falconBOT
nova rapids
#

Thank youuuuuuu

sand otter
#

So, im just starting a unity project and im following a tutorial to get the movement started. For some reason, the ray casted to tell if the player is on the ground doesn't work. I've been at it for three hours and know that the ray is being drawn and it should be colliding with the ground, but it doesn't. Can anyone help? (the debug.log always shows false)

sand otter
polar acorn
sand otter
hexed terrace
#

!vs

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)

sand otter
#

thanks

polar acorn
#

change your DrawRay's distance to Vector3.down * (playerHeight * 0.5f + 0.2f)

#

So you can see how long your actual raycast is

sand otter
#

the raycast is very faint but there

#

from under

polar acorn
#

Are there any colliders inside of that ray? That looks pretty small and also way below the capsule

sand otter
polar acorn
#

I was asking if that ray is colliding with anything

#

it doesn't look like it's colliding with anything

#

but colliders could be invisible so I'm asking if there's anything there

zenith cypress
#

It looks like the controller is offset from the actual transform

sand otter
#

yes, it is colliding with the ground object box collider

polar acorn
sand otter
#

oh

#

i was moving the ground around so the top of it would collide with the ray and it started working

#

i had the ray fully covered with the ground and not touching the top

#

i guess that was the problem?

polar acorn
#

Yes, the ray needs to cross a collider to detect it

#

it can't start inside of one

sand otter
#

ah okay

#

thank you

stuck palm
#

@swift crag i've been recommended to rewrite my entire system to use fixed-point math, as well as create my own physics system with its own collisions to achieve full determinism ๐Ÿ˜ญ

zenith cypress
swift crag
#

It's intended to be used with the rest of the Entities packages, though.

stuck palm
#

by own stuff i mean like, kinematic character controller or whatever

tulip prairie
#

i'm back, i cant build again :/

polar acorn
#

Check the import options for that asset

swift crag
#

more editor-only assets that got into the build, methinks

tulip prairie
#

i think so too but when i move the folder to Editor these pop up

#

its the tool i use for the dialog so i think moving it messes some stuff up

#

it can no longer use the cherrydev i need

slender nymph
#

nobody said to move the entire folder into an Editor folder though

#

it's just the one asset in the Resources folder that seems to be an issue

high cobalt
#

Hey, can anyone help me? Im trying to make a platformer game and I've got a basic movement script and animations, but for some reason the jumping animation which has 11 keyframes only plays 2 first frames and loops them

magic panther
#

creditTextRef is a Canvas Image. This snippet is inside my introManager script (https://gdl.space/buketafama.cs). Not only is the color alpha not changing, but I hear the audio play on every frame this if is reached. Can someone help?

if (creditTextRef.color.a != 1) {
  Color creditTextColor = creditTextRef.color;
  creditTextColor.a = 1;
  creditTextRef.color = creditTextColor;

  audioManager.PlaySFX(audioManager.Popup1, Random.Range(0.9f, 1f), 0.7f);
}
umbral rock
#

any tips to learn coding? im fairly new and understand a few things, when i watch a tutorial i understand the code most of the time but when i have to type it myself i dont know where to start...

summer stump
high cobalt
wintry quarry
summer stump
high cobalt
#

alright, ty

slender nymph
magic panther
#

because otherwise I'd see the value change in it's color property

#

or am I missing something

high cobalt
lone sable
#

I'm having this weird issue where I'm using RotateTowards, and, it appears to be changing speed constantly. Sometimes it feels a lot slower when I'm close, othertimes, when I'm really far away, its stupdily quick/speeds up quickly. Why is this happening?

void Update(){
        if (player == null) {
            return;
        }

        Vector3 playerPos = player.position + (Vector3.up * aimOffset);

        timer += Time.deltaTime;
        positionHistory.Enqueue(playerPos);


        if (timer >= lookAtDelay) {
            currentDelayedPos = positionHistory.Dequeue();
            Vector3 direction = (currentDelayedPos - losAimPoint.transform.position).normalized;
            Quaternion targetRotation = Quaternion.LookRotation(direction);

            // Smoothly rotate towards the target rotation at a constant speed
            aimingHead.rotation = Quaternion.RotateTowards(aimingHead.rotation, targetRotation, lookAtSpeed * Time.fixedDeltaTime);

        }
}
slender nymph
summer stump
magic panther
high cobalt
#

alright, ty

magic panther
slender nymph
#

where did you actually put the breakpoint

woven sequoia
#

Hey everyone;) I have a question I have a parent with a child gameobject the child has 0.15 for y the rest are 0 when I move the parent now in x direction and look at child.transform.x it does not match with parent.transform.x what is the reason?

magic panther
#

alright, i think i found it

#

you were right

slender nymph
#

i know

magic panther
#

I needed to flip the bird in this part

#

thanks mate

umbral rock
#

i dont know what to do next, im in tutorial hell lmao, im just watching tutorials and i know the code they write but i cant write it myself

summer stump
#

Try to make the simplest thing on your own

umbral rock
#

thats the problem

summer stump
#

Just brickbreaker or something

umbral rock
#

dont know what to write

umbral rock
#

i know i few things

summer stump
umbral rock
#

yes i did, i know what functions and methods are and all, i just dont know where to start, i understand what youtubers do when they show the tutorial but when i try to make on my own its impossible lol

summer stump
slender nymph
umbral rock
#

i just dont know what to write for the thing i want lol, i cant even write basic movement out of my head, i just dont know what or how to write, but if i watch tut i understand it

raw token
umbral rock
summer stump
#

Get something SUPER simple done. You just need confidence

lone sable
umbral rock
#

i just dont know what to write, no matter what im trying to make, i need to google it how i need to do it...

#

i am doing a few things right when coding but then i dont know what else i need to do

slender nymph
# umbral rock i have a simple idea like flappybird, but when im trying to make it i just dont ...

you don't just go "i'm going to write flappy bird, here is the code for that". you break that down into smaller steps and write code for that. like "how do i make the object fall" then you realize you can just slap a rigidbody on it with gravity. then it's "how do i make the object jump" and you realize you can add force to the rigidbody. and you just keep making incremental steps like that. that is how you make stuff

summer stump
# umbral rock i just dont know what to write, no matter what im trying to make, i need to goog...

Stop thinking like that. Just write garbage. Keep writing. Try to fix the garbage.

Break it down as small as you can in your spoken language. As precise and small steps as you can

Like making a sandwich could be 30 to 50 steps or more if explicit enough for a computer to act on.

Reach right hand towards loaf of bread. Clamp hand onto it with low force. Lift loaf. Bring to cutting board. Remove tie. Remove plastic. Reach for slice. Etc
Just as an example.

Write your pseudo-code like that

umbral rock
#

cant fix the garbage without internet....

summer stump
umbral rock
#

bro, i just dont know what to write lmao

summer stump
tulip prairie
#

i've run into another issue, i have noticed that my character moves at extremely different speeds depending on which aspect ratio is used any idea how to fix this?

summer stump
#

Write pseudocode first

ivory bobcat
#

It's more about the thinking than the writing

raw token
# lone sable That is sort of what I expected. At the end of the day, I want it to rotate at ...

If you always rotated towards the player's current position, it would be a constant angular speed, since it wouldn't factor in how the player moved as it currently does...

But are you saying you want the point on the beam closest to the player to travel the same amount of distance, regardless of the distance between the turret and the player? (In which case, the turret would actually rotate slower when the player is far, and faster when the player is close)

umbral rock
#

write garbage but if i dont know what is wrong about my code and i cant use the internet then im done

slender nymph
#

then don't bother practicing and never get better ๐Ÿคทโ€โ™‚๏ธ i don't know what else you are expecting to hear other than "break things down into smaller, more achievable steps"

umbral rock
#

i just dont know what to write without the help of the internet

#

i open vscode and im there like, what do i need to write to move

slender nymph
#

so you look up various ways to move an object

#

you're not just going to magically know how to do something without having researched how to do it first

summer stump
ivory bobcat
umbral rock
slender nymph
#

then fucking look it up. stop putting these restrictions on yourself and actually learn.

ivory bobcat
#

Sounds like a dependency issue

summer stump
tulip prairie
#
public class new_player_movement : MonoBehaviour


{
    public Animator anim;
    public float speedH;
    public float speedV;
    public float RunSpeed;
    public bool walk = false;

    private EventInstance playerFootsteps;
    private EventInstance playerRunsteps;
    // Start is called before the first frame update


    private void Start()
    {
        playerFootsteps = AudioManager.Instance.CreateEventInstance(FMODEEvents.Instance.playerFootsteps);
        playerRunsteps = AudioManager.Instance.CreateEventInstance(FMODEEvents.Instance.playerRunsteps);
    }
    // Update is called once per frame
    void Update()
    {
        transform.position += new Vector3(Input.GetAxis("Horizontal")*speedH*(Input.GetKey(KeyCode.LeftShift)?RunSpeed:1), 0, 0);
        transform.position += new Vector3(Input.GetAxis("Vertical") * speedV * (Input.GetKey(KeyCode.LeftShift) ? RunSpeed : 1), 0, 0);

        anim.SetBool("isRunning", Input.GetKey(KeyCode.LeftShift));
        anim.SetFloat("Walking", Mathf.Abs(Input.GetAxis("Horizontal")));

        transform.localScale = new Vector3((Input.GetAxis("Horizontal")<0?-1:1), 1, 1);
    }
   
}

#

this is for my player movement

lone sable
# raw token If you always rotated towards the player's current position, it would be a const...

I want it to always rotate towards the players position (Or in this case, the players delayed position) at a constant rate. So if the player gets a speed buff, the laser will still try to get to the next delayed position, at the same rate.

So if I tell it to spin at say, 5 degrees a second, then, it should always turn at 5 degrees to reach the given target position. It shouldn't ever go faster, or slower than that 5 degrees.

umbral rock
slender nymph
umbral rock
#

so its normal if i learn how to do movement code, the next day i'll still need to research it bcs i cant remember how to do it?

ivory bobcat
#

You probably haven't learned it but that's to be expected

umbral rock
#

pfff i thought i was abnormal bcs i need to research everything

slender nymph
raw token
lone sable
umbral rock
#

damn... ait

lone sable
#

But thats not what is happening right now..

raw token
# lone sable But thats not what is happening right now..

I wager it is what's happening. It slows down because it achieves rotation to the delayed position. If it wasn't achieving the rotation to the delayed position, then it would not slow down as it would ride the maxDegreesDelta cap

lone sable
#

So I guess I need to get the delta between the current rotation and target rotation, and, if its less than the maximum speed, skip the saved position in history.

#

TBF. There might be an easier way than using the history. I think thats my main problem here. I think if I just figure out if the player is Clockwise or Counter Clockwise from where its currently aiming, I just increase or decrease the rotational speed over time. That way I'll get that "Overshooting" motion I need.

#

Glad I wasted 2 hours on that. :^)

knotty hull
#

Could anyone please tell me what that means?

polar acorn
rocky canyon
#

once u find it remove it

knotty hull
#

thanks for the help @rocky canyon and @polar acorn

raw token
#

Though... hmm

#

Ah that still has issues. It does seem like a problem that I too could waste hours on ๐Ÿ‘Œ

fading mountain
#

Hey everyone, I'm trying to make an audio system for my quiz game. I hve four audio clips such as button clicking and a clock tick sound effect. I want the clock tick sound effect to play when there is a new question, which I have achieved by using PlayClipAtPoint(), but I also want it to cut off after the player answers the question. I cant find a way to access the game object that is created by PlayClipAtPoint() to Destroy it if the player answers the question. Also, there will be other audio clips playing at the same time as the clock tick if an answer is selected. SO, how to disable just the clock tick sound effect?

rich adder
#

having a reference to an audiosource you can easily Stop/Start, PlayOneShot, whatever

fading mountain
rich adder
#

but then it would be diffcult to play 2 diff sounds at same time if you need to

queen adder
#

not sure if i have to code a camera instead of use cinemachine
since when i zoom out, all the characters get pixelated and when standing still its even worse, when moving its a bit better lol

rich adder
fading mountain
#

so maybe create four audio source game objects as children to the audio manager and then assign and play the clips I need in the methods ive written. got it. I'll let you know how it goes

rocky canyon
#

i tend to use a seperate GameObject for each type of audio

#

then .PlayOneShot() all day long

ember tangle
#

my debug logs are being grouped rather than being displayed in order, extremely disruptive to debugging. Is there a setting somewhere to prevent the unity editor from ever doing this again?

ember tangle
#

i must have clicked that by accident, thanks

ornate compass
#
        {

            foreach (Transform i in tegels)
            {
                if (i.position.z == Left.position.z)
                {
                    int x = selectedtile.Length + 1;
                    selectedtile[x] = i;
                }
            }

        }```
#

Hi

#

When i run this code it's giving the following error, does anyone know how to fix this problem?

verbal dome
#

Well the last item index in selectedtile is selectedtile.Length - 1 and you are using +1

ornate compass
#

ah

polar acorn
ornate compass
#

thanks!

high cobalt
#

Hey, can anyone help me? I'm having trouble with making an animation while wall clinging, I think everythings right here and in Unity but it doesnt work. Any idea why please?
this is the code:

rich adder
#

!code

#

uhmm were da dyno tho

high cobalt
#

dyno asleep

rich adder
high cobalt
#

aight

rich adder
high cobalt
rich adder
#

also could you explain exactly what "doesn't work" means in this context

high cobalt
#

The animation won't play, I have the bool and the transition done

rich adder
#

are you talking about the "OnWall" one?

high cobalt
#

When my player touches the wall the animation that plays is the falling

#

yea

rich adder
#

the others work ?

high cobalt
#

yup

rich adder
# high cobalt yup

are you using Unity 2022 ? Go under Physics Debugger and check the casts

#

make sure first the cast is correct then narrow down from there

high cobalt
#

I don't have a thing called physics debugger idk

#

im using unity 2022.3.35f1

rich adder
#

sure you do, its under Window -> Analysis

#

there will be a tab called Queries in PhysicsDebugger

high cobalt
#

okay, what am I looking for there?

rich adder
#

click ShowAll

high cobalt
#

yea

rich adder
#

then check playmode with gizmos enabled, lets see the boxcasts

high cobalt
#

Okay ๐Ÿ™ƒ it turns out i ctrl z'd the layer back to ground instead of wall, ty for helping

safe radish
#
VoxelData voxelData = ChunkManager.Instance.voxelData;```

if i use one of these methods, am i making a copy of the data or storing a reference to the original? i'd rather avoid making copies
verbal dome
safe radish
verbal dome
#

Then you are only referencing the original, so it's what you want

safe radish
#

allright ty

verbal dome
#

Well, as long as GetVoxelData isn't making a new copy

#

If it was a struct then it would give you a copy because it is a value type

safe radish
#

another question i had, im using a 3d array the size of about 500x50x500. the data it holds is not sparse. would using a dictionary for those sizes be better if i want to change the values in it often?

raw token
waxen adder
#

How can I give a script the gameobject its attached to? (Without using a public variable and just slapping the gameobject on in the editor)

lone sable
# raw token Beautiful!! How did you end up implementing it?

The bulk of the code is this:

        Vector3 playerPos = player.position + (Vector3.up * aimOffset);

        Vector3 direction = playerPos - losAimPoint.position;
        direction.y = 0f;

        Quaternion targetRotation = Quaternion.LookRotation(direction);

        float angleDifference = Mathf.DeltaAngle(aimingHead.rotation.eulerAngles.y, targetRotation.eulerAngles.y);

        if (angleDifference > 0) {
            targetSpeed = lookAtSpeed;
        } else {
            targetSpeed = -lookAtSpeed;
        }

        currentSpeed = Mathf.Lerp(currentSpeed, targetSpeed, Time.deltaTime * speedChangeSpeed);

        float step = Time.deltaTime * currentSpeed;

        float newYAngle = aimingHead.rotation.eulerAngles.y + Mathf.Clamp(Mathf.Abs(angleDifference), -step, step);

        aimingHead.rotation = Quaternion.Euler(0f, newYAngle, 0f);

Might be able to clean things up a bit but yeah.

raw token
lone sable
raw token
strong prairie
#

Hello! I am new to ECS. I just followed the "Netcode for Entities" tutorial for creating a networked cube.

Now I want to spawn the cube in a specific location controlled by spawner logic. But the tutorial spawns the cube from the networking system. A spawner system should do that, not a networking system.

How do I tell the spawner system to spawn the cube? Set a flag on the spawner component that we are "ready to spawn"?

Okay, but then the networking system needs to associate the cube with the networking id.

So does the spawner system then set another flag on the spawned entity to signal to the networking system that it's now spawned and ready to have the networking id set on it?

What am I missing here? Surely a ridiculous setup of signaling back and forth to do a basic spawn and set some data is not the correct ECS workflow?

#

I'm probably not quite getting it since I have an OOP mindset. Maybe in ECS we don't care if the spawner controls the spawning logic and I just make the networking system do the spawning logic?

I suppose I could put the spawning logic in a shared namespace that both the spawning system and the networking system can use...

snow merlin
mild onyx
#

the text that i add goes in the bottom left corner of my screen in game mode instead of staying where it is in the scene mode, how do i fix this?

#

tbf it does look nicer but id still like to know

fading mountain
#

Hey everyone. I'm getting an error CS0029: Cannot implicitly convert type 'int' to 'bool' on lines 51 and 64. I know its probably something super simple but I dont know how to fix it. Here is my code: https://gdl.space/zitokozuya.cs

short hazel
#

A more common pattern is to use i < Count though, it's resistant to the case where i exceeds that value. With == you'd end up with an infinite loop, as i would be greater, which isn't strictly equals to the (count - 1) anymore

raw token
raw token
mild onyx
raw token
mild onyx
#

i made them buttons and im gonna add the coode SceneManager.LoadScene (sceneName:"Put the name of the scene here"); dont know how much it will affect it

mild onyx
#

thats what i mean

mild onyx
raw token
# mild onyx

I think the large white outline in your first image is your screen space - so the text in the game view appears to be right where you've placed it - flush with the left edge, near the bottom.

short hazel
#

It's following the design you give them, it's just that the UI Canvas is way bigger (1 unit = 1 pixel) so you just see the bottom-left corner of the canvas

#

Denoted by the slightly brighter lines that go up and right

#

When making UI, don't think about the objects in the world, because they're not in the same "dimension", and vice versa

mild onyx
#

so i need to make my scene ALOT bigger

#

as in make the image inline with the lines

short hazel
#

No, UI elements are overlaid on the screen and it adapts to the screen size, given that your anchoring presets are correct

#

Again, the two dimensions are separate

swift crag
#

The apparent position of an overlay canvas is completely irrelevant

raw token
#

It is admittedly somewhat confusing that Unity displays overlay canvases in world-space when the two have nothing to do with one another... They moved away from that approach with UI Toolkit

swift crag
#

The actual positions of the objects do match where you see them in the scene view

#

but yeah, they aren't rendered by the camear

remote osprey
#

Hello, can anyone give me a little help?

swift crag
#

if you ask a question, maybe!

remote osprey
#

I have a butotn that doesn't change the color of a sprite

#

I even set up the Event System and everything

#

The main idea is that there is a genie (A sprite) which is a singleton that can grant wishes

#

And each button (R,G or B) can ask the genie to grant a wish (add the color to the corresponding color of the sprite)

#

Something like this

#

Wait, could it be I can't add any more white than 255?

modest dust
raw token
modest dust
#

You pass in values from 0 to 1

remote osprey
#

oh wait, that wsa another test

#

Sorry

remote osprey
dusk veldt
#

hi guys can someone help me implement a line of code in my code? in #๐Ÿ’ปโ”ƒunity-talk they suggested i implemented this to fix my problem but im clueless, if i send the code can someone help?

raw token
remote osprey
mild onyx
swift crag
#

the values range from 0..1, not 0..255

modest dust
swift crag
#

Color uses floats colors in that range.

remote osprey
#

Ohh, I see

swift crag
#

The 0..255 you are used to is an artifact of how colors normally use 8 bits per channel

#

so 0..255 is the range of integer values you can store for each channel

#

Color allows for a wider range of values (each component is a float)

#

When you go past 1, you'd call that an "HDR" color

raw token
fading mountain
dusk veldt
# raw token There's only way to find out! People will generally be more reluctant to commit...

ok ok, so basically there's two problems: 1) i'm using a secondary camera to render my guns, which already was a big problem but i got it working, but now my guns render through walls and stuff, so in #๐Ÿ’ปโ”ƒunity-talk they suggested to add this: gameObject.layer = LayerMask.NameToLayer("Default"); in my code, but i dont know in what code i could do that. 2) when i try to drop off a gun, instead of replacing the new gun i picked up, it just starts flying in a random place. Here's the weapon + interactable object scripts if needed:

polar acorn
eternal falconBOT
dusk veldt
eternal falconBOT
remote osprey
#

Silly buttons only accept ints as input tho ๐Ÿ˜ข

polar acorn
modest dust
remote osprey
#
    public void setRed(float red)
    {
        float conversion = red / 255;
        setColor(m_SpriteRenderer.color - new Color(0, conversion, conversion));
    }
    public void setGreen(float green)
    {
        float conversion = green / 255;
        setColor(m_SpriteRenderer.color - new Color(conversion, 0, conversion));
    }
    public void setBlue(float blue)
    {
        float conversion = blue / 255;
        setColor(m_SpriteRenderer.color - new Color(conversion, conversion, 0));
    }
#

I got another error anyway

modest dust
#

Fix the errors first then

brave compass
#

Yeah, code won't update until it can compile without errors.

remote osprey
#

Its not compilation tho

#

Its an ArgumentException: method arguments are incompatible when Iclikc the button

#

I imagine because I expect float and I can only give int because of Event Trigger doesn't let me add floats (e.g. 0.5)

brave compass
#

Try removing and adding them back.

remote osprey
#

it worked!

#

Ok, it's working!!

#

thank youu

summer stump
dusk veldt
#

okay

#

!code

eternal falconBOT
dusk veldt
#

how big is a large code

summer stump
dusk veldt
#

sooooo i use the links? just to be sure

modest dust
#

Yes, use the link.

dusk veldt
#

okay

remote osprey
north kiln
#

The logic is bad, confusing, or even wrong. Also the method names aren't PascalCase, which is normal C# standard.

remote osprey
#

yes, my logic certainly isn't working

#

Do you have any idea as to why?

north kiln
#

Because subtracting like that makes no sense?

polar acorn
#

I cannot make sense of what this code is supposed to accomplish

remote osprey
#

I'm just currently working on a method to leave a white color more "reddish", "bluish" or "greenish"

remote osprey
north kiln
#

I can't explain that to you, because I don't understand how you think it does

#

To tint a color generally you're best to use multiplication.
color * new Color(1, 0.9f, 0.9f) for example would return a slightly more red color

#

Because you've scaled down the non-red channels slightly

remote osprey
#

I was trying to accomplish that with subtraction

#

I'm gonna give multiplication a try!

#

Thanks for the suggestion

north kiln
#

I see now why you were using subtraction, but it wont return colors that are always positive, which is definitely an issue!

remote osprey
#

I see!

north kiln
#

But I also think it's odd to provide 0-255 value under the guise of a single color, say "red" and then use that to scale an existing color. It's just weird logic

remote osprey
#

You mean the conversion logic?

#

I was using it to accept int parameters

#

Because that was the issue I was having, Event Trigger didn't update realtime as I updated my method's parameter types

#

It works ๐Ÿ˜ฎ
Thanks everyone! ๐Ÿ™

high cobalt
#

Could anyone help me make a roll mechanic (like, roll a few units in a direction with editable stats and the roll decreases your collision by a bit)? I tried making it myself, looking for it online even using chatGPT but I can't for the love of god make it work (2D)
this is my current code https://gdl.space/eguqutipav.cs
๐Ÿ™

teal viper
high cobalt
#

I click R, the button for rolling and it won't roll. I have it bound to R in input manager axes, it doesnt work. i tried everything but it does nothing

teal viper
high cobalt
#

doesnt this work?

#

sorry i started coding yesterday

teal viper
#

But to be honest, if you just started, you should probably go !learn the basics first.

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

high cobalt
teal viper
bright grail
#

so us more of the code

high cobalt
#

Yes

teal viper
high cobalt
#

Yes

teal viper