#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 504 of 1

steep rose
#

click other settings

#

then go under configuration

#

Active input handling

#

and tell us what it says

oak kelp
#

this ?

steep rose
#

correct

oak kelp
#

do i change it to both?

languid spire
#

ok, you did save and recompile your code didn't you?

oak kelp
#

yes everything is saved

languid spire
oak kelp
#

keep it Input Manager (old)>?

languid spire
steep rose
oak kelp
#

i get no errors

#

even when i press A/D/Spacebar nothing happens

languid spire
#

can you put a debug.log in the update itself, just to check it is actually running

steep rose
#

hm, are you entering playmode? your code should work

#

did you try do up the values in the inspector?

languid spire
#

maybe the script/gameobject is disabled

steep rose
#

doesnt seem like it

oak kelp
#

i have it checked

languid spire
#

if the debug.log is showing then it's running. show the console

oak kelp
steep rose
#

no errors or warnings, unity isnt giving us a lot to work with lmao

languid spire
#

ok, good, you can remove that

oak kelp
#

im just dont understand why no work

steep rose
#

are you tabbed into playmode?

oak kelp
#

i just click the play button at the top

steep rose
#

do you click the game view tab?

#

if not try clicking on it then doing inputs

languid spire
#

there are only 2 reason why the Debug.Log inside the if does not print

  1. An error is happening before the if is reached
  2. You are not pressing the spacebar
oak kelp
#

ok sooo umm

#

i figured out the problem

#

i was clicking the top screen not the bottom one

#

im sorry for wasing time

steep rose
#

okay so you were not clicking on game view

#

no problem, it happens

oak kelp
#

i feel bad now im use to unreal engine

steep rose
#

why feel bad, it happens

#

you're all good

oak kelp
#

for wasing your guys time

languid spire
#

no problem, even I have been known to make mistakes (admittedly a very long time ago), lol

steep rose
oak kelp
#

i try many engines UE4/UE5, RPG Maker MZ, GameMaker and now Unity so now i hope i can get use to this engine

gleaming kraken
#

hey guys, quick question

when using the or operator ||, it means only one of the conditions needs to be true, right?

steep rose
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

river garnet
#

How do I make my sprite jump while gravity is inversed? My gravity switch code is here, its seperate from my player movement code. Thanks ๐Ÿ™‚

languid spire
steep rose
eternal falconBOT
oak kelp
gleaming kraken
gleaming kraken
#

