#💻┃code-beginner

1 messages · Page 318 of 1

brittle isle
#

thanks

wintry quarry
#

This part is just as important. Make sure everything is arranged and assigned correctly

hot lily
#
 {
     if (lfAngle < -360f) lfAngle += 360f;
     if (lfAngle > 360f) lfAngle -= 360f;
     return Mathf.Clamp(lfAngle, lfMin, lfMax);
 }
 private void CameraRotation()
 {
     //targetRotation = Mathf.Atan2(inputVector.x, inputVector.y) * Mathf.Rad2Deg + _mainCamera.transform.eulerAngles.y;
     //float rotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation);

     if (cameraInputVector.sqrMagnitude >= 0.01f)
     {
         _cinemachineTargetYaw += cameraInputVector.x;
         _cinemachineTargetPitch += cameraInputVector.y;
     }
     
     _cinemachineTargetYaw = ClampAngle(cameraInputVector.x, float.MinValue, float.MaxValue);
     _cinemachineTargetPitch = ClampAngle(cameraInputVector.y, BottomClamp, TopClamp);
     
     CinemachineCameraTarget.transform.rotation = Quaternion.Euler(_cinemachineTargetPitch, _cinemachineTargetYaw, 0.0f);
 }```

I'm trying to copy the code over from the 3rd person asset to create a 3rd person camera
but instead of working it caused my camera to be stuck in its original position
#

what did I do wrong?

hot lily
#

nvm, chatgpt pointed out the big oopsie

#

i'm an idiot

buoyant thistle
#

i was looking for a not instantaneus rotation but does like keep the object rotating afterwars

wintry quarry
#

you make gradual rotations by doing lots of small instantaneous rotations, one per frame

eternal falconBOT
frosty lantern
#

So I am using this validate method to determine if one of my moves is valid, but it only seems to work if I hover over what I presume to be the last movement in the list of movements, and it highlights all of the movements as opposed to the valid movement
https://gdl.space/ijiwuniduq.cs

#

It recognizes each movement so it's most probably just the structure of when I chang ethe color of the pieces

tawny bolt
#

can someone explain how to fix this code ?

rich adder
tawny bolt
#

basicly my Dash() function is not being called out

rich adder
#

have you debugged and logged your values / checked ?

#

like dashcount amount etc.

#

also gotta check what is value of dashCD1,dashCD2 etc..

tawny bolt
#

yes

#

//counter
if (dashcount == 2 && dashCD1 == true)
{
DashChance1.interactable = false;
dashcount--;
Dash();
pm.Dashing = true;
dashcount -= 1;
dashCD1 = false;
Debug.Log("minused");
}
if (dashcount == 1 && dashCD2 == true)
{
DashChance1.interactable = false;
dashcount--;
Dash();
pm.Dashing = true;
dashcount -= 1;
dashCD2 = false;
Debug.Log("minused");
}
}

not getting call

frosty lantern
polar acorn
tawny bolt
#

sorry i am new wdym by logging

frosty lantern
tawny bolt
#

ok

frosty lantern
# tawny bolt ok

you can turn variable values into strings so that you can read values at runtime in the console

tawny bolt
#

i will try that

tawny bolt
#

this is what i got

polar acorn
tawny bolt
#

i do get the fallse from both DashCD

#

ok

#

so do i just go and do
public bool DashDc = true;?

#

for both

rich adder
#

why do you put that variable if ur just gonna set it true in inspector

#

what is literally the point of that variable 🤔

polar acorn
#

Well, you're starting a timer to set them to true, and if that's not happening, you need to find out either why it's not finishing those invokes or where else it's setting it to false

#

because solely based off of the tiny window into your code you've provided, they should become true after 3 seconds

tawny bolt
# rich adder what is literally the point of that variable 🤔

if (dashCD1 == false)
{
Invoke("Dash1", 3);
DashChance1.interactable = true;
}
if (dashCD2 == false)
{
Invoke("Dash2", 3);
DashChance2.interactable = true;
}
}

`private void Dash1()`
`{`

dashCD1 = true;
}
private void Dash2()
{
dashCD2 = true;
}
this is what i did for the variable

polar acorn
frosty lantern
#

https://gdl.space/arikosanig.cs
This is my entire chesspiece code, the ValidateMove(Vector3Int attempt) method is making all objects green when I am hovering over the last move in my basicHexMoves array, because it logs seeing all of the valid moves but overwrites them back to white

tawny bolt
#

they came like this after spamming

#

but the number never got minused

#

how ?

polar acorn
# tawny bolt

Change your logs to something easier to read:

Debug.Log($"{gameObject.name} - Dashcount: {dashcount}, CD1: {dashCD1}, CD2: {dashCD2}");
#

Now you can know for sure which ones are true and false

violet nova
tawny bolt
tawny bolt
#

after spamming

polar acorn
tawny bolt
#

yes

violet nova
polar acorn
tawny bolt
#

but i have to press a key to make it true from false otherwise it never starts as true

tawny bolt
#

by making the values true in inspector

#

but still the same bug

polar acorn
tawny bolt
#

i get this

polar acorn
#

Does your "minused" log appear

tawny bolt
#

no

#

thats what i am confused about

polar acorn
tawny bolt
#

ok

polar acorn
#

make sure to include the corner that shows the message counts and settings

tawny bolt
#

gimme a minute

short gust
#

https://gdl.space/lonayariwo (hope link will work)
I have this code that being used in CodeMonkey's tutorial on field of view simulation with generated mesh as a mask (quality of that code is questionable, but I just use it to get things done and simple testing)
And it "works" in it's core, but I have an offset that increases/decreases while player is moving because I'm using this generated mesh from tutorial as a child of a player's empty gameObject that works like eyes placement, not as individual separated gameObject, like it was in tutorial (because when I do this - it works as intendent ofc)
Funny enough I understand why it does that, but I simply can't get an idea how to prevent this offset with parenting without some convoluted substraction, lol
I've tried using Vector3.zeros as _origin, some Transform methods, etc. - it's all just make weird bugs/artifacts and not working as intendent
Pic 1 - when mesh is a child object of that eyes object and using it's transform as _origin, pic 2 - when mesh is separated and eyes object is set through inspector and _origin is it's position

short gust
tawny bolt
#

after i hit the dash button

willow scroll
willow scroll
# short gust yeap

In this case you wouldn't need to add an offset, as its start position is already the position of that parent object

polar acorn
#

Also, scroll to the bottom so it's showing the most recent messages

tawny bolt
#

this ?

polar acorn
# tawny bolt

Okay, good. I wanted to make sure errors weren't hidden and collapse was off. I'm assuming that CD1 is becoming false after you hit the dash button, which would imply that it is now working

#

You can comment out that log and see if you get any of your other logs when you enter one of those conditions

#

see if it ever prints your "minused" log

tawny bolt
#

ok ima try that

tawny bolt
#

now it prints minused

#

what do you think the soulution should be

polar acorn
#

What is the problem

#

it's calling Dash now

tawny bolt
#

if (dashCD1 == false)
{
Invoke("Dash1", 3);
DashChance1.interactable = true;
}
if (dashCD2 == false)
{
Invoke("Dash2", 3);
DashChance2.interactable = true;
}

#

i want this to work

#

private void Dash1()
{
dashCD1 = true;
}
private void Dash2()
{
dashCD2 = true;
}

polar acorn
#

And why do you think it doesn't

tawny bolt
#

cuz i remove my dash to false and then it just stays true

polar acorn
#

Why would it not?

tawny bolt
#

thne this not come back to its orignal state

#

just stays empty

polar acorn
#

I have no idea what this is

tawny bolt
#

dashCD in ui

polar acorn
#

At no point in any of the discussions we've been having have you ever mentioned anything related to UI

tawny bolt
#

sory got off point

#

the delay stops working

#

the invoke method

polar acorn
# tawny bolt the delay stops working

Well, every frame that the boolean is false, you start up a new timer that sets it to true 3 seconds later. Meaning once the first one's time is up, you have 3 seconds of queued "true"s to burn through before it can ever become false again

#

Maybe instead of starting the timer every frame it's false, you start the timer once when the value becomes false

tawny bolt
#

how do i do that ?

frosty lantern
#

So I tried logging the indices of the moves that get colored correctly, and my king with 12 files only gets colored green on file 10 (index 9)
queen is colored on file 12 (index 11)
my knight is colored on file 12 (index 11) as well
My pawn with one move technically works fin since it only has one move (index 0)
My rook is colored on move 12 of file 6 (index 5, 11)

Actually, one of my other rooks gets colored at index (5,10)
and another knight logs at (9,0)

#

By colored correctly I mean that the entire thing turns green on those moves and not the others

#

I still need it to color them individually as needed

gleaming burrow
#

I have problem because my character in my 2D game doesn't jump when I press the space key, my jump system works but the character dosn't take account if I press jump key more time

wintry quarry
#

my character in my 2D game doesn't jump

my jump system works

gleaming burrow
wintry quarry
#

What are you actually asking

rare basin
#

your jump works but it doesnt jump?

gleaming burrow
#

it doesn't jump if i press more time the jump key

rare basin
#

show the code and describe the issue, because we still cannot understand what's wrong

#

and what is the desired behaviour

wintry quarry
rare basin
#

!code

eternal falconBOT
gleaming burrow
wintry quarry
#

Input.GetButtonDown in FixedUpdate is 🚫

#

input handling belongs in Update

gleaming burrow
#

So ok I just follow thetutorial for see if it works but I never used FixeUpdate before

#

thanks I will try it

#

Yes I will never used fixeUpdate again because it not woks correctly

#

thanks @wintry quarry

wintry quarry
#

Input handling goes in Update
Phyics code goes in FixedUpdate

gleaming burrow
boreal hare
#

Hello

gleaming burrow
boreal hare
#

I'm using VS Code

#

but i need that extension like Visual studio

gleaming burrow
#

why?

naive pawn
#

vscode has c# and unity extensions

summer stump
eternal falconBOT
boreal hare
#

Becuase I'm not encoding my code

summer stump
gleaming burrow
boreal hare
#

Writing them on my mind

naive pawn
#

you aren't supposed to encode your code

boreal hare
#

Example when I write p

#

that will show public auto

gleaming burrow
summer stump
gleaming burrow
eternal falconBOT
boreal hare
#

But in VS Code everything on my mind

summer stump
boreal hare
#

Thank you

empty ice
#

Anyone could help me with my script?
So i got this GameObject called FacilityDoor. Inside it i got 2 3D objects called FacilityDoor1 and FacilityDoor2.
Now i want the door to open when i click the door so i was working on this script but for some reason it doesnt work. Could anyone tell me why?
Both scripts under.
FacilityDoorScript.cs


public class FacilityDoorScript : MonoBehaviour
{
    [SerializeField] private float rayLength = 5f;
    [SerializeField] private KeyCode openDoorKey = KeyCode.E;

    private void Update()
    {
        if (Input.GetKeyDown(openDoorKey))
        {
            RaycastHit hit;
            Vector3 fwd = transform.TransformDirection(Vector3.forward);

            if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
            {
                FacilityDoorController FacilityDoorController = hit.collider.GetComponent<FacilityDoorController>();
                if (FacilityDoorController != null)
                {
                    FacilityDoorController.dooropen();
                }
            }
        }
    }
}

FacilityDoorController.cs

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

public class FacilityDoorController : MonoBehaviour
{
    private bool DoorOpen = false;

    public GameObject door1;
    public GameObject door2;
 

    private void Awake()
    {

    }

    public void dooropen()
    {
        Destroy(door1);
    }

    public void doorclose()
    {

    }
}

both are attached to the FacilityDoor1 in the GameObject, inspector and on GameObject 1 field the FacilityDoor1 is placed

wintry quarry
empty ice
wintry quarry
#

alaso instead of Vector3 fwd = transform.TransformDirection(Vector3.forward) you can just use transform.forward

empty ice
#

My bad i forgot to mention that

wintry quarry
#

You need to use Debug.Log to check

#

you should also make sure your console window is open

empty ice
wintry quarry
#

With an actual message of course

empty ice
#

Yes alright ill check

wintry quarry
#
Debug.Log("This is the DoorOpen function!");```
empty ice
#

Give me a second ill check, there were no errors in the console so i thought that means that the code works fine

wintry quarry
#

obviously the code doesn't work fine if it's not doing what you want it to do.
that would be the opposite of "working fine"

polar acorn
empty ice
#

on FacilityDoorController Awake works since it sends out message but when i click on the door nothing happens. It doesnt debug or anything so the problem lays withing the FacilityDoorScript then?

wintry quarry
empty ice
summer stump
# empty ice wdym

There is a location that you write code.
It would be in some method. Between some lines
Where is that location

wintry quarry
# empty ice wdym

I recommend something like this:

if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
{
    Debug.Log($"The raycast hit {hit.collider.name}");
    FacilityDoorController FacilityDoorController = hit.collider.GetComponent<FacilityDoorController>();
    if (FacilityDoorController != null)
    {
        Debug.Log($"{hit.collider.name} had a FacilityDoorController!");
        FacilityDoorController.dooropen();
    }
    else {
        Debug.Log($"{hit.collider.name} did NOT have a FacilityDoorController!");
    }
}
else {
  Debug.Log("The raycast didn't hit anything");
}```
#

now you can actually know what's going on.

empty ice
#

Alright thank you, ill check

wintry quarry
#

We expected an answer like "I put it right before the raycast if statement" or just showing the code with the logs in it to explain where the logs are

summer stump
# empty ice I still dont understand

I don't really understand what part you are not getting

If I write this:
public void Start() {
Debug.Log("something");
}

And someone asked where I put the log, I would say "I put it in start"

empty ice
#

No debug or anything is comming from the script. The only one im getting is from Awake().
I got a box collider on the door, isTrigger enabled. So i dont know what could be wrong

#

could it be that its an child of an GameObject like i said before? Since the FacilityDoor1 in which both scripts are placed in is inside a GameObject called FacilityDoor

polar acorn
#

So, where are those logs you're not seeing?

empty ice
#

And in the script its ```Hit.collider.GetComponent<FacilityDoorController>();

Shouldn it be something like getchildren or something like that since the object is a child of FacilityDoor?
ember oasis
#

could anyone tell me why my IEnumerator in one script works fine but in another script gives me the error "not all code paths return a value"

empty ice
# polar acorn So, where are those logs you're not seeing?
{
    Debug.Log($"The raycast hit {hit.collider.name}");
    FacilityDoorController FacilityDoorController = hit.collider.GetComponent<FacilityDoorController>();
    if (FacilityDoorController != null)
    {
        Debug.Log($"{hit.collider.name} had a FacilityDoorController!");
        FacilityDoorController.dooropen();
    }
    else {
        Debug.Log($"{hit.collider.name} did NOT have a FacilityDoorController!");
    }
}
else {
  Debug.Log("The raycast didn't hit anything");
}

I used this one

polar acorn
summer stump
polar acorn
ember oasis
wintry quarry
empty ice
wintry quarry
#

shouldn't it be attached to your player?

empty ice
#

Ah. im such an idiot

#

Now it works

#

bruh, sorry im new to coding and thought it was supposed to be attached to the code

#

but thank you so much

wary sigil
#

would these be correct for trying to get a button to store its' name on click?

ember oasis
#

could someone tell me how to make a trigger such that when the player leaves an area before a certain amount of time passes they trigger an event

summer stump
#

That is one way. Could use a coroutine, could do the timer in OnTriggerStay if they are in it the whole time.

green ether
#

or just OnTriggerExit

#

If you dont want to do stuff every frame in OnTriggerStay

#

Countdown would need to be somewhere though

rich adder
#

Start timer on TriggerEnter
Check on TriggerExit what timer is when left

summer stump
#

Yeah, my thinking was that they may NOT actually exit the trigger. But I guess no need to check that every frame. If OnTriggerExit isn't called, they are still in it

wary sigil
#

would people know why the function for the script is greyed out and locked to this value?

wintry quarry
#

Because it's just telling you what script that is

#

It wouldn't make sense for it to be editable

summer stump
wary sigil
#

I don't

summer stump
rich adder
#

this looks very odd

wary sigil
#

oh maybe I do

rich adder
#

haha yeah that filename is wild

wary sigil
#

the file is supposed to be buttonclickhandler though

rich adder
#

so name your file that

summer stump
#

You named the file, you can also rename it

rich adder
#

in unity those two must match btw

wary sigil
#

this is the class name?

rich adder
#

thats filename

wary sigil
#

why are they different

rich adder
#

class name is the name that is literally next to the keyword class

rich adder
wary sigil
#

I'm so lost haha

rich adder
#

mate, just rename it lol

#

make sure it matches the class name

wary sigil
#

how do you rename the one on the side

rich adder
#

right click? rename ?

#

you're renaming the filename not the class

#

the class is fine

#

its normally allowed to have different filename and class name, but in unity not so much

wary sigil
#

yeah I think I tried to do that but it doesn't copy over

#

oh

#

restarting unity fixed it

#

probably a local issue

rich adder
summer stump
#

I was gonna suggest copying the code onto a new script and deleting the old one

quaint anchor
#

sorry to be a bother but i'm new to unity, how do i make solid ground for 2D, I created a square as a 2D object and added a tilemap collider to it but my player just clips thru the floor

summer stump
quaint anchor
#

yes the player has both a box collider and circle collider

summer stump
#

Are either collider set to isTrigger?

#

Ground or player I mean

quaint anchor
#

nope

#

should i set player to isTrigger ?

summer stump
#

Show the editor with the player selected

rich adder
#

show what you mean by "clip through"

#

also yeah show inspectors

quaint anchor
#

for the player

#

for the square

#

this is what i mean clip through, just doesnt collide

summer stump
rich adder
summer stump
#

Can you show the whole editor, uncropped

quaint anchor
rich adder
#

does it still happen if you disable the script ?

#

I see player script there, could be causing issues

summer stump
#

That scale is wildly massive

rich adder
#

also yeah lol wtf

summer stump
#

48 meters tall

quaint anchor
#

yeah needed the character to show up lol it was tiny before

#

just scaled it up

rich adder
#

gonna take a wild guess and say groundchecks are not properly working

quaint anchor
rich adder
#

also is that a dynamic rigidbody ?

quaint anchor
summer stump
#

Did you find the CharacterController2d script online?

quaint anchor
#

yes

summer stump
#

Is that the one you disabled?

quaint anchor
#

the character controller 2d script came from online, character movement is mine

quaint anchor
polar acorn
summer stump
#

The former

#

Also not a code question

polar acorn
#

Whenever anything on a canvas changes, every element on that canvas redraws. In general, anything that animates should be on its own canvas

fallow silo
languid spire
#

nothing there will give a performance boost, both options will degrade performance

summer stump
# quaint anchor yes

I dunno what is going on. I would try fully removing the CharacterController, setting the scale back down to 1,1,1, and then move the character up a little to avoid starting in the ground collider

quaint anchor
summer stump
polar acorn
#

Doing nothing is always faster than doing something

summer stump
quaint anchor
#

the issue with when scale is 1 1 1 is that the camera is like this and i cannot see anything

#

since the character is so small

summer stump
rich adder
#

is that even a tile?

summer stump
#

What is the z position of the camera

slender nymph
quaint anchor
#

how do i paint tiles? just assumed adding the collider would be enough

#

and it would recognise the square as the tile

rich adder
#

nope

#

thats a sprite renderer, not tilemap renderer

quaint anchor
#

this ??

rich adder
#

if you want to paint tiles you need a tilemap yes

quaint anchor
#

okay that makes a bit more sense

#

i do have a tilemap already

rich adder
#

yes but ur mixing a sprite renderer with tilemap

#

if you were to add a box collider to ur sprite you'd probably get collisions

quaint anchor
#

right

#

okay so how do i paint the sprites given this

rich adder
quaint anchor
#

ah i see

#

okay well

#

the player still falls through

#

do i need to set one as isTrigger?

summer stump
#

IsTrigger means there will be no collision/it is not a physical object

quaint anchor
#

oh

rich adder
#

tilemap needs to live in grid

quaint anchor
#

done that

rich adder
#

and did you add tilemap collider to the new tilemap

quaint anchor
#

forgot, sorry

#

okay it works now, perfect thank you

rich adder
summer stump
#

I am not great with 2d

rich adder
#

and then they probably added tilemap collider and tilemap components on it thinking it would work as part of collider

#

that would imply they would have removed the original box collider for making tilemap

summer stump
rich adder
summer stump
olive storm
#

oke

polar acorn
#

Materials are putting textures on the model

#

That is what putting a texture on a model means

pallid iron
#

ohh gotcha

#

what i wanna figure out is;
how do i make the zipper look.. well
more as it should?

polar acorn
pallid iron
#

alright, i'm gonna delete these messages and ask the question there if that's okay

polar acorn
#

Yes. Pick one and ask there, don't post in all three

olive storm
#

braah no one is responding

frosty hound
willow scroll
frosty hound
olive storm
#

womp womp

rich adder
#

people posting multiplayer questions in code beginner

#

hilarious

polar acorn
pallid iron
#

i feel an argument coming

#

lemme get my popcorn

olive storm
pallid iron
#

oh ok

desert citrus
#

hey guys does anyone have any tips im doing 2d top down game and i guess my default state is set to idle down because after moving when i dont press buttons character looks down. How can i make it so that the character keeps looking the way it was last moving. Example: if i press D i want it to keep looking right even after i dont touch keyboard. thank you

wintry quarry
#

it will retain whatever it was

desert citrus
#

oh yeah thank you so much man 🙂

cobalt dagger
#

how do i make an object face another object in 2D?

wintry quarry
#

(or possibly .up, depending on how your sprite is laid out)

cobalt dagger
#

oh okay

desert citrus
wintry quarry
#

hard to say specifics without seeing what you have already

cobalt dagger
#

it works thank you

desert citrus
buoyant meteor
#

how do i just get a script from an object using getComponent

honest haven
#
    
    [SerializeField] private int enemeyPositionOne;
    [SerializeField] private int enemeyPositionTwo;
    [SerializeField] private int enemeyPositionThree;

      public void Start()
    {
        enemeyPositionOne = activeBattlers.IndexOf(activeBattlers[1]);
        enemeyPositionTwo = activeBattlers.IndexOf(activeBattlers[2]);
        enemeyPositionThree = activeBattlers.IndexOf(activeBattlers[3]);
        
        activeBattlersPosition.Add(enemeyPositionOne);
        activeBattlersPosition.Add(enemeyPositionTwo);
        activeBattlersPosition.Add(enemeyPositionThree);
    }

     public void RandomlyRotateCubes()
    {
        if (Random.value < 0.5f)
        {
            rotateCounterClockwise = true;

            for (int i = 0; i < activeBattlers.Count; i++)
            {
                enemeyPositionOne+=1;
                enemeyPositionTwo += 1;
                enemeyPositionThree+=1;
            }
            
            StartCoroutine(rotationTriangle.RotateCubesClockwise());
        }
    }``` Hi need some help please. what im trying to do is set the active batters index into a list. and then when the rotate they change postion. So im trying to keep track of what player is in what postion. so player 1 = 1 player 2 = 2 and player 3 = 3. if the rotate i want to update the list in ++1 but of course there is only 3 so i want it to loop so player 1=2, player 2=3 and player 3 =1. but i dont know how to bring player 3 back down to 1. trying to almost do it like an array becuase on the last one if i did ++ that would go back to zero correct?
#

i cant hard code it like above becuase next time they rotate it will be player 1 = 3, player 2 = 1 player 3=2 and so on. I juat dont know how to do it

wintry quarry
honest haven
#

really lol where

#

array?

wintry quarry
#

I was replying to someone else

honest haven
#

sorry

buoyant meteor
wintry quarry
wintry quarry
#

Because your question/description makes little sense. What use would it be to find "the first script"?

buoyant meteor
wintry quarry
buoyant meteor
#

they dont

#

each weapon only has one script

#

but each script has a different name respective to the weapon type

wintry quarry
buoyant meteor
#

thats what I have set up

wintry quarry
#

So then what's the issue

#

You just do GetComponent<Weapon> or GetComponent<IWeapon> and you're done

buoyant meteor
#

is just that then each script on each weapon has a different name

wintry quarry
#

Also which one of the three do you have set up?

wintry quarry
buoyant meteor
#

interface

wintry quarry
#
IWeapon weapon = theObject.GetComponent<IWeapon>();
float damage = weapon.DamageAmount;``` or whatever you call your damage property
#

this is the whole point of interfaces

#

so you don't have to know which IWeapon it is, you just use the interface

buoyant meteor
#

Yup, on the learning curve with interfaces

#

so in your small example shouldnt DamageAmount actually be a method?

wintry quarry
#

Makes more sense as a property to me

#

unless you need parameters for it or something

buoyant meteor
#

how would that work then?

wintry quarry
#

Wdym?

#

It would work like any property works

#

Not to be confused with a field of course.

#

Interfaces can't have fields, but they can have properties, no problem.

buoyant meteor
#

ok I thought they couldnt have properties so let me look into that.

wintry quarry
#

There's nothing stopping interfaces from having properties

#

properties are really just methods anyway.

buoyant meteor
#

nvm im trippin

#

I was thinking about something else

valid pulsar
#

Im trying to make a turret that is two parts that rotates to face an object. I wrote some code That "works" but only for a single axis at a time (It works if the base is set to rotate and the gun isnt and vise versa). If i try enabling both at the same time it then dosent work. Also I believe there is an easer way to do what im doing because currently Im giving the boecjt a local rotation then another local rotation. (The base is has the y bool set to true and the gun has the z bool set to true)

buoyant thistle
#

like is it a transform function?

wintry quarry
#

You either rotate the Transform or the Rigidbody if you have one

#

if you have a Rigidbody, you should generally be using that

buoyant thistle
#

so like rigidbody.rotate ?

wintry quarry
#

no not like that

buoyant thistle
#

like how

wintry quarry
buoyant thistle
#

no, ill go try that

#

thank you

valid pulsar
dusk minnow
#

I have a problem, my autocomplete and my c# doesnt load, i cant see auto completion advice and nor can i see any other possible completion

tawny bolt
slender nymph
eternal falconBOT
dusk minnow
slender nymph
#

make sure you have followed all of the steps for the guide

dusk minnow
#

alr, im updating the vsc editor rn, thanks bro

slender nymph
#

well that's wrong

dusk minnow
#

no

#

i mean in unity

slender nymph
#

yeah, i know

dusk minnow
rich adder
slender nymph
slender nymph
#

show me where you see it says to update the Visual Studio Code Editor package

dusk minnow
#

it said update befor

slender nymph
#

yes that is the correct package. you said "vsc editor" which is visual studio code editor, notably not the same thing

dusk minnow
slender nymph
#

are you even using visual studio or are you using vs code

dusk minnow
#

vsc

slender nymph
#

well then "the first thing noted up there" is also wrong considering the first thing noted in the bot message is for visual studio

dusk minnow
#

thanks, doesnt help

rich adder
# dusk minnow

you're still missing the Unity extension aren't you ? Solution explorer missing

#

that should install C# Devkit with it

dusk minnow
rich adder
#

clos vscode first

dusk minnow
#

how to do that

dusk minnow
rich adder
#

External Tools page where you connected Vscode in unity

dusk minnow
#

1 sec

#

yes

dusk minnow
#

ah i see it

rich adder
dusk minnow
#

done

#

bro nvm

#

idek i clicked it and it worked, before it didnt

rich adder
#

uh you should not click to use C# extensions

dusk minnow
#

Thank you anyways UnityChanThumbsUp

dusk minnow
rich adder
#

Unity plugin uses Devkit

dusk minnow
#

why not

dusk minnow
rich adder
dusk minnow
rich adder
#

fuck it, if it works it works ig..

dusk minnow
dusk minnow
valid pulsar
quartz mural
#

can someone help me with my main menu please

#

when i press tutorial

#

it starts a new game

#

this is the code

polar acorn
quartz mural
quartz mural
#

begginig is the name of the scene after

#

its the correct scene

#

thtat one workd

polar acorn
quartz mural
#

it the tutorila one

#

so should i get rid if the playgame funcitno

polar acorn
#

What are you expecting to happen that isn't happening?

quartz mural
#

ok

#

so when i press

#

tutotiral

#

it takes me to the first scene

#

which is only supposed to come up

#

when i press new game

#

the tutoirla button

#

is supposed to load up a differe scene

#

but it doesn

#

the new game button works

polar acorn
#

So, the issue is that the tutorial button does not take you to the scene "Tutorial"?

quartz mural
summer stump
polar acorn
# quartz mural yes

Unless you're getting an error, if you call that function, you're loading the scene "Tutorial"

#

Whether or not you actually stay in it is a matter unrelated to what you've posted so far

quartz mural
#

i just need to get there

#

idk why it doesnt load

polar acorn
quartz mural
#

all the buttons take me to the same scene

quartz mural
#

nope

#

it doesnt come up

#

the log doesnt come up

polar acorn
#

Then nothing is running that function

quartz mural
#

wdym

#

but the code is there

#

is there smt wrong with it

polar acorn
# quartz mural wdym

If you put a log in that function, and that log doesn't run, then the function isn't running

#

Where are you trying to call that function from?

quartz mural
#

main menu script

polar acorn
#

Show

quartz mural
quartz mural
polar acorn
# quartz mural

Okay, so if you put a log in GoToNewTutorial before the load scene, and that's not logging, then this button is never clicked

quartz mural
#

ok

#

it doesnt come up

polar acorn
#

Then that button is never clicked

quartz mural
#

it is though? 😭

#

it changes scenes cuz i click it

polar acorn
# quartz mural it is though? 😭

Well, if you've shown that this button calls that function on click, and you've put a log in that function that will print something whenever the function runs, and you don't see the log, then that is 1000% inviolable proof that the button is not being clicked

#

So either it's not being clicked, or one of the facts above is incorrect.

#

The fact that it's going to a different scene seems to indicate that you're clicking on that button

quartz mural
#

i copied and pasted it

#

renames it

#

and gave it a differen location for the scene siwtch bit

#

to switch to a different scene

#

this one works

#

this one oesnt

polar acorn
# quartz mural

Put a log in that function. Does that one print? What about when you put it in that function and try to click on what you assume is the TutorialButton? Does it print the same thing?

quartz mural
#

all of these buttons r subclasses

#

of the main menu

#

the main menu has the script

#

of main menu

polar acorn
#

Put a log in GoToNewGame

quartz mural
polar acorn
#

attempt to click on TutorialButton

#

Does that log print

quartz mural
#

ok

frigid sequoia
#

Any idea why the reference to projectilePatternParent get lost SOMETIMES after performing the attack?

quartz mural
#

doesnt show for either

polar acorn
quartz mural
#

but still works?

#

that means the functino isnt used at all?????????????????????????

#

😭 😭 😭

polar acorn
eternal falconBOT
frigid sequoia
polar acorn
#

` not '

quartz mural
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
    public void PlayGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); // Loads when the game starts
    }

    public void GoToNewGame()
    {
        Debug.Log("new game loaded");
        SceneManager.LoadScene("Beggining"); //When New Game is pressed go to new game
    }

    public void GoToNewTutorial()
    {
        Debug.Log("tutorial loaded");
        SceneManager.LoadScene("Tutorial"); //When Tutorial is pressed go to Tutorial
    }

    public void QuitGame()
    {
        Application.Quit(); //Back button for Tutorial
    }
}
quartz mural
polar acorn
quartz mural
#

yes

#

im aware of that now

#

but why

#

this script is connected to the Main menu

#

which is the parent class to the buttons

polar acorn
polar acorn
# quartz mural but why

Because nothing calls these functions. Since you've sent screenshots of buttons that appear to be calling these functions either:
A) The object that they are calling functions of is not this script
B) The buttons are never being clicked at all

quartz mural
#

DONE

#

FIXED IT

#

it had another script attacked to it

polar acorn
#

On one of those buttons, click (once) on this object here. What highlights in the inspector?

quartz mural
#

thanks for the help bro

polar acorn
#

Okay, there we go

#

Remember, code cannot lie.

quartz mural
#

yes 🫡

polar acorn
#

If the facts are telling you something that makes no sense, assume the code is correct and it is the fallible human jelly brain that is the problem

quartz mural
#

yes

daring oasis
#

hey i am very new to anything related to game dev and i want to do a basic 2D game i tried making basic player movement , it works but it feels like i am on ice or in space is there any way to fix it without using linear drag?

deft grail
#

!code

eternal falconBOT
daring oasis
# deft grail how are you making the movement
float xAxis = Input.GetAxis("Horizontal");
        float yAxis = Input.GetAxis("Vertical");

        if(xAxis != 0){
            rb.velocity = new Vector2(xAxis*Speed,rb.velocity.y);
        }if(yAxis != 0){
            rb.velocity = new Vector2(rb.velocity.x,yAxis*Speed);
        }
daring oasis
#

getaxisraw will return only 0 or 1?

deft grail
#

-1 0 1

daring oasis
#

oh ok thanks

deft grail
daring oasis
deft grail
frigid sequoia
#

Just a quick random question that came to my mind; why is Random.insideUnitSphere a parameter and not a method? Cause it is missing the "()"

teal viper
frigid sequoia
teal viper
teal viper
daring oasis
teal viper
teal viper
frigid sequoia
teal viper
daring oasis
teal viper
frigid sequoia
#

Isn't that the same?

harsh wraith
noble rover
#

Hey so Im wanting to add 180 degree turn animation for my player I have 2, walk turn 180 and sprint turn 180, however I cant for the life of me find a tutorial that shows how to add this logic has anyone got a recommendation for one or would anyone mind having a look at my code its a modified script of Isteps third person controller and pointing me in the right direction https://paste.ofcode.org/TrTd6WWyW293PcQVVs5V3z

teal viper
teal viper
teal viper
modest sierra
#

I got a problem with my script. I got 3 gameObjects that I reference in this script. connection1 is the child of grabbedObject. The objective of this script is to match the position and rotation of the connection1 to connection2, but with the rotation being flipped so it sorta "mirrors" themselves. Since the grabbedObject is the parent and not the child of the connection 1, it doesnt move with it, so I do it through the script. This script should make it so the grabbedObject stays with connection1, moves its position and rotation offset (since connection1's position is offset from grabbedObject). However, it doesnt seem to work. connection1 doesnt rotate correctly and neither does the grabbedObject. Can anyone help me with this? Lmk if you dont understand what I explained.

eternal needle
eternal needle
frigid sequoia
daring oasis
slender nymph
frigid sequoia
#

What's the difference?

teal viper
#

Parameters are what you pass into method calls

#

Properties are what we are discussing

#

And you seem to be confusing then with member fields

grizzled zealot
#

I understand that I can write the code, but maybe someone else already did and also caught all the corner cases:

Is there a pooling library where I can register objects and automatically create pools for them? I don't want to have to code each pool, but instead just register a gameobject/prefab with a pool and say: create me a pool of those with a certain ID.

frigid sequoia
#

Also, basically the member fields are just the parameters for the whole class for me XD

teal viper
teal viper
#
private int intField;
public int IntProperty => SomeCrazyMath();
public int Method(int intParameter)
{
    return SomeCrazyMath2(intParameter);
}

Understand?

eternal needle
frigid sequoia
grizzled zealot
teal viper
cyan shoal
#

Anybody know why my script for detection only works sometimes? Here's the script. ```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class CarTrigger : MonoBehaviour
{
public GameObject[] InteractText;
public string sceneName;
public bool inTrigger = false;

private void OnTriggerEnter(Collider other)
{
    InteractText[0].SetActive(true);
    Debug.Log("Enter");

    inTrigger = true;
}

private void OnTriggerExit(Collider other)
{
    InteractText[0].SetActive(false);
    Debug.Log("Exit");

    inTrigger = false;
}

void Update()
{
    if (InteractText[0].activeSelf == true && inTrigger == true)
    {
        if (Input.GetKey(KeyCode.E))
        {
            SceneManager.LoadScene(sceneName);
        }
    }
}

}

teal viper
frigid sequoia
#

I get it

teal viper
frigid sequoia
#

Thxs, but I am gonna keep mistaken then all the time, they just seem near synonyms to me XD

#

I will try not to though

timber tide
#

properties are getter/setter methods in any other language

#

they are just c#'s sugar coated way to do things

eternal needle
# grizzled zealot Why do you think it caused unnecessary complexity? I would need object pools for...

well first thing, this object pool is likely gonna exist as its own all encompassing solution. Thats the purpose of it being made. Because of this, you're probably aiming to just have one of these, as a singleton. If not, well then now you're gonna have to inject the reference to the correct object pool in each and everything that uses it. Not always fun to do
2nd is you also have to handle resetting an object properly. This means like a pooled rigidbody (maybe a bullet) might need its velocity set to 0 when its released/gotten from the pool. Now that theres just a collection of object pools, all with objects that need to be reset in different ways, you have to figure out how you want to attach logic to reset an object.
In my case, i wanna also have some objects ignore collision from the character that spawned it so that a bullet doesnt hit the user it spawned from. This isnt really fun to setup. I know how to do it, but it doesnt feel right

teal viper
frigid sequoia
teal viper
#
public float MyFloatProperty
{
    Get
    {
        Calculate something to return;
    }
}
timber tide
#

they are similar, but another takeaway is that you don't need to invoke properties like methods

#

but again, just c#'s special syntax of creating these types of getters

frigid sequoia
#

Ok, sure. It makes sense

timber tide
#

auto properties though could be confusing though as they are both a getter/setter and a field

#

hence, property field

frigid sequoia
#

So if I have a Property and I call it and it is assigned to a method, it would just be like exactly the same that calling that method to begin with.

#

So, yeah, basically sorta of a getter

teal viper
#

Though, sometimes thy are used for that as well for readability

teal viper
# frigid sequoia So if I have a Property and I call it and it is assigned to a method, it would j...

So, imagine you have an inventory class that contains a list of items. You don't want to expose the list to outside the class, but you want to know the amount of items in the inventory, so what you could do is implement a property that returns the list count:

public int ItemsCount => itemsList.Count;

That's a typical use case for properties. You can implement it with a method of course, but property makes it so much easier.

grizzled zealot
eternal needle
frigid sequoia
slender nymph
grizzled zealot
eternal needle
#

Yes they exist in a scene, an ObjectPool is nothing special related to a gameobject. its just a collection of gameobjects and gives you whatever ones are available

frigid sequoia
slender nymph
#

the property is a method though. properties are just methods that look like variables to reduce the number of actual methods you are writing. you don't need special Get and Set methods because that's what properties are for

timber tide
#

It really does confuse me that you don't need to invoke properties, especially on the caller side of things

#

which means that it's up to naming convention usually to clarify it for me

slender nymph
#

just don't have public fields, then you know that everything you are working with is a property 🤷‍♂️

frigid sequoia
#

So whatever I have there is calculated at runtime when calling a Property?

slender nymph
#

yes public int ItemsCount => itemsList.Count; works *exactly the same as pubic int GetItemsCount() { return itemsList.Count; }

#

it's just easier and prettier to write

frigid sequoia
#

Ok, I kinda see where I can use it now

modern rover
deft grail
#

it needs to have a different name

modern rover
#

it is my own

#

what should the name be

deft grail
#

actually no it doesnt, because you have a lower case i

deft grail
modern rover
#

yeah i just started coding so i jsut followed a tutorial for how to make the camera look around and i got stuck

deft grail
#

you should make them be the same, ideally upper case, which then would require having a different name

rocky canyon
#

keep ur filename and class names identical

modern rover
#

here is the file name

#

u cant see it here

#

is that correct?

rocky canyon
#

looks that way

slender nymph
#

you probably have compile errors preventing unity from seeing that there is a MonoBehaviour in that file

modern rover
slender nymph
#

exactly

modern rover
#

yeah i noticed this error for a while and i dont know how to fix it

#

private PlayerInput.basicActions basic;

#

this line

slender nymph
#

if that is what the code looks like in vs code then you haven't saved it

modern rover
#

its definitly saved

slender nymph
# modern rover

this screenshot says otherwise because that line of code is different here

#

and the error implies otherwise because it actually matches up with what that screenshot shows

modern rover
#

im jsut messing with it but the error is ther efor both versions

slender nymph
#

did you copy the code from a tutorial?

modern rover
modern rover
#

i mean i just followed the steps

slender nymph
#

pay better attention to the tutorial, your code is not exactly the same

#

and it's all because you've named your input actions PlayerInput and just allowed vs code to import the incorrect namespace

modern rover
#

ok ill try again thanks for helping

brittle isle
#

The unfortunate catch with my code for my mercy invincibility is that I can push enemies around, even when I told it to ignore collisions. at least it doesn't stay invincible. https://hatebin.com/qhergypwtq

faint osprey
#
    // Start is called before the first frame update
    void Start()
    {
        rb = gameObject.GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if(dir[1] == true)
        {
            rb.position -= -transform.right * conveyorSpeed * Time.deltaTime;
            rb.MovePosition(rb.position + -transform.right * conveyorSpeed * Time.deltaTime);
        }
        
        if (dir[3] == true)
        {
            rb.position -= -transform.forward * conveyorSpeed * Time.deltaTime;
            rb.MovePosition(rb.position + -transform.forward * conveyorSpeed * Time.deltaTime);
        }
    }``` Im using this script to immatate a moving conveyor and im attaching the script to multiple game objects and flicking certain bools in the array to true to get it to go in different directions however they all act as if the same bool is true for every instance of the script and I dont know why
worthy veldt
#

try using else if

faint osprey
#

didnt work

#

thats not the issue

#

the issue is it thinks a bool is true when it isnt

worthy veldt
#

what do you mean by flicking the bools in the array ?, show the code

teal viper
rich adder
frigid sequoia
polar acorn
frosty lantern
#

I'm having 2 issues: only my pawns can move forward reliably, the knights, horses, king, bishop and rook are finnicky (they do work on occasion and not on others and I can't make heads or tails of what to debug)

the second issue is that after I implemented the gameManager script I am getting null errors out of the woozah

  • BitBoard

https://gdl.space/isimasorud.cpp

  • BoardCoord

https://gdl.space/jedeginapu.cs

  • GameManager

https://gdl.space/wojuqizito.cs

  • ChessPiece

https://gdl.space/ivuluxujuq.cs

  • Piece Setup

https://gdl.space/usanovusup.cs

#

I have to sleep but if anyone happens to see what I don't please ping me

frosty lantern
#

Through further testing I've also found that the logic that prevents jumping pieces in the display moves section also doesn't work correctly

#

For the rooks and queens. The bishop works fine and so does the knight and the king

loud mango
#

is there any way to keep a Debug.DrawRay for longer time?

#

or until i close the game?

rich adder
loud mango
rich adder
#

so use that

loud mango
#

idk how

#

idk the parameter thats why

rich adder
#

is ur IDE not showing it to you ?

loud mango
#

till the color

rich adder
#

there are more signatures tho

loud mango
#

ohki its working now

#

thanks!

rich adder
#

so its a float, so prob at most you can do float.MaxValue

loud mango
#

i never noticed the Duration parameter

#

cuz debugging the ray was not needed till now

loud mango
#

like, when i shoot, i think my crosshair is not in the middle of the screen cuz the bullet's not hitting everytime

#

and i dont think there can be any other reason for them not hitting

rich adder
loud mango
#

do u have any examples / links maybe?

#

nvm its fixed

willow scroll
rich adder
willow scroll
rich adder
#

na I think they were trying to see their Debug.DrawLine in build

willow scroll
#

Got it

rich adder
#

or maybe i misunderstood what they wanted to debug lol

loud mango
#

i wanted to debug the raycast in built version

young fossil
#

Hey guys, so about the new input system. How are control schemes meant to work?

To my understanding they were input modes that were defined by me but they seem to automatically change depending on the input detected.

#

So for example, I use the mouse/keyboard, I touch the joystick and it automatically switches to that

rocky canyon
# young fossil Hey guys, so about the new input system. How are control schemes meant to work? ...

thats desired behaviour i believe.. unity automatically detects which device is being used and automtically switches..
you can tailor inputs for certain things.. 1 scheme for kb 1 scheme for joystick.. or a scheme that has both types of inputs for a singular action..
the old input system for example has two bindings for each Axis.. you could remove extra's if u wanted (by default i think both the old and new input system is enabled)
you could handle swapping manually to only use 1 type of input.. or remove any trace of a certain type of input from the controls

young fossil
boreal hare
#

Hello

burnt wyvern
#

hi, i need help making a character climb a wall, not wall jump but like climb up. my code rn has a lot of bugs and isnt working properly and im not sure what to do to fix it.
https://gdl.space/ebuzaxiqoc.cs
here is my code

rocky canyon
young fossil
rocky canyon
#

you just have to create 2 schemes.. 1 for just the keyboard w/ no alternative keys like a joystick

young fossil
#

Sorry to be persistant in asking, just don't want to write a system for Unity to just ignore it xD

boreal hare
#

Coroutines are trash if you use alot of methods?

rocky canyon
#

does it still respond to joystick inputs if u set it to only use hte new input system.. (in player settings active input handling is set to use both)

young fossil
#

Is there any decent documentation on any of this you know of?

rocky canyon
#

if ur schemes only include keyboard inputs i wouldnt think it'd respond to joystick inputs

young fossil
#

Okay, so wait. Let's get this straight:

You have a map of keybindings called an "Input Action Asset".

Then inside each of those, you have Control Schemes which are defined in the Unity window.

So currently I have a single "default" Input Action Asset that contains two control schemes: keyboard&mouse and gamepad.

young fossil
young fossil
rocky canyon
#

https://www.youtube.com/watch?v=e30i55Hp-to&ab_channel=SasquatchBStudios
and also theres an argument to be made that you Want unity to actively be using both..
you said you wanted to chose in a menu.. but say I wanted to use a Joystick.. but it defaults to keyboard..
say i use a joystick b/c i dont have a keyboard.. how would i navigate thru the menu's to change it to use the joystick?

young fossil
#

Yes. It is a good feature, actually I have made a project with what you describe there. But for this feature the game only should switch depending on an in-game setting

rocky canyon
#

i can't find any specific tutorials on how to force it to use just keyboard but the new input system is supposed to be modular.. and allow u to use different schemes.. or no schemes.. etc.. #🖱️┃input-system would know how

young fossil
#

Actually, to add to that, I can't find an tutorials OR documentation.

young fossil
#

I found this and it's where all the new input stuff is

rocky canyon
#

theres lots of documentation...

young fossil
#

Yea, I think you're missing what I'm getting at, there is no methods/built-in functionality that implies you can use the Input system's control schemes manually. Instead to my understanding, the automatic behavior is not configurable...

#

Which further implies that it shouldn't be used like that, right? Confusing since it's a pretty concrete feature across many game engines

rocky canyon
#

its an entire system.. not compareable to a single built-in method ud find in a Math class for example..
i dont think its fair to imply it couldn't and probably pretty straight forward to code yourself given a bit of research

#

doesn't imply it shouldnt be used like that.. as it is a full replacement for the old one.. what u can do with the old one u can do with the new one.. + more.. not less

#

seems around the web, ppl do use it like that

burnt wyvern
#

very sad i cant use new input system

#

i hate old input system

rocky canyon
#

yea, its pretty lame.. I'm slowly using the new one more often than not

burnt wyvern
#

im stuck on unity 2018.2

rocky canyon
#

and now that the newer versions of unity have both systems enabled default.. it helps me use it more often

burnt wyvern
#

ios 8 support 👍

near siren
#

Can I ask a question about learning Unity

young fossil
#

Thanks though I appreciate your help. Like you say, guess it just needs more research on the forums and how others have done it

rocky canyon
near siren
#

I am watching a tutorial that is asking me to use Unity events. I understand code but I feel like learning this is useless because theres no way I could reproduce changing the editor. Do people usually modify the editor like this?

young fossil
rocky canyon
young fossil
near siren
proven junco
#

someone tag code sharing??

rocky canyon
#

ohhh, you meant the unity eventsystem** its mainly for ui.. such as clicking, drag and dropping interactions.. but it can be used with 2D sprites as well.. and even 3d objects(anything with a collider) if its paired with a graphics raycaster

proven junco
#

cant remember what sites

rocky canyon
#

i thought you meant Unity Events..

proven junco
#

my code is too long for dc too

rocky canyon
proven junco
rocky canyon
#

but u can use !code to pull up an embed with a list of em

eternal falconBOT
proven junco
#

okay so my character is way too fast and I can only change drag to decrease the speed but then my gravity gets weird

rocky canyon
#

float currentSpeed = isRunning ? runSpeed : walkSpeed; why not change the speed variables you already have

proven junco
#

dont reallyunderstand what you mean

rocky canyon
#

you ahve variables that control how fast you move.. runSpeed and walkSpeed are two of em..

#

why not lower those

proven junco
#

yeah I know

rocky canyon
#

instead of cranking up the drag

proven junco
#

but I have

#

but it does not work

hot lily
#

how to invert cinemachine camera direction?

#

when i pushed my mouse upwards the cam points down and looks at ground

rocky canyon
# proven junco but it does not work
        float currentSpeed = isRunning ? runSpeed : walkSpeed;
        Vector3 movement = (transform.forward * vertical + transform.right * horizontal) * currentSpeed;
        rb.AddForce(movement, ForceMode.VelocityChange);```

it has to. to build `movement` you multiply ur inputs * the currentSpeed
#

if u drop that it will slow down..

burnt vapor
rocky canyon
#

make them 0 for example..

#

bet u dont move at all

proven junco
#

but If I have 0 I cant move

#

and 0.3 does not do any

#

either

#

I gotta have0.000000001

#

or some is wrong

boreal dove
#

Player character rotation gets reset when moving

proven junco
#

okay now it works I did some wrong first time

young fossil
#

@rocky canyon went to do another job without figuring a fix, then noticed... 🙃 one of those days

#

Amazing how that isn't in the docs

tepid summit
#

is vs the blue logo orthe purple logo

burnt vapor
#

VS is the purple one

tepid summit
#

ok

#

ill switch now

proven junco
#

I dont know if this is my coding or not but my character glides instead of walking so I continue to move after I´ve released "W"

#

!CODE

eternal falconBOT
proven junco
proven junco
rocky canyon
#

drag is basically air resistance

#

u want a Physics Material to apply to the rigidbody/collider its Friction

tepid summit
#

aight we got it installed

#

now just to !ide

eternal falconBOT
tepid summit
burnt vapor
#

No

#

Your scripts are not related to the IDE

tepid summit
#

ok

tepid summit
#

aight cool

#

we got it configured

#

mind if we continue ith my issue?

#

ill reply to it for you

#

right ehre

whole idol
#

Why is this thing visible in my game?

#

I thought this was supposed to be visible only in my scene

#

for me to see while editting the actual scene

#

look at this invisible green object at the end

#

Ive turned its renderer off so why is it visible?

#

this Green "END" shouldn't be visible in my game

#

is there any way to do this without removing its green symbol ?

#

I mean I can change this here

#

but i dont think this is supposed to be showing in the game play mode

#

should I turn off 3D icons?

young fossil
#

Are you trying to turn it off while keeping other gizmos on?

whole idol
#

oh okay never mind

#

that fixed it yeah

#

3D Icons

tepid summit
#

(Just reposting so people don't have to scroll 400 messages up) But here I have these 2 scripts, which are causing these 2 errors that i have no clue how to get rid of. any ideas?

https://gdl.space/geqesekuxe.cpp

#

i can see how to fix the first issue

#

but idk how to invoke a method

#

at least i havent heard of it

#

oh eait

#

the errors have changed

#

there we go

#

ok nvm i fixed it

#

sorry if i spammed the channel

green ether
#

What is UIHandler?

tepid summit
#

an object in my sene

#

scene

#

but i fixed it anyway

green ether
#

is it a class you created?

tepid summit
#

ye

green ether
#

Well

UILink = UILink2.GetComponent<UIHandler>;
#

UILink is a GamObject

tepid summit
#

man

green ether
#

youre trying to put the class UIHandler into Gameobject

tepid summit
#

i appreciate it

#

but i fixed the issues

#

i wrote the script late last night

#

it was an obvious fix'

#

but i truly appreciate the help

green ether
#

I think the problem was the naming

#

UiLink and UiLink2 being 2 different classes is very confusing

#

but yeah)

tepid summit
#

yes

queen blade
#

quick question yall, its a little urgent but if I rotated an object with:

transform.rotation *= some Quarternion like (0,1,0,0)

is there a way to make this my new (0,0,0,0)

#

or (0,0,0)

cunning mesa
tepid summit
#

wouldnt you be able to set it to something like a var?

#

idk i dont mess with quaternions a lot

queen blade
#

err.. say after I rotated an object around the X-axis 90 degrees, when i rotate it around the desired y-axis

#

it now is rotating around the world z-axis

#

since i applied the 90degrees rotation on the object around the x axis, the object's y-axis is now alligned with the z axis (in our perspective)

languid spire
#

the only way I can think to do that would be to apply the X axis rotation to a parent object and then apply a local rotation to the Y axis of the child.

queen blade
#

i thought the easiest solution would be after I apply any rotation, I set the current rotation as my new default

languid spire
#

there is no method to do that

queen blade
#

so i can easily apply rotations again along the world's axis

queen blade
languid spire
#

it would be like applying a rotation in Blender, current rotation becomes Quaternion.identity. Unity can't do that

queen blade
#

ah yeah i wanted that effect

#

thanks, I'll look for another method👌

eternal needle
queen blade
#

when i rotated the object around the x-axis by 90 degrees and I want to rotate the object around the y-axis subsequently by pressed A/D

#

the object is now rotating around the z-axis

eternal needle
#

Maybe you want to use the relative to parameter here

#

If I have understood you correctly

daring oasis
#

how can i set a default value to a serialize field

eternal needle
#

[SerializeField] float a = 5;

queen blade
#

i didnt know that that was a parameter, I appreciate it

#

Thanks

eternal needle
queen blade
#

👍 fair enough, I will keep that in mind

daring oasis
#

Input.GetKeyDown returns a bool? if yes why

if(Input.GetKeyDown(KeyCode.LeftShift))

does not detect when i press shift

keen dew
#

You'll have to show the entire script. Most likely it's in the wrong place

glossy sierra
#

error CS0433: The type 'IAsyncEnumerable<T>' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=' and 'netstandard, Version=2.1.0.0, Culture=neutral,
anyone know abt this error?

daring oasis
# keen dew You'll have to show the entire script. Most likely it's in the wrong place
[SerializeField] int sprintMulitplyer=1;
void Update()
    {
        float xAxis = Input.GetAxisRaw("Horizontal");
        float yAxis = Input.GetAxisRaw("Vertical");
        if(Input.GetKeyDown(KeyCode.LeftShift)){
            rb.velocity  = new Vector2(xAxis,yAxis).normalized*Speed*sprintMulitplyer;
        }else{rb.velocity  = new Vector2(xAxis,yAxis).normalized *Speed;}
        Debug.Log(rb.velocity.magnitude);
    }
keen dew
#

GetKeyDown is true once, when you press down shift. So you set the sprint velocity for exactly one frame.

#

use GetKey instead if you want the sprint speed for the entire time you press down shift

loud mango
#

finally uploaded my game prototype

#

thanks for the help.... i dont remember names so you know if u helped me

burnt vapor
#

You're welcome

daring oasis
#

is it ok for player movement to use nested if? like use an if for sprinting and another for jumping and other things like that? and if no is it any other way?

burnt vapor
#

Often you should split your method into sub methods, which also improves documenting the code in a way. This could be one of those ways to omit nested if statements

#

Another one could be guard clauses, who knows

daring oasis
#
if(Input.GetKeyDown(KeyCode.Space)){
            Debug.Log("Pressed");
            rb.velocity = new Vector2(rb.velocity.x,jumpPower);
        }

i did this in the update and when i press space it does register but does not matter how high i set the jump power it does not add any velocity

burnt vapor
#

I'd say log rb.velocity after you set it and see what it actually becomes

#

Or log jumpPower

languid spire
keen dew
daring oasis
daring oasis
# burnt vapor Or log `jumpPower`

i logged both of them and when i press space jump power says is 100 and Y velocity says its 100 asweek but the character is not moving

keen dew
#

You'll have to show the full code again

burnt vapor
#

Then consider logging rb.velocity in your Update method and see what that logs

daring oasis
#

This is the code for jumping in a different script

if(Input.GetKeyDown(KeyCode.Space)){
            rb.velocity = new Vector2(rb.velocity.x,jumpPower);
            Debug.Log(rb.velocity.y);
            Debug.Log(jumpPower);
        }

This is the movement code

void Update()
    {
        float xAxis = Input.GetAxisRaw("Horizontal");
        //GetKey detects if the key is down for the whole period of time it is down
        if(Input.GetKey(KeyCode.LeftShift)){
            //Sprint when LeftShift is pressed
            if(touchingLand==true){
                Debug.Log("Sprinting While Touching Land");
            }
            rb.velocity  = new Vector2(xAxis,0)*Speed*sprintMulitplyer;
        }else{
            //Move normally if GetKey does not get input
            rb.velocity  = new Vector2(xAxis,0)*Speed;
            }
        //Debug.Log(rb.velocity.magnitude);


    
    }
daring oasis
#

so this is the problem

keen dew
#

Yes, because you set it to 0

languid spire
#

so both of those set velocity.y to zero

daring oasis
#

ahhhh

keen dew
#
rb.velocity  = new Vector2(xAxis,0)
daring oasis
#

waaait

burnt vapor
#

This is why context matters

#

And make sure you don't immediatley try to pinpoint an issue in your question. Notice here the issue was a completely different part of your code 😎

kindred halo
#

can anyone check why my weapon swapping isn't working?
The functions do seem to work as my swap animation plays but weapon doesn't change when I scroll my mouse
https://paste.ofcode.org/8qfiY52Y46defHiExRyKPw
here's the mouse scroll input code

{    if (Input.mouseScrollDelta.y != 0)
    {
        scrollDirection = Input.mouseScrollDelta.y;
        actions.SwitchState(actions.Swap); }
}```
keen dew
#

The first thing to do would be log the value of weapon.Length

#

and put a log in WeaponPutAway to check that it's called

kindred halo
keen dew
#

seems so

kindred halo