#💻┃code-beginner

1 messages · Page 349 of 1

final kestrel
#

In which line exactly do we change the vertical movement to be forward and backward?

wintry quarry
#

That happens every frame. Time scale doesn't matter

#

Update happens every frame and doesn't care about time scale

rare basin
#

ow

#

forget it then, thank you

wintry quarry
#

FixedUpdate is affected by time scale

final kestrel
#

Well okay I got it no need.

#

Is dealing with vectors always dis complicated

deft grail
rare basin
latent epoch
#

omg nope. I'm just an Idiot, there is a return statement, but its made it way ALLLL the way down to the very bottom of my code, I don't even think its within the Mesh constructor

sacred orbit
#

new… new input system????

icy wedge
#

oooh okay so this is how you bind the prefab to the variable ?

final kestrel
#
moveDirection = (transform.TransformDirection(Vector3.forward)*currentInput.x) + (transform.TransformDirection(Vector3.right) * currentInput.y);

How does this line return 0 on the y?

deft grail
sacred orbit
final kestrel
#

I mean moveDirection is a vector3 but we only deal with x and y input?

deft grail
rich adder
icy wedge
#

okk yea i did it

final kestrel
rocky canyon
#

it would become 0

final kestrel
deft grail
#

your only giving it a X and a Y from your Input, however your putting that into a Vector3

#

your not directly giving an X and Y to moveDirection

final kestrel
#

it could be simplified as transform.forward * currentInput.x + transform.right * currentInput.y too?

final kestrel
deft grail
final kestrel
#

I'll do that once I get home. On a different pc at the moment.

deft grail
#

alright

#

well it wont be 0

rocky canyon
rocky canyon
#

yea i was about to scroll

final kestrel
#

yeah it stores the y beforehand

#

i mean it gets restored after calculation

rocky canyon
#

ahh okay coolio

final kestrel
#

I was just confused how we assign vector2 to a vector3

tiny rain
#

A little synthatic sugar I often use myself, maybe you guys would like it-
Make a few extension methods like Vector2.X0Y(), Vector3.XZ(), Vector3.X0Z() and stuff

#

The function is self explanatory

final kestrel
tiny rain
deft grail
tiny rain
#

Similar thing with using a vector3 as a vector2, it throws the z axis away

rocky canyon
#

yup

tiny rain
#

Btw guys, what would be the best way to create some sort of cancelable event?

#

if I want to permit layers of subscribeable functions that would block something from happening

frank zodiac
#

its been around for years

tiny rain
#

The best I have is delegate with a ref bool

rocky canyon
#

i'd probably use a seperate event CanvelableEventHandler

#

or something

final kestrel
rocky canyon
#

or the bool

final kestrel
#

Good to learn now thanks all.

tiny rain
rocky canyon
#

im sure theres other ways. but thats the first thing that comes to mind..

tiny rain
#

I saw that delegates can pass something back. What would that do?

rocky canyon
#

ya, u can have a sender parameter

tiny rain
#

Uh, I mean, can that in any way be turned into a true if any subscribers return true thing?

final kestrel
#

Goddamn

deft grail
final kestrel
final kestrel
#

I cant even add 3 numbers together haha

#

Well thanks.

deft grail
final kestrel
deft grail
final kestrel
#

Well great. Thanks a lot!

valid slate
#

where can i ask about unity installation itself?

sleek notch
#

Hi I have problem with buttons in canvas. I can't click on it and I have no idea where is problem.

polar acorn
sleek notch
#

The script is attached to newsPaperUI

polar acorn
# sleek notch

Is WordEventSystem an EventSystem you've renamed and attached other objects to? Show the inspector for it

sleek notch
#

No

#

The WordEventSystem is my empty gameObject and it will do another stuff

polar acorn
#

So do you have an event system in the scene

sleek notch
#

No?

polar acorn
#

Then that would be your problem

sleek notch
#

So how do I create it?

polar acorn
#

Create -> UI -> Event System

sleek notch
#

And that is everything?

polar acorn
#

yes

#

you might need to click the big red button on it if you're using the New Input System, or it might have come with one. If it doesn't look angry at you that should be enough

sleek notch
#

Nope. I installed new input system and still not working

icy wedge
#

hey, in my folder script I have the class A and the class B, and now in my class C i want to instanciate them but from what i understand, I really need to drag and drop the A and B to the inspector ? Why isn't it as simple like using or import idk ?

polar acorn
polar acorn
sleek notch
polar acorn
icy wedge
#

he just say the Type or namespace name 'A' could not be found, I wrote Using A since its in the same folder

#

(vscode does not help alot on imports lol)

sleek notch
polar acorn
icy wedge
#

just public enum A nothing really special

polar acorn
polar acorn
icy wedge
#

no, so i should use another keyword like import ? Im from java idk much about c#

polar acorn
#

If it's not in a namespace it's global

icy wedge
#

okok i see

sleek notch
#

No it is now working. I replaced with normal legacy button

tiny rain
#

Is this a good way to do it?

public CanSlotModifyDelegate CanSlotModify = (Itemstack it, int i, ref bool b)=>{};
#

I have to initialize it with a starting value cus otherwise += would throw a null reference exception, I'd not use = cus again, it's meant to be an event to subscribe to.

polar acorn
tiny rain
#

Well, not exactly an event ig, since it's also used as a question by more than just itself...

#

*Called by other scripts too

#

Strange, they didn't initialize it but they're implying that it works without.

mystic dawn
#

hey there! does anyone know if there is a way to check for when a variable like a float reaches a certain % of it's assigned value?

let's say i set a float value in the inspector, how can i check when this value reaches <= 50% of it's value no matter what i assign for it as a value? any help would be greatly appreciated!

polar acorn
mystic dawn
#

do i just do something like * 0.5 for 50% and such or is there a specific better way to do it?

polar acorn
tiny rain
#

Is marking it as an event going to avoid the issue?

polar acorn
tiny rain
#

Cus this nightmare

                bool canceled = false;
                CanSlotModify.Invoke(itemstack, i, ref canceled);
                if (canceled) continue;
brave compass
tiny rain
#

Uhm... Imma test it again to prove my point... Or prove that I did a blunder even if I'm skeptical of that one

#

Answer iiiiiiis... Yes, half

#

Non-event delegates/actions/funcs will have trouble with += when you haven't assigned a value to it

#

But adding event does indeed bypass the issue, soo... Thank you digiholic xD

#

Sigh... No it's mistaken, event appears to be unable to bypass the issue 🤦‍♂️

edit: No wait it does actually work with or without, am I the one who did a blunder all along??

honest haven
#

thanks sorry was in a meeting for ages, before i try moving the scene. I am goingto try ddol, but it dos not become a ddol

rich adder
honest haven
#

Thanks i went with wrapping a game object around the battle scene and moving it to a new space and not unloading the main town thank you for your input was really helpfull

drifting walrus
#

Hi, I'm working on a game that requires players values to change based on duration of time passed.

There are time difference calculations, calculated between the player's current time, and a previous timestamp stored on a remote database.

