#💻┃code-beginner

1 messages · Page 419 of 1

tulip tendon
#

hi, i have a problem wih textures, i have an image that i need as ui sprite, but when i click at texture type and chose sprite, i cant hit apply, when i change other settings i can press aply but nothing will change

tulip tendon
fierce geode
#

the video doesnt show the thing on the side with the file settings,

eternal needle
#

The whole thing basically gets solved when you apply scriptable objects because now you can reference an instance. You can say A goes to B, B goes to A (looping dialogue). With what you had initially, each instance of dialogue (defined in that list) was unique so you couldnt say A goes to B goes to A, because you couldnt reference A like that. Even if identical, it would be A goes to B goes to C. Hopefully this wasnt confusing.
I wouldnt really describe what you had as segmented, it's more of just how you were creating instances that was the issue in the first case.

tulip tendon
slender nymph
# tulip tendon here it is

just FYI you should use mp4 rather than mkv if you want to embed the video in discord. most people wouldn't want to download the video to watch it

slender nymph
fierce geode
tulip tendon
fierce geode
slender nymph
#

that is the whole issue

tulip tendon
#

oh, thx you soo mutch

frank zodiac
#
get => _currentHealth;
set
{
    if (_currentHealth <= 0)
    {
        Die();
    }
}

for some reason this line of code is running in update, i only want it to run ONCE when the player dies

slender nymph
#

you'd have to share more context. but your setter doesn't actually assign to the backing field. so i assume that it remains 0 so each time you attempt to assign to it the Die method is called

frank zodiac
#
if (collision.CompareTag("Projectile"))
{
    PlayerCombat.GetInstance().CurrentHealth -= 1;
}

im only setting it here

slender nymph
#

why do you insist on showing as little context as possible

frank zodiac
#

right?

slender nymph
#

one would assume so, yes. but you're barely showing any context at all so how could anyone possibly guess what is causing the issue

#

have you even bothered doing any debugging to find out what is going on?

frank zodiac
#

I did a debug log when it hits a projectile and it only ran once

slender nymph
#

have you considered a log in the setter where your issue actually is?

#

at least i'm assuming that you've actually done literally anything at all to narrow it down to that being the issue

eternal needle
#

The issue doesnt even make sense, your property is not magically associated with update at all

slender nymph
#

maybe someday we'll see all of the code so we don't have to play "make 100 suggestions until they accidentally stumble upon something that might be related"

fierce geode
eternal needle
# fierce geode Changed the dialogue script to scriptable objects, and now can't assign a dialog...

Custom editor scripts shouldnt really interfere with this, assuming you're using like DrawDefaultInspector, I forgot what the actual method is called if im wrong here.
What are you trying to assign? Also I highly recommend in some form saving all those dialogue options you already had because just changing this to scriptable objects might just break everything and lose you all those components saved in scene.

fierce geode
eternal needle
#

Or maybe just create a new script for the SO to hold the dialogue information, create assets and then just copy what you had in scene to this asset

#

I dont know much about editor scripts, just double check that you're using the right types. Maybe even try this on a new test script entirely to see if you can drag it on there

fierce geode
#

but now everything functions well

barren meteor
#

I just opened my unity project for the first time in a month, but now I got some random errors I didn't have last time I opened the project, why did this happen?

slender nymph
#

configure your !IDE and check for duplicate script

eternal falconBOT
eager spindle
#

i want to make a game entirely in visual scripting for fun

#

but its gonna be so pain

barren meteor
molten dock
#

could someone simply explain what {get; set;} does

hallow acorn
#

can i use "this" keyword if i want to for example the object my script is attached too?

fierce geode
#

Are all errors equal?

cosmic dagger
fierce geode
#

I'm getting annoyed at Unity's SplineAnimate script, because it will set the position of the thing it's animating even when the script itself is disabled.

hallow acorn
cosmic dagger
#

@hallow acorn Typically, it's used (to differentiate between) if you have a class field and a local variable of the same name . . .

fierce geode
hallow acorn
languid spire
fierce geode
cosmic dagger
cosmic dagger
#

Accessing the gameObject property will refer to the object the script is attached to. Similar to transform . . .

languid spire
tacit lava
#

hi, I'm trying to reposition and resize a UI button with a script, but the UI button ends up being unaffected by my script. Does anyone have experience with doing something like this?

Here is my script:

public class RTS_ResponsiveUIElement: MonoBehaviour {
    [Header("Position offsets (in % of viewport height)")]
    public float positionX = 0f;
    public float positionY = 0f;

    [Header("Size (in % of viewport height)")]
    public float sizeX = 0f;
    public float sizeY = 0f;

    void Start() {
        Debug.Log("RTS_ResponsiveUIElement.Start: called");
        this.AdjustTransform();
    }

    void Update() {
        Debug.Log("RTS_ResponsiveUIElement.Update: called");
        this.AdjustTransform();
    }

    void AdjustTransform() {
        float vh = Screen.height / 100f;
    
        RectTransform rectTransform = GetComponent<RectTransform>();
        rectTransform.sizeDelta = new Vector2(this.sizeX * vh, this.sizeY * vh);
        rectTransform.anchoredPosition = new Vector2(positionX * vh, positionY * vh);

        Debug.Log($"Setting size to: {rectTransform.sizeDelta}");
        Debug.Log($"Setting position to: {rectTransform.anchoredPosition}");
    }
}

the logs do show up in the console, and the numbers of size and position are correct; but in practice my button gets its size from Rect Transform and not from my script.

fierce geode
languid spire
fierce geode
languid spire
#

just because a script is disabled does not mean it cannot be executed

fierce geode
#

That does feel a bit confusing, I thought it was to do with the fact that the script calls
#if UNITY_EDITOR
type code.

#

which might circumvent the script being enabled.

slender nymph
#

no. a disabled component only prevents a few specific unity messages from running such as Start, Update, FixedUpdate. other messages like Awake and OnCollisionXXX are not preventing from running when disabled. Likewise, any method you've defined can still be called on that object

fierce geode
#

Ah okay.

languid spire
#

I am guessing, if you have code which is throwing exceptions in the editor but not in a build then you have code inside a UNITY_EDITOR define which is causing it

fierce geode
#

Yeah, my only confusion is that the function that the error is logged in. Is only called in the Start function.

#

The script I'm talking about is the SplineAnimate script

#
  void Start()
    {

#if UNITY_EDITOR
if(EditorApplication.isPlaying)
#endif
Restart(m_PlayOnAwake);
#if UNITY_EDITOR
else // Place the animated object back at the animation start position.
Restart(false);
#endif
}

Context: the function that calls the logError is inside Restart

#

I think the error should be fine, since if disabled component stops Update or FixedUpdate; then I should probably be in the clear. Since it probably won't animate outside of those functions.

hallow acorn
#

hey i have a slight problem. my ship shoots barrel towards my target point, randomized by around +/-10° on the y axis. is there a not to complicated way to increase the probability for the barrels to get shot towards the middle of the island like an heatmap?

fierce geode
#

If I wanted to be really safe... I could use AddComponent to add the SplineAnimate script only when I needed it and then remove it otherwise.

hallow acorn
#

could i do 2 targets, one for every island with a bit smaller rotation range and a 50/50 chance on which target it lands?

fierce geode
#

