#💻┃code-beginner

1 messages · Page 115 of 1

sudden grove
#

what im trying to do is detect whether my canvas is active, if the canvas is active then turn off my script because my menu is open, if the canvas is off then enable the script so i can look around

polar acorn
sudden grove
#

i dont actually know hang on

#

let me look at the original code because i deleted a ton of stuff before

quartz anvil
#

https://hastebin.com/share/ejiqulukaz.csharp am trying to raycast from a camera to an object with a mesh and delete voxels from the mesh. works fine when clicking the bottom and 2 sides of the voxel but not when clicking the top or 2 other sides. I can link the spawner code too if needed

sudden grove
rich adder
#

stop using generative AI then

sudden grove
#

i need to essentially check if the canvas is active then turn off my script because my menu is open, if the canvas is off then enable the script so i can look around

sudden grove
#

that is horrendous

#

i really am sorry @polar acorn ive been so confused

#

plus its 3am, and ive been working on this since about 9pm

polar acorn
sudden grove
quartz anvil
#

If anyone has some answers that would be sweet, also if i need to clarify or add more I can.

#

I would have done inline code but I dont have nitro

polar acorn
quartz anvil
sudden grove
#

@polar acorn is it possible to code it so that picking up a specific item, sets a trigger, so i can enable a button?

polar acorn
polar acorn
#

and also what you mean by "button"

sudden grove
#

im gonna make a legend of zelda progression/ item system, so instead of having an inventory, i want to make it so that all of the slots are disabled in my inventory, so that when i pick up the flashlight, it sets off a trigger, and enables the button, which then allows me access to the torch whenever and where i want

cosmic dagger
#

Are you using Unity's CharacterController?

quartz anvil
cosmic dagger
#

What does your controller use for movement then? If not rigidbody or colliders, then how is the trigger message being sent?

polar acorn
quartz anvil
#

I did add recalculatenormals

sudden grove
quartz anvil
rich adder
quartz anvil
sudden grove
#

how do i make checkboxes in my inspector?

polar acorn
rich adder
sudden grove
#

ones that once turned on, dont turn off unless done manually?

polar acorn
sudden grove
polar acorn
#

nothing changes unless you tell it to

sudden grove
#

ohh okay

#

im just thinking

#

imma have a script that controls my inventory items

#

using booleans, in which everytime a specific item is interacted with it will tick the checkbox, therefore unlocking it in my inventory

rich adder
#

who cares about the checkbox, thats just the displaying bool inside unity inspector.

#

whats important is the value..

sudden grove
#

i think its an easier way of displaying the value for myself

#

so im thinking activating the checkboxes would be an easier way of going about what im looking for

rich adder
#

in the editor ? sure.

sudden grove
#

cause all ive gotta do is activate a bool when i pick up an item, and it stays active in my inventory then

rich adder
sudden grove
#

i tried this but ion know if it references my button?

summer stump
# sudden grove

You reference a Canvas component, an Inventory class, and a PickUpControllerTorch class

Depends on where you put those scripts I guess

sudden grove
#

I need to reference the torch button, that is below the image of my script

#

how would i go about that?

summer stump
rich adder
#

[SerializeField] private Button button 😏

#

but yeah make sure its from UI namespace

summer stump
#

Yeah yeah lol
I am on a phone haha

sudden grove
#

so would i just say public Button Torch; ?

summer stump
rich adder
summer stump
#

No worries lol
I'll have you know it IS my birthday though. I demand respect for the fact I was born!

sudden grove
rich adder
rich adder
rich adder
sudden grove
#

i just wanna enable the torch button

rich adder
#

whenever you find yourself labeling variables with numbers like that

#

use a list/array

sudden grove
#

whats that?

rich adder
rich adder
#
[SerializeField] private bool[] items;```
sudden grove
#

it acts as algebra

rich adder
#

only difference is they start at 0 index

sudden grove
#

ill have to have a proper read tomorrow

#

cause rn its 4am

rich adder
#

so item1 is items[0]

sudden grove
#

and i just wanna get this last thing finished before i got to bed 😭

rich adder
#

also also

#

make a class for items

sudden grove
#

why would that make it easier?

rich adder
#

because you can store more info than just a bool, cause now you need to make a new thing for each different check you want

#

its gonna get you confused more

sudden grove
#

okay okay

rich adder
#

later on

sudden grove
#

how would i create a quick class for my torch?

rich adder
sudden grove
#

hang on then

rich adder
#

then change torch class to Torch : Item

#

everything should work exactly the same except now You can store torch inside
List<Item> items;

sudden grove
#

wait hang on

#

i just made the script

rich adder
#

lol Class

#

it can just be Torch

#

class is implied

teal viper
#

Buttery butter

sudden grove
teal viper
#

My name is John Smith Name

rich adder
#

you can check if the list contains this torch

sudden grove
#

to be fair on the pickup script, theres already an equipped bool, so could i activate that item1 bool, when its equipped, saving me the trouble

rich adder
#

why does a pickup script have an equipped bool

sudden grove
#

i dont know but its useful

rich adder
#

oh boy..

#

you were gonna make a pickup controller for each object ? ?

#

you need to refactor this to be more generic

sudden grove
#

nah i was gonna just tailor the same one to each object

teal viper
#

Which is basically what they said

sudden grove
#

oh yeah

#

haha

rich adder
#

ok well if you have the class i suggested you can make it a reality

#

(ideally we would use Interfaces but thats too complex rn)

sudden grove
#

im just trying to get stuff working tbf

rich adder
#

so you see the RB and all that goes inside torch

sudden grove
#

yeah

rich adder
#

and make Torch : Item

sudden grove
rich adder
#

thats not Item

sudden grove
#

so what do i do?

#

i have the code open

rich adder
#

look its not that hard

    public class Item : MonoBehaviour { }

    public class Torch : Item { }```
#

one in each file

sudden grove
rich adder
#

and its not correct

sudden grove
#

im so confused

#

each file of what?

rich adder
#

nothing confusing here

#

make a dam file for each class

#

not hard

sudden grove
#

i literally have 1 item at the moment so its just 1 class at the moment

rich adder
#

You already made scripts.. hows this anything difficult

sudden grove
#

im sorry if im abit slow

#

ive been at this for 7 hours

rich adder
#

take a break then lol

#

whats the rush

#

this is not a race

sudden grove
#

ion kno

rich adder
#

coding tired is never good

sudden grove
#

i just was hoping to have this 1 thing done today

rich adder
#

thats a lot of stuff you already did so far..

#

if you push yourself you'll burn out

sudden grove
#

cause i had a task for myself to have some sort of inventory sorted

#

true

rich adder
#

its almost there after you prepare these two classes

#