What are the best practices / frameworks to use for getting the player's current time from the Internet? Essentially, I don't want the player to change the time on their device to speed up time durations. Whenever a CurrentTime is called, I want the player device to check the CurrentTime of some cloud service.

Is there an existing web service / function in Unity? Otherwise, what are the standard ways to achieve this?

tiny rain
#

If you're making a multiplayer game or something of that sorts, pretty sure you should simply never let the player send it

#

Never trust input from the client, basic rule

#

Checking for time should be done by the server in that case, I guess

wintry quarry
#

Kind of a whole different skillset/toolset than Unity

tiny rain
#

Timezones can still trick it I think? Though it'd be so constrained that it'd not be very valuable... Normally.

rich adder
tiny rain
#

Unless if he's trying to make some sort of highscore/shortest time beaten system

rich adder
#

yeah but how do you define which is current player?

#

or just anonymous i suppose

tiny rain
#

Idk, no matter how I think about it it can be tricked

#

I heard that clientside's encoding doesn't work cus they can use your program to do the same

rich adder
#

yes everything should be handled server side, client just sends request

#

ideally to an API

tiny rain
#

Basically that means that if people want, they can have full control over the whole client

#

Which then... Ig that the only way is to announce that you've started a session, and then... No, even then they can fake the victory signal

rich adder
#

this is why everything is mostly handled with tokens

tiny rain
rich adder
#

because the token was issued by the server, usually with a custom signature

#

if you tamper it, the signature doesn't match , becomes invalid

tiny rain
#

So... The token acts as a key to the session on the server, I'm guessing?

rich adder
#

yes hence why they typically have expiration time

#

you the dev have to handle the timing and refreshing new tokens to keep someone logged in

tiny rain
#

What stops cheaters from using the token to send fake data back though...

#

Currently I'm imagining one of those speedrunning games

drifting walrus
#

We already have an auth system and cloud save system. But that tool does not have such a feature to give the current UTC time.

rich adder
#

store that inside each players Cloud Save

rich adder
#

some tokens also add machine signing , depends on algo used too

tiny rain
#

If hackers can use the whole client's stuff I don't see what stops them from using the token ngl

drifting walrus
rich adder
rich adder
drifting walrus
#

I meant moreso that I dont want players to be able to set their mobile device time to some time in the future, to skip ahead the time they need to wait for features in the app

drifting walrus
tiny rain
#

No I mean... Like, for example, my brother actually did some modding on a multiplayer game before, he could just access the client's source code...

rich adder
#

you need to grab server time

#

just make a simple HTTP Request to some free server time

drifting walrus
rich adder
drifting walrus
#

Or any Unity time server service offered?

rich adder
#

but probably not worth wasting tokens

drifting walrus
drifting walrus
#

When there are free solutions out there, got it

#

Ok thanks for the help!

rich adder
#

soo many

thick cobalt
#

Hi I'm trying to use the Meta Movement SDK examples, specifically the Aura Sample, to implement a handtracking and eye tracking logger (print positions of user's hand and eye movements). I'm not really sure which scripts to modify and how to get this information. Would appreciate any help for a beginner at Unity! https://developer.oculus.com/documentation/unity/move-samples/#face-and-eye-tracking-with-aura

weak grove
#

a friendly noob has appeared!

#

hello!

#

today i learned about the component system lol

rich adder
#

good thing too, unity is Component based

weak grove
#

haha yes 😄

#

its like a freer type of inheritance

#

flat hierarchy and all that

umbral rock
#

why does velocity.up work but velocity.right doesnt? i cant move right?

wintry quarry
umbral rock
#

i meant vector

#

sorry lol

#

😄

wintry quarry
#

show the inspector of your object?

umbral rock
#

i can jump but i cant move right

wintry quarry
#

did you constrain the x position of the rigidbody perhaps?

#

(also what's with the weird brackets)

umbral rock
rich adder
#

yup

#

Praetor nailed it

wintry quarry
umbral rock
#

oooh

wintry quarry
umbral rock
#

omg

rich adder
#

maybe you meant to do rotation ? UnityChanLOL

umbral rock
#

im so sorry.. what a dumb mistake :/

#

thanks for the help tho, it works now lmao

stuck palm
#

why doesnt this event show up?

wintry quarry
#

and doesn't have [SerializeField]

#

so it is not serialized

#

BUt also... a UnityEvent wouldn't show up in that list in the first place

#

only methods will show up there

stuck palm
#

okay thank you

fervent abyss
#

how can i check if 2 objects intersect without using colliders stuff like on trigger enter

valid violet
#

@fervent abyss You can check the distance between two object and if they are close enough trigger what you need

languid spire
languid spire
dim stream
#

hi, i have this code but i cant look to the sides, oonly up and down and the camera still dont attach to the player

#

may someone know the solution?

fervent abyss
#

you dont do anything Y axis related

dim stream
#

😔

#

i followed a tutorial

#

and the guy could move all directions

#

i dont understand

#

😱Mejor explicación que FUNCIONA EXELENTE para TÚ PERSONAJE en PRIMERA PERSONA mas SCRIPT AQUI ABAJO :D Aquí te explicare lo que nadie mas explica a detalle y lo mejor de todo en menos de 10 min si te funciona déjame un comentario y un gran like que no cuesta nada :D

Regalo Script 🎁 Aquí 👇🏻
https://terabox.com/s/1J6jSdSexWWJSm3bUh6MEvA

🟣Twitch...

▶ Play video
rich adder
#

love how he copied the same brackys tutorial thumbnail and still made same mistake with Time.deltaTime

rich adder
dim stream
#

ok

rich adder
#

well first of all

#

it is rotating left / right

#

the camera is not child of Player

#

ofc its not gonna follow it

dim stream
#

what

rocky canyon
rich adder
rocky canyon
#

u rotate the camera up and down transform
u rotate the player left and right.. player.transform

rich adder
#

If you took your eyes out of your socket and just left them on a shelf, can you see where your body is going ?

dim stream
#

when i move the mouse side to side only the player turn the head, but the camera dont do it

rocky canyon
#

the player shuld be a child object of the player..

#

meaning it would follow the player if the player rotates

rich adder
rocky canyon
#

wouldnt matter if u had zero more code..

#

that would still work

dim stream
rich adder
#

no

dim stream
#

srry im not understanding jajajaja

rich adder
#

do you know what Parenting does in unity?

#

or any other program like blender?

dim stream
#

yeah yeah yeah okey, i didnt put it there because before i tried but didnt work

rich adder
#

because you had two cameras

dim stream
#

now it works i think

dim stream
dim stream
#

thank you so much @rich adder

#

😄

hollow dawn
edgy prism
#

Hello, I have different types of projectiles in my game I kept getting missing reference errors for one kind, after endless searching for what was destroying them I realised it was another type of projectile (at least I'm 99% sure). However I thought that in my function I was telling it not to destroy that kind of projectile can anyone explain why it is anyway?

public void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.GetComponent<PlayerController>() != null)
        {
            Debug.Log("You Died");
            GameController.i.SetGameOverState();
        }
        else if (col.gameObject.GetComponent<Bullet>() == null)
        {
            Destroy(col.gameObject);
            Destroy(this.gameObject);
        }
    }
