#💻┃code-beginner

1 messages · Page 478 of 1

frank flare
#

but the thing is that if you're making an online game you still need some community so like, the first game you're gonna make would be a game to get community for the 2nd game

daring depot
#

and yes, I can work in vscode on roblox games

frank flare
daring depot
#

my first 50 games are going to be fucking awful

#

especially since I haven't used C# or unity before

frank flare
short hazel
#

Never start with a multiplayer game, it adds a whole lot of complexity. Some engines provide automatic object synchronization, in Unity you have to set that up yourself. Some scripts are pre-made for that, but you'll have to roll your own code to synchronize data for your own scripts

daring depot
#

1 man isn't making such a multiplayer game anyway

#

but with Roblox it's a platform meaning roblox gives you all the users

#

but with this, it's like we have to make our own platform

silent valley
topaz flax
#

o/

wondering if there are any tutorials for instead of sprite flipping when going in that direction but the sprite faces a targe only on the x axis? wanting to make a 2d combat game but I can't really find any tutorials for this mechanic (they do it in like streetfighter and MK)

daring depot
polar acorn
daring depot
#

I made roblox say $1650 in robux; they return me back 24.5% of it

#

or something stupid like that

#

they act as if they're the government with the taxes

short hazel
#

Well yeah, the servers aren't gonna pay themselves, so they take their cut

eternal needle
topaz flax
#

so would it be like a raycast?

#

Planning on making it like for honor where you can lock onto and off of your opponent and do certain inputs but its linear 2d like a traditional fighting game

eternal needle
topaz flax
#

right okay so

#

my player looks to the right by default

#

want to make it so that if it crosses either another player, or whatever its locked onto, it flips so that its still facing that player/ object

eternal needle
#

If you want it to lock onto the nearest character for example, you could just do a physics query every so often like a overlap box (or whatever the 2d equivalent is) and check what's nearest

topaz flax
#

hm okay

#

I'm not really 100% sure how i'd go about that tbh, never dealt with anything like that since i've been stuck in tutorial hell for years

eternal needle
topaz flax
#

I'll try to experiment with it though

thorny basalt
#

That is how I do it in my fg

topaz flax
#

OOoooo

#

oh honestly thats so much easier than I thought holy moly

#

thanks so much lmao

thorny basalt
#

And you can set scale.x to that variable, and use it in math

topaz flax
#

Ahh gotcha okay

#

tysm

thorny basalt
topaz flax
#

okay!!! really appreciate it! going to probs be working on the sprites for a while because i'll be able to base hitboxing and timing easier once I get that down but I'll defo let you know!

thorny basalt
#

Gotcha

eternal needle
thorny basalt
glad wagon
#

https://gdl.space/ehetovidoc.cs I have this monster code that is taking care of the player movement, knife system and gun system....I'm having a really hard time trying to separate in smaller scripts

#

it is interacting with another code for a inventory manager

#

but everytime i try to separate in other scripts the equipgun stops working

teal viper
glad wagon
teal viper
#

Well, then debug it.

static wasp
west obsidian
#

Does collider.ClosestPoint check only the surface or also the volume of a collider?

static wasp
#

are you talking to me?

west obsidian
#

no

steep rose
#

not sure why you are changing gravity

#

since it would create this issue

static wasp
steep rose
#

stop messing with gravity via script since you are using a RB, instead use the actual project setting gravity

#

or

#

change RB gravity on the RB itself

#

like only once

static wasp
#

ok, lemme try that rq

steep rose
#

what did you do

static wasp
#

i turned all the gravity switching things in the script to comments

#

and i changed the value on gravity on the rigidbody

#

(in inspector)

#

and it's still random

steep rose
#

also this doesnt make sense

                if (rb1.velocity.y > 0)
                {
                    if (rb1.velocity.y < 12.5f)
                    {
                        rb1.velocity = new Vector2(rb1.velocity.x, rb1.velocity.y * 1.025f);
                        print(rb1.velocity.y);
                    }
                    else
                    {
                        rb1.gravityScale = 10;
                        gravity = 10;
                    }
                } 

you are checking if the RB Y velocity is more than zero but also checking in there if it is less than 12.5f so this code is useless

#

also you have a lot of nesting

static wasp
#

when the velocity is more than 12.5, i want it to stop going up

steep rose
#

you are using a less than sign

#

not more than

#

so that code will not do anything

#

like ever

#

its contradicting itself

static wasp
#

because it goes up when the velocity is less than 12.5, but it stops when it's more than 12.5

steep rose
#

no you are not understanding, this code will never run

                    if (rb1.velocity.y < 12.5f)
                    {
                        rb1.velocity = new Vector2(rb1.velocity.x, rb1.velocity.y * 1.025f);
                        print(rb1.velocity.y);
                    }

because of the fact that you are checking if the velocity is more than zero, if its more than zero it will never be less than 12.5f, so it will never run

static wasp
#

i basically want my jump like hollow knight, where it goes up higher if you hold it for a longer time, but not infinitely

steep rose
#

also best look up a tutorial for something like this

static wasp
static wasp
steep rose
#

ah a mistake on my part, my bad.
still you might want to fix the nesting

steep rose
#

i just saw like seven tutorials

static wasp
#

wait lemme send a video of what i'm talking about

#

my internet is so slow

#

it's sending

steep rose
#

its the exact same thing

static wasp
#

not really, but lemme watch one rq

steep rose
#

im pretty sure hollow knight got inspiration from mario for this type of jumping movement

static wasp
#

it jumps 3-7 meters up

#

when i fully hold it down

static wasp
#

opens playtest: doesn't work
re-opens playtest: works
re-opens playtest: doesn't work
i love unity

teal viper
#

Conditional bugs are very common and unrelated to unity.

static wasp
teal viper
static wasp
teal viper
#

Figure out the condition and the cause.

static wasp
#

also, i'm repeating the same button over and over

#

so i don't think so

obsidian furnace
#

If I'm interested in making a game with Unity, what should I do to start?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

obsidian furnace
#

Thanks!

teal viper
# static wasp so i don't think so

In a game engine there are a lot of conditions. Some you don't even see or know about. Timing is one condition that often causes bugs hard to reproduce.

static wasp
#

it isn't a one-off thing

cosmic dagger
# obsidian furnace Thanks!

also, start with C# tutorials to learn the basics of programming. either from blogs, websites, or videos . . .

teal viper
static wasp
#

maybe fps has something to do with it

teal viper
#

For example 2 timings or more might need to meet for the bug to occur.

static wasp
#

because i'm using delta time

teal viper
#

Yeah, frame rate is another possible condition.

static wasp
#

but i don't think frame rate would cause a 30% increase

teal viper
teal viper
static wasp
teal viper
#

It means that even one small change in value could lead to a tremendous change in a complex system.

cosmic dagger
#

like a butterfly. stay away from those . . . 🦋

static wasp
#

might just leave it like this

#

bc idk how to fix it

teal viper
# static wasp bc idk how to fix it

Debug it... It's a good opportunity to learn how to solve issues. Skip it now and you're gonna keep on facing issues that you don't know how to solve

static wasp
#

i'm feeling kinda burnt out, so maybe later

obsidian furnace
cosmic dagger
obsidian furnace
#

👌, thanks

