#💻┃code-beginner

1 messages · Page 310 of 1

wintry quarry
#

Get rid of Time.deltaTime

#

it's wrong there

honest haven
#

IEnumerator WaitTwoSecs() { yield return new waitforseconds(2f) }

#

i do

willow scroll
#

I was referring to them not being able to use the TMP_Text in the dictionary's field initialisation, how they wanted to do, as they can neither reference the TMP_Text field created above, nor create the new ones, as it's abstract

wintry quarry
#

This is not IEnumerator

bitter walrus
wintry quarry
#

velocity is velocity

gaunt ice
#

velocity is m/s

bitter walrus
#

Ok

wintry quarry
gaunt ice
#

if you multiple it with s, it becomes m

ebon skiff
#

How do I change the hit box on the vehicle so the ramp isn't on the front

honest haven
#

So if i am calling start routine insdide that function. how do i stop the code under it from starting till its returns

wintry quarry
bitter walrus
wintry quarry
#

and you can't pause execution in this function unles this function is a coroutine

#

that's the superpower of coroutines
so the answer is - you don't unless you make this function also a coroutine.

ebon skiff
honest haven
wintry quarry
#

idk if that's the "best" answer but that's one option.

honest haven
#

what else would wokr

wintry quarry
#

why not just turn this big function into a coroutine

honest haven
#

work

wintry quarry
#

IEnumerator WaitTwoSecs() { yield return new waitforseconds(2f) }
This is actually pointless

#

you can just directly use WaitForSeconds

#

but obviously only INSIDE a coroutine

wintry quarry
honest haven
#

sprry was fixing my typo

willow scroll
wintry quarry
#

oh

honest haven
#

Thank you ill do what you said

willow scroll
honest haven
#

yh lol,

spring hill
#

hello im trying to make a fireball its not working, what is even wrong with it? I copied the code from the tutorial so i think its a settings issue or something

gaunt ice
#

i dont know what you mean by "not working", i guess the position is too low?

willow scroll
spring hill
# willow scroll * What do you mean by "not working"? * We don't know what tutorial it is, and th...

https://youtu.be/PUpC44Q64zY?si=m33SDJBlCxRrVuYZ&t=1016 for contex thats what its suppose to look like

2D platformer for complete beginners in Unity. In this episode we're adding the ability to shoot fireballs.

➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-3
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-4

Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤...

▶ Play video
willow scroll
spring hill
willow scroll
summer stump
spring hill
willow scroll
summer stump
# spring hill what?

It looks like it is shooting from the feet, I thought that was the issue at first

spring hill
spring hill
#

cause i dont know and it will help

gaunt ice
#

is the fireball affected by gravity?
how you set its initial position when you shoot it?

spring hill
summer stump
spring hill
#

its in the scripts

#

i copied it one for one

amber spruce
#

this is the script that loads and saves the data when you load a scene the values are right player skin is the correct value but its still 0 on the player any idea why
https://hatebin.com/ierjamuwej

spring hill
willow scroll
spring hill
spring hill
#

deadline and stuff

slender cargo
#

only one data set has playingMiniGame to true

#

so I'm updating it's index by removing it and re creating it, Then I am overwriting it's position

#

but for some reason another index is also over writing it's position

gaunt ice
#

since you have remove the element at i

slender cargo
#

ohh

gaunt ice
#

then the element at i+1 now go to i

slender cargo
#

of course

willow scroll
slender cargo
#

so then I now need to re-get the element with the bool to true, then set its position

polar acorn
spring hill
#

only explosions

willow scroll
#

You said the issue is in your bullet being destroyed too early

#

Well, so the explosion animation just works too early, not after the 5 seconds

spring hill
spring hill
willow scroll
spring hill
#

only explosions...

willow scroll
spring hill
willow scroll
spring hill
gaunt ice
#

you code wont work btw
since the item at i+1 be i now and you will skip the check on it

willow scroll
spring hill
willow scroll
#

You said the object is destroyed after 5 seconds. The animation is just happening too early then.

#

Yes, this is how your animation looks in the game

#

So I need to see the length of your animation

spring hill
# willow scroll You said the object is destroyed after 5 seconds. The animation is just happenin...

the animation should show fire ball like in the tutotrial video, its should look like thishttps://youtu.be/PUpC44Q64zY?si=FCHEqfchSkPbHRMV&t=1016

2D platformer for complete beginners in Unity. In this episode we're adding the ability to shoot fireballs.

➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-3
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-4

Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤...

▶ Play video
willow scroll
#

Yes, the length in seconds

spring hill
willow scroll
#

Do you insist on having the same logic as in the video above, even though the logic in the video works and yours doesn't?

willow scroll
spring hill
spring hill
#

am i expalining correctly?

willow scroll
#

No

spring hill
# willow scroll No

ok whats the issue? cause that how the speed of projectle moves in the game, the fireball is the projectile, if you mean something like animation or animator?

#

is this it?

willow scroll
#

Alright, I've checked the code, and the fireball is supposed to explode when colliding with a trigger, which you should've known, have you thoroughly looked through the code

private void OnTriggerEnter2D(Collider2D collision)
{
    hit = true;
    boxCollider.enabled = false;
    anim.SetTrigger("explode");
}
willow scroll
# spring hill

In the video above, the fireball is clearly colliding with the ground.

spring hill
willow scroll
#

So the problem is not in the, as I've assumed before, incorrect usage of the single animation, which makes the fireball redundantly fly and explode, without caring about its lifetime

spring hill
willow scroll
#

Your fireball collides with the ground

spring hill
willow scroll
#

It's the fireball either being spawned in the incorrect place, or having an incorrect flight angle. Or both.

willow scroll
#

Preventing the fireball from hitting the ground in any possible way should solve the issue for you

spring hill
#

ok

raw aspen
#

im trying to undestand profiling. does this look problematic?

summer stump
# spring hill meaning?

Sounds like it may be colliding with the player itself. Check if it is the player it hits, and if so, don't play the explode animation

#

Or spawn it a little further ahead of the player

