#💻┃code-beginner

1 messages · Page 360 of 1

primal lintel
summer stump
primal lintel
#

what to show you more exactly

short hazel
#

How the animator is set up would be the first thing that comes to mind
Looks like you have root motion enabled, not sure if the problem is really about the code
The object moves, but the animator moves it again, and with root motion enabled it snaps back when the animation clip loops

bitter cove
#

where would I ask for help, cause im struggling?

dense root
#

How would you go about making a pokemon style movement system? Would you create a grid for the player to move to square to square?

short hazel
#

Read the message I sent

primal lintel
#

I see

#

can you help me with anydesk

slender nymph
glossy turtle
short hazel
dense root
slender nymph
#

use the tutorials to help understand how you do certain things so that you have the knowledge to make your own system if the tutorials don't do exactly what you want

dense root
#

So when you're learning do you just watch the video without trying to copy?

#

I've been stuck in tutorial hell for quite some time and I'm really trying to claw my way out of it

slender nymph
#

there's really no one way to learn and everyone learns a bit differently. you just gotta figure out what works best for you

summer stump
warm condor
glossy turtle
short hazel
primal lintel
short hazel
#

That person does not seem to understand what we're trying to say

summer stump
stuck palm
#

what does ref mean? im using this package i found

random cave
#

!code

eternal falconBOT
short hazel
#

