#💻┃code-beginner

1 messages · Page 317 of 1

gusty dome
#

should be setup

short hazel
#

The error is now underlined

polar acorn
# gusty dome

Okay, it's underlined, that's what was missing in the last one

tender stratus
languid spire
short hazel
frosty lantern
#

how do I call a static member without an instance?

polar acorn
# gusty dome

So look at that line and see what's wrong with it. Hint: You cannot assign a value to the word float

tender stratus
#

it says assembly csharp not compatible

wintry quarry
#

You need to assign it first.
The syntax is fine.

short hazel
gusty dome
tender stratus
#

Works, thanks a bunch!

wintry quarry
polar acorn
gusty dome
#

ahh ok i think i see, sorry im tottaly in the deep end here

gusty dome
#

got it fixed thanks all, seems very simple now ive got it

short hazel
#

"identifier expected", basically it expected to see a (variable) name, but it found a = instead. That's how parsers work, they scan your input element by element and yells at you when it's not what they want

gusty dome
#

ahhhh ok cheers

blazing ruin
#

sup y'all. Anybody know why when I start to write void Update or void Start. And push tab, visual studio auitomatically type for this useless thing:

dusk cedar
#

how would i make something wait for like 3 seconds before doing the next thing "yield return new WaitForSeconds(3);" gives me an error

wintry quarry
wintry quarry
#

yield return new WaitForSeconds(3); is only valid inside a coroutine

dusk cedar
#

alr thanks ill look it up

#

ive been lost on this same thing like 3 times now

blazing ruin
short hazel
wintry quarry
blazing ruin
polar acorn
short hazel
#

Your screen recorder might be able to export as MP4 if you change the settings

blazing ruin
#

sup y'all. Anybody know why when I start to write void Update or void Start. And push tab, visual studio auitomatically type for this useless thing:

short hazel
rare basin
#

it's normal

polar acorn
#

That looks completely functional

#

What are you expecting it to do?

blazing ruin
rare basin
#

okaay, and?

blazing ruin
#

when i delete start and decide to write it again, it write me with private

polar acorn
rare basin
rare basin
#
private float x;
float x;
#

its the same

blazing ruin
rare basin
#

huh

eternal needle
#

This isnt a unity thing. It's a VS thing

polar acorn
#

But it really doesn't matter, and being explicit is almost always better than implicit

#

If anything the Unity template should be changed to add the private

blazing ruin
short hazel
#

You can modify the default "new script" template yourself to add these access modifiers, if you want

blazing ruin
#

can't find

short hazel
#

It's not in VS, it's from Unity directly

blazing ruin
blazing ruin
short hazel
#

Huh?

eternal needle
short hazel
#

Modifying code style preferences -> From VS
Modifying Unity's default template file -> From Unity

blazing ruin
short hazel
#

If you need to remove the default modifier on code completion, then this is done via the code style preferences in VS.
If you need to add the default modifiers to the auto-generated Unity script, then this is done via modifying the script template located in the editor's program files (https://blog.theknightsofunity.com/customize-unity-script-templates/)

rough dust
#

Sorry, not sure what channel this problem fits under, so please redirect me if this is the incorrect channel

I have an orthographic camera that looks at my minimap, a world space canvas group. And the camera feeds its frames to a render texture which is then fed into a raw image in my screen space canvas group. And just 5 seconds ago, it was working. But as you can see, it just stopped updating the texture. What could be the reason for this? Because in my code, nowhere does it make the camera stop feeding its frames. I don't even know if that's possible

short hazel
#

You seem to have the "Stop" button (top-center of the window) enabled, can that interfere with rendering?

rough dust
#

But yes, if I did pause it, that would interfere with rendering

short hazel
rough dust
#

Alright, thanks

stuck palm
#

what kind of stuff do you put in lateupdate?

rocky canyon
#

stuff that makes sense to run (after update).. like when things settle down a camera tracking script for example, maybe

eternal needle
stuck palm
#

awesome

rocky canyon
#

character animations (updating based on final state of movement/actions)
physics related operations (if u need to calculate stuff based on a final state)
input handling (processing and responding to input after all updates have been processed)

#

ive only ever written 1 or 2 scripts in lateupdate myself tho.. my code isn't structured that well lolio

eternal needle
#

All input happens before update, according to the execution order on the docs

covert cairn
#

How would one have the raycasts pivot while rotating similar to how the model does. I have a class that sets up some rays for firing and there are two sets in this example video.

public class Antenna
{
    public Transform agentPos;
    public Vector3 offset;
    public Ray leftRay;
    public Ray rightRay;
    public void InitializeRays()
    {
        leftRay = new Ray(offset + agentPos.position, -agentPos.right);
        rightRay = new Ray(offset + agentPos.position, agentPos.right);
    }
}
polar acorn
#

Maybe make a function (or property) that generates the left and right rays when you actually intend to use them

covert cairn
short hazel
#

Ray being a struct it may be actually more performant to not have them as fields, but as locals instead?

polar acorn
covert cairn
polar acorn
#

Your code already uses agentPos's orientation. You're just only checking it in InitializeRays

short hazel
#

Yeah in that case you must create them each time because the values you pass to it are computed once, they're not reactive

covert cairn
#

I guess I'm just not understanding what I'd need to change.

short hazel
#