it will make everything later on easier trust

sudden grove
#

but yeah im just a little confused on what your showing me, like what makes it easier, what are we achieving?

ruby ember
#

does someone know how to make the question mark button and when i click it
it appears a text like a hint and takes like 5 seconds or 7 seconds now it dissapears

for example coin menu: you clicked the button: you need more coins to unlock it

rich adder
#

You want to have a "Generic" but common class you can identify your torch and other items with

sudden grove
rich adder
sudden grove
#

yeah

rich adder
#

is now inherently an Item

sudden grove
#

i think that makes sense

rich adder
#

yes so anything with Item can be picked up and stored in the same list

#

eg like an inventory

rich adder
#

like display a text for 7 seconds and disappear right?

sudden grove
ruby ember
#

yes

ruby ember
sudden grove
rich adder
#

you inherit your parents that inherit their parents that inherit their parents

sudden grove
#

wwhy has stuff broken again now

rich adder
sudden grove
#

for some reason my inventory state thing is breaking again

#

it turns off everything but it doesnt turn back on

rich adder
sudden grove
#

it literally disables my player

true pasture
#

when using add listener can I add the listener to the top priority-wise. I don't fully understand this yet but it seems to add them to the bottom of the events. (This script is competing with an event set in the inspector and going second is my understanding)

eternal needle
true pasture
#

the order is guaranteed when you can move them in the inspector

eternal needle
#

But tbh this sounds more like a design problem if the order is an issue

wintry quarry
true pasture
#

ok thanks i think i found a better way.

queen adder
#

If u use the Inspector events it will Invoke the functions from top to bottom / Whatever order u have them in the inspector

rich adder
#

no

queen adder
#

Oh am i mistaken?

#

My apolgies if so

rich adder
#

yes, had plenty of times where second to last would run earlier

#

order is def not guarneteed

queen adder
#

Oh really? is there a way guarantee the order in which the methods are invoked?

rich adder
#

dont use the inspector

true pasture
#

I thought that was true as well, since I had to reorder some things early on in my project and it fixed them. Im not using that system anymore though

rich adder
#

eg instead of 1 event doing so many thing
1 script listens to this script which listens to something else

#

and it keeps going down

#

its prob ugly but it works for me atm

polar acorn
#

I'm pretty sure it'd do them top to bottom. I haven't tested it but I'm pretty sure it uses an Event under the hood, and those are deterministic

queen adder
#

Yeah im pretty sure ive tested it? i could do it now honestly

#

And show everyone the results

polar acorn
#

Yeah, I'd make a few functions that log a number, put them into the inspector in order, then run it a bunch of times to see if it prints them in the right order

queen adder
#

Bet

#

Ill post it here if anyones interested

rich adder
#

i guess it depends maybe what is you're doing ? I always for example disable the script that uses NavMeshAgent and then disable the Movescript first and then Agent Component but for some reason script threw error that navagent needs to be enabled to call Move

teal viper
#

Even if it is deterministic, it's not a great design to rely on their order.

rich adder
#

very wise

queen adder
#

I mean if u want to be invoked in a certain order going top to bottom isnt bad

teal viper
#

Each subscriber should be able to work properly regardless of what else is subscribed to an event.

queen adder
#

Thats true^^

#

But thats not always what u want For example if u have a button that disables itself but activates another button you would want that other button to be activated before the button you press is disabled

#

Having the methods invoked from top to bottom would just make sense

rich adder
queen adder
#

I mean if ur getting mixed results then yeah for sure stop doing it

#

Ive never had problems with it on my end tho

teal viper
summer stump
rich adder
#

thats the thing, the invoke is but what about receiving end?

queen adder
#

I could test it and see

rich adder
#

yeah but i think with different mixed components

#

eg Rigibody n other mixed frames items

#

Inspector is ugly way to have events anyway

#

you cant see in code what is subscribed to event

queen adder
#

It actually will still activate that other button even if its disabled

rich adder
#

compared to doing +=

queen adder
#

So i was wrong

honest matrix
#

I'm trying to work with complex movement systems, and wanted to know if anyone used rigidbodies or controlled velocity at the root?

summer stump
#

This is a cool chart for types of movement

honest matrix
#

yeah but with or without rigidbodies?

#

I've heard using Rigidbodies takes away control

summer stump
#

If you want more control, you can make the rigidbody kinematic and use MovePosition.

#

Rigidbodies are also required for physics messages like OnCollision and OnTrigger, although CharacterController works for OnTrigger and has an alternative to OnCollision called something like OnControllerHit or something

nimble scaffold
#

Merry Christmas to y'all

feral gate
#

merry christmas !

ivory bobcat
summer stump
#

Instantly stole it. Along with this one that they DEFINITELY made

split dragon
#

Hi. I decided to do a camera shake (rotate the x and z axes), but I had a problem that now I can't rotate the camera on the x axis. I tried to change the vector number, etc., but nothing helped. How to fix it?

#

Yes, the camera does not rotate only on the x axis (up-down)

#

Yes, she trembles when moving

hardy mist
#

what's the best way to map DB data to client assets? E.g. in a player account there is "unlockedHeroes": {}, {}, {},.
Do people usually add "assetPath" field to "unlockedHeroes" in DB to load the prefab of the unlockedHero during runtime?
Or is it some kind of ID and on the client there is a mapper like switch (id) { case1: pathToHero1 }.

split dragon
#

It's other

#

Oh, yeah. I accidentally wrote public float x = 0f... Thanks

#

And if you remove this, then swinging the camera will not work...

eternal needle
languid spire
charred spoke
languid spire
split dragon
#

Line 31 prevents the camera from rotating along the x axis, and this line depends on the rotation value, which is in line 13. I tried to change Vector3.zero to other values, but swinging the camera does not work, but turning the camera works fine. How to solve it?

uneven path
#

Hi hii I'm trying to get the value from the user in a text mesh pro input field

#

So like this is what I typed out

#

If I type like 5

#

it does say I got 5

#

but when I try to convert it then print it again

#

it gives like an error

languid spire
#

change it to a TMP_InputField

uneven path
#

Big thanks

shrewd swift
#

Hi

I got a animation that basically move the player UP
but when playing it in game it will "stick" to the ground, i think it might be because of gravity, because it stays up then goes down on the ground

is there a way to fix it without manipulating the rigidbody ?

woven crater
#

i dont know where to put interface classess. do i make a script and put every interface in there?

hasty spire
#

im tryna get a particle effect to play when i turn around, but idk how, is there a way to check if my player is flipped

hasty spire
#

ty

hasty spire
#

im reading the documentation

rich adder
#

thats pretty much all there is to it

#

best way is also to select the object that has animator when viewing animation window to add Event