Or if you want the accuracy probability to be more gradual. You could lerp the former solution. Like
Mathf.lerp(10,0, Random.Range(0.0f,1.0f)).

frank zodiac
#

is this considered too much scripts for a game with a dialogue system and combat system and inventory system

silk night
#

no

frank zodiac
silk night
#

but you should create some folder structure for it

frank zodiac
#

in unity i have a huge array of subfolders

final hull
#

Heya, do anybody know how to store DoTween animation in a scriptable object please?

silk night
final hull
#

Alright, thanks will see what can I do

fierce geode
#

Simple question, how do you invert a layerMask?

slender nymph
fierce geode
#

thanks!

wanton canyon
#

Can someone point me in the direction for how to program rain? I have a particle effect but I'm a little dumbfounded on how to randomly time the initiation of it, and when I google it I just get creating the particle effect...

slender nymph
#

which part are you not understanding how to do? like are you asking how you can randomly call the ParticleSystem's Play method?

cosmic dagger
wanton canyon
slender nymph
#

well you can generate random numbers using the Random class. beyond that it really depends on exactly how you want it to behave

hallow acorn
#

can i get a transform in an array using getComponent and CompareTag? if yes how exactly would the index look i cant figure it out

river quiver
#

i want to build a game and this is coming up while building it The name 'AssetDatabase' does not exist in the current context.