Meaning if the position/rotation changes and you get the ray again (if it's a field), then there will still be the old position/rotation in them

polar acorn
covert cairn
covert cairn
# polar acorn Yes

Was this supposed to solve the issue, or was a code esthetics thing, because i'm still getting the same result.

polar acorn
short hazel
#

Pre-emptive layer mask mistake detection: make sure your enemyLayer variable is actually a layer mask, not a single layer number

polar acorn
covert cairn
#

Ohhh I think I may have asked the question incorrectly

#

I meant like they literally move as the box rotates

small mantle
#

How can a beginner in 2D AI, go about making an enemy that can chase the Player even when the Player jumps to higher ground? (No help needed for Horizontal Movement)

covert cairn
rich adder
#

but its not very dynamic

small mantle
polar acorn
#

Then you'd use one of those spots instead of agentPos

small mantle
#

The whole map is off of square Tilemap. If it works for that, then it should be enough

covert cairn
polar acorn
#

You could even make it so they all point forward or up in the direction you want, so you would no longer need leftRay and rightRay, you can have each ray just pointing in its own forward direction

rich adder
small mantle
rich adder
#

but this won't take into account complex pathing

small mantle
rich adder
summer stump
rich adder
#

like a* would help but being sideview introduces complexities than topdown say

small mantle
#

🤔 @rich adder Where could I look more in depth on the solution you gave?

rich adder
#

google the words together lol

#

pretty much need good amount of trajectory math

small mantle
rich adder
#

trajectory math

rich adder
#

its not direct code but more or less explains such an approach

small mantle
#

Thanks for sending more information. Really appreciate it 🫡 @rich adder

celest holly
#

hi there, idk why im getting this error, its at line 70 in my gun script

#

this is line 70 as it wasnt in the picture

rich adder
polar acorn
#

The bullet prefab should probably be of type Bullet so you don't need to use get component

celest holly
#

the bullet prefab is just a model of the prefab with a rigidbody and bullet script

#

newbullet does have the bullet script on it too

#

im confused

polar acorn
celest holly
#

okay ill try that

#

will that fix the problem though?

polar acorn
#

In that it will prevent you from attaching a prefab without that component on it, yes

brave acorn
#

can i make this so the run animation only kicks in when shift is held and the player gets a speed bost

celest holly
rich adder
polar acorn
#

Instantiate spawns an entire object

celest holly
#

like this?

polar acorn
#

The type just determines what is returned

polar acorn
celest holly
#

still no spawning

#

this is all my prefab is

polar acorn
#

Do you still get the error

celest holly
#

yeah

polar acorn
#

same one?

celest holly
#

69 now

#

theone above it

#

instantiate

polar acorn
celest holly
#

dont seem to be

#

ill check again

#

improvements

#

its spawning now

#

now i get an error on line 20

#

have i not grabbed gun correctly

polar acorn
#

Awake runs, then you set it. This shouldn't be in Awake

celest holly
#

right

#

ill look for a different function thne

rich adder
polar acorn
#

Or just use Start

celest holly
#

never heard of that,i was gonna use ienumerator

#

i havent coded for long in this language

#

start works?

polar acorn
#

Yes

celest holly
#

i thought start played before anytjhing else

polar acorn
#

Start runs before the first Update

#

Awake runs the instant this object exists

celest holly
#

oh okay

#

no more errors

#

thank you very much

#

so helpful

rich adder
torn edge
#

Hello can someone tell me why my mathf.clamp() is not working properly? Here is my code and logs https://hastebin.com/share/laqeqovite.csharp

celest holly
#

sounds useful

polar acorn
torn edge
#

Really?

#

Actually you're right wow

polar acorn
torn edge
rich adder
# celest holly ill look into inits later then

yeah basically something like this

Bullet bullet = Instantiate(etc..)
bullet.Setup(this);

//in the Bullet.cs
private Gun gun;
public void Setup(Gun gun){
    this.gun = gun;
    //setup rest of stats from awake
}```
torn edge
#

It doesn't work when I use if/else statements (for the same reason I think)

polar acorn
celest holly
#

thanks for showing me

rich adder
torn edge
celest holly
rich adder
polar acorn
torn edge
#

Like, I would need to check it before I convert it?

polar acorn
#

Clamping between 30 and 330 would get you if the number is above 30 or below 330

#

So since there's not an "inverse clamp" the best way to do it is to just do two checks

celest holly
#

mainly because i was using it for roblox lol

#

ive never gotten into modding

#

is it fun?

torn edge
polar acorn
rich adder
torn edge
polar acorn
torn edge
#

and then convert it?

celest holly
torn edge
#

So if it's between 0 and 20 or between 340 and 360

#

Wait convert it after?

waxen adder
polar acorn
#

then you check if that angle is below 20 or above 340

#

If it's not, then set it to whichever of those is closest

rich adder
torn edge
celest holly
polar acorn
celest holly
waxen adder
celest holly
#

like blueprints?

waxen adder
#

No, it's some old language unreal used

#

Like a decade ago now?

torn edge
torn edge
#

Wait

torn edge
celest holly
waxen adder
rich adder
#

I use events almost everywhere

#

very good for decoupling code

celest holly
#

another term im not sure on

#

what is decoupling?

rich adder
# celest holly what is decoupling?

gotta search what u dont know, from google:

When we say two pieces of code are “decoupled”, we mean a change in one usually doesn't require a change in the other. When you change some feature in your game, the fewer places in code you have to touch, the easier it is.

waxen adder
#

^ That gets important as your game's infrastructure gets larger. Idk how big that's gonna get for a beginner

rich adder
#

true but also best learning good practices early too

#

for example a score Logic script should have no idea about a UI score display script

#

UI Score script just "listens" to events thrown by the Score such as Updated score event to refresh the UI

celest holly
#

ahhhh i see

#

thats helpful though i get that

rich adder
#

imagine you put UI inside the score script too, now you need UI every time you want to test logic for score

celest holly
#

ive been doing that a bit but never knew thats what decoupling actually meant

#

isnt that kind of like interfaces too? with functions

rich adder
#

interfaces can help with decoupling sure

#

makes things more modular

celest holly
#

i love interfaces so much

rich adder
#

but yeah as beginner don't worry, its good making mistakes so we learn WHY something else is better to use instead

celest holly
#

thank you for the advice

torn edge
polar acorn
torn edge
#

Okay thanks

stuck palm
#

what does this mean?

#

like i know the value is null

#

but im unsure as to what value is null

#

and it wont show me what is null and where

grizzled zealot
#

Question on structuring audio for killing monsters; Do you:

  1. assign an audio source to each of the many monsters, each audio source with an instance of the asset audio clip, and then play the clip when the monster dies; or
  2. create one audio manager, and when a monster dies, ask it to spawn a new audio source at that location and play the clip; or
  3. create an audio manager with a pool of audio clips, and move a pool instance to the location of the dying monster; or
  4. something completely different that I haven't thought about.
frosty hound
torn edge
polar acorn
torn edge
#

But you said I needed to use two

stuck palm
#

i think its because they are set first then immediately turned off, which could be causing the error

polar acorn
#

You don't actually call Mathf.clamp, you do the math manually

torn edge
#

I thought you meant like actual mathf.clamp()

#

It works now so thanks

hollow slate
#

double-click the error, it should enter your IDE

#

you'll see what's null.

stuck palm
#

instead of start i did awake

#

fixed it

hollow slate
#

Just as a general guideline, you want to avoid using FindObjectOfType unless absolutely necessary. It's not a very great practice.

stuck palm
#

Yeah i know

hollow slate
#

I'm saying this as a general thing - if it works in your case that's fine.

stuck palm
#

it is absolutely necessary in this case

#

i guess the object was inactive at start time

#

so doing it in awake fixed it

wintry quarry
#

Seems like you could just use the Singleton pattern for this

eternal needle
#

it definitely doesnt look necessary here. dont these objects both exist just in the scene? You could drag it in. Or use singleton

stuck palm
#

so idk if singleton would work

hollow slate
#

that should be fine.

wintry quarry
stuck palm
#

but multiple in a session

wintry quarry
#

Just not DDOL Singleton

stuck palm
wintry quarry
#

The basic form of Singleton just has the static accessor, DDOL isn't required

hollow slate
#

what's DDOL?

#

abbreviation for...?

wintry quarry
#

DontDestroyOnLoad

hollow slate
#

ah

stuck palm
#

althought i recognise it is better practice to use a singleton in this case

frosty lantern
#

If I have an instance variable in my abstract class, why doesn't the inherited class include that in it's scope? I can only modify baseclass in the Awake/Start... methods, but not in the variable declaration area.

timber tide
#

usually you modify parent variables in the constructor but since you can't really use one with monos that's why you're usually using awake or start

#

or make a custom initializer method

frosty lantern
#

ok, I guess that makes sense.

polar acorn
#

You can't override things in the declaration

cosmic dagger
#

also, you're missing a Vecttor3Int in one of those lines . . .

frosty lantern
#

i wiped the rest of them too

cosmic dagger
cosmic dagger
frosty lantern
frosty lantern
#

For some reason, my knight class thinks it's special, because it isn't creating the polys it's meant to. I am calling the exact same method on all of the classes in the same manner, and I've even setit up so that the instantiating of the poly is done in the abstract class that's inherited by the subclasses just to ensure a consistent result.

Of course, everything was consisten except for the horsey.

wintry quarry
#

Debug.Log to double check that

#

or perhaps we're looking at the wrong code

#

!code is a better way to share

eternal falconBOT
frosty lantern
# wintry quarry !code is a better way to share

https://gdl.space/egumehujoj.cs

You are correct, that the debug.log is saying hexmoves is empty. In fact I debugged the start method of the knight:

https://gdl.space/wiwabayebi.cpp

And it's not even adding the vector3ints. It' s just ignoring the assignment.

I am calling the instantiate method the same way for all of the classes, though the abstract parent class:
https://gdl.space/epoyetazud.cs

the CubetoQuad is for thoroughness
https://gdl.space/igowiqiwet.cs

#

my bad on the code flood tho

#

what's really messing me up is the fact that my program is literally ignoring me

wintry quarry
#

It's unclear where InstantiateMovePoly() is defined

frosty lantern
wintry quarry
#

why not just include it there O.o

#

showing the full scripts may help

frosty lantern
#

that's the full chesspiece method

wintry quarry
#

and Knight?

frosty lantern
#

there isn't much in there

wintry quarry
#

Ok so this logs what exactly again?

#

like what does this log?
Debug.Log(name + "\n" + basicHexMoves.Count);
and
Debug.Log(name + "\n" + basicHexMoves.Count + "\n" + moveIndicators.Count);

frigid sequoia
#

What's the difference between a trigger and a boolean as an animator parameter?

#

Aren't they both just a toggle?

timber tide
#

trigger is once

#

boolean is toggle

frigid sequoia
#

Oh, so trigger cannot be dissabled after called once?

timber tide
#

it's for like one-time attack animations

#

any one-off animation it's useful for

frosty lantern
# wintry quarry like what does this log? `Debug.Log(name + "\n" + basicHexMoves.Count);` and ` D...

Debug.Log(name + "\n" + basicHexMoves.Count);
The log in the knight statement verifies the length of the knights hexmove list. It's right after the assignment so I can verify that the assignment happened correctly

Debug.Log(name + "\n" + basicHexMoves.Count + "\n" + moveIndicators.Count);
The log at the end of the InstantiatePoly() method verifies the length of the hexmove list for all pieces and verifies how many move polys I create for each of them.

frigid sequoia
timber tide
#

ye, got to probably add some exit time to them too so they don't fallback to your other animation state instantly

wintry quarry
#

not what they do

frosty lantern
#

The assignments fail immediately in the awake method, which leads to empty lists for them in the instantiate method

frigid sequoia
wintry quarry
#

it's because you have a semicolon here

frigid sequoia
#

If I want for them to transition from ANY point of the idle state to the attack state, I have to dissable exit time right?

#

Else it waits for the end of the loop isn't it?

wintry quarry
timber tide
frosty lantern
# wintry quarry it's because you have a semicolon here

that's the first time I've put a semicolon that wasn't supposed to be there. usually I forget to put them where i need them.

Do you happen to know why the code doesn't throw an error when declaring a bunch of new lists without identifiers, since the semicolon was separating them?

wintry quarry
#

A real collection initializer uses commas and curly braces:

List<Cat> cats = new List<Cat>
{
    new Cat{ Name = "Sylvester", Age=8 },
    new Cat{ Name = "Whiskers", Age=2 },
    new Cat{ Name = "Sasha", Age=14 }
};```
frosty lantern
#

oh, cool

frigid sequoia
timber tide
#

yeah but if it's a trigger animation without exit time I'm pretty sure it falls back into the previous state instantly without it or maybe im mistaken

#

I usually just try to use booleans if possible since I like that control better

fiery notch
slender nymph
#

not everything in the hitEnemies array has an Enemy component

fiery notch
slender nymph
#

if those objects are on whatever layer is included in the raycast, then yes. you'll want to use TryGetComponent to check if the object has the component if you don't want to change the layers on those objects

#

also consider using the NonAlloc version of the query to reduce your garbage generation

fiery notch
#

each child object under enemy has the enemy tag

slender nymph
#

it's the layer that matters, you're not doing anything at all with tags

fiery notch
#

sorry

#

i mispoke

#

they all have the enemy layer

slender nymph
#

yes, i gathered that. hence my suggestions

fiery notch
slender nymph
fiery notch
#

im looking at it, im still confused on how it works

deft grail
#

the doc shows exactly how to use it, should be easy to implement into your script

fiery notch
#

i am just lost on what to replace in my script

deft grail
#

thats what your replacing

fiery notch
slender nymph
#

did you not look at how it works

deft grail
#

the docs for GetComponent and TryGetComponent are completely different

fiery notch
#

i just dont get it

#

idk what else to say

frigid sequoia
#

Can I check if a local parameter already exist before creating it?

deft grail
#

literally

fiery notch
#

ok

rich adder
deft grail
# fiery notch

idk why its in the start method, anyway now change it to your components

slender nymph
fiery notch
deft grail
#

cant do it from nothing

slender nymph
#

you also need to call TryGetComponent on the colliders in the array, not on this component

deft grail
#

again, look at the code in the documentation

#

how they use .useSpring = false;

frigid sequoia
# frigid sequoia Can I check if a local parameter already exist before creating it?

Like let me explain, I have a parent general class for enemies that gets the player position in Update and sets other basic stuff with it. I want all that to happen AFTER some modifications in the Update of the specific enemy (that also need the player position), so I am calling base.Update() after that but I don't want to calculate the player position once again at the base.Update() if I already did before, is there a way to do this with a variable inside update itself or it NEEDS to be a class parameter for that?

fiery notch
deft grail
#

you definitely should take a beginner C# course

fiery notch
#

im in one now, but ive never dealt with trygetcomponent before

rich adder
timber tide
#

because your 'base' update will always call the most derived method if it's overriden

buoyant thistle
#

I am trying to add a force that would push my object forwards depending on the angle its rotated

#

2d btw

#

but i can only seem to get it to go straight up and im not quite sure how the addforceatpostion function works

deft grail
buoyant thistle
#

void Update()
{
if (Input.GetKey("w"))
{
rb2d.AddForce(Vector2.up);

    }
}
deft grail
buoyant thistle
#

ohhh

#

thank you

#

I have another question, right now im using addtorque to change the rotation of my player but how can i do it where it stops immediatly after i stop changing the rotation and not continue to rotate

frosty lantern
#

Debug.Log("( ${x}, ${y}, ${z})");
how do I get the values from variables like this?

slender nymph
#

Dollar sign goes on the string, not in it

frosty lantern
frosty lantern
#

thanks

eternal needle
#

Do you need to use add torque? Usually it's fine to just directly affect the rotation with the values you want especially if this is just a capsule.
Otherwise you can set the angular velocity

fiery notch
#

just wanted to say i figured it out, thanks for the advice

frigid sequoia
#

If I want this to Translate locally I have to pass it the parent right?

timber tide
#

I'd do a tryitandsee considering that second parameter there

frigid sequoia
#

Is kinda hard to see with what I am trying rn, but sure

#

This is the pattern I am seeking, which I assume is best done if I just parent every bullet to an spinning empty parent and move them forwards locally

#

Is it? XD

timber tide
#

sounds probably right then

#

transform.foward is always considerd relative to itself such that it's a direction its forward direction is pointing to

#

such that you should just be able to refer to its forward and use world position local/absolute units to go in the direction it's facing

frigid sequoia
#

Is basically that the world itself is the parent if there is none given

timber tide
#

eh, I don't really think of it that way. Tranform.Forward just uses the object's orientation as is, such that you can create a direction from the coordinate system its composed of

#

so no matter where it is in the world, transform.forward will always just go in its own forward direction

#

I don't really use transform.Translate but it sounds like you just refer to is own object space and then use absolute units

#

otherwise you do something like transform.position(Transform.forward * speed * deltatime)

summer stump
grizzled zealot
#

What can cause this? I have gameObject.SetActive(false) in a MonoBehaviour, and it only deactivates the current script, not all the GO's scripts and the children.

worldly ravine
#

I need help fixing this i have no idea how this works

#

Assertion failed on expression: 'CompareApproximately(SqrMagnitude(result), 1.0F)'
UnityEngine.Quaternion:Internal_FromEulerRad (UnityEngine.Vector3)
Test:Update () (at Assets/Test.cs:28)

#

float angle = Mathf.Atan(rb2d.velocity.y / rotate) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));

#

nevermind It's because i forgot to set the variable rotate to something

summer stump
summer stump
topaz mortar
#

Deactivating a GameObject disables each component, including attached renderers, colliders, rigidbodies, and scripts.

#

so it would deactivate the scripts on the GO

#

but the children should become inactive too yeah

summer stump
#

They are saying it is ONLY deactivating the script

grizzled zealot
# summer stump Hmmm, that should not deactivate a script. Just the gameobject. And if it has ch...
   void Update() {
        if (_hasHit) return; // spurious
        _life += Time.deltaTime;
        if (_life > _pld.Lifetime.Value) {
            gameObject.SetActive(false);
        }

        RaycastHit2D hit = Physics2D.Linecast(transform.position,
            transform.position + Direction * _lookforward * Time.deltaTime,
            (1 << LayerMask.NameToLayer(UnitManager.LAYER_PLAYER)) | (1 << LayerMask.NameToLayer(UnitManager.LAYER_ENEMY)) | (1 << LayerMask.NameToLayer(UnitManager.LAYER_NEUTRAL))
            );

        if (hit) {
            if (hit.transform.gameObject.TryGetComponent<HealthCapability>(out HealthCapability hc)) {
                _hasHit = true;
                enabled = false;

                transform.position = hit.point;
                transform.GetComponent<Rigidbody2D>().velocity = Vector3.zero;

                hc.DecreaseHealth(_pld.Damage.Value);

                // show explotions
                Instantiate(_pso.explosionPrefab, transform.position, Quaternion.identity) as GameObject;
                // play audio
                AudioSource audioSource = gameObject.GetComponent<AudioSource>();
                audioSource.clip = _pso.soundExplosion;
                audioSource.spatialBlend = 1f;
                audioSource.maxDistance = 100f;
                audioSource.Play();

                gameObject.SetActive(false);
            }
        }
    }
grizzled zealot
#

Btw. I understand that deactivating right after Play() means that the audio clip is not played.

topaz mortar
#

show your hierachy of gameobjects (where it shows which ones are active and not active) after this is called

grizzled zealot
#

object pools are fun

willow nexus
#
    {
        if (outlineColor == Color.white)
            return;
        outlineMaterial.SetColor("_Color", outlineColor);
        outlineMaterial.SetFloat("_Thickness", highlightedThickness);
        outlineMaterial.SetFloat("_ColorOverlayActive", 1f);
    }

    private void OnMouseExit()
    {
        outlineMaterial.SetFloat("_Thickness", defaultThickness);
        outlineMaterial.SetFloat("_ColorOverlayActive", 0f);
    }```

Any idea why this would be causing my object to flash?
topaz mortar
grizzled zealot
topaz mortar
willow nexus
#

that first bit was so if i dont apply an outline color with item rarity it just never enables the outline

i disabled any other scripts that could interfere i think, ill check again

#

it grabs the outline color from the scriptable object so the color.white (default) is just so it doesnt do weird stuff if i forget to set it

topaz mortar
#

but the return prevents the rest of the OnMouseEnter to execute

devout spire
#

for some reason when i press the console key and call RunCommand, it is not able to match the command entered to one of the commands in the array. it will log in the console the "no such command" message, and even include the command in the message that should be getting found successfully but for some reason isn't.

using System.Collections.Generic;
using System.Data;
using Unity.VisualScripting;
using UnityEngine;
using TMPro;

public class ConsoleController : MonoBehaviour
{
    [Header("Keybinds")]
    public KeyCode consoleKey = KeyCode.BackQuote;

    [Header("Command List")]
    public string[] commands;

    [Header("References")]
    public TextMeshProUGUI commandLine;

    bool showConsole;

    void Update()
    {
        if(Input.GetKeyDown(consoleKey))
        {
            RunCommand(commandLine.text);
        }
    }

    public void RunCommand(string command)
    {
        foreach(string s in commands)
        {
            if(s == command)
            {
                Debug.Log("Command Found! Command: " + s);
                return;
            }
            else if(s == commands[commands.Length - 1])
            {
                Debug.Log("No such command '" + command + "' found!");
            }
        }
    }
}```

that is my full class, not sure what's going on
#

i will note that for some reason, if i manually set command to one of the commands in the RunCommand function, it works correctly. but it doesn't work correctly when getting the string from a tmpro input object

eternal needle
#

as for why its not working, try printing out the actual results like
Debug.Log($"Command {command} Comparing to {s} Result {s == command}");

willow nexus
devout spire
eternal needle
#

not entirely sure how tmpro handles that stuff, but some basic debugging should've pointed you towards that the input was flawed

#

also, you can do if(commands.Contains(...)) using Linq

verbal dome
#

The text object in input field has an invisible character at the end of its string

#

That's why your string comparison wasn't working when you were using the text from text object instead of the input field

devout spire
#

ah

#

thanks

brazen canyon
#

Hey guys, I wonder what if I serialize a list of scriptable objects into json.
And when i deserialize it, what do I get ?
Say i have a class

public class Demo : ScriptableObject
    public List<DataSO> listOfLust;

After deserializing, do I still get a list or what ?

onyx tusk
#

how 2 fix this text? autosize is already true

timber tide
#

and yes, you can serialize scriptable objects usually

timber tide
# brazen canyon Thanks

Though, you don't actually want to deserialize/serialize SOs but rather you should be id-ing them and grabbing the pre-defined instance from your assets. Assuming you aren't writing to your SOs

feral moss
#

So my goal is just to program Minesweeper so I can figure out the basic tools because I already know how to make the actual algorithm for generating a Minesweeper board
I've run into 2 snags though:
I need a way to have the camera size up enough to capture the whole board regardless of the size up to the max size I'll allow,
Second, I'm running into an issue with the board... losing detail when the camera gets large enough I think?

#

Here's the board 9x9 with camera orthographicSize 5

#

It looks a little trippy because I slapped the sprite together in like 5 seconds

#

Here it is 13x13 with size 7 though

#

Some of the lines are losing visiblity, and the problem worsens as the camera gets larger

timber tide
#

is it a texture? Could be mipmaps related

onyx tusk
#

stop, i understoodproblem

feral moss
#

I have a GridManager object that uses a Tile prefab object I made, and that Tile object has a SpriteRenderer with a 1200x1200 sprite scaled down to 0.09 in all dimensions

onyx tusk
#

maybe, you will make some lines above field?

feral moss
#

Like... have the lines be separate objects from the tiles?

timber tide
#

I would just tile a texture and use the tiling and offset values of a shader

#

usually they comes with unity's default shaders

onyx tusk
#

& image will become a material

timber tide
#

sprite import probably has some similar options if you don't want to do it via shader I guess

#

shader stuff just easier to manipulate at runtime

feral moss
#

I just didn't know it was an option and I'll need to research how to do it

timber tide
#

I think the idea here is you shouldnt be moving the camera, but you should be tiling the texture differently

feral moss
#

It does sound like a better plan for retaining detail I imagine

#

I'll give it a shot

#

Thanks

timber tide
#

that would probably be the sprite way to tile, or just use repeat/wrapping mode?

#

https://learn.unity.com/tutorial/shader-graph-tiling-and-offset-2019-3
otherwise this node is on most unity shaders in the material options (or include it in your own shader if you want)

Unity Learn

There will be times when you want to manipulate the UVs, tiling or offset of your Textures, normals or results of a gradient. This is when the Tiling and Offset node becomes useful. In this tutorial you will learn how to use the Tiling and Offset node.

faint osprey
#

Script error: OnTriggerEnter
This message parameter has to be of type: Collider
The message will be ignored.
why am i getting this error

#
    {
        if (other.tag == "Pickup")
        {
            Debug.Log("woking");
            endOfConveyor = false;
            approve.interactable = true;
            deny.interactable = true;
            baggageInScanner = other.gameObject.transform.parent.gameObject;
        }
    }``` thats the method its talking about
charred spoke
#

Well what do you think the solution is ?

faint osprey
charred spoke
#

Think a little about the error msg. It says it should be of type Collider, not any type of collider.

#

Collider and BoxCollider are not the same type.

faint osprey
#

But i need to distinguish between box and sphere tho as i have more than one on the gameObject

topaz mortar
#

Ah Uri, you never told me how to send my data over the network if not in a dictionary.
Why is it bad to use a dictionary and what is the alternative?

timber tide
#

list of structs

charred spoke
faint osprey
topaz mortar
timber tide
#

bulk of what I send over networks are usually just ids

#

some vectors and whatnot... but im talking about a crappy vampire clone and shooter arena ;)