spring hill
#

cause i set the fire point away from player

spring hill
#

the fire point is away from the player

#

the red one is where it shoots

gaunt ice
#
private void OnTriggerEnter2D(Collider2D collision)
```do you know why there is a argument passed into ontriggerenter2d? it contains the data on what you have collided with
btw dont name the parameter as collision, since there is a Collision struct in unity
spring hill
teal viper
gaunt ice
#

other The other Collider2D involved in this collision.

raw aspen
#

you think it might be some other issue?

#

i mean it drops to like 20 fps

#

or less

spring hill
teal viper
#

or less

raw aspen
gaunt ice
#

thats why you shouldnt copy and paste the code especially you are new
read how the example code use the "other"

void OnTriggerEnter2D(Collider2D col){
    Debug.Log(col.gameObject.name + " : " + gameObject.name + " : " + Time.time);//access the field of col
}
teal viper
raw aspen
#

you can do that?

#

ok ill look into it

teal viper
#

Yes

raw aspen
#

ty

raw aspen
calm hare
#

guys i was following a tutorial and i wanted to open up a script and start coding then it said i cant, i figured its because i dont have anything to open a script with so i peeped what the guy in the tutorial was using and he was using visual studio, then this

#

trying to doiwnload this

#

wth

raw aspen
#

@calm hare i think you need to scroll down and find unity

calm hare
#

OHHHHH

#

thanks!

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)

calm hare
#

i thougt those were my onlu options

hexed terrace
#

Pay attention to the UI, the scroll bar is obvious :p

gleaming burrow
#

I want to update my ATH with the current slot ID when i drop the item but i don't know how I can do it

willow scroll
calm hare
#

trying to make a 2d character move'

#

the tutorial didnt work

polar acorn
calm hare
#

where

slender nymph
eternal falconBOT
calm hare
#

whats that

polar acorn
calm hare
#

wait il search it up

slender nymph
calm hare
#

oh do i have to like download one of those

slender nymph
#

you need to configure visual studio

calm hare
#

u sure that wil fix it

#

il try it

slender nymph
#

that won't fix your issue. but it is a requirement to get help here

calm hare
#

alright

languid spire
calm hare
#

idk what an ide is

willow scroll
calm hare
#

man im confused

languid spire
ocean basin
#

I need help with my code or maybe its unity but when i click play its supposed to show all the sprites on the board and I dont really know what im doing wrong. if anyone can help me that would be great here's a video of everything ive done. and its supposed to be a match 3 game https://streamable.com/pxymz7

the beginning of the video is me showing you what its supposed to do and then i proceed to show all the code and unity. im also really new to this so help would be much appreciated

slender nymph
polar acorn
# calm hare u sure that wil fix it

Your issue is that what you've written in no way resembles C# code. A configured IDE will underline syntax errors and give you auto complete and make it less likely that you'll accidentally type nonsense

slender nymph
eternal falconBOT
calm hare
polar acorn
languid spire
calm hare
#

well

#

its what i got first result

slender nymph
calm hare
#

he did NOT warn me about that

polar acorn
# calm hare
I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 157
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-4-18
calm hare
#

what did i get

#

was i the 158th

polar acorn
#

157th

willow scroll
languid spire
bitter walrus
#

Says there is nothing as orthographic Size

light relic
#

hi there is chat on integrating ads allowed here ?

slender nymph
eternal falconBOT
polar acorn
light relic
#

is box friend a bot?

slender nymph
#

yes

light relic
#

hun?

polar acorn
languid spire
slender nymph
#

Dead Discord Theory™️

ocean basin
light relic
#

you dont had to cut me offf

bitter walrus
#

Error CS1061 ‘camera’ does not contain definition ‘orthographicSize’

#

Blah blah blah

polar acorn
slender nymph
summer stump
light relic
#

umm i was asking could we talk on integrating ads here ?

willow scroll
languid spire
bitter walrus
willow scroll
slender nymph
summer stump
graceful spruce
#

Hey, so adding of the hero works fine but when I try the removehero function it just doesn't work and gives no errors.

    public List<GameObject> heroSlots = new List<GameObject>();

    public void AddHeroToSlot(GameObject hero)
    {
        foreach (GameObject slot in heroSlots)
        {
            if (slot.transform.childCount == 0)
            {
                GameObject newHero = Instantiate(hero, slot.transform);
                newHero.transform.localPosition = Vector3.zero;
                break;
            }
        }
    }

    public void RemoveHeroFromSlot(GameObject hero)
    {
        foreach (GameObject slot in heroSlots)
        {
            if (slot.transform.childCount > 0)
            {
                if (slot.transform.GetChild(0).gameObject.GetInstanceID() == hero.GetInstanceID())
                {
                    Destroy(slot.transform.GetChild(0).gameObject);
                    break;
                }
            }
        }
    }

}```
bitter walrus
willow scroll
summer stump
eternal falconBOT
summer stump
light relic
#

can someone help me with integrating ads !!! plz ! the unity page doesnt help i have tried it many time

graceful spruce
polar acorn
bitter walrus
summer stump
languid spire
light relic
polar acorn
ivory bobcat
graceful spruce
bitter walrus
slender nymph
graceful spruce
summer stump
graceful spruce
#

can I try to use a tag?

green robin
#

can a proffesional review my code pls

bitter walrus
summer stump
polar acorn
polar acorn
charred spoke
ivory bobcat
summer stump
rich adder
graceful spruce
#

yeah I was actaully thinking of tag

graceful spruce
slender nymph
# green robin can a proffesional review my code pls

if you want help with your code, you'll need to post it. if it's a long block then use a bin site like the bot shows below !code
and it's generally good to have something specific to ask about, even when asking for code reviews

eternal falconBOT
bitter walrus
summer stump
polar acorn
#

You can absolutely make a variable of type camera if you have one. That's perfectly cromulent C# code

bitter walrus
#

Ohhhh yea

#

Srry

graceful spruce
polar acorn
gleaming burrow
graceful spruce
#