eternal needle
obsidian furnace
sullen perch
#

I have this gun script but whenever i shoot the bullet dosent go forward

#

somewone please help me with this

ivory bobcat
sullen perch
#

im realy new, how do i fix it?

ivory bobcat
#

Show the !code that moves the bullet

eternal falconBOT
sullen perch
#

idk how to use this?

ivory bobcat
#

Show an image of the spawn bullet object.

#

Specifically we're interested in the inspector.

sullen perch
#

wdum?

ivory bobcat
#

I can't help you if you don't know what an inspector is.

sullen perch
#

that?

ivory bobcat
#

So nothing moves the bulllet.

sullen perch
#

oh

ivory bobcat
sullen perch
ivory bobcat
# sullen perch

Show the bullet script using the below guidelines - paste all of the code in one of those links and press the save button on the site then copy and paste the url here.

#

How to post !code

eternal falconBOT
sullen perch
ivory bobcat
#

Does the spawned bullet move at all?

sullen perch
#

i would hope so but i guess not

teal viper
sullen perch
#

i did but i guess i was just being stupid

teal viper
sullen perch
#

i have this bit of code but idk how to add it to the other one

teal viper
sullen perch
#

ok mb

teal viper
ivory bobcat
#

I'm guessing a duplicate script.

sullen perch
#

I dont think it is red i was just playing around with some settings

teal viper
teal viper
sullen perch
#

sorry sent wrong screenshot

teal viper
#

Take a screenshot of the gun object with this script

sullen perch
teal viper
sullen perch
#

wdum?

teal viper
#

What's the difference between Gun and IDKGun?

sullen perch
#

idkgun shoots the bullet and the normal one adds a firerate so u cant spam shoot

teal viper
#

That doesn't make sense. Why split it into 2 components? Also why does the normal gun references the bullet prefab then?

#

Also, does the bullet spawn point need to be assigned or not?

sullen perch
#

im realy new to unity and dont know how to merge the two scripts.

deft grail
sullen perch
#

then will it work?

deft grail
sullen perch
#

ok

teal viper
sullen perch
#

i did

teal viper
sullen perch
#

mb

#

iwas just trying to send you all the screenshots fast enoth

quiet cipher
#

Hello friends, I wrote this code in Unity. The code is not visible in the onclick of the button.

#

just have a monoscripts

queen adder
#

you need to make an instance of that mainmenu script

north kiln
#

Ah, I see you cross-posted. Please don't do that.

languid spire
spark ember
#

been working in unity for years and never had this issue, when I have a gameobject attatched to my player and look up and down it warps

#

anyone able to help me?

languid spire
#

probably you have uneven scaling somewhere in your gameobject hierarchy

spark ember
#

ahh yeah wasnt looking at the actual player

#

thank you

raw robin
#

Hi all, this thing pops up whenever I update my script that I created (not from any package etc), not sure why that's the case. Anyone has any idea?

languid spire
raw robin
#

The script it's referring to is a script I created myself, and I don't believe it's calling any API "that has changed", thus why Im asking

#

the message also doesn't give much info as I pressed "update any that's found later" and it still shows up after. Thus why Im asking

languid spire
#

in that case make a copy of the script outside of Unity, let Unity update it then compare the two

daring depot
#

where should i be putting my scripts

teal viper
#

In the bank

#

Wdym "where should I put them"??

daring depot
daring depot
teal viper
daring depot
#

why are you being rude?

#

if you don't want to help then don't, and if you are why are you being rude

teal viper
#

Because you clearly didn't do any learning. Start with the beginner pathways on unity !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

teal viper
#

Or read the manual.

teal viper
#

First learn/make effort, then come with the remaining questions.

daring depot
#

i am making an effort

#

that's why i'm here

#

what if I did read the manual?

teal viper
#

Then you wouldn't make that question

#

If you mean something specific, then clarify, because just "where to put scripts" doesn't make any sense.

daring depot
#

where does it tell me where scripts go in the manual

teal viper
#

Define what you mean by putting scripts first?

daring depot
#

can I make any other service folders except packages and assets

#

this is what i have

teal viper
daring depot
teal viper
#

That doesn't explain anything.

daring depot
teal viper
#

What about them?

daring depot
#

yeah that's where they will go

teal viper
#

Great. Does that answer your question?

daring depot
#

yes

teal viper
#

If you're asking where in the assets folder to put your scripts, then you're free to put them wherever you want.

daring depot
#

and we can't segregate certain items into folders inside of sample scene

teal viper
#

I'm not sure what you mean by that? You can create whatever folders you want.

daring depot
#

in here

teal viper
# daring depot

This is a scene hierarchy. It contains gameObjects. Has nothing to do with files in the assets

daring depot
#

Okay

#

so we can use game objets as folders

teal viper
#

You can use empty gameObjects for nesting and grouping other gameObjects. That's not the same as folders though.

daring depot
#

okay nice

long jacinth
#
private void OnCollisionEnter(Collision other) {
        if(other.gameObject.tag == "Player")
        {
            Debug.LogWarning("Hit Player");
        }
    }```
#

idk why this isnt working

#

btw the object in this script is a trigger

#

do i need a rigid body?

stiff birch
long jacinth
stiff birch
#

I guess the player in this situation

long jacinth
hushed mural
#

is there a possiblity i can import an already existing code or project into unity?

languid spire
stiff birch
# long jacinth still doesnt work

Quick check list :

  • Does your player have both a collider and rigidbody ?
  • Does your player have the tag "Player"
  • Does your trap have a collider ?
  • Is your script attached to your trap ?
long jacinth
#

my player also has a character controller

stiff birch
stiff birch
long jacinth
stiff birch
#

As long as the collider on your player has its IsTrigger property set to false, it should be fine.

hushed mural
languid spire
hushed mural
#

i am sorry i mean like i see people have moons already in their unity notlikethis

#

is it possible to import the same thur a code or some way?

languid spire
#

you still have not have answered the question

hushed mural
#

this for example^

#

is it possible to import the same into my unity?

languid spire
#

that is a unity script

hushed mural
#

okay

#

so how do i import it into mine?

languid spire
#

copy/paste

hushed mural
strong wren
#

Generally things are just files in your project folder, so simply dragging and dropping generally works

stiff birch
languid spire
#

into the assets folder of your project

hushed mural
#

i am completely new notlikethis

languid spire
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

stiff birch
#

You'll go nowhere if you don't know how to use your tool so follow these guidelines ^^'

hushed mural
#

Oh okay

#

thank u so much again !

#

@languid spire thank you

#

+rep

#

@stiff birch is there a possiblity, u could teach me some aspects?

stiff birch
hushed mural
#

its alr thanks anyways

stiff birch
daring depot
#

How does the relationship between server adn client work?

#

I'm so confused

teal viper
daring depot
#

so I have my folders

#

but each script seems to be the same

#

like I'm so used to scripts having different functions, server, client and modules

hexed terrace
#

Why did you make them the same?

daring depot
#

I didn't

#

ah

#

so monobehaviour is server

languid spire
daring depot
#

yeah so

#

we have a client

#

which has their own set of controllers and client scripts

#

then we have our middleman which handles data being sent to the server and from the server to the client

#

and then the server scripts

#

but how can I replicate this in unity

#

in my old game engine we had different scripts for the server and client

#

so I understand now

#

bydefault unity games are singleplayer, if we want a networking structure, server and clients we have to write it ourselves

languid spire
daring depot
#

well it's probably better to make our own right, so it's relative to our game

languid spire
#

if you have the knowledge and experience, yes

daring depot
#

Yes

#

I'll take a look at Netcode

buoyant tundra
#

is anyone able to help me and my friend with our code it isnt working and we cant figure out why we have been at it for 3 hours thanks!

#

@languid spire are you able to helop

cosmic dagger
buoyant tundra
#

sorry

cosmic dagger
languid spire
# buoyant tundra

why do I see absolutely no evidence of debugging in that code. Also !code

eternal falconBOT
buoyant tundra
#

we have started from scratch and tried to debug different ones

languid spire
buoyant tundra
#

we have been on different scripts

#

this is a new one

languid spire
#

irrelevant

buoyant tundra
#

what

#

bro i need help either help or dont

#

im new to unity programming

languid spire
#

if the script is not doing what you expect. you put debugs in there to see what it is doing. This you have not done

buoyant tundra
#

whart

#

that makes no sense to me

neon spire
#

It is better to change a value in Unity or in the code ?
For exemple the Jump height in a platformer, should i write ```cs
public float jumpHeight;