{

    Camera mainCamera = Camera.main;
    int newPos = (int)mainCamera.transform.position.x + 21;

    switch (newPos)
    {
        case 0:
            nameText.text = "Bagieta:";
            descriptionText.text = "- podobno od niego capi\r\n- lubi fugę\r\n- jako skrzydło posiada piłę łańcuchową";
            twitchText.text = "- https://www.twitch.tv/mbagietson";
            break;
        case 21:
            nameText.text = "Mamm0n:";
            descriptionText.text = "- jeździ na wózku\r\n- lubi makowiec i chrupiącą\r\n- lata machając chrupiącą";
            twitchText.text = "- https://www.twitch.tv/mamm0n";
            break;
    }

    AnimationClip clip = new AnimationClip();
    Animation animation = mainCamera.GetComponent<Animation>();
    AnimationCurve curve1 = AnimationCurve.Linear(0.0f, mainCamera.transform.position.x, 0.75f, newPos);
    AnimationCurve curve2 = AnimationCurve.Constant(0.0f, 0.75f, -10.0f);

    clip.SetCurve("", typeof(Transform), "localPosition.x", curve1);
    clip.SetCurve("", typeof(Transform), "localPosition.z", curve2);
    clip.name = "CameraMoveRight";
    clip.legacy = true;

    animation.clip = clip;
    animation.AddClip(clip, clip.name);
    AssetDatabase.CreateAsset(clip, "Assets/" + clip.name + ".anim");
    animation.Play();

    leftArrow.SetActive(true);
}```
this is the code and the ``AssetDatabase.CreateAsset(clip, "Assets/" + clip.name + ".anim");`` is the line that the error is refering to
#

what can i do to avoid this

slender nymph
#

you cannot use the AssetDatabase in a build

river quiver
#

is there something else i can use?

slender nymph
#

is there a reason you are creating an asset there?

river quiver
#

so i can play it

#

or i dont have to create it there

#

i just want to be able to play that animation which is created in this script

wanton canyon
solar arrow
#

this.GetComponent<Image>().enabled = false;

why is this doesnt work can someone explain?

slender nymph
slender nymph
solar arrow
slender nymph
#

you've got the wrong using directive. you are likely trying to use UnityEngine.UIElements.Image rather than UnityEngine.UI.Image

solar arrow
#

i dont see that UIElements.Image before

#

sorry, but i appreciate your help

slender nymph
#

no problem, you just gotta pay more attention to the options in the autocomplete in your IDE, when you start typing something like Image it will show multiple options, and should show the namespace for each option, which option you select or tab to complete will be the one the namespace is imported for

atomic holly
#

Hello,
I want to put a bubble at the top of a PNJ when I come close to it. Should I create this bubble as a child of my PNJ or create it in the canvas ?

willow scroll
atomic holly
#

Yes so an NPC

willow scroll
manic void
#

i'm making an inventory system for a 3d unity project. right now i'm trying to add a drag and drop system to the items but it doesn't work.. I only have debug.logs right now and nothing shows up in the console

DragDrop - https://hst.sh/cufazifuva.cpp
ItemSlot - https://hst.sh/movubemodo.csharp

i've read forums talking about adding a StandaloneInputModule to the event system but because im using new InputSystem i need to use a InputSystemUIInputModule. I've added a canvas group to the item, made sure the canvas has a GraphicRaycaster. I also did an Event System debugger - https://hst.sh/musobofono.cpp and still nothing shows up in console. when i click on the item absolutely nothing happens

atomic holly
#

It will be an image with some text in

#

But I want the bubble is fix compared to the NPC

willow scroll
#

In your npc script, serialize the bubble prefab and instantiate it at the beginning of the game, constantly aligning its position when changed

#

Surely, you will have to use the main camera to convert the spaces

atomic holly
willow scroll
sharp abyss
#

trying to recreate a system like qwop without ankleshttps://paste.ofcode.org/379dhvpMEsxaYJJxwDii8x4 I have this script but that doesnt work properly I cant go forward.Thought about it may be because of limits.(dont use animations)

atomic holly
willow scroll
atomic holly
#

So the NPC will not be a gameobject but a UI, that's it ?

willow scroll
willow scroll
#

Yes

atomic holly
#

Mhhhh, so if I understand, I need to change always the position of the bubble UI in the script of the NPC ?

waxen void
#

Hello, Can anyone help me with scriptable objects?

So, I'm trying to make an editor script for the scriptable object so that it shows toggle buttons like shown in the video and I can store where obstacles need to be instantiated on the grid. But, currently what happens is when I hit play or restart unity or recompile scripts the scriptable object gets reset as shown in the video.

Below are the relevant scripts:

Obstacle Editor:

using UnityEngine;

[CustomEditor(typeof(ObstacleData))]
public class ObstacleEditor : Editor
{
    public override void OnInspectorGUI()
    {
        ObstacleData obstacleData = (ObstacleData)target;

        for (int row = 0; row < 10; row++)
        {
            EditorGUILayout.BeginHorizontal();
            for (int col = 0; col < 10; col++)
            {
                obstacleData.blockedTiles[row,col] = EditorGUILayout.Toggle(obstacleData.blockedTiles[row,col]);
                
            }
            EditorGUILayout.EndHorizontal();
        }

        if(GUI.changed)
        {
            EditorUtility.SetDirty(obstacleData);
        }
    }
}

ObstacleData:

using System.Collections.Generic;
using UnityEngine;


[CreateAssetMenu(fileName = "ObstacleData", menuName = "ScriptableObjects/Obstacle Data")]
public class ObstacleData : ScriptableObject
{
    [SerializeField] public bool[,] blockedTiles = new bool[10,10];
}
errant anchor
#

!code

eternal falconBOT
languid spire
waxen void
#

ohh? I'm still new to this can you explain how I can do that?

languid spire
#

look at the AssetDatabase.Save documentatioin

willow scroll
errant anchor
willow scroll
#

What SetDirty does is mark the object as dirty for it to be saved in the AssetDatabase when the Assets are reloaded

waxen void
sage mirage
#

Hello, guys! I am playing around with post-processing and I don't understand why it says that to me? Also, it doesn't work when I am checking and unchecking it, I mean in Screen Space Reflections.

willow scroll
errant anchor
errant anchor
willow scroll
errant anchor
#

why not the same

#

so confused

#

without any input

waxen void
willow scroll
waxen void
verbal dome
#

The physics will take care of that

#

@errant anchor The value it is printing is not actually (0.00, 0.00) but some small numbers (like 0.0001), that's just how Vector logs look by default. It shows only two decimals.

silk night
#

RigidBody.MovePosition already included deltatime, right?

summer stump
fickle plume
#

By the virtue of where it should be used

#

Since it should be used in FixedUpdate it will be frame independent (based on fixed frames instead)

silk night
#

Oh yeah right

Hmm i just changed from transform.position to Rigidbody.MovePosition and now my units are slow as hell and I am not sure what the difference is right now even though ive done it a hundred times by now xD

#

well the solution was just above this, forgot to switch to fixedupdate

errant anchor
errant anchor
normal badger
#

Hi everyone, I'm currently developing a video game in unity, the game is set to be released at the end of this year, but I'm having trouble setting up the procedural animation for the monster, does someone knows about procedural animations on Unity?

errant anchor
uncut dune
#

awesome now what

verbal dome
# uncut dune

Put emission into a local variable first then modify that

polar acorn
# uncut dune

You cannot both get and set a struct on the same line. You want to store the emission burst in a variable, then modify it's count

verbal dome
polar acorn
# errant anchor

Try this log instead:

Debug.Log($"Input: {inputDirection}, speed: {speed}, Rb.velocity: {Rb.velocity.ToString("F6")}", this);

this will tell you more about the input and speed values to see which is the problem

austere crypt
#

Hello, can anyone help me add nuget libraries in unity ?
Tried but it's getting removed from project

verbal dome
#

Btw {Rb.velocity.ToString("F6")} can be shortened to {Rb.velocity:F6}

errant anchor
uncut dune
#

no errors so Ig

magic pagoda
#

I have this line of code and I want it to pick a float between 0 and 1, but it constantly picks an int. how can I make it pick a float?
float spawnValue = Random.Range(0, 1);

verbal dome
magic pagoda
#

so is Random.Value more reliable or (0f, 1f) more reliable?

verbal dome
#

Same result

uncut dune
#

is this possible?

magic pagoda
#

okay, thanks!

verbal dome
#

The structs are just sort of wrappers with properties

rich adder
# magic pagoda okay, thanks!

Random.value is only 0-1 float.
so its quicker to write if you you only need 0-1 (but it makes no difference functionally)

uncut dune
verbal dome
rich adder
#

its weird with Particle System man... you dont need to assign back only specific things

uncut dune
austere crypt
uncut dune
verbal dome
#

Yeah particle system is doing things in a pretty non standard way in this case

polar acorn
magic pagoda
#

ended up going with value ^^

rich adder
polar acorn
# uncut dune is this possible?

Okay, so, particle systems are really really fuckin weird in that they give a similar error to trying to modify the components of a vector, but they are passed by reference. So you just need to store it in a variable and modify it and that's the whole thing done and dusted, while the incredibly similar error with things like rb.velocity have that extra step of reassigning back. Unless you look up which things are structs or classes in the documentation, this is the kind of thing you just have to know through experience

polar acorn
rich adder
uncut dune
polar acorn
rich adder
rich adder
#

how much procedual are walking here

#

fully IK ? Script driven ? etc..

uncut dune
#

unity is messing me upnotlikethis

#

how do I work around this

#

it doesnt show up in editor

rich adder
#

yes they are not serializable

uncut dune
#

do I need a for loop to check every component of the game object?

rich adder
#

you could make a custom inspector too iirc

#

or there is one on github somewhere

rich adder
polar acorn
# uncut dune it doesnt show up in editor

IDamageable is presumably an interface, which is not serializable by default. What I tend to do in these situations is make an abstract class that extends monobehaviour, something like public abstract class DamageableBehaviour : MonoBehaviour, IDamageable and make your script extend that. It'll still have to implement the methods, and still be an IDamageable, but you'll be able to drag it in by making that field of type DamageableBehaviour

#

Note, the DamageableBehaviour should not have any functionality. It's just a passthrough for the interface methods while allowing it to also inherit MonoBehaviour

uncut dune
rich adder
#

why not just GetComponent if its on the same object, store the private var assign it with GetComponent

uncut dune
rich adder
#

that defeats the point of the interface no?

polar acorn
uncut dune
polar acorn
#

As long as there's only one IDamageable on it, it'll grab that one

polar acorn
#

If there's more than one and you need a specific one, you'll need to go either the abstract class or custom editor route to be able to drag it in

summer stump
rich adder
#

doesnt Odin support interfaces?

summer stump
#

Yeah iirc

uncut dune
rich adder
#

ISleep, IEat, ICode

uncut dune
#

lmao

polar acorn
rich adder
#

yay love that comparison, use it myself. abstract is like interface but with inheritance instead of composing

polar acorn
#

For the most part, you can think of it as an interface that can define functions in addition to declaring them (since Unity doesn't support that feature of C# yet) at the cost of losing out on multi-inheritence

uncut dune
#

will do some research around it, u made me curious

#

I just know that if I dont understand it its cuz its powerfull as heck

rich adder
polar acorn
uncut dune
rich adder
#

yeah you can assign multiple interfaces to one object which can help composing a modular object.
With abstracted you are limited to only inherit one class

polar acorn
#

You know I never actually checked if Unity 6 is going to actually have that interface change yet or if that's still nebulously "in the future"

cosmic quail
rich adder
uncut dune
#

I see, so cool! Ive been off of unity recently messing with C and even godot and Ive came with a more modular mentality, trying new things ended up making me learn about new stuff here so I feel like it was positive

polar acorn
rich adder
#

we need a TryGetComponentInParent and TryGetComponentInChildren 😦

#

had to make extension methods..

brave compass
polar acorn
#

However if you already have DamageableBehaviour there's fundamentally no difference, unless you're gonna need to access any MonoBehaviour methods like .transform

zenith cypress
polar acorn
#

Oh dang is it? I really should check these things before assuming they just haven't updated them

uncut dune
rich adder
#

unless you're doing basic c# stuff like IO writes or Web Calls

zenith cypress
uncut dune
rich adder
hallow acorn
#

can i somehow get a transform using getcomponent and compareTag if yes how exactly would the syntax look like? i cant figure it out

rich adder
polar acorn
rich adder
#

generally all Components have access to their Transform
(components only exists on gameobjects anyway so they always have both transform/gameobject)

warm condor
#

Hey everyone, can anyone explain to me why my character in vibrating/bouncing when I am sliding. It works a lot better when sliding to the right, but when sliding to the left it is much worse. Here i'll show you a video:

hallow acorn
rich adder
#

they just told you how lol

polar acorn
warm condor
rich adder
hallow acorn
rich adder
polar acorn
hallow acorn
polar acorn
rich adder
#

have you bothered looking at examples online

zenith cypress
#

@brave compass and it still doesn't support these lol

hallow acorn
polar acorn
hallow acorn
slender nymph
#

in order to call CompareTag on something you have to already have a reference to that object

polar acorn
hallow acorn
polar acorn
#

on the same object you just checked the tag of

rich adder
#

its literally in the example
replace gameObject with transform its the same thing

#

you probably should learn how references work @hallow acorn its essential knowledge

hallow acorn
warm condor
#

guys, can someone help me here... #💻┃code-beginner message
I don't know why my character in vibrating/bouncing when I am sliding, especially when sliding to the left.

queen adder
#

how can I make my character stick to the gameobject it lands on? like in crossy roads.

slender nymph
#

a common solution to that is to set the player as a child of the moving object

rich adder
#

imagine doing Country.State.City.Address

#

to find your home (in this case an object, or a function etc.)

queen adder
celest holly
queen adder
#

thanks ill look into it

normal badger
# rich adder "procedual animations" in unity is pretty vague

The creature that I’m trying to animate is a spider with 8 legs, and each already has IK rig on it, but I’m having trouble with the code, I have been using this video from YouTube https://youtu.be/acMK93A-FSY?si=sqU7fCK5ghzZkscu

In this episode of the Prototype Series, we've expanded the Procedural Boss project by creating a procedurally animated walk animation!

⭐ Project Download https://on.unity.com/3jX6PAY
⭐ Training Session https://on.unity.com/3atx3rW
⭐ Procedural Boss video https://youtu.be/LVSmp0zW8pY

Timestamps:
00:00 - Intro
00:54 - Setting up the rig
03:55 -...

▶ Play video
rich adder
rocky canyon
#

ive gotten mine to stand.. but no walk yet

rich adder
#

took me ages just to get my character to press the button dynamically, it was not a fun experience lol

rocky canyon
#

ya, its never straight forward for sure

river quiver
#

is there something that only happens in unity editor?

rich adder
#

how should we know you only posted 1 function

#

debug it

#

animation component is wildly outdated

#

why is this even going on here typeof(Transform) ohh I see because animation clip function..

river quiver
#

wdym

#

what should i use then

rich adder
#

wasn't Animation component deprecated or am I misremembering 🤔

#

anyway I have no clue what this scrip is supposed to do but cant you just use the Timeline

slender nymph
#

it's not deprecated, it's just older than the mecanim animator system and is considered "legacy"

river quiver
rich adder
slender nymph
#

especially since each time you call this method you create a brand new animation clip

river quiver
slender nymph
#

sure, but is there a reason you need to use an animation for that? it's incredibly simple to just lerp its position or whatever

#

you can even sample an animation curve for the lerp's t value if you want easing

river quiver
#

i didnt know there exists a thing like lerp

#

im new to this

slender nymph
#

if you're so new, perhaps consider going through some basic courses to learn wtf you are doing. i don't understand how you came to the conclusion you needed to generate an animation clip and also save it into the asset database (since you were doing that earlier) just to move an object when almost every google search would have provided information about just modifying its position or using cinemachine or something

#

the pathways on the unity !learn site are an excellent place to get started learning how to use the engine

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
river quiver
#

no

#

but ok

#

i get it

#

shit code

rich adder
#

no one said that

rocky canyon
#

😄 nah, just not common

cosmic dagger
#

I'm all about the basics . . .

rich adder
#

usually AI comes up with wild functions to do basic things was curious were code was from

river quiver
#

i guess i code like ai

rich adder
spiral glen
#

Is there a way to make it so I can check if an object is touching ANY other collider instead of just one with a pre-defined gameobjects collider?

river quiver
rich adder
#

ah yes I can see why that showed up now

#

if its a cinematic why not use Timeline or Animator?

#

no scripts needed

#

acutally even the dolly function in cinemachine

river quiver
#

idk man

#

you just have more knowledge than me

#

a lot

rocky canyon
#

its more rhetorical.. just giving u some options

rich adder
river quiver
#

but you guys know everything about unity

raw token
spiral glen
#

I actually got it

#

It's good

rich adder
spiral glen
#

👍

rocky canyon
summer stump
rich adder
#

not even Unity Devs know about everything Unity UnityChanLOL

twin bolt
#

I'm having a issue with my script, the point of the script is to make a mini Looking system for a stationary player, my only issue is that the yaw never starts at the cameras y rotation i set it to at the beginning. https://hastebin.com/share/vanokurude.csharp

#

for example, my player starts at -180 y the script sets the player to -90

#

the look max is 90

rocky canyon
#

i see gimbal lock in ur future

spiral glen
#

anyone know how to make my colliders work?
I tried changing it from collider to collider2D, collision2D, collision and one other option I can't remember.

polar acorn
rich adder
#

i would not directly set localEulerAngles

#

i would use .rotation/localRotation instead

twin bolt
polar acorn
slender nymph
rocky canyon
#

also theres an error there because ur trying to use OnTriggerEnter()

#

yea.. u seen nvm

rich adder
#

the IsTouching is def not needed if it already hit Trigger

cosmic dagger
rocky canyon
polar acorn
# twin bolt CameraROTY

Try this log before the clamp line:

Debug.Log($"Clamping Yaw from {yaw} between {CameraRotY - lookMax} and {CameraRotY + lookMax}, result: {Mathf.Clamp(yaw, CameraRotY - lookMax, CameraRotY + lookMax)}");
yaw = Mathf.Clamp(yaw, CameraRotY - lookMax, CameraRotY + lookMax);
twin bolt
polar acorn
#

Oh, wait, clamping from 0

#

meaning that's the default value of yaw

#

Maybe just give me the whole line

twin bolt
#

whole line of what?

polar acorn
#

the log I had you write

#

just give me the whole log

twin bolt
#

Clamping Yaw from 0 between -270 and -90, result: -90

polar acorn
#

Okay, that makes sense. Your starting Yaw is out of range, so it gets clamped

#

So what's the problem?

twin bolt
#

THe problem is i need it to start at the beginning rotation. So for example my camera is set to -180, but when i enable the camera the script sets it to -90

polar acorn
#

It's currently set to 0

polar acorn
willow scroll
verbal dome
#

Could store the starting yaw (euler y) in a separate variable at start, then add that to the final yaw in the Vector3 that you assign to localEulerAngles

#

If you want the clamping to be relative to the starting angle

spiral glen
#

I'm trying to access a method from a different script, I tried doing it like this (basic movement is the script that has the metod and grabTest is the accessor for hte method. anyone know how to fix this?

slender nymph
spiral glen
#

isn't the reference basicmovement?

rich adder
#

access the instance, right now you're accessing a "blueprint"

zenith cypress
#

That's a type

spiral glen
#

ah ok

#

so if I got access to the player object (which has the script) it'd gain access to the method

rich adder
#

You need the Instance thats on the player
so if its on a player you have to find that first, or you can use a cheat sheet sometimes with FindObjectOfType(this is ideal if only 1 instance exists of said script) or whatever the new equivalent is

twin bolt
queen adder
slender nymph
#

use the SetParent method. and to unparent it, you set its parent to null

polar acorn
spiral glen
rocky canyon
#

it means you have to tell the code What instance / version / copy of that Script are you using

#

u declared it (told the script it exists) but u dont assign it. (tell it which one)

rich adder
# spiral glen what does that mean

imagine you want to run a function called Slap()
and say you have class named Human..

the computer want sot know, which human you want to slap ? you are looking for Jeff

polar acorn
# spiral glen what does that mean

I mean you could have a trillion instances of BasicMovement in your scene for all the code knows. Which specific one do you want to call grabTest() on?

queen adder
#

no basically, my character now sticks but when it sticks it doesn't allow jumping, which is necessary to jump onto other obstacles. I tried a method to unparent first and then jump when the jump button is pressed but it doesn't seem to be working. ```void Update()
{
if (Input.GetButtonDown("Jump") && IsGrounded())
{
Transform currentParent = transform.parent;
transform.parent = null;
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
//transform.parent = currentParent;
}
}