languid spire
charred spoke
# faint osprey Yos

I would just separate the triggers into their own gameObjects and have a script for each

charred spoke
# topaz mortar but how do I send less data then 😦

Like I said you would send a itemId and the relevant generated stats. Anything that is not random the client can reconstruct when creating the object on his side for example having the item start with 100% durability.

topaz mortar
#

yeah that's what I'm doing, it's just structured in a dictionary

charred spoke
#

I believe last time we talked you were sending pretty much the entire item serialized as json.

topaz mortar
#

yeah because there's a lot of generated stats on the item

eternal needle
#

surely other players can also generate the same thing then

topaz mortar
#

it's multiplayer, needs to be generated by the server

eternal needle
#

definitely not

charred spoke
#

Look if it aint causing network traffic issues and it works it works right hah. I suppose generating items is a rate enough event.

topaz mortar
#

I just thought there was something wrong with sending a dictionary structure over the netwerok

charred spoke
#

Depends on your dictionary I suppose

eternal needle
topaz mortar
hot lily
#

how do I make cinemachine camera orbit around a target?

eternal needle
hot lily
#

i've been fiddling with this the whole day but the camera just refuses to do so

topaz mortar
eternal needle
topaz mortar
#

I'm saying it doesn't matter if they modify it client side, because everything happens on the server and the server doesn't accept any client data