Or
```cs
public float jumpHeight = 233f;
languid spire
#

In Unity, once a value has been serialized changing the code will not cange the value

neon spire
languid spire
neon spire
#

oh okay

#

Thanks 👍🏻

languid spire
burnt vapor
# buoyant tundra your no help thanks mate

They are, and if you don't know what they mean then ask for more information rather than repeating yourself.
Debugging is a very basic skill that you can start off with and it is incredibly helpful.

buoyant tundra
#

fixed myself dont @ me again

burnt vapor
full kite
#

I dont know if I can write this type of question here but yeah. When I write something in an inputfield and then delete even a single letter, the text shifts all the way to the left. Does somebody know why?

burnt vapor
#

Maybe you have a video?

buoyant tundra
full kite
#

I do, one second

burnt vapor
full kite
burnt vapor
eternal falconBOT
burnt vapor
full kite
#

can you describe where to look ab this padding?

full kite
#

resolved it

graceful fractal
#

Greetings, would anyone be able to help me set up a basic AR system?

This is my first time working with AR, I've been trying to get something to work for weeks but I've had no success. No tutorial or forum I've followed has been of any help.

I would please just like help to come to understand how to work with it, and how to set up this system.

The system needs to do the following:

  • It should be able to be turned off and on.
  • Using the Mobile Phone's Camera, and it should look for a picture, and then project a 3D model onto where the picture is.

Please, any help would be greatly appreciated.

long jacinth
#
        if(other.gameObject.tag == "Player")
        {   
            if(TrapSpikeUp.SpikeUp == true)
            {   
                other.GetComponent<Health>().CurrentHealth -= PlayerDamage;
                Debug.Log("Hit Player");
            }
        }
    }```
#

this is a spiketrap script is there a way so that it doesnt deal damage every millisecond when i stay in the trap

#

and instead it has a cooldown

ivory bobcat
#

Have an invulnerability timer in the health script

#

Ideally, you'd evaluate it in your current health property

wintry quarry
#

Or just set a bool and use FixedUpdate

tight fossil
#

What happens to a coroutine if the gameobject its attached to is destroyed? Does it stop midroutine or finish its iteration?

tight fossil
#

h*ck

#

is there a way to make it finish?

ivory bobcat
#

Or delay 0.01 seconds or something

#

Destroy(gameObject, 0.01f);

tight fossil
#

what if there were a couple of WaitForSeconds in there though :x

ivory bobcat
#

Where you'd have a reference to the other coroutines and would flag their loop false with a variable when wanting to terminate them by natural/normal means.

stiff birch
# long jacinth ``` private void OnTriggerStay(Collider other) { if(other.gameObject.tag...

Multiple solutions possible :

  • coroutine that start when entering a trigger and stop when exiting a trigger as PraetorBlue said
  • a member variable to handle the delay with Time.time and a simple comparison like below
private float nextDamageTriggerTime;
private float damageTriggerDelayInSeconds = 1f;

private void OnTriggerEnter(Collider other)
{
  // Do stuff

  nextDamageTriggerTime = 0;
}
private void OnTriggerStay(Collider other) {
    if(other.gameObject.tag == "Player")
    {   
        if(TrapSpikeUp.SpikeUp == true && Time.time >= nextDamageTriggerTime)
        {   
            other.GetComponent<Health>().CurrentHealth -= PlayerDamage;
            Debug.Log("Hit Player");
            nextDamageTriggerTime = Time.time + damageTriggerDelayInSeconds;
        }
    }
}
woven crater
#

what is the different between unityengine.random and system.random?

wintry quarry
#

Have you checked their docs pages to see?

#

The most significant difference is System.Random expects you to make an instance of it, and UnityEngine.Random operates entirely with static methods.

woven crater
#

oof readding the docs now thank you

long jacinth
#

i trieda countdown and it didnt work