void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Obstacle"))
{
Debug.Log("Crashed");
}
else if (collision.gameObject.CompareTag("Platform"))
{
transform.parent = collision.transform;
}
}

void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Platform"))
{
transform.parent = null;
}
}```

spiral glen
#

the one on my player object

queen adder
#

oops sorry mightve been too bi

rich adder
#

parenting wont work well

queen adder
#

ohh how should i change it

rocky canyon
#

aka slip and slide

polar acorn
rich adder
#

look up "rigidbody moving platforms" you get a plethora of info

queen adder
silk night
#

Is there something like physics2d circlecast without a direction? Like just detecting whats around you? or is that just 0 for distance?

silk night
#

OverlapCircle?

polar acorn
#

Yeah, sorry, that's the one for 2D

silk night
#

CheckCircle doesnt exist 😄

#

ty

grizzled gale
#

@silk night

silk night
#

yeah?

grizzled gale
#

@rich adder

polar acorn
#

Please don't ping random users for no reason

rich adder
celest holly
silk night
#

if (closest < delta.sqrMagnitude)
if (closest < delta.magnitude)

Top one is faster cause its doesnt have to calc the sqrRoot right?

polar acorn
#

@silk night is correct

willow scroll
#

The bottom one is faster, because it doesn't have to calculate the square root.

polar acorn
#

sqrMagnitude is faster

#

Because it doesn't have to square root it

willow scroll
#

Damn, I was...

#

Yeah, you're right

summer stump
#

A² + B² = C² (as an example, using 2D)
sqrMagnitude is the C², then you can square root it to get magnitude (or just C)

Just to be clear about the order of operations

wanton pecan
#

Y'all I want to learn c# but I don't want to watch boring tut that won't teach anything for 4 hours what do I do?

frosty hound
#

Give up?

#

Sit on tiktok and watch 5 second videos that won't bore you.

rocky canyon
#

lol.. that ^ or find better sources..

#

hopefully ur a fan of reading.. else game-dev is gnna be challenging for u

hallow acorn
polar acorn
zenith cypress
final kestrel
#

Are not brackey's tutorials outdated now?

rocky canyon
#

no not really..

final kestrel
#

I think he recorded those way before

rocky canyon
#

unity hasnt changed its basic functionallity in ages

#

some things change/ menus/ locations/ some things get deprecated and replaced.. but the gist of them are still the same..

#

i still recommend sebastian lague unity c# playlist.. its almost 8 years old

final kestrel
#

Sebastian is going too deep into maths I believe thats why he confuses me a lot haha. But yes Man knows what hes doing!

rocky canyon
#

ya his basic beginner series is good

#

his studies get deep tho

rocky canyon
silk night
wanton pecan
#

I need some fun stuff that won't bor me as much but still teach alot

#

Yk

willow scroll
eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
languid spire
spiral glen
#

why no worky

#

oh gimme as ec ill show the red

languid spire
#

typo

spiral glen
#

oh

polar acorn
willow scroll
spiral glen
#

damn

#

wrosk

spiral glen
#

works

#

grati

wanton pecan
languid spire
rich adder
wanton pecan
rich adder
#

lol

spiral glen
#

putting a
timer += Time.deltaTime;
in a while loop doesn't do anything weird and just makes it into a timer, right?

rich adder
#

"I did everything " is redudant

#

chances is the opposite

wanton pecan
#

Nope

rich adder
wanton pecan
#

Most tutorials r wrong

spiral glen
#

actually that makes no sense without further blah blah

rich adder
#

this will just freeze until its done

spiral glen
#

ah ok

#

how would I make it happen over a span of frames?

wintry quarry
# spiral glen

This is more or less equivalent to not having those two lines at all

spiral glen
#

oh in update()

wintry quarry
#

or Update

spiral glen
#

what's coroutine?

wintry quarry
#

it's a piece of code that lets you "wait" in the middle of it

rich adder
wintry quarry
#

a special type of function in Unity

spiral glen
wintry quarry
#

not quite

#

Because it's a special kind of waiting

#

that doesn't freeze the whole application

rich adder
wintry quarry
#

it lets the rest of the game engine run while it waits

spiral glen
#

oh ok

#

I'll check that out before going to update

hallow acorn
# hallow acorn hey i have a slight problem. my ship shoots barrel towards my target point, rand...

is this a solution? ```
Transform[] Targets = new Transform[2];
GameObject[] Objects = GameObject.FindGameObjectsWithTag("Target");
for (int i = 0; i < Targets.Length; i++)
{
Targets[i] = Objects[i].transform;
}
if(Random.Range(0, 2)== 0)
{
Vector3 TargetRotation = new Vector3(transform.rotation.x, Random.Range(Targets[0].transform.rotation.y - rotationVariance, Targets[0].transform.rotation.y + rotationVariance), transform.rotation.z);
}
else
{
Vector3 TargetRotation = new Vector3(transform.rotation.x, Random.Range(Targets[1].transform.rotation.y - rotationVariance, Targets[1].transform.rotation.y + rotationVariance), transform.rotation.z);
}