#

this way it gives you a selection box for that method

dry tendon
#

wich is the common format for the bg music of a game on android?

#

which is the best config for the audio on the inspector for android?

#

and for sound effects?

modest dust
long anchor
#

i have this super simple editor script that is ment to set offsets for a held item to a scripted asset
i move and rotate the item to fit in the players hand and when i press the button the POS works fine, but the rotation is not even close how do i fix this?

#

thats whats expected

eager elm
#

ah nvm there is your code as well

long anchor
#

I am using local

#

I want the rotation of the bone is under to be it's 0,0,0

sudden grove
#

guys can you help me disable a script when a condition is met?

bitter oar
#

can't you do if (condition) return; ??

languid spire
sudden grove
#

my code was working fine last night then randomly stopped working

bitter oar
#

oh yikes

#

do you have a github?

#

cant you see which changes were made?

sudden grove
#

so what im doing is im detecting whether my inventory is open, if its open, then initiate inventory state, which locks my camera, movement, and unlocks my mouse

languid spire
#

the very nature of code is that it does nothing randomly

bitter oar
#

oh

bitter oar
#

why dont you go to camera script and do

if (!inventoryopen)
{

}

sudden grove
#

but for some reason instead of disabling the script

bitter oar
#

and all your code inside it

sudden grove
#

its just disabling my player entirely

languid spire
#

show your code

bitter oar
#

can you show code?

woven crater
#

For enemy types that have different enemy behaviour it's better to create prefab rather than using scriptable object?

sudden grove
#

thats my inventory state code

languid spire
sudden grove
bitter oar
#

oh wait

#

im dumb

languid spire
#

so what is wrong with PlayerMovement.enabled = false; ?

sudden grove
languid spire
#

why not?

sudden grove
#

it opens my inventory for a split second then immediately closes it

languid spire
#

so post PlayerMovement script

ancient valley
#

Hi, I have created a game objec with a script etc to handle my logic of my goblin and in my game manager I'm just doing this to spawn some goblin but the default goblin is always there and i dont want him to be present by default, i want to only handle the mecanics of spawn thought the script how can I delete him from being present ?

public class GameManager : MonoBehaviour
{
    public GameObject goblin;

    void Start()
    {
        SpawnScript spawnScript = GetComponent<SpawnScript>();
        goblin = GameObject.FindGameObjectWithTag("Goblin");

        if (spawnScript != null)
        {
            for (int i = 0; i < 100; i++)
            {
                spawnScript.SpawnEntity(goblin);
            }
        }
    }
}
sudden grove
languid spire
sudden grove
#

so what do you think the issue is?

languid spire
#

no idea but it certainly has nothing to do with using PlayerMovement.enabled = false;

sudden grove
#

lemme check some of my other code

languid spire
#

it's much more likely something to do with how/when/where you set inventoryCanvas.gameObject to inactive

sudden grove
#

well i set it to be active by clicking tab, and its whenever i want to click it, so i assume its somewhere in my code

languid spire
#

maybe as well as just if (inventoryCanvas.gameObject.activeSelf) you should check 'have I alreasdy done this?' as this code is in Update

eager elm
languid spire
#

you do know what Update method does do you not?

sudden grove
languid spire
#

exactly so if (inventoryCanvas.gameObject.activeSelf) is being run every frame and so is everything below it

#

Update is probably not where you want this code

woven crater
# languid spire no

okay... then how do i instantiate a scriptable object instead of a prefab with a script inside it

languid spire
#

you dont

bitter oar
#

Okay, i need help! I'm trying to do that when the player sprints, and he turns, he "slightly drifts" to that direction instead of turning there immediately.
kinda like in mario games, its more realistic then just turning straight away.
Now, if you move the joystick a bit, it does the drift very well. but if you move it a lot, its just kinda trash. can anyone help me? here is my code:
https://hastebin.com/share/rinecadeco.csharp

Help is really appreciated!

sudden grove
languid spire
sudden grove
#

im enabling and disabling the game object

#

so once its disabled i cant run the code

woven crater
# languid spire you dont

so instantiate an empty game object then set sprite and parameter on it? if so how do i use method like follow player or go in circle to that game object?

languid spire
#

yes, perfect

sudden grove
#

to turn it back on

#

i dont think its an issue with placement

#

its an issue with code

ancient valley
# eager elm drag the default goblin into your assets and delete him from your scene. To "fin...

Alright thanks and also I had this line of code to get the goblin in case I forgot to drag it via inspector, is there another way to get it because I assume this work only if the object is in the scene
And is it better to assign the variable like goblin prefab or any other variable in the start or directly using the inspector ?

goblinPrefab = GameObject.FindGameObjectWithTag("Goblin");
sudden grove
#

the code is doing something its not supposed to

languid spire
woven crater
#

was asking if the SO can also contain enemy behavior method and use it on the instantiated prefab

eager elm
languid spire
bitter oar
#

Oh sorry

#

Ok deleted in every channel but this

sudden grove
languid spire
bitter oar
#

what do you mean? what to debug?

#

i can send a video of what happens

languid spire
#

to start with, which paths are being taken in your code and what variable values are they using. Basic Debug 101 really

languid spire
bitter oar
#

i was asking if you would like a video of the current outcome

#
  1. Movement Ability Check:
  • Condition: canMove
  • Path if True:
  • Calculates base moveDirection using camera forward and input.
  • Incorporates horizontal input for non-sprinting or zero previous input.
  • Normalizes moveDirection and sets its Y component to 0.
  1. Sprinting and Drifting Logic:
  • Condition: isSprinting
  • Paths:
  • Resets driftTimeElapsed if input direction changed and movement is significant.
  • Updates driftTimeElapsed and applies drift effect if drifting conditions are met.
  • Applies horizontal input to moveDirection in other cases.
  1. Speed Calculation:
  • Condition: inputManager.moveAmount > 0 (joystick moving)
  • Paths:
  • Increments moveIncreaseSpeed if below maximum.
  • Calculates moveSpeed based on sprinting state and input amount:
  • Sets to sprinting speed if sprinting and input amount is high.
  • Varies speed based on running speed, max speed, and input amount otherwise.
  • Applies selected moveSpeed to moveDirection.
  • Resets moveSpeed and moveIncreaseSpeed to 0 if joystick is not moving.
  1. Crouching Adjustment:
  • Condition: crouching && !longJump
  • Path: Adjusts capsule collider height and center for crouching.
  1. Grounded Movement:
  • Condition: isGrounded && !isJumping
  • Path:
  • Sets gpJump to false.
  • Applies moveDirection to player rigidbody velocity.
  • Resets dive-related variables.
  • Key Variables:
#
  • moveDirection: Vector3 representing movement direction.
  • canMove: Boolean indicating if movement is allowed.
  • isSprinting: Boolean indicating if sprinting is active.
  • driftTimeElapsed: Float tracking time for drift effect.
  • inputManager: Object managing input values.
  • moveSpeed: Float representing current movement speed.
  • moveIncreaseSpeed: Float used to gradually increase speed.
  • capsCol: Capsule collider component for character.
  • isGrounded: Boolean indicating if character is on the ground.
  • isJumping: Boolean indicating if character is jumping.
  • playerRigidbody: Rigidbody component of the character.
languid spire
#

ok, so tell me this, on the basis of what you have just posted is this
if (moveSpeed < runningSpeed)
true or false?

bitter oar
#

runnning speed is like the normal walking speed. sprinting speed is the faster one.

languid spire
#

what I mean is it is impossible to follow your code unless you try to debug it properly

sudden grove
#

@languid spire do you by chance know how id reference my PickupControllerTorch script and access the equipped bool?

languid spire
bitter oar
#

Nvm

sudden grove
#

ive used them, but i havent used a bool to enable a bool

#

im pretty sure i know how to access the script

#

i just need to know how to express it

languid spire
#

`it's simple
declare a public variable
reference that in the Inspector
in code access variable.equipped

green island
#
RaycastHit2D hit = Physics2D.CircleCast(transform.position, 1f, transform.right, 1f);
Debug.Log(hit.collider.name);

the spherecast hits the player that shoots it but it should become an multiplayer game so every player has the same layer so i cant just ignore one layer so that it doesnt hit itself

sudden grove
#

simple but it sounds viable

fringe plover
nimble apex
#

u just need to find out the exact code using unity documents

bitter oar
#

Talking to me?

nimble apex
#

oh debug

sudden grove
#

hi guys

#

im trying to freeze some restraints on a rigidbody, how would i go about it

cosmic quail
#

so how would you do it if you were making a competitive shooting game?

bitter oar
sudden grove
#

guys it wont freeze my rotations 😭

cosmic quail
#

!dontasktoask

#

idk what the command is
or link

cosmic quail
#

dont ask to ask
just ask

#

whats the porblem

#

change it in the inspector?

#

u gotta do * moveSpeed * Time.deltaTime;

#

not just * moveSpeed

sudden grove
cosmic quail
#

u using a Charactercontroller component?

#

rigidbody then?

#

but it doesnt collide with things, is that right?

#

do you want it to?

#

well there are two choices. charactercontroller or rigidbody.

#

oh its a 2d game..

#

rigidbody2d then

#

thats what you gotta use

#

you didnt but now looking at your code its quite obvious

#

my bad

sudden grove
#

okay guys i lied

sudden grove
#

nah im going about this all rong

cosmic quail
#

thats how u freeze rotation

sudden grove
#

im trying to do it with code

cosmic quail
sudden grove
#

instead of being awkward and freezing rotation im going to just disable the gameobject

sudden grove
#

when i open it i need my character to completely freeze

sudden grove
#

no movement, no camera movement, and the only thing that keeps moving is the item

#

well

#

"rotating" which is then messing up the direction the torch is facing

#

okay i got it working

#

so satisfying

#

ITS SLOWLY COMING TOGETHER

#

now guys this is where i need your help again

cosmic quail
#

can u show the code?

sudden grove
cosmic quail
#

looks like u didnt follow a tutorial

#

move the input.getaxisraw calls into Update. put the rest into FixedUpdate.
because input must be in update. and physics things need to be in fixedupdate

cosmic quail
polar acorn
#

Velocity is an amount to be moved in one time step. You are passing it a position

cosmic quail
#

you can change velocity to rb.moveposition

#

and do the update and fixedupdate thing i told you, too

#

if u have input in fixedupdate then its gonna be unresponsive and laggy

#

is that not a thing in 2d?

cosmic quail
#

its just a command that sends your character to the position you give it

#

MovePosition(...); not MovePosition = ...

polar acorn
#

It's a function. You call the function

#

You don't assign a value to it

spiral narwhal
#

Are coroutines "paused" if Time.deltaTime is 0?

spiral narwhal
#

Ah I see. Thanks

cosmic quail
spiral narwhal
#

Oh yes

woven crater
#

why it say typemismatch?

#

i select player gameobject in the scene

wintry quarry
#

Just reassign it

woven crater
#

doesnt show select game object window in the clip lol

polar acorn
#

Prefabs can exist anywhere. What value would it have if you instantiated it in a different scene?

cosmic quail
#

yeah you can only put another prefab in there

woven crater
#

i see

cosmic quail
polar acorn
#

Or if you spawn it at runtime you'll have to set it in code after instantiating it

woven crater
#

got it thank guys

cosmic quail
#

so u decided to stick with velocity instead of moveposition?

#

well ur previous code worked with moveposition but it seems u changed it to work with velocity

#

you can just write rb.velocity = vt * moveSpeed; its shorter

#

and its the same thing

#

but apart from that yeah looks good now you can move around and collide with walls. probably

main sage
#

does C# allow you to have a set of mutable objects?

polar acorn
#

Even if a collection itself is immutable the objects inside it can be changed freely

main sage
#

oh i meant the objects inside are mutable

woven crater
#

i set target as player prefab inside SO and when i log it out the target position it always point to 0,0

#

why?

cosmic quail
woven crater
#

yea

cosmic quail
#

which u havent instantiated?

woven crater
#

the white square is on the game scence in the pic

cosmic quail
# woven crater yea

if u have a player and in the scene and want its position then drag that player in there, not the one thats in your folder at the bottom

woven crater
main sage
cosmic quail
gaunt ice
#

do you now what are reference type and value type in c#?

cosmic quail
#

or assign the player via code

woven crater
#

i did then i put it in the scene but still cant drag it into the slot

main sage
cosmic quail
main sage
#

without it losing the ability to identify individual objects

woven crater
gaunt ice
#

reference type (pointer) and value type (whole chunk of data) have no effect on O(1) accessing it in hash table

#

or O(data size)

sudden grove
#

guys can you help me put this pseudocode into actual code?

main sage
#

like in java u can directly specify a field on an object used for differentiation

sudden grove
#

cause im pretty sure this is the last functionality threshold i need to finish before my character is done i believe

gaunt ice
#

first check the hash value, then compare the whole key
java has no value type

main sage
#

ah yeah

#

whole key?

#

in the case of a reference?

gaunt ice
#

compare the two keys (the keys you passed into and the key stored in hash table) byte by byte

main sage
#

oh so literally lol

#

and the key would be the reference value correct?

#

not the value pointed to by the reference

frigid sequoia
#

Kinda weird question here: for what I know, a float cannot have a null value; it becomes 0 instead; the thing is; I want for 0 to be an actual valid input you can enter (since they are coordinates) and not entering anything just tells the class to place some default values for the variables needed; there is a way of doing that? Make a "no input" and "0" be differenciated somehow on class?

woven crater
native flicker
#

i got a question, is there any way to change the color of a image with an click event?

main sage
native flicker
#

so ik how to create the event and all but idk if i could change the color

native flicker
#

how?

rich adder
main sage
#

can u do that for any value or reference type?

gaunt ice
#

value type means the data is stored "inlined", and you know java so i dont need to explain what is reference type

int[] array=new int[10];//all 10 ints stored in this array, not the pointer to 10 int
rich adder
gaunt ice
#

reference is pointer so it can be null

frigid sequoia
main sage
rich adder
frigid sequoia
# rich adder don't think unity serializes them in the inspector

The idea is that I have a item I want to move and I enter the starting and ending coordinates, and it loops between then; if you enter nothing (or "0" rn...), it assumes their starting coordinates are their current coordinates and the ending coordinates are equal to the starting ones; like for example, you don't want the item to move in Z axis, so you just don't input anything there

rich adder
frigid sequoia
rich adder
#

typing wise

#

is it an input string? or where are these values inputted

woven crater
#

is this how you use Scriptable object? been studying it all day now . not entirely sure of its use but i think i can create more variant of the Enemy_normal using SO

frigid sequoia
# rich adder is it an input string? or where are these values inputted

I wanted to create multiple moving plataforms that loop back and forth, so instead of making a pathway or an animation, I just made a script that moves to desired position and origin position constantly; this is initially not meant to recieve any other input than what you enter in the inspector; what is doing right now is just assuming that if you left the default value the inspector gives which is 0, you didn't input anything at all there and resorts to default values

frigid sequoia
#

I just want to know if I can give it some kind of "null value" from the inspector even though they are floats and are not meant to

rich adder
#

with a bool

frigid sequoia
gaunt ice
#

nullable actually is a struct with an additional bool

rich adder
#

this would be pretty easy if unity liked nullables

#

but apparently it doesnt serialize them

frigid sequoia
#

I think you should literally have a button next to the value in the inspector that makes it null automatically

rich adder
#

that can be done

#

with custom inspector

#

but is it worth the time? does ur logic mainly rely on inspector for this feature?

wind meteor
#

why its dont work

frigid sequoia
#

Yeah, that would probably do it

rich adder
gaunt ice
#
public struct NameT>where T:unmanaged{
  public T value;
  public bool isNull;
  public static implicit operator T(Name<T> t){
    return t.value;
  }
  public static implicit operator bool(Name<T> t){
    return t.isNull;
  }
}
```it probably works, but idk what will happen if the T is bool
tender hound
wind meteor
rich adder
rich adder
frigid sequoia
# rich adder