polar acorn
icy wedge
#

hey guys, i'm having trouble with audio source, i have this little script that just play one sound, but I guess i have to attach an audiosource from here but there is no in the list

edgy prism
# polar acorn What is the specific error you are getting? What line?

I think I've fixed it now, I am just curious why if what I think is the cause was that piece of code didnt stop it. But to answer your question it was this line:

Rigidbody2D rb = projectile.GetComponent<Rigidbody2D>();

And the error was MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.

#

(The game is set up in such a way that the projectiles shouldnt be able to be destroyed before force is applied to them)

polar acorn
polar acorn
edgy prism
polar acorn
edgy prism
crystal chasm
rancid zenith
#

https://www.youtube.com/watch?v=f473C43s8nE&list=WL&index=10&ab_channel=Dave%2FGameDevelopment
watching this video, after limiting my speed so i dont infinitely accelerate, my character still continues to slide, but his doesnt, ideas why it seems like the ground still has no friction for me?

FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial

In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.

If this tutorial has helped you in any way, I would really appreciate...

▶ Play video
polar acorn
icy wedge
#

i didnt want to add audio clip i m trying to just generate a sound based on frequency and play a bit with its length @crystal chasm

polar acorn
#

But if you log in OnDestroy and also before the error, you can at least see the order

icy wedge
#

to create a sort of piano if you want

crystal chasm
#

Ok. You will still need an audiosource for that.

crystal chasm
#

It's a component

polar acorn
icy wedge
#

okay

timber tide
#

Quick question. Will StopCoroutine throw a null ref if the coroutine ends before the method is called. Not by string, but by reference overload

crystal chasm
#

Not that I have ever seen.

edgy prism
#

Because I havent encountered it since and im 99% its just destroying the projectile with the Bullet script on it anyway

crystal chasm
#

Destroying your bullets all the time is not the correct way to go about it anyway. You should be object pooling.

polar acorn
edgy prism
polar acorn
#

If your projectile has a log in OnDestroy you can find out if it's getting destroyed somehow between instantiation and accessing the Rigidbody

polar acorn
crystal chasm
edgy prism
edgy prism
crystal chasm
#

SimplePool is the one I have used for bullets.

edgy prism
wind raptor
#

How might I accomplish something like the following?

int x = 4;
string str = $"x: {x}";
x = 5;
Debug.Log(str); // I'd like this to print "x: 5"

I know the string object doesn't work this way, but I'd like to have a sort of dynamic string object that contains references to variables that change the string value when they are updated

#

I've written an overly complicated parsing function to sort of accomplish what I'm after, but I feel like there must be a simpler way.

hollow dawn
eternal falconBOT
hollow dawn
polar acorn
honest haven
#
    {
        _inZone = true;
        GameManager.instance.battleStarter = gameObject;
    }``` i have 10 npc with this script, why does it trigger that on all of them?
wind raptor
polar acorn
polar acorn
wind raptor
polar acorn
#

because those are conflicting goals

crystal chasm
polar acorn
#

All you've done to theirs is removed the string interpolation

rancid zenith
wind raptor
#

I somewhat suspect that what I want to accomplish is not possible.

#

But wanted to make sure there wasn't some dynamic string something or other that checks all the boxes

edgy prism
polar acorn
# wind raptor ...both?

If you've got a lot of different things you want to use, at some point you're going to have to tell the code about those things. So you'll need to either use an interpolated string or make a function that returns a string

crystal chasm
#

yeah. lol, Debug.Log(str + x);

#

don't add the number to str at all.

polar acorn
#

Actually, the whole object with the camera on it

#

not just the one component but the transform and whatnot too

rocky canyon
crystal chasm
#
string str = "x: "; 
x = 5;
Debug.Log(str + x);
rocky canyon
#

is the height high enough?

#

u can also debug the raycast hit to see if anything is blocking it

rancid zenith
#

right now ive got a debug on the groundcheck, and the raycast seems to be hitting, but the console states, "grounded: false"

i dont know if my height is high enough, how do i check

eternal falconBOT
polar acorn
#

Include your logs

wind raptor
rocky canyon
rancid zenith
#

!code

eternal falconBOT
rancid zenith
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class XYZMovement : MonoBehaviour
{
    [Header("Movement")]
    public float moveSpeed;
    public float groundDrag = 5f;
    

    [Header("Ground Check")]
    public float playerheight = 2f;
    public LayerMask whatIsGround;
    bool grounded;



    public Transform orientation;

    float horizontalInput;
    float verticalInput;

    Vector3 moveDirection;

    Rigidbody rb;



    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.freezeRotation = true;
    }

    private void Update()
    {
        SpeedControl();
        MyInput();

        grounded = Physics.Raycast(transform.position, Vector3.down, playerheight * 0.5f + 0.2f, whatIsGround);

        if (grounded)
            rb.drag = groundDrag;
        else rb.drag = 0;

        Debug.Log("Grounded: " + grounded);
    }

    private void FixedUpdate()
    {
        MovePlayer();
    }

    private void MyInput()
    {
        horizontalInput = Input.GetAxisRaw("Horizontal");
        verticalInput = Input.GetAxisRaw("Vertical");
    }

    private void MovePlayer()
    {
        moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

        rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);
    }


    private void SpeedControl()
    {
        Vector3 flatVel = new Vector3(rb.velocity.x, 0f, rb.velocity.z);

            if(flatVel.magnitude > moveSpeed)
        {
            Vector3 limitedVel = flatVel.normalized * moveSpeed;
            rb.velocity = new Vector3(limitedVel.x, rb.velocity.y, limitedVel.z);
        }



    }

}
#

thats longer than i expected

#

💀 my bad

eternal falconBOT
rocky canyon
#

his raycast is just a boolean.. u can debug the value to see if it ever returns true..

#

the player height is cut in half.. so u can just increase that a bit higher just to test..

hollow dawn
rancid zenith
#

just the player height?

rocky canyon
#

its a process of debugging.. you test various things to rule out if thats the problem..

polar acorn
# hollow dawn

Is your camera being controlled by any of your animators? Try disabling the animators and see if the camera is still wigging out

rocky canyon
#

so if player height is the issue.. u can raise that to some value high enough u know u'd get a hit..

#

and then if it doesn't u move to the next thing

#

Debug.log(grounded);

#

that would debug the value of the boolean named grounded

rancid zenith
#

yeah that was legit the issue lmfao

#

i went into the inspector and changed the player height

rancid zenith
#

and now im not a peguin lol

strong token
rancid zenith
crystal chasm
rancid zenith
rocky canyon
#

if ur player is 6 units tall.. then the code playerHeight * 0.5f would cut it in half.. soo ur raycast is then 3 units long.. and it starts at the point u chose.. soo probably transform.position which is the dead-center of the capsule..

polar acorn
rocky canyon
#

he includes a + 0.2f on his code. so u can use the exact player height.. and once its halved he makes it a tad bit longer.. so it will clear the mesh.. and touch the ground

polar acorn
rocky canyon
rancid zenith
rocky canyon
#

if the scales are not 1:1:1 then a 2 unit tall capsule really isn't 2 units

rancid zenith
#

the code runs fine when i set the player height to 6, it doesnt change anything i dont think, but im just getting an understanding of it

stoic glen
#

Clones are still spawning in the hirachie, after closing the game

    private GameObject goBullet;
    public float bulletSpeed = 10.0f;
    public float intervall = 1f;

    void Start()
    {
        InvokeRepeating(nameof(Shoot),0f,intervall);
    }

    private void OnValidate()
    {
        CancelInvoke(nameof(Shoot));
        InvokeRepeating(nameof(Shoot), 0f, intervall);
    }


    private void Shoot()
    {
        var bullet = Instantiate(goBullet, transform.position, transform.rotation);
        bullet.GetComponent<Rigidbody2D>().velocity = transform.up * bulletSpeed;
    }```

