#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 838 of 1

elder hearth
#

Well can be

sour fulcrum
#

i have many potential flood points

elder hearth
sonic harbor
#

what's needed for that

elder hearth
sour fulcrum
#

actually would i even add 7 in this example or would i only add neighbours i've "passed"?

elder hearth
sour fulcrum
polar acorn
sonic harbor
verbal dome
#

Pretty sure that when you add an unvisited neighbor to the stack (or queue), you can mark it as visited/explored right away

naive pawn
#

i was thinking before the foreach. you'll get duplicates either way, but the order of duplicates would be different

i think it's better in one iteration and worse in another? i haven't thought about this kind of thing in a long time and tbh i need to stop procrastinating ๐Ÿ˜“

elder hearth
sonic harbor
verbal dome
naive pawn
#

@sour fulcrum it seems like you had a question but it kinda got lost

what was your question, also are you going for breadth-first or depth-first

elder hearth
sour fulcrum
#

that question is new to me so i'm not sure, give me a sec ill give a bit more context

sonic harbor
night raptor
#

It would be very kind of you if you did that elsewhere

sonic harbor
elder hearth
sonic harbor
naive pawn
night raptor
sour fulcrum
#

ok so i have these tiles, and i have them like voxelised into a little grid right.

the voxels that aren't being drawn in are "uninitalized" right now (just an enum). I need to flood this space in a way where the green floods into the uninitialized voxels (apologies if i'm misusing a term or something)

#

I guess the problem im running into based on how yall are responding is that my flood points are pretty varied and inconsistent in placement

naive pawn
sonic harbor
#

DO YOU NEED A LAPTOP TO GET STARTED WITH CODING AND UNITY PROJECT

sour fulcrum
#

can you just fuck off

polar acorn
verbal dome
naive pawn
verbal dome
#

So you can avoid doing the extra check after dequeuing/popping from the stack

sonic harbor
frosty hound
#

Is there an actual question here?

#

Obviously you need a computer of some sort to get started with Unity.

naive pawn
sonic harbor
elder hearth
#

Is there a way to speed up Vector3.MoveTowards?

transform.localPosition = Vector3.MoveTowards(this.gameObject.transform.localPosition, Vector3.zero, Time.deltaTime);
``` hers the code I'm using(it is in fixedUpdate)
naive pawn
#

multiply Time.deltaTime by the desired speed

night raptor
polar acorn
#

Increase that

naive pawn
elder hearth
#

Okay thanks a lot!

naive pawn
#

damn, i refunded my tech skill tree and took everything out of competitive programming...

elder hearth
naive pawn
#

oh, yeah

elder hearth
#

xDDD

elder hearth
naive pawn
#

variable (adjective)

elder hearth
#

Ahhhh thought so

night raptor
sour fulcrum
#

yes

#

maybe my brain was using the term too literally vs programmically

#

imagine like literal flooding

night raptor
# sour fulcrum yes

And the yellow ones presumably work as boundaries for the flooding? You don't want any liquid sim (or flooding animation) happening there though do you?

sour fulcrum
#

correct, but the work is already done there so-to-speak in the sense that this flooding would just be checking if current voxel is green then "somehow" making any white/empty tiles green (via the solutions we've been talking about)

#

yeah nothing fancy nor realtime, this isn't for actual flooding ๐Ÿ˜…

elder hearth
naive pawn
#

what did you expect

elder hearth
#

My brain kinda just forgot the math

#

maybe i should get some proper rest lol

naive pawn
#

lower number = lower speed

#

deltaTime * 0.5 < deltaTime (deltaTime > 0)

elder hearth
#

I realised that now lol

naive pawn
#

MoveTowards takes a max delta
if you have a deltaTime of 0.1 and a speed of 2, if you multiply those together, you get 0.2, the amount to move in 1 frame
deltaTime = 0.1 --> 10fps, so with 10 frames (1 second), you move by 2 (matching that initial speed)

verbal dome
#

Also @sour fulcrum this might be a good usecase for a Job, but make it work first, jobify it later

elder hearth
night raptor
# sour fulcrum correct, but the work is already done there so-to-speak in the sense that this f...

Ok. So what you could do is start by finding all the green cells, marking them as explored and adding all of them to the stack/queue. Then you can start running this #๐Ÿ’ปโ”ƒcode-beginner message algorithm by going through every element in the stack and adding all the neighbours which are not yet explored to the stack/queue (you would also not want to add yellow cells there).

Assuming that you have easy access to the state of each cell, you don't need to keep track of the explored cells separately, instead you can turn each cell to green immediately in the foreach loop if it is unexplored (not green or yellow) and you can then treat cell explored if it is green by color (or whatever state the green color indicates in your case). The whatever structure you have for the cells (3d array?) would serve the purpose of the bitset Chris mentioned here #๐Ÿ’ปโ”ƒcode-beginner message

sour fulcrum
#

thank you very much, i appreciate the time and advice a lot ๐Ÿ™

#

ill let you know how it goes

night raptor
# sour fulcrum thank you very much, i appreciate the time and advice a lot ๐Ÿ™

No problem. Feel free to ask if anything is unclear. Note that I wrote the pseudocodes from memory, they are not tested to work. You can google iterative BFS/DFS implementations to find a lot of similar solutions (filling and searching is very similar in nature). Once you get it implemented, you can try changing the stack to a queue or other way around and see if it affects the performance. Using stack makes it depth-first and queue makes it breath-first

#

One important considerations is also how many ways you want to search from a given voxel. The less is more efficient but you need to do more if you need the fill to snug through corners or edges. The flood fill wikipedia page has a nice visualization of the effect in 2D with 4-way and 8-way fills. In 3D, you can do 6-way, 18-way or 26-way fills. Looking at the image you send of your level, 6-way fill is probably what you want

night raptor
#

Just for extra demonstration, I can go through this example assuming a 8-way (diagal neighbours also checked) breath-first implementation (queue) of the algorithm explained. So the algorithm would start by collecting all green cells and adding them to the queue which would then only be [ 3 ]. Then we would start the while loop which takes the 3 out of the queue and adds all the neighbours (which are white) of 3 to the queue and colors them green. The queue would now look like this [ 4, 8, 7, 6, 1 ]. Now 4 would be removed and nothing added since 4 does not have white neighbours anymore. The next iteration would remove 8 and add 12 and color it since that's the only white neighbour. Now the queue would look like this [ 7, 6, 1, 12 ]. At this point everything except 11, 10, 9, 5 and 0 are colored green.

7 has an unexplored neighbour 10 so that is added and colored. 6 has unexplored neighbours 9, 5 and 0 so those are added to the queue and colored green. Now the queue is as follows [ 1, 12, 9, 5, 0 ] and the whole room except 11 is colored green. The algorithm doesn't know that yet and goes through each of the cells in the queue removing them one by one, since it doesn't find any new unexplored (white) neighbours for any of them, the queue will become empty and the algorithm will terminate right there.

elder hearth
#

How performance heavy is adding and removing a component during runtime?

frosty hound
#

Impossible to say. Doing so is normal workflow though.

elder hearth
#

Ahh okay thanks

frosty hound
#

Though, if you're needing to do that, you might consider just using prefabs or prefabs variants. But it depends on what you're doing.

swift crag
#

yeah, give us some more details and we might be able to give more specific advice

ionic zealot
#

Hii, is it possible to have time scale affect particles?

swift crag
#

oh, interesting, i always figured that particle systems would respect your timescale

#

my first thought would be to write a script to handle that

#

just call it ParticleTimescaleHandler or something and have it set the simulation speed of the system

short hazel
#

By default it uses the regular delta time, but there's a check box to tell it to use unscaled delta time somewhere in its settings, if I remember correctly

swift crag
#

oh, yeah, then that should work fine

#

I looked at the settings, saw that property, and decided "oh, but that's not the timescale, that's delta time!"

ionic zealot
#

https://codeshare.io/5Dw7EW

My outputted reticle position does not at all match the position on canvas, but i have no idea why, can anyone please help me?

naive pawn
ionic zealot
#

I dont think so, cause then theres anchors, yk, but im not a remotely smart lad, so could be wrong

swift crag
#

The min/max anchors tell you how much you stretch based on the size of the parent RectTransform

#

it's the fraction that you, with a width/height of zero, try to occupy

#

(so, anchors of 0.5 mean you don't stretch at all!)

naive pawn
naive pawn
swift crag
#

right, that's more accurate to say

#

my statement was the obnoxious kind of true ๐Ÿ˜‰

ionic zealot
#

So, would anchored position save me then here maybe?

naive pawn
#

ive told you what, 4 times now to use anchoredPosition, haven't i?

ionic zealot
#

Well, yeah, but it just all kinda broke every time, so i keep trying to modify it enough for it to work

naive pawn
#

use anchoredPosition and make sure your anchors are set properly and make sure you're using anchoredPosition consistently.

ionic zealot
#

Nah yyea nah,it doesnt work, unity sucks sometimes

#

or ig i sucks at unity sometimes

ivory bobcat
#

What do you mean it doesn't work? Is there an error?

#

Are the values not what you'd expect? Anchored position.

ionic zealot
#

Yeah, the y pos is like 2-300 too high

naive pawn
ionic zealot
onyx ridge
#

I'm following a tutorial and I'm really confused why the scoreboard is being referenced like this instead of with a [SerializeField] and then dragging it into the inspector? The reason the guy gave was

"There are a lot of different ways to get references inside Unity. Weโ€™re most familiar with using SerializeField and dragging objects into the Inspector, but in this case thatโ€™s probably not the best practice. A Scoreboard is currently a MonoBehaviour attached to a GameObject in the scene, while your enemies are prefabs โ€” and from scene to scene those prefabs might not persist. You might even want to instantiate enemies at runtime, and they wonโ€™t be able to spawn with a SerializeField reference to a scene object. In that situation, it can be a good idea to obtain that reference in another way."

I don't really understand this explanation. Why wouldn't enemy be able to spawn with a SeralizeField reference to a scene object all of a sudden? I just don't see how scanning the entire project with FindFirstObjectByType<Scoreboard>() is better?

solar hill
onyx ridge
#

idk why I find this so confusing

#

So prefabs can reference other prefabs in [SerializeField] when instantiated but not objects in the scene?

grand snow
#

Finding objects by name/type should be done sparingly as its slow

onyx ridge
#

they did say that tbf

solar hill
grand snow
#

The good way to overcome the issue is that the spawned objects get initialised and given the references needed

#

but thats not easy for beginners

onyx ridge
grand snow
#

Most beginners of unity have no prior programming knowledge ๐Ÿคทโ€โ™‚๏ธ

solar hill
sour fulcrum
#

a prefab referencing something in the scene is like a boxed blender at walmart having a reference to the wall socket in your kitchen

grand snow
#

what are you smokin

onyx ridge
grand snow
#

a scene object CAN reference a prefab and thus can give shit to instantiated stuff

onyx ridge
#

what if I just made the Scoreboard a prefab then referenced it that way in [SerializeField]

#

then they're both prefabs

grand snow
onyx ridge
#

So could I just make the Scoreboard a prefab and reference it through [SerializeField] that way to dodge the issue?

grand snow
#

The way to really solve the issue is to just setup what you spawn after is created

#
[SerializeField]
Enemy enemyPrefab;
//...
Enemy newEnemy = Instantiate(enemyPrefab);
newEnemy.Init(scoreboard, coolShit);
#

^imagine this is in a component already in your scene so it can serialize a ref to scoreboard

#

perhaps it could be named EnemySpawner ?

onyx ridge
#

Both Base Enemy and Scoreboard is in the Hiearachy but I wouldn't be able to drag Scoreboard into a [SerializField] on the Base Enemy because it's a prefab?

#

oh wait it's an instance of a prefab

grand snow
#

yes thats correct

onyx ridge
#

so it's also an object

grand snow
#

so these can just have a serialized ref

#

But an instantiated prefab would not and requires manual initalisation

naive pawn
grand snow
#

everything is an System.Object

onyx ridge
#

but I have a [SerializeField] GameObject destroyed VFX but it's a prefab that I drag into the field so that's why that works?

grand snow
#

cus its a prefab ASSET

onyx ridge
#

But I wouldn't be able to do the same thing is Scoreboard because it's a game object in the scene?

grand snow
#

YES

#

think logically, how can a prefab asset possibly reference something in a scene when it may not even be loaded??

#

what happens if you tried to use that prefab in another scene?

sour fulcrum
#

(also just as a vibe check, this is a very big thing beginners "struggle" to learn so don't stress if it feels weird)

grand snow
#

Yea that is true. The important thing to understand is that when we "load" a scene unity just makes everything that was in the scene fresh

onyx ridge
#

Yea this is the first thing I've come across so far that I'm really struggling to understand, referencing things in different ways. So far it's just been a memory game apart from this

grand snow
#

An asset is different because its constant and the same and wont go anywhere

onyx ridge
#

so the reason we can't do it isn't "You might even want to instantiate enemies at runtime, and they wonโ€™t be able to spawn with a SerializeField reference to a scene object" But it's that we literally can't because unity doesn't let us even if we tried, and not because of something I 'might' want to do later on?

#

As in, it's not something I 'could' do now but 'shouldn't', it's that I literally can't because unity doesn't allow it?

grand snow
#

Its just not logically possible with unitys design

#

and thats fine and normal and expected

solar hill
#

its a bit of a catch 22

grand snow
#

It could be overcome but would be dumb and unreliable

solar hill
#

yeah even if possible, it wouldnt be advisable

onyx ridge
#

so scoreboard = FindFirstObjectByType<Scoreboard>(); is the best way to do it?

grand snow
#

no but just do that to learn how stuff works

#

you can learn better ways down the road

onyx ridge
#

It's really confusing trying to keep in mind how everything links together in scripts - inspector - prefabs - hierarchy

onyx ridge
#

Thanks for the help everyone ๐Ÿ™‚

placid solstice
#

hello, im trying do a movement system for the camera, this error appears:

Movement.Update () (at Assets/Movement.cs:24)```