okay now its clear

#

thanks :D

proven junco
#

does someone know why my character is spassing out when I changed update to fixedupdate??

#

in my movment code

slender nymph
#

show code

light relic
#

wdym by spassing out

summer stump
proven junco
#

code seems to be good from my experience but imma show

ivory bobcat
ruby python
#

!code

eternal falconBOT
proven junco
#

can link the code with c

#

it is too long

#

aperently

ivory bobcat
slender nymph
#

if only there were instructions for posting large code blocks

summer stump
rich adder
proven junco
#

omg

light relic
#
using UnityEngine;

public class PlayerController1 : MonoBehaviour
{
public float moveSpeed = 5f;
    public float jumpForce = 10f; 
    public float lookSpeed = 2f; // Camera rotation speed

    private Rigidbody rb;
    private Transform playerCamera;
    private Vector3 moveDirection;
    private float rotationX = 0f;

    void Awake()
    {
        rb = GetComponent<Rigidbody>();
        playerCamera = Camera.main.transform;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        // Get the player's input for movement
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        // Calculate the movement direction based on input and camera orientation
        moveDirection = moveHorizontal * playerCamera.right + moveVertical * playerCamera.forward;
        moveDirection.y = 0f; // Keep the movement only in the horizontal plane
        moveDirection.Normalize();

        // Rotate the player based on the mouse movement
        RotatePlayer();

        // Move the player
        MovePlayer();

        // Jump if the spacebar is pressed
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Jump();
        }
    }

    void MovePlayer()
    {
        Vector3 movement = moveDirection * moveSpeed * Time.deltaTime;
        rb.MovePosition(transform.position + movement);
    }

    void RotatePlayer()
    {
        float mouseX = Input.GetAxis("Mouse X") * lookSpeed;
        rotationX -= Input.GetAxis("Mouse Y") * lookSpeed;
        rotationX = Mathf.Clamp(rotationX, -90f, 90f);

        // Rotate the camera vertically
        playerCamera.localRotation = Quaternion.Euler(rotationX, 0f, 0f);

        // Rotate the player horizontally
        transform.rotation *= Quaternion.Euler(0f, mouseX, 0f);
    }

    void Jump()
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
    }
}

plz identify potential areas of improvement in this cod

proven junco
ivory bobcat
light relic
ivory bobcat
proven junco
#

well then the game glitches out and throws me out the world

ivory bobcat
light relic
#

just asked if i can improve the overall experience of the player with any changes in the code

proven junco
ivory bobcat
rich adder
#

if it works, it works.

polar acorn
amber spruce
light relic
#

wanted to ask that how to make the game go smoother and better for all divices

polar acorn
calm hare
#

i quit code il take a step back and go on scratch for the first time in 7 years

light relic
ivory bobcat
dark hatch
#
Button[] buttons;
for(int i = 0; i < someLength; i++) {
  buttons[i].onclick.AddListener(delegate {
    Debug.Log(i);
  });
}


this always logs the value on i on last iteration. how do i make it so that the iteration number(i.e. what was value of i when listener was added) is logged instead?

dark hatch
#

yeah though that this question was really stupid. makes sense

polar acorn
#

Boxfriend has the link, but I just want to point out that no matter how many times I know this happens I always step on that rake

ivory bobcat
green robin
#

!code

eternal falconBOT
languid spire
green robin
ivory bobcat
proven junco
#

okay so I tried doing something like that

#

as you told

#

dont know how really

#

but i tried

#

and it still doenst work

amber spruce
# ivory bobcat Add this line: ```cs Debug.Log($"{player.name} was successfully loaded",player);...
public void Load()
{
    string saveString = SaveSystem.Load(saveSlot);
    if (saveString != null)
    {
        SaveObject saveObject = JsonUtility.FromJson<SaveObject>(saveString);
        if (player != null)
        {
            Debug.Log(saveObject.currentSceneName + " Save slot " + saveSlot);
            if (saveObject.currentSceneName != SceneManager.GetActiveScene().name)
            {
                //SceneManager.LoadScene(saveObject.currentSceneName);
            }
            player.GetComponent<PlayerHealth>().currentHealth = saveObject.playerhealth;
            player.GetComponent<PlayerHealth>().Heal(0f);
            player.GetComponent<PlayerControllerNew>().Skin = saveObject.playerSkin;
            Debug.Log("Player Skin: " + saveObject.playerSkin + " Current Scene: " + SceneManager.GetActiveScene().name);
            Debug.Log($"{player.name} was successfully loaded", player);
            if (SceneManager.GetActiveScene().name == "SinglePlayer")
            {
                player.transform.position = saveObject.playerPosition;
            }
        }
    }
    else
    {
        Debug.Log("No Save File Found");
    }
}

so like here?

slender nymph
# proven junco and it still doenst work

well naturally that won't work. you need to store the result of the input in fields so that they can be accessed in those other methods instead of just letting compile errors stick around

ivory bobcat
slender nymph
#

also you should 100% be doing the rotation in Update rather than FixedUpdate. you're missing a lot of mouse input by doing it in FixedUpdate

ember oasis
#

could someone help me make an endless background

#

in 2d

rich adder
summer stump
proven junco
#

yeah I have no clue for me this should work

#

but it doesnt

#

I tried having no fixedupdate

#

and I flew

#

tried fixed

#

now I spass

summer stump
ivory bobcat
proven junco
#

okay sry

spiral narwhal
#
        public GameSaveModel SaveCurrentGameState()
        {
            var model = new GameSaveModel();
            _savableServices.ForEach(service => service.SaveGameState(model));
            return model;
        }

Do the services that alter the model object, alter a copy or the reference to that object? Because a value of it is null despite being set by a service

polar acorn
rich adder
amber spruce
#

i can find the object

ivory bobcat
polar acorn
spiral narwhal
amber spruce
#

so yeah im modifying the right object it just seems not to change the skin

languid spire
ivory bobcat
polar acorn
# spiral narwhal It's a class