Much slower then the 1 second, but it doesnt stop
polar acorn
polar acorn
hollow dawn
polar acorn
rocky canyon
#

if u use that drawray method i sent earlier u can draw a physical line in the editor to represent what ur ray is doing..

polar acorn
#

Debug Log should literally have been the first line of code you wrote in Unity

hollow dawn
#

oh debug

polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
rocky canyon
#

0s eh?

polar acorn
# hollow dawn

Okay, so it looks like your input manager gets you the mouse position, but your code is assuming it's mouse movement

#

I think? It's kind of hard to tell actually, the mouse doesn't seem to sit still for very long

#

Maybe show the input manager code as well

#

!code

eternal falconBOT
stuck palm
#
 private void Awake()
    {
        Time.timeScale = 1;
        foreach (VolumeSlider slider in vs)
        {
            slider.Init();
        }
        fade = FindObjectOfType<FadeToLoad>();
        StartCoroutine(fade.FadeOut());
        mainButtons.SetActive(true);
        optionsScreen.SetActive(false);
    }

why cant it find fade?
fade is there

hollow dawn
polar acorn
stuck palm
polar acorn
polar acorn
#

what line is the error on

hollow dawn
polar acorn
hollow dawn
#

so is the problem with my other script?

polar acorn
#

The problem doesn't appear to be either of these scripts but something else. Disable your player control script and see if the camera still moves without it

hollow dawn
#

yh its the player script

stuck palm
hollow dawn
polar acorn
frigid sequoia
#

Just a quick clarification, OnEnable, just as anything on non-editor scripts just triggers during runtime, is that right?

polar acorn
frigid sequoia
rancid zenith
#

im back, no more sliding, although it feels like my gravity is very low, how do i increase it? i think im just using the RB gravity as my base, im not sure tho

polar acorn
hollow dawn
rancid zenith
hollow dawn
polar acorn
stuck palm
hollow dawn
#

should I put this in this line of code? _xRotation = Mathf.Clamp(_xRotation, UpperLimit, BottomLimit);

cedar shale
#

hey, i'm trying to program a board game, with a kinda open world, so i have spaces, but you can move in any direction to any of them. how can i get the distance in spaces between them? here a pic as visualization