wintry quarry
#
                TimeToSpike = 0f;
                DamagePlayer();

    private void DamagePlayer()
    {   
        TimeToSpike -= Time.time;
        if(TimeToSpike == 0)
        {   ```
#

By the time you do cs if(TimeToSpike == 0) It is ALWAYS going be equal to - Time.time

#

which btw you probably meant to use Time.deltaTime, but even that doesn't make any sense here

#

you're:

  • Setting TimeToSpike = 0
  • subtracting Time.time (or deltaTime)
  • Then checking if it's 0???
#

Think about your code for a minute

#

it will not work

#
x = 0;
x -= 5;
if (x == 0)```

Will this ever work??
#

Thnk about it

#

that's what you're doing

atomic holly
#

Hello,
Is it interesting to use namespace in Unity or not ?

languid spire
#

interesting?

wintry quarry
atomic holly
# languid spire interesting?

I follow a course of C# and found namespaces. When I see it, I don't see the utility in Unity but I ask if it interesting to use it in some specific situations

frosty hound
#

Interesting is completely irrelevant. You don't do certain coding practices because it's "interesting".

#

Are they useful? Yes, they can be. Are the necessary? Not always, no.

languid spire
cosmic dagger
#

Namespaces are not necessary for most people because they are not working on large systems where some organization is required or to prevent naming conflicts, but I recommend using a namespace for your scripts . . .

stiff birch
#

Even without large scale project, if you want to have reusable code across your projects with name that can be, well, common, I find it useful to isolate your code in namespaces to prevent conflict.

celest holly
#

!help

#
{
    private float lastTimeFired;
    public float chargeTime, maxDistance;
    private Camera cam;

    private void Start()
    {
        cam = Camera.main;
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && CanFire(lastTimeFired, cooldown))
        {
            StartCoroutine(FireDelay());
            lastTimeFired = Time.time;
        }
    }

    public override void Shoot()
    {
        RaycastHit hit;
        Vector3 dir = (MousePos - transform.position);   
        Ray ray = new Ray(transform.position, dir);
        Physics.Raycast(ray, out hit, maxDistance);
        Debug.DrawRay(transform.position, dir, Color.red, 50);
        print(hit.collider.gameObject);

        lastTimeFired = Time.time;
    }

    private IEnumerator FireDelay()
    {
        yield return new WaitForSeconds(chargeTime);
        Shoot();
    }
}

This direction just goes wherever it feels and i have 0 clue why

#
{
    get
    {
        Vector3 mousePosition = Input.mousePosition + new Vector3(0, 0, -1);
        Vector3 position = Camera.main.ScreenToWorldPoint(mousePosition);
        return position;
    }
}```
thats the code for the mouse position
#

and my camera is in orthographic

stuck palm
#

why is Inputs not recognised in here, but it is in a different script?

#

Inputs is an auto generated class

#

from the new input system

celest holly
#

did u put using unity.inputsystem or whatever

polar acorn
verbal dome
#

@celest holly With ScreenToWorldPoint the Z value is at your camera's position (or its near clip plane)

celest holly
#

ohhh my god of course

stuck palm
polar acorn
#

You might also have assembly definitions excluding the namespace Inputs is in from this script's assembly

celest holly
#

still coming from the sky

stuck palm
polar acorn
verbal dome
#

Are you using 3D colliders and rigidodies by the way? Your game logic seems 2D but you are using Physics and not Physics2D

celest holly
#

they go upwards

#

yeah im using 3d colliders

#

is that problematic

verbal dome
#

Oh. Your world is in the XZ plane, not XY plane

#

I assumed it was side-view because of your code

stuck palm
#

the thing on the bottom left

celest holly
#

oh so its y that needs to be 0 and not z?

rich adder
#

thats an asmdef

stuck palm
#

this is whats inside it

celest holly
#

thank you osmal ive fixed it now

verbal dome
#

Make sure to check the bool that Physics.Raycast returns, though

celest holly
#

oh okay

#
{
    get
    {
        Vector3 mousePosition = Input.mousePosition + new Vector3(0, 0, -1);
        Vector3 position = Camera.main.ScreenToWorldPoint(mousePosition);
        Vector3 finalPos = new Vector3(position.x, transform.position.y, position.z);
        return finalPos;
    }
}``` this seems to be working for it though
#

is it neccessary to rewrite it?

verbal dome
#

If that's how your camera is then yeah sure

celest holly
#

yeah my cameras always facing down

verbal dome
#

Is it orthographic or perspective?

celest holly
#

orthographic

#

i heard perspective just creates problems

verbal dome
#

Alright then it should be fine

celest holly
#

okay thanks for the help

celest holly
#

ill look into it

#

thanks

fading mountain
#

Hey guys. I'm just working on a flappy bird clone project, right now I'm having an issue in my pipe spawner script (The object of type 'Transform' has been destroyed but you are still trying to access it. Line 78). I think what's happening is the ManagePipes() function is deleting pipes as they go off the screen and for some reason MovePipes() is still trying to move them. https://hatebin.com/dldhnwwofu

rich adder
#

one of the pipe in currentPipes was destroyed yet you're trying to access its trasnfrom, since its still in the array/List

fading mountain
#

but managePipes() is called after movepipes()

#

so wouldnt the list be updated by then

#

by the next frame

rich adder
#

assuming you're cleaning the correct objects in the list

wintry quarry
#

after you delete the last pipe in the list, the last one will again be at currentPipes.Count - 1

#

if you want to delete the last two pipes you would do

currentPipes.RemoveAt(currentPipes.Count - 1);
currentPipes.RemoveAt(currentPipes.Count - 1);```
#

because removing one changes the count

fading mountain
#

ohh that makes sense let me try it

wintry quarry
#

that will likely be the most efficient way.

fading mountain
#

it worked thank you

#

let me look st that

fading mountain
#

I get the same error as before

#

oh wait nvm

#

yes that does work and is a better way to do it thanks 👍

full kite
#

!code

eternal falconBOT
full kite
#
using UnityEngine

public class Exemple : MonoBehaviour
{
    public bool Something = false;
     
    void Update()
    {
       Debug.Log(Something);
    }
}```

why by having these code, I got in the console, true?
#

and only by adding the start function and set the bool value to false it goes to false?

polar acorn
full kite
#

oh damn, it was filled with the checkmark

#

thank you

polar acorn
#

The inspector takes precedence over the default values in code. This is so you can change the value on specific instances

full kite
#

aha, got it

#

thank you

bold swallow
#

Is there a way to write this more cleanly?

public void GetDataFromStage(GameObject stageButton)
    {
        StartPlanetInt = stageButton.GetComponent<StageButtonData>().StartPlanetInt;
        FinalPlanetInt = stageButton.GetComponent<StageButtonData>().FinalPlanetInt;
        hasComets = stageButton.GetComponent<StageButtonData>().hasComets;


        
    }

something like this for example:

public void GetDataFromStage(GameObject stageButton)
    {
        Something data = stageButton.GetComponent<StageButtonData>();

        StartPlanetInt = data.StartPlanetInt;
        FinalPlanetInt = data.FinalPlanetInt;
        hasComets = data.hasComets;
    }
cosmic dagger
languid spire
cosmic dagger
#

then you can access the data from the component. there is never a reason to use a GameObject type . . .

languid spire
cosmic dagger
#

but at that point, if you already have a component, you can just do component.gameObject.blah . . .

languid spire
#

But if you have an empty GO? I suppose you could use Transform instead

bold swallow
#

Ohhhh

#

I didn't know I could do that

cosmic dagger
#
public void GetDataFromStage(StageButtonData stageData) {
    StartPlanetInt = stageData.StartPlanetInt;
}```
cosmic dagger
bold swallow
ember tangle
#

I'm having a hard time accessing the TileBase from a TilePalette to build a tilemap with script using Tilemap.SetTile(). The documentation in unusually terrible for Unity for this system. Anyone have any good links or advise?

rich adder
cosmic dagger
bold swallow
#

I came looking for copper, but found gold

#

Thanks a lot!

radiant meteor
#

so i'm trying to rotate a gameobject 5 times, with a little gap in time between all of these times, for a full 360. The way i'm doing this is using a while loop in a coroutine that will stop once the object's y rotation reaches the target, and inside the while loop there's a smoothdamp for the objects transform.rotation, thing is, it keeps freezing the project once it runs the coroutine, i dont think its an infinite loop so what is it? (my code is in another language, hold in while i get it here in english)

#
{
    observing = true;

    for (int i = 0; i < 5; i++)
    {
        float targetRotation = transform.rotation.y + 72;
        velocity = 0;

        while (transform.rotation.y != targetRotation)
        {
            transform.rotation = new(transform.rotation.x, Mathf.SmoothDamp(transform.rotation.y, targetRotation, ref velocity, 0.5f, 10, Time.deltaTime), transform.rotation.z, transform.rotation.w);
        }
        yield return new WaitForSeconds(0.75f);
    }

    if (!targetFound) { yield return new WaitForSeconds(2f); }
    observing = false;
}```
polar acorn
#

Well, that while loop's gonna run to completion instantly, and if it happens to not be able to reach targetRotation, it'll never stop

#

Also, what are you hoping to achieve by manipulating a quaternion directly like that?

#

That's gonna produce a really weird orientation

radiant meteor
#

i've thought that maybe it wouldnt get to the exact value of targetRotation so i put an if statement so if rotation gets less than 0.1f and more than -0.1f from the targetRotation it would set it to the targetRotation, but it didnt work

radiant meteor
polar acorn
#

.rotation is a Quaternion, a normalized 4D vector. Human minds were not meant to manipulate those numbers directly

radiant meteor
#

so, do transform.Rotate and move it to work in Update only if (for example) a bool is activated in the coroutine?

polar acorn
#

Or change the euler angles in the coroutine instead of rotation

faint agate
#

This isnt a coding question, but I added volume n bloom so an gameobject can glow, but its applying to the skybox sun too. How would I go about removing bloom from skybox and only have the gameobject glow. The 2 camera method didnt work

#

im using urp

#

I can upload a photo if needed

steep rose
#

if its not a coding question why did you post it here?

long jacinth
wintry quarry
#

You should make it reset when you first touch the spike, right?

#

That's what OnTriggerEnter is for

long jacinth
#

oh

#

thanks

queen adder
#

hey um im kinda dumb why isnt this working?

languid spire
#

because you dont have a class called LogicScript

queen adder
#

oops

#

i am really stupid sorry for wasting your time lol

marble bison
#

Does anyone have any meta development experience?
I need help getting contents of a assets folder dir, and writing storage to the SD/game dir

languid spire
marble bison
#

I'm about to send script

#
using System.IO;
using UnityEngine;
using CraftSharp.UI;

public class QuestAppdataSpoof : MonoBehaviour
{
    public LoginControl client;

    void Start()
    {
        if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.ExternalStorageWrite))
        {
            UnityEngine.Android.Permission.RequestUserPermission(UnityEngine.Android.Permission.ExternalStorageWrite);
        }

        CopyMineproxyFiles();
    }

    void CopyMineproxyFiles()
    {
        string sourcePath = Path.Combine(Application.dataPath, "Dependencies/Mineproxy");
        string destinationPath = Application.persistentDataPath;

        CopyDirectoryContents(sourcePath, destinationPath);
        TryConnectToServer();
    }

    void CopyDirectoryContents(string sourceDir, string destinationDir)
    {
        DirectoryInfo dir = new DirectoryInfo(sourceDir);

        if (!dir.Exists)
        {
            Debug.LogError($"client dir does not exist: {sourceDir}");
            return;
        }

        FileInfo[] files = dir.GetFiles();
        foreach (FileInfo file in files)
        {
            string targetFilePath = Path.Combine(destinationDir, file.Name);
            file.CopyTo(targetFilePath, true);
            Debug.Log($"loaded file: {file.FullName} to {targetFilePath}");
        }
        DirectoryInfo[] dirs = dir.GetDirectories();
        foreach (DirectoryInfo subDir in dirs)
        {
            string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
            if (!Directory.Exists(newDestinationDir))
            {
                Directory.CreateDirectory(newDestinationDir);
            }
            CopyDirectoryContents(subDir.FullName, newDestinationDir);
        }
    }

    void TryConnectToServer()
    {
        client.TryConnectServer();
    }
}