Then it's passed by reference. The model variable holds a reference to an object and other things referencing the same object will share data

spiral narwhal
ivory bobcat
spiral narwhal
ivory bobcat
polar acorn
spiral narwhal
#

The model will later be parsed into JSON and then into a file

polar acorn
amber spruce
ivory bobcat
amber spruce
#

its just this

#

it shouldnt affect it

polar acorn
ivory bobcat
#

Other than that, you've saved again immediately after loading, perhaps some things have occured after loading.

proven junco
#

not it kinda works, but I acelerate really fast

#

so I become reeeallly fast

rare niche
#

Hey, not really sure where to put this but I'm having an issue where I can't left or right click anything in the Scene view (I also can't move or rotate with the shortcuts)

All the answers online say to switch from Iso to Perspective, but I'm already in perspective mode
I tried closing scene view and making a new one, no luck, and this issue affects every scene

I've also tried of course closing it and opening it back up, restarting my computer

If anyone could help that'd be great, my project is pretty much stuck until I can figure this out

slender nymph
#

you were meant to separate the input from the movement, handle input in Update and movement in FixedUpdate

proven junco
#

ohh okay Imma try

ivory bobcat
rare niche
proven junco
ivory bobcat
#

For example:cs private float vertical; private float horizontal; private bool jump; private void Update() { vertical = Input.Get... horizontal = Input.Get... jump = Input.Get... }

proven junco
amber spruce
slender nymph
proven junco
#

I seperated input form logics

#

and errors

slender nymph
#

show the code

ivory bobcat
amber spruce
#

it was in the start function of the player controller

#

i was setting it to a playerpref that i was using before i set up the save and load stuff

#

thanks

proven junco
#

okay so I have seperated them this time but Now I am shaking again and it is kinda weird

ivory bobcat
#

Also describe shake better or show a video clip

proven junco
#

all the time

#

like no stop

ivory bobcat
proven junco
#

yuh

ivory bobcat
#

Maybe it's not related to these lines of code or your character isn't ever not moving.

#

Or the camera is just screwed up

dense osprey
#

Hello there,I'm sumesh ... can anyone suggest to me on how to build 2d beginner games using unity game engine, thanks in advance

proven junco
#

so the character controller want my player obj to fly up the sky

#

while my script has gravity

eternal falconBOT
#

:teacher: Unity Learn ↗

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

proven junco
#

so it is a constant up and down

frozen burrow
#

I've been watching a video on how Super Mario 64 detects floor, wall n' ceiling and it uses the triangle's Normal Vector to do so. Basically if the Normal Vector is pointing down, it's a ceiling; upwards, it's a floor; and if it's straight, a wall.

I was wondering if I can get this information on Unity and get the Normal Vector Rotation/Orientation from a model's triangles/faces to apply the same logic seen in SM64.

ivory bobcat
rich adder
#

oh. they crossposted it everywhere UnityChanOops

polar acorn
# frozen burrow I've been watching a video on how Super Mario 64 detects floor, wall n' ceiling ...

||But first we need to talk about parallel universes||

The Dot Product of two vectors gets you the "sameness" of the vectors. It's 1 if they're pointed in the same direction, -1 if they're opposite, and 0 if they're perpendicular. The way SM64 likely does the check is to dot product the wall's normal with world up. If it's greater than something like 0.9, it's a ceiling. If it's below -0.5, it's a floor, and otherwise, it's a wall

warm basalt
#

Question, does anyone even check the #⛰️┃terrain-3d channel? Me and others are having problems and like no one responds ever

hexed terrace
warm basalt
proven junco
polar acorn
frozen burrow
polar acorn
#

If the controller is moving in a way you don't want, it's because you have a .Move call somewhere you shouldn't

polar acorn
green robin
#

is rigidbody based movemnt actually better then character controller

rich adder
#

they both have their use cases

eternal needle
proven junco
green robin
rich adder
#

Character Controller offers similar control of Kinematic RB without having to deal with no Collision / phasing through walls and having to do manual checks like casts

green robin
#

but its quite janky so im trying the cc

rich adder
#

fighting forces is not fun

rich adder
#

also why assigning velocity in Update and FixedUpdate?

green robin
#

meh idk im trying to make it super moduable

#

so should i put everything with rb in fixed

proven junco
rich adder
#

No idea what that means or how that would help here do that

violet nova
#

Hi i just formatted my pc and i want to download vscode extensions can you guys send me link to the extensions that i need

rich adder
rich adder
#

if you don't want to deal with fighting forces just use CC

green robin
#

but imma make both a cc based and a rigidbody script tbh

rich adder
#

I make things like acceleration manually anyway

#

Animation Curve would be your best friend for achieving nice movement

ivory bobcat
rich adder
#

for some reason thats the only command that likes to be alone :\

#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

willow scroll
hexed terrace
hexed terrace
#

stoopid dyno

proven junco
#

I HAVE FIXED code kinda but now I am stuttering when looking around, movment works tho and I can kinda look around

#

so do someone know how to fix this problem

slender nymph
#

are you still only performing your rotations in FixedUpdate

long jacinth
#

i want to change the version of my project to and older one

proven junco
#

so the inputs from rotation into update and logic into fixed

slender nymph
#

so you remember how i pointed out you should be doing the rotations in Update so you aren't missing input from your mouse?

rocky canyon
long jacinth
rocky canyon
#

should be fine

long jacinth
#

i found out before you answered XD

proven junco
#

as you can see in the code

slender nymph
#

you didn't share the code?

torpid basalt
#

So I have an audio manager, where I want to switch between the music "Phases" like a lot of other games. The problem is, when I try playing the music when the player crosses a trigger, it changes the track in the audiosource, but nothing actually plays. The "BeforePhaseOne" Plays, and changing it in the editor then playing the game does play the audio. Just for some reason the code doesn't play when it switches (BTW I'm using a mediator to communicate when to play the song phases)

slender nymph
#