(im aware it's js code, but i figured the syntax is pretty similar so it accomplishes similar results)

steep rose
#

I would look up java operators then, they are probably the same but still

rich adder
#

javascript operator works the same as c# operator

steep rose
#

then the link stands true ๐Ÿ˜

gleaming kraken
#

or well no

#

not an ampersand

#

but rather checking if authorized and then checking in a nested statmenet if authenticated

languid spire
deft grail
rich adder
#

&& needs both conditions to be true

gleaming kraken
#

that's a pretty fatal flaw here

gleaming kraken
#

corrected it

rich adder
#

this code is bad anyway, missing early return..if first one logs why even run the second if statement?

river garnet
#

!code

eternal falconBOT
languid spire
gleaming kraken
languid spire
#

| means both conditions will be evaluated

river garnet
#

Im wondering how to make my character jump while inversed

#

This script is seperate from my player movement one

gleaming kraken
languid spire
#

yes

gleaming kraken
#

alright, thanks a lot!

languid spire
#

and nav is correct, there should be a return in there for it to make any sense

simple falcon
#

are quaternion understandings a beginners issue?

#

about to kick a gimbal to the moon over here

languid spire
simple falcon
#

so I need an angry wizard

#

how about, copying a quaternion and making sure its the same quaternion?

#

to the same object too

languid spire
#

no, you need a priest, just have faith they work

simple falcon
#

wololo

steep rose
#

and pass that for whatever

#

ig

simple falcon
#

heres the silly part, im sending it via osc, and reciving it via osc

#

so the meaning gets 'lost' and I have zero clue what Im doing

#

its for osc out to blender, but I had issues, so Im doing unity > unity first

#

90% the way there now

#

to blender will be another monster

#

RECEIVE | ENDPOINT([::ffff:127.0.0.1]:54057) ADDRESS(/rotation/L_Wrist) FLOAT(0) FLOAT(0.95881975) FLOAT(0) FLOAT(-0.28401527) this is my osc message, I can send hatebin stuff too, I hope this isnt too wizardry like when its quaternion to quaternion

steep rose
#

if im being honest, i have zero clue what OSC is

simple falcon
#

worst part is when i can swap an axis, it follows but you do another rotation and its no longer following, its crazy

languid spire
#

code please

simple falcon
#

sorry, preface, im learning a ton too didnt understand last week, osc is a protocol for sending info, I have a client and server on the game objects, just wanted to give preface and context because im using unity to build a app / tool here, was easier than using openxr and setting a dev environment, enough context though sorry

#

position follows fine now, although its an euler, works fine, didnt before lol

languid spire
#

line 46 is a big, big nono

simple falcon
#

testRotation = new Quaternion(testRotation.x + 0.01f, testRotation.y, testRotation.z, testRotation.w).normalized;

not Debug.LogWarning($"Position data mismatch or invalid for '{objectName}'."); Right ?

languid spire
#

yes, you can never manipulate the internal values of a Quaternion, so the + 0.01f and the normalized are out

#

'black magic box', do not touch for fear of explosion

simple falcon
#

Gotcha, removed that for now, for now won't be able to set it back to 1, 0 , 0 , 0 without it with my f key, not sure if I don't need it or not though for 'reset'

#

I want to be nice to the box

languid spire
#

1,0,0,0 is not a valid Quaternion.

simple falcon
#

sorry going by blender w, x, y, z in my mind

#

meant, 0 ,0 ,0, 1

languid spire
#

that is Quaternion.identity in unity speak

steep rose
#

oh are you making a unity to blender exporter or smth?

simple falcon
#

Unity to blender for openxr so I can use a mocap glove / oculus quest 2 hand tracking in blender

steep rose
#

ohhh you are gonna copy position and rotation from unity to blender

#

oh thats pretty neat

simple falcon
#

there's a tool out there already for now mocap fusion but processing time is ~15 mins for 2 mins of mocap, need something instant I have vmc4b with slimevr that works wonders

languid spire
#

sod that, I'd just write a python add on for Blender

simple falcon
#

I've been dying to animate something with hands so bad

simple falcon
#

I have some of the python for blender ready to go too

#

I tried c++ openxr and the dev environment after ~8 hours got set and then couldnt get openxr to detect hmd ๐Ÿง ๐Ÿ’ฅ haha

#

1.5 days bye bye

steep rose
#

wait why not just make ik in blender and control it via Python or c++ (maybe)?

languid spire
# steep rose or c++

never done c++ for blender, always done it in python, didn't even know you could c++ tbh

simple falcon
#

c++ was for openxr, just couldnt get the dev environment running

#

quaternions were 1:1 awhile ago, but I kept writing code and ... oops

steep rose
#

you should be able to use c++ for it?

#

i wouldnt see why you couldnt

#

unless blender just says no to it

languid spire
#

not sure how you would link the libraries

simple falcon
#

Only need OpenXR skeletal data to blender bones so I tried to use unity, wish it wasnt because the xr stuff takes a bigger load on system already running face mocap at the same time in conjuction with it, takes more resources, makes more lag

languid spire
#

tbh everything you need to do should be doable in python inside blender

simple falcon
#

but for now its been ~1 week, it'd feel wrong to give up

#

do need access to openxr skeleton though

#

blender has openxr sort of

#

but not sure if 3.6 lts would support, that's where I'd need it

languid spire
simple falcon
#

my LTS has ~50 addons lotsa paid stuff thats intertwines, lotta custom code, old but stable!

languid spire
simple falcon
#

Yeah, 90% are updated but I have so much custom code backed into blender for my own comfort too, I tried 4.x, my friend switched over he also relies on addons like animaide that dropepd support in 3.4x but he rewrote some of the code to make it work, he's been carrying the old along with him regardless of support ๐Ÿ˜‚๐Ÿดโ—

#

unfortunately blender 3.4x vr experimental stuff is limited on documentation, not sure if it'd be worth debugging around to see if vr skeletal data would even be there

#

its just unity has the openxr stuff pretty accessible, with some resources, I think this might be a good method

languid spire
#

anyway, back to your problem, your ocs output looks ok, but are you sure you are reading x,y,z,w on the blender side because they are switched you may be better outputting w, x, y, z from Unity to make sure

simple falcon
#

there are ~15 + vtuber apps, virtual motion capture has finger capture, but the pinky finger does not rotate correctly, so much searching on github for example code hahaa

#

for now I need to get x y z w to be 1:1 in unity I think

#

I couldnt get the child objects to rotate right in blender so I wanted to try in unity first if that makes sense

#

unity > unity 1:1 make sure that its doing the right stuff

languid spire
#

makes sense, as I said apart from line 46, your code looks fine

simple falcon
#

thanks for poking around with it! for now I tried flipping values, it just got more confusing haha

#

kinda like rotating a rubix cube around if you dont know what youre doing

languid spire
#

rotations are always a bitch, try simulating a gyroscope if you want to end up in the mad house

simple falcon
#

oof no gif

#

rotates rubix cube around until it breaks again

#

I will try asking slimevr, they somehow figured out the madness histerical confusion

languid spire
#

sorry I could not be of more help, as a politician would say ' I think you are being very brave'

simple falcon
#

something something black ops JFK "I am a donut I can do it"! ๐Ÿ’ช

simple falcon
languid spire
simple falcon
#

this is my little ducky haha, it hurt my hand once when I grabbed it and forgot about the needle in his head

#

he isnt used as often as typing a giant question into discord and then deleting it after though lol

languid spire
#

rofl, my rubber duck is in my head, it's why people are always giving me strange looks when I walk around talking to myself

simple falcon
#

Subvocalization requires louder vocalization sometimes ๐Ÿ—ฃ haha

steep rose
#

ah nevermind just looked it up, yes we rubber duck around here

river garnet
steep rose
steep rose
#

i dont see any jump code so

#

but thats the basic premace, just reverse whatever you are using to jump, probably a vector so reverse that

river garnet
#

Yeah its seperate from my movement code, let me paste that

#

!code

eternal falconBOT
river garnet
#

@steep rose this is my player movement code

steep rose
#

just reverse the vector using -

#

well reverse the inputs of it

river garnet
#

Which line and where do I put it

steep rose
#

rb.linearVelocity = new Vector2(-rb.linearVelocity.x, jumpingPower); this should work

#

just make a check if you are actually flipped

river garnet
#

how would I do that?

#

Im very new to this, dont quite grasp it fully yet

steep rose
#

just add a Boolean in Flip() that either toggles or doesn't depending on what the code does and see if that is true and if it is then use the opposite inverted jumping

river garnet
#

And would I put that script you just pasted in the gravity script or in my movement script?

steep rose
#

your movement script

#

i would suggest you !learn if you are new to this

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

river garnet
#

Under an if statement?

#

Yeah im doing the learning, im just trying to get this figured out

steep rose
#
if(isinverted){
  //do something
  // use inverted jump
}

if(!isinverted){
  //do something
  // use normal jump
}
river garnet
#

How do you make it know if youre inverted though

steep rose
river garnet
#

I dont know how to do that lmao

steep rose
#

its as easy as making a boolean variable and using it, either toggling it or not depending on if your code already toggles

#

boolean = !boolean; to toggle it (this should work, although i havent tested it)

karmic sparrow
#

hello i am trying to spawn an object then launch it and be able to control bit but it isnt accepting any inputs when spawned what am i doing wrong? i can seem to find any refrences online

deft grail
karmic sparrow
timid geyser
#

I was interested in creating a first person shooter, but I cant' really figure out what's more beneficial, a rigid body player controller or using a regular player controller. Any ideas?

deft grail
north kiln
#

Kinematic character controllers are very robust and usually what I go with

timid geyser
#

I was wanting to make something that would use more momentum kinda.

north kiln
timid geyser
#

Huh, shouldn't I make something from scratch though? Wouldn't using that without knowing scripting too much be bad?

#

Thats something im torn over quite a lot dhap

north kiln
#

Yeah, if you have little scripting knowledge it's probably not the best recommendation. But there are tutorials that go over making a kinematic character controller from scratch. You mentioned momentum so it might not be the most suitable? It's really hard to say, and sadly it's not the simplest topic even though so many games require one haha

timid geyser
#

Yeah, after looking through Halo 3 vidocs, I realized just how complex controllers are despite being so simple to play with.

deft grail
#

just try making each of them and see what fits what you need, no harm in trying and learning all you just get experience

timid geyser
#

That was something I was doing. Was pretty cool to have that click moment with adding momentum to a rigid body. the mouse look is a bit weird though. Almost kinda like its choppy? or stuttery?

deft grail
north kiln
#

Just make sure you're not multiplying mouse delta by deltaTime

timid geyser
#

Rigidbodies seemed smarter for calculating velocity though.

heavy knoll
#

anyone know what happened to gdl.space? i used to use it to send code but its now turned into this? Is it safe that i went on this site? cause it says im running this thing in the cloud now

north kiln
#

Looks like we'll have to remove it from our recommendations

timid geyser
#

I think i'll monkey with a regular controller later, but has anyone heard of the game I am your Beast?

heavy knoll
north kiln
#

of course you're fine

timid geyser
#

https://store.steampowered.com/app/1876590/I_Am_Your_Beast/

Like I want to replicate this sort of character controller but was thinking rigid body was the best idea.

I Am Your Beast is a shortform covert revenge thriller FPS about getting hunted across the North American wilderness by the military-industrial complex โ€” and turning the tables.You are secret agent Alphonse Harding. Retired for six years, you've been asked to complete โ€˜one last jobโ€™, one too many times. Declining your latest mission sets in moti...

Price

$19.99

Recommendations

1044

โ–ถ Play video
polar acorn
heavy knoll
polar acorn
#

Basically, their website got reverted back to the template project. You did not get a virus, their website is just down

heavy knoll
#

cool thx

#

anyone know how i can modify my drag a bit more, to check if im on a different type of floor like ice or something or like glue? Would it be better do this a different way instead of making layers for each type of ground like NormalGround, Ice, and Glue?

teal viper
heavy knoll
teal viper
heavy knoll
teal viper
#

You're probably doing something like setting the velocity directly I guess? If you're resetting it when the input is zero, obviously it's not gonna slide anywhere.

heavy knoll
#

this is what i got for the movement atm, and the drag is just this, i also have stuff for sprinting crouching jumping and dashing, but that shouldn't affect this i dont think

teal viper
#

Where is MovePlayer called?

heavy knoll
#

FixedUpdate

teal viper
#

Share the fixed update. Share the whole script actually.
!code:

eternal falconBOT
primal flare
#

what is wrong with this

#

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

public class Handanimcontrooler : MonoBehaviour {

 [SerializeField] private InputActionProperty triggerAction;
 [SerializeField] private InputActionProperty gripAction;
 
 private Animator anim;
 
 private void Start() {
     anim = GetComponent<Animator>();
 }    
 
 private void update() {
     float triggerValue = triggerAction.action.ReadValue<float>();
     float gripValue = gripAction.action.ReadValue<float>();
     
     anim.SetFloat("Trigger", triggerValue);
     anim.SetFloat("Grip", gripValue);
 }

}

teal viper
eternal falconBOT
primal flare
teal viper
heavy knoll
#

i tried just doing it on an ice layer but then the layer of the ice isnt ground anymore, which prevents my player from being able to jump on it

teal viper
heavy knoll
#

ok

#

yea im able to slide if my drag is set to 0

teal viper
next moat
#

anyone here familiar with using unity and github together?

#

me and my friend are new to source control and can't seem to upload the project we've been working on, into a single github repository. we have a central folder and don't know why we can't upload it to a github repo

heavy knoll
teal viper
teal viper
heavy knoll
#

and then just use physics materials for every object that i want to the player to walk on?

next moat
teal viper
next moat
#

You don't have any tips?

#

other than "figure it out?"

teal viper
teal viper
#

If you have an issue with the tutorial then come back with a specific question

next moat
#

I have a folder containing a bunch of unity test projects. I want to be able to upload them to a github repo so my friend can have access to the same projects and make changes to them accordingly, but it isn't allowing me to take my centralized folder and create a repo out of it. I guess my question is, how can I do that? OR is my understanding of how repos work wrong?

teal viper
#

A repo is just a set of files. There's no specific rule preventing you from uploading several folders

next moat
#

so in the structure, does it go:

  1. repo/folder
#

or
2) folder/repo