eternal needle
eternal needle
topaz mortar
#

because I want to display the item data to the user? 😛

eternal needle
#

When you say items are generated, you mean randomly right?

#

Or these are all just preexisting items already declared

topaz mortar
#

damage for example is randomized between certain values yeah

#

all the stats are

eternal needle
#

then whats stopping you from just sending the user the seed and having them generate the item data with the same algorithm the server used?

topaz mortar
#

that is actually a really great idea

eternal needle
#

That is what ive been saying from the start

topaz mortar
#

thanks for explaining it 🙂

timber tide
#

your server should be generating everything and giving it back

#

unless you dont* really care about clients bsing about getting the best rolls possible

eternal needle
#

theres really no difference in this case

#

i vaguely remember what they were doing but i believe it was creating a json string from their item information. which was like a dictionary in a dictionary or something.
Theres literally no difference if someone wants to modify that string compared to modifying the seed they receive

timber tide
#

you'd still verify it, not like when you smack a mob the server does going to look away when the client hits it for 1000k damage

topaz mortar
#

yeah it's a dictionary containing 2 dictionaries
one for the combat and one for the items dropped
but in both cases I can just send the random seed and then let the client calculate it by itself
should solve a lot of my issues 🙂

eternal needle
# timber tide you'd still verify it, not like when you smack a mob the server does going to lo...