and also i said to perform the rotation in Update, not just get the input for it in Update. because i can guarantee that if you are just getting the input in update you aren't properly accumulating the mouse's change in position since last FixedUpdate hence the stuttery rotations since you get 1 frame of rotation 50 times per second instead of every frame

long jacinth
eternal falconBOT
proven junco
#

okay so I tried it and it does not work

proven junco
ocean basin
polar acorn
ocean basin
summer stump
# proven junco someone??

You seem to he rotating a transform, but you have a rigidbody. Rotate the rb instead
Also do it in FixedUpdate

proven junco
#

never tried rotating rb

frail star
#

I have 3 star images and they scale the way I want but I want to stagger them

wind lily
#

hey! I'm basically a complete beginner but I'm trying to make a game for a class and need to make a tutorial. I have a "next" button on a panel, and when you click it I want the panel that is currently showing to be disabled and a different panel to become enabled, repeated for a couple more panels, almost like flipping through a book. could someone help me with that? I've tried searching for a long while and nothing helped!

hexed terrace
#

What have you got so far?

polar acorn
summer stump
wind lily
hexed terrace
#

so your google should be something like -> "unity how to disable a gameobject with a button"

wind lily
polar acorn
hexed terrace
#

The answer is in the first result of what you were told to google 😉

frosty lantern
#

the probuilder channel only refers to the editor and scene view

proven junco
#

rigidbody instead of transform??? or should I have it some where else bc when I place rb there it gives me error and I only have problem with rotation so I don't think I need to change movement??

torpid basalt
proven junco
# frosty lantern what's the error?

Well when i run the build I can move around without any problems but my camera movment is stuttering, so I am figuring out how to fix that

#

but I have no clue on how to do that

summer stump
#

Ah yeah, you're using localRotation. Rb has .rotation

wind lily
proven junco
wind lily
frosty lantern
summer stump
proven junco
#

oh

proven junco
# summer stump Well you have the word localRotation Instead have rotation

I got error, Severity Code Description Project File Line Suppression State
Error CS1061 'Transform' does not contain a definition for 'Rotation' and no accessible extension method 'Rotation' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\gottc\My project (1)\Assets\Objective system\CharacterControllers\FPSController.cs 69 Active

summer stump
#

The whole point of this was to switch from transform to rigidbody...

frosty lantern
frosty lantern
proven junco
# frosty lantern ```c private void HandleRotation() { rotationX = Mathf.Clamp(rotatio...

Severity Code Description Project File Line Suppression State
Error CS1061 'Camera' does not contain a definition for 'rb' and no accessible extension method 'rb' accepting a first argument of type 'Camera' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\gottc\My project (1)\Assets\Objective system\CharacterControllers\FPSController.cs 69 Active

hexed terrace
summer stump
frosty lantern
proven junco
polar acorn
proven junco
summer stump
#

Try doing what you did before, but in lateupdate

proven junco
polar acorn
proven junco
#

rotation input too?

wind lily
polar acorn
#

Input always goes in Update regardless

proven junco
#

thx imma try

#

okay so I did the thing

#

but rotation is still totaly messed up

frosty lantern
#
            if (proMesh == null)
            {UnityEngine.Debug.Log
                    ("Mesh Failed");}
            else if (uIPoints == null)
              {UnityEngine.Debug.Log
                    ("Points Failed");}
            else{string log = "";
                foreach (Vector3 point in uIPoints)
                    log += "(" + point.x.ToString() + ","
                         + point.y.ToString() + ","
                         + point.z.ToString() + ")\n";
                UnityEngine.Debug.Log(log);}}

I'm trying to debug the reason why the meshes won't show up and it seems like the points aren't being created:

proven junco
#

movment works fine and all but rotation stutters a LOT

frosty lantern
proven junco
frosty lantern
proven junco
#

where should I place it?

frosty lantern
#

you could put it directly in the Quaternion.Euler statement

rocky vortex
#

hello, is each added function of a button run in a cycle per click or do all of them run at once ?

polar acorn
rocky vortex
#

well not once but sequentially

queen adder
#

Im trying to make it to where it constantly makes it to where it goes up by 10. I keep getting this error but I don't know how to fix it.

polar acorn
queen adder
#

Oh.

queen adder
#

I had that opened

#

Still do.

polar acorn
queen adder
#

OHHH

rocky vortex
queen adder
#

srry i live in a area with major allergies and I got allergens which make me forget everything and lose my appetite.

rocky vortex
#

I dont have any code messing with the canvas yet either, most of this is the basic canvas

polar acorn
#

so end result it's going to be active

rocky vortex
#

right, but the menu im going for still doesnt activate

#

or show ig

polar acorn
frosty lantern
rocky vortex
polar acorn
rocky vortex
#

yes...

#

i keep clicking it

polar acorn
rocky vortex
#

yes it gets darker

#

then lighter

#

toggles

polar acorn
rocky vortex
#

lame

#

ty

abstract pelican
#

How do I disable the stroke and panel when lifting an item?

proven junco
#

I was tryna figure it out but no work

frosty lantern
proven junco
#

the whole segment???

summer stump
#

This is what they refer to as wrong lerp

proven junco
#

or just after =

frosty lantern
proven junco
#

oh alr

frosty lantern
#

after the equals

summer stump
#

First and second parameter of lerp should be unchanging, and third should move smoothly from 0 to 1

#

Use movetowards for this.

abstract pelican
#

Help guys

frosty lantern
#

I finally got it!!

frosty lantern
eternal needle
abstract pelican
frosty lantern
summer stump
#

Why not just movetowards?

#

Or smoothdamp?

polar acorn
#

That line is very wrong in several ways

frosty lantern
#

yeah i'm dumb rotation is a quaternion

eternal needle
kindred nest
#

watched that CGP video of it again yesterday, good stuff

#

pawns look really decent too, gj!

frosty lantern
#

unity store

kindred nest
#

oh, you got my hopes up 😦

#

still nicely put toghether though

rose spade
#

Vector3 SnapToGrid(Vector3 position)
{
float snappedX = Mathf.Round(position.x / gridSize) * gridSize;
float snappedY = Mathf.Round(position.y / gridSize) * gridSize;
float snappedZ = position.z;
return new Vector3(snappedX, snappedY, snappedZ);
}