If anyone can help, this would be greatly appreciated; I've looked online for a solution already with none found.

wintry quarry
wintry quarry
#

That doesn't explain what the issue is

#

It just says you need help

slender nymph
#

assets folder dir
are you referring to the Assets folder within your project? because that does not exist in a build

marble bison
#

Is there any solution to this without downloading files from a server?

polar acorn
slender nymph
polar acorn
#

What is the purpose of trying to read data from assets

wintry quarry
marble bison
# polar acorn What problem are you trying to solve
  • ' getting contents of a assets folder dir, and writing storage to the SD/game dir' I don't know if I simplified this enough.

Importing everything in one directory
(assets/dependencies/mineproxy)
To
(sdcard/Android/data/com.Exotic.Mineproxy/files)

#

I have write permissions set up correctly, and only just the base folder seems to be going over.

slender nymph
#

for what purpose

marble bison
#

I've explained enough

queen adder
#

any advice on learning c#?

polar acorn
#

so there is no folder to read the contents of

languid spire
#

pretty simple really this

string sourcePath = Path.Combine(Application.dataPath, "Dependencies/Mineproxy");

should be using streamingAssetsPath but... Because this is an Android build you need UnityWebRequest to read it

slender nymph
marble bison
slender nymph
polar acorn
#

You've asked a solution, not a problem

marble bison
#

Dawg idk how to dumb it down enough for yall 💀

polar acorn
#

The solution you're asking about is non-viable. We cannot provide alternatives because we don't know what the problem is

marble bison
#

Yo chatgpt is actually more reliable even when it comes up with shit ong

#

server is garbage

vocal wharf
#