summer stump
rich adder
wintry quarry
willow scroll
spiral glen
eternal falconBOT
#

:teacher: Unity Learn ↗

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

wintry quarry
#

They are not euler angles

#

you can't treat them as euler angles

polar acorn
# hallow acorn why?

Because transform.rotation is a Quaternion, a 4-dimensional complex number that unless you're a PhD in math means absolutely fuck all to anyone

hallow acorn
polar acorn
# wanton pecan Most tutorials r wrong

169 people have said the same thing before you. And 169 more are probably to come. Yes this is a live counter. Yes this is only things I have personally witnessed.

"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 169
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-07-09
hallow acorn
polar acorn
hallow acorn
wintry quarry
hallow acorn
wintry quarry
#

z is just the first one i noticed in your code

rich adder
#

.rotation will give you numbers into 0-1 range

polar acorn
willow scroll
# waxen void ahh alright please tell me if you find something. Thank you for the help!!

The thing is that assigning the matrix's elements this way is not entirely correct, as they don't seem to save their values when accessed from target.

obstacleData.blockedTiles[row, col] = EditorGUILayout.Toggle(obstacleData.blockedTiles[row, col]);

You're also unable to access a SerializedProperty for a matrix with the SerializedProperty.FindProperty method, so I think the only may to do it is create your own structure with, note, a custom PropertyDrawer, not Editor, for it. This way, you also won't need to create a custom Editor for your class, assuming only this Type is meant to be drawn.

rich adder
#

they're not angles -180 to 180

final kestrel
#

I have been using rider but shit started acting weird. Do i go with vs code or visual studio you think?

hallow acorn
polar acorn
queen adder
polar acorn
#

Because that is a four-dimensional normalized vector

rich adder
#

when using .rotation to set angles, always use the Quaternion.Euler method