the line was is wrong is

```cs
GetTransform.Translate(new Vector3(horizontal, vertical, 0f) * Time.deltaTime * velocidade);
#

im sorry for dont have some description about the error

#

but, basically, the script what contains this line was used in a "Main Camera"

#

idk if have a problem about this

#

i can show the code if was necessary

rich adder
radiant voidBOT
placid solstice
#

like, all

#

all lines

rich adder
placid solstice
#
using UnityEngine;

public class Movement : MonoBehaviour
{
    private Transform GetTransform;

    private float horizontal;
    private float vertical;

    [SerializeField] private int velocidade;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        horizontal=Input.GetAxis("Horizontal");
        vertical=Input.GetAxis("Vertical");

        GetTransform.Translate(new Vector3(horizontal, vertical, 0f) * Time.deltaTime * velocidade);
    }
}
rich adder
#

GetTransform is null as the message pointed out, so you did not assign it

placid solstice
wintry quarry
rich adder
#

also weird ass name lol

placid solstice
rich adder
#

GetTransform implies a method, also what ๐Ÿค” ?

teal viper
#

Imagine a programming language where you need to spell variable names in a specific weird way for a hidden behavior to be applied to them. ๐Ÿ˜…

placid solstice
teal viper
#

No. There aren't many languages that limit you in terms of naming your api.

placid solstice
#

ill read again

#

wait a sec

ivory schooner
#

Does anyone feel like helping me with understanding how to make a camera reset feature in a gyro experiment I'm working on? I have been at it for like a week and can't get it right. ๐Ÿ™

swift crag
#

what does that entail?

ivory schooner
swift crag
#

yes; what would a "camera reset feature" be?

keen bridge
#

thanks! ๐Ÿ™‚

minor pawn
#

"transform" is a built in variable inside all MonoBehaviours

bold root
#

Once I have a usable build whatโ€™s the normal pathway to trying it out and maybe publishing it privately so someone else can try it as well

teal viper
keen bridge
#

hey, is there a way to make this health bar centered? the only way I know how is to manually adjust it until it "looks right". Is there a button to do this automatically?

timber tide
#

rect transform? wat

#

oh you're using a world space UI right

keen bridge
#

yes that is correct

timber tide
#

Should just be able to center the pivot as you have it and zero out the coordinate space assuming the canvas is child to your character

#

and modify the y a bit manually

keen bridge
#

ahh ๐Ÿ˜… thank you, i got it ๐Ÿ™‚

keen bridge
#

Hello,

I am watching a youtube video for attacking other troops, the person has setup a trigger sphere so when a troop enters the collider it will set them as their target. He recently added the "OnTriggerStay" function, but kept the "OnTriggerEnter", but I'm not sure why. If the code in both stays the same, whats the point in keeping "OnTriggerEnter"? Unless im missing something it would be best to remove the OnTriggerEnter event?

    private void OnTriggerEnter(Collider other)
    {
        if(isPlayer && other.CompareTag("Enemy") && target == null)
        {
            target = other.transform;
        }
    }

    private void OnTriggerStay(Collider other)
    {
        if(isPlayer && other.CompareTag("Enemy") && target == null)
        {
            target = other.transform;
        }
    }
stoic mural
keen bridge
#

from my point of view OnTriggerEnter is not useful, as if it was removed then OnTriggerStay would set the target value anyway? Not sure if im missing something

cosmic dagger
stoic mural
keen bridge
cosmic dagger
#

if you only need to check once, then OnTriggerEnter is the better, more performant option. you can use OnTriggerExit to check if that enemy left the trigger, then set the target to null . . .

stoic mural
#
  • Enter = pick target quickly
  • Stay = pick a new target already inside
  • Exit = clear target when it leaves range
#

Do not take it as ultimate solution but to understand how it works

cosmic dagger
fickle plume
#

@stoic mural Don't post slop code here. If you don't have the answer don't delegate it to LLMs.

keen bridge
#

is it possible to add descriptions to components?

Its not immediately clear that this is for "is troop in range", I imagine a troop could have many colliders, which could make it hard to know which one is for what.

fickle plume
#

You can put them on named game objects, or assign named unique physics materials with default values to differentiate.

keen bridge
#

so for the first option, id have
troop

  • object named "in range collider" as a child of troop, with "sphere collider" attached to that, instead of the troop
fickle plume
#

events from children colliders should propagate to parents

#

Only 2d I think has weird behavior where collider placement matters for sorting layer when it's not on the object with renderer. 3d should be fine.

keen bridge
#

thank you ๐Ÿ™‚

wet pivot
#

I'm very confused by the velocity change function force mode. I have a simple movement script here and the speed keeps going up if I keep pressing the move buttons.

` private void Update()
{
moveDirection = orientation.forward * inputManager.verticalMove + orientation.right * inputManager.horizontalMove;
}

private void FixedUpdate()
{
    MovePlayer();
}