that verification still doesnt affect if the client or server generates something. its really nothing if the client generates something wrong intentionally while the server has its own correct copy. Because itll be using the correct information in damage and other things.
Ive played a few games where they really dont care what you have or see client side, because its not like you can do anything with it. I've tried a lot to actually do something with it too, but the game just didnt care

topaz mortar
timber tide
#

seems like that would cause a lot of desync issues

#

idk, i'd just ask the server hey, I'm rerolling my weapon mods can you do it for me

eternal needle
#

to be fair, you cant really complain about desync if you're trying to hack

topaz mortar
#

only way there's desync is if the server & client have different generation methods, which I guess could happen lol

eternal needle
#

The 20 year old game osrs has massive desync issues, that you kinda have to intentionally cause. they really dont care, you just get booted off when that desync eventually causes an error clientside

#

other competitive games have it too, which arent intentionally caused but sometimes by lag. Nothing you can really do. Best not to worry about hackers unless you're making the next valorant

topaz mortar
#

bawsi is there a simple way to use one random seed to generate different randomized results?
say we fight a monster, I need player damage, monster damage, experience gained, item dropped
can I easily use 1 seed or would it be better to send 4 random seeds?

burnt vapor
burnt vapor
#

If you use a set seed then the result will be the same each time

#

Nowadays there's Random.Shared for a shared random class because there's no point in having 4 different classes for randomization

#