#

because I'm choosing 1

heavy knoll
next moat
#

and it's not saying I've made any changes to the repo

teal viper
teal viper
next moat
#

github desktop

teal viper
teal viper
next moat
#

and as I've added folders to the repo on my local machine, it isn't updating github for my friend who cannot fetch the changes I'm trying to make

#

and I've tried pushing those changes as well

teal viper
heavy knoll
teal viper
#

Aah, actually, I see what the issue is.

#

I guess you'll need to use both for finer control.
As for how you can detect a surface type, you could use a raycast or OnCollisionEnter to get the surface collider you're currently touching. Then you have many options to identify the surface type. For example, you could check the physics material it's using. Or check the object tag. Or have a component that defines the surface type.

waxen adder
#

I have a custom grid in unity. I'm trying to brainstorm how I would snap objects to the grid when created and when moved around while in the editor. Currently struggling on the idea. Any help?

teal viper
waxen adder
teal viper
waxen adder
waxen adder
tender ravine
#

how do i do a code so that on collision it takes the Y value and multiplies it by -1 and multiplies the X by 1?

teal viper
tender ravine
teal viper
#

How do you multiply a number in C#?

#

Or any programming language even.

tender ravine
#

idk thats y im asking

tender ravine
teal viper
teal viper
tender ravine
teal viper
#

Same as any other number. If you don't know how to multiply numbers, you should go learn the basics properly.

near wadi
#

there is also the Junior Programmer Pathway on the !learn site, and also this video if you are in a rush to get this done without a real understanding of things (You will Really need to learn those things, as it is expected in order to use Unity)
https://www.youtube.com/watch?v=sYf4bSj9j2w
@tender ravine

In this video I tried to cover as much useful information about Vectors in Unity as possible. We start by discussing what Vectors are, what useful properties they have then we go through most useful methods and at the end of the video I am giving 2 examples of solutions that require vectors.

This was until now the most challanging video to make...

โ–ถ Play video
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

heavy knoll
#

is there a way to make it so as soon as i stop touching the ice it stops settings isGroundedOnIce to true

waxen adder
#

God, I love editor scripts so much

heavy knoll
# teal viper OnCollisionExit

is this the correct way to do it? Also is this performance heavy at all/not really optimized to do, im not really sure on what the best practices are atm to make something optimized

#

this is also how my drag is now

teal viper
heavy knoll
#

just dont wanna develop any bad habits lol by doing something that's really costly. I've done some stuff in Unreal Engine before and ik ppl say to not put a bunch of heavy operations under the event tick that's called every frame, which is comparable to like void Update i think

teal viper
vernal spear
#

guys don't use Linq constantly, especially if you have high amount of subjects

#

I have done that mistake, lol.

#

like, I saw my mistake by the performance loss that I had to detect in the profiler

misty breach
#

code not displaying the ray

#
using System.Collections.Generic;
using UnityEngine;


public class control : MonoBehaviour
{   public float x,y;
    public float movSpeed;
    float speedX, speedY;
    public float dist; 
    public GameObject start;
  
    
    Rigidbody2D rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        x = 1f;
        y = 0f;
        
    }

    // Update is called once per frame
    void Update()
    {   
        if (speedX >0){
            x = 1f;
        }
        if (speedX<0){
            x= -1f;
        }
        if (speedY>0){
            y = 1f;
        }
        if ( speedY<0)
        {
            y = -1f;
        }
        RaycastHit2D ok = Physics2D.Raycast(start.transform.position, Vector2.up*new Vector2(x,y),5f);
        
        speedX = Input. GetAxisRaw("Horizontal") * movSpeed;
        speedY = Input. GetAxisRaw("Vertical") * movSpeed;
        rb. velocity = new Vector2(speedX, speedY);

        if (ok.collider != null){
          Debug.DrawRay(start.transform.position,Vector2.up*ok.distance*new Vector2(x,y),Color.blue);  

        }

        else 
        {
            Debug.DrawRay(start.transform.position,Vector2.up*ok.distance*new Vector2(x,y),Color.blue);
        }
      
    }
}
#