(since Quaternion is a struct, a value type, it's by default copied when you pass it around)

stuck palm
#

awesome thaks

random cave
#

Can someone help me with my air resistance code? Im trying to make it so my bomb goes all over the place and rotates and sways then stabilizes at 90* pointing down heres my code
https://hastebin.com/share/eqaluwomug.csharp

stuck palm
#

@rich adder fixed that stupid rotation issue i had by passing rotation in the update rotation method in the KCC

short hazel
#
Quaternion q = transform.rotation; // copy
UpdateRotation(ref q); // reference, modified inside
Debug.Log(q); // modified
random cave
tidal basin
#

How can i set my fps characters direction to go to the direction it is looking? (My camera script turns the character already in Vector3.up)

currentInputVector = Vector2.SmoothDamp(currentInputVector, input, ref smoothInputVelocity, .1f);
Vector3 move = new Vector3(currentInputVector.x, 0, currentInputVector.y);
controller.Move(playerSpeed * Time.deltaTime * move);```
slender nymph
#

transform your input direction (after turning it into a vector3) using transform.TransformDirection

willow scroll
tidal basin
willow scroll
stuck palm
#

i feel like the fading goes too quickly, but i cant use standard delta time if im making the timescale 0. how can i fix this issue?

willow scroll
#

Multiply them by the value if needed

summer stump
# primal lintel its ok now

You didn't show much of what I asked for at all.
The child is definitely moving on its own, and the parent is much slower. That's about all I can say

Oh, it's a long video...
Well, video is perhaps the worst way you could possibly share that information, but give me a minute to watch it

grim tulip
tidal basin
willow scroll
stuck palm
grim tulip
#

Or nah

zenith cypress
#

Rider is paid

tidal basin
grim tulip
willow scroll
summer stump
# primal lintel its ok now

Your animation itself is moving moving the transform, right? I don't see that in the video, but it's hard to follow along the way it is recorded, especially on my phone

tidal basin
willow scroll
#

You've already done it with forward

lethal apex
#

guys do i need to learn about the .NET to develop games?

willow scroll
#

Changing a single word is enough to make it work with right too

random cave
summer stump
lethal apex
summer stump
#

And you are trying to assign it to a float

willow scroll
tidal basin
lethal apex
tidal basin
willow scroll
summer stump
random cave
lethal apex
random cave
#

That's how I learnt to code

lethal apex
random cave
#

Played a lot any idea that came to mind tried to make it

willow scroll
random cave
#

Quite fun, your game wont be polished but gotta learn things here

lethal apex
tidal basin
random cave
random cave
#

So you're learning unity and coding

lethal apex
#

oh.

summer stump
willow scroll
grim tulip
tidal basin
summer stump
#

They are already vectors

primal lintel
grim tulip
summer stump
#

Just set move to forward * your multiplier (or right if that's what you want)

willow scroll
tidal basin
#

Sorry english isn't my main language so i cant explain myself so good. In this line Vector3 move = new Vector3(transform.right * currentInputVector.x, 0, transform.forward * currentInputVector.y); I am trying to move my character through to looking direction. The last argument, transform.forward * currentInputVector.y is okay. But in the first argument, its saying you cant transform vector3 to float. Please say if you didnt understand anything..

random cave
#

"Tokyo Night" would look close to what you saw

#

Wiat no

tidal basin
summer stump
random cave
willow scroll
#

So you assign the x axis to (currentInputVector.x, 0, 0)

slender nymph
slender nymph
#

what do you even mean by that

random cave
#

Yeah I ment tokyo night

tidal basin
random cave
willow scroll
summer stump
grim tulip
slender nymph
tidal basin
#

um okay i will try it

willow scroll
#

Make sure to change the Time parameter according to the fade duration

#

Setting the parameter to unscaledDeltaTime makes it only work when the duration is 1 real-time second

#

So simply multiply em

tidal basin
# slender nymph transform your input direction (after turning it into a vector3) using transform...

So i add that "move = transform.TransformDirection(move);" line and now its working. Idk am i do it right but at the end its working. Tysm!

    {
        // Smooth movement codes.
        Vector2 input = moveAction.ReadValue<Vector2>();
        currentInputVector = Vector2.SmoothDamp(currentInputVector, input, ref smoothInputVelocity, .1f);
        Vector3 move = new Vector3(currentInputVector.x, 0, currentInputVector.y);

        // Transform the move direction relative to the object's rotation
        move = transform.TransformDirection(move);

        controller.Move(playerSpeed * Time.deltaTime * move);
    }```
slender nymph
#

yes, that is how you use that

mighty marsh
#

I'm getting an error in unity for the 1st line of code in this function and I don't really understand why. The error is "object reference not set to an instance of an object. ```cs public void Movement(bool move)
{
//Extra gravity
rb.AddForce(Vector3.down * Time.deltaTime * 10);

        //Find actual velocity relative to where player is looking
        Vector2 mag = FindVelRelativeToLook();
        float xMag = mag.x, yMag = mag.y;

        //Counteract sliding and sloppy movement
        FrictionForce(InputManager.x, InputManager.y, mag);

        //If speed is larger than maxspeed, cancel out the input so you don't go over max speed
        if (InputManager.x > 0 && xMag > currentSpeed || InputManager.x < 0 && xMag < -currentSpeed) InputManager.x = 0;
        if (InputManager.y > 0 && yMag > currentSpeed || InputManager.y < 0 && yMag < -currentSpeed) InputManager.y = 0;

        float multiplier = (!grounded) ? controlAirborne : 1;
        float multiplierV = (!grounded) ? controlAirborne : 1;

        float multiplier2 = (weaponController.weapon != null) ? weaponController.weapon.weightMultiplier : 1;

        if (rb.velocity.sqrMagnitude < .02f) rb.velocity = Vector3.zero;

        if (move)
        {
            rb.AddForce(orientation.transform.forward * InputManager.y * acceleration * Time.deltaTime * multiplier * multiplierV / multiplier2);
            rb.AddForce(orientation.transform.right * InputManager.x * acceleration * Time.deltaTime * multiplier / multiplier2);
        }
        else
        {
            if (grounded) rb.velocity = Vector3.zero;
            return;
        }```
#

Also the error is only showing up in the unity console and not in the code

slender nymph
mighty marsh
#

thanks

void forum
mighty marsh
#

ohhhhh okay thank you

void forum
random cave
shut finch
#

How do I parse a json that uses the following naming convention: example_property

Having exampleProperty field in the target class does not work. Can I somehow give custom names to fields?

fyi: I am using JsonUtility.FromJson<T>() method

short hazel
#

You'll either need to switch to another serialization library, or rename your fields so they have the same name as in the JSON objects

stuck palm
#

am i doing this right? it doesnt feel like its lerping between the two curves correctly.

switch (damageMultiplier)
                {
                    case > 3:
                        MoveVector = MoveVector.normalized * (launchSpeed * heavyCurve.Evaluate(progress));
                        break;
                    case > 2:
                        MoveVector = MoveVector.normalized * (launchSpeed * Mathf.Lerp(mediumCurve.Evaluate(progress), heavyCurve.Evaluate(progress), damage / 3));
                        break;
                    default:
                        MoveVector = MoveVector.normalized * (launchSpeed * Mathf.Lerp(lightCurve.Evaluate(progress), mediumCurve.Evaluate(progress), damage / 2));
                        break;
                }
solid pendant
#

could anyone help me? i have 2 main problems with visual studio when working in unity. I dont have autocomplete pop up when i type code and I dont see any errors until i save and go back into Unity. It is wasting a lot of my time and none of the solutions online are helping me

short hazel
eternal falconBOT
polar acorn
stuck palm
#

its meant to be damage multiplier

#

thanks

solid pendant
# languid spire !ide

When I go to external script editor and change it from file extension to Unity 2022 it doesnt show any code whatsoever

polar acorn
solid pendant
#

i cant find a solution

stuck palm
polar acorn
#

If damageMultiplier is greater than 2, it's entirely possible that damage / 3 is greater than or equal to 1

languid spire
stuck palm
solid pendant
rich egret
#

!code

eternal falconBOT
solid pendant
#

mistyped, my brain turns to mush quickly

polar acorn
rich egret
languid spire
solid pendant
languid spire
stuck palm
#

as the value usually jumps over these thresholds anyway

lethal bolt
#

Why cant i see the Gizmos+

polar acorn
solid pendant
polar acorn
polar acorn
solid pendant
#

when i changed it to visual studio from file extension thats all it gives me

#

whenever i try to go into my code

stuck palm
#

obviously the video is an extremely exaggerated version of what i want to do

#

but thats basically it

#

wait a minute

#

no this looks right

lethal bolt
polar acorn
lethal bolt
#

This?

stuck palm
polar acorn
lethal bolt
#

no...

languid spire
stuck palm
#

@polar acorn

while (stunRemaining > 0)
        {
            yield return null;
            stunRemaining -= Time.deltaTime;
            if (decay)
            {
                launched = true;
                float progress = (length - stunRemaining) / length;
                switch (damageMultiplier)
                {
                    case > 3:
                        MoveVector = MoveVector.normalized * (launchSpeed * heavyCurve.Evaluate(progress));
                        break;
                    case > 2:
                        MoveVector = MoveVector.normalized * (launchSpeed * Mathf.Lerp(mediumCurve.Evaluate(progress), heavyCurve.Evaluate(progress), damageMultiplier / 3));
                        break;
                    default:
                        MoveVector = MoveVector.normalized * (launchSpeed * Mathf.Lerp(lightCurve.Evaluate(progress), mediumCurve.Evaluate(progress), damageMultiplier / 2));
                        break;
                }
                MoveVector = FightPhysics.ApplyGravity(MoveVector);
                MoveVector = FightPhysics.CalcEnv(MoveVector);
            }
        }

this is the full thing, am i doing it wrong possibly?

lethal bolt
#

This is the code

polar acorn
stuck palm
#

it doesnt feel like its following the curve

polar acorn
#

That function is not OndrawGizmoos

lethal bolt
#

oh

#

What is it suppose to be?

solid pendant
polar acorn
solid pendant
#

now i get that

polar acorn
stuck palm
polar acorn
stuck palm
#

make it feel better in the game

languid spire
lethal bolt
#

man.... okay i JUST got home from an 5hour test but ig the point is to learn XD

polar acorn
stuck palm
#

i thought it would be okay to lerp based on the difference between health

polar acorn
polar acorn
stuck palm
#

its not health per se

#

its more like smash bros

#

where ur damage goes up

#

bad naming on my part

polar acorn
#

Okay, so then it seems like that damage should be deciding which curve you use, rather than getting some value between two curves

stuck palm
polar acorn
stuck palm
split jay
#

hey i also have a question, does anybody know how i can make something fly along a predetermined path in a natural way? ( i have this fireghost that is looking for shelter from the rain in a forest, he searches for a few seconds and then stops under a tree)

split jay
#

ahh that looks promising, is that like a curve i can draw in the world?

worthy tundra
#

i have something that makes 0 sense.
i have a pick up script, with an assignable layerMask variable, call it allowedLayers.

the player object is under the Player layer (i checked) and the allowedLayers is assigned to the Player layer.

i then do an OnTriggerEnter, and something illogical happens.

i have

if (other.gameObject.layer != allowedLayers) 
return;

and when the PLAYER enters the trigger, it returns (i checked with debug.log). however... when i do

if (other.gameObject.layer == allowedLayers)
return;

it DOESNT return.
idk why

outer coral
#

How can I load the unique GUID's of my objects when entering a new runtime? All the old ones are gone on startup (new ones get assigned) and I have them saved but theres no way for me to find which objects had which ids, currently I have it working except I am using FindObjectsOfType so it keeps loading the objects in a different order and thus not mapping to them correctly how can I accomplish this? Having a hard time trying to figure this out

to be explicit my enemies spawn coins if its the players first time defeating it, so i am saving the guid of all the enemies that were defeated, and then loading them to determine which enemies should drop coins (since the enemies will be back the next runtime) - essentially the incorrect mapping results in the wrong enemy not spawning coins when it should

slender nymph
worthy tundra
slender nymph
#

no, it's the layer index

worthy tundra
slender nymph
#

yes, it is the layer's index. it is not a layer mask. read through the link i sent

languid spire
worthy tundra
#

then how do i check for the layermask of a gameobject

slender nymph
#

did you bother reading the information on the link i shared?

polar acorn
languid spire
#

convert the Layer id to a LayerMask

slender nymph
#

there's a convenient side bar that has some options for things like exactly what you are trying to do

old dew
#

can i ask a basic question about why unity cant find a gameobject i made?

worthy tundra
old dew
#

i wrote it bad

polar acorn
#

!code

eternal falconBOT
willow breach
#

how carful should i be with the data i need to save? do i need to write to the file every time there is a change incase it crush or can i just save when the game closes?

old dew
slender nymph
worthy tundra
#
    if (partita != null)
    {
        partita.SetActive(false);
    }

how can you set it to inactive if you dont have a reference to it?

worthy tundra
old dew
worthy tundra
#

my brain refuses to function today

old dew
#
void HandlePlayerCollision(GameObject player)
    {
        // Disable the player
        player.SetActive(false);

        // Determine the winner
        string winner = player.name == "Player1" ? "Player 2" : "Player 1";

        // Disable the game object called "Partita"
        GameObject partita = GameObject.Find("Partita");
        if (partita != null)
        {
            partita.SetActive(false);
        }
        else
        {
            Debug.LogWarning("Partita GameObject not found");
        }

        // Enable the game object called "FinePartita"
        GameObject finePartita = GameObject.Find("FinePartita");
        if (finePartita != null)
        {
            finePartita.SetActive(true);

            // Update the text of the "WinnerText" object
            Text textComponent = finePartita.GetComponentInChildren<Text>();
            if (textComponent != null)
            {
                textComponent.text = "complimenti al " + winner + " per aver vinto il round! \n \n \n \n \n Premi la X per tornare al menù";
            }
            else
            {
                Debug.LogWarning("Text component not found in FinePartita");
            }
        }
        else
        {
            Debug.LogWarning("FinePartita GameObject not found");
        }
    }
#

i get the debug warning Debug.LogWarning("FinePartita GameObject not found");

#

i checked the name alredy and its the same

polar acorn
languid spire
#

this
GameObject partita = GameObject.Find("Partita");
will only find an active gameobject. Is it active?

old dew
#

ohhh i see

#

and how should i write it?

#

because it is not active

slender nymph
polar acorn
old dew
#

idk i can try

solid pendant
#

@languid spireI think i got it fixed thanks to you, i appreciate it ❤️

outer coral
swift crag
outer coral
#

No

swift crag
#

Unity objects don't have GUIDs on them.

#

Show me what you're doing, then

outer coral
#

I am giving them unique guids at runtime and saving the ones that have been killed, then loading those guids the next runtime my problem comes when I cant map the objects to the ids they were given the first time

#

I've tried using a dictionary but if anything it just made it worse

slender nymph
#

ideally you would assign the GUID at edit time, not runtime. the problem with doing it at runtime, is how do you know what GUID maps to which object without a deterministic way to remap them. and it's not like you'd be able to just generate a new GUID, because that would be kind of pointless.
so assign the GUID at edit time, then it will never change and you will just not have the problem you are currently trying to solve

outer coral
#

What do you mean edit time?

#

would that work in a build?

slender nymph
#

wdym would it work in a build? if you have already assigned the GUIDs and they are serialized in some way then it will just be there in a build already

outer coral
#

Okay that makes sense

#

So how do I assign them at edit time

final sluice
#

Can someone recommend me a good free unity course for developing 2d games using Unity ? Thank you

eternal needle
outer coral
#

So you mean manually go add a guid to all of my objects? That is the easiest way?

slender nymph
#

i mean you could write a script to do it automatically, but otherwise yeah

eternal needle
#

You can have an editor script do it for you

silk fossil
#

yo my block cooldown method is not working

#

the BlockCooldown is not startinf

#

idk why

slender nymph
#

do you actually use those bools you assign to?

wintry quarry
#

Use more logs

silk fossil
zenith cypress
silk fossil
silk fossil
#

my player is taking damage

wintry quarry
#

show your console

silk fossil
#

oka

solid pendant
#

very simple question that i never quite understood even when explained a few times. when would i use public and private? what exactly is the difference?

rich adder
#

encapsulation

zenith cypress
#
class Foo {
  public int A;
  private int B;
}

var foo = new Foo();
foo.A = 1; // no error, public is accessable to anything if it has an instance to Foo
foo.B = 2; // error! private cannot be accessed outside of the type
silk fossil
astral falcon
silk fossil
#

before block cooldown

#

and after blockcooldown

#

it looks like it prints blockcooldown has started

silk fossil
#

which is in the couritine

wintry quarry
silk fossil
#

but does not reset the blockcount

wintry quarry
#

See how it says "Block cooldown started"

silk fossil
#

ya

wintry quarry
#

So the problem is not what you said

#

the BlockCooldown is not startinf
This is not correct

wintry quarry
silk fossil
#

ya now I think the problem is that the playerhealth.blockcount=0 is not happening

outer coral
wintry quarry
#

Most of the time it's the third one

robust turret
#

hey everyone

#

I am new here and confused of everything

wintry quarry
zenith cypress
astral falcon
#

Does your coroutine get started several times as you wait for some seconds on the beginning before setting the block back to 0? So its overwriting itself?

silk fossil
#

alr tnx man

wintry quarry
outer coral
robust turret
#

Is there any store in unity on some mock projects to start with?

#

for free

#

I wanna try a few things

rich adder
#

unity learn aslo has more

robust turret
#

there are a lot of threads here

astral falcon
robust turret
#

kk

rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

robust turret
#

also which one is more useful youtube tutorials or unity learn?

rich adder
#

learn

astral falcon
robust turret
#

there are 100 threads here XDD

#

thanks y'all

zenith cypress
outer coral
solid pendant
swift crag
wintry quarry
# solid pendant but in that case why not just use public for everything and only access it if yo...

In software systems, encapsulation refers to the bundling of data with the mechanisms or methods that operate on the data. It may also refer to the limiting of direct access to some of that data, such as an object's components. Essentially, encapsulation prevents external code from being concerned with the internal workings of an object.
Encaps...

zenith cypress
#

The more public everything is, the more issues you will end up having when everything touches everything else all over the place. Encapsulation makes code easier to manage.

astral falcon
wintry quarry
outer coral
west sonnet
#

I have 2 sprites for my player jumping animation. One for when the player jumps up and one when they fall back down. Anyone have any idea how I could detect when the player is moving up and down in script?

solid pendant
#

that does make sense, thanks guys

west sonnet
#

I know how to detect when the player is moving along the Y axis, but not up or down seperately

swift crag
astral falcon
swift crag
#

Reset runs when a component is attached, or when you hit Reset in its context menu

slender nymph
swift crag
#

I do this in my game, actually!

#

I assign GUIDs to some things so I can identify them when I save and load config data

astral falcon
outer coral
#

that works on monobehaviour?

zenith cypress
astral falcon
swift crag
#

If you create the items at runtime, then you can at least keep track of the order you created the objects in

#

maybe keep a running counter

west sonnet
astral falcon
swift crag
#

speed would be a single float

west sonnet
#

Oookay, I think I get ya

outer coral
#

me when I didnt even know that method existed

zenith cypress
astral falcon
#

Not sure why you want create a guid for runtime created objects anyway

west sonnet
zenith cypress
#

That would be "fine" if you didn't save the object state to disk, as that is an instance id. So it will change every time.

swift crag
#

if you know the order you generate coins in, you can just write down the indices of the coins

#

instance IDs are not consistent, so they are not useful here

astral falcon
#

Yeah, this is only for runtime obejcts that only live in that runtime scope. If you wanna store those values across game starts, you need to save them anyway.

swift crag
astral falcon
zenith cypress
#

Guids are nice too if you need cross-object communication across game state deserialization. Since then you can load them back up where they were, with their same id, and use that guid as an id into a lookup map. Dunno what that would end up being needed for but it is a useful thing nevertheless. Maybe if an enemy has to follow another enemy around, that could be a use-case for it CH_DogDance

swift crag
zenith cypress
#

I do the same for asset guids yeah. I have a custom AssetRef<T> that I serialize to its guid generated from its asset path relative to a root folder (we don't change the paths after we make it). Then that is converted to a guid when saved to disk. And is converted back when loaded up. Super nifty. I do need to rewrite this at some point once we get funding, but for our latest demo it works great.

stuck palm
#
velocity.y -= gravity * Time.deltaTime;
        if (velocity.y < maxSpeed)
        {
            velocity.y = maxSpeed;
        }

is this a good way to clamp if i only want to clamp a maximum?

swift crag
#

you have that backwards, I think

#

it sets the Y component to maxSpeed if it's less than maxSpeed

#

otherwise, yes, that's reasonable

stuck palm
#

so like

#

if its less than -30 for example

#

sets it to -30

swift crag
#

ah, okay

stuck palm
#

-30 being the vector y component

astral falcon
swift crag
#

an alternatve that's more general:

Vector3 down = Vector3.down;

Vector3 fallingPart = Vector3.Project(velocity, down);
Vector3 otherPart = Vector3.ProjectOnPlane(velocity, down);

if (Vector3.Dot(fallingPart, down) > 0)
   fallingPart = Vector3.ClampMagnitude(fallingPart, 30);

velocity = fallingPart + otherPart;

Not so useful here, but it would be if gravity was going all over the place!

#

split your velocity into two pieces:

  • the part that's aligned with "down"
  • the part that isn't

if the first part points in the same direction as "down", clamp its length

put them back together

stuck palm
astral falcon
swift crag
stuck palm
#

i guess i could max and the absolute value of velocity.y

swift crag
#

you want Mathf.Max for falling

#

so that you get your currently Y velocity as long as it's more than -30

astral falcon
#

See my one liner

stuck palm
astral falcon
#

yes

swift crag
#

I would call that variable "max fall speed" to make it more obvious than it's going to be negative

stuck palm
#

okay

#

thank you 😄

stuck palm
swift crag
#

Yes, you could use clamp there

reef patio
#

Hello.

#

I have a player controller script that's a bit buggy, can someone help?

#

Courtesy of Udemy.

deft grail
#

what script? !code
whats buggy about it

eternal falconBOT
reef patio
swift crag
#

okay, and what are the actual errors?

deft grail
reef patio
#

ok one moment

deft grail
#

following a multiplayer course, not good...

reef patio
deft grail
# reef patio

Enemy enemy = hit.collider.GetComponent().< Enemy > ();

wintry quarry
# reef patio

These are basic C# syntax errors. If you're struggling with these it's really not a good idea to be trying to make a multiplayer game.

deft grail
#

this is A line with an error

eager wolf
#

is there a way to link one TMPro text box with another in a scene so that it copies what ever is written in the other one WITHOUT using Update() ?

reef patio
#

the get component stays underlined in red

wintry quarry
reef patio
#

is there a spacing error

eager wolf
reef patio
#

or is it a missing brace?

wintry quarry
swift crag
wintry quarry
#

or a property, which is basically just a function.

swift crag
#

the generic type parameter has migrated past the function call, and then you're trying to call it again

rich adder
eager wolf
deft grail
wintry quarry
eager wolf
wintry quarry
#

yeah I mean I get it

reef patio
#

ive been using Unity a couple months, and c# for about a couple months, I have done other tutorials

wintry quarry
#

If you must do it with two objects, just make a component that handles it all

reef patio
#

its asking for an identifier

zenith cypress
#

Unity also has a Shadow component for ui

rich adder
wintry quarry
eager wolf
#

right, with Underlay?

rich adder
#

whats wrong with the shadow built in TMP shader?

deft grail
eternal falconBOT
wintry quarry
rich adder
eager wolf
summer stump
reef patio
#

yeah

rich adder
#

you've been coding these few months without a configured ide ?

deft grail
#

a lot of people do that who dont come to the server

#

if a video doesnt say it how else would you know it needs to be configured

reef patio
#

ive been with a ide that's at Csharp

summer stump
reef patio
#

one moment ill brb

trail crypt
#

I have a question about exporting from blender into unity. I have this animation, mesh, and rig that's in blender and it loops well, uses root motion, and doesn't have any obvious errors while it's in blender. I store the animation in a NLA editor strip. However, when I export the thing into unity, the root motion seems to change and instead of working like it should, the animation moves the character back every 22 frames, which I know doesn't exist in the original blender animation. Does anyone know why this could be happening?

reef patio
#

ok, I'm going to go over it again, much more thoroughly

#

thank you guys for your time and support

wintry quarry
#

Use a field initializer?
Or have the constructors call each other.

#

Also make sure you're not using a constructor on a MonoBehaviour

#

Optional parameters are a potential alternative too

#

structs are not classes, no

#

they are types

eager wolf
#

can i edit a font's generation settings after it's been generated? Trying to change the padding

wintry quarry
#

unclear what you mean by "use them as classes"

rich adder
#

in c# they are difference between reference types and value types

wintry quarry
#

In C# the difference is that structs are value typed and classes are reference-typed

#

C# has proper access modifiers

rich adder
#

pretty big in my opinion

slender nymph
#

in c++ structs just hold data

#

nothing at all to do with being a "private version" of a class

rich adder
#

if you dont specify access modifier its also private in c#

slender nymph
#

wdym it's defaulted to private? like the members? because c++'s struct members are public by default iirc

dense root
#

Any ideas on why my player is refusing to move?

private void Update()
{
    if (isMoving)
    {
        input.x = Input.GetAxisRaw("Horizontal");
        input.y = Input.GetAxisRaw("Vertical");

        if (input != Vector2.zero )
        {
            var targetPos = transform.position;
            targetPos.x = input.x;
            targetPos.y = input.y;

            StartCoroutine(Move(targetPos));
        }
    }
}


/* 
coroutine to move player from current position to target position
used to do something over a period of time, in this case moving the player from current position to next position
checks difference between target position and current position is greater than some value
yield return null stops coroutine and begins it again
*/
IEnumerator Move(Vector3 targetPos)
{
    isMoving = true;
    
    while((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
    {
        transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
        yield return null;
    }
    transform.position = targetPos;
}
wintry quarry
#

Should if (isMoving) be if (!isMoving) ?

#

or maybe even better:

if (isMoving) return;

// the rest of the code```
#

Also, you never set isMoving = false

slender nymph
#

also this code will only ever allow you to move within 1 grid space unit of 0,0

dense root
#

Oh I see...

#

What do I need to do to move more than 1 grid space within 0,0?

slender nymph
#

consider adding to the target position instead of assigning each axis to the input

wintry quarry
#

Well first off best practice would be to store the current grid position with int variables or a Vector2Int

#

because right now if your user is using a joystick / gamepad, sadness is going to happen

slender nymph
#

it's literally just += instead of =

dense root
#

Oh

#

Thank you

wintry quarry
#

Or a = a + b; instead of a = b;

dense root
#

Works great, thank you all

#

So i copied this code from a tutorial video, what steps do you recommend I take so that I understand it further?

random cave
#
Vector2 inputDir = value.ReadValue<Vector2>();
        Vector3 movementDir = new (inputDir.x, 0, inputDir.y);
        rb.velocity = movementDir * speed;```
Why isnt this working?
It says:
'InputValue' does not contain a definition for 'ReadValue'
slender nymph
#

bool does not have an implicit cast to integer in c#, nor does the inverse exist either

zenith cypress
dense root
#

Well I hand wrote it of course

random cave
#

Make him look at the cursor

rich adder
#

int isTrue = myBool ? 1 : 0 ;

dense root
#

But I still "copied it" from a video

random cave
dense root
#

Wdym make him look at a the cursor? Like point the animation towards it?

random cave
#

Make the player look at the mouse cursor

dense root
#

How do I go about doing that?

rich adder
#

haha yeah it happens in the beginning a lot

#

value types are pretty efficient

silk fossil
#

bro wtf is happening bro why is my console not outputting everything

#

just a second ago it was outputing everything

#

now nothign

rich adder
#

yeah you can throw really bad code at them and they still run great

#

what a time

summer stump
eager wolf
#

How would I go about changing the underlay color of my text based on the color of the text?

rich adder
#

we wont even need code just inject our ideas into the machine

silk fossil
dense root
#

What position does transform.position refer to? Is it always self-referential? So in my case the player object?

rich adder
dense root
#

What is world position?

rich adder
#

the position in the world

dense root
#

Position in the world of the object? Isn't that transform.position?

ivory bobcat
#

The local position would be what you'd see in the inspector

dense root
#

Can you provide an example of when you would use the world position?

#

If I understand it correctly transform.position would be used for something like movement, but what would world be used for?

ivory bobcat
#

They are both simply positions

#

Either can be used for movement

#

The local position would simply be the position of the object without accounting for the parental offset.

dense root
#

Hmm I think i kind of understand it

silk fossil
#

if (!collision.gameObject.CompareTag("Boss") && !collision.gameObject.CompareTag("shooter") && !collision.gameObject.CompareTag("Projectile"))
{
Destroy(gameObject); // Destroy projectile if it hits anything else
}

bascially there is one boss object, one shoooter object and there are multiple projectile objecters everywhere, and the projectile objects sometims hit each other and just get stuck in the air, how would I fix this

#

I dont want the projectile objects to destroy each otehr when they touch

#

but I also don't want the projectile objects to collide and just float in the air

#

this is an "oncollisionenter" method btw

ivory bobcat
eager wolf
#

How can i make it so the Text Underlay (aka shadow) is based on the text color (like example on the right) rather than a fixed color for every piece of text (like on the left example)?

it seems impossible

real trellis
#

i just typed a big ass thing and resolved my problem just by typing it out bye

rich adder
silk fossil
zenith cypress
# dense root Hmm I think i kind of understand it
Root @ (1, 0, 0) // local position
 - Child @ (10, 1, 0) // local position

Root world position -> (1, 0, 0)
// this is effectively each transform's local position added up
// in its parent tree
// so (1, 0, 0) + (10, 1, 0) = (11, 1, 0)
Child world position -> (11, 1, 0)

// local positions allow you to position relative to a parent.
// such as an item that bobs up and down on a moving platform.
// the platform would want the item to move along with it
// while the bobbing effect would want to only apply to the local position
// so it still follows the platform, but moves up and down.
ivory bobcat
eager elm
eager wolf
silk fossil
silk fossil
analog pivot
#

hello, I did a little looking. I know its a bit of a meme to say I followed a tutorial verbatim but I checked it out and set { doesnt need a ; before it but... again super new here just trying out.

I kinda understand that most parameters or whatever the term is need ; but thats usually within the brackets

deft grail
dense root
zenith cypress
#

remove the ; on those. They aren't fields anymore, they are properties.

eager elm
analog pivot
teal viper
eternal needle
eternal falconBOT
analog pivot
#

it isnt. youre correct

silk fossil
faint agate
#

Hello, im having trouble on something im sure is simple. I made a script to shoot a ray cast and if it hits the object tagged with candrag, I want to move it up and down on the y axis while its still on the line of my raycast. How should I approach this?
here is my script https://gdl.space/toxiciwopo.cs

rich adder
faint agate
faint agate
#

sorry

rich adder
#

how do you want to move it up and down?

#

you could probably raycast on a plane

#

set plane center where the object center is

#

maybe explain the mechanic of what you want to do

dense root
#

If you got code from a tutorial, what process do you do to understand how it works and ensure you can replicate it later?

dense root
#

I hate just watching a video, writing the code and not retaining the information/concepts

rich adder
#

repetition is key to retaining info

eternal needle
#

you need to experiment with it, change values, see what outcome it does. Try to understand what most functions actually do

#

A lot of tutorials really are just shit though, so be wary

faint agate
# rich adder maybe explain the mechanic of what you want to do

simply put
The redcircle game object is a target. I click, hold down mouse to drag down redcircle on the Y axis to hit a greencube. The player has to keep the crosshair on the redcircle in order to keep pulling it down and hit the greencube. I need the redcirlce to follow the crosshair going down on the Y axis as long as the crosshair is on the redcirlce.

#

I hope this makes sense, bad at explaining things

hybrid tapir
#

how do you prevent 2 bools from being active at one time in the inspector? like if there is bool lamborgini and benz, you cant have 2 favorite cars.

rich adder
summer stump
cosmic dagger
#

though, an enum is definitely better for this . . .

hybrid tapir
#

can an enum run without play mode? i want to make a big selection of bools for the inspector and if any of these bools are set to true, this other bool will be set to false if it was true and if the one bool is set to true, sets the other bools to false

cosmic dagger
summer stump
hybrid tapir
#

lmao

cosmic dagger
#

an enum displays a drop-down. only one value can be selected . . .

hybrid tapir
#

i should probably stop trying today

summer stump
#
public enum MyValues {
  X,
  Y,
  Z
}

public MyValues currentValue;
#

currentValue can only be x, y, or z (as written, there is a way around this, but that is not what you want)

rich adder
#

flags

#

think Layermask

cosmic dagger
#

i didn't mention flags or using bitmasks though. that's a different story . . .

rich adder
hybrid tapir
#

i know the way to just correct the bool at runtime, i was wondering if there is a way to run my if statements out of runtime

hybrid tapir
#

oh

#

thank you

hybrid tapir
#

how do i reference the bool in my struct from here

teal viper
cosmic dagger
#

then you can access the bool field of each extVals struct . . .

hybrid tapir
#

i saw this on stackoverflow but theres only an example void of how to add a value to the dictionary

summer stump
wintry quarry
# hybrid tapir

You would do:

foreach (KeyValuePair<int, extVals> pair in this) {
  int key = pair.Key;
  extVals value = pair.Value;
  bool myBool = value.fileBool;
}```
#

It's pretty unusual to be deriving from Dictionary in practice though

#

instead of just, for example having a Dictionary field

#

Also it's C# convention for type names to use PascalCase, not camelCase (extVals -> ExtVals)

cosmic dagger
#

honestly, i missed (skimmed over) the derivation from Dictionary. that's wild . . .

teal viper
hybrid tapir
#

isnt it funny this is how i just discovered what a struct is

summer stump
#

Is there a reason you chose that?

timid oriole
#

Hey guys I wanna learn code is there a full course where I can learn all the basics I know most of the theory behind coding just not the actual words lol

summer stump
#

Microsoft has a guide

#

And !learn, which is obviously specific to unity

eternal falconBOT
#

:teacher: Unity Learn ↗

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

timid oriole
#

awesome I'm going to look into that thank you

#

is it free im kinda poor

summer stump
#

All are free

timid oriole
#

awesome ty

hybrid tapir
# summer stump Is there a reason you chose that?

my intention was to hard code the values, somehow serialize the bools, and then use OnValidate to make sure that one specific bool is false when any of the others are true, and when that one bool is true, sets the other bools to false

summer stump
#

Which would not need all that extra work

hybrid tapir
#

i wanted to make it so that with any of the other bools, any amount of them can be set to true

summer stump
#

But then you need to deal with setting flags false. Certainly a lot easier and cleaner than with bools though

tall cliff
#

hey all I have no programming knowledge but I have to make a unity game for my scholarship that could grant full ride and it's due in about 3 weeks

#

I'm trying to adjust the center of mass of my car. How can I do so if the boxes are greyed out? (I used a script from a tutorial on youtube)

polar acorn
tall cliff
#

So there's no way to change them? I heard lowering the COM helped keep the car from flipping over

timid oriole
#

hello guys I'm very new but not to sure why I get error

queen adder
#

how to change tiling of a material again? I remember there's a specific code for this

queen adder
timid oriole
#

oh

queen adder
#

and the other one

timid oriole
queen adder
#

should just be if(x) and if(!x)

tall cliff
# wintry quarry From code

do I just replace the "com" in the script with the value? public class `ExampleClass : MonoBehaviour
{
public Vector3 com;
public Rigidbody rb;

void Start()
{
    rb = GetComponent<Rigidbody>();
    rb.centerOfMass = com;
}

}`

timid oriole
#

I don't fully understand sorry do you mind explaining

queen adder
timid oriole
#

Thank you I'm reading it now 🙂

polar acorn
timid oriole
#

Honestly not sure just learning code since 5 minutes ago haha

queen adder
timid oriole
#

I mean

#

I'm following a guide recommended by someone

polar acorn
timid oriole
#

Just curios how they interact with each other

#

Well to me it makes sense

#

idk

#

If applesauce is true say this and if its not true say that

#

I don't know coding but that's just how I saw it

tall cliff
#

I'm not seeing any setting in the script when I go back to unity to adjust the COM

queen adder
#

anyways, the () is important to look out for, it controls who can intereact with another

polar acorn
queen adder
#

im more worried with that semicolon tho lol 😆

real trellis
timid oriole
tall cliff
#

lemme try something rq

timid oriole
polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

wintry quarry
#

That' looks super weird

polar acorn
#

as long as whatever's in the if condition evaluates to a boolean

tall cliff
timid oriole
#

won't it evaluate it based on what I set it as for exmaple I said it was true so if I said if its true say this why didn't that work

tall cliff
polar acorn
tall cliff
#

I got an idea tho

polar acorn
queen adder
real trellis
tall cliff
#

I got a job

real trellis
#

okay so does nearly everyone here

tall cliff
#

Once I'm done with fixing the center of mass I'm just making levels and stuff

#

I can model all night

timid oriole
#

I guess what I read was wrong in the tutorial rip

tall cliff
#

CHAT I DID IT

queen adder
#

yes

timid oriole
tall cliff
#

YIPPEE

real trellis
#

hey man, good on you. good luck with your project - try to keep the scope of it small and simple! (i say this as someone who did modeling and art first and foremost)

tall cliff
#

one last thing though, my car is jittery now when I drive. How can I fix that

real trellis
#

what is the geometry of the ground like? is it terrain or something you'd modeled?

summer stump
tall cliff
#

it's a flat plane

#

I'll record rq

timid oriole
#

We confirmed I set it to true then if see's if its true no?

summer stump
summer stump
timid oriole
#

dang

summer stump
#

if (whatever == true) {
}

#

Not
if (whatever) = true

timid oriole
#

THAT

polar acorn
timid oriole
#

makes so much more sense

#

because

#

the condtion

#

should be in the if statement

#

not outside

#

Dumb mistake ty ❤️

tall cliff
#

ignore the colors that's just bc i'm bad at OBS lol

#

embed fail moment lemme convert it

timid oriole
#

Does anyone know why I'm getting error

tall cliff
polar acorn
tall cliff
#

like the last line

timid oriole
#

sorry

tall cliff
#

I'm no programmer though so dont take my advice lol

timid oriole
#

Uh I thought

#

could ends with } to close it

timid oriole
real trellis
timid oriole
#

but it didn't fix it

summer stump
#

The braces are not the issue

polar acorn
summer stump
#

Look at the last character on the if line

#

And reread how to write else if

timid oriole
#

they just said preview and add {}

timid oriole
summer stump
#

Character, not letter

timid oriole
#

Does it need a condtion but I thought I set the condtion above

#

I don't think it needs caps and the spaces look right

#

I'm not ending the code there either so idrk

summer stump
#

Look at the format of an if statement and compare it to yours

polar acorn
summer stump
#

Especially what comes between the ending ) and beginning {
Hint: nothing should go there

timid oriole
tall cliff
#

oop now my car is buttery smooth I just changed the interpolate value from "none" to "interpolate"

real trellis
#
{
    gamer = fuel;
    Debug.Log("hi");
} ```
#

oops bye guys i'm done for

summer stump
timid oriole
#

oop

spare mountain
summer stump
#
if (something)
{
  // do something
}

else if (something else)
{
}
timid oriole
#

ohhh

#

U would put the something else in the ()

#

So It would be console.writeline(") in the else if

spare mountain
#

() is for conditions

#

{} is for actions

polar acorn
summer stump
timid oriole
polar acorn
#

instead of else

timid oriole
#

Because it kept auto filling whenever I tried to use else

summer stump
#

You don't HAVE to use what it suggests

real trellis
timid oriole
#

Just got confused about how the statements worked

lavish magnet
#

If i want a 3d healthbar to be in my game above my player at all times, Just always facing the camera no matter what orientation the camera is in, how do i do this? Do i use a canvas

timid oriole
#

I tried chatgpt but I got the wrong answer from it

lavish magnet
#

==

#

true

timid oriole
#

shit

#

wait

cosmic dagger
#

= is assignment
== is comparison . . .

timid oriole
#

ignore that so sorry I set applesauce to a nubmer I meant to put potato in there

summer stump
#

There is no need to even do == for a bool.
Just If (boolVar)

#

Ah, it is not a bool. Ignore that then

timid oriole
timid oriole
summer stump
polar acorn
#

You need to give it a condition that evaluates to true or false

lavish magnet
timid oriole
cosmic dagger
cosmic dagger
lavish magnet
#

How do i make it always just face the camera, like theirs an option in particle system to always face camera

cosmic dagger
#

place a script on it, with code that allows it to always face the camera . . .

lavish magnet
#

I can do Transform.LookAt, but my characters rotation is very sharp and it bugs,

cosmic dagger
#

oh, so you already have the code. have it face what ever GameObject you want, and that's it . . .

lavish magnet
#

healthSlider.transform.LookAt(mainCamera);

#

I have that in Update, But my players rotation is instant ant sharp, w rotates it 90, s rotates -90 and it bugs a little bit

cosmic dagger
# lavish magnet

if the camera remains in this position, there is no reason to have it in 3d or rotate with the player . . .

#

just have it face the current view and move along with the player. i don't see a need to rotate it at all . . .

lavish magnet
cosmic dagger
#

also, the glitchyness is because the canvas is a child of the player. it should follow/track the player's position instead of being a child . . .

lavish magnet
lavish magnet
#

So in a seperate script, it shouldnt be a child, and ill just manually set it to follow the player in Update?

cosmic dagger
lavish magnet
#

I will read it

#

Why add ... to all your messages lol

cosmic dagger
#

that's how i type . . .

silk fossil
#

I have these vfx i wanna add to the "WROLSSHALSG" object

#

but its not working

teal viper
cosmic dagger
covert obsidian
#

I have this code for movement on a 2d sprite:

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


public class movemnt : MonoBehaviour
{
    public float jumpForce = 5;
    public float speed = 5; // Added speed variable
    private Rigidbody2D rb; // Declared rb as a class member
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        float moveHorizontal = Input.GetAxis ("Horizontal");
        
        rb.velocity = new Vector2 (moveHorizontal*speed, rb.velocity.y);
        if(Input.GetButtonDown("Jump")){
            rb.AddForce(new Vector2(rb.velocity.x, jumpForce));
        }
    }
}

(ignore jump)

When you go 1 direction for too long, it starts jumping a little. I'm unsure of why or how to disable it.
When you press both keys, it stops, as expected, but several things happen. When you release both and you press the key you pressed first, it doesn't move until you go backwards. It also gets buggy.

silk fossil
#

but now I know

#

from pin

#

so its alright

teal viper
teal viper
summer stump
#

And (I know you said ignore jump, but...) consider using ForceMode.Impulse for a jump

covert obsidian
summer stump
#

Show the inspector for the rigidbody

teal viper
covert obsidian
covert obsidian
teal viper
covert obsidian
#

The collider of the floor is at the bottom of the orange line, behind it.

covert obsidian
teal viper
#
  1. You should probably use a simpler collider, like a capsule or sphere. Colliders with corners can get stuck/stumble on a surface where 2 colliders meet.
  2. You can offset your visuals(sprite renderer) instead of the collider.
  3. It's likely that you are working with small scales judging from the size of the gap. I'd recommend not scaling your objects down too much. A character should be somewhere between 1 and 2 units ideally.
covert obsidian
#

imma try doing that and come back if issues presist

covert obsidian
#

idk how to scale it up properly

teal viper
#

This doesn't look like .2

covert obsidian
reef patio
#

Can I hire someone to help me with some coding for games, guidance with manuals I get, give me a tell and I can add you?

wintry quarry
covert obsidian
#

oh then it should be inbetween 1 and 2 right?

teal viper
# covert obsidian
  1. This is scale. Not the actual size of your character. Which means that your sprite is just huge originally. You should modify the units per pixel property of your sprite.
  2. You should avoid scaling rbs.
eternal falconBOT
reef patio
#

Ok ty.

#

!code

eternal falconBOT
reef patio
#

I was coding the whole thing over, and then this 1 error in the compiler had appeared to be a bit difficult, I want to finale it with you all hopefully.

eternal needle
reef patio
#

Is it just brackets?

#

No, I'm taking a tutorial.

#

To improve and get a certificate.

#

I seem to be getting into a multiplayer, that's basic and just leave it as experience made.

#

Theres 2 (die)'s.

#

both have no error

eternal needle
lavish magnet
#

why would this crash my game private IEnumerator HealthRegenerationCoroutine() { while (health < maxHealth) { health += (0.1f * regenSpeed); UpdateHealthSlider(); } health = maxHealth; UpdateHealthSlider(); yield return null; } 😭

#

In my take damage function i call it here HealthRegeneration = StartCoroutine(HealthRegenerationCoroutine());

eternal needle
eternal falconBOT
reef patio
#

i'll check the IDE, brb

eternal needle
# lavish magnet why would this crash my game ```private IEnumerator HealthRegenerationCorout...

its likely not crashing your game, just infinitely running (for whatever reason). your coroutine also does nothing here that a regular method wouldnt do.
In a loop it will instantly keep increasing the health by 0.1f * regenSpeed then call UpdateHealthSlider();.
If this loop ever finishes, it will set the health to max, then call UpdateHealthSlider();
THEN it finally waits for 1 frame before doing nothing

reef patio
#

IDE updated... probably needs more tuning, brb

lavish magnet
#

regenSpeed was set to 0

#

I am alsi using yield return new WaitForSeconds(regenSpeed); now

reef patio
#

ok it's updated

dense root
#

What's the difference between Lerp and MoveTowards? Are they similar in principle?

eternal needle
# lavish magnet I am alsi using ` yield return new WaitForSeconds(regenSpeed);` now

i would add a sanity check in that while loop as well to do nothing if regen speed is 0 or negative. Also this doesnt fully make sense that you are using regenSpeed in the WaitForSeconds. If your regen speed is 1, you heal 0.1 every 1 second. if its 0.5, you heal 0.5 every 0.5 seconds... same thing (assuming we ignore the imprecisions here)

eternal needle
# reef patio ok it's updated

your ide now should point out the errors, but in this case really just go through your brackets because you have extras. Errors will be near the brackets because theres code where there shouldnt be, according to the IDE

lavish magnet
eternal needle
reef patio
#

ok, ill keep you guys informed

#

bbl

eternal needle
lavish magnet
#

Yeah Sorry 😭

#

Should i swap the 0.1f and regenSpeed?

dense root
eternal needle
eternal needle
dense root
#

What is creating the smoothing in MoveTowards?

eternal needle
#

Nothing, what smoothing?

summer stump
#

Smoothing would be done entirely separately from both methods

lavish magnet
#

In the TakeDamage() function

summer stump
lavish magnet
#

Hmml,

summer stump
#

There is a StopCoroutine method

lavish magnet
#

Oh

#

if the corutoine is null tho, will it error?

summer stump
lavish magnet
#

Looks like this worked, Thank you! ``` if (HealthRegeneration != null)
StopCoroutine(HealthRegeneration);

    HealthRegeneration = StartCoroutine(HealthRegenerationCoroutine());
eternal needle
lavish magnet
#

i'm dumb

eternal needle
#

well that specific line doesnt need to exist, but yes at the very end

lavish magnet
#

dont answer that

#

Okay thank you

dense root
#

By updating an object’s position each frame using the position calculated by this function, you can move it towards the target smoothly.

eternal needle
#

Theres a difference between smoothing, and something moving smoothly. The docs are just telling you that MoveTowards can be used to make something move towards another object in a way that doesnt look its teleporting or stuttering

dense root
#

Oh I see

#

So how does it go about the smoothing then?

eternal needle
#

there is no smoothing

dense root
#

Oh okay lol

eternal needle
#

its always useful to just make a test script and debug what the values are, like print the result you get from MoveTowards if you give it a 0 vector, and try to move towards (1, 0, 0) for example. Change the max distance around.
Its not like the method will magically give you a different value than what you asked for because it thinks itll look better

dense root
#

yeah i'll go ahead and try that

slate haven
#

Hey Everyone,
I have a certain functionality that a lane can get removed out of the scene by scrolling downwards out of the scene. As you can see the items which are on the lane fully are no issue, as they leave the scene exactly when the lane leaves. But there are other items:

I want to handle these 2 situations such that the items which arent on the lane get destroyed immediately. The item partially on lane should be handled such that it doesnt look that its lying on the ground and lane as well. Its all about it shouldn't look absurd to the player

mighty marsh
#

When trying to build my project as a WebGL I kept running into errors and while trying to close an error message I accidentally closed the unity editor. When I reopened it I had a bunch of nullreferenceexception errors that dont make sense and I can't figure out how to fix, does anyone know what might have caused this? I'm not even able to move around in my game anymore.

wintry quarry
#

Probably just something wasn't saved

mighty marsh
#

Sorry this is my first project how would you debug any normal NRE error

mighty marsh
#

thanks

lavish magnet
#

[CreateAssetMenu(fileName = "New Gun", menuName = "Gun Data")]
public class GunData : ScriptableObject
{
    public string gunName;
    public int damage;
    public float fireRate;
    public enum FiringMode {SemiAuto, Auto }
    }
``` This is my scriptable Object class, But their is no option for it in my Create Menu?
wintry quarry
lavish magnet
#

None

wintry quarry
#

Show your asset menu?

lavish magnet
#

i also should mention that i have these settings enabeled.

rich adder
#

should not matter

rich adder
lavish magnet
#

That should work

#

Trying it now

#

Its there now!

rich adder
#

woo!

dense root
summer stump
#

you can add it via the inspector as well 🤷‍♂️

#

Ah, I see. The code is like that just so they don't have to explain that you need to add the component in SOME way.
You can do it via inspector, or in code. It doesn't matter. The example code simply chose to do it via code with addcomponent

#

They could have also done [RequireComponent(typeof(CharacterController))] and then getcomponent

#

That example code is not great honestly. It is preferable to combine all the vectors and only do ONE Move() call per update

dense root
#
void Start()
{
    controller = gameObject.AddComponent<CharacterController>();
}

void Update()
{
    Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
    controller.Move(move * Time.deltaTime * playerSpeed); 

    if (move != Vector3.zero)
    {
        gameObject.transform.forward = move;
    }

}

What am I doing wrong here I am trying to move the player left and right, top to bottom but it disappears into the void then reappears when I hit a key

lethal apex
#

i am having problem with vs code agan

#

does anyone know how to turn back the red wavy line again

#

idk what i did yesterday

dense root
#

!ide

eternal falconBOT
lethal apex
#

the red thing is not showing up

#

the error things

dense root
#

Yeah you gotta enable it

lethal apex
dense root
#

Checkout the link above

lethal apex
#

see there is no error

#

btw i still havent started programming in unity

dense root
tiny plaza
astral falcon
tiny plaza
#

what can i do then?

astral falcon
#

You cant do that. If you want your player to be assigned to the bullet, either have a player singleton in your script or assign your player as soon as you instantiate it

astral falcon
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

burnt vapor
#

Or spawn the player from the singleton directly, for example

#

There are multiple ways, mostly depends on your needs

astral falcon
#

You do not even need the player. Just rotate the bullet to the correct rotation when instantiating already and let it fly its own forward vector

tiny plaza
tiny plaza
astral falcon
tiny plaza
#

true the unity docs are so good

dense root
#
    void Start()
    {
        controller = gameObject.AddComponent<CharacterController>();
    }

    void Update()
    {
        Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        controller.Move(move * Time.deltaTime * playerSpeed); 

    }

I'm trying to move the character along both the X and Y axis top down style yet it just moves left and right, where did I go wrong?

tiny plaza
dense root
#

Tysm

tiny plaza
# dense root Tysm

don't forget to normalize your vector or your character will move faster diagonally

tiny plaza
#

you just type . normalized at the end of your vector

burnt vapor
leaden vector
#

Hi, I am currently having an issue with the "Loader" field getting removed when I press play. I have included parts of the scripts that might have made the problem.

languid spire
#

why line 16 (GetComponent) when the value is set in the inspector?

#

also the inspector value is set from the Transitions game object NOT the game object containing this script

leaden vector