IDK if that is in Unity though

eternal needle
topaz mortar
#

ah there's no real multiplayer, the clients do not communicate with each other, only with the server

#

and not all that often really

native seal
#

how should I setup skill trees to work alongside the UI? should I just handplace every ability in the tree for each class and then just activate whichever class the player is? or are there any better suggestions

topaz mortar
#

I think I'm not exactly following, atm I'm just doing stuff like Random.next(0, 100)

burnt vapor
#

Yeah that's Unity's build in Random

eternal needle
burnt vapor
#

There's two, idk why Unity has one

eternal needle
eternal needle
#

depends more so on how the player even stores abilities

timber tide
#

or go half way and handcraft a reusable template

terse raven
#

Would splines or a grid system be more efficient in making a conveyor belt system?

topaz mortar
eternal needle
topaz mortar
#

would it work with parameters if I want to generate a number between certain values?
like mindmg = random.next(1,10)
maxdmg = random.next(500,600)

verbal dome
burnt vapor
#

So the whole point of it is to have a static reference to an existing feature? I'm confused

#

Because I was looking it up and apparently it was it's own generator to some people

topaz mortar
#

The point is to have my server generate the random number (or numbers or seed)
and then generate a lot more numbers based on those on both my server & client

verbal dome
#

I'm saying that it is System.Random.Next, nothing to do with UnityEngine.Random

burnt vapor
#

Then I got confused because he capitalized the wording, assuming it was some static class

#

Either way my point was that I don't see why Unity would have its own Random to begin with 🤷‍♂️

topaz mortar
#

probably slightly faster, optimized for games

#

I don't care about which Random class I use though
I'm just using System.Random.Next atm because my server is C#, not unity

verbal dome
#

Unity Random also has a bunch of useful features for gamedev, such as insideUnitCircle/Sphere

eternal needle
topaz mortar
#

awesome 🙂

onyx tusk
#

how 2 fix this text? autoFontSize is already true

burnt vapor
whole idol
#

Why does this script have a screw nut symbol

#

rather than a script symbol?

#

SUS

green ether
whole idol
#

ok

green ether
#

just a fancy icon for that class

whole idol
#

First time I see something like this

#

hopefully it wont cause any problems later on

tepid summit
whole idol
#

yeah whatever

#

😛

tepid summit
green ether
#

I have a GameManager aswell and mine didnt get that icon for some reason... In the other project I have it does though

#

Why is that

topaz mortar
#

🔩 u

whole idol
#

unity's trolling you

#

maybe its an easter egg or something

verbal dome
#

Static random class can be useful, though I often find a need to use instances so that's when I use System.Random

burnt vapor
#

Suppose it mostly boils down to convenience then. I wondered if there was an actual reason apart from that

eternal falconBOT
tepid summit
#

ok

#

damn i need to bookmark these

naive pawn
#

you can't get uniformly distributed integers (easily) with UnityEngine.Random since it's closed instead of half-open

tepid summit
rare basin
#

maybe show the code?

naive pawn
#

for the first one, maybe follow what the error says to do

tepid summit
#

yeah my bad forgot to paste the link

rare basin
#

UILink = UILink2.GetComponent<UIHandler>;

#

UILink is type of GameObject

naive pawn
#

yeah the error tells you exactly what to do

rare basin
#

and you are trying to assign UIHandler to it

tepid summit
#

ok

rare basin
#

you can just read the error

#

it's exactly the same i wrote

tepid summit
#

yeah idk what to do to my code

naive pawn
tepid summit
#

ive tried a million and 1 solutions

naive pawn
#

did you try the one the error tells you to do, first off

rare basin
tepid summit
#

it doesnt

naive pawn
#

GetComponent is a function, you didn't call it

tepid summit
#

or im dont get it at least

naive pawn
#

right, but it's a step in the right direction

rare basin
#

you cannot assign UIHandler

#

to GameObject

#

it's a type mismatch

tepid summit
#

right i need the parenthesis

naive pawn
rare basin
#

ok so?

#

it's still an error

#

that needs to be fixed

naive pawn
#

not the current error

tepid summit
#

not currently

naive pawn
#

one step at a time my guy

rare basin
#

it is

#

it wont even compile

#

he didint even screenshot the entire console

naive pawn
#

i don't think you registered what i said

rare basin
#

im not talking to you please carry on

naive pawn
#

it's not the current error. the current error is that the function wasn't called to begin with. fix that, and get the new error, the one you're referring to, with a more helpful message

tepid summit
#

damn

#

my brother got hit with the clown reaction

rare basin
#

is your ide configured?

tepid summit
#

pretty sure

rare basin
#

can you screenshot it just to be sure?

topaz mortar
#

so no probably lol

tepid summit
#

one sec

naive pawn
#

once you've added the function call, you'll be able to see another error that you're trying to assign UIHandler to GameObject

you've declared UILink as GameObject, but you're trying to set it to a UIHandler, and you're trying to use it as a UIHandler, so you haven't declared it with the type you actually want it to be.

tepid summit
#

making it a gameobject was just a test as when i had it just as uimanager it still made errors

#

just explaining

naive pawn
#

UIManager != UIHandler though

#

you're trying to use it as a UIHandler, not a UIManager

tepid summit
rare basin
#

find what?

#

screenshot your code

tepid summit
#

ide

topaz mortar
rare basin
tepid summit
#

i know ho toscreenshot

rare basin
#

so screenshot

#

your code lol

tepid summit
#

you asked me to ss my ide

rare basin
#

do you know what is ide?

#

doesnt look like

tepid summit
rare basin
#

you dont

naive pawn
tepid summit
#

integrated development environment

rare basin
#

so why can't you screenshot it

tepid summit
rare basin
#

i asked you to screenshot your CODE

naive pawn
#

you were asked to screenshot your ide, not your ide config

rare basin
#

i want to see if your ide is configured

#

i dont care about your ide config/settings

tepid summit
topaz mortar
#

can we dial down the rudeness a little pls?

rare basin
#

that just proves

#

you dont understand what is ide

tepid summit
rare basin
#

screenshot your code please

#

as asked already

tepid summit
#

ok

rare basin
#

yup, it is not configured

topaz mortar
#

!ide

eternal falconBOT
rare basin
#

!ide

eternal falconBOT
vapid tendon
#

Is there info on what order Update()s are processed?

Context (not a problem, I solved it, but I want to understand it more):
I had a 2D camera follow a player, with this logic (pseudo code):

// player
void Update(){
    transform.position = new Vector3(...);
}
// camera
void Update(){
    tranform.position = playerObject.transform.position;
}

There was jittering when I tested this.
I googled about it, saw some people say use FixedUpdate instead. So I tried that, it helped with the jittering (but didn't completely solve it), and also like now movement is 60fps on my 165hz monitor, it looked slightly off.
Then I remembered LateUpdate exists, I move the camera code to LateUpdate and it worked like a charm

nimble scaffold
#

please help me fix this

rare basin
#

basically camera operations should be called in LateUpdate

#

after the player changes his position

vapid tendon
tepid summit
nimble scaffold
naive pawn
vapid tendon
#

I just want to know more about order of operation.
Is there any logic to the order of different scripts' Update() calls, or is there no particular order one can rely on (treat it as if it's random order)?