hallow acorn
polar acorn
celest holly
rich adder
#

storing rotations always use Quaternions

hallow acorn
#

bro i just want to turn my cannon why is this so complicated

wintry quarry
#

because you don't understand it

spiral glen
#

would this work to create a 3 second delay w/ enumerators?

rich adder
wintry quarry
queen adder
hallow acorn
spiral glen
polar acorn
polar acorn
spiral glen
polar acorn
spiral glen
rich adder
#

i thought you wanted to wait for the door activate ?

wintry quarry
spiral glen
rich adder
#

oh ok then yeah put after the wait

spiral glen
#

this function is being called by the door activate thing

queen adder
hallow acorn
wintry quarry
hallow acorn
queen adder
#

that must be the problem, ill fix it

celest holly
#

you could shoot a raycast down instead

#

i think thats how most people do it

#

i think it just works better in general

queen adder
#

i fixed it thanks for the advice

wintry quarry
#

I think you just want something simple like:

// Pick random target
GameObject[] Objects = GameObject.FindGameObjectsWithTag("Target");
int randomItem = Random.Range(0, Objects.Length);
Transform target = Objects[randomItem].transform;

// point at the target with some random variation
float rotationVariance = Random.Range(-10f, 10f);
Vector3 directionToTarget = (target.position - transform.position).normalized;
Vector3 rotatedDirection = Quaternion.Euler(0, rotationVariance, 0) * directionToTarget;
transform.forward = rotatedDirection;```
hallow acorn
#

bro what

#

youre blowing my mind

wintry quarry
#

It's unclear to me why your old code was reading the rotation of the target

#

we don't care about the rotation of the target unless I'm misunderstanding the ask

hallow acorn
#

yeah idk

trail harbor
#

Any idea why I have to regenerate csproj after opening visual studio 2022 everytime? IDE doesn't work before running the regenarate button in unity

rich adder
#

delete old csprojs if any

#

try other new projects see if its same problem

slender nymph
languid spire
rich adder
#

ohh thats weird is it not saving the settings?

slender nymph
# trail harbor Exactly

if that is the case then unity is for some reason unable to write the setting to the registry. if you launch it as admin, change that setting, then relaunch without admin permissions that setting will stick

trail harbor
#

deleted libary folder and the .sln ill try now

#

alright

slender nymph
#

neither of those steps you've tried are relevant to the actual issue

rich adder
#

oh yeah then this is prob not project

#

editor issue

stark sapphire
#

Hey so I'm new to the programming thing with Unity, currently I'm trying to make a Save System for Character Creation, I want it to be Artist Friendly without needing to touch code and it's set up, the only problem is, nothing saves.
What I want to save are mostly the Blendshapes on the Character Body and the Prefabs that attach during runtime, but no matter what I do nothing seems to make it save anything.

trail harbor
#

Thanks, it worked by using all 3 steps, running as admin and deleting libary & sln. Just did all at once and it worked.

river quiver
#

if i want to use the Vector3.Lerp and move the object smoothly i probably would need to place it in the Update() or can i try with a while loop inside another function which executes after clicking a button

slender nymph
#

!code

eternal falconBOT
cosmic dagger
#

Not like this . . . 😭

stark sapphire
#

What do you mean?

languid spire
#

He means if you want people to look at your code, post it correctly

stark sapphire
#

How do I do that?

languid spire
#

there is a bot message right there

stark sapphire
#

Ah okay, I'll try it that way.

slender nymph
#

and if it wasn't clear, you should be using links to a bin site, not the inline code section

sudden pilot
#

guys what is the more optimize way for read a code frame frame

#

ı mean like fixedupdate reads 50 frame each second

#

but ı want some funcıon reads 5 frame each second

slender nymph
#

can you explain wtf you mean by that

verbal dome
sudden pilot
verbal dome
#

You could use a timer

sudden pilot
slender nymph
#

use a timer

sudden pilot
#

isnt there any other way right?

languid spire
#

no way you can be sure to run for 5 frames/second you can only approx it

sudden pilot
#

yea ı need to do ıt approx

languid spire
#

coroutine is favourite

sudden pilot
#

just ı want to know is there any way to make more slow functıon lıke update

sudden pilot
spiral glen
#

if I use a static class, can I access the methods from that class in any other class?

summer stump
#

Via the type of course

#

Mathf.Max
Oh wait, is that the weird one they made a struct?

slender nymph
#

naturally they do need to be public

zenith cypress
summer stump
#

Yeah just remembered. Picked the worst example of course

spiral glen
#

is there a static class thing on the unity website, I can only find it for game objects (so I can figure out what I'm doing with it)

slender nymph
#

wdym by "static class thing"

spiral glen
#

gimme a sec I'll try to find an exmaple

slender nymph
#

to create a static class you declare it as static in the code

summer stump
slender nymph
#

it is not the same thing as making a gameobject static

spiral glen
#

yeah idk I'm just trying to figure out how to solve the CS0713 error I got

polar acorn
#

What is the actual error

spiral glen
#

Static class 'Control' cannot derive from type 'MonoBehaviour'. Static classes must derive from object.

polar acorn
#

Well yeah

#

static classes can't be MonoBehaviours

slender nymph
spiral glen
#

ik but then what do I put there

summer stump
polar acorn
summer stump
#

You can write a class that doesn't inherit anything

public class MyClass { }

slender nymph
#

note that if you need this attached to some gameobject for any reason at all then it cannot be a static class because it must derive from MonoBehaviour

zenith cypress
#

it inherits object

spiral glen
#

I'm just gonna find a video to explain static classes

slender nymph
spiral glen
slender nymph
#

that has nothing at all to do with being a static class

spiral glen
#

damn man

wanton pecan
polar acorn
summer stump
slender nymph
# spiral glen damn man

a static class ensures that there are 0 instances of that class and that all of its members are static.
explain the actual use case for what you are trying to do and a proper solution can be suggested

polar acorn
summer stump
spiral glen
polar acorn
slender nymph
#

do not abuse static just for easy referencing

eternal falconBOT
tired bluff
#

Hey guys. Can you tell me why the code is completely highlighted in red in the upper right corner? It seems to have written everything correctly, but it is still highlighted in red.

verbal dome
#

All those red lines have errors in them

#

As you can see the red underlines in the code itself too

tired bluff
verbal dome
#

Is this on an older unity/C# version?

tired bluff
#

No, on a new one

verbal dome
#

The one with errors is a newer version?

#

In any case, look at the errors and show us

#

And share the whole script !code

eternal falconBOT
slender nymph
# tired bluff

i do want to point out that if this did have errors, you wouldn't see them underlined in red because this visual studio is not configured for use with unity

tired bluff
slender nymph
#

i never said that. i said that your visual studio is not configured so it won't show errors

tired bluff
slender nymph
#

!ide

eternal falconBOT
slender nymph
#

also actually providing any information about what the errors are would help determine the actual cause of them

#

i have a theory, but you'll need to actually confirm the errors to confirm whether my theory is correct

tired bluff
slender nymph
#

wdym you only have screenshots? do you not have the unity editor open to actually see the errors in the console?

tired bluff
slender nymph
#

well then come back for help when you do have access

bright grail
#

Hey guys i need a little help im trying to make this thing in unity shoot 4 bullets in different directions based off of what directing the shooter is facing but they all seem to go into the same direction i tried looking on google and couldnt find anything. here is the script https://gdl.space/fihatavuye.cs

wintry quarry
bright grail
#

its put on all 4 shooters

slender nymph
#

also consider not using the rotation values at all for the force, and instead use either transform.up or transform.right depending on which direction they are supposed to face

wintry quarry
#

also

            if (timer >= 2)
            {
                timer -= 2;``` would be more correct