the direction is wrong(haven't configured) but the code isn't displaying anything

#

it isnt drawing anything unless the distance of raycast is 500f

#

or more

north kiln
keen dew
#

If the raycast doesn't hit anything, distance is 0 so the debug.drawray length is also 0. Use a fixed length in that case

#

Also multiplying two vectors shouldn't even work

north kiln
#

Certainly a concern that the code shouldn't be compiling

#

if errors aren't underlined in red your !ide needs configuring

eternal falconBOT
misty breach
#

it still isnt colliding with anything

keen dew
#

The code you've shown doesn't compile

misty breach
#

whaaaaa

vernal spear
#

Bruh.. did you even read what vertx wrote?

misty breach
keen dew
#

Wait, I take it back. Multiplication is defined for Vector2

#

It's still wrong though

vernal spear
#

do you see the sphere in the most right? that's what enables the debug draws

misty breach
vernal spear
#

just enable it, that's what he said as first

north kiln
keen dew
#

Change it to this:

if (ok.collider != null)
{
    Debug.DrawRay(start.transform.position, new Vector2(x, y) * ok.distance, Color.blue);
}
else
{
    Debug.DrawRay(start.transform.position, new Vector2(x, y) * 5f, Color.red);
}
north kiln
#

Vector3 doesn't have a multiply, but Vector2 does

keen dew
#

Yeah, it just doesn't make sense here

north kiln
#

Your logic is very weird though, as Vector2.up*new Vector2(x,y) doesn't make much sense

#

The outcome would be the same as new Vector2(0, y)

#

Also change the raycast to use new Vector2(x,y) instead of multiplying

misty breach
#

realised he did so as he was making a side scroller

misty breach
#

also if may not be too much trouble could you explain what was wrong with my logic?

#

and what you did?

keen dew
#

Like I said, ok.distance is 0 when the raycast doesn't hit anything so the DrawRay was also 0 length when you multiplied by it

#

and like vertx said, multiplying the vector by Vector2.up doesn't make sense

misty breach
#

i see

#

thanks

#

thank you all

solemn fractal
#

Hi my friends.. quick question.. when I mouse over the non active objects never turn into active.. any ideas? The script is on the gunright object.

ivory bobcat
#

Place a log and see if it's called

solemn fractal
#

It is not being called the debug log. But why would be that? it is an object with that script.. and that is it.

north kiln
#

You want enter and exit in this case

solemn fractal
static cedar
#

Using UnityEvents, the event has a float as an argument but for some reason, this field is here and calls the function with 0.
How do i make it so it actually uses the event argument?

wintry quarry
#

Not the static list

static cedar
#

Thanks.

wanton iron
#

Hi everyone! help please. i make a multiplayer game using Photon Pun, and i have everything working, [actually], there are players on the server, but they are not visible in the game. i can throw all the scripts for multiplayer that i used. i tried to fix it, but it didn't work out.

ionic raven
#

How many lines of code should my player script have?

keen dew
#

42

ionic raven
#

42 seems VERY low

keen dew
#

43?

ionic raven
#

much better ๐Ÿ˜Œ

wanton iron
#

60

ionic raven
#

60 seems too many

wanton iron
#

50

ionic raven
#

but i think i need to cut down my script then, mine has 630

wintry quarry
#

630 is small

ionic raven
frosty hound
#

Why do you think you need to? It's a silly question

keen dew
#

That's the wrong question to ask. A script should have as many lines as are needed

#

If it starts to get several hundred lines long, it's time to consider if it could be split into multiple classes

misty breach
#

HELLO again

#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;


public class mapManager : MonoBehaviour
{
    public Tilemap map;
    //control script;
   



    void update()
    {
        if(Input. GetMouseButton (0)){
                Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector3Int gridPosition = map.WorldToCell(mousePosition);
                TileBase clickedTile = map.GetTile(gridPosition);
                print("At position" + gridPosition + " there is a " + clickedTile);
                print("YESSS");
        }
        
    }
}
short hazel
#

Update is misspelled

#

Unity won't call yours

misty breach
wintry quarry
misty breach
#

MAN ive been trying to correct it for hours now!!!!

#

just for the update to be wrong

frosty hound
#

It's not the only thing that's wrong ...

#

You need to configure your !ide so you can actually see errors.

eternal falconBOT
misty breach
#

thanks

ionic raven
stuck palm
#

how do you specify unmanaged types?

celest flax
#
Vector2 lookDirection = (mousePos - pivotPos).normalized;
float lookRotation = Quaternion.FromToRotation(Vector2.right, lookDirection).z;
weaponPivot.rotation = new Quaternion(weaponPivot.rotation.x, weaponPivot.rotation.y, lookRotation, weaponPivot.rotation.w);```

I'm trying to rotate an object towards my cursor, and it works fine except that when the z-rotation is between -120 and -180 degrees, it just flips and becomes positive, and I can't figure out why or why it's for those angle specifically. Does anyone have any idea?
runic lance
#

if you want to specify the rotation in angles, use Quaternion.Euler

inland kettle
slender nymph
#

!code

eternal falconBOT
queen adder
#

lol this is the best way Ive seen someone share code

slender nymph
inland kettle
rich adder
inland kettle
slender nymph
#

yes

tulip nimbus
#

Why cant i create a reference to a script here, and how do i properly do it?

slender nymph
#

do you have a component called ObjectB?

rich adder
tulip nimbus
slender nymph
#

gameobject names are not variable types

inland kettle
slender nymph
inland kettle
#

i wanna make it so that once it collides with a player/paddle, it bounces in the other direction at the same angle as its initial impact

rich adder
inland kettle
#

i tried that but the outcome is the same

slender nymph
#

did you bother going through the link i sent that will tell you why that code is not working?

inland kettle
#

it doesnt explain specifically why my code isn't working, it's a general overview on collisions in unity is it not

rich adder
#

did you click through the steps?

slender nymph
#

the issue is also answered by literally the first step

inland kettle
#

oh is it cause it was Collision and not Collision2D

slender nymph
#

make sure you read all of the information presented to you

inland kettle
#

thank you for the um clues

#

now collision works but it just goes in a rectangular path

slender nymph
#

show your current code

inland kettle
slender nymph
queen adder
inland kettle
#

doesn't really reflect, just kind of slides off the surface to another surface and slides across that one too. rectangular path again

#

happened the last time i tried vector reflect too

slender nymph
#

and what debugging have you done to ensure the values you are using are what you expect?

inland kettle
#

I just made it write a line for when it detects collision with the walls or paddles, and it doesn't write anything

slender nymph
#

well that at least indicates that the if statement is never true if a log inside of it never prints

#

which means you need to check the tag on the objects you expect this to collide with

amber nimbus
#

So question, why use ScriptableObjects when you can serialize variables in the inspector anyway? Is there any benefit or is it just cleaner code?

slender nymph
#

ScriptableObjects allow you to define a type of asset rather than just a component (which is what MonoBehaviour is for)

inland kettle
slender nymph
#

make sure you are printing that information outside of the if statement

inland kettle
#

yep, same problem

#

after it collides with the wall and paddle once, it doesn't register the tag anymore

slender nymph
#

show your current code

inland kettle
slender nymph
#

so if nothing at all is printed, then no valid collision is actually happening. are you sure nothing is printed, rather than maybe you have your console set to collapse mode?

inland kettle
#

no it prints the tag correctly twice, then it just prints the last printed thing over and over even though the tag isnt correct

slender nymph
#

it is printing the tag of the object that it collides with. if you think that the tag isn't correct, then it is colliding with something that has the incorrect tag. the logs are not lying to you

#

replace your log with this: Debug.Log($"{name} is colliding with {collision.gameObject.name} with tag {collision.gameObject.tag}"); and you'll see more info about what is colliding and can get a better idea of why that is happening

inland kettle
#

alright thanks

#

is it ok to send a vid of whats happening

slender nymph
#

if it is a proper screen recording and not recorded with a shaky phone camera, yes

verbal dome
#

I dont think that using Reflect with rb.velocity really works when colliding. When OnCollisionEnter gets called, the collision has already modified rb.velocity

#

Probably better to keep track of the velocity manually

slender nymph
#

sure but that's not what we are currently debugging. they are saying that the object being collided with has the wrong tag. i am trying to show them why. then we can move on to debugging the actual values they are using (like i suggested before this)

inland kettle
native seal
#

does anyone know why ScreenToWorldPoint is always returning 0,0,-1 for me? I'm trying to get Input.mouseposition to work with a camera space pixel perfect canvas in unity 2d

#

nvm, fixed it. had to set the Z to the camera distance

wintry quarry
native seal
#

for some reason my camera was on perspective

#

when it should have been on orthographic

#

pixel perfect was overriding it, not sure if it was just an inspector thing

slender nymph
# inland kettle

can you screenshot your console when this is happening. because we were trying to figure out why it was colliding with objects that had the incorrect tag. we need to address that before addressing your incorrect reflect

radiant frigate
#

the logic for going into the rollingstate is correct, made a debug of it and was working well, only thing is that the roll coroutine isnt working

keen dew
#

Coroutines must be started with StartCoroutine() from a MonoBehaviour

#

you can't just call the function

radiant frigate
#

you deserve all good that happens to you and even more

#

may god bless you

misty breach
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;


public class mapManager : MonoBehaviour
{
    public Tilemap map;
    
    control script;
   
    void Start()
    {

        script = GameObject.Find("Square").GetComponent<control>();
    }
    



      


    void Update()
    {
       
        
        if (Input.GetKeyDown(KeyCode.Tab))
        {   Vector2 pos = Camera.main.ScreenToWorldPoint(script.ray_end);
            Vector3Int grid_pos = map.WorldToCell(pos);

            TileBase selected_tile = map.GetTile(grid_pos);
            print(grid_pos );
            print(selected_tile);
            print("YESSS");
        }
    }
}
#

the code works but the detals of the tile at the given position is wrong

#

as if the entire map is shifted

kind heron
#

can anyone help me figure out why my enemy is doing this for the rollaball tutorial?

EnemyMovement script

using UnityEngine;
using UnityEngine.AI;

public class EnemyMovement : MonoBehaviour
{
 // Reference to the player's transform.
 public Transform player;

 // Reference to the NavMeshAgent component for pathfinding.
 private NavMeshAgent navMeshAgent;

 // Start is called before the first frame update.
 void Start()
    {
 // Get and store the NavMeshAgent component attached to this object.
        navMeshAgent = GetComponent<NavMeshAgent>();
    }

 // Update is called once per frame.
 void Update()
    {
 // If there's a reference to the player...
 if (player != null)
        {    
 // Set the enemy's destination to the player's current position.
            navMeshAgent.SetDestination(player.position);
        }
    }
}```
misty breach
#

but it should display hilla_11 here which it is not

#

but if i move a but up it shows the tile name as hills_11

ivory bobcat
ivory bobcat
#

I'm wanting to suggest that maybe the ball's collider is preventing the agent from getting closer.

kind heron
marble hemlock
#

if i were doing an inventory system where the player would use their wasd keys to move around it, for different rows would i have the lists be nested inside another list, or tell it to just jump a certain number of slots (assuming the amount of slots is a multiple.

Like if I have 24 slots as a 6 x 4, and I want to go to the slot directly below number 1, it would need to check 6 slots down the list

#

i dont know which seems more reasonable

#

i feel like telling it to move 6 slots lower or higher if they click w or s would be easier but im not sure if its the best method to go about it

strange cape
#

hey Im starting to develop my first game and Im stuck on making my jump work

#

if anyone can help me on VC I would grately appriciate it

real grail
#

!code

eternal falconBOT
strange cape
#

I dont want to use forces because it makes the game feel harder to control

#

so I'm implementing them using vectors

deft grail
#

!csharp

eternal falconBOT
languid spire
#

also your code makes little sense

real grail
# strange cape I dont want to use forces because it makes the game feel harder to control

something like this might work:

private float jumpTime = 0.0f;
private float buttonTime = 0.5f;
private float jumpForce = 10.0f;
private bool isJumping;
private bool isJumpCancelled;

void Update () 
{
    Jump();
}

private void FixedUpdate()
{
    if(isJumpCancelled && isJumping && playerRB.velocity.y > 0)
    {
        playerRB.linearVelocity = new Vector3(0, jumpForce,0);
    }
}

void Jump () 
{
    if(isGrounded() && Input.GetKeyDown(KeyCode.Space)) 
    {
        isJumping = true;
        isJumpCancelled = false;
        jumpTime = 0.0f;
    }
    
    if(isJumping) 
    {
        jumpTime += Time.deltaTime;
        if (Input.GetKeyUp(KeyCode.Space))
        {
            isJumpCancelled = true;
        }

        if (jumpTime > buttonTime)
        {
            isJumping = false;
        }
    }
}```
tranquil basin
strange cape
#

I tried to do a basic add force function for when I press 'w' and the character still doesnt move

deft grail
strange cape
#

thats the problem thanks

wheat wave
real grail
# kind heron

Did you try creating empty object and put that empty object as a child of a player and then tried to follow that empty object instead of player ?

primal flare
#

bro y dose this have to be so cunfuzeing using

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

public class PlayerJump : MonoBehaviour
{

[SerializeField] private ImputActionProperty jumpButton;
[SerializeField] private float jumpheight = 3f;
[SerializeField] private CharacterController cc;
[SerializeField] private LayerMask groundLayers;

private float gravity = Physics.gravity.y;
private Vector3 movement;

private void Update() {
bool _isGrounded = _IsGrounded();

 if (jumpButton.action.WasPressedThisFrame() && _isGrounded)  {
 Jump();

         movement.y += gravity * Time.deltaTime;

         cc.Move(movement * Time.deltaTime)

 void Jump() {
   movement.y = Mathf.Sqrt(jumpheight * -3.0f * gravity);
 }

     private bool IsGrounded() {
            return Physics.CheckSphere(transform.position, 0.2f, groundLayers);
        
     }



 }
#

AND IT STILL DOSENT WORK

rich adder
eternal falconBOT
rich adder
#

seems like a syntax error

primal flare
#

thats what i did at first and i got this

rich adder
#

use links to post large code

primal flare
#

thats the result of it

rich adder
#

the result of what?

primal flare
#

those websites

rich adder
#

its not, you have to send the link after you pasted and saved the code on the site

primal flare
#

hu what link

polar acorn
primal flare
#

paste

polar acorn
#

Yes, and then share the link here so we can actually see the code

primal flare
#

OOOOOOOOOOOO

kind heron
primal flare
rich adder
#

line 25 why did you ignore the error you have
can't expect it to work if you have code that doesn't even compile

polar acorn
real grail
primal flare
kind heron
rich adder
primal flare
#

i did

rich adder
#

send the tutorial link, n screenshot your Unity Console window

primal flare
#

tripple checked

#

ok

rich adder
#

corporate wants you to find the difference

polar acorn
# primal flare https://www.youtube.com/watch?v=Xf2eDfLxcB8
"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: 179
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-10-05
real grail
kind heron
#

looks like its getting the correct position still

primal flare
rich adder
primal flare
#

๐Ÿ˜ข

polar acorn
real grail
polar acorn
#

You have the answer right in front of you, it's not going to be any easier to read it if we write it instead of the tutorial

kind heron
#

gotcha

#

so position is the exact player position but the enemy still isnt moving towards it

#

i definitely followed the tutorial to the T so im not sure why its not moving on its own

real grail
kind heron
#

this is like my 5th time trying to figure it out so i dont think that would help

real grail
#

If that dosent help try to draw a sphere and see where its trying to get in Scene view.

void OnDrawGizmos()
    {
        // Draw a red sphere at the transform's position
        Gizmos.color = Color.red;
        Gizmos.DrawSphere(player.position, 1);
    }
kind heron
#

where would i put that? in the Update func of enemy?

real grail
kind heron
#
 void Update()
    {
 // If there's a reference to the player...
 if (player != null)
        {    
 // Set the enemy's destination to the player's current position.
            navMeshAgent.SetDestination(player.position);
            Debug.Log($"{player.position}");
            OnDrawGizmos();
        }
    }

void OnDrawGizmos()
    {
        // Draw a redlow sphere at the transform's position
        Gizmos.color = Color.red;
        Gizmos.DrawSphere(player.position, 1);
    }```
deft grail
kind heron
#

do i just put the function or do i call ti somewhere

deft grail
real grail
#

Yea just put the function

kind heron
#

i see

real grail
kind heron
#

these settings are good yea?

#

omg i think i got it

real grail
kind heron
#

no man im dumb, i positioned enemy body and not enemy parent object...

#

nvm about following tutorial to the T....

#

thanks for the help though appreciate it

torpid forge
#
using UnityEngine;
using UnityEngine.PostProcessing;

namespace UnityEditor.PostProcessing
{
    [CustomPropertyDrawer(typeof(MinAttribute))]
    sealed class MinDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            MinAttribute attribute = (MinAttribute)base.attribute;

            if (property.propertyType == SerializedPropertyType.Integer)
            {
                int v = EditorGUI.IntField(position, label, property.intValue);
                property.intValue = (int)Mathf.Max(v, attribute.min);
            }
            else if (property.propertyType == SerializedPropertyType.Float)
            {
                float v = EditorGUI.FloatField(position, label, property.floatValue);
                property.floatValue = Mathf.Max(v, attribute.min);
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
            }
        }
    }
}
#