wind raptor
honest haven
#
    {
        if (other.CompareTag("Player") && gameObject.CompareTag("EnemyWeapon")
        || other.CompareTag("Enemy") && gameObject.CompareTag("PlayerWeapon"))
        {
            test = true;
        }
    }``` why are both object true. only the left one should be tru
wind raptor
#
int x = 4;
string str
{
  get { return "myInt: " + x; }
}
#

And just have a custom getter for each string, referencing whichever variable.

languid spire
honest haven
#

sorry can you give me a bit more of a hint

#

oh

#

yes

languid spire
#

well, I presume you are trying to isolate the 2 &&'s

rancid zenith
honest haven
rocky canyon
#

needs to tune gravity and drag of the rigidbody

hollow dawn
#

@polar acorn should it look like this?

languid spire
wintry quarry
polar acorn
rocky canyon
#

ur gonna need to start actively researching things urself..

honest haven
rocky canyon
#

we use keywords that are generally easily searchable.. and included in Unity

#

s documentation

polar acorn
languid spire
rancid zenith
hollow dawn
wintry quarry
hollow dawn
#

@wintry quarry praetorblue

wintry quarry
#

Which I'm not aware of what that is

wintry quarry
#

What's it set to?

hollow dawn
wintry quarry
#

It should probably be somewhere between 0.5 and 5

#

1 would be a good starting point

hollow dawn
#

@wintry quarry what should I put the upper limit and bottom limit?

wintry quarry
#

Certainly upper should be higher than bottom though

#

Well except that you plugged them backwards in your code

#

So they're currently backwards

hollow dawn
#

bro im getting stressed how can I fix this?? literally there is not one video about how to fix this I literaly cant look around and the camera is glitching

wintry quarry
#

Every video tutorial is "how to fix it"

#

You'd have to also show how your input manager code works

#

I would guess that's the other part of the problem

#

The input manager code is likely not correct

hollow dawn
#

not its correct I showed @polar acorn the input manager and he said its fine its the player script along with the camera code

polar acorn
#

I'm still waiting for you to post the results of the log I asked for

hollow dawn
#

OMG I FIXED IT!! I just had to fix the upper and bottom limit lol

#

@polar acorn @wintry quarry Guys thank you for your assistance and help I've managed to fix some errors but here is the final product im soo happy 😭 ❤️

sudden quiver
#
        if (Input.GetKeyDown(KeyCode.W) == true)
        {
            myRigidBody.velocity = Vector2.up * jumpStrength;
        }

        if (Input.GetKey(KeyCode.D) == true)
        {
            myRigidBody.velocity = Vector2.right * walkStrength;
        }

        if (Input.GetKey(KeyCode.A) == true)
        {
            myRigidBody.velocity = Vector2.left * walkStrength;
        }
polar acorn
sudden quiver
#

owh

#

how do i go on about not cancelling gravity

hollow dawn
open veldt
#

For several stats in a battle system, is it preferred to have several single int variables or one array of numbers for each stat?

wintry quarry
#

Neither

polar acorn
open veldt
#

Then what’s neither

#

What else to do

wintry quarry
#

I mean it really depends on your requirements

wintry quarry
#

But typically something more robust that supports augmentations and buffs and debuffs etc

#

Status effects, etc

hollow dawn
#

@wintry quarry I need help. everything is working fine just one little thing. the camera is placed in the head and when im running the camera moves along with the head similar to when your running in real life how can I fix this

wintry quarry
#

Don't put the camera in the head

open veldt
sudden quiver
open veldt
#

But basically I have a class containing the ints for each stat

hollow dawn
polar acorn
open veldt
#

If u dont want first person

hollow dawn
open veldt
#

On the head, as if you are running in real life, is first person

polar acorn
hollow dawn
#

I want it to be still

polar acorn
hollow dawn
#

ill show u

open veldt
#

Like is it moving too fast or falling off or something ???

#

Because in first person it SHOULD move when you walk and turn your head

wintry quarry
hollow dawn
polar acorn
polar acorn
#

I couldn't make heads or tails of that question

open veldt
#

My wifi is so bad I cant see it tragic :(

#

Ohhh yeah I get it

#

Did my best 😭

sudden quiver
#

wa

#

when i vector2.up

wintry quarry
#

Show it

sudden quiver
#

how come it resets the y velocity is what i dont understand

wintry quarry
polar acorn
#

See how the y value is 0

sudden quiver
#

yeah

polar acorn
#

you're setting the y velocity to 0 and the x velocity to walkStrength

#

Meaning you're overwriting gravity

sudden quiver
#

so this is a poor way of making a moving an object

#

basically.

open veldt
polar acorn
wintry quarry
sudden quiver
open veldt
#

I love classes shoutout to classes

#

For a bunch of variables on the BattleInfo class though representing each stat, would it be fine to just have a single variable for each or should I put it in an array or list?

I’d use a dictionary but I’m hesitant because I have a save system with JSON and dictionaries don’t save

#

Or like they don’t convert to JSON

wintry quarry
#

The most flexible thing is like a list and each stat object says what it is

#

Especially if not everyone or everything has all the same stats

#

But maybe they do

#

Dictionaries are fine as long as you know how to work with them and serialize them if needed

#

JSONUtility in Unity doesn't Serialize them by default that's all

open veldt
#

They all have different ones this is basically a base class for things that need stats to battle

I’ll try a list maybe or I’ll try and see how dictionaries can be serialized since player stats need to help saveable

#

Dont wanna have my player grind for 3 hours n come back to level one lmaoo

dawn oracle
#

so i have this (i took it from a post) ``` private void OnTriggerEnter(Collider collision)
{
string[] tagToFind = new string[] { "wall", "robot", "gameObjects", "walls", "doors" };

    for (int i = 0; i < tagToFind.Length; i++)
    {
        var testedTag = tagToFind[i];
        //compareTag() is more efficient than comparing a string
        if (!collision.CompareTag(testedTag)) continue; //return early pattern, if not the good tag, stop there and check the others

        Debug.Log($"hit {testedTag}"); //improve your debug informations
        return; //if the tag is found, no need to continue looping
    }
}

}``` the wall object looks like this. the controller that collides with it looks like this . ( this is my first time asking for help not sure what you all need help would be very much apperieicated)

open veldt
#

I’m just trying to figure out how to structure this well, thanks!

dawn oracle
dawn oracle
wintry quarry
dawn oracle
#

so put is trigger on?

wintry quarry
#

If you want a trigger..

#

Maybe first understand what a trigger is

#

Otherwise you might want to look at OnCollisionEnter

dawn oracle
#

ok

dawn oracle
cosmic dagger
#

bruh . . .

stuck palm
#

what value cant be null? im confused here.

frigid sequoia
#

Any idea why this could cause a NullReferenceException?

#

It is assigned

ripe shard
frigid sequoia
# stuck palm

Maybe you are not passing the parameter? What line?

stuck palm
frigid sequoia
stuck palm
#

is the line that is causig the error

ripe shard
wintry quarry
# stuck palm

That error looks like what happens when you have an AudioSource without an assigned clip

wintry quarry
frigid sequoia
frigid sequoia
ripe shard
frigid sequoia
#

Oh, now it doesn't return the error, but is not doing anything

wintry quarry
frigid sequoia
ripe shard
#

well your code doesn't do what you probably want. its just wrong.

stuck palm
ripe shard
#

use OnEnable/OnDisable and just call your Play/Stop there

wintry quarry
stuck palm
frigid sequoia
wintry quarry
ripe shard
frigid sequoia
ripe shard
#

for example

frigid sequoia
#

Yeah, it does

#

In play mode too

#

I just want to sync it with an animation and I need to see both at the same time

stuck palm
ripe shard
# frigid sequoia Yeah, it does

well, no idea then, i would have assumed this to be the way to play it, if that doesn't work something else is the issue or its not possible, idk

wintry quarry
grizzled zealot
#

I want to create SOs where I store a callback function and would like to configure this through the inspector. Is there a way to assign functions to Action attributes in SOs through the inspector?

wintry quarry
#

It's calling PlayOneShot with null

#

It's a listener to the on value changed for your volume slider

grizzled zealot
wintry quarry
#

(which is running when you set the slider value)

wintry quarry
stuck palm
#

oh wait

#

the audio source is null

#

but i dont understand

wintry quarry
#

Is Collapse turned on in your console

stuck palm
#

there is an audio source here

#

so im confused

strong wren
#

making Ai isnt that hard is it?

#

well in my case it should be easy

wintry quarry
strong wren
#

is it hard to make an AI just go to the player position?

stuck palm
strong wren
#

like in my game i just need an enemy to spawn in Know exactly where the player is then go to the player and if its in the range it should damage him and active an animation

#

which the dmg part is easy il slap a colider on that bad boy and if the player colides with it hit animation starts and it decreases the players hp

wintry quarry
#

Where does it take you

strong wren
#

idk how to do it tho

i was thinking maybe draw a raycast from the player to the ai and the ai should just follow it?

#

or maybe i can get the vector 3 of the player and tell it to go there but i dont think thatl work

stuck palm
strong wren
#

is there maybe smth like movetowards?

stuck palm
#

from what i can tell, its trying to call before it exists.

strong wren
#

like transform.position = Vector3.movetowards(0, 1, 0)

wintry quarry
dusty ember
#

is there a good tutorial that teaches me the syntax of unity

eternal falconBOT
#

:teacher: Unity Learn ↗

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

dusty ember
#

why thank you

stuck palm
#

different issue now, im getting the print log fine, but the audio mixer isnt actually reflecting the changes. this error only happens on startup, when the volume changes from player input it works as normal.

private void ChangeVolume(float sliderValue)
    {
        print("Changed Volume to" + sliderValue);
        float volumeValue = Mathf.Pow(sliderValue, exponent);
        audioMixer.SetFloat(channelName, Mathf.Log10(volumeValue) * 20);
        PlayerPrefs.SetFloat(channelName, sliderValue);
        if (sliderValue == 0)
        {
            audioMixer.SetFloat(channelName, -80f);
        }
    }
real falcon
#

is it possible to say, place a prefab during runtime, but have it apply to the actual scene itself?

#

like realtime level editing

#

I hate the default 3D navigation and would like to make my own placement tools for certain things similar to GMod

eternal needle
#

otherwise you'd need to create your own way to save a scene

real falcon
dusty ember
#

guys people in youtube videos have this thing where it shows possible code you want to type, but it doesnt show it for me. how do i enable it?

eternal falconBOT
eternal needle
real falcon
#

I mean maybe the file thing wouldn't be too hard

#

if it's just instructions for prefabs with preset values

#

like, could I have a scene with geometry and navmesh and all that, and then load a text file that says "this prefab at these coordinates with these variables?"

#

that might make it hard to visualize in the editor, but I could just give godmode and pause to the ingame or something

eternal needle
real falcon
#

hm ok. wondering if that's maybe just what I should do, because I wast so much time trying to position stuff in the editor, very slow to edit placements and stuff

eternal needle
#

if its editor only, theres really no reason to be messing around with saving to your own file. You could create a tool that spawns certain objects for you depending where you look as you wanted but i truly doubt itll be saving that much time.

#

im not really sure what part you struggle with, like what are you placing thats difficult to edit?

real falcon
#

it's just tedious

#

gotta find the prefab in a list, zoom into the right spot which is very annoying in Unity, click on it, drag it, hold buttons to make it snap, even though it doesn't snap properly, so I have to readjust it, then click on another tool to rotate it, etc.

#

would be a lot faster if I could just run there, right click on the ground, and the enemy is there facing me

#

or wall mounted object, etc.

eternal needle
#

🤷‍♂️ i doubt you'll get the behaviour you want from an editor script in this case, because you'd basically just be recreating the drag and drop that already exists.

real falcon
#

yeah I'm thinking of making a file which keeps a list of prefabs to spawn when the level loads

#

then I can do something like, pause the game, place a turret in a spot I want to try with a few clicks, and restart the level

eternal needle
#

thatll honestly be way longer. especially cause you're kinda just skipping over the part where you're having trouble with placing it in editor already, whats the workaround gonna be? You can create your own script which lets you place with right click... but where will it place? Drag and drop already does it based on your cursor

real falcon
#

it doesn't do it properly, I'll be able to set the exact spawn location with this instead of relying on "center" or "pivot", it will then also auto-snap the the normal I'm pointing at, and then depending on the object placed do other contextual stuff like looking at my location

#

or I could add a tool to link events like just point at a button, point at a door, etc.

eternal needle
#

i think maybe you just arent used to the unity editor 😅 this tool sounds nice on paper if it already exists. itll definitely be a good waste of time though especially if you go with the file route.
The only useful part really could just be creating a script which takes 2 objects, then rotates object A to look at B

#

especially loading your scene will just take longer

real falcon
#

I mean I wouldn't use the file if it was possible to just directly add prefabs to a scene prefab from runtime but it doesn't sound like that's possible

eternal needle
# real falcon I mean I wouldn't use the file if it was possible to just directly add prefabs t...

well if you for sure wanna continue down this path, just know itll be a major pain in the ass. Especially during the development cycle where prefabs may change, be deleted, or new ones may be added. You'll need to reference it by some ID, and looking through this in a file to know which ones to delete are gonna be a headache. In which case you may think to further develop your editor tool, to allow you to delete objects. This is gonna be a lot of dev time sunk into a worse solution than just becoming familiar with the unity editor

real falcon
#

the editor is not very quick to use

#

it's not specialized to my needs and the quicker I can edit a level the more likely I will be to expiriement

#

if there's no way to place an object in the scene in a permanent way from runtime, then I will have to use a file that loads them

paper peak
#

Im watching a scripting tutorial video and theres this reference where it equals to "default", what this default statement do exactly?

#

Would there be any difference if i were to do

private GameObject attackArea;
```?
teal viper
teal viper
#