So I'm making an ultra simple 3d car controller script. I have the simple movement and turning working but I want to make so that the vehicle turns the opposite way when reversing (like a real car does) instead of still rotating the same direction, if you can understand my poor explanation. I tried to do this by multiplying by turnSpeed variable by -1 when the forward velocity is negative and resetting the variable when the speed is 0 or greater by multiplying by Math.Abs but this made the turning quit working completely. Can someone here please show me a solution to this? Also if there is a good way to get rid of the if statements in my code I would appreciate those tips as well!

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody rb;
    public float speed = 1f;
    public float turnSpeed = 1f;
    bool canTurn;
    void Update()
    {
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        rb.velocity = transform.TransformDirection(0, rb.velocity.y, vertical * speed);
        if (rb.velocity.z != 0)
        {
            canTurn = true;
        }
        else
        {
            canTurn = false;
        }
        if (canTurn == true)
        {
            transform.Rotate(Vector3.up * horizontal * turnSpeed * Time.deltaTime);
        }
    }
}```
shell yew
#

people won’t want to help you if you’re just being an arse

polar acorn
languid spire
#

You can stop this conversation, I've given him the answer to the question he has yet to ask

slender nymph
# marble bison server is garbage

have you considered that it is actually your attitude and lack of explanations of what you actually want to achieve with this that is garbage?

polar acorn
#

But every now and then, someone doesn't. Then they post here

polar acorn
#

Shouldn't need to invert it at all

vocal wharf
queen adder
#

probably another stupid mistake but i cant figure it out

polar acorn
queen adder
languid spire
queen adder
#

figured it out

#

thanks

#

im gonna make a list of reminders lol

marble bison
# steep rose best of luck with that

Yeah It's alright I literally just put it in the recourses folder
the only thing close to helpful anyone came here was reminding me that the assets don't build when compiling.

polar acorn
marble bison
#

So thanks for whoever said that

hoary heron
#

how do i make a teleporter script for my fps game?

steep rose
eternal falconBOT
polar acorn
#

And if you had said what you were trying to reference from disk, we might have suggested Resources

languid spire
vocal wharf
polar acorn
vocal wharf
polar acorn
vocal wharf
#

well it doesn't

polar acorn
#

Which is why I asked how you were doing the turning and you haven't shared it

vocal wharf
slender nymph
#

you are much less likely to actually receive help if you post photographs of your screen instead of sharing !code correctly or using screenshots

eternal falconBOT
steep rose
#

how are you on discord then

#

that doesnt make sense

polar acorn
#

I thought it was being used further down and was cut off, my bad

slender nymph
#

sucks for you then

steep rose
#

put an internet card into your pc

steep rose
rocky canyon
#

use ur cellphone as USB tether

languid spire
#

connect the phone to the PC and piggyback

rocky canyon
#

tada 🪄

polar acorn
languid spire
#

you have come here asking for help therefore it is your responsibility to make it easy for us to help you. If you cannot be bothered to do that then you can hardly expect us to help you

vocal wharf
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

queen adder
#

but it still didnt show me or correct me

slender nymph
#

Start rewriting the line and it will show suggestions as you type and you'll see the correct method

vocal wharf
#

@polar acorn I googled and looked up the doc and stuff and I still can't figure out the syntax 😭 can you help plz?

rocky canyon
#

the method expects a quaternion.. ur feeding it a vector3..
look up how to convert vector3 to quaternion.. and give it the right type of value

#

the errors a give-a-away.. cannot convert blank to blank

polar acorn
slender nymph
#

MoveRotation is also not static, you need to call it on your rb variable, not on the Rigidbody class itself

rocky canyon
#

ohh true ^

snow warren
#

can i join in the convo as well?

vocal wharf
rocky canyon
#

docs are ur best-friend

polar acorn
#

That whole section would be what you'd pass to the MoveRotation function

vocal wharf
#

ah ok

#

so something like this?

 rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * horizontal * turnSpeed));
#

the red squiggly lines went away so I must have done something right 🥲 (this is a joke)

#

@polar acorn

polar acorn
#

Quaternions are wizard numbers I tend to just futz with them till it works

vocal wharf
#

I'm a beginner so I wouldn't know lol

#

real

#

ight imma test it

polar acorn
#

That one wasn't sarcasm that's lack of confidence in my own understanding

vocal wharf
#

ok it works but it still doesn't turn the right way when reversing

#

here is my updated code:

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody rb;
    public float speed = 1f;
    public float turnSpeed = 1f;
    bool canTurn;
    void Update()
    {
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        rb.velocity = transform.TransformDirection(0, rb.velocity.y, vertical * speed);
        if (rb.velocity.z != 0)
        {
            canTurn = true;
        }
        else
        {
            canTurn = false;
        }
        if (canTurn == true)
        {
            rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * horizontal * turnSpeed));
        }
    }
}
rocky canyon
#

my car controller uses the Vertical input multiplied into the Rotation..
when ur going forward its 1.. soo anything multiplied with it is what it is (this is normal steering)
when ur reversing its -1.. soo anything multiplied with it is reversed (this is reversed steering)

#

this automatically makes it work right out the box..

vocal wharf
#

oh that's a good idea actually

rocky canyon
#

yessir, then u only need to make ur steering work (going forward) and if it does it should work w/ reverse just by multiplying the vertical input in w/ it

vocal wharf
#

It works!!!

#

thank you bro

#

it already feels more like a car now

#

just gotta add my blender model I made

silent valley
#

Hi. I have a resource cost Monobehaviour class to manage my resource costs for building/crafting etc. I have the resource cost on my item to build. Set the cost in the inspector. All that works. My inventory also works with the resource cost. The way i place a building part is to ResourceCost cost = pendingObject.GetComponent<ResourceCost>(); the it sees if i have the resources available then places itor doesnt. I have made scriptable objects for my crafting recipes. I got it to work if i make the Resource cost not a mono behaviour but just a class. But this ruins my building manager as it requires get component. How can i show the resource cost in my inspector for the scriptable object as a monobehaviour or how can i access the resource cost in the building manager if it isnt a monobehaviour? I'll send examples

deft grail
silent valley
#

Do you mean like this?

deft grail
# silent valley Do you mean like this?

yeah i guess, or if you say you have "recipes" then surely that should just automatically detect what you need?
if not then yeah just putting the cost like this should be fine i think

shell yew
#

how can i get the faced direction of a 3d object?

wintry quarry
silent valley
deft grail
shell yew
wintry quarry
#

And it's already a Vector3

shell yew
#

what is the correct way of doing it then?

wintry quarry
#

directionToMove = transform.forward;

#

Don't overcomplicate it

shell yew
#

oh alright, thanks

deft grail
shell yew
#

yeah i missed out new, i already have that just didnt add it when typing it across to discord

silent valley
wintry quarry
#

Anyway that would only be to create a new vector3

#

You already have one

deft grail
tender stag
#

what if i add velocity instead?

#

like add the movement velocity to the current velocity

rocky canyon
#

u could probably do that too..

wintry quarry
#

AddForce with transform.forward OR AddRelativeForce with Vector3.forward

#

Pretty straightforward, no pun intended

polar acorn
#

Use AddForce and pass in transform.forward multiplied by some amount of force

#

transform.forward multiplied by some amount of force

#

Do you know how to call a function

eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
#

You call that function and pass in the parameter I said

rocky canyon
#

🫣 Function (Parameters) ;

polar acorn
#

I literally gave you the exact answer

#

I told you what function to call and what value to pass it. Then when you said you didn't know how to call a function, I sent you how

rocky canyon
#

rb.Function

#

to be exact

#

Function w/o a prefix would call a method within the same class..

#

but ur lookn for rigibody stuff

steep rose
#

next time please !learn how to use unity

eternal falconBOT
#

:teacher: Unity Learn ↗

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

steep rose
#

we wont spoon feed you next time

solemn fractal
#

hey guys I am using a dictionary.. I want to have set already some waves for my game .. each wave with dif enemies and quantities.. but it seems very hard to access from another script these values.. is there any other easier way?

#

example: wavesDictionary["Wave2"] = new Dictionary<string, int>{ { "Circles", 7 }, { "Squares", 2 }, { "Total", 9 } };

polar acorn
solemn fractal
#

hmm.. ok, might be a good idea. I will check that. Thank you

flat summit
#
if (boatController.drivingBoat)
  {                 
      yRot = Mathf.Clamp(yRot, boatController.transform.eulerAngles.y - 90, boatController.transform.eulerAngles.y + 90);
  }

my camera snaps when turning boat, i realize its becuase quaternions are weird and values goes back to zero but idk how to fix D:

teal viper
flat summit
teal viper
flat summit
#

sure, here is a video of what i just explained. Let me know if anything else could be of use.

#
float xInput = Input.GetAxisRaw("Mouse X");
float yInput = Input.GetAxisRaw("Mouse Y");

yRot += xInput * _sensitivity;
xRot -= yInput * _sensitivity;

xRot = Mathf.Clamp(xRot, -90, 90);

transform.rotation = Quaternion.Euler(xRot, yRot, 0);
playerOrientation.rotation = Quaternion.Euler(0, yRot, 0);

this is the only code thats rotating anything.

flat summit
#
rb.AddForceAtPosition(-sideDirection * turnSpeed, turnForcePos.position, ForceMode.Force);
teal viper
#

First of all the ideal solution would be to use cinemachine

solemn fractal
steep rose
flat summit
polar acorn
solemn fractal
#

damn that is too much hahaha

polar acorn
#

If you have 100 waves you're going to need 100 of something

#

You can't store data on nothing

solemn fractal
#

I am actually at the end using a dictionary. its working as intended. Even tho not sure if the best way or optimal. THank you 😛

#

doing something like that:

#

There are so many ways to do what I want to do. Hard to pick one

#

And prob game will have 100 waves or more.. each one to be balanced, I need to do them manually and not just random.

#

still thinking ways to optimize that. will not go forward until I find a good solution

#

will keep only 2 waves until I find best way to replicate that to 3..4....100...

cosmic dagger
# solemn fractal

That's wild. Why not use a WaveData struct, class, or SO containing a list of enemies?

ivory bobcat
cosmic dagger
#

You can have an SO containing a list of WaveData (all of your waves) where each instance in the list has its list of enemies. There is no need to store the total, as a list — or any collection — keeps track of its size . . .

ember tangle
#

I want to confirm that this```
[SerializeField] private TileBase test;