what is this error

kind heron
#

unity is struggling to know which MinAttribute you want to use i think

deft grail
#

you can do that in 2 ways

#

by just doing UnityEngine.PostProcessing.MinAttribue attribute = ... when using it (or the other one if you want that)

rare basin
deft grail
#

or just do using MinAttribute = UnityEngine.PostProcessing; i think

ember tangle
#

what is a great way to have a field dissapear in the editor if a bool in that scriptable object is set to false?

kind heron
deft grail
#

but both work

kind heron
#

gotcha

ember tangle
# rich adder custom inspector

What im trying to do specifically is something like (pseudo code) public class Attack : ScriptableObject { bool ranged; if(ranged) ProjectileType projectile; int volleySize; float damage; float cooldown; }

Will what you referenced work for this?

rich adder
short spade
#

Do you guys use statemachines for coding ?

polar loom
#

Anyone got a Teleport script for a gtag fan game?

deft grail
polar loom
#

Ok

#

Thanks for the help ig

deft grail
arctic flame
#

im new to unity and im following this flappy bird tutorial to make my first game. should i learn some c# before diving into unity?

eternal needle
arctic flame
#

do you recommend any specific tutorials on youtube or online? or should i keep following my flappy bird tutorial?

cosmic dagger
short spade
pure crest
#

When I'm trying to use an interface from another script and have a class inherit it do I have to reference the script that I'm getting the interface from? I'm attempting to have a class in another script inherit an interface but im getting an error of " The type or namespace name 'IInteractable' could not be found (are you missing a using directive or an assembly reference?)" I have the interface inheritance placed after Monobehavior like "Monobehavior, IInteractable"

cosmic dagger
# short spade Example ?

character controller, a turn-based battle system (any turn-based/ordered system), or anything that must be in one state of being at a time . . .

cosmic dagger
pure crest
#

It's an interface, I just renamed it cause I realized its poor naming convention, its IInteractable now

#

Nevermind, just solved it myself my bad

#

I gotta reference the original script just using dot notation, so I just had to make it "Monobehavior, InteractionHandler.IInteractable"

cosmic dagger
#

that's because you made the interface a member of InteractionHandler. it should be outside of the class (in its own file) . . .

pure crest
#

Yep you're right, I accidentally nested it inside InteractionHandler, I left it in the InteractionHandler file just cause I dont have a file just for interfaces right now so it just makes sense to me to leave it there, but moving it out of InteractionHandler so its not nested fixed it so I dont need to reference InteractionHandler before

polar loom
#

Iโ€™ve never coded before

rich adder
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

rich adder
polar loom
#

Yeah thanks Iโ€™m tryna Learn but rn I donโ€™t know how to do the simplest script

rich adder
polar loom
#

Ikkkkkk

#

I hate the blender server

#

I said one thing

#

Not knowing itโ€™s a rule

#

And got flamed for not knowing

heavy knoll
#

Can anyone help with my camera code? for some reason it feels inconsistent like it has some sort of mouse acceleration on it somehow, I'm following a pretty popular fps controller tutorial and everything is copied correct I'm pretty sure

rich adder
heavy knoll
#

this is how everything is setup currently

rich adder
#

thats why your sens is 450+

heavy knoll
#

but it still feels inconsistent

rich adder
#

yea

#

most likely because your camera and body are rotating at different times or same forgot which