It's just the tutorial person being fancy or silly

#

Or maybe they're just used to it.

paper peak
#

Got it, thanks for the help

teal viper
#

Maybe it's a convention they're used to

eternal needle
#

That's definitely silly, I hope it's not any popular convention

cosmic dagger
#

everything is default . . .

teal viper
#

Or, maybe the code was decompiled 😱

cosmic dagger
#

that's my new thing. i use default instead of null . . .

eternal needle
#

Theres a major difference, for example default quaternion is not valid

cosmic dagger
#

structs and value types have a default. an int is just 0 . . .

foggy saffron
#

Hello! I'm working on a project and need some advice. I'm making a score counter, but I'm not sure which approach is best. My first idea is to make an array similar to how I have the game objects spawning, and then using the array in an "if" statement to raise a score counter for each gameobject in the array that translates past a certain vector. If I do the first idea I'm planning on using one script on a gameobject that will be able to track the player score as well as the enemy score. My second idea was to make a script that I can attach to the gameobject prefabs that would change the counter as the translate past the vector that triggers the score change.

Also, not looking for help with the actual code just yet. I'm just trying to figure out which method would be better to use.

teal viper
eternal needle
frigid sequoia
#

Is it like soccer? Golf? A deathmatch? Scrabble?

foggy saffron
#

3d top down shooter. Player scrolls side to side and fires projectiles and incoming gameobjects. If a game object makes it past thier score goes up. Player score goes up when hitting an incoming game object

frigid sequoia
#

You would need something to differenciate between those

foggy saffron
#

hmm right now I have the prefabs getting destroyed when they pass a certain vector. It wouldn't be just as easy to trigger a score increase that way as well?