I would have it on my mind for future stuff, I don't think it is quite worth the effort right now; is just for the weird cases where I want to specifically move it to 0 in some coordinate, and I can work around thay quite easily just was wondering if there was a simple way of telling the script that I want those values to be null if I input nothing

wind meteor
# rich adder show tutorial

FULL PICK UP & DROP SYSTEM || Unity3d Tutorial:
Since I just started my series on how to shoot with projectiles in Unity, I thought it would be cool to share how to make a full pick up and drop system :D

Don't forget to subscribe if you enjoyed the video, and if you have any questions just write a comment, I'll answer as many as I can! :D

Link...

▶ Play video
rich adder
#

they literally said in the beginning they are working on a previous vid

#

just replace it with your own weapon class

frigid sequoia
#

Thanks though 🙂

charred axle
#

following the official guide, in the videos there's explanations to the codes (picture 1)

#

but i cant see those on mine, anyone know how to fix/change this?

gaunt ice
#

!ide

eternal falconBOT
charred axle
# gaunt ice !ide

did everything but still not working as i want it to work, still like this

rich adder
#

also it looks like its working

charred axle
#

first picture clearly shows what does the hovered code do, mine doesn't, when i press alt+o it shows examples

#

"shorthand for writing vector3 0 0 1"

rich adder
#

wat so this screenshot is not yours?

charred axle
rich adder
#

including solution explorer

charred axle
#

this is mine (hovering vector3)

polar acorn
#

And what are you expecting to see while hovering Vector3

rich adder
#

assuming this

charred axle
#

"shorthand for writing vector3 0 0 1"

polar acorn
rich adder
#

not sure whats wrong

charred axle
rich adder
#

which VS version is this 19 or 22 ?

charred axle
#

latest

rich adder
#

try Regen Project files maybe ?

#

in that same screen

polar acorn
#

Pretty sure that's a VS setting

rich adder
#

yeah this is internal thing prob

charred axle
rich adder
#

yeah something in ur VS setting is fdup

#

idk where you find that though :\

charred axle
#

so i can have better understanding as i progress

#

maybe something from here?

rich adder
#

yes having Summary is important

charred axle
#

as far as i know all these things about intellisense

rich adder
#

your IDE did load it though which is the odd part

charred axle
#

can it be these boxes?

rich adder
#

not likely

#

something wrong with XML

charred axle
#

how can i search this as? summary doesnt show up or what

rich adder
#

yeah pretty much

charred axle
#

aight ty

green island
#

i have an Scriptible Object and i want for to have an function that every has but it is different so i thought of making a script but i dont know how to link it

eager elm
sullen zealot
#

on build some thinks are missing (some materials and colliders and tags)

#

in the editor run everything is fine

#

does anyone know what can be the cause?

sage mirage
#

Hey, guys! If I want to save my quality settings with Player Prefs, do I have to use Dropdown class or DropdownOptions class which one?

#

If I want to get reference to that dropdown I mean like [serializefield] private Dropdown or DropdownOptions field;

crude prawn
#

just like a button

sage mirage
#

So, you mean that i have to make a method?

crude prawn
#

yeah

sage mirage
#

@crude prawn Hey! How to add my dropdown to the inspector of my game object, I mean there is dropdown only and dropdown text mesh pro, for one reason I can't drop my dropdown game object inside the game object space. Why?

sage mirage
#

No!

#

Types don't match.

#

@rich adder Check it out!

#

When I make dropdown only in script it shows that dropdown on the inspector, but when I make DropdownOption then it doesn't show that on the inspector and tha'ts why I want the dropdown option to be seen on my inspector to drag and drop that game object inside.

#

I can simply make a dropdown game object in legacy btw but I want to find a way make that work with tmpro.

native flicker
#

how could i check the color of an image? would it be if (image.color == color(255,255,255))?

green island
sage mirage
#