private void MovePlayer()
{
    rb.AddForce(moveDirection.normalized, ForceMode.VelocityChange);
}`
#

Just for clarity, vertical/horizontalMove are the x and y axis of a joystick/WASD input and orientation is an empty object in the center of my player object to keep track of which way he is facing.

#

I thought velocity change forcemode instantly sets the movement speed to the first input vector, in this case moveDirection.normalized. If I'm using a normalized movement vector, shouldnt the velocity always be 1?

#

hmm documentation says "Add an instant velocity change to the rigidbody, ignoring its mass." so I guess it adds 1 unity of velocity to the rigidbody every frame?

fickle plume
wet pivot
fickle plume
#

it just sets it to vector length

wet pivot
#

oh yeah u right 10 is not a vector3 XD. hm this is still weird unexpected behavior imma try it out in a scene by itself maybe something else in my scene is messing with the physics... or maybe the physics settings.

keen dew
#

AddForce will always add more velocity to that direction regardless of mode. If you want a specific velocity just set it directly

wet pivot
#

ah ok. I followed a pretty long tutorial series that used direct velocity changes, but the code got quite bloated and the direct velocity changes led to some issues that the youtuber fixed off-screen... and then another youtube tutorial said changing force directly is actually BAD and using addforce is better...

#

it seems he misrepresented how addforce actually works

#

I'm gonna just try to rebuild what I had before using direct velocity changes and just pay more attention to what I'm doing so I don't lose track of how it all works ๐Ÿ˜…

fickle plume
keen dew
#

Neither of them is good or bad, they're just for different use cases. Setting velocity directly gives you snappy, instant movement but you have to manage it manually and adding more features like jumping and knockback is more difficult. AddForce gives you natural acceleration and deceleration and interaction with physics objects but you lose some control and you have to tweak it more to get it right

wet pivot
#

Some of them were direct velocity changes, but some stuff like the dash were impulse forces and sometimes the velocity would get set and override the added forces. Got really messy and hard to keep track of all the different conditions.

#

Sorry to ramble, but it's at least good to know that this is something that tends to cause issues when using rigidbody movement and it isn't just me being a complete noob.

fickle plume
#

I've only experimented briefly with physics based controller, but it absolutely possible to have a nice snappy physics based one. You usually want to increase gravity, and add linear damping and also control friction on surfaces depending on conditions. There's a lot of corner cases to handle but it's doable.

wet pivot
#

Yeah he makes a pretty sick rigid body parkour character controller by the end of the series ngl but again very bloated and confusing to navigate

#

my goal currently is to split it into different scripts and get a better grip on how and when it changes velocities so I can implement my own movement features without breaking everything

bold root
#

I just imported NGO and the unity multiplayer packages, but when i click start host i get this error and when I click start server i dont get any errors. Any idea what causes this? The error links to the default unity transport script. Not even sure where to go about debugging this

unkempt adder
#

Can anyone help me understand this code I found from a tutorial?

ionic zealot
#

enemy: (141.64, 99.92) reticle: (137.43, 94.11) Accuracy: 1462.082 I dont think that's right

float distance = Vector2.Distance(reticle.anchoredPosition, enemyLocalPos);```

This is the func

```c#
void ResolveShot(bool won)
    {
        Canvas canvas = reticle.GetComponentInParent<Canvas>();
        RectTransform canvasRect = canvas.transform as RectTransform;

        Vector2 enemyLocalPos;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(
            canvasRect,
            cam.WorldToScreenPoint(enemyTarget.position),
            canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : cam,
            out enemyLocalPos
        );

        float distance = Vector2.Distance(reticle.anchoredPosition, enemyLocalPos);

        Debug.Log("Accuracy: " + distance);

        Time.timeScale = 1f;

        float hitThreshold = currentSize * 0.5f;

        if (won && distance < hitThreshold)
        {
            Debug.Log("You won");
            _enemy_anim.speed = 2f;
            _enemy_anim.SetTrigger("Die");
        }
        else
        {
            Debug.Log("You lost");
        }
    }

Please help me figure this bit out cause I am using anchored pos but its still breaking

naive pawn
radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #๐ŸŒฑโ”ƒstart-here

naive pawn
#

can't help without the necessary context ๐Ÿ˜‰

ionic zealot
unkempt adder
sour fulcrum
unkempt adder
#

ok, do i just send it here?

teal viper
#

!code

radiant voidBOT
naive pawn
#

i could probably help, but i'm also fighting a deadline and can't guarantee availability. if you DM'd me you'd just end up wasting your own time lol

unkempt adder
#

oki thx

bold root
#

its like going to talk to your professor/teacher and then just sitting there silently waiting for them to guess what you need help with

stoic mural
# unkempt adder ok, do i just send it here?

Yes ๐Ÿ‘๐Ÿป send your questions as many as you want and wait to replay ( you will get one) and try again to solve it ( if it works then good) and if donโ€™t then ask again and we will try to help you ( donโ€™t forget to help another person here) and it okay if nobody catch it on first try just try to make your issue explaining clearer

polar acorn
ionic zealot
#

Oh, uhh i fixed it

#

I dont really remember how, but it works now

humble summit
#

anyone here ever used the meta xr toolkit. i am using it to setup full body tracking, everything works except grabbing and picking up items. i used an older system from before i introduced the full body tracking feature and now the old system doesnt work anymore

ionic zealot
#

This just makes no sense

//doesnt work
void HandleShootingInput()
    {
        if (_dead) return;

        if (Input.GetMouseButtonDown(0))
        {
            _faster = true;
            shootingPhase = false;

            _player_anim.speed = 2f;
            
            _gun.active = true; 


            Time.timeScale = 1f;
            
            _player_anim.SetTrigger("Shoot");
            StartCoroutine(Flash());
            ResolveShot(true);
        }
    }

    IEnumerator Flash()
    {
        _gun.active = true;
        Debug.Log("FlashCoroutineCalled");
        yield return new WaitForSecondsRealtime(1f);
        _player_anim.speed = 2f;
        flash.Play();
        _shoot.Play();
        _player_anim.speed = 0.5f;
        _gun.active = false;
    }```
```c#
//works
void HandleShootingInput()
    {
        if (_dead) return;

        if (Input.GetMouseButtonDown(0))
        {
            _faster = true;
            shootingPhase = false;

            _player_anim.speed = 2f;
            
            _gun.active = true; 


            Time.timeScale = 1f;
            
            _player_anim.SetTrigger("Shoot");
            _shoot.Play();
            StartCoroutine(Flash());
            ResolveShot(true);
        }
    }

    IEnumerator Flash()
    {
        _gun.active = true;
        Debug.Log("FlashCoroutineCalled");
        yield return new WaitForSecondsRealtime(1f);
        _player_anim.speed = 2f;
        flash.Play();
        _player_anim.speed = 0.5f;
        _gun.active = false;
    }```

I need a bit of a delay before the shot cause of the animation, but this is just broken
undone rampart
stoic mural
stoic mural
elder hearth
#

I was looking for hours to find the reason I couldn't jump after running into walls, turns out my sphere was too big...

ionic zealot
ionic zealot
#

Mainly cause its a mixamo read only animation and i cant really add on

undone rampart
#

or duplicate the animation file and it will create a writable copy

ionic zealot
#

Where?

undone rampart
#

there is an animation tab

ionic zealot
#

Ohh i see

undone rampart
#

there should be an events foldout there

open crater
#

Guys what is a logic script? And how to figure out if the script im writing is logic or not

frosty hound
#

Where did you hear about a "logic" script?

#

By definition, every script you make contains "logic".

open crater
frosty hound
#

Same question, where did you hear about that? And by definition every script contains logic.

#

What are you actually trying to achieve?

red ivy
#

Why is my physics.raycast detecting Collider_01 at some parts of the screen?

#

It doesnt really detect what it should

#

everything is Collider_01

frosty hound
#

Search for Collider_01 in your hierarchy and see what the object is?

#

Perhaps your raycast isn't starting or firing in the direction you think it is? Or it is, but it's being blocked by said collider?

elder hearth
#

This is the part of my movement script that is called in update

            Vector3 moveDirection =
            transform.right * CurrentMovementInput.x +
            transform.forward * CurrentMovementInput.y;

            if (moveDirection.magnitude > 1f)
                moveDirection.Normalize();

            transform.position += MoveSpeed * Time.deltaTime * moveDirection;
``` It clips into objects, how can I prevent this whitout adding any performance-heavy tasks?
frosty hound
ionic zealot
#

Hi, y'all, can anyone help me with this

'PlayerRigged (2)' AnimationEvent 'Shoot()' on animation 'mixamo.com' has no receiver! Are you missing a component?

I looked it up and i added a script onto the game object that just does this

using UnityEngine;

public class AnimationReceiver : MonoBehaviour
{
    public DuelSystem duel;

    public void Shoot()
    {
        duel.Shoot();
    }

    public void SpawnGun()
    {
        duel.SpawnGun();
    }

    public void RemoveGun()
    {
        duel.RemoveGun();
    }
}```

But still get the error, any ideas?
red ivy
#

some fucking colliders were on the way

#

invisible wodoo crap

elder hearth
frosty hound
#

You're not using physics at all, if you're using transform.position

elder hearth
#

Oh yes I know but I was just saying this is on a rigidbody with physics

#

Also thanks for the help!

wintry quarry
polar acorn
polar acorn
stoic mural
#

Should you separate your Player movement into another script? And make method to handle the player and then the DualSystem script manage the dual interactive between the player and the enemy?

turbid jolt
#

how would i be able to have my tank move by itself as an enemy npc if anybody knows roughly, i also kind of need the turret to be able to shoot and etc by itself too seperately from the main body

#

i have the player version worked out

#

and ill add health damage after the movement parts

wintry quarry
#

it's a pretty vague question

solar hill
#

this is also multiple problems

#

and not one singular one

#

break it down first

turbid jolt
#

i see

solar hill
#

start with basic AI pathfinding first

wintry quarry
# turbid jolt and ill add health damage after the movement parts

Almost certainly the stuff like health and damage etc should be common to both the player tank and the enemy tank. I would expect generally that the two tanks are almost identical except for a couple of components, e.g. "PlayerTankControl" vs "AITankControl" scripts

#

assuming they are meant to be the same physically other than who controls them

stoic mural
#

And โ€œTurretHandler.csโ€

turbid jolt
turbid jolt
stoic mural
pearl galleon
#