frigid sequoia
paper peak
#
Invoke("MyFunction", timeToInvoke)
Invoke(nameof(MyFunction), timeToInvoke)
```Whats the difference of using nameof() here?
#

Im watching a video where it says i shouldnt use invoke without nameof() but it doesnt really explain why

teal viper
#

It helps you prevent human mistakes(typos) as well as not break if you rename the function(correctly).

#

it basically gets the name of the function as a string during compile time.

dusty ember
#

guys can someone show my how to setup ide

deft grail
eternal falconBOT
frigid sequoia
#

Is there a way to use like... Random.InsideUnitSphere but give it an angle to sample for?

verbal dome
#

Maybe randomize the x and y axes

#

And then multiply with Vector3.forward

frigid sequoia
knotty agate
#

Any Method to let Linear X max value become 3. I tried edit the key's value to 3 (like left's picture)but not working

final kestrel
#

How do you discard changes (not committed) in git?

#

I tried looking it up but they mention reverting commits and such

timber tide
#

usually right click discard in github desktop :)

slender nymph
#

depends, if you are using a GUI for it you can typically select the file(s) you want to discard and right click to select discard changes (or whatever your GUIs equivalent is)
or you can use the stash command to discard but store them, or reset to completely remove them

final kestrel
#

I'm not using the gui yeah thats why I got confused because you right click and discard on gui but on command I was confused

#

hmm all right thanks

timber tide
#

github desktop is trash anyway so good on you using the command line

slender nymph
#

fork is best gui

final kestrel
#

I have gitkraken just to check the stuff from time to time

slender nymph
#

oh yeah, another command you could use to discard changes is checkout

final kestrel
#

so I can stash and clear them all too?

final kestrel
slender nymph
#

stash stores the record of the changes so you can apply them back in the future, like if you needed to stash changes before pulling or something. if you just want to completely remove the changes without storing them at all use one of the other options

final kestrel
#

okay I'll use reset or checkout then

slender nymph
final kestrel
#

ahh sorry for that. I did not know where to ask

#

thanks a lot

timber tide
#

stashing has created more problems than it has helped

#

rule of thumb, just fix the merge conflict over stashing if prompted

west sonnet
#

I have a dialogue manager which is what I use for all my characters dialogues. I'm trying to figure out a way that I can trigger certain events to happen at the end of a dialogue, For example, a character walks away. I thought about creating a method in the script, but the script is used for all characters, and I wouldn't want all characters to walk away after speaking. Does anyone have any idea what the best way to do this would be?

eternal needle
#

The only part where this gets tedious is if this method will need logic passed in parameters, because your dialogue system might not have that information in the first place. In which case the component will need to get it by itself

west sonnet
#

Is it okay for me to move my scripts into different folders? I have loads and want to organise them, but i'm worried it'll affect something.

#

I'll do it within Unity too

queen adder
#

I could use some help please

#

for some reason I'm getting an error, and I'm unsure why

slender nymph
#

spelling

queen adder
#

😅

#

ty

modest dust
queen adder
#

gonna turn all my strings to const, I can't with these strings lol

west sonnet
eternal needle
eternal needle
#

It simply couldnt find it because it's not there anymore

west sonnet
timid lagoon
#

So currently I have the following func made

IEnumerator Punch()
    {
        isPunching = true;

        float initialAngle = rb.rotation;
        float punchTargetAngle = initialAngle + punchAngle;
        float punchReturnAngle = initialAngle;

        float punchTime = 0f;
        while (punchTime < punchDuration)
        {
            punchTime += Time.deltaTime;
            float angle = Mathf.LerpAngle(initialAngle, punchTargetAngle, punchTime / punchDuration);
            rb.rotation = angle;
            yield return null;
        }

        RaycastHit2D hit = Physics2D.Raycast(transform.position, mousePos - (Vector2)transform.position, 1f, treeLayerMask);
        Debug.Log("Punching...");
        if (hit.collider != null)
        {
            Debug.Log("Hit: " + hit.collider.name);
            if (hit.collider.CompareTag("Tree"))
            {
                Debug.Log("Hit Tree");
                hit.collider.GetComponent<Interact>().OnPunch();
            }
        }

        // Rotate back to the initial angle
        punchTime = 0f;
        while (punchTime < punchDuration)
        {
            punchTime += Time.deltaTime;
            float angle = Mathf.LerpAngle(punchTargetAngle, punchReturnAngle, punchTime / punchDuration);
            rb.rotation = angle;
            yield return null;
        }

        isPunching = false;
    }``` 

But what if there are 2 trees near and I am standing in the middle of it, or 2 persons. How would I do that?
#

I saw something like RaycastAll in the lib, can I use that?

topaz mortar
#

!code

eternal falconBOT
topaz mortar
#

How do I stop myself from making silly and extremely time consuming mistakes like this?
I was debugging this for hours ...