Nevermind, I found it I just had to add TextMeshProUGUI in order use my dropdown game object that is text mesh pro inside my game object space, for one reason I was using Dropdown class like I said before.

sage mirage
#

What do you mean?

rich adder
#

nvm thats ur variable name i see

native flicker
#

whats wrog here?

public class selection : MonoBehaviour
{
    public Image image;
    // Start is called before the first frame update
    public void select()
    {
        // Check if the color of the image is (0, 255, 0, 100)
        Color targetColor = new Color32(0, 255, 0, 100);

        if (image != null && image.color == targetColor)
        {
            image.color = new Color32(255,255,255,100);
        }
        else
        {
            image.color = new Color32(0,255,0,100);
        }
    }
}```
#

error = Assets\Scripts\selection.cs(7,12): error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)

sage mirage
sage mirage
#

On the other hand, Dropdown class shows the field on the inspector

#

I mean

rich adder
#

what is Dropdown option type

sage mirage
#

It is a class you use in visual studio

sage mirage
#

private DropdownOption field; for example

native flicker
#

thx

sage mirage
#

or

#

public Dropdown field;

#

That's what I mean.

rich adder
#

it should be TMP_Dropdown

sage mirage
sage mirage
#

Yeah! Actually, there is that's cool!

rich adder
#

the only UI that doesnt have TMP variance is Button

#

that comes with a nested TMP_Text tho

#

but regular Button component

prime lodge
#

how can i make the sprint end after it not holding the shift anymore?

rich adder
prime lodge
#

is it the only way?

rich adder
prime lodge
#

okaaay

#

thx

crude prawn
rich adder
#
 float moveSpeed = 0;
 float sprintSpeed = 10;
 float walkSpeed = 5;
 private void Update()
 {
     var sprint = Input.GetKey(KeyCode.LeftShift);
     moveSpeed = sprint ? sprintSpeed : walkSpeed;
 }```
this is as simple and functional as it gets
rich adder
#

kinda pointless for sprint

tough geyser
#

Hi guys, do y'all know where i can find all these classes or whatever they're name like destroy(gameObject), or translate.transform?

rich adder
#

!docs

eternal falconBOT
wild cargo
wild cargo
# rich adder how so?

Oh.. upon second looking it now seems that it would also need the "else" statement replaced with "if (GetKeyUp()), THEN it would work correctly

crude prawn
#

Yeah exactly

crude prawn
wild cargo
#

I would use this approach if I was expecting some kind of effects system later on, like speed modifiers etc. so then it can stack easier

wild cargo
#

GetKey is needed for their approach

rich adder
#

not even just normal speed, but because its in else it will keep/=

wild cargo
#

But there's no division used in your code, just variables am I right?

rich adder
#

right they're fixed speeds

wild cargo
#

Yup

rich adder
#

so if you need increase stats you just increase sprint speed or walkspeed

wild cargo
#

Ohh yeah I completely overlooked that they can be multiplied or divided the same way as in the old code.. stupid me

long anchor
copper locust
#

or its unnecessary

rich adder
#

or you get skewing

rich adder
long anchor
#

The scale is uniform and that's not the issue

rich adder
#

do you even know what uniform means?

#

the screenshot you shared the scales are not uniform

copper locust
rich adder
copper locust
#

oh ok

copper locust
long anchor
#

All the scales are identical aka uniform, the object is not warping or sewing the only issue is the rotation transfer

copper locust
#

oh no

long anchor
#

Anyways I never ment to post it in this chat anyways so moving to the other, I'm not a beginner so sorry mods ig. It was like 5am when I posted so wasn't paying attention

nova swift
native flicker
#

how could i check for an animation has ended?

fickle plume
#

!mute 706939554627584020 3d Don't shitpost across the server, don't post off-topic.

eternal falconBOT
#

dynoSuccess n.e.v.e.r.d.u.l.l was muted.

rich adder
native flicker
#

so how could i add smt to a var when it ends? sorry im new to C# and im trying to learn but im looking online and i don't find much

languid spire
#

Care to explain what 'smt to a var when it ends' means to you

native flicker
crude prawn
wild cargo
#

GetKey does it for all frames until the key is released

crude prawn
crude prawn
#

hmmm my bad i confused getkey and getkeydown

wild cargo
#

You can imagine GetKey as like GetKeyHeld

#

It simplifies the understanding

nova swift
#

Names can be misleading

wild cargo
#

Yeah

native flicker
#

what does this error mean?
'zombie' AnimationEvent has no function name specified! everything is set so idk whats wrong

#

nvm fixed it

sage mirage
#

Hey, guys! How to make FullScreen mode and Windowed mode with a dropdown panel? I have seen some videos with only toggle fullscreen but dont know how to make with options. Any help??

rich adder
wide raven
sage mirage
rich adder
wide raven
rich adder
wide raven
#

This is how it went

#

I cant make it stand up too

sage mirage
#

@rich adder Check it!

#
{
    if (displayModeDropdown.value == 1)
    {
        Screen.fullScreen = isFullscreen;
    }

    else if (displayModeDropdown.value == 0)
    {
        Screen.fullScreen = isWindowed;
    }
}```
rich adder
wide raven
rich adder
wide raven
#
    private void FixedUpdate()
    {
       Move();
        HandleJump();
    }

    private void HandleJump()
    {
        if (IsGrounded && _jumpPressed)
        {
            _jumpYVel = CalculateJumpVel(jumpHeight);
            _jumpPressed = false;

            _moveVel = _rigidbody2D.velocity;
            _moveVel = new Vector3 (_moveDir,_jumpYVel);
            _rigidbody2D.velocity = _moveVel;
        }

    }

    private void Move()
    {
        quaternion playerRot =  PlayerObj.transform.rotation;
       playerRot.value.z = _moveDir;
    }
    

    private float CalculateJumpVel(float height)
    {
        return MathF.Sqrt((-2 * _rigidbody2D.gravityScale*Physics2D.gravity.y * height));
    }

    void GetInput()
    {
        _moveDir = Input.GetAxisRaw("Horizontal"); // takes move input
        _jumpPressed |= Input.GetKeyDown(KeyCode.Space); // takes input for jump using space
    }```
#

this is the movement code @rich adder

fringe perch
#

Hello ! How could I approach adding turning animation when the character is not moving ? Here is what I got so far, everything works except turning parts which have their animation not played (it directly goes to the end)

rich adder
wide raven
#

I can't even make the player the way it should start to jump