public void DrawTiles()
{
baseTiles.SetTile(new Vector3Int(0, 0, 0), test);
baseTiles.SetTile(new Vector3Int(0, 1, 0), test);
}```

Doesn't work because each 'tile' needs to be created individually from a prefab or something?

#

because that would make no sense whatsoever given that a tile is a scriptable object.

shell sorrel
#

just try it

#

should work but easy way to find out

#

there SO's so assumeing all it needs is the reference to the asset and not a instance

rich adder
#

when you dragged the tiles onto tilepalette it asked you where to place them

ember tangle
#

I did, still nothing, The documentation is not up to unitys normal standards, I'm assuming because most people do not script their tile system

#

The tiles will only be placed during runtime

rich adder
#

you didn't use tile palette yet ?

ember tangle
#

I cut a sprite into tiles

shell sorrel
#

assuming they made tiles already, and they jsut want to build things procedurally

ember tangle
#

SetTile works exactly once

rich adder
#

it works as many times as you call it

#

I personally would also not use BaseTile. Just inherit Tile class you can make custom tiles

solemn fractal
ember tangle
rich adder
ember tangle
#

In the start function of a LevelManager game object.

rich adder
ember tangle
#

pos?

steep rose
#

position

#

pos = position

ember tangle
#

oh god, yeah obviously

#

hmm, so no matter what I do it looks like all tiles are only being drawn on one square

#

regardless of position

#

The TileMap im targeting has an XY orientation though

shell sorrel
rich adder
#

SetTile should automatically refresh the board

ember tangle
rich adder
#

do you have a grid component btw

ember tangle
#

You know what

#

I did, but when I dragged the grid > tilemap to be a child of a manager it lost its hierarchy and I didnt realize it

#

let me fix that and test

shell sorrel
#

yeah i normally just make the the tilemaps all childern of a grid

#

it can't figure it out otherwise since it is aloud to have multiple grids

ember tangle
#

thats what it was

#

literally didnt pay attention to the object hierarchy lol

shell sorrel
#

well its burnt into memory now to check for that next time

queen adder
#

Hey, I had a question if anyone has a moment to help me with something.

shell yew
#

don’t ask to ask

eternal falconBOT
queen adder
#

lol I suppose so... I just feel very stupid about this coding stuff.

steep rose
#

we all start somewhere

queen adder
#

I am trying to make a flappy bird clone to learn coding from this great video.

#

But it keeps telling me I haven't assigned something in my script and I have no idea why.

rich adder
#

well then assign it 😉

steep rose
#

thats probably because you havent

queen adder
#

I don't know what that means though :X

shell sorrel
#

would need the exact error but could be a few things

rich adder
#

well start by showing us the exact error with a screenshot

shell sorrel
#

good chance you need to just drag something into the script as a reference

queen adder
#

Okie dokie! Give me a second.

steep rose
shell yew
#

i’m using AddForce to move a 3d object. i’m trying to get it’s current direction of travel during runtime.
i’m doing this so that i can tell it to rotate to face away from it’s direction of travel.

steep rose
#

got it

queen adder
shell yew
steep rose
#

it is a vector yes

shell yew
#

thanks!

shell sorrel
rich adder
# queen adder

ok so the script on the bird gameobject, needs it assigned

queen adder
#

Okay, how do I assign it?

queen adder
#

OHHH

#

This link is super helpful.

#

❤️

#

Wait.

#

Let me read more, that didn't fix it.

rich adder
queen adder
rich adder
#

you have a copy maybe on Main Camera

slender nymph
#

make sure you aren't doing something like overwriting the assignment in Start or Awake

rich adder
#

seems ok

slender nymph
#

and yeah, make sure you don't have another copy of the component in the scene

queen adder
#

I rewrote the whole script.

#

But it still has this problem.

rich adder
#

what did you write

steep rose
#

i mean theres not a lot to rewrite

queen adder
#

Like I deleted the whole script, came back here, rewrote it the way he said, then was like "I need backup" and came here.

steep rose
#

why?

steep rose
#

just update your script

queen adder
#

Sure!

shell sorrel
#

since the one instance you showed looked fine, make sure its not attached to a other game object

vocal wharf
#

Hello! I am making a simple open world 3d car game and I have made a working car controller script (with the help of a few people here) but the acceleration and braking is instant. I want it to ramp up slowly and preferably coast when I let off the gas (until I hit the brake of course). How would I go about doing that? Here is my super simple script so far:

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody rb;
    public float speed = 1f;
    public float turnSpeed = 1f;
    bool canTurn;
    void Update()
    {
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        rb.velocity = transform.TransformDirection(0, rb.velocity.y, vertical * speed);
        if (rb.velocity.z != 0)
        {
            canTurn = true;
        }
        else
        {
            canTurn = false;
        }
        if (canTurn == true)
        {
            rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * horizontal * vertical * turnSpeed));
        }
    }
}
steep rose
#

best use addforce()

queen adder
vocal wharf
rich adder
rich adder
steep rose
eternal falconBOT
queen adder
#

No! I didn't know that was a thing.

steep rose
#

configure your ide

rich adder
#

make sure you did assign it like you shown , if its still errors check the camera if you didnt put another copy of that script

queen adder
#

I think I'll have to write down a lot of these words you guys are using and look them up so I can understand better.

#

Because I am very confused at what is being asked of me and I think it is unfair to ask for help if I don't know the language :X I apologize guys.

rich adder
#

and !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

especially the Essentials pathway

shell sorrel
queen adder
#

I'll look at that then.

steep rose
#

pretty big giveaway

queen adder
#

Me and friend are trying to learn this stuff because finding a programmer is hard xD

steep rose
#

well you found us

shell sorrel
steep rose
steep rose
#

clearly something is wrong

queen adder
#

xD Well, sure. Finding programers who are alive is easy. Finding programmers who want to work on your game, on your schedule, for free well, that isn't like under 18 is pretty hard.

steep rose
#

unless they took a picture as soon as CS opened

#

that would explain it

rich adder
shell sorrel
frosty hound
#

You can always post on reddit and the likes, there's always people looking for projects to collab on.

#

Provided you have something worth showing to entice people to join up. Most won't do so blindly.

shell sorrel
#

programming is just a skill though anyone can learn it

#

just takes effort and time

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

rich adder
#

very tru

queen adder
rich adder
#

the resources are plenty and they are free

ivory bobcat
steep rose
#

i guess you will be our frequent customer, welcome and keep this page on standby!

shell sorrel
#

yes its by far one of the easier and least costly skills to learn

rich adder
#

it can cost sanity if you let it 😛

solemn fractal
queen adder
steep rose
#

dont ask me how I know

shell sorrel
rich adder
rich adder
shell sorrel
#

yeah keep your idea in mind, but start on some introductory learning content

steep rose
#

what good is a fisherman without his pole? is the best way to explain this

shell sorrel
#

its hard to know what to do with out a grounding first

rich adder
#

some cheese words "its a marathon not a race"

vocal wharf
#

@steep rose alright so I figured out how to implement AddForce and it works but the other part of code that I came up with isn't working how I want it to (surprise surprise). When I am pressing a gas or brake input it lets me turn but when I let go of the inputs and keep coasting/sliding, it doesn't let me turn anymore, despite the purpose of my code being to allow me to turn when the forward velocity is not 0. Do you know why this is happening?

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody rb;
    public float speed = 1f;
    public float turnSpeed = 1f;
    bool canTurn;
    void Update()
    {
        Vector3 forwardDirection = rb.transform.forward;
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        rb.AddForce(forwardDirection * vertical * speed);
        if (rb.velocity.z == 0)
        {
            canTurn = false;
        }
        else
        {
            canTurn = true;
        }
        if (canTurn == true)
        {
            rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * horizontal * vertical * turnSpeed));
        }
    }
}
queen adder
#

You guys are really nice ^___^ next time I'll be better

rich adder
queen adder
#

I'm gonna head to bed. Thanks again everyone.

vocal wharf
#

I tried it inverted with != but that didn't work either

shell sorrel
#

can use Mathf.Approxmentaly

#

or test how close it is to zero and decide what is good enough

steep rose
#

ive had this before

#

with my game in particular

vocal wharf
#

ok

#

how do I use local velocity?

steep rose
#

as soon as you turn im guessing you cannot turn again?

vocal wharf
#

even when I am still coasting

rich adder
#

btw rigidbody should be moved in FixedUpdate not Update

vocal wharf
#

how is that better?

steep rose
rich adder
steep rose
vocal wharf
shell sorrel
#

pretty much anything to do with rigidbodies should be fixed update

shell yew
#

i’m trying to make something turn to face the opposite way it’s heading when a function is called.
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(rb.velocity), 1 * Time.deltaTime);
however when called the function does nothing in the scene.
what have i done wrong?

rich adder
#

is there a reason you're not using the wheel colliders btw? Unity has a great example of a vehicle on the Wheel collider Docs

vocal wharf
shell yew
vocal wharf
# rich adder yea

I put everything that was in the update function into FixedUpdate but now it doesn't move at all. I'm assuming there's something that needs to stay in update? 0_0

shell yew
rich adder
solemn fractal
steep rose
# vocal wharf I put everything that was in the update function into FixedUpdate but now it doe...

the reason i think it is because you are not using local velocity i personally dont see anything that would affect turning other than (unless you are modifying it somewhere else)

        if (rb.velocity.z == 0)
        {
            canTurn = false;
        }

this code says if the rb.velocity.z == 0 to not turn but you are using global velocity if that makes sense. and addforce doenst just stop instantly, but if you turn away from rb.velocity.z it will be 0 so im not actually sure whats wrong here other than that

shell yew
shell sorrel
#

since that will only move a tiny fraction of a degree

steep rose
rich adder
shell yew
rich adder
#

no you need this to happen across span of frames

shell sorrel
#

no it needs to be called many many times

#

you are telling it to move max 1 degree * deltaTime per invok

steep rose
#

call it in update()

rich adder
#

or a Coroutine

shell yew
#

so i need a bool “isDoingThing” and if it’s true then it will execute in a fram?

steep rose
#

im guessing its a void

shell sorrel
#

so thats a very small number that you will not even notice

ivory bobcat
solemn fractal
rich adder
#

you need it in update , or coroutine

shell yew
#

are there any significant advantages or disadvantages

shell sorrel
#

would do update if you always got a look target you want it to move to over time

#

would use a coroutine if its like a 1 off action

#

like move to this rotation over this many seconds type thing

rich adder
shell yew
#

coroutine sounds best, it’d happen reasonably rarely so i think that’s best, welp, off to go learn coroutines

rich adder
vocal wharf
rich adder
shell sorrel
#

yeah it gets strange looking quick if you got multiple coroutines editing the same thing at the same time

rich adder
#

one of my first scripts in unity with StartCoroutine in Update UnityChanLOL

shell sorrel
#

don't think i made that mistake before, thjough when i was learning unity back in the 3.5 days pretty sure i just used update tick mostly since its what i was used to from other engines

rich adder
#

Ahh thats good. I had no coding xp except for modifying some scripts for source engine and some lua for gmod

#

so many goofy mistakes , who knew Update would be now what I use least, now its mostly coroutines to have more control on the ticks

shell sorrel
#

had some old idtech experience coming into it, and a ton of as2 flash stuff

ivory bobcat
rich adder
#

always wanted to use the macromedia software but it looked foreign to me

shell sorrel
#

back in those days it was everywhere

rich adder
#

yeah I was a Newgrounds junkie in its early days

shell sorrel
#

like even high school had it a bunch of macromedia stuff installed on all the machines including flash

rich adder
#

haha yeah they would block it in my school because they knew people would game on it

shell sorrel
#

yeah not sure why but literally every school machine had flash, dreamworks and fireworks installed

rich adder
#

oh thats when the adobe thing happen

shell sorrel
#

was still all macromedia owned then

#

adobe bought it much later

rich adder
#

what a shitshow lol

vocal wharf
# steep rose the reason i think it is because you are not using local velocity i personally d...

I found the problem. I was originally multiplying my turning (horizontal inputs) with my vertical inputs to invert the steering when reversing like a real car behaves. I didn't take into account that when not giving vertical inputs it would be multiplying my steering by 0, therefore not allowing me to steer 🤦‍♂️ I guess I'll have to find a different way to invert my steering. Probably change a variable based on velocity... idk

shell sorrel
#

if adobe, or autodesk buys something it will be a shit show from then on

steep rose
steep rose
#

Actually I'm not sure if newgrounds allows copyrighted songs 🤔

shell yew
#

i’m trying to make an object correct itself after being spun by a collision, how can i detect that rotation so that i can counteract it?

slender nymph
shell yew
#

yes i want it to rotate after.
in such a way that it appears physically possible that it corrected itself under it’s own thrust

slender nymph
#

you can use Rigidbody.MoveRotation to do that, you just need the target rotation and the speed you want it to move at. but to get the current rotation you can use that property i linked before

shell yew
#

i think the way i want it to happen getting current rotation is better, thanks for the help!

static wasp
#

i've been using print to write on the console, i don't use Debug.Log because it's faster to type print. There aren't any differences, right?

slender nymph
#

print just calls the single parameter overload of Debug.Log. so the only difference is that you can provide more context if you use Debug.Log because it has a few overloads

shell yew
slender nymph
#

yeah that was not clear from what you asked. that would be its angular velocity

shell yew
#

sure, not trying to have a go at you or anything, just explaining there was a miscommunication, how would i get that

slender nymph
#

check the docs

static wasp
#

took a solid hour to solve a problem i had, turned out to be a floating point issue, as always 👍

snow warren
#

hi

#

i need some help?

slender nymph
#

!ask

eternal falconBOT