public async Task<string> EquipItem(string itemType, int itemId)
{
    // Unequip item
    if (character.EquippedItemList.ContainsKey(itemType))
    {
        // What it should have been
        int equippedItem = character.EquippedItemList[itemType];
        character = ActuallyUnequipItem(character, equippedItem, itemType);

        // What I did
        character = ActuallyUnequipItem(character, itemId, itemType);```
#

So basically I was unequipping the item I wanted to equip

#

go to youtube and type "unity jump tutorial"

timid lagoon
#

swould this work

#

yield return new WaitForSeconds(respawnTime);

#

As it doesnt continue after the respawnTime (what is 5f)

timid lagoon
#

Fixed it

#

made the dumb mistake to disable the gameobject

brittle maple
#

sorry if this is a dumb question but, Im learning to use the Unity Input System (for 3D movement), how can I make it so when im holding down a button, the speed is kept constant? Since now, whenever I press a button, it gives the player a short burst of speed instead of constantly moving.

frosty hound
#

Track it in a bool. When the button press is performed, set the bool to true and then false when it is canceled.

hollow dawn
#

I want to add a idle crouch animation and I was wondering do I have to put the same positions as normal idle?

brittle maple
eternal falconBOT
dim stream
#

this is what happens when i press W and D or W and A instead of just walk in diagonal. Anyone knows what is the problem

faint sluice
wintry quarry
#

!code

eternal falconBOT
rotund egret
#

Guys i have a building problem idk why

young warren
dim stream
#

i fixed it

languid spire
#

cannot use anything from UnityEditor namespace in a build

hollow dawn
hollow dawn
languid spire
#

Dont use UnityEditor namespace in a build

icy wedge
#

okk

rotund egret
languid spire
#

remove the using statement?

rotund egret
languid spire
#

Only GameManager is throwing an error but unless you are writing Editor scripts I'm not sure why it would be in any script

rotund egret
#

So remove unity engine?

languid spire
#

did I say that

rotund egret
languid spire
#

do you see the words UnityEditor there?

rotund egret
#

yes

languid spire
#

so why are they there?

rotund egret
#

Dont ask me ask unity it was alr there

languid spire
#

no it was not

languid spire
rotund egret
#

then pls tell me what to do

#

Im using just IEnumerator on this code

languid spire
#

and that has absolutely nothing to do with UnityEditor

rotund egret
#

This is the code inside the gamemanager

languid spire
#

notice how lines 2 and 3 are greyed out? that means they are not being used, so remove them

rotund egret
#

ok

#

Done

languid spire
#

so what other UnityEditor references do you have in your code?

rotund egret
#

Wdym

languid spire
#

well, if you have any other scripts with a UnityEditor reference in them they are going to throw errors as well

rotund egret
#

let me see

#

Found this

#

do i remove all the grey ones

languid spire
#

OMG. Do any of them say UnityEditor. I must have typed this 20 times by now

rotund egret
#

no

wintry quarry
#

Get rid of that

#

The other problem is your mouse look is probably set way too high

languid spire
rotund egret
queen adder
#

I am trying to make a game inspired by Minecraft but better, how would I make a world terrain generator?

rotund egret
#

am i suppost to remove that when i finish testing?

languid spire
#

or just comment out the line and be done

rotund egret
#

ok im just gonna remove the unityeditor . editapplication

languid spire
#

comment it out, is the simpler way

rotund egret
#

no need i just did it anyways

#

its ment to be a prototype gam

#

a prototype game

#

so i can move on to making better games

#

since im still learning

#

there is buildrd

#

ama keep that on mind when i make another game

stoic glen
#

I spawn a object from a prefab. This should on Collision change a variable on another skript. How can I create a connection from the PointSystem to the prefab. It shows this:

#

I also tried to unpack the prefab an repack it, but it can't acces the other skript

ivory bobcat
#
var instance = Instantiate(prefab);
instance.pointSystem = pointSystem;```
stoic glen
dusty ember
#

!ide

eternal falconBOT
stoic glen
rich adder
stoic glen
rich adder
grizzled zealot
#

Is AddForce for RBs calculated immediately, or after one frame? The question is when I do AddForce, does RB.velocity reflect this immediately?

swift crag
#

It's tallied up and applied in the next physics update.

#

The velocity of the rigidbody will not immediately change.

#

It also might not change by the next frame.

swift crag
thorn perch
#

I have a question in relation to documentation and how to look up things in the documentation.

I recently had a problem where i tried to update my slider max value.

and i found this: https://docs.unity3d.com/ScriptReference/UIElements.Slider.html

in here i found properties would be "highvalue" that i should be editing. but it did not work. After a lot of troubleshooting and querying chatgpt i found out that this is for UIElements.Slider meanwhile i am using UnityEngine.UI.Slider which should have used maxvalue not highvalue as property

I then queried chatgpt how i can figure this out on my own instead of reverting to chatgpt every single time and it told me to look at the namespace and then look up "UnityEngine.UI.Slider" on the website, but doing so i still cant really find what i was looking for.

Ive gotten the stuff i needed to work via chatgpt but i would like to be able to look things up myself, verify i am looking at the right thing, and if not find the right thing. But even now that i know what im looking for i still cannot find it. Any tips ?

swift crag
#

It used to be part of the core engine, but it was pulled out into a package a while ago.

thorn perch
#

oooh whatyt are the differences between these two pages ?

swift crag
#

The script reference on docs.unity3d.com covers everything that is built into the editor

#

(you will find very old UI docs on there, from back when they were built in to the editor)

#

It is a pain point, since google often winds up giving you the old doc pages on the main site

thorn perch
swift crag
#

Right: that's the manual for the slider. You will also want to see the scripting API page.

thorn perch
#

oh my even looking up things are difficult xD

swift crag
#

I'm not a huge fan of the layout for package documentation

#

it doesn't have a single list of all of the members

#

it looks like this in the old docs

thorn perch
#

yeah, i am not so much of a fan either because its extremely difficvult for newbs like me to find things and know if it is the right thing im looking for, but i really appreciate you clearing this up for me

swift crag
#

you do get this on the package page

#

it just lacks descriptions

thorn perch
#

oooof

swift crag
#

clicking on one will take you to that spot on the page though

#

Unity UI is the one thing that's really annoying to look up like that

thorn perch
#

yeah, haha thanks ima save these links for the future i think this is gonna save me a lot of trouble atleast

#

thanks man !

swift crag
#

no prob

strong wren
#

how can i fix this issue?

#

i have a code that makes the model look at the bean (player)

#

and it keeps looking above the player and once it gets super close it just looks up

#

i was thinking about making a empty gameobject and tell the code to look at that

swift crag
#

you'll have to show us what you're actually doing

#

!code

eternal falconBOT
strong wren
# swift crag !code
    public float ChildSpeed = 4;

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector3.MoveTowards(this.transform.position, PlayerBody.position, ChildSpeed * Time.deltaTime);
        transform.LookAt(PlayerBody);
    }```
swift crag
#

so, the problem is that LookAt is rotating the transform so that it's forward vector (the blue arrow when you select it) points straight at the target

strong wren
#

its a very tiny code since its also simple

swift crag
#

An empty object attached to the base of the player would fix this on flat ground.

#

But you'd have problems if the player was above or below the model

swift crag
#

it'd do the same thing: tilt forwards and backwards

strong wren
#

it didnt btw

swift crag
#

What you can do instead is something like this:

Vector3 target = PlayerBody.position;
target.y = transform.position.y;
transform.LookAt(target);
rich adder
#

var target= PlayerBody.position
target.y = transform.position.y
LookAt(target)

swift crag
#

jinx 😉

rich adder
#

oh nvm 🦥

strong wren
#

far and close

swift crag
#

This ensures that the enemy always looks at a position on its own Y level

strong wren
#

should i switch the target to the name of the transform? like i want it to look at the Transform of PlayerBody should i switch target to player body?

#

oh no

#

the target is the playerbody

rich adder
swift crag
strong wren
#

yep i jsut read the code

swift crag
#

I just used a different name there

#

(the variable name doesn't matter at all!)

#

you could call it florp and it'd still work

strong wren
#

alr now it just jumps i think if i freeze the Y movement of it it should fix it

#

oh no nvm

#

the collider is aliltle in the ground

#

so it gives the ilusion of jumping

#

is there to make it so it also doesnt want to go to the y level of the player

#

i think its cause its also going to the y level

#

so if i somehow tell it to only go to the Z and X then it shouldnt fly should it?

swift crag
#

Right, and you'd do that in the same way

swift crag
#

Ideally, the player's root should be positioned at the player's feet

#

with the capsule body and camera parented to that root object

viscid kayak
#

how do I combine meshes on unity?

swift crag
#

the model would never be able to move up or down

swift crag
#

note that this isn't a code problem

viscid kayak
viscid kayak
#

that used code

#

to fix this

swift crag
#

okay, and what tutorial is this?

viscid kayak
swift crag
#

that's what i'm asking for (:

velvet turret
#

I just wanted ads in my game.

swift crag
#

you have a giant pile of syntax errors

#

your code editor should be highlighting all of them for you

languid spire
rich adder
#

make sure that IDE is indeed configured

velvet turret
#

!code

eternal falconBOT
viscid kayak
swift crag
#

okay, that is indeed combining multiple meshes together via code

#

What are you trying to accomplish here, though?

velvet turret
swift crag
#

not "combine meshes"; that's the attempted solution to your problem

viscid kayak
swift crag
#

storage space?

#

completely irrelevant

#

you have the same amount of mesh data no matter how you mash them together

#

(and Unity will already do this for you with static batching!)

#

Focus on making a game, not on trying to micro-optimize it

languid spire
viscid kayak
viscid kayak
swift crag
#

combining meshes will do nothing to your triangle count

velvet turret
swift crag
#

also, combining meshes with blendshape data sounds miserable

velvet turret
swift crag
#

If you want to merge meshes together, do it in Blender.

#

That will be much simpler than trying to script it in Unity.

languid spire
viscid kayak
swift crag
#

perhaps ask about this on !vrchat

eternal falconBOT
viscid kayak
swift crag
#

are you actually concerned about file size, though?

#

perhaps you're talking about vertex count, or material count, or something else?

#

file size is certainly nice to keep low, but it's not what you're usually trying to cut down

eternal needle
languid spire
velvet turret
thin grotto
#

What's some useful books you lot would recommend for someone who's only got a bit of experience with Unity and C#? I feel books force me to learn compared to video tutorials . Also I've a cs degree but can't code to save my life so want to start over learning from scratch 🙃

languid spire
languid spire
velvet turret
#

It wanted this right?

thin grotto
rich adder
languid spire
#

I knew Uni's had dumbed down a lot since my day but that much is bloody frightening

rich adder
#

they lower standards, more students pass, school looks good. IQ of the country slips another few points

thin grotto
#

There's a reason why I work as an IT tech and not a software engineer haha

frank zodiac
#

it doesnt even debug anything to the console

languid spire
frank zodiac
#

nothing happened

languid spire
#

Also if it hits nothing that code will throw a Null Ref exception

frank zodiac
#

it didnt throw anything

languid spire
#

is it even running?

frank zodiac
#

yes 😭

languid spire
#

prove it

frank zodiac
#

i ran Debug.Log(raycastHit.collider.name);