rich adder
#
void Update()
{
    input.x = Input.GetAxis("Horizontal");
    input.y = Input.GetAxis("Vertical");

    anim.SetFloat("MoveSpeed", Mathf.Abs(input.x));

    if(Input.GetKeyDown(KeyCode.Space))
    {
        rb.AddForce(Vector3.up * (moveSpeed/1.4f), ForceMode2D.Impulse);
    }
}
private void FixedUpdate()
{
    rb.AddForce( Vector3.right * (input.x * moveSpeed));
}```
#
 private void FixedUpdate()
 {
     rb.MoveRotation(Mathf.LerpAngle(rb.rotation, targetRotation, force * Time.fixedDeltaTime));
 }``` limb
#

and yes the lerp is kinda wrong but I'm testing

wide raven
#

Lemme try

rich adder
#

well i'm not saying you need to copy it exaclty, just showing how simple it is with rigidbodies

wide raven
#

what is anim btw

#

is it connected to the player obj?

rich adder
#

its Animator

wide raven
rich adder
#

ok? you're doing something else though

#

your balancing is different

#

i have limbs that I use

wide raven
#

Yea I'll be using active ragdoll and give it a try then

#

Will inform you :)

thin idol
#

Привіт

wild cargo
thin idol
#

Hello, I downloaded unity version 2022.3F16, when I run the project I get the error "Unity running as administrator". Please help, fix it

wild cargo
#

Because Unity running as administrator probably shouldn't be a cause of concern.. although it should be runnable in non-admin mode too

thin idol
wild cargo
thin idol
crude prawn
wild cargo
wild cargo
# thin idol

Are you purposefully running Unity as administrator (like have you set a flag in the properties of the executable to run in admin mode, or something like that?)

#

Bc that shouldn't be happening

#

Unless you're doing it on purpose

#
Reddit

Explore this post and more from the Unity3D community

rich adder
#

they probably installed Hub with UAC disabled

#

also this is not a code problem

thin idol
thin idol
rich adder
thin idol
rich adder
#

also this is a code channel

#

unlrelated to your issue

thin idol
vestal gazelle
#

Hey quick question,if i have "new Vetcor3" in a loop, do the old Vector3 get forgotten or am i creating more and more things for the computer to remember endlessly?

rich adder
#

you create new one replace old one

vestal gazelle
#

So its not making a metric ton of vectors? Because i dont want a metric ton of them.

rich adder
#

probably the last thing you should be worrying about
its literally floats you're creating

thin idol
vestal gazelle
#

Well there isnt much going on rn in my little game yet it makes my computer fan go crazy and im using a lot of them so i was wondering if that was happening.

wild cargo
#

But structs are very performant (it's like creating ints for example) so that should not be causing the performance dips (if you even have those issues)

rich adder
#

anything 3D will get your fans running

vestal gazelle
#

Not sure what an iteration is but, i have about 6 objects each making a new vector about 60 times a second. Now that i think about it those numbers arent that big all things considered so its probably something else.

wild cargo
crude prawn
#

Could just simply be a bad pc/bad fans

rich adder
#

my old laptop start its lag/fans just by opening the editor in scene view..

vestal gazelle
#

Its definitely not the computer.

rich adder
#

then its def not the structs

vestal gazelle
#

But thanks ill check the profiler

crude prawn
#

Yeah probaly just bad fans then

vestal gazelle
rich adder
#

local variable it would get cleaned up quick, a stored var is just replacing

#

float is about 4 bytes

thin idol
#

What should I do if my visual studio shortcut does not have an image?

rich adder
thin idol
#

I click, everything works, just the shortcut does not have a visual studio image

rich adder
# thin idol How to do it?

this is like basic computer stuff not really unity related.. You go to the original exe foldeer and right click -create shortcut

twin wave
#

Urmm are there any PDF that contains every coding for basics controls?

#

I want to learn it, but just rarely have internet connection

clear seal
#

You search stuff and you find it

#

Text only no vid

rich adder
#

and so does .NET / C#

clear seal
rich adder
clear seal
#

Kwel

twin wave
#

Owww, nice. Thanks

crude prawn
crude prawn
twin wave
twin wave
twin wave
#

I don't want to go into details

crude prawn
#

yeah no problem i understand

clear seal
crude prawn
#

i think the school turns off wifi

clear seal
crude prawn
#

yeah same idk weird school

twin wave
#

So straight up no internet connection

clear seal
twin wave
#

Yes

rich adder
#

how are you connected now

twin wave
#

Cause I'm not in campus

#

It's holiday mate

rich adder
#

so hows the page says
yea...page not found

crude prawn
#

where are you from?

twin wave
#

confidential

rich adder
fossil drum
#

He has CH in his name, which normally means china

crude prawn
#

i mean idk what u want us to do its pretty hard to learn unity without internet

rich adder
#

CCP

twin wave
#

So there's no way?

crude prawn
#

i also think u cant use unity without internet

rich adder
twin wave
crude prawn
#

u need to have internet once a week or u cant use the engine

rich adder
#

not for long

twin wave
fossil drum
#

You can afaik, only the new version that comes out next year requires you to be online every couple of days.

rich adder
#

pretty sure you can also just run it without hub no?

fossil drum
#

No idea how the new version next year is going to force it tbh, but you should be able to work with Unity like you guys said now if you just download the docs.

twin wave
#

I don't know

crude prawn
twin wave
#

How hard is it to get started even?

rich adder
crude prawn
#

depends on how much work you put in

fossil drum
#

And on your brain power UnityChanLOL

twin wave
twin wave
rich adder
crude prawn
twin wave
#

2 hours a day

twin wave
twin wave
crude prawn
rich adder
#

they could be watching you 🕵️

twin wave
#

None of them use discord

crude prawn
#

how the school doesnt have internet 😂

twin wave
#

So I'm fine

rich adder
twin wave
crude prawn
#

weird country and school

twin wave
rich adder
crude prawn
#

internet just helps the school with knowledge etc.

rich adder
#

knowledge is forbidden without control in those places

crude prawn
#

oh yeah true

twin wave
crude prawn
#

is there even game devs in ur country?

twin wave
#

Just wait till I get into Diploma then I can have my phone. Free access no restrictions

twin wave
rich adder
#

yeah going from dealing with schools to governament , not big change usually lol

#

one conditions for the other

#

anyway going offtopic here :ima seee myselfout

crude prawn
#

tbh we are going a little off topic thn what this server allows

#

same

twin wave
#

yea too far

crude prawn
#

@twin wave if you have any questions about coding this is the channel

twin wave
#

Oh, okay. I'll finish the mock up first

#

If I have any problems I'll be here right away

#

Thanks

lapis halo
#

Im having trouble making my enemy follow the player after spawning in.
Currently, they go towards the players spawn position instead of the player's current position.

    {
        enemy.transform.position = Vector2.MoveTowards(gameObject.transform.position, player.transform.position, speed * Time.deltaTime);
    }```
#

^ The enemy's are the ones spawning in, not the player.

harsh owl
#

My Raycasts for the suspensions which hold my car into its "floating mode" are always falling back a couple of frames when i accelerate my car resulting in completely bugging my car and moving it really weird as soon as i accelerate a bit quicker. Any idea how i can make them stay where i put them?

code for the suspensions: https://gdl.space/uvupucirah.cs

rich adder
#

back at it I see 😏

rich adder
#

or the whole raycast

#

put it in update and pass those values to fixedupdate

harsh owl
#

okey ill try

rich adder
# harsh owl okey ill try
   Vector3 spring_direction;
   private void Update()
   {
       didHit = Physics.Raycast(transform.position, Vector3.down, out hit, maxRayLenght);
       if (didHit)
       {
           Debug.DrawLine(transform.position, hit.point, Color.green);
           spring_direction = Vector3.up;
           Vector3 tire_world_velocity = rb.GetPointVelocity(transform.position);
           current_offset = spring_length - hit.distance;
           velocity = Vector3.Dot(spring_direction, tire_world_velocity);
           force = (current_offset * spring_strength) + (spring_dampening * velocity);
       }
       else
       {
           Vector3 end_point = transform.position + new Vector3(0, -maxRayLenght, 0f);
           Debug.DrawLine(transform.position, end_point, Color.red);
       }
   }
   void FixedUpdate()
   {
       rb.AddForceAtPosition(force * spring_direction, transform.position);
   }```
rich adder
# lapis halo please

this should prob b changed
from
enemy.transform.position = Vector2.MoveTowards(gameObject.transform.position, player.transform.position, speed * Time.deltaTime);
to
enemy.transform.position = Vector2.MoveTowards(enemy.transform.position, player.transform.position, speed * Time.deltaTime);

rich adder
lapis halo
rich adder
lapis halo
#

I was thinking of getting the player's position using get component then the enemy's just going towards that position.]