i have this snap to grid function but as you can see it has weird functionality when applied to blocks bigger than the grid, what should i do?

wintry quarry
frosty lantern
rose spade
queen adder
#

Hey guys. So I am trying to make a "platform system" to help 2d developers make mods.
But when I hold E down it flashes immediately and goes away. I just want it to where if people press E then it stays there till they let go.
Here is my script:

using System.Collections.Generic;
using UnityEngine;

public class Mods : MonoBehaviour
{
    [Header("Platforms")]
    public GameObject platform1;
    public GameObject platform2;

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

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("e")) {
            platform1.SetActive(true);
            platform2.SetActive(true);
        }
        else
        {
            platform1.SetActive(false);
            platform2.SetActive(false);
        }
    }
}
south sky
#

Can someone help, keep getting this error and i dont understand it

proven junco
polar acorn
frosty lantern
polar acorn
#

What is line 23

proven junco
#
 {
     rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
     playerCamera.transform.localRotation = Quaternion.Euler(Mathf.Lerp((float)rotationX, (float)rotationX, Time.deltaTime), 0, 0);
 }
    
frosty lantern
south sky
polar acorn
wintry quarry
proven junco
queen adder
wintry quarry
frosty lantern
rose spade
#

okay thats a start, just got to get them back to the bottom left of their grid position

frosty lantern
frosty lantern
# proven junco you know somehting else that might help?

void HandleRotation()
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(Mathf.Lerp(transform.rotation.eulerAngles.x
, rotationX, Time.deltaTime), 0, 0);
}
that should work i think

queen adder
#

I think I fixed it by making if key up

queen adder
#

nvm

polar acorn
queen adder
#

I want it to where when you stop pressing e it goes away

proven junco
queen adder
#

I used a else statement.
Failed.

polar acorn
queen adder
#

Ik

#

but I am getting confused more than ever.

polar acorn
#

Whenever you release the key, deactivate them

queen adder
#

so get key release?

#

ok

queen adder
wintry quarry
rich adder
polar acorn
#

Which is not what they want

queen adder
#

u can switch to GetKey

#

and it will do exactly that

#

uh oh

#

while e is pressed it will be active and when released it will deactivate

polar acorn
#

better to just set it on press and release

queen adder
#

it doesn't say Release is a thing.

polar acorn
queen adder
polar acorn
queen adder
queen adder
#

im so confused

rich adder
queen adder
queen adder
#

depends what he wants

queen adder
#

it no work

rich adder
polar acorn
queen adder
queen adder
polar acorn
#

That's not how you call a function

queen adder
#

i got confused

#

alr i got it done.

fast glade
#

Whats better?
Import all of the guns into the scene and deactivate them. And switch them on and off in the script, when i switch my weapon, or should i create a new gameObject, with the weapon, when i switch the weapon?

Or do you have a better idea then both of these methods?

deft grail
#

makes it much easier, you can also preset the locations and variables and anything you need

fast glade
#

Alright, thank you! 🙂 @deft grail

rocky vortex
#

my anchors have gone missing from some of my canvas elements, although the toggle's anchors still show up

deft grail
rich adder
#

is it even inside a canvas component?

rocky vortex
deft grail
rocky vortex
rocky vortex
#

but not the white background itself

#

/image

rich adder
rocky vortex
#

those slots however do have anchors

deft grail
#

are they just an empty game object?

abstract monolith
#

was there like an update or something because yesterday my code was fine now theres like 40 errors

rich adder
abstract monolith
#

never mind i fixed it

rocky vortex
#

same thing as the character slots parent

rocky vortex
rich adder
rocky vortex
#

sry, rect

rich adder
#

also this isnt code related

rocky vortex
#

2 people responded, u included, and we were already having a conversation going

rich adder
#

just create a new object and see if work

rocky vortex
#

but ok, ill go to UI

#

I want to understand why tho

#

is unity that buggy? It crashed earlier when I hid a samplescene gameobject lol

rich adder
#

nvm. Did you maybe use layout group or something ?

rocky vortex
#

sry idk what layout group is. When i was trying to figure it out myself I was worried that I might have accidentally clicked something I shouldnt have but I cant find the difference between the ones that do show anchors and dont

#

but ur right, just have to spend another 20 minutes adding in a few blocks again

#

is probably the best approach

main anchor
#

let me know if you have any clue whats causing the issue and i'll get to fixing it

rich adder
main anchor
#

so should i remove it?

rich adder
#

dynamic rigidbody should either use addforce or velocity, or switch to character controller

frigid sequoia
#

If I don't have an object on Scene the animation events don't show the dropdown menu to attach methods; even if I am not selecting a object on scene and just like modifying the animation controller directly, can I still manually write the method and it does work?

#

These are the two different UIs that I am mentioning, just to be clear

frosty lantern
#

Thread

swift crag
#

It will send a message named DeactivateDamageCollider to the object the animator is attached to

#

so any method on any component on that object whose name matches will get called (if the type signature is right, at least)

teal viper
swift crag
#

perhaps something else was using the GPU at the time and caused a delay

teal viper
#

Yeah, that's a possibility

fast glade
#

I have a trail renderer on my bullet. When e.g. there are 3 bullets active in the scene, because i have a high fire rate. The trail renderer renders a trail to every single bullet, when i shoot. How can i render this trail once for every bullet?

polar acorn
#

A trail renderer will draw the movement of whatever object it's attacked to. If each bullet has a trail renderer, then each bullet will render a trail

fast glade
polar acorn
fast glade
polar acorn
#

Why wouldn't each bullet have its own trail?

fast glade
polar acorn
#

I don't know what you mean. That seems like exactly what you'd expect out of bullet trails. What's "weird"?

fast glade
#

Its like they always try to get the trail back to me. So when i move and a bullet is already out and i shoot again, the bullet trail is buggy

frigid sequoia
#