hello i need i build a mobile app game the problem is the apk is installed but i cant open it i verified it its installed in the phone itself i tried everything using different project file and

  • Confirmed it is not a Work Profile install (personal profile only).
  • Confirmed Unity Package Name was set (you showed com.it7.cogniville in Player Settings at one point).
  • Confirmed the Firebase Unity popup indicates your Firebase config contains com.cogniville.appname (and was missing com.it7.cogniville ), so you decided to use com.cogniville.appname .
  • Confirmed your custom manifest includes the correct launcher intent on UnityPlayerActivity :
  • android.intent.action.MAIN
  • android.intent.category.LAUNCHER
  • android:exported="true"
  • File: AndroidManifest.xml
  • Confirmed there is no Leanback/Android TV intent or feature declared in your Android plugin manifests (no LEANBACK_LAUNCHER etc.).
  • Confirmed your UI reference resolution is already 1920x1080 (CanvasScaler)
wintry quarry
pearl galleon
wintry quarry
#

how did you create the app

pearl galleon
#

by unity just clean build on android platform

wintry quarry
#

and how did you install it?

pearl galleon
#

by transfering the apk thru google drive to my phone and installing it in my file manager in the phone

wintry quarry
#

And something like this should launch it: adb shell monkey -p your.package.name -c android.intent.category.LAUNCHER 1 if not you're missing an appropriately configured Activity in the android manifest

wintry quarry
pearl galleon
#

ohhh

#

ill let you know what happens then thank you

ionic zealot
ionic zealot
ionic zealot
#

Fixed it

elder hearth
#

Hi! I wanted to know how I could do something like the On Click() from the button component for my own scripts!

elder hearth
#

Okay thanks!

red ivy
#

have a problem over here

#

my mesh moves when animation played

#

instead of an object

#

found the problem

#

its due to copy pasting having the same mesh

#

a bug of some sort

placid solstice
#

hello, in a Flappy Bird tutorial, i used a canvas from UI option when u right click in Hierarchy, but, the display now is soooooo big, is there a way to fix it?

#

the positions arrows are from a gameobject, in the normal size, if u see

#

the UI is so big

#

i am surprised cuz when u click in Game tab the game are normal

frosty hound
#

This isn't a coding question.

This is also how screen space UI works, it's not in the world. The white box you see in your first screenshot represents your screen, and those elements will be where on the screen they lie.

runic wren
#

I am making a game and I used a tutorial and it is for vr and was using open XR but he has a box under android called oculus but when I looked for it was not there here is the video:https://youtu.be/nll9A1aHoM0?si=2kEH4ZeRtsW1rCRy the box is on timestamp 5:09

Hi guys! This is my updated tutorial for How To Make A Multiplayer Gorilla Tag VR Fan Game in 2025. This is an updated tutorial from my last tutorial that I made a few years ago. All the links that you need are down below (under the Discord links). Please comment down below what videos you want me to make. Thanks for watching!
**Set rendering mo...

โ–ถ Play video
vagrant parrot
#

i just started learning does anyone know any good courses or tutorials

radiant voidBOT
copper pasture
#

Hello! I'm very new, I am trying to make a simulator with generated planets with multiple environment, I've looked at a bunch of tutorials but all of them are only for one type of biome and based on how it works I can't seem to add more. I need around 5-8 separate biomes and I'm struggling to add even one.

rich adder
#

scope too big for the skills you have right now

toxic yacht
red ivy
fierce ether
#

Hello everyone.
I'm kinda new in programming. I want to understand how to build system of destructions for environment like in Battelfield.
For now i only now that you can manually shatter object in Blender and than working with pieces in Unity, but its looks like very complex and not optimized. I saw in Unity Store asset that can do it with any object.

Can you give some advices in which way should i looking?

keen dew
#

Well you could use the asset you found.

#

It's a very advanced topic, so if you're new you might want to start with something simpler

fierce ether
keen dew
upper token
#

Huh?
Did I send this here? I'm such an idiot

wheat forum
#

Hii, I am starting to write code I know what i need to do just have no idea how to write it, I kinda want a grappling hook like LittleBigPlanet,
I was thinking of using a LayerMask so i can choose what you can grapple to and a LineRenderer + DistanceJoint 2D to make it functional

verbal dome
wheat forum
#

it should just fail

verbal dome
#

Okay, then you can't use that layermask directly in the raycast (or whatever you use), otherwise it will just ignore things that can't be grappled

#

You can use it to check if the hit object was on the correct layer after you detect the hit, though

wheat forum
#

Imma be so fr i hadnt even thought of that

verbal dome
#

Other than that, linerenderer + joint would work yeah

#

Or manually adding forces/adjusting velocity of the rigidbody, instead of using a joint

wheat forum
#

the only thing i noticed is when i enable the joint and i start hanging the rigidbody loses momentum at the bottom

#

i think it has to do with how the movement i made works but i am not sure

verbal dome
#

Show your movement code

wheat forum
verbal dome
#

Use a paste site

#

!code

radiant voidBOT
wheat forum
verbal dome
#

The issue is that you are overriding the velocity by setting rb.linearVelocity = ...

#

So the joint doesn't get to affect the velocity

#

How I solved it is use AddForce when in the air/when grappling

wheat forum
#

okay i did see such an thing is it smart to transfer the code so it uses that just in general?

verbal dome
#

You can achieve the same things with AddForce and modifying velocity. All AddForce does after all is modify the velocity

wheat forum
#

i am assuming to do that i just change for example for moving rb.linearVelocity = new Vector2(moveInput * moveSpeed, rb.linearVelocity.y); to like rb.AddForce(moveInput * moveSpeed, 0, 0)

verbal dome
#

What I like to do is something like cs var targetVelocity = moveInput * moveSpeed; var velocityDifference = targetVelocity - rb.linearVelocity; rb.AddForce(velocityDifference * snappiness);
So basically add the "difference to desired velocity" as a force. This way you won't overshoot.
snappiness is just a float that controls the acceleration/deceleration speed (and you could have different values for this based on if you are on ground, in the air, grappling, etc).

#

But the common, simpler way is to just use AddForce like you just showed and have some drag (linearDamping) on the RB to limit its speed

wheat forum
#

Okay ill just try the simpler way for now and if i have time for the other way ill try and implement that

#

but real quick back on to the grapple basically what id want to do is:
OnMouseDown > Raycast > If collides with LayerMask > Enable Joint + Line with anchor on mouse position

verbal dome
#

That sounds reasonable, is there an issue?

wheat forum
#

no just a side question to it doesnt really matter if it does or not but does that mean that it will only connect to the sides of a sprite?

verbal dome
#

Not 100% sure I understand but the raycast doesn't care about sprites, it cares about collider components

wheat forum
#

so if it collides with a BoxCollider so to say it will put the Anchor on the sides of said BoxCollider instead of the centre so to say

verbal dome
#

Oh, you'd set the anchor to the exact hit point that you get from RaycastHit2D.point

#

RaycastHit2D is what the raycast returns to you

wheat forum
#

Awesomeee!!

#

ty so so much

fickle plume
#

@opal plume Don't post off-topic here

polar acorn
#

If you'd rather be working on your game you could just actually work on it instead of trying to find the best hallucination engine to use

opal plume
fickle plume
opal plume
#

I see some posts about AI over in Unity talk? is that the right place?

fickle plume
#

@opal plume If it's not related to Unity workflow, it's not related to Unity. Find relevant community interested in AI slop

opal plume
slow blaze
#

Why am I getting this even though the class I'm instantiating is not a monoBehaviour

You are trying to create a MonoBehaviour using the 'new' keyword.  This is not allowed.  MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor ()
MyEvent:.ctor ()```
```C#
public class MyEvent
{       
    public event Action StartDialogue;
    public event Action EndDialogue;

    public void doStartDialogue()
    {
        StartDialogue?.Invoke();
    }

    public void doEndDialogue()
    {
        EndDialogue?.Invoke();
    }
}```
```C#
public class DialogueEventHandler : MonoBehaviour
{
    public MyEvent dialogueEvent;
    public int test = 0;
    void Start()
    {
        dialogueEvent = new MyEvent();
    }