rich adder
lapis halo
#
 public GameObject player;
rich adder
#

how do you assign it, show me the inspector if thats what you used

harsh owl
lapis halo
#

which might be the problem

rich adder
#

you have to assign the instance in the scene if you're spawning player in

lapis halo
#

The enemy prefab doesn't allow me to assign the player in the scene

lapis halo
#

and i have no clue how to change that

lapis halo
#

god this stuffs makes no sense

rich adder
lapis halo
#

I dont even know

verbal karma
#

I have a script without a gameobject, and I need to run it without using a static method, whats the best way?

summer stump
severe valley
#

^LOL in the chat guys. am i right or am i right!? xdddeezers

verbal karma
#

Licking Ohio Lollies 😂

severe valley
#

im gonna do stuff lil bro

frosty hound
#

We don't need the spam @severe valley

severe valley
#

ok mb

verbal karma
#

no problem fam

severe valley
#

or is it? 🤔🤔🤔

verbal karma
#

thanks for the help btw jlm!!

severe valley
#

no porblom

verbal karma
#

bogos pinted?

severe valley
#

how to like and subscribe in unity gaming engine? or am i thinking too far for your guys brainzzzz!!!!!

verbal karma
#

👽 🤯

severe valley
#

wtf

#

(what the fluff)

frosty hound
#

!mute 742458880511967292 3d Spamming

eternal falconBOT
#

dynoSuccess jllm was muted.

verbal karma
#

get muted 😆 kiddo got the like and subscribe from ohio cell

polar acorn
#

Did some kids just get Discord for Christmas

verbal karma
#

date the bay 👊 😂

verbal karma
#

i need it for christmas

frosty hound
#

!mute 267702803831455751 3d spamming

eternal falconBOT
#

dynoSuccess siqius was muted.

dusky pendant
#

helloooo, need some help with some code im trying to get working, i have not a single clue of what im doing outside of some general knowledge xD, is this the right place to post questions like such?

dusky pendant
#

:D great, so im doing some stuff with optimizing my avatar i have in unity meant for VRC, so im using version 2019.4.3, Im in the proccess of putting toggles into blendtrees instead of multiple layers,

#

the only issue i have is that some of my toggle animations are animated to have dissolves, and since blendtrees dont play animations, rather just switch from the animations state they are curently in (so since it starts as soon as the scene goes into play mode, itll just switch from the last frame of the animation)

#

so im trying to make a custome script thatll detect when my paramater is set to a certain value than replay a certain animation when its set to that value

#

this is the script i curently have,

#

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

public class Dissolve : MonoBehaviour
{
public Animator animator; // Reference to the Animator component
public string parameterName; // Name of the blend tree parameter
public string animationStateName; // Name of the animation state
public float detectionValue; // The value to detect

private float lastParameterValue; // Last known value of the blend tree parameter

void Start()
{
    // Initialize lastParameterValue with the current parameter value
    lastParameterValue = animator.GetFloat(parameterName);
}

void Update()
{
    // Get the current parameter value
    float currentParameterValue = animator.GetFloat(parameterName);

    // Check if the parameter value has changed to the detection value
    if (currentParameterValue == detectionValue && currentParameterValue != lastParameterValue)
    {
        // Restart the animation
        animator.Play(animationStateName, -1, 0f);
    }

    // Update lastParameterValue
    lastParameterValue = currentParameterValue;
Debug.Log()
}

}

#

the issue is, its saying my game object dosent have an animatior when it does, and it complains about not being able to find the paramater due to not seeing the animator

cosmic dagger
eternal falconBOT
narrow ore
#

Hello! I'm just starting to make a little 2d game and I could use some help with movement. I've got a neat little movement animation, but i'm trying to figure out how to make the idle animation stay facing whatever direction the player was facing last (if that makes sense)

#

because right now the player snaps back to the right because that's what i have the idle animation set as

teal viper
#

Did you try flipping the sprite?

next sleet
#

can anyone teach me how to add height calibration to my vr game?

teal viper
strong moth
lethal depot
#

hii guys right now i'm working on a project that consist of a enemy patrolling , the enemy patrols between the waypoints(white cubes in the given video) and player if detected it chases the player and attacks it and the health from health bar decreases, but the enemy apparently goes for the ground component instead of player i dont know why its doing that , here are some information about the components attached to each objects 1.player= a capsule collider, health script,movement script and rigidbody 2. enemy= a eyepoint child component(to represent eye, sphere collider ( to detect if the player is in attackrange,enemyAI script (responsible for navmesh movement)and enemyEyesight script,navmeshAgent component)

wintry quarry
lethal depot
#

sorry about the confusion i'll share the code

wintry quarry
#

Please share code via paste sites as per !code

eternal falconBOT
wintry quarry
#

Paste site

wintry quarry
#

Or switch the order of those conditions

lethal depot
#

i'll try