#

parent the camera to player remove the rotation on Y axis for cam

#

player rotating will make camera follow that rotation

heavy knoll
#

i think i have the rigidbody rotation frozen rn atm too

rich adder
#

you're using a rigidbody ?

#

probably why its worse for you parenting

heavy knoll
#

Yea

rich adder
#

rotating not matching the physics time on cam usually causes issues

heavy knoll
#

yea, also on top of it feeling a little inconsistent it sometimes like skips a bit fast in the direcetion im looking around in, kinda like almost teleport in the direction im currently moving my camera but not really

rich adder
#

You can try maybe seeing if cinemachine will deal with it better on the cinemachine brain

bitter canyon
#

!code

eternal falconBOT
bitter canyon
#

sometimes it works

#

sometimes it doest

#

the max rooms is 30 and min is 20

north kiln
bitter canyon
#

yeah they dont spawn on top of each other it just doesnt reach enough

#

in the console you can see it looks at a room that already has one but doesnt spawn it

#

it doesnt reach the generation complete message

heavy knoll
#

Anyone know how i can show my moveSpeed float value on screen as text constantly changing so i can see my speed in real time?

rich adder
#

or use a canvas

heavy knoll
# rich adder what are the changes ?

it seemed to just add subtract and multiply the variables i had a bit different and without the delta time, and also just switched what the scripts where placed on, and what objects i needed to drag into the inspector

rich adder
heavy knoll
#

seems to work now though so thats good lol

bitter canyon
radiant frigate
#

it goes inside the roll state and afterwards goes back to whatever state

hardy shard
#

i try to copy an examine system of a girl's tutorial but it doesn't seem to work, when i move close to front of table, the console immediately shows error at line 111, and for the back of table, it shows error at 121, here the code of her: https://github.com/yasmeen2001234/Unity-3D-Examine-system/blob/main/Assets/Object_Interact.cs

GitHub

Contribute to yasmeen2001234/Unity-3D-Examine-system development by creating an account on GitHub.

radiant frigate
misty breach
#

question

#

I'm referencing a player gameobject position from one script to another,

#

but its x,y pos is coming as 0,0 even if i move the object

polar acorn
#

How are you referencing the object

misty breach
#

vector2 aa = obj.transform.position

polar acorn
misty breach
#

in the first script๐Ÿ‘†

#

square player in my scene

#

with a rigidbody2d and movement controls

polar acorn
misty breach
#

in second im using it as vector2 bc = script.aa

polar acorn
#

I didn't ask about any vectors

#

I asked how you were referencing the object

misty breach
polar acorn
#

how are you referencing that object

misty breach
#

sir

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;


public class mapManager : MonoBehaviour
{
    public Tilemap map;

    
    
    control script;
   
    void Start()
    {

        script = GameObject.Find("Square").GetComponent<control>();
    }
    



      


    void Update()
    {
        if(Input. GetMouseButton (0)){
                Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector3Int gridPosition = map.WorldToCell(mousePosition);
                TileBase clickedTile = map.GetTile(gridPosition);
                print("At position" + gridPosition + " there is a " + clickedTile);
                print("YESSS");
        }
        if (Input.GetKeyDown(KeyCode.Tab))
        {   Vector2 pos = Camera.main.ViewportToWorldPoint(script.ray_end);
            Vector3Int grid_pos = map.WorldToCell(pos);

            TileBase selected_tile = map.GetTile(grid_pos);
            print(grid_pos );
            print(selected_tile);
            print("YESSS");
        }
    }
}
#
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;


public class control : MonoBehaviour
{  public float x,y;
    public float movSpeed;
    float speedX, speedY;
    public float dist; 
    public GameObject start;
  public Vector2 ray_end;
    
    Rigidbody2D rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        x = 1f;
        y = 0f;
        
    }

    // Update is called once per frame
    void Update()
    {   
        if (Input.GetKeyDown(KeyCode.W)){
            x = 0f;
            y = 1f;
        }

        if (Input.GetKeyDown(KeyCode.A)){
            x = -1f;
            y = 0f;
        }
        if (Input.GetKeyDown(KeyCode.S)){
            x = 0f;
            y = -1f;
        }
        if (Input.GetKeyDown(KeyCode.D)){
            x = 1f;
            y = 0f;
        }
        
        RaycastHit2D ok = Physics2D.Raycast(start.transform.position, Vector2.up*new Vector2(x,y),dist);
        
        speedX = Input. GetAxisRaw("Horizontal") * movSpeed;
        speedY = Input. GetAxisRaw("Vertical") * movSpeed;
        rb. velocity = new Vector2(speedX, speedY);

       if (ok.collider != null)
        {
            Debug.DrawRay(start.transform.position, new Vector2(x, y) * ok.distance, Color.blue);
        }
        else
        {
            Debug.DrawRay(start.transform.position, new Vector2(x, y) * ok.distance, Color.red);
        }
       
       Vector2 ray_end = start.transform.position* new Vector2(x,y)*dist;
       
       

    }
}
#

i did correct the code later

polar acorn
misty breach
#

but referencing the position of the obhect from the other script isnt working

polar acorn
#

What line is giving you a position you don't expect

misty breach
misty breach
polar acorn
misty breach
#

square is the gameobject which i assigned start

polar acorn
#

Okay and what is it assigned to

misty breach
#

sir

#

imma start crying now

polar acorn
#

Please stop saying sir and actually answer the questions I ask

#

How have you assigned a value to start and what is it assigned to

misty breach
polar acorn
# misty breach

Okay, so you have dragged in this object from the scene into itself

misty breach
polar acorn
#

My first question would be why have the start variable at all instead of just using this.transform.position

misty breach
polar acorn
#

So, every time you use start.transform.position you're getting this objects current position.

Then, you're multiplying that position by 5 and using that as ray_end

misty breach
#

yes

polar acorn
#

So, that'd be the position five times further from the origin than the object currently is, in each direction.

Is that what you're going for?

misty breach
#

yes

#

wait

#

im going for the 5 times the pos in the current direction the object is facing

polar acorn
#

Nothing here involves a facing direction. You're just multiplying the position by 5

#

So if the object is at 0,0 the ray end will be at 0,0. If it's at 1,1, ray end will be 5,5. If it's at 100,100, ray end will be 500,500

radiant frigate
#

I dont know why its changing states, even if isDashing is still true after the duration of the roll it still changes to some other state and doesnt check the update inside the rollstate https://hatebin.com/hpzrpuipte (state manager), https://hatebin.com/ymqgluhfmm (Player states), from what i think since im changing the state and the code isnt working unless that state is active the only thing that matters to read is the state manager and line 162-204 in player states

#

ive been stuck with this for hours, and its not that i cant fix it, its that i dont even understand it

#

any help is aprecciated

#

(pls ping, ty)

sterile slate
#

i need to reference a button that on click it shows some text and i need to find displaymessage from operators but i just dont see anything, im trying to learn from a tutorial that is 2 years old, did anything change? (sorry for bad english)

ivory bobcat
sterile slate
#

yes, i referenced the text to the button

#

and i referenced the script to the text

ivory bobcat
#

I'm assuming you meant you attached the component to the object and referenced the object

sterile slate
#

yes

ivory bobcat
#

Is the function public?

#

Maybe you ought to show the function

sterile slate
#

so for more context first, im following a tutorial and it said to create a script called my operators, add that script to the text, and reference the text to the button

devout stratus
#

Hello people. Do you know how to get a GridLayout reference from a Gameobject who have a Grid as component? I didn't found how online even on Unity Manual

iron wing
#

hi, im trying to figure out how in the world to enable VSync. unfortunaley the Quality Settings doesnt really seem to affect the vsync when im playing in the editor and it's left unchecked.

QualitySettings.vSyncCount = 1;

#

apologies if this is the wrong place to ask this

devout stratus
ivory bobcat
#

Or possibly they've got an invalid function - limited one parameter etc

languid rivet
#

If i have vector3 P1 , how to get Vector3 P2 on the direction line Vector3 V1?
is it Vector3.Project(P1, V1) ?

modest dust
#

Depends what you're doing

#

I imagine P1 being a point relative to the center of the world and V1 could be relative to whatever you're getting it from and to

languid rivet
#

V1 and P1 both relative to world.

#

i know a random point on that line though

modest dust
#