rare basin
#

in script execution order

nimble scaffold
#

anyone??

naive pawn
topaz mortar
#

I think Update() functions are completely unrelated, so there's no order, but not sure

rare basin
#

that you can set

nimble scaffold
#

anyone please help solving this issue

naive pawn
rare basin
nimble scaffold
nimble scaffold
tepid summit
#

nothing changed

topaz mortar
tepid summit
#

give it a minute

rare basin
naive pawn
nimble scaffold
topaz mortar
# rare basin in MonoManager, script execution order

doesn't seem like it's mean for the Update function though?
Would you be able to make a specific Update function of one script consistently run before/after another one?
Wouldn't it depend on the time it takes the function to run?

twilit cliff
tepid summit
naive pawn
naive pawn
tepid summit
#

when i followed the steps to configure

#

nothing in vs changed

nimble scaffold
burnt vapor
#

VSCode's configuration is annoying

stiff fjord
#

i figured it out nvm

burnt vapor
#

Either way your syntax should be properly highlighted so if this is not the case follow the steps again and perhaps try a restart

twilit cliff
hot lily
naive pawn
eternal needle
naive pawn
#

maybe you could add some variance to the spawning to make it improbable to spawn in the same place?

eternal needle
twilit cliff
naive pawn
#

that looks smaller, perhaps it's having some floating-point stuff so it's not perfectly aligned

eternal needle
hot lily
twilit cliff
eternal needle
hot lily
#

nvm figured out why#

burnt vapor
#

The physics makes sense here

hot lily
#

in my infinite wisdom i might have accidentally clamped the camera and prevented it from moving at all

burnt vapor
#

It's just super perfect here with where it lands which is unrealistic

eternal needle
eternal needle
# twilit cliff

That's weird, I wouldnt really expect this with circle colliders but I dont do 2d. Maybe try to play around with the settings like a higher bounciness

#

Obviously can be done with code solutions but you mightve missed a step when following the tutorial. That part is more concerning to me that it's not acting exactly like a video you're following

twilit cliff
naive pawn
twilit cliff
naive pawn
#

it could be so small as to be unnoticable, just so they aren't perfectly aligned

#

a gaussian distribution perhaps, but even a uniform distribution in [-0.001, 0.001] would probably be fine

twilit cliff
native seal
#

is it preferable to have everything on one canvas or have many canvases

eternal needle
topaz mortar
native seal
topaz mortar
#

well it depends on your UI lol
I have my real UI on a single canvas
but each monster healthbar has it's own canvas

native seal
#

kk, thanks

topaz mortar
#

I think in most cases a single canvas is easiest

ripe shard
topaz mortar
#

ah nice to know

native seal
#

thanks

topaz mortar
#

most of that probably doesn't matter for a small game though

onyx tusk
#

how 2 fix this text? autoFontSize is already true

carmine elbow
#

Yoooooooooooooooooo, I have an inventory system with items that ALL have a different use case. Generalizing them into different classes like WeaponItem and ArmorItem wouldn't work. Should I just create a different class for every item and let them inherit from ItemBase or is there a better approach?

charred spoke
#

What do you mean by use case ?

carmine elbow
charred spoke
#

Well there is nothing wrong with several levels of inheritence like ItemBase-WeaponBase-m4a4

naive pawn
#

if they're all "weapons" in a way a player can understand, then they can be handled the same way in code to some degree

timber tide
#

ItemBase is a good idea, and even a more less* derived based for serialization purposes perhaps?

#

otherwise can use interfaces for that if you want

naive pawn
hexed terrace
#

this is a code channel bud, delete and ask in #💻┃unity-talk .. showing screenshots of before and after.

cunning mesa
blazing ruin
#

Hi. Can I write here my problem, when I wrote early in code-general branch to get help asap?

naive pawn
#

please don't crosspost

blazing ruin
languid spire
blazing ruin
green ether
#

you didnt properly set your anchors, i would assume

languid spire
blazing ruin
carmine elbow
cunning mesa
#

Yeah ScriptableObjects for my items

green ether
#

So instead of an interface the equipable items all derive from EquipableItem first

#

Not sure if that was a good idea or if I should also use interfaces

wintry quarry
#

This is a classic pitfall

#

Going to bite you in the ass

#

Get rid of the inheritance, use composition and tagging

#

That's my suggestion

green ether
#

What do you mean with composition/ tagging?

cunning mesa
wintry quarry
#

Custom obviously since these aren't GameObjects

mild summit
#

how to solve that combined mesh problem?

wintry quarry
#

Composition meaning the item would have something like List<Effect> or List<StatBonus> to satisfy equipping or consumption.

green ether
#

hmm I will have to read up on it

cunning mesa
mild summit
wintry quarry
#

In the inspector, as SO assets

mild summit
#

yes

green ether
#

I also am doing it a bit different where I dont use scriptable objects in the game but just use them to hold the data.
Then I use the stuff set in the scriptable objects to build Items through an ItemBuilder/ Builder pattern

#

Not sure if thats the proper way

young fossil
#

I've heard that generalisation/inheritance is something to avoid in Unity for the most part. Been told you can use it to extend specific classes with more functionality but the typical use of inheritance is better to just use composition since that's how the engine has been designed

wintry quarry
#

That's more about MonoBehaviour scripts

stiff birch
#

This should help visualize what PraetorBlue is talking about : https://www.youtube.com/watch?v=8TIkManpEu4

Check out the Course: https://bit.ly/3i7lLtH


Not sure if you should be using composition or inheritance? Or not sure what that even means? In this video, I'll talk about the differences between the two, the positives and negatives of each, and show how to use these programming paradigms in your own game cleanly.

Unity Mastery Course...

▶ Play video
wintry quarry
#

But in general composition is better for solving a lot of problems than inheritance is

carmine elbow
cunning mesa
wintry quarry
timber tide
#

you can do anything with scriptableobjects that you can with plain c# classes

#

the benefit of SOs is being able to reuse instances

#

throughout the editor itself, so you can reference them on different GOs

green ether
#

Can you create new scriptableObjects in the Build?

timber tide
#

sure, why not

green ether
#

i thought you only can through the CreateAssetMenu thing

timber tide
#

I would recommend just using them as readonly assets though, this way you can be sure that referencing them on different GOs won't change them internally

willow scroll
#

No, you can easily create and copy them via code

carmine elbow
carmine elbow
#

I'd rather use Scriptable Objects as it's alot easier for my Artists to use and then they won't have to keep on bullying us devs 😄

cunning mesa
#

I have a question of my own.
Without giving too much context, what I think that I want is a LateFixedUpdate method, so that I can perform an action once I know all FixedUpdates have finished.
I imagine this is a common desire - is there a common answer?
(I'm not interested in specifying script execution order, unless that's unanimously the one and only correct solution)

timber tide
#

The only real downside of SOs is asset bloat, as sometimes you don't really need to reuse those instances

#

but even with that downside I've came to other problems with unity's serialization with plain c# classes and it's that there's a point where these serializable classes would bloat the editor itself, or become initialized with compiler defaulted values