wintry quarry
#

transform.rotation is a Quaternion

#

you will only get a value between -1 and 1 from this

#

so yeah they'll all basically shoot to the right

#

why wouldn't you just do

rb.AddForce(EnemyGunPos.transform.right * BulletSpeed, ForceMode2D.Impulse);```
#

why get angles involved at all

#

even if you wanted an angle here and had the correct one... you were applying it to the y part of a direction vector? It didn't make any sense at all as you had it

#

You could also just do:

rb.AddRelativeForce(Vector2.right * BulletSpeed, ForceMode2D.Impulse);```
bright grail
slender nymph
#

that will at least make it go in the correct direction instead of a nonsense direction. at the moment though you have nothing that makes them point in different directions

bright grail
#

i have them rotate around this circle

silver flicker
#

Hey, I've looked around, but I need some advice. I'm trying to detect a change in a variable (mouse position for context but it'd be nice to know what to do generally) that will need to be called every frame, what is the best method of detecting a change in this variable?

slender nymph
silver flicker
#

Okay, gonna have to look up a lot of that terminology, but thats a good starting point, thanks I'll try it out

wintry quarry
spiral glen
#

anyone know why this error is happening?

#

(on 21 and 18)

summer stump
#

Movement is null

verbal dome
#

You have an instance of this component where movement is not assigned

rapid storm
#

Hey everyone, i need a little help with a editor script. i'm a beginner on unity and C#, but experienced programmer

My problem is in this print.

I tried make a editor script on unity and need use a class MonoBehaviour, but cannot use this by missing reference, error: The type or namespace Interactable could not be found (are you missing a using directive or an assembly reference?)

Editor script: Assets/Editor/InteractableEditor.cs
MonoBehaviour script: Assets/Scripts/Interactable.cs

summer stump
#

Type t:BasicMovement into the hierarchy

#

We cannot tell you where of course

spiral glen
summer stump
#

Not sure which part is not clear

spiral glen
#

I don't know where the hierarchy is

summer stump
#

The hierarchy shows the names of th things in your scene, and their relations to each other. It is on the left by default

spiral glen
#

on unity or my code editor

summer stump
#

Unity

spiral glen
#

it only shows my player object which contains the basicmovement script which is being accessed through the Phone script

verbal dome
#

Worth trying

summer stump
#

Show the inspector of the object

spiral glen
#

am I being dumb or smthin, I really don't see what I'm doing wrong here

verbal dome
#

You should really learn what the windows in the unity editor are called

summer stump
ivory bobcat
#

Google Unity Inspector and show us the inspector

spiral glen
#

mb

verbal dome
#

You should search for t:Phone actually

spiral glen
#

oh

summer stump
#

This does not have Phone on it.
GetComponent only finds components on the SAME object

verbal dome
#

Also movement is private so it doesn't show in the inspector

summer stump
#

Unless you specify the object beforehand

spiral glen
# spiral glen

I'm still confused, what am I doing wrong here?
I used an object reference n' stuff

summer stump
#

As I said, Phone is on a different object

#

So your method is not going to work

polar acorn
# spiral glen

You have an object with the Phone component on it that doesn't have a BasicMovement component on it

verbal dome
#

@summer stump You told them to search for BasicMovement which probably confused them

polar acorn
#

You're setting movement to the BasicMovement component from this object

summer stump
spiral glen
polar acorn
verbal dome
polar acorn
#

if you wanted to get it from a different object you should reference that one

spiral glen
#

oh

ivory bobcat
spiral glen
#

oh ok

latent sedge
#

What is the hotkey called where you want to skip a line without bringing everything in front of your current placement down to that line as well. Example

"He
llo"

verbal dome
polar acorn
rapid storm
verbal dome
# rapid storm

So regenerating project files helped, did you restart Unity and VS after that?

ivory bobcat
#

The object with the Phone component did not properly reference a Basic Movement component and does not have a Basic Movement component thus the Get Component call returned null to be assigned to movement on line 10. Best practice would be to reference from the inspector when possible.

latent sedge
polar acorn
#

press the down arrow

latent sedge
#

The arrow key is so far away from my other fingies though! Theres not a closer hotkey?

rapid storm
latent sedge
#

my pinky cant reach while im typing quickly

polar acorn
#

If you can reach enter you can reach the arrow keys

latent sedge
#

Phooey.

#

Okay thanks!

verbal dome
ivory bobcat
#

But the numpad is further than the arrow keys 😔 - assuming home row.

verbal dome
#

Closer to the right hand though lol

fading mountain
#

quick question, can I have script 1 with public IEnumerator method StartGame() and in script 2 call script 1.StartCoroutine(StartGame())

verbal dome
#

I'm mostly joking here, using that feels horrible

#

I use arrow keys with my right hand, at least

latent sedge
#

I use my my pinky to reach the enter key while my other fingers can type, in order to hit the arrow keys id have to reach over and stop typing in order to reach it!

verbal dome
#

I can't help you further, I don't really even use VS

slender nymph
#

looks like the assembly-csharp project is unloaded, that will need to be right clicked and loaded with dependencies. that should fix all of this

wintry quarry
rapid storm
verbal dome
rapid storm
#

loaded the project with dependencies

#

thanks guys @verbal dome @slender nymph

final kestrel
#

https://hatebin.com/glltpggfdy On line 42 it says index out of range exception. I have my Slots set up in the inventory. I can switch between my slots using my keyboard just fine but it throws the error.

#

I am kind of confused

polar acorn
#

And show what it says

final kestrel
#

It should be of size 4 all the time no? Why is it 0

#

I am following a tutorial btw

final kestrel
final kestrel
polar acorn
verbal dome
final kestrel
#

I do indeed. How did you notice?

verbal dome
#

Well, one log says it has 4 slots and the other says 0

polar acorn
final kestrel
#

Ah okay that fixes it. I copied another project which Ive been working on saving scriptable object data. I must've forgotten to delete that. Thanks a lot.

final kestrel
# polar acorn

I thought i was actually removing stuff from the array

polar acorn
#

they're fixed size on creation

final kestrel
#

Unlike lists right?

#

makes sense all right.

wanton pecan
polar acorn
wanton pecan
#

3 am to be exact

#

It didn't work cuz the ball didn't return

polar acorn
wanton pecan
#

Followed all bits

#

Bad tutorial

wanton pecan
polar acorn
#

They all blame the tutorial

#

I showed you my counter.

#

169 times it has been the user. Five times it has been the tutorial

wanton pecan
#

Tons of ppl said the same in the comments btw

polar acorn
#

And three of those five were the same codemonkey video

wanton pecan
#

Not code monkey

final kestrel
#

wait code monkey bad?

wanton pecan
#

Listen brother not all tutorials work

#

Not my fault

polar acorn
#

I have literally been tracking this statistic for years.

#

I'd love to add more examples of times the tutorial was wrong

#

but at this point, that just doesn't really happen

wanton pecan
polar acorn
wanton pecan
#

All I came on here to do was find out what was wrong with the code

final kestrel
polar acorn
#

So there will just be a cut where the code is different and they never mention the changes

polar acorn
#

You haven't ever done that

#

you've just said the tutorial is bad and never followed up

wanton pecan
#

I said I followed the tutorial and it didn't work and y'all kept going on and on about me not following it

polar acorn
polar acorn
wanton pecan
#

U gotta scroll up on the other channel buddy

polar acorn
#

Oh this?

#

Where you were wrong and the tutorial was right?

summer stump
safe radish
#

somewhat code related and im a beginner, how hard is it to use a compute shader?

polar acorn
wanton pecan
safe radish
#

seems like part of the algorithm im working on will be to heavy for the cpu and saw that compute shaders were perfect for those tasks

verbal dome
polar acorn
wanton pecan
#

I checked all codes 10 times

summer stump
wanton pecan
summer stump
#

No. Do it again

#

Now, so that those that are here can actually see jt

wanton pecan
#

It's 3am not showing that shit again late at night buddy

summer stump
safe radish
wanton pecan
#

Just scroll up

summer stump
summer stump
# wanton pecan Just scroll up

That is a really dumb response.
You can link if you want but I am not scrolling through a ton of posts just to find the one from the person demanding help
When you want help, post the code and the tutorial. Until then, leave

polar acorn
wanton pecan
polar acorn
#

If it's too late to solve the problem then it's definitely too late to bitch about how you can't solve your problem

verbal dome
#

If you ever wrote shaders then it might feel a bit more familiar

safe radish
verbal dome
#

Also knowing C# helps a bit, there's some similiarities

verbal dome
safe radish
#

is there a specific channel for compute shaders if i cant figure something out?

verbal dome
safe radish
#

allright ty

spiral glen
#

isn't this how you make an advance for loop (i : array)?

spiral glen
#

man

wintry quarry
#

that's java foreach syntax

polar acorn
#
spiral glen
#

oh it's more straight forwards

wintry quarry
#

you want either:

foreach (GameObject obj in beanArray)```
or a regular for loop
spiral glen
#

c# is so similar to java except when it decides to be randomly quirky

polar acorn
spiral glen
#

oh

#

quirked up coding language

steep rose
#

i have a step offset for a rigidbody controller i have and it works fine going up the steps, but when i go down my character kinda just floats off, any ideas on how to detect if my character is going down the steps?

wintry quarry
#

it greatly simplifies things

steep rose
#

i know of that and i probably will for some parts of my map but i do need the stair code for other parts

summer stump
#

It's also quite common, even in big games

#

How are you currently detecting going UP steps?

steep rose
#

a raycast is right where the "foot" of my character is and if it detects a step my character goes up it a bit

#

currently only if you are walking forward

eternal needle
frigid quartz
#

Hope this makes sense...
Will a function stored in a variable be called when the variable is passed into another function call?

steep rose
#

theres no slope

spiral glen
#

can someone explain what the maxDistanceDelta means in regards to the Vector2/3.Movetowards?

steep rose
#

i will add the stepping based of movement

#

but for now

#

yeah

polar acorn
polar acorn
frigid quartz
spiral glen
#

oh so like how large the step is towards moving object

polar acorn
frigid quartz
#

void MoveCard(Transform card, Transform toParent) {
card.SetParent(toParent, false);
}

polar acorn
#

These are all just normal variables that hold objects

eternal needle
# steep rose theres no slope

my bad i was thinking of something else, you could also snap the player down but i just wouldnt go for steps at all if it can be avoided as others wrote. This snapping down behaviour would be tedious. On small steps it'd look the exact same to just fake the stairs, on large steps it'd look unnatural

frigid quartz
steep rose
#

wait

eternal falconBOT
steep rose
#

i might have thought of something

#

brb

frigid quartz
polar acorn
frigid quartz
#
    void DealCardsToAllPlayers(int cardsPerPlayer) {
        CountTotalPlayers();

        Transform topCard = deckManager.GetTopCard();
        int startIndex = FindStartingSeatIndex();
        int dealerSeatIndex = FindDealerSeatIndex();
        int targetIndex;      

        //repeats as many times as cardsPerPlayer
        for (int c = 0; c < cardsPerPlayer; c++) {
            targetIndex = startIndex;
            //gives each player a card
            for (int p = 1; p <= totalPlayers; p++) {
                if (targetIndex < totalPlayers - 1) {
                    MoveCard(topCard, players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    targetIndex++;
                } else if (targetIndex == totalPlayers - 1) {
                    MoveCard(topCard, players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    targetIndex = 0;
                } else if (targetIndex == dealerSeatIndex) {
                    MoveCard(topCard, players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    break;
                }                             
            }
        }                       
    }
frigid quartz
polar acorn
frigid quartz
# polar acorn Then you should probably call `GetTopCard` more than once
   void DealCardsToAllPlayers(int cardsPerPlayer) {
        CountTotalPlayers();

        Transform topCard = deckManager.GetTopCard();
        int startIndex = FindStartingSeatIndex();
        int dealerSeatIndex = FindDealerSeatIndex();
        int targetIndex;      

        //repeats as many times as cardsPerPlayer
        for (int c = 0; c < cardsPerPlayer; c++) {
            targetIndex = startIndex;
            //gives each player a card
            for (int p = 1; p <= totalPlayers; p++) {
                if (targetIndex < totalPlayers - 1) {
                    MoveCard(topCard, players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    targetIndex++;
                } else if (targetIndex == totalPlayers - 1) {
                    MoveCard(topCard, players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    targetIndex = 0;
                } else if (targetIndex == dealerSeatIndex) {
                    MoveCard(deckManager.GetTopCard(), players.GetChild(targetIndex).Find("Player").Find("Hand"));
                    break;
                }                             
            }
        }                       
    }
polar acorn
#

Right now you're storing a reference in topCard and using that object for every MoveCard that happens

frigid quartz
#

wrong copy/paste

#

my bad

night raptor
#

Find method 6 times in a double for loop 💀

frigid quartz
frigid quartz
night raptor
polar acorn
# frigid quartz Like so?

Whenever you call GetTopCard() it will return whatever thing that function gets and store it in the variable. It does not matter what you do with that variable afterwards. GetTopCard() is only called when you specifically call it

frigid quartz
frigid quartz
polar acorn
#

A line that's just GetTopCard() would also call the function, even though you don't store the result anywhere

night raptor
frigid quartz
frigid quartz
#

Like eventually I wanna make a full on casino game, but again that's a future dream

limber bear
#

I just started today and i could have gone better. Why does it not find follow the object? Anything wrong with the code or have i doen something wrong in Unity?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hode : MonoBehaviour
{
public Transform Kropp1;
void Update()
{

        Vector3 targetPosition = Kropp1.position + new Vector3(0.0f, 1.0f, 0.0f); 
        transform.position = targetPosition;
    
}

}

rich adder
limber bear
#

Yeah its running. In the console it says that i have to do something with the Inspector.

sharp abyss
#

What does if(collision.collider.gameObject.CompareTag(‘’something’’)) check? Does it check if the tag of my gameobject is something

rich adder
rich adder
#

CompareTag is a function

sharp abyss
#

Ohh with pharanthesis right

rich adder
#

but yeah that check the tag on the object as you can see ^