Projection works for vectors of the same origin as far as I'm aware, so if that's the case then just try it out and see for yourself

robust kelp
#

!code

eternal falconBOT
robust kelp
ivory bobcat
north kiln
#

Use !myList.Any(...

languid spire
#

why would you want to use LinQ when a simple for loop will do the same job and is much more efficient?

north kiln
#

Either Any with double negative, or All. Linq is very readable, so just think about the logic you're performing

#

E.g.
itemInfos.All(a => a != b)
All elements don't equal b
!itemInfos.Any(a => a == b)
Not any (i.e. none) elements equal b

languid spire
#
foreach(Transform a in transform.Find("App Windows Parent/App Window/Layouts")){
   bool found = false;
   for (int i=0;i<itemInfos.Count;i++)
            if(itemInfos[i].ItemDisplayName = a.name)){
               found = true;
                break;
            }
if (!found)  Debug.Log(a.name);
        }

or better

List<int> itemInfos
foreach(Transform a in transform.Find("App Windows Parent/App Window/Layouts")){
    bool found = false;
   for (int i=0;i<itemInfos.Count;i++)
            if(itemInfos[i] == a.gameObject.GetInstanceId())){
               found = true;
                break;
            }
if (!found)  Debug.Log(a.name);
        }

where itemInfos contains the gameObject instance id's so no string comparison

north kiln
#

If it was the same object then they could just do normal equality, or walk the hierarchy to see if it's a child

languid spire
#

did you see I updated the code?

#

look at my updated code if you want only objects not in the list

#

explain exactly what you do want, not what you don't want

#

but that logic is flawed. it will destroy all gameobjects

#

the current gameobject will not match at least one of the names in the list

#

then my updated code will work

bright pewter
#

guys im trying to learn game development, should i use unity?

steep rose
#

If you want, it does depend on what you are looking for

bright pewter
#

i want to make a VR game.

steep rose
#

Sure go for it

#

But best you !learn first

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

bright pewter
#

its just hard to choose the game engine because people are saying that ae5 has better graphics and that roblox studio is better for success haha

#

i like unity tho

north kiln
#

Unity is well suited to VR

bright pewter
#

yeah, what kind of game are you making?

languid spire
#

does Roblox even support VR?

bright pewter
#

eh, kinda.

#

not really tho

#

its very bad

languid spire
#

first lesson of Game Dev. Learn how to make informed decisions

steep rose
#

I have never heard in my life that people actually use roblox for success

bright pewter
#

if you get like 100 consistant players in your game youยดll most likely earn a lot of money

steep rose
#

As stated if you are thinking of coming over to unity you must learn from the link above

bright pewter
#

ive been coding for about 3 years with lua and ive met a lot of other devs that have made a lot of money

languid spire
bright pewter
#

i never said that

#

i just enjoy making games, im just having a hard time choosing. Thatยดs all.

#

a physics based game with gorilla tag movement

#

why not?

#

thankfully c# and lua are kind of similar so ive made 2 simple 2d games in unity the past 2 weeks

#

what are you making?

#

oh nice!

#

dang

languid spire
#

that is still not my updated code, it will not do what you asked to do

#

how else do you expect to check if the name does not appear in the list at all. And if you dont like proper logic figure it out yourself. I'm done

#

and that from the man who wanted to use LinQ

steep rose
bright pewter
#

i never said it was the same

steep rose
#

If you are wanting to solely make a VR game then Unity is fitted for it

bright pewter
#

is that from ur game?

#

are u using gtag movement too?

#

cool

#

fr

rancid tinsel
#

is there any way of feeding variables into the [Range(,)] attribute?

short hazel
#