Adding a wait for second anywhere that is not on a Coroutine does something or do I have to specifcially create a coroutine to wait for seconds?

#

Like lets say I want to wait for half a second at Awake to do X

polar acorn
polar acorn
polar acorn
#

If it returns IEnumerator it'll be run as a coroutine instead of a normal method

frigid sequoia
fast glade
frigid sequoia
polar acorn
polar acorn
fast glade
polar acorn
#

If Awake were a coroutine, it'd just become Start

polar acorn
fast glade
#

Thats super confusing

frosty lantern
#

Is there a way to reference the standard shader when creating a material?

polar acorn
timber tide
#

oh, but you probably need some extension script to call it

#

when calling the assetdatabase

frosty lantern
#

ah really

fast glade
polar acorn
timber tide
polar acorn
swift crag
#

the core premise of object pooling is that you can get away with doing less than completely destroying and recreating an object

#

however, this means that you are now responsible for making sure that old data doesn't stick around

polar acorn
swift crag
#

(and that old references aren't being kept!)

polar acorn
#

You need to clear it before you re-use it

fast glade
frosty lantern
swift crag
#

The code Mao linked does not create a new shader.

#

It creates a new material.

#

Every material must reference a shader, though, which is why it's using Shader.Find

frosty lantern
#

sadge

#

i was hoping it'd be a built in variable/instance i could call

timber tide
#

cache em at the start

#

well, I mean, the AssetDataBase is for editor specifics if that's what you were wanting

#

which shouldnt really matter about it being a string lookup

swift crag
#

the only nuisance is that you need to pick the right shader for your current render pipeline

frosty lantern
#

I was hoping to use the standard one used in game view and scene view

frigid sequoia
#

If I want to like have 3 different sounds for the same thing and pick one of them at random do I need 3 AudioSources or is there a way to store the clips on a LIst and then attach that to the AudioSource before playing it?

deft grail
#

the array will just hold the sounds

#

not any AudioSources

fast glade
frigid sequoia
#

So something like that?

deft grail
dense walrus
#

my visual studio cursor is weird and instead of adding new stuff, it hovers over code and replaces the code with new code, not a good explainer but hopefully u guys will understand

dense walrus
abstract monolith
#

how do i fix this

queen adder
#

Same with the two NavMesh Classes

abstract monolith
#

how can i delete thos scripts

rich adder
#

might be some package broken

rocky canyon
#

the errors show exactly where they are.. but u shouldn't just go delete scripts here and there from Unity packages. it'll just end up throwing more errors

#

if u want u can remove the entire package.. but thats not gonna do u any good if u wanting to use it

rich adder
abstract monolith
#

git

rich adder
#

thats old

#

2019

abstract monolith
#

i just draged and dropped the assets

#

should i just reinstall from package manager

rich adder
#

delete old first yea

abstract monolith
#

still not sure how to delete it lol

#

nvm got it

summer stump
abstract monolith
#

ok

#

are there any easier enemy ai things i can use or no

rich adder
#

navmesh agents are pretty easy to get started

rocky canyon
#

navmesh are the easiest

abstract monolith
#

alright thanks guys

rich adder
#

giving it good variations is a whole different beast 😅

abstract monolith
#

i cant find navmesh on package manager

rich adder
#

its should be called AI

abstract monolith
#

this?

rich adder
#

should be i use 2023 so im a later version

#

seems to be same of what you had before though so not sure

abstract monolith
#

yeah it is

frigid sequoia
#

A quick but kinda specific question, an AudioSource plays at the origin of the object right?

rocky canyon
#

if its set to 3D spatially the origin of the source itself yes

abstract monolith
#

unless im in the wrong place

rich adder
abstract monolith
rich adder
#

my latest was 2.0 so i got confused for sec

frigid sequoia
#

What if I wanted to be on the closest point of the object then? Imagine like a really streched out mesh that should be heard equally as strong at any point near the whole mesh? A laser for example

#

Can I do that?

abstract monolith
rich adder
#

anyway something else is wrong if you installed that package and got those error

abstract monolith
#

should i update unity to 2023?

rich adder
#

no

abstract monolith
#

then im not sure what im doing wrong

rich adder
#

try reimport all assets, under Assets menu

abstract monolith
#

ok

#

well it installed okay this time so

#

im just gonna leave it alone lol

rich adder
#

why are you crossposting

rain peak
#

because

#

im a begginer so i did one min here to

#

yo im making a open world zombie shooter like wwz if anyone wants to help!

rich adder
rain peak
#

im not?

rich adder
#

you were already linked to where to ask for collab posts

rain peak
#

yo someone has nothing better to do lol

rich adder
eternal needle
rain peak
#

so i cant ask for help?

rich adder
#

ask a specific thing then about code?

rain peak
#

you know what im leaving this server

frosty hound
rain peak
#

kinda boring

#

im out

swift crag
#

You could then position the audio source there

nova swift
#

Trying to detect controller in unity with:
foreach (string joystick in Input.GetJoystickNames())
print(joystick);
but it prints an empty string, though I do have a controller connected and it can play the game

deft grail
nova swift
#

no other alternative? I've already got pretty much all logic done for the inputs, and am yet to learn about using the new input system

polar acorn
nova swift
#

I only need this detection to automatically differentiate controller types so the player wouldnt have to tell the program manually what controller type they'yre using through a toggle or button

deft grail
nova swift
#

Well, I learned that the old input system maps binds differently to different controllers, so I automated this binding, but I have a variable which tells the program which controller type they are using

#

I wanted to be able to set this variable automatically depending on what the string returned by Input.GetJoystickNames() contains

#

Something like this for example:

if (joystickName.Length > 0)
{
if (joystickName[0].Contains("Xbox") || joystickName[0].Contains("XInput"))
{
isXbox = true;
}
}

deft grail
nova swift
#

I haven't heard of those before, so I'll check it out, those need to be set up for Input.GetJoystickNames()) to work?

deft grail
deft grail
#

works fine

#

can actually just do 0 instead of the i and remove the whole for loop, and works the same way