    // Update is called once per frame
    void Update()
    {
        if(test > 10)
        {
            dialogueEvent.doStartDialogue();
        }
    }
}```
sour fulcrum
#

have you saved all your scripts? otherwise you might have another script in the project with a MyEvent class that is inheriting from monobehaviour?

slow blaze
#

yeah I have saved and recompiled scripts multiple times

#

there's nothing really that has MyEvent the project is small and trackable

#

I'll try changing the class name to see what happens

fickle plume
#

Right click on the class name and go to definition

slow blaze
#

changing the class name for some reason made it work

fickle plume
#

Make sure there are no other errors and build recompiled.

#

Also make sure you are not trying to use constructor in any MonoBehaviour object

wheat forum
#

I think i messed up with AddForce

polar acorn
wheat forum
#

So it needs to come from an Vector?

#

you cant just put a float or interger number

#

thats what i am understanding from that

sour fulcrum
#

yes

#

a single float wouldn't make sense

verbal dome
#

And AddForceY ofc

wheat forum
#

that helped a lot already

#

The errors are gone at least the jumping tho isnt functioning but thats probably tweaking some numbers

mint imp
#

Hey guys im wondering what might be a better way to code variable planets/levels.
I have randomized planet levels you can pick at will in a hubworld map.
They have different types such as farm planet or jungle planet, which changes alot per planet.
When selecting a planet would it make more sense to make every planet type its own scene or have a single "planet scene" that i can dynamically adjust to fit the planet type you selected

frosty hound
#

If they're randomized, you can't have one for every planet of course. So it seems like a single planet scene you generate the planet in, is the right way to go.

turbid jolt
#

the blue tank ai enemy wont move towards the red idk if it's cause of the nav mesh?

#

i havent done this before so im not sure if it's that good that there's uneven risen parts lol

elder hearth
#

How can I prevent my player clipping in/out objects it walks into? Here's the code being called in update

            Vector3 moveDirection =
            transform.right * CurrentMovementInput.x +
            transform.forward * CurrentMovementInput.y;

            if (moveDirection.magnitude > 1f)
                moveDirection.Normalize();

            PlayerRB.AddForce(transform.position += MoveSpeed * Time.deltaTime * moveDirection);
naive pawn
#

don't modify the transform

rich adder
naive pawn
#

that's also not how addforce works

turbid jolt
#

my one classmate did the same one and his works so idk what i did diff

rich adder
# turbid jolt

put some logs and see what is running and wat isn't along with logging their values

#

also wth kinda theme is that for VS ๐Ÿค”

turbid jolt
naive pawn
#

that feels unconfigured rather than a theme thing

turbid jolt
#

my eyes hurt otherwise

polar acorn
radiant voidBOT
rich adder
rich adder
naive pawn
rich adder
sour fulcrum
rich adder
#

Transform is also white and should be green

#

I remember though VS has a weird theme too that also did some weird shit like this while still being configured.
OP needs to confirm by seeing if intellisense / suggestions still appear

naive pawn
#

huh i remembered types being white in some contexts

#

couldve confused it with the namespaces there ig

elder hearth
naive pawn
#

so what's the actual code?

elder hearth
#

(I realised that i did not mean PlayerRB.AddForce lol)

rich adder
naive pawn
rich adder
#

if you don't want it to do that you'd have to manually check collisions and prevent movement in that dir, otherwise use Velocity / AddForce

naive pawn
#

you essentially ask us to check for issues in new code that is loosely based on what you have, instead of what you actually are using

elder hearth
naive pawn
#

(same for errors, just fyi)

elder hearth
#

Wait actually let me just test it real quick

rich adder
#

im guessing at times it tries to compensate

elder hearth
rich adder
#

can you show a vid of issue

#

hard to tell cause many reasons it can jitter

elder hearth
#

Yeah sure! One sec!

elder hearth
rich adder
# elder hearth

I see. Also I'd try calling the movement in FixedUpdate. See if that helps a little

#

Dynamic based rigidbody character controllers are a pain in the ass to get correctly working tbh

naive pawn
#

could you show your current movement code? i got kinda lost and i feel like i don't have the full picture there

elder hearth
elder hearth
#

odd

rich adder
elder hearth
#

Why? It was working fine a second ago.

rich adder
#

PlayerRB.AddForce( MoveSpeed * moveDirection, ForceMode.Acceleration);

instead of
PlayerRB.AddForce(PlayerRB.position + MoveSpeed * Time.deltaTime * moveDirection, ForceMode.Acceleration);

elder hearth
verbal dome
elder hearth
verbal dome
#

FixedUpdate runs at a fixed rate, so that would remove that issue

elder hearth
#

Hmm ok

#

thanks

verbal dome
#

(It's ok to do an impulse force like the jump in update, though)

elder hearth
verbal dome
#

Easiest fix is linear damping on the rigidbody and/or friction on the physics materials

elder hearth
#

Okay thanks!

junior basin
#

Hey there, I'm getting a MissingReferenceException the moment I start the game, but everything is working completely fine. I've got this Lighter script attached to a lighter gameobject which is currently a child of the player

wintry quarry
#

It will tell you which code is causing the error

polar acorn
limpid sparrow
keen dew
#

Not a code question but it behaves like that because the parent object's scale is not uniform

polar acorn
#

Every object's transform is relative to its parent, since the parent is 6 times wider on one axis, so will its children

#

That scaling remains in the same place no matter what orientation the child object is

limpid sparrow
polar acorn
#

So, it skews

frail hawk
#

What ya trying to achieve?

limpid sparrow
#

to rotate it around itself and then do the same thing for the childobject. A bit like a arm

#

to build something like this

#

void Update()
{
if (Input.GetKeyDown(KeyCode.DownArrow)) // forward
{
transform.Rotate(Vector3.forward * 45);
}
} Can someone explain to me why, this only works ones. i would like to stack it, like 45,90,135,180 and so on

sour fulcrum
#

Vector3.forward is global, kinda like how "North" points to the same place everywhere in the world

transform.forward is the specific to that object

verbal dome
#

Rotate works in local space by default so that should be ok here

verbal dome
#

Are you clamping or otherwise modifying the rotation anywhere? Or does it have other scripts/components that could modify the transform?

#

I'd expect that code to rotate it along its own Z axis, 45 degrees per key press

#

Additively

mint imp
frosty hound
#

If each planet is hand crafted, I would create separate scenes. The syncing thing is a non-issue if you're using prefabs? Unless you can think of a specific situation?

earnest raven
#

Hi! New to using IEnumerator. I'm trying to make walls lower and raise:

private IEnumerator RaiseWalls()
    {
        var t = 0f;
        t += Time.deltaTime;
        float percentComplete = t / 1f;

        arenaWalls.transform.position = Vector3.Lerp(wallEndPosition, wallEndPosition, percentComplete);
    }
    private IEnumerator LowerWalls()
    {
        var t = 0f;
        t += Time.deltaTime;
        float percentComplete = t / 1f;

        arenaWalls.transform.position = Vector3.Lerp(wallEndPosition, wallStartPosition, percentComplete);
    }

but I get this error:

Assets\Scripts\Enemy\SpawnTrigger.cs(60,25): error CS0161: 'SpawnTrigger.LowerWalls()': not all code paths return a value

#

I'm not really trying to return any value

mint imp
frosty hound
#

What would be an example of a feature?

#

The proper way to handle shared things is to have a root/side loaded scene that contains it, so it exists when you need it.

#

For example, in the game we're doing, we have a bunch of levels - each are their own scene. However, of course we need to have the same UI/pause menu/gameplay elements between them so we have a LevelElements scene that gets loaded alongside any level.

#

When you leave the level , say to go back to the main menu, both the level and this LevelElements scene is removed.

frosty hound
#

Even if it's just yield return null, though if that's the case, then you're not using a coroutine correctly.

#

Also just reading your code, you're not using it correctly ๐Ÿ™ƒ

earnest raven
#

well yeah no crap man I said I'm new to using it. I'm using it wrong, that's why I came here

frosty hound
#

Relax

earnest raven
#

such attitude some people may have

frosty hound
#

Oh okay, nevermind then.

#

I'll just do the short version of my answer: you need to loop inside your coroutine to do the progression.

wheat forum
#

Hi everyone i took a break saved and closed my unity normally i open it and come back to this

polar acorn
#

Because you got one and apparently decided it was a personal attack

#

If you can't be told that your code is incorrect, don't ask how to correct it

frosty hound
#

Actually, that's referring to the UnityEngine.UI ... it's missing ๐Ÿค”

#

Check if that is installed in your package manager?

wheat forum
#

should it be in between there?

frosty hound
#

The Unity Registry option on the left

wheat forum
#

I am assuming most of these should be installed huh

#

yeaaa okay

frosty hound
#

Well, check the Unity UI one first, that's the one it's actually complaining about.

#

2D Sprites, sure, if you're intending to use them.

wheat forum
#

yea the thing is all of em arent installed not even unity physics and indeed uGUI

#

thank you ill figure out if ill just restart with a new project or figure out everything thats missing

mint imp
grand snow
#

Prefabs?

frosty hound
#

Currently, if you have it in every scene you would if they're weren't using the prefab.

#

But a prefab solves that issue. Modify the prefab and it applies to every instance of it.

sick cliff
#

why can't I see recommended commands when i type in tran.. for transform in VS. I have downloaded VS community and have a checkmark at the game development box. I have no idea what to do. Can someone help me please?

slender nymph
#

!ide

radiant voidBOT
sick cliff
#

Thanks!

sour fulcrum
#

@night raptor works like a charm ๐Ÿ˜„

#

now i can dynamically get which part of my rooms are playable space or void space ๐Ÿ˜„

foggy copper
#

yoyoyoyooyoo

#

I want to make a skiing game what unity installation should I use?

verbal dome
#

I'd say 6.3 LTS (skiing game or not)

#

6.4 breaks a bunch of previous things so wouldnt recommend for beginners right now

foggy copper
#

ok

#

LTS what does that mean?

verbal dome
foggy copper
#

ok so it is recommended to use 6.3

narrow idol
#

This is my Collectible.cs

using UnityEngine;

public class Collectible : MonoBehaviour
{

    public float rotationSpeed;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(0, rotationSpeed, 0);
    }

    private void OnTriggerEnter(Collider other)
    {
        // Destroy the collectible
        Destroy(gameObject);
    }

}
#

pls ping if anyone responds

inland crystal
#

What kind of response are you looking for?

narrow idol
#

I followed the instructions given by unity but im seeing that its not destroying the apple

inland crystal
#

It looks like you haven't added the script to the object

narrow idol
#

oh, i had added the script to "apple"

inland crystal
#

OK, but I'm guessing apple does not have a collider on it. "Collectible_apple" does

narrow idol
#

yea

#

i added the script to Collectible_Apple and removed from apple and that fixed it

kindred temple
#

I'm modding a game with some particle systems in it, and I'm trying to modify the velocity over lifetime and it's weirdly inconsistent

For one set of particles it only applies the velocity if I set it to a constant value, for another it only works if I set it to two constants (with the same lower and upper bound so it should function the same as a constant)

What could be different? I can't seem to find anything that explains why they'd act differently.

#

(By doesn't work I just mean it doesn't seem to apply any velocity)

naive pawn
errant breach
#

Hello everyone !
So i have an issue with my AI not rotating nor walking correctly.

I've freezed all X Y Z rotation in the rigidBody. I want to ai to spin 180 degrees when touching a wall.

  • When i remove the freeze in Y, the AI stop walking / start shaking
  • When i put a random owner.transform.Rotate(0, -36, 0); in the code, even with Y freezed, it work
  • The rotate() function is called, but does not work...

if someone can check at my code and explain me why the rotation doesnt work, i would be extremly thankful !
https://pastebin.com/SE54fnKV

naive pawn
#
    //if (owner.transform.rotation.eulerAngles.y < -360) owner.transform.Rotate(0, 0, 0);
    //if (owner.transform.rotation.eulerAngles.y > 360) owner.transform.Rotate(0, 0, 0);

you don't need this part at all btw

#

you should not be reading eulerAngles to drive these decisions, they won't necessarily be consistent

#

eulerAngles should generally be write-only

errant breach
#

Oh, that's why... Alright, now the biggest issue is that when the Y rotation is unfreezed, the AI just doesnt want to move ๐Ÿ˜…

#

But thanks for the explanations !

sharp bloom
#

Is it possible to force classes to implement Unity event method such as Update() and OnDisable() using an interface?

#

Like if I just make a simple interface with public void OnDisable(), will that work?

naive pawn
#

unity messages aren't particularly special outside of unity knowing about them

sharp bloom
#

I kind of thought that, but I was also prepared to hear something like "they're super magic special messages that dont work like this"

elder hearth
sharp bloom
#

Come to think of it, how does Unity know about the very existence of those methods at all? I mean the MonoBehavior class doesn't force a class derived from it to implement those.

#

Some kind of reflection magic?

naive pawn
naive pawn
naive pawn
elder hearth
naive pawn
#

you have to use "opposing force to slow me down" in some capacity if you want it to slow down on its own. rather than recreate it, why not investigate why it isn't working for you?

naive pawn
elder hearth
#

the damping and friction to be clear

naive pawn
naive pawn
#

which part?

verbal dome
naive pawn
#

making the wall frictionless? that would be done with a physicsmaterial on the wall

elder hearth
# naive pawn which part?

friction would not unless you were also touching a wall (which you can configure to not give friction)

#

hmm okay

naive pawn
#

anyways if "friction" is making your character not handle well while you're in the air and not touching anything, it's not the friction.

elder hearth
#

It is, and honestly it works really well

#

I am quite happy with the results

limpid sparrow
#

I have a question about rotation, may some of you might be able to help. I want to rot a object, by pressing a key, so far it work's. The thing that i don't understand is, i print out the rotation. The print out is 0,45,90,135,...315,0. In the Inspector is the rotation, goes from 135 to -180, why? The Code is ' if (_middelObject)
{
transform.Rotate(Vector3.forward * 45); // and Vector3.back -> for the other direction
_selectionManager.middelRotation = (int)transform.rotation.eulerAngles.z; //This is the "printout"
}' H

naive pawn
rich adder
naive pawn
#

generally, don't read eulerAngles, treat them as writeonly

limpid sparrow
#

understood, and now how to get the correct value in the selectionManager _selectionManager.middelRotation = (int)transform.rotation.eulerAngles.z; ?

rich adder
#

its the same value, just displayed differently

#

if you want to display it as unity does in inspector you just do the normalization yourself

float z = transform.eulerAngles.z;
if (z > 180f)
    z -= 360f;```