Values passed to attributes must be constants. So you can make two const fields and put them into attributes (they won't show in the Inspector), but impossible for regular fields/properties

#

A custom property drawer and attribute could emulate that like Naughty Attributes does, where you pass the names of the variables instead of theire values, and they're resolved at runtime:

public int Min, Max;

[CustomRange(nameof(Min), nameof(Max))]
public int Value;
sharp abyss
#

Do you know how can I draw like in this video with these physical blocks. I created the cells but couldnt think of anything about drawing. https://youtu.be/IEhWPowlS98?si=unlC8LrucSkAR4ue

Recreating pixel/cellular automata based simulations from Noita and Powder toy in the Unity game engine.

Links:
Source code: https://github.com/NivMiz0/Draw-With-Physics-Automata
Play the game: https://nivmizzer.itch.io/draw-with-physics
Twitter: https://twitter.com/NivMizzer
Discord: https://discord.gg/Qj7uDk9Nnc
Mickey (nextProgram)'s channel...

โ–ถ Play video
distant fossil
#

is there a consensus about whether to explicitly mark MonoBehavior event functions as "private" or not?

#

just in terms of style

short hazel
# distant fossil just in terms of style

Since Unity calls them, and that you're not meant to call them yourself (either from the same class or from another), I'd keep them at the highest restriction level which is private

#

If you do not specify an access modifier, private is implied

distant fossil
short hazel
#

Read the message right above

distant fossil
#

oh so you're saying just leave it as-is since it's private anyways?

short hazel
#

Yep it's a matter of code style, if you prefer it to be explicit or not

distant fossil
#

the thing is that in normal C# code I use private explicitly everywhere

north kiln
#

The .NET convention is to specify

distant fossil
#

and I think it's almost misleading to call them "private" since they're not really private, they're just called by Unity magically

short hazel
#

Unity script files are taken from template files which you can modify yourself

distant fossil
#

oh neat

rancid tinsel
#

in the first loop, is h equal to 0?

#

i always forget how this works

languid spire
#

h++ mean increment AFTER so, yes, if youj did ++h then h would be 1

rancid tinsel
#

ah ok so they do start at 0

#

so it will instantiate at 0, 0 ,0 then 2, 0, 2...

languid spire
#

you do specifically say 'h=0' do you not?

rancid tinsel
#

yes but its the adding at the end

#

i always forget if i remember it correctly ๐Ÿ˜ญ

#

memoryception

burnt vapor
#

h would still start at 0

rancid tinsel
#

!code

eternal falconBOT
rancid tinsel
#

guys what is this i opened gld.space and this is what i got

#

gdl.space*

strong wren
rancid tinsel
#

ah

#

it seems the issue is in the first script since thats the one i changed right before it started leaking?

languid spire
#

that should be Destroy(gameObject) not Destroy(this)

rancid tinsel
modest dust
#

Technically Destroy(this) is also valid, and safer

#

In case you have multiple components on that GO

rancid tinsel
#

im going to try reimporting all assets and see if that somehow fixes it

#

yeah no that didn't fix it

languid spire
#

why dont you try doing what the messages tell you to do?

rancid tinsel
#

do what?

#

also i //'d the GameOver() method and it stopped

languid spire
rancid tinsel
#

so this causes the memory leak

burnt vapor
#

What is ChangeColour?

rancid tinsel
#

i just realised i dont need "this."

burnt vapor
#

And this also calls GameOver in a recursive loop?

wintry quarry
rancid tinsel
#

omg

rancid tinsel
ivory bobcat
modest dust
rancid tinsel
#

i think both destroy this and gameobject work in my case

ivory bobcat
#

You'd probably want to destroy the game object if you're using Singleton pattern unless you're just wanting to destroy the script and not the game object.

rancid tinsel
#

i had no idea that would cause a memory leak though wow

polar loom
#

Umm how would a script a teleport script when it is clicked with hand tag, I have no idea how to script so if someone could please teach me it would be a pleasure.

celest flax
#

I have a Quaternion.FromToRotation() that is used to rotate an object along the z axis, but when the object has to rotate 180 degrees it instead rotates along the y-axis. Is there a way to make it always calculate the rotation around a specific axis if possible?

verbal dome
static cedar
#

IPointerClickHandler seems more so for OnRelease, rather than click itself? UnityChanThink

lone barn
#

I've just started using Unity.Netcode in a script. But Unity complains about the namespace not being available. I've doubled check that NGO is installed, I've already put some network script on go.

Does anyone recognizes the problem ? Unity hints to reference an asmdef but none are available for Unity.Netcode. (Though there's com.unity.netcode.editor but that seems to be internal)

carmine lagoon
#

asking some guides again for this

#

in my code the tower that detects enemy can only detect one game object so im planning to make an array so that every game object it detects within range can be detected and have those values transferred to another tower

grand badger
#

Yup! You can do: string[] s = myTMProTextReference.text.Split('\n');

#

\n is actually a character, not a string, and represents the beginning of a new line in text

fervent abyss
#

thanks

grand badger
#

you can swap '/n' with System.Environment.NewLine which is more correct for multiplatform, but in Unity splitting by \n will always work.

fervent abyss
#

okay

sharp bloom
#

Hi, can someone tell me what am I doing wrong? I want to use scritable objects for a card game to assign different effects to cards easily.

#

Then in my card script, I want to assign the effect in Inspector

#

However, I can't drag and drop the effects in

#

I simply have public effect cardEffect

rich adder
sharp bloom
#

Nevermind I have smooth brain

#

I'm supposed to create the scritable object via the asset menu

#

Not directly drop the .cs script in

tulip nimbus
#

hello, i was using the camera normally but now i cannot scale it somehow. Why is that? Im using a canvas for my text

#

i want to scale my camera because some objects that arent text or buttons cannot be seen for some reason

runic lance
slender nymph
#

also not a code question

sleek notch
#

Hi I need help. Why I can't see it in inspector?

slender nymph
#

Item is not serializable, you need to mark it as such to be able to serialize it and edit it in the inspector

sleek notch
#

the struct or the list?

slender nymph
#

the struct which is the only thing here called Item

sleek notch
#

still nothing or I'm probably idiot

slender nymph
#

did you save the code and recompile?

sleek notch
#

I did

#

Oh now

#

Sorry

#

my bad thanks

rich adder
#

(don't mind me just randomly seeing something like this for first time lol )

sleek notch
#

It is normal for me. Idk why it is happening

rich adder
bold saffron
#

for some reason public GameObject[][] enemiesInWave; won't show up in the inspector

slender nymph
#

unity cannot serialize multidimensional or jagged arrays. you could create a struct that has a GameObject array and use an array of that if you need to

languid spire
#

Unity will not serialize jagged arrays

wintry quarry
bold saffron
#

oh so how do I do it?

bold saffron
#

(I changed waves name to enemiesInWave)

slender nymph
#

you need to access the array variable inside that object

languid spire
#

do you initialize your arrays?

bold saffron
slender nymph
#

the same way you access any variable on any object. using the . operator

#

remember your array does not contain arrays but rather your class that itself has an array

bold saffron
#

what

languid spire
#

to use praetors example
waves[i].enemies.Length

wintry quarry
#

It's important to read and understand the error message, rather than just seeing "error" and guessing

bold saffron
#

thank you everybody who helped me ๐Ÿ‘

languid spire
faint osprey
#
    {
        while (RTL.hasPassedArea == false)
        {
            gameObject.transform.up = player.transform.position - new Vector3(0, +4.5f, 0);
            yield return null;
        }
    }```
this is my function that makes my light point at the player however when i reach the end of the level and the next scene loads the light in that scene is tracking me but pointing the opposite way as if its reversed
wintry quarry
#

why not:

transform.up = player.transform.position - transform.position;```
faint osprey
#

true ill give that a go

scarlet stirrup
iron wing
#

apologies if this is the wrong place to ask this. I've used QualitySettings.vSyncCount = 1; but I can't find like a visual way to see if it's working. How can I check? The line of code doesn't seem to affect the VSync checkbox above the editor window no matter what I do.

short hazel
#

When you do that, the FPS will be fixed to your current monitor's refresh rate

#

Alternately you can make a few tall cubes whose color contrast with the background, and wiggle your mouse left to right. If you can't see any tearing along the vertical lines, VSync is active

tulip nimbus
#

So theres two things that i dont understand currently. First of all, i dont know what i did but after editing this script and running the Game it freezes the entire thing. Also, I want to make it so that every time timer or timerA hits zero it spawns a gameobject at the random x and y coordiantes. However when testing all the Prefabs spawned at one coordinate instead of a random one.

public class GameManager : MonoBehaviour
{
    [Header("COLIN")]
    public int maxSprites = 8;
    public int currentSprites = 0;

    [Header("SCORE")]
    public int currentScore;
    public float timer = 3;
    public float timerA = 3;

    [Header("AYBARS")]
    public int maxAybars = 3;
    public int currentAybars = 0;

    public GameObject Colin;
    public GameObject Aybars;
    public StatsManagerScript statUPDATE;

    Vector2 spawn = new Vector2(Random.Range(171, 215), Random.Range(380, 300));

    void Update()
    {
        
        timer -= Time.deltaTime;
        timerA -= Time.deltaTime;

        while (currentSprites < maxSprites)
        {
            if (timer <= 0) 
            { 
            currentSprites++;
            Instantiate(Colin, spawn, Quaternion.identity);
            timer = 2;
            }
        }

        while (currentAybars < maxAybars)
        {
            if (timer <= 0)
            {
                currentAybars++;
                Instantiate(Aybars, spawn, Quaternion.identity);
                timerA = 2;
            }
        }

    } }
languid spire
tulip nimbus
languid spire
#

ok, what is the value of timer the first time it executes

tulip nimbus
#

3 if im not mistaken

languid spire
#

3 - deltaTime to be precise. So how is currentSprites ever going to increment?

tulip nimbus
#

as the code is in the Update() function i thought that timer decrements every real time second until it hits zero and is then set back to 2

#

or are you saying it isnt going down at all?

languid spire
#

but you are in a while loop, not the Update loop, it never exits it once it enters

short hazel
#

Execution enters the loop. Timer is greater than 0, the if is skipped, and the loop's condition is evaluated again. currentSprites hasn't changed so the loop continues. Timer is still greater than 0. The if is skipped. Repeat, infinitely. Your game freezes since your code never ends.
Unity will not render a new frame until all of the code has finished executing.

tulip nimbus
#

oh ok that makes sense, so the timer variable is always 2?

languid spire
#

no, it is always 3 - deltaTime

tulip nimbus
#

ah ok

languid spire
#

and the while cannot exit

#

that should probably be if statements not while statements

tulip nimbus
#

im going to try to implement something else with my code regarding this thank you so much in advance

#

Ok i changed the conditions into the if statments alone and it worked thank you guys! However im still kind of confused about the random.range Vector

tulip nimbus
#

oh this is great thank you

iron wing
short hazel
#

Try a standalone build, the editor might apply its own settings

celest flax
#

Is it possible to make a GameObject-variable except the variable only accepts a specific prefab or variants of that prefab?

iron wing
ivory bobcat
queen adder
#

This is just stupid, it's giving me a thousand errors and i don't see anything wrong with it, and guess what? It wasn't giving me errors for this same thing before.

#
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;

public class Rafael : MonoBehaviour
{
    public Rigidbody RafaelBody;
    public int RafaelSpeed = 3;

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

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.A))
        {
            RafaelBody.velocity = Vector3.left * RafaelSpeed;
        }

        if (Input.GetKey(KeyCode.D))
        {
            RafaelBody.velocity = Vector3.right * RafaelSpeed;
        }

        if (Input.GetKey(KeyCode.W))
        {
            RafaelBody.velocity = Vector3.up * RafaelSpeed;
        }

        if (Input.GetKey(KeyCode.S))
        {
            RafaelBody.velocity = Vector3.down * RafaelSpeed;
        }
    }
}```
keen dew
#

What's the first error?

queen adder
#

Let me give you all of them.

#

Ah dammit i cant.

#

wait.

languid spire
#

you have a duplicate script

queen adder
#

What

#

Another one??

languid spire
#

that is what duplicate means, yes

queen adder
#

WAIT A SECOND.

#

YOU ARE LITERALLY RIGHT

#

i wiped it off.

languid spire
#

of course I am

queen adder
#

thank you

#

Another couple errors

lethal elbow
#

Is anyone able to help me with a clamping issue?

 if (isRotating)
        {
            
                currentMousePosition = Input.mousePosition.y;
                mouseMovement = currentMousePosition - startMousePosition;

                transform.Rotate(Vector3.right, -mouseMovement * speed * Time.deltaTime);

                startMousePosition = currentMousePosition;
                
                
        }

I know I could track the values by using transform.localeulerangles.x but I don't know how to store the angle since I can't do transform.localeulerangles.x = MathF.Clamp ~~~~

#

I want to track the angle of the shape that's being rotated

#

then clamp it so it can't go past certain angles

queen adder
#

Ok