nova swift
#

Yea it just returns empty for me for some reason, could be my controller

deft grail
nova swift
#

Potentially my version too if that's important? I'm on 2020.3.29f1 which is probably older than this controller as well if that matters

deft grail
nova swift
#

Fair enough, I'll keep trying I guess

deft grail
nova swift
#

Its bluetooth

deft grail
#

that would probably fix the issue i think

nova swift
#

Connecting the joystick would normally say its type right? Unity just seems to recognise it as an empty string

nova swift
#

Ill see if I have a cable but I'm not sure I do

deft grail
#

bluetooth works differently and recognizes it as different

nova swift
#

Either way, thanks for all your help

#

Turns out I do have a cable, but it still returns empty unfortunately, probably just my controller

deft grail
nova swift
#

That's alright, thanks for your help

#

May need to move on from the old input system haha

wind bridge
#

hey so I'm still learning unity and I'm trying to script basic character movement into unity, can someone tell me why my script is not showing up under components properly? I'm even following a video guide

#

what it should look like (from the video I'm following)

polar acorn
queen adder
#

what is the #if directive for mobile/touchscreen environment?

wind bridge
#

I keep getting this but idk if its related

#

other than that I don't have any errors popping up and yes the names match

queen adder
#

are you trying to Run in vsc?

summer stump
# wind bridge

Definitely want to fix that right away. But it won't affect things in unity, just the vs code configuration

summer stump
summer stump
polar acorn
summer stump
#

The console is in unity

#

It is where you would see the errors

wind bridge
#

oh sorry still new

#

its blank

summer stump
summer stump
#

FPSController and FPSMovement

wind bridge
#

changed FPSMovement to FPSController and now this popped up

summer stump
#

Add an ending simcolon to the end, or remove the ending one.

Your indenting is completely messed up, so it's hard to tell which.

Do one and if it doesn't work, then do the other

wind bridge
#

like the end of the entire script or the first part?

summer stump
#

Of the whole script, yes

#

The error says line 81, which is where the error indeed is

tough cave
#

Someone taht can explain me why its saying this error. I dont get it. Wym its missing a class attribute. its a interface wot.

public interface IBulletOnCollision
{
    void OnTriggerEnter(Collider other);
}

public class EnemyBulletOnCollision : MonoBehaviour, IBulletOnCollision
{
   
    private GameObject tempBullet;
    public GunController gunController;
    public int damage;


    public void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            other.GetComponent<Player>().TakeDamage(damage);
            Destroy(tempBullet);
        } 
        
        //if on collision with a layer:
        if (other.gameObject.layer == LayerMask.NameToLayer("Environment"))
        {
            Destroy(tempBullet);
            gunController.DestroyBullet();
        }
        
    }
}
polar acorn
#

you can't do that, you need to add in a MonoBehaviour that implements it

wind bridge
# summer stump > to the end

added that but it didn't do anything. I do think I see my issue so I'm going to redo the whole thing and hopefully should fix it

#

thanks for being patient with me lol

summer stump
#

I meant curly brace

#

} this thing

tough cave
#

Oh fair. could be it. oops. Guess Ima scan through all the objects lul zzz

summer stump
#

It is red, so I feel you need to remove it

frosty lantern
#

I have a question: How do I fix the behavior of translucent polys that I've made so that they don't render as solid at certain distances?

#

2 and 3 are the same location, and 1 and 4 are the same location

burnt crow
#

Hey folks, building a very simple application for Meta Quest 3. I'm trying to implement a weighted laser for selection of objects (one that curves downward, like the photo). How can I implement this laser, and how can I map it to a Raycast hit? Thanks so much

timber tide
#

i'd probably segment a bunch of raycasts and iterate over them until one of them hits

burnt crow
#

like how could I approach doing what you said lol

timber tide
#

many videos on trajectory where they use linecasts to indicate where a projectile will hit

#

similar logics

burnt crow
#

gotttt it, any thoughts on rendering it?

timber tide
#

linerenders

frosty lantern
#

My thought was if you have your character or the hand at the origin, you can plug in the math, c = height, b is arctan of the vertical angle, a is your gravity,, and alpha (the angle) would be rotation around the y axis

burnt crow
frosty lantern
#

so you can test over the length of the ray (low t to high t)

gaunt ice
#

you need to solve for the collision point

cobalt flare
#

can someone help me learn c# and remember?

frosty lantern
#

idk i've never done raycasting before tho

warm pawn
#

idk where to post this but i have a problem with my prefabs i am kinda new to gamedev but i created a prefab but it dont want to have a reference for maincamera and one game object idk why? i mean they are on the gameobject i cant get them on the prefab.

charred spoke
#

Prefabs can not reference scene objects

warm pawn
#

oh

#

thanks

oak island
#

Hi all

#

I have multiple NPC in my game all having the same animator attached and same script...Right now when I am playing default animation it is playing the same for all NPC at once and they appear to be in sync with each other. What I want is to introduce random variation in the animation for each NPC

#

Like say for NPC 1 the first animation takes 1s for other it takes 1.5 sec (all randomly decided)

#

How do i proceed?

summer stump
#

This is not normal behaviour

#

Or maybe I am misreading this. You aren't saying they all do the same animation at the same exact time right? Just that they all are too similar?
You may want to ask in #🏃┃animation

misty coral
#

How can I MoveToward a position for 5 seconds

#

while at the same time the object is being pulled on by other methods

#

(i am trying to make procedural recoil)

oak island
#

ditto

summer stump
oak island
buoyant prawn
#

!code

eternal falconBOT
buoyant prawn
#

!help

rancid tinsel
#

hey guys, im writing a style guide for a uni project, I was wondering if there is a term for when visual studio automatically adds namespaces at the top of the code that aren't actually being used (like when it autocompletes to the wrong thing)? Is that called intellisense or is it something different?

whole idol
#

Hi, i made a flappy game for training, theres some problems with it

#

i added a box collider 2d on my obstacles

#

they also have a sprite renderer