limpid sparrow
#

i'm using a if statement later and the statement don't work

rich adder
#

thats an entire different issue than what you're asking

limpid sparrow
#

something like if middleRoation is 270 do XY

rich adder
limpid sparrow
#

switch ((middle, right, left))
{
case (0, 90, 270):
letterIndex = 1;
Debug.Log("Case 1");
break;

        case (180, 90, 270):
            letterIndex = 1;
            Debug.Log("Case 2");
            break;

something like this

polar acorn
limpid sparrow
#

i meant a switch statement

#

case 1 work, case 2 doen't

verbal dome
#

Maybe just store the rotation in an integer (0,1,2,3) or enum instead of looking for exact floating point number match

limpid sparrow
#

Thank's

rich adder
#

@limpid sparrow how many chases do you expect ? it may be cleaner to use a lookup table

verbal dome
limpid sparrow
#

one for each letter of the alphabet

rich adder
#

giant switch

#

maybe a dictionary ?

limpid sparrow
#

i know

#

with 3 keys and 1 value? that's possible?

rich adder
#

of course

#

just dont use float

limpid sparrow
#

i will google it, thanks

rich adder
#

I'd probably round the float instead of truncate though

#

do you really want 9.9 to be 9 instead of 10 ?

limpid sparrow
#

i didn't use float, i'm using int's for. The Rotation doesn't need a decimal point

rich adder
#

so I said in the example 9.9 would become 9 but you might want it to be 10 so its best to do a
int myInt = Mathf.RoundToInt(myfloat)

limpid sparrow
#

understood, i know what you mean now

ruby python
#

Hi all, I'm having a bit of a brainfart and hope someone can help out a little.

I have this code as part of my character controller (using addforce to control everything).

 private void MovePlayer()
 {
     // Let's try this shit
     Vector3 moveDirection = transform.TransformDirection(smoothInput).normalized;

     if (targetForward == 0 && targetRight == 0 && playerRigidBody.linearVelocity.magnitude > 0)
     {
         playerRigidBody.AddForce(-moveDirection * playerMoveSpeed, ForceMode.Acceleration);
     }
     else
     {
         playerRigidBody.AddForce(moveDirection * playerMoveSpeed, ForceMode.Acceleration);
     }
 }

Everything works great, except the stopping. lol. As you can see I'm trying to apply an 'Opposite' force to bring my character to a stop (increasing the drag doesn't really work unfortunately, kinda makes the character behave as though it's in clay).

Using the code above the force applied to the character does change direction correctly, however the character kinda flies off the screen.

Not entirely sure what I'm doing wrong, but there's obviously something wrong in my logic. (targetForward & targetRight are set between 0 and 1 with the WASD keys).

Could someone point me in the correct direction please? ๐Ÿ™‚

wintry quarry
#
playerRigidBody.AddForce(-moveDirection * playerMoveSpeed, ForceMode.Acceleration);```
This is adding a force opposite your *input direction* not opposite the current direction of motion
#

and if the input is 0, it's doing nothing, because -0 is still 0

#

It's also unclear what targetRight and targetForward are or where they're being populated

ruby python
#

This is the complete script. There's a lot going on so it's a bit long, sorry ๐Ÿ˜•

https://hastebin.com/share/iwozisezej.csharp

stark helm
#

Guys should I do health regeneration in Update() or FixedUpdate()?
Could someone tell me which one works the best?

rich adder
solar hill
#

or maybe per some arbitrary amount of time?

naive pawn
solar hill
#

yeah youre right actually i missunderstood what nav said

#

he was just comparing the 2 updates lol

unkempt kettle
#

hey guys, I'm very inexperienced with tilemaps, is there a way I can make a script/shader that makes tiles gradually darker the further away they are from an "edge" of the tile (visual mockup in photoshop)

What I had initially on my mind is setting a script that can check my Tilemap/Tilemap Renderer components and assign a value of "Depth" to each tile (edge tile = 0, and every tile away from an edge is +1), and then depending on their depth, change their color multiplier to different shades of black

Is this something that can be done with tilemaps? Or will it be best to spend my time just making the extra few sprites of darkened terrain?

stark helm
rich adder
naive pawn
#

also if you're doing it in discrete steps, have an time accumulator and use loops to make sure it stays consistent over time

elder hearth
#

Just checking but Rigidbody.linearVelocity is world space and not local right? And if so how can I get the local space velocity?

solar hill
elder hearth
solar hill
#

to convert it from world space to local

elder hearth
solar hill
#
Vector3 worldVelocity = rb.linearVelocity;
Vector3 localVelocity = transform.InverseTransformDirection(worldVelocity);
elder hearth
#

Okay so mine is just shorter?

solar hill
#

yes if you just need the lateral velocity use .x

elder hearth
#

Hmm okay

#

thanks!

solar hill
#

also you dont need .transform

elder hearth
#

Ohh okay thanks

elfin pike
#

looked in code general and couldnt find any thred with AI vision or detection system.

solar hill
#

also just make a thread yourself?

#

thats the point of the channel lol

elder hearth
#

fr lol

sour fulcrum
#

really depends on what ai vision / detection means

solar hill
#

im assuming just pathfinding with player detection

elfin pike
naive pawn
#

could cast to multiple points

solar hill
#

i dont think thats how half life 2 handles player detection?

#

half life 2 has pretty advanced ai for its time

elfin pike
sour fulcrum
#

you'd have to give proper context to what your looking for here otherwise people will just kinda vaguely guess what it is which might not allign with what you want

elfin pike
#

player detection for enemy. what else to add?

solar hill
elfin pike
#

i could cast 5 rays (4 for edges and 1 in center)

solar hill
sour fulcrum
#

I think some games have like points per limb?

solar hill
#

i was going to say

#

you could get away with 2 maybe

elfin pike
solar hill
#

one from the center mass and one from the head

sour fulcrum
#

like if its a rigged enemy you'd get the center of each leg, the body, the head etc.

solar hill
sour fulcrum
#

might be! that's why proper context on the question is important ๐Ÿ˜„

elfin pike
sour fulcrum
#

it's less about phrasing and more about giving people the information you already have

naive pawn
#

at some point would a vision cone be more reasonable if you want the smallest part peeking to count as a detection

sour fulcrum
#

think about all the questions we have asked you and all the respones youve posted,
in theory you probably could have gotten to this point in the conversation from 1 initial message that contained the thoughts and concerns you've already mentioned

#

its not like a big deal but it helps you get your answer faster and us understand it faster

elfin pike
solar hill
#

this is as much of a design decision as it is a technical one

#

most detection systems give the player a lot of lee way

#

because it just feels less punishing

elfin pike
solar hill
#

thats not what i asked though

naive pawn
#

or if yknow, a sleeve peeks behind a wall because of it being impossible to judge or control that within a game where input fidelty and depth perception are limited

solar hill
#

thats why games purposefully make detection for enemies "worse"

#

theres a difference between the player standing out in the open vs a small part of them peeking through cover

#

you dont want to punish the player for the latter

#

or you shouldnt, do whatever you want

elfin pike
solar hill
#

imo you should cast from enemy limbs to your players center mass... and maybe the head

#

casting to individual player limbs is exactly what you want to avoid

elfin pike
solar hill
#

thats already something else

#

but a smart decision

elfin pike
solar hill
#

its your game, but this is exactly what we are telling you to avoid... casting too individual legs and arms could be too punishing, feel free to test it and play around with it

naive pawn
tacit hound
#

posted there

elfin pike
#

best question would be how much ray would be too much. Ray are expensive?

sour fulcrum
#

rays are cheap

solar hill
#

my grenade system uses up to 40+ rays for occlusion

#

theres also close to a hundred raycasts in certain update functions

#

no performance impact, so go crazy

sour fulcrum
#

it's using the fancy raycastcommand stuff but this dispersing prop step in my world gen does a millie raycasts lol

#

raycasts cheap cheap

elfin pike
sick cliff
#

Can someone explain what's wrong with my code?

sour fulcrum
sick cliff
#

ah thanks

sour fulcrum
naive pawn
#

an axis is an analog input

#

(the logic is kinda questionable though)

sick cliff
#

what is the diffrence?

naive pawn
#

it's treated as a button when you call GetButton

#

GetButton is for buttons while GetAxis is for axes

sick cliff
#

So i should use GetButton?

naive pawn
#

if your Fire1 input is a discrete button rather than an analog axis, yes

bronze hinge
#

Hi, I'm new to Unity and C Sharp and could you please check if everything is ok with my object generation script?

naive pawn
#

!ask not if you don't ask ๐Ÿ˜‰

radiant voidBOT
# naive pawn !ask not if you don't ask ๐Ÿ˜‰

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #๐ŸŒฑโ”ƒstart-here

naive pawn
bronze hinge
solar hill
#

does it work?

bronze hinge
bronze hinge
solar hill
#

then what do you want us to do lol

bronze hinge
solar hill
#

it works though... unless you see something explicitly wrong with the way it works

#

you dont have to worry about it

bronze hinge
oak cloud
#

Im trying to make a turn based strategy game and want to use hexes for the (3d) map. My problem is that the Asset that im using has a wrong center and I dont know how to allign the hexes. (I dont know the Dimensions either). Should I make my own basic asset, use rectangels, do it in 2 d or use an other asset? Thank you.

verbal dome
#

Unity has a grid component that supports hexagons

oak cloud
verbal dome
#

A texture?

#

You can see its dimensions in unity if you select the texture, or in your OS file browser

#

Oh 3D mesh?

oak cloud
#

its a prefab

#

my idea was to make a grid of game objects and teleport the Pieces to the center of the game objects

verbal dome
#

For example GetCellCenterWorld would be useful for placing objects on the cells

oak cloud
#

Im not using it reading about it now thnx

high needle
#

Hello. Are there any Codewars users here? I'd love to add some allies

sour fulcrum
#

no

elder hearth
#

When compiling my game or using playmode my variable change( well this is my hypothesis). My code is this:

            Vector3 worldVelocity = PlayerRB.linearVelocity;
            Vector3 localVelocity = this.gameObject.transform.InverseTransformDirection(worldVelocity);

            // Movement direction (camera-relative)
            Vector3 moveDirection =
                (this.gameObject.transform.right * CurrentMovementInput.x +
                this.gameObject.transform.forward * CurrentMovementInput.y) * MoveSpeed;

            if (moveDirection.magnitude > 1f)
                moveDirection.Normalize();

            // Jump
            if (groundedCheck.isGrounded && JumpIsPressed)
            {
                JumpIsPressed = false;
                PlayerRB.AddForce(Vector3.up * 391.65f, ForceMode.Impulse); // simplified + tunable
            }

            // Target velocity
            Vector3 targetVelocity = moveDirection * maxSpeed;

            // Convert target velocity to local space for comparison
            Vector3 targetLocalVelocity = this.gameObject.transform.InverseTransformDirection(targetVelocity);

            // Calculate velocity difference
            Vector3 velocityChange = new Vector3(
                targetLocalVelocity.x - localVelocity.x,
                0,
                targetLocalVelocity.z - localVelocity.z
            );

            // Apply movement force
            PlayerRB.AddForce(this.gameObject.transform.TransformDirection(velocityChange), ForceMode.VelocityChange);

            // Friction / stopping
            if (CurrentMovementInput == Vector2.zero && groundedCheck.isGrounded)
            {
                Vector3 horizontalVelocity = new Vector3(worldVelocity.x, 0, worldVelocity.z);
                PlayerRB.AddForce(-horizontalVelocity * 0.1f, ForceMode.VelocityChange);
            }
``` IT works fine in the editor, unity 6.4 and this is all called in update.
sour fulcrum
#

what variables

#

and what do you mean it works fine in editor

elder hearth
#

Wait actually I should just double check this rq

#

I'll be back in a sec

sour fulcrum
#

you don't need this or gameObject for most of this btw

#

you can just access transform directly

elder hearth
#

Oh I know I just use them because of habit

#

I don't even know when I began to do that lol

grand snow
#

js moment

elder hearth
#

Okay turns out this isn't variables changing. But my when I move in a compiled game it goes CRAZY. I am using FishNetworkin. I wonder if thats it.

#

Like my Velocity is the maxium possible value

grand snow
sour fulcrum
#

thats a question for wherever people talk about fish net

elder hearth
#

I'll go to their server

grand snow
#

This is probably due to higher framerate in the build so it just adds even more force

elder hearth
#

but it is so dead lol

elder hearth
#

Wait I have a way to test this

grand snow
#

Add force/change velocity in Fixed update only

#

Its such a critical thing to learn

elder hearth
elder hearth
elder hearth
grand snow
#

How to alter physics and using delta time/frame time is a common topic for game development/realtime 3d applications

elder hearth
lean sandal
#

It's hard enough trying to learn code itself

#

but when you cant even use visual studio without it messing up it makes it even more stressful. I cant get it to so suggestions at all when im typing stuff. Im using 2026 and I updated it. Ive already got .net and stuff installed. I tried many different solutions and none worked...

#

Can someone please help me fix it I can screenshare if I need too

sour fulcrum
#

theres no screensharing here sorry

#

make sure you've gone through this if you haven't gone through it all

#

!ide

radiant voidBOT
grand snow
#

Assets > Open C# Project / double click a script asset in editor

lean sandal
#

if i do something like public or public int it autofills it
but if im doing oncollisonenter or
getcomponent I dont get shit

#

I read through all of that stuff

grand snow
#

If the unity tools were installed it should suggest unity message names ๐Ÿค”

#

but technically they work in a non standard way so they dont "appear" by normal c# rules (unity calls em by magic)

elder hearth
#

Hi! It is me again lol, but anyways. When I rotate an object, but it's rotates around a pivot, my method doesn't move the Object to the target's new position.

    void MoveTowardsTarget(Rigidbody Object, Transform target, float force)
    {
        Vector3 pendingForce;
        Vector3 direction = (target.position - Object.position);
        pendingForce = direction * force;
        Object.linearVelocity = pendingForce * Time.deltaTime;
    }
elder hearth
# radiant void

Do people actually install Visual Studio through Unity Hub?

grand snow
#

no cus its an old ass version

elder hearth
#

Fair lol

cosmic dagger
keen acorn
#

Quick question, what's MonoBehavior and why would we not want to have scripts derive from it?

keen acorn
cosmic dagger
grizzled steppe
#

Any idea why raycasts are being so buggy? I am walking into the object it doesn't detect but if I jump onto it it detects fine...

sour fulcrum
#

we'd need to see

#

!code

radiant voidBOT
swift crag
#

some prior terms first:

  • UnityEngine.Object is anything that the Unity engine can keep track of
  • Component is anything that you can attach to a GameObject
  • Behaviour is a Component that you can enable and disable
  • MonoBehaviour is a Behaviour, and user scripts are allowed to inherit from this class
cosmic dagger
#

the real question is knowing when to derive from it or to use a plain 'ol c# class (POCO) . . .

swift crag
#

The name itself is a bit of a legacy thing โ€“ I believe it refers to the Mono runtime (the system that actually runs your C# code)

swift crag
#

You inherit from it to create new kinds of components

#

If you are not creating a kind of component, then you need to derive from something else (or nothing at all)

grizzled steppe
#

This is my helper class I use.

swift crag
#

e.g. ScriptableObject to create new kinds of generic Unity objects

grand snow
#

Understanding object oriented programming should explain it anyway

sour fulcrum
# radiant void

you gotta read this again ๐Ÿ˜„

and we'd need to see where your using the stuff in this helper class

cosmic dagger
#

mote the Mono in MonoBehaviour. it's intended use is for a single behavior . . .

sour fulcrum
grizzled steppe
#
        
        float castDistance = HipHeight + 2f;

        Vector3 groundOrigin = Character.position + Vector3.up;

        Vector3 leftLegPos = Character.position - (Character.right * 0.5f);
        Vector3 rightLegPos = Character.position + (Character.right * 0.5f);

        float legCastDist = Crouching ? 1f : 2f;

        Vector3 legBoxSize = new Vector3(0.75f, Crouching ? 1f :2f, 0.75f);
        
        Vector3 VectorDown = new Vector3(0f,Crouching ? -1f : 0f,0f);

        var leftHit  = Eggie.Boxcast(leftLegPos+ VectorDown,  legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);
        var rightHit = Eggie.Boxcast(rightLegPos, legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);

        var leftHitRay = Eggie.Raycast(leftLegPos,VectorDown*legBoxSize.y,rParams);

        float FloorPlantLevel = -2000f;

        List <float> YLevels = new List<float>();
        if (leftHit.Hit) {
            Debug.Log("Left:"+leftHit.Instance.name);
            YLevels.Add(leftHit.Position.y);
        }
        if (rightHit.Hit) {
            Debug.Log("Right:"+rightHit.Instance.name);
            YLevels.Add(rightHit.Position.y);
            }

        foreach (float Value in YLevels)
        {
            if (Value > FloorPlantLevel) FloorPlantLevel = Value;
        }

        isGrounded = FloorPlantLevel != -2000f;

        // Stair sticking
        bool stickToStairs = false;

        if (!isGrounded && Velocity.y <= 0)
        {
            var stairStick = Eggie.Boxcast(Character.position+ VectorDown,  legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);
            if (stairStick.Hit)
            {
                Debug.Log("Stairstick:"+stairStick.Instance.name);
                isGrounded = true;
                LastWall = null;
                FloorPlantLevel = stairStick.Position.y;
                stickToStairs = true;

            }
        }
cosmic dagger
sour fulcrum
#

im leaving monobehaviours behind entirely ๐Ÿ˜„

#

scriptableobject singletons and poco classes my beloved

grand snow
#

its a shit old name and nothing more

grizzled steppe
#

See it works fine for ground and stuff, but on wedged mesh parts it completely breaks

solar hill
#

mono means one
and behaviour means behaviour

grand snow
#

๐Ÿคฆ

solar hill
cosmic dagger
grizzled steppe
#

See it only detects the hit if I am landing on it.

teal viper
#

Where's the damn StereoBehaviour??

grizzled steppe
#

But the first two left and right hits should also be factored and they arent for some odd reason

cosmic dagger
swift crag
#

CoreCLRBehaviour ๐Ÿ˜‰

swift crag
#

small thing: your boxcasts are inconsistent; the right leg doesn't add VectorDown

#

but that only matters while you're crouching

grizzled steppe
#

Yes

#

But even if the right doesn't hit the left one should be but doesn't detect it

#

It's skipping the wedge and hitting the ground under

#

The only time it actually detects the wedge is if I am jumping stright on top of it

swift crag
#

if a BoxCast starts inside of another collider, it will ignore that collider

#

That would explain why it works when you jump

grizzled steppe
#

So how would I solve this issue?

#

If a wedge can be higher than player

#

In terms of like map designing and such

#

Cause I want to have some walls that are angled

#

or like angled floors

swift crag
#

i'm guessing that the boxcasts are starting low enough that, when you walk directly into a sloped surface, they start inside of the surface

#

and thus don't detect it

#

raise them up a bit and see how it behaves

grizzled steppe
#

yeah and if I am walking onto one it skips it

#

plus theres an issue where I need to be able to crouch inside vents with slopes and i am using wedges as elevations

cosmic dagger
# grizzled steppe

if you only need one or the first hit, then using an array of size 1 is unnecessary . . .

grizzled steppe
#

okay

#

Is there a way to make it so unity can detect objects if you start raycasting, since my object uses a custom collider?

#

Like here the green boxes are the debuggers for the boxcast. but they are outside of that wedge when they start so they should be hitting that wedge, instead they are going through it. and the player is only so big, so having to raycast high in the sky just to detect a wedge under the player sound a bit overkill, plus some elevations are drastically bigger than the player.

verbal dome
#

@grizzled steppe Seems like you asked in 3 different channels... dont cross-post

fickle plume
#

You have a thread, don't cross-post here

mortal spade
keen dew
#

Time for some debugging then. Find out which part of it is not working

mortal spade
#

well i am trying that, id prefer if anyone has resources on [procedurally creating tree instances] because i think my problem is i cant find anything that covers it well and terrain is new to me

elfin pike
#

I was sent back from ai-navigation, but now I have question collider. Is there way to make truncated pyramid collider?

naive pawn
#

in 3d, correct?

#

well, mesh colliders can be any shape

elfin pike
#

Or shouldn't bother with that and do mesh collider

naive pawn
elfin pike
#

To be fair sad that we are limited with square and sphear

sour fulcrum
#

(and meshes)

naive pawn
#

(and capsules)

inland crystal
#

More than once I wished I could have a cylinder collider tbf

#

Although, if by "truncated pyramid" you mean a frustum, you could do it manually using GeometryUtility

keen dew
#

!collab and English only server

radiant voidBOT
# keen dew !collab and English only server

:loudspeaker: Collaborating and Job Posting

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

rocky wyvern
#

I have a List<Int2> that represents tile coordinates in relation to an object. I wish to rotate these by 90*; any easy way?

grand snow
naive pawn
#

if you want to get new structs that are rotated, then loop through and rotate them

#

for 90ยฐ it's just a swizzle and negate one of them

grand snow
#

Huh til that's a thing

rocky wyvern
rocky wyvern
naive pawn
# grand snow Huh til that's a thing

yeah quite a few primitive transforms can be done with a combination of negate and swizzle (eg reflect on X, reflect on Y, reflect on y=x, rotate 90ยฐ, rotate 180ยฐ)

limpid sparrow
#

Is there a mistake in my code ? "Clicked" get's print out twice public void LeftMouseClick(InputAction.CallbackContext context) { if (context.performed && clickable) { Debug.Log("clicked"); _renderer.material.color = Color.green; ClickFunction(); // the first line in this function is clickable = false } }

frail hawk
#

ClickFunction probably also has a Debug.Log("clicked")

limpid sparrow
#

Nop private void ClickFunction() { clickable = false; StartCoroutine(DeactivationTime()); } public IEnumerator DeactivationTime() { Debug.Log("Deactivation started"); clickable = false; for (int i = 0; i < 30; i++) { yield return new WaitForEndOfFrame(); } Deactivate(true); }

teal viper
limpid sparrow
#

If i'm understand that corret, the clickable get set to false and still get trigger again, that's got me puzzeled

#

found the mistake, the script was attached twice. My fault, upps

frail hawk
#

is there not somethign like context wasPerformedthisFrame for single click

elder hearth
#

The grabber rotates around a pviot, and I don't think that is updating the position

#

Yep it isn't being updated(the grabbers position)

lament basin
#

Would a message queue for the server processing interaction events on the terrain be overkill?

#

I'm thinking for things like chest updates and other interactions it would make sense for consistency

fickle plume
elder hearth
shy tapir
#

Hello Guys

mint imp
#

Howdy everyone
I'm working on toollips for my ability selection menu.
Basically I have a square icon representing an ability you can use (just a button), when the mouse is over it i want a box to show up and show you the name and description.
I'm already using a detection system per button system to display a selection outline for each button, so I was thinking to just call the toolip to spawn with that?
How do people normally add toolips?

limpid sparrow
#

why is "color" not working - Cannot resolve symble"color". i already using a KI, doen't helped. There isn't a typo, right? the private Image is Internal class

slender nymph
#

using UnityEngine.UI; is grayed out which indicates that you are not using the Image type from that namespace

wintry quarry
#

you can't do .color on an array

slender nymph
#

also that

wintry quarry
#

you need a specific Image from the array, then you can do .color on it

#

Box's concern is also true - you probably made your own Image class

limpid sparrow
#

private UnityEngine.UI.Image tabImages; okay this works

frail hawk
#

yeah but you still should choose another name for your class

slender nymph
#

yeah either never name your types the same as a unity type, or make sure it's in a namespace so it forces you to fully qualify it or you get an ambiguous reference error

frail hawk
swift crag
#

assuming you're using UGUI, you'll want to put your tooltip prefab at the very bottom of the UI hierarchy and give it a Layout Element set to ignore layout

#

if this is UIToolkit, use an absolute-positioned element

midnight tree
#

I have a quick (weird) question about vectors.

Doesn't it bother you that the direction of movement (normalized) and a regular vector(with distance) are indistinguishable, and you have to specify, for example, in the summary that you want a normalized vector and not a regular vector as input to a method?

Or am I an idiot and it is possible to understand from the principle what exactly the method requires?

naive pawn
#

don't rely on just the types to determine what the value represents

swift crag
#

You could, indeed, use the type system to distinguish these concepts

#

it would be very awkward, though, since many operations make sense for both "types"

naive pawn
#

the types show how the value can be encoded, but semantics (and documenting those semantics) are also important

swift crag
#

it's the same idea as using separate types for "sanitized" strings and "unsafe" strings

wintry quarry
#

e.g. it's why you call your parameter playerPosition or playerForwardDirection not playerVector

swift crag
#

i kind of wish it was just float3 instead of Vector3

#

(like it is in the Mathematics package)

#

that makes it clear that the type simply represents 3 floats

#

it doesn't hint at a particular meaning

#

(of course, in computer science, "Vector" has a meaning totally divorced from the mathematical idea of a "Vector")

naive pawn
#

that makes it clear that the type simply represents 3 floats
i mean it kinda doesn't, given that it has all the normalization/magnitude/dot/cross stuff

naive pawn
#

Vector2/Vector3 in unity are math vectors (whereas Vectorโ€  in java or vector in c++ would be the cs vector you're referring to)

fading marten
#

Anyone think they can help me? I'm trying to make it so that when my player finishes their jumping animation their capsule collider returns to the normal size it has before it jumps

#

I have this script that plays when a certain frame of the animation is hit and it returns to running, however I can't seem to access my players capsule collider there

swift crag
#

if you have a component that responds to an animation event, then you can give it a CharacterController field and assign it in the inspector

fading marten
swift crag
#

what's stopping you from updating the character controller right now?

fading marten
#

I haven't used that before