burnt vapor
#

That said, why would you want this?

#

If you want something to happen after another thing, usually you'd write an event, or have your own system that calls methods in order. Having a LateX method solves nothing

#

Especially when later on you need something to happen after this LateX and now you need a LateLateX

cunning mesa
#

Sovles nothing? Surely it solves the issue of being able to call a method between all FixedUpdates and the end of the fixed frame?

burnt vapor
#

My point is that you now have a strict limitation where something is forced to run later, so rather than having a general "Late" feature of something, instead consider hooking up an event somehow that is called after the required work is done

#

This is why things like LateUpdate are also bad because you will always have an order in a way and making new LateX methods for everything won't solve it cleanly

cunning mesa
#

I see, thank you for the input. I'll modify my implimentation to not need one - cheers

boreal dove
#

I have a problem with my figure, no matter how i rotate it, either the parenting object nor the others below, when i walking in the simulation everything seems to be resetted. the values in the inspector are still the values like i rotated it, but the figure itself is resetted like all values are 0. i have no clue whats going on.

eternal falconBOT
topaz mortar
#

don't pm me, post it here

boreal dove
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ThirdPersonCam : MonoBehaviour
{
    [Header("References")]
    public Transform orientation;
    public Transform player;
    public Transform playerObj;
    public Rigidbody rb;

    public float rotationSpeed;
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        //rotate orientation
        Vector3 viewDir = player.position - new Vector3(transform.position.x, player.position.y, transform.position.z);
        orientation.forward = viewDir.normalized;

        // rotate player object
        float horizontalInput = Input.GetAxisRaw("Horizontal");
        float verticalInput = Input.GetAxisRaw("Vertical");
        Vector3 inputDir = orientation.forward * verticalInput + orientation.right * horizontalInput;

        if (inputDir != Vector3.zero)
            playerObj.forward = Vector3.Slerp(playerObj.forward, inputDir.normalized, Time.deltaTime * rotationSpeed);
    }
}

eternal falconBOT
topaz mortar
wintry quarry
boreal dove
#

player character

wintry quarry
#

still vague

#

Are we talking about animations or something?

topaz mortar
#

camera rotation it seems?

naive pawn
#

i vaguely recall it not working but it's been a long time since i tried

wintry quarry
# boreal dove player character

You have all of these:

    public Transform orientation;
    public Transform player;
    public Transform playerObj;
    public Rigidbody rb;```
And it's unclear which object is which. Super confusingly named and probably duplicated objects.
topaz mortar
boreal dove
#

ive got another idea how to show you what i mean

brittle isle
wintry quarry
brittle isle
#

collisions are still detected, but the player stays invincible

wintry quarry
#

Logs are things like this:
Debug.Log("Invuln On");

#

show your console when this stuff happens

brittle isle
#

there is no "Invuln on"

wintry quarry
#

then your code is never running

#

Is Debug.Log("Taking Damage: " + _damage); ever printing?

brittle isle
#

yeah

#

which is weird

wintry quarry
#

Sounds like isInvulnerable is starting out as true

#

or you're dying

#

those are the only possibilities

brittle isle
#

updated my hatebin

wintry quarry
#

show your console

brittle isle
#

I've found the problem - the Is Invulnerable bool stays true and the coroutine stops itself when it calls for collisions between players and enemies to no longer be detected

#

even so it still stays invulnerable

wintry quarry
brittle isle
#

which is weird

boreal dove
#

@topaz mortar you saw my problem in the video ?

naive pawn
#

does timescale affect the Update methods?
am i right to assume that Update/LateUpdate aren't affected, but FixedUpdate is?

wintry quarry
#

Update runs once per frame

#

it doens't care about Time Scale

#

FixedUpdate is yes

#

So actually I guess the answer to your whole question is yes not no lol. Didn't see the second message at first

naive pawn
#

lol, i probably shouldve written XUpdate or *Update to make it less confusing

lunar carbon
#
    {
        int minutes = (int)(time / 60000);
        int seconds = (int)((time / 1000) % 60);
        int milliseconds = (int)(time % 1000);

        return string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, milliseconds);
    }```

could someone explain this code
ebon skiff
#

Please help, it says The variable of FollowPlayer has not been asigned and then the camera dosnt follow the veichle how do i fix this, this is my code and editor

wintry quarry
languid spire
wintry quarry
lunar carbon
#

return string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, milliseconds);

#

that part

ebon skiff
wintry quarry
#

No^
it's clearly not assigned

languid spire
#

so go look up string.Format in the docs

ebon skiff
#

Ohhhh thanks

wintry quarry
eternal falconBOT
ebon skiff
undone rampart
#

you can just parent the camera to the car and drag it to offset it, you dont need a script for it

ebon skiff
#

Oh

bold nova
#

I have a troubled time with enemies looking at a player. For some reason enemy looks in complete random direction, does anyone see mistake in my code? ignore layer in ray cast is so that enemy doesnt project ray in himself, its one layer only.

 private void LookAtPlayer()
    {
        UpdatePlayerPosition();

        agent.transform.forward = lastPlayerPosition.normalized;
    }
    private void UpdatePlayerPosition()
    {
        var direction = (player.position - agent.transform.position).normalized;

        RaycastHit hit;
        if (Physics.Raycast(agent.transform.position, direction, out hit, 100f, ~ignoreLayer))
        {
            Debug.DrawRay(agent.transform.position, direction);
            if (hit.transform.CompareTag("Player"))
            {
                lastPlayerPosition = hit.transform.position;
            }
        }
    }
undone rampart
bold nova
undone rampart
#

no

naive pawn
#

please don't spoonfeed code, at least say what changed lol

brazen canyon
#

Guys I need a little help.
How to stop an object from falling when this object has Character Controller component ?

brittle isle
brittle isle
brittle isle
wintry quarry
brittle isle
#

most are debug lines about enemies

wintry quarry
# brittle isle

you need to turn off Collapse so the logs are shown in order

#

also this isn't the full console

brittle isle
#

oh right

boreal dove
wintry quarry
#

delete all the extra stuff that isn't in the video

#

follow the video exactly

#

and pay attention to what they're doing and try to understand it

boreal dove
#

there is nothing more in the video

wintry quarry
#

I didn't say there was

#

You didn't follow the video

#

You did some things differently

#

so start over

#

and follow it more closely

brazen canyon
#

Guys I need a little help.
How to stop an object from falling when this object has Character Controller component ?

#

:((

wintry quarry
#

So it is your code doing the "falling"

boreal dove
#

the only different thing is my character, and it ignores if i rotate it. one script seems to reset it to the original position and i dont know how to fix that without ruin the meaning of the whole script. can i somehow rotate the whole pivot of an object ?

brittle isle
#

it hates layermasks, thought i could kill two birds with one stone

wintry quarry
#

I also doubt the tutorial has both of these:

    public Transform player;
    public Transform playerObj;```
#

That would be very weird

boreal dove
#

it has, but i cant tell you why.

wintry quarry
#

you passed in a LayerMask

brittle isle
#

makes sense

wintry quarry
#

it wants a layer index, not a LayerMask