#💻┃code-beginner

1 messages · Page 731 of 1

sacred cradle
#

if you dont mind i can send some of it

rich adder
sacred cradle
random lodge
#

I wouldn't trust chatgpt with anything but writing stories tbh.

rich adder
#

more like Fido

sacred cradle
random lodge
#

It will point you in the wrong direction though and make bad guesses.

rich adder
#

there is a reason it carries a big stigma

sacred cradle
naive pawn
#

which is the issue - it will make mistakes, and you won't be able to catch them

#

just use reputable sources instead

rich adder
#

its a cyclic problem

sacred cradle
#

its what i am trying to do i hope this will give you the idea of screen

rich adder
#

half my convos with gpt
me: "cannot do x because xyz"
gpt: "Oh yes you're right my mistake.." *proceeds to make a even more sloppy response *

rich adder
sacred cradle
cosmic dagger
#

If you're posting !code, use the provided links . . .

rich adder
#

is this generated? half this doesnt seem to make sense?

rich adder
#

!code

radiant voidBOT
rich adder
#

where do we submit features for this bot?
lol its basic bitch af.. would be nice if we can make it reply a specific person instead of the invoker of command

#

something like !code [user] and send bot reply to them but i guess can be easily abused for spam...double edge sword of development...

rich adder
# sacred cradle yes

yeahh exactly, aint no one wants to fix that.. burn it with Fire 🔥
start fresh with code you wrote and actually understand, i think there are youtubers like SamYam that cover Input touch system

sacred cradle
#

i learned most of my coding first from chatgpt then when it works i learn it also watch some toturials at youtube

sacred cradle
#

guess i am gonna learn alot here

rich adder
#

learning new things should be 70% of your daily routines

cosmic dagger
#

I agree. Samyam has great input tutorials . . .

sacred cradle
#

gotta give a look to samyam

sacred cradle
gleaming turtle
#

is anyone able to help me diagnose why i'm getting a jitter when looking around & moving with my character controller?
i've tried to use a preset asset for a character controller as i don't want to code my own for this small project

rich adder
#

" a preset asset for a character controller" needs to be more specific

#

common issues are usually mismatching between Update loop, Fixed Loop and Camera Loop

ivory bobcat
gleaming turtle
# rich adder yea maybe. If you posted the info, it would probably get you more help

yeah fair enough, didn't want to type a massive thing into the channel and get ignored lol - happnened too many times before

i'm using a preset asset i found in this video - https://www.youtube.com/watch?v=I3CXMP_PoaM

i've made sure that i'm rotating the rigidbody and player separately to the camera

Modular Physics-Based Character Controller
Take your Unity projects to the next level with this fully modular physics-based character controller! Designed for flexibility and realism, this asset offers a dynamic and customizable movement system that integrates seamlessly into any game—whether it's a platformer, action game, or simulation.

Key...

▶ Play video
sacred cradle
#

should i use rigidbody or charactercontroller for player controls?

gleaming turtle
#

I can provide code, screenshots of what's wrong, etc.

this is the code inside the CharacterLook script

    private void Update()
    {
        Vector3 look = Vector3.Scale(inputProvider.Look, sensitivity);
        rotation += look * Time.deltaTime;
        rotation.x = Mathf.Clamp(rotation.x, -89.9f, 89.9f);
        cameraRoot.localRotation = Quaternion.AngleAxis(rotation.x, Vector3.right);
        transform.localRotation = Quaternion.AngleAxis(rotation.y, Vector3.up);
ivory bobcat
#

Usually camera jittering is resolved by using interpolation mode with moving objects

gleaming turtle
rich adder
#

each has pros and cons

gleaming turtle
sacred cradle
#

if my game is more focused on player controls maybe like cod or cs2

primal trench
#

what are some approaches for a weapon system with a lot of weapons with animations

sacred cradle
gleaming turtle
primal trench
rich adder
rich adder
#

& access withvar myAnimation = mySo.GunAnimation

#

ScriptableObjects are similar to regular classes (well they are technically), they should just not reference scene components.. the rest is fair game

primal trench
#

is there an animation class?

rich adder
#

though you typically can grab an entire controller as well

ivory bobcat
# sacred cradle should i use rigidbody or charactercontroller for player controls?

Rigid body physics will be using the Rigid body physics system (more applicable for actual physics where you're rolling a ball or something). Character Controller is a tool for providing basic locomotion and basic collision detection/responses (you'll need to implement some stuff yourself). Rigid body in kinematic mode would give you full physics detection without simulating anything (if you're just needing detection and implementing your own game physics).

primal trench
#

-# god i hate 3D animation
thanks :)

ivory bobcat
gleaming turtle
#

camera is a child of cameraroot which is being rotated. it's first person controller so yes camera is moving.

i'll try changing the cameraroot rotation to lateupdate

rich adder
#

use Cinemachine and half the worries about camera and update loops is slashed in half..

twin pivot
#

Cinemachine == "life";

rich adder
#

best investment unity made, that and textmesh pro.. life changers

#

thats when unity was still making good decisions at the corporate / management levels

cosmic dagger
gleaming turtle
#

okay just looked into cinemachine and turns out the character controller i'm using actually uses cinemachine but didn't mention that part. however, on the prefab i'm seeing this

slender nymph
rich adder
#

Cinemachine 2.x implemented the CM pipeline on a hidden GameObject child of the vcam, named "cm". This has been removed in CM 3.0, and CM pipeline components (such as OrbitalFollow or RotationComposer) are now implemented directly as components on the CinemachineCamera GameObject. You can access them as you would any other components: GetCinemcachineComponent() is no longer necessary, just use GetComponent().

pliant lion
#

what is best way to move character in 3d enviornment

slender nymph
#

there is no "best", it entirely depends on your needs. there are plenty of tutorials for character movement and even plenty of premade assets that do most of the work for you so just find something that suits your needs

pliant lion
#

i would appreciate if you can provide me with some links to website to yt videos to understand

slow blaze
#

hey so I have a parent object
and it has a child with a collider on it
I grabbed the collider with GetComponentinChildren<>()
Now can I call smth like OnTriggerEnter2D with that collider?

keen dew
#

Are you trying to check if that collider is currently overlapping something else?

languid pagoda
#

Anyways to figure out what the engle between a vector3 and an objects forward direction?

slow blaze
#

if that doesn't make sense I'll just make it in the weapon itself

keen dew
#

Why can't you just use OnTriggerEnter

slow blaze
cosmic quail
#

i'd just use Physics.CheckBox tbh

#

it's more accurate than a trigger

keen dew
#

If the weapon has the collider you want to check and the pivot has the code you want to run then have the weapon call a function on the pivot when it registers the hit

devout turret
#

I just started, how do I open a code file lol

radiant voidBOT
cosmic quail
#

i recommend visual studio

cosmic dagger
languid pagoda
#
    /// Returns steering input in [-1,1] to turn the vehicle toward targetWorld.
    /// - fullLockAtAngleDeg: angular error (deg) that maps to |input| = 1
    ///   (usually your car's max steer angle).
    /// - deadzoneDeg: ignore tiny angle jitter.
    /// - useVehicleUp: use vehicle.up for banked roads; otherwise world up.
    float SteerToward(Vector3 targetWorld,
                                    float fullLockAtAngleDeg = 45f,
                                    float deadzoneDeg = 0.1f,
                                    bool useVehicleUp = true)
    {
        

        Vector3 up = useVehicleUp ? transform.up : Vector3.up;

        // Project onto ground plane so slopes don't skew the angle.
        Vector3 fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;
        Vector3 toT = Vector3.ProjectOnPlane(targetWorld - transform.position, up);

        if (toT.sqrMagnitude < 1e-6f || fwd.sqrMagnitude < 1e-6f) return 0f;

        float angDeg = Vector3.SignedAngle(fwd, toT.normalized, up); // + left, - right
        if (Mathf.Abs(angDeg) <= deadzoneDeg) return 0f;

        // Map angle to input. Negate to match your convention: left -> negative.
        float input = -angDeg / Mathf.Max(1e-3f, fullLockAtAngleDeg);
        return Mathf.Clamp(input, -1f, 1f);
    }

anyone see a problem with my logic? the steering just goes back and fourth between -1 and 1 its not really working as intended.

junior basin
#

Hey there, does anyone know why a part of this script is grayed out?

languid pagoda
#

its basically visual studios way to tell you its safe to be deleted

#

but that doesn't really apply for unity

junior basin
#

Ah that makes sense, I getcha

languid pagoda
#

because if you're calling it in start or awake it might still be grayed out

hallow acorn
#

hey im just learning stateMachines and got my state machine working mostly. i got an attack state which i dont know how to implement. because attacking should be possible while walking so how would i transition to the state?

#

am i supposed to make a second state machine for cases like attacking or using spells etc?

naive pawn
sage wyvern
#

I need help, anybody got a video on soulslike movement?

naive pawn
cosmic quail
languid pagoda
sage wyvern
#

they are all videos on how they make it

#

not on how i can make it

naive pawn
cosmic quail
languid pagoda
naive pawn
#

that should handle unity messages just fine. are they not showing up in blue?

sage wyvern
cosmic quail
cosmic quail
sage wyvern
cosmic dagger
sage wyvern
#

anybody maybe just got tips on soulslike movement?

#

like what should i definitly add

#

and what can i choose

rich adder
#

part 151 lord.

sage wyvern
#

luckily it's only bout the movement

cosmic dagger
sage wyvern
polar acorn
cosmic dagger
cosmic quail
cosmic dagger
polar acorn
slow blaze
#

hey guys I have a question
I have a weapon that's supposed to be always invisble (sheathed) until I press some input to do the attack sequence and actually show the weapn and stuff, how can I do that?
I want to disable the spriteRenderer and collider components as a way to do that, are there other options? would it be better to disable the object and awaken it from another object?

ivory bobcat
#

Lookup Unity tutorials on Animator states

slow blaze
#

I'm not using an animator

ivory bobcat
#

I've got to go but for better support maybe you should provide further context otherwise it's pretty open ended.

cosmic quail
slow blaze
#
 private IEnumerator PhaseThreeAttack(Vector3 minimumScale, Vector3 maximumScale,float scaleRate)
    {
        hasAttacked = true;
        float originalScaleRate = scaleRate;
        Vector3 originalScale = transform.localScale;
        Vector3 newScale = originalScale;
        while(newScale.x < maximumScale.x)
        {
            newScale = Vector3.Lerp(minimumScale, maximumScale, scaleRate);
            scaleRate += Time.deltaTime;
            transform.localScale = newScale;
            yield return null;
        }
        yield return new WaitForSeconds(0.1f);
        
        scaleRate = originalScaleRate;
        while (newScale.x > minimumScale.x)
        {
            newScale = Vector3.Lerp(maximumScale, minimumScale, scaleRate);
            scaleRate +=Time.deltaTime;
            transform.localScale = newScale;
            yield return null;
        }
        
        yield return new WaitForSeconds(0.3f);
        this.gameObject.SetActive(false);
        hasAttacked = false;
    }```
this is basically the attack code

```C#
 if (Input.GetMouseButtonDown(1))
        {
            if(!hasAttacked)
            {
                
                Vector3 objectScale = transform.localScale;
                Vector3 targetScale = new Vector3(1.6f, 0.5f, 1);
                float scaleRate = 0.8f;
                StartCoroutine(PhaseThreeAttack(objectScale,targetScale, scaleRate));
            }```

this is it's call

I want to disable and enable the object on right mouse click like so but disabling the object makes this script disabled too thus it is not awakened again.
slow blaze
cosmic quail
slow blaze
#

so I will just attack the script to another gameObject that won't get disabled I guess, though I will try disabling the rendeder and collider first.

rugged beacon
#

is there a equivalent to Resources.LoadAll<Sprite> but without requiring to create a resource folder?

rich adder
#

addressables most likely

rugged beacon
#

i tried it and it created another addresable folder

#
#if UNITY_EDITOR
    [Button]
    public void FetchSprites()
    {
        // Sprites = Resources.LoadAll<Sprite>("Skewer");
    }
#endif

this is what i try to do

rich adder
#

should prob just explain usecase

rugged beacon
#

i want the sprite thingys remain in its graphic sprites folder

rich adder
#

Doesnt addressable let you do that you just link it to a Group ?

#

without needing dedicated folder

#

you technically can use File.IO too but idk just seems dirty

rugged beacon
#

no idea, havent use it before but when i tick the addressable box in the inspector, it said need to be move to addressable folder

#

usually i just shift hold multiple objects and drag to inspector but this package completely change the inspector list and doesnt allow drag multiple anymore

rich adder
# rugged beacon no idea, havent use it before but when i tick the addressable box in the inspect...

i recalled you can fine..

Enable the Addressable checkbox in the Inspector window for either the asset itself or for its parent folder.
only if it lived in Resources
If you make an asset in a Resources folder Addressable, Unity moves the asset out of the Resources folder. You can move the asset to a different folder in your Project, but you cannot store Addressable assets in a Resources folder.
https://docs.unity3d.com/Packages/com.unity.addressables@2.7/manual/get-started-make-addressable.html

#

but this seems overkil , you should be able to just drag and drop them if its not a special usecase

rugged beacon
#

like i can just select these and drag, in a serializefield array

#

not anymore

rich adder
rugged beacon
#

his package completely change the inspector list and doesnt allow drag multiple anymore

#

even odin

rich adder
#

whos package ? what?

rugged beacon
#

currently tri inspector, but im looking at a odin inspector project also

#

cant drag them anymore

rich adder
#

if it doesn't support multi-selected item drop in...that would be pretty trash..

rugged beacon
#

dang i heard odin is very standard

rich adder
#

ehh depends on the uses

rugged beacon
#

but i will look into addresabble

rich adder
#

thats still probably not a good usecase here.. you should probably get a good working inspector

#

are whatever attributes they have even worth breaking the workflow?

rugged beacon
#

should probably get a good working inspector
wym

#

mean i should rip these package out ?

rich adder
#

I dont understand whats wrong with just using the regular inspector? is there something specific you want

#

half the time I'm not even looking at the inspector lol

rugged beacon
#

considering it, this package allow me to easier use serializeReference and modify the list view less cluster, i dont have very deep knowledge into drawer

rich adder
#

idk is having that worth breaking the array drag n drop feature?

#

Maybe something you need to enable or something? I find it puzzling that a Unity asset would break such a needed feature

#

using inspector is the way to go anyway, using Resources / Addressables is overkill here esp to skirt around an asset breaking something

rugged beacon
#

i only need to fetch once in editor so should be fine

next idol
#

where should i learn how to script (i wanna do mostly vr and gorilla tag fan gtame game type of games)

rocky canyon
#

doesn't matter what genre' ur scripting or what "input" you use.. coding is coding..

#

!learn

radiant voidBOT
old karma
#

ok i feel like im missing something obvious.
so i have a game object that on it's root is made to look at the camera via transform.lookat.
meanwhile im trying to rotate the sprite renderer within it by the z axis.

however when i set it in script, my results gets weird, sometimes giving me the mirrored direction of where i wanted it pointed towards.
how do i sort this out, cause i feel like im missing something obvious

#

on the root is simply a script that runs the look at to point at the camera.
cs transform.LookAt(cam.transform.position);

in the sprite child, even though i wanted to only rotate the z axis to allow the root to handle the rest, it doesn't go that way.

the closest i got was this. this aims in the correct direction for me, but for some reason it ignores the rotation on it's parent script. and just goes flat when i rotate around it.
cs transform.rotation = Quaternion.Euler(0,0,angle)

#

so... yeah

rain solar
#

how do i program physics simulated clay

rocky canyon
#

metaballs

#

softbodies

frosty hound
#

Sure, you can freely change the sprite on the SpriteRenderer component in code.

old karma
sand field
#

Feel like I am going crazy, why is the game saying the playerTarget Transform is itself (En_SculptedDemon) instead of the correct game object assigned in the GUI (Player)

using UnityEngine;

public class EnemyChase : MonoBehaviour
{
    public Transform playerTarget;
    private CharacterController enemyController;

    public float moveSpeed = 20f;
    private Vector3 direction;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        playerTarget = GetComponent<Transform>();
        enemyController = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        MoveEnemyTowardsPlayer();
    }

    private void MoveEnemyTowardsPlayer()
    {
        direction = (playerTarget.position - transform.position).normalized;
        Debug.Log("playerTarget.position" + playerTarget.position + playerTarget.name);
        enemyController.Move(direction * moveSpeed * Time.deltaTime);
        Debug.Log("transform.position" + transform.position);
    }
}
random lodge
#

So instead of modifying a variable from another script, it's better to call a function, right? Is there a time when it's "good practice" to modify a public variable from another script?

slender nymph
#

really just when you need to. but typically you would use properties rather than public fields. properties also get rid of the need for manual get/set methods that some other languages recommend

random lodge
#

So just do it if you need to but "try not to if you can help it" I guess.

abstract copper
#

https://pastebin.com/yAaybB58
Any reason as to why my enemies stop spawning after like 5 spawn? something around that. I made sure to check if game state is being set to over but its not its always playing.

frosty hound
#

Yeah, you can manually call and play an animation state by name.

willow iron
#

lists are the version of arrays that can be expanded during runtime right?

rocky canyon
#

Lists are closely related to arrays, collecting multiple values of the same type in a single variable. They are much easier to deal with when it comes to adding, removing, and updating elements, but their elements aren’t stored sequentially. This can sometimes lead to a higher performance cost over arrays.
yessir

potent hornet
#

Does anyone have any tips on reducing lag that OpenCV does when reading hand inputs. I did a project where I could read hand inputs outside of Unity with python and I don't remember that lagging at all. But with Unity using OpenCV whenever the camera comes on sometimes there's lag spikes.

#

I'm wondering if there's any tips or code I can remove to help reduce it

cosmic dagger
rocky canyon
#

^ chatgpt likes to do that alot.. (it'll give u a public or serialized field to assign in the inspector) but it'll also add a GetComponent in the Start() or Awake() for whatever reason it decides to do that

cosmic dagger
# random lodge So instead of modifying a variable from another script, it's better to call a fu...

No, accessing an internal field from another script is never good practice. It's called encapsulation. Use a property or a method to change the field

This helps if you need to check/set limits, send an event, etc. Directly assigning its value from an outside script bypasses that

When you use dot notation, the members that appear indicate what you're allowed to control, hiding unnecessary or internal data that the class is responsible for maintaining . . .

cosmic dagger
cosmic dagger
random lodge
#

So if I want to for example -1 HP from an enemy from another script just add TookDamage() in the script and call that from the other script? That's the right way? Maybe not the best example but just as an example.

cosmic dagger
random lodge
#

gotcha, thanks 🙂

proper trench
#

Hey everyone, has anyone seen a good guide / course on how to use Unity Debugger / Profiler tools? Would appreciate any recommendations!

rocky canyon
#

can't say whats the best as i kinda learned debugging along the way.. but can't beat starting at Unity itself

proper trench
cosmic dagger
rocky canyon
#

"Redundancy" it says

torpid jetty
#

Has Unity stated what version of C# they're potentially upgrading to once they get around to upgrading the scripting system to .NET Core?

slender nymph
#

it is supposed to be whatever is the latest release at the time

torpid jetty
#

I see, thanks

rain solar
#

how do i program physics simulated clay

teal viper
mighty peak
#

anyone know whats happend now?

#

its was working fine before 20sec

#

and cleancode doesnt solve it

rich adder
mighty peak
rich adder
mighty peak
#

also i didnt find button field in unity

mighty peak
rich adder
mighty peak
#

just there is 1 image

rich adder
#

the quantity of the fields have nothing to do with the error

mighty peak
#

just have1

rich adder
mighty peak
#

since 1 years

#

before yes

#

some errors which i get at this time

rich adder
#

nowhere did I mention c#. I'm talking about the link I just sent

rich adder
#

great..so .. did you not click it and maybe informing yourself about the error instead of making it up why it error

sour fulcrum
#

c# is chsarp

rich adder
# mighty peak just have1

the error has nothing to do with how many Button references you have...
UnityEngine.UI & UnityEngine.UIElements namespaces both Have Image and Button. The compiler has no idea which ones you are trying to reference from

mighty peak
#

thats why im asking

rich adder
mighty peak
#

i thougt you talking about the variable not imports

#

yes its solved

rich adder
#

I specifically said namespaces multiple times and the link of error sent mentions them, nowhere is variables mentioned

mighty peak
#

Anyway there's no errors now should i find button Field now?

rich adder
rich adder
mighty peak
rich adder
mighty peak
#

send code?

rich adder
mighty peak
#
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UIElements;

public class player : MonoBehaviour
{
    public Rigidbody2D rb;
    public Image leftbtn;
    Vector2 xdirection;
    public Button leftb;
    public Button rightb;

    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Button"))
        {

            Debug.Log("left");
            transform.Translate(Vector2.left * 0.5f);
        }

        /*
        xdirection = new Vector2(Input.GetAxisRaw("Horizontal"), 0);
        rb.velocity = xdirection * 600 * Time.deltaTime;
 */
    }
}


rich adder
naive pawn
#

why do you have UnityEditor.UI included

rich adder
#

also thats another issue ^

#

probably half those namespaces don't need to be there

mighty peak
naive pawn
#

you chose to import this one from autocomplete

#

it's most likely not what you want

rich adder
#

you gotta pay attention to those things

#

some namespaces like that one left unchecked from UnityEditor would prevent you to build any executables..

mighty peak
naive pawn
#

it's now costing you time because it's writing bullshit and you don't know how to fix it

mighty peak
naive pawn
#

genAI are power tools. if you don't know how to use them properly you'll end up injuring yourself

mighty peak
rich adder
naive pawn
mighty peak
naive pawn
#

just stay away from genAI until you get the experience. it'll be hurting more than helping.

rich adder
# mighty peak which?

two are grayed out in the IDE. the third is the UI Toolkit one that had Image/Button in it

naive pawn
#

the ones that are grayed out and the extra one that nav mentioned

mighty peak
naive pawn
#

for both that are unused - you'll end up with suggestions from these namespaces, which will be noise for the actual types you want.
for the UnityEditor one - just including it without conditionals will make it fail builds.
for the UIElements one - you are using the wrong namespace so you're getting the wrong type.

mighty peak
#

i will try something :/

naive pawn
#

!collab

radiant voidBOT
# naive pawn !collab

: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**

pallid osprey
naive pawn
#

see the bot message

mighty peak
naive pawn
#

you would use callbacks for that

#

perhaps check out the UI guides

naive pawn
#

the onclick event is accessible through code

#

not everything is going to be spoonfed to you

mighty peak
naive pawn
#

so go research how to do that then

mighty peak
modest harness
#

I'm making a camera drag functionality, like if you were dragging a map
and i went crazy to figure out why it was not moving 1:1
it turns out this was happening because of "Scale"
and it looks like this part of unity editor has no api?

So my questions are: is this how game window is scaled in engine too (like if you shrink/expand the window) or is this purely editor future? should i be worried about Unity Input system Drag [Delta] breaking if the window size changes in compiled game?

eager spindle
mighty peak
#

Just do script for every button with pointer

#

And i need to make it in same player script so

cunning bramble
#

Hi it is hard for me to explain this :) but it try

So what i need is an tutorial or someyone that could help me i want an item pickup code / system so when i am near to an object that i can press E or what ever and it gets picked up and i can drag it around any good tutorials because i dont finde an single one that works :(
pls ping me

frail hawk
#

i found maany

frail hawk
cunning bramble
#

yes but none of them works

frail hawk
#

show code

cunning bramble
#

!code

radiant voidBOT
cunning bramble
#

i am afk for 15min just ping me :)

frail hawk
#

oh boi seems like you found that code somewhere and want us to clean it up for you.

cunning bramble
#

nope

#

so i watched this tutorial

#

and he said you can get the code from the discribion

grand snow
#

so yes you want us to fix some random tutorial code 😆
Its clear this beginner code anyway from how its written

cunning bramble
#

i am beginner

#

or what do you mean by the last sentence

#

Okay i am looking for an new video

fallen hound
#

Hey if i learn this video is it possible that i will be able to code in unity?
https://www.youtube.com/watch?v=GhQdlIFylQ8

This course will give you a full introduction into all of the core concepts in C# (aka C Sharp). Follow along with the course and you'll be a C# programmer in no time!

❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp

⭐️ Content...

▶ Play video
grand snow
#

This tries to use physics but also moves the object without physics so kinda shit

cunning bramble
#

so do you know schedule1 @grand snow

#

I want the pysics from the game

#

because it is made funny

grand snow
#

A better way is to use force/change velocity to move the object towards the "hold position"

#

I dont sorry

frail hawk
fallen hound
cunning bramble
#
frail hawk
#

it is ok for now other than that you can check the pinned messages on this channel to learn more c# basics

grand snow
#

I check this video briefly and it shows how to move the object with physics which I think is better
https://www.youtube.com/watch?v=6bFCQqabfzo

Lets learn how to pickup and drop objects in Unity. Objects with a Rigidbody component attached can be manipulated like the portal style physics game mechanics. The system can easily be modified to only pick up objects with a certain tag or adjust the speed at which objects are moved. Written in C# and all the content can be found on my Patreon ...

▶ Play video
cunning bramble
#

Okay i wrote it but i have some errors but i dont find them

#

@grand snow

#

!code

radiant voidBOT
grand snow
#

Why ping me im not a personal helper

cunning bramble
#

Okay sorry

#

I am sorry it will not happen again :)

north kiln
#

I'm not sure what you want from anyone

#

What do you mean you can't find the errors? What are they?

sour fulcrum
#

(that code doesn't compile btw)

north kiln
#

If you're not having errors underlined in red, and lack proper autocomplete you need to configure your IDE

#

!ide

radiant voidBOT
frail hawk
frail hawk
#

you won´t get far with copy pastin code

cunning bramble
# north kiln If you're not having errors underlined in red, and lack proper autocomplete you ...

Okay i am setting it up :)
Good idea and my errors are wierd
ERRORS:

Assets\PickUpCOntrooller.cs(23,48): error CS1061: 'Transform' does not contain a definition for 'gameobject' and no accessible extension method 'gameobject' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)

Assets\PickUpCOntrooller.cs(21,47): error CS1061: 'Transform' does not contain a definition for 'postion' and no accessible extension method 'postion' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)

north kiln
#

Configure your IDE

cunning bramble
cunning bramble
#

Urm i have IDEA Intellji

north kiln
#

That is not a C# IDE

cunning bramble
#

yea

#

:(

north kiln
#

!ide

radiant voidBOT
cunning bramble
#

Wich is in your oppinion the best one? @north kiln

north kiln
#

Rider

cunning bramble
#

Okay got the VS CODE

north kiln
#

Why ask if you're just going to ignore the suggestion lol

cunning bramble
#

Because i have never heard of that and i meant from the list xD

north kiln
#

Read the list

cunning bramble
#

Uh atwhatcost

#

I see now

#

xD

#

Sorry but where do i get it from xD

silver fern
#

click on it

cunning bramble
#

oh i have bad wifi so it takes 30 min notlikethis

silver fern
polar dust
mighty peak
#

hi if someone know how can I make specific ui button get down and up in same script please told me because I'm tiered from searching:)

cunning bramble
#

Okay i have it but the script dosent work :((

quasi dawn
silver fern
cunning bramble
#

I am writing it new so give me 5 min

mighty peak
#

Not one click

naive pawn
#

for input? sounds like you'd want onscreen controls for that

civic pebble
#

hey guys, anyone got any experience with Cinemachine transitions? I got them to work already but right now it seems to memorize where the camera was before and always transitions back to that state, and I would like it to reset behind the player/vehicle so the transition is always consistant.

cunning bramble
#

Guys this might be an DUMB Question but what did i wrong in this part

**ERROR: **
Invalid expression term ")" Line 21

**CODE: **
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, pickupRange,))

rocky canyon
#

u have a , at the end

cunning bramble
#

ahhh xD

#

Thanks didnt saw that

#

now i test it out

#

Urm okay so in unity i see that i have spelling errors like Tranform instad of Transform but my Editor didnt catch that is there anyway to add that?

rocky canyon
#

!ide yea ur ide shoulda underlined the extra ,

radiant voidBOT
cunning bramble
#

Haha i love my English

cunning bramble
naive pawn
cunning bramble
#

Sorry again but

cunning bramble
cunning bramble
naive pawn
cunning bramble
naive pawn
#

it's probably gonna be one of these

cunning bramble
#

Got it i guesss

naive pawn
#

nope, wrong one

#

it's the one below that

cunning bramble
#

Yes the lower one

#

i have it now

#

Still no chatch

#

catch

naive pawn
#

there are several other steps

cunning bramble
#

yes i have these extensions in Studio

#

uhhrrmm okay nah i just leave it like this unity is catching so it shouldnt be an problem :)

naive pawn
cunning bramble
naive pawn
#

have you installed .net

cunning bramble
#

BOMMBOO CLLLATTT your right i need to bc i miss spelled 13 times atwhatcost

#

Looks like it does

naive pawn
#

you've installed the .net install tool

#

that doesn't mean you've actually installed .net

cunning bramble
#

this?

naive pawn
#

no, .net itself isn't a vscode extension

#

open the command palette and install .net system wide

cunning bramble
#

I am sorry but where it the palette?

#

Hi there i have this tutorial and this code but it looks like it doesent work any ideas or is the tutorial just not good?

https://www.youtube.com/watch?v=6bFCQqabfzo&ab_channel=SpeedTutor

Lets learn how to pickup and drop objects in Unity. Objects with a Rigidbody component attached can be manipulated like the portal style physics game mechanics. The system can easily be modified to only pick up objects with a certain tag or adjust the speed at which objects are moved. Written in C# and all the content can be found on my Patreon ...

▶ Play video
#

!code

radiant voidBOT
cunning bramble
#

am i doing something wrong i mean everyone is gone :(

west sonnet
cunning bramble
west sonnet
#

How can I copy & paste an object position in Word Scale? Whenever I try it does it in local scale and I can't figure out how to change it

#

via the inspector

cunning bramble
#

ah true i also have an question but i dont know how to exlpain it so sometimes 0x 0z 0y is like center of map but then other times it is like an diffrent point why?

slow blaze
#

how can I prevent an object from rotating with its parent?

#

how do I make it so it doesnt rotate with it

cunning bramble
#

hi i have an problem i want the object to follow the camera complettly so when i go up the item goes up also but it doesent

#

!code

radiant voidBOT
cunning bramble
slow blaze
eternal needle
slow blaze
#

so not making it a child object ruins some other stuff

#

gueses I'll work around that and make it follow the player with a script

shell sorrel
#

If it only needs to follow position not rotation just use a component to set its position to the other objects position

slow blaze
#

yeah I will do that

#

btw why does the 2d camera sometimes not show the contents?

#

it's follolwing the player with a component with a little bit of offset in the x (player.x - 10) but I can't see anything in game

red igloo
#

Stop ❌ cross posting keep it in one channel.

limber turtle
#

how do i stop the coin (small circle) from interacting with the platforms in any way? i tried changing the collision layers so the coin excludes platforms and the platform excludes coins but this still happens

#

coin's collider

#

platform's effector

#

i should be using the collider mask, right? i think it was on by default

limber turtle
keen dew
#

Go to project settings -> Physics 2D -> Layer Collision Matrix and disable the coin/platform collision there

limber turtle
#

the platform effector says it's not using the global layer collision matrix

#

i'll give it a try though

#

alright, i had to disable the platform effector's collision mask

slow blaze
#

my camera is following the player with a -60 offset

#

for no reason lmao there's no script tht does that

limber turtle
#

are you using cinemachine? that could be one of the default settings

rain solar
cunning bramble
#

Hi guys can you rate my physics?

#

i think they are funny

zealous talon
#

hello guys: i wanted to make the scene of my game a little more "dark" so i downloaded another skybox and messed up with the lightigs, don't really know how does it work so i think i messed up a little bit. at the moment i put againt the default skybox on lighting > environment and set the directional light at its standard parameters, what should i do to reset the lightings setting at its default? at one point i think i misclicked on "generate lightings" but i m not really sure about what have i done.

dawn iron
slow blaze
#

does Physics.CheckBox() return the collider it interacted with?

#

@zealous talon holy shit hi

zealous talon
#

omg

slow blaze
#

I'll create a new collider to interact with then it's supposed to be an AOE kind of thing

slow blaze
#

oh overlap box

zealous talon
#

i want to put a field of grass instead of the water, any tips of how can i do that?

rocky canyon
#

a terrain w/ grass brush as default ¯_(ツ)_/¯

zealous talon
#

could it be performative inefficient?

rocky canyon
#

terrains are prettty optimized..
if u were worried about that you could just use the Default Plane and a tileable texture

winged ridge
slow blaze
naive pawn
#

not directly through the OverlapBox call, you'd have to have something to actually render the box

slow blaze
#

so I'd have to add a Rendeder to the object attached to the call's script?

zealous talon
rocky canyon
#

check out the asset store they have lots of free materials/textures

slate heath
#

Hey guys so i'm trying to use a material and uvs to set a texture but for some reason I think it every mesh:

#

(every material)

#

I don't know why this is happening, could someone help me?

grand snow
rocky canyon
#

just looks like a really really dense texture tiling

slate heath
#

i forgot to do / tileSize

#

mb guys

rocky canyon
#

all textures look like that when they're scaled too far down

#

get that fractal look

slate heath
#

now I just have more bugs 👍

rocky canyon
#

heck ya.. sounds like a party 🍻

slow blaze
#

Is there a default Circle texture/sprite in unity?

slate heath
#

well, it kinda works now xD

rocky canyon
molten vortex
#

Hey I am trying to create a Sim-style camera system that rotate the camera around the focal point. Currently I have the focal point face the cameras to keep the relative axises the same. However, in some positions, the camera rotation Up/down either inverts or just stops and I do not know how to fix this.

rocky canyon
molten vortex
#

I was gonna try to figure that out after it actually moved corretly

#

Im guessing the rotateAround method isnt the way to go

rocky canyon
#

i'd work that out now and see if the issue still persists afterwards

keen dew
rocky canyon
#

not sure its sim enough.. but it helped me out

molten vortex
# keen dew You'll have to show the code if you want someone to suggest fixes
using System;
using UnityEngine;
using UnityEngine.InputSystem;

public class cameraController : MonoBehaviour
{
    public float rotationSpeed = 10.0f;
    public GameObject focalPoint;
    
    private InputAction _lookAction;
    private InputAction _enableLook;
    private float _distance = 10f;
    
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        _lookAction = InputSystem.actions.FindAction("Look");
        _enableLook = InputSystem.actions.FindAction("EnableLook");
    }

    // Update is called once per frame
    void Update()
    {
        if (_enableLook != null && _enableLook.IsPressed())
        {
            Vector2 lookDelta = _lookAction.ReadValue<Vector2>();
            
            // translate UP/Down
            //if ((25 <= transform.rotation.eulerAngles.x || lookDelta.y < 0) && (75 >= transform.rotation.eulerAngles.x ||  lookDelta.y > 0))
            //{
            transform.RotateAround(focalPoint.transform.position, Vector3.right, rotationSpeed * Time.deltaTime * lookDelta.y);
            //}
            
            // Translate left/right
            transform.RotateAround(focalPoint.transform.position, Vector3.up, Time.deltaTime * rotationSpeed * lookDelta.x);
            
            // look at it
            transform.LookAt(focalPoint.transform.position);
            focalPoint.transform.LookAt(transform.position);
            
        }

    }
}
keen dew
#

If this is mouse look, don't multiply by deltatime. But that's a separate issue

#

Vector3.right is in world space, you need to rotate around focalPoint.right

molten vortex
#

ahhh

keen dew
#

focalPoint.transform.right I mean

#

Actually probably transform.right if the focal point doesn't rotate along with the camera

hard tapir
#

Hello, Im new to c# and I have a triangle In my scene (2d) that I want to duplicate once it hits a cube named dupicate (already assigned rigitbody and colliders). I was told to use the Instantiate command but all of the tutorials I found were for 3d and for creating objects from ur assets which im not. this script is under the triangle object, if you could link some good tutorials for this itll be great!

keen dew
#

It's still Instantiate even if it's 2d and the object is in the scene

hard tapir
#

oh, well thank you

rocky canyon
#

^ and u use a reference regardless if its a prefab in ur assets or from the scene..
u get a reference to it and stick it in the instantiation method

    public GameObject triangleReference;

    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject hitObject = collision.gameObject;

        // Duplicate the object that hit us
        Instantiate(hitObject, hitObject.transform.position, hitObject.transform.rotation);

        // Duplicate this GameObject (the one with this script)
        Instantiate(gameObject, transform.position, transform.rotation);

        // Duplicate the reference at the current position and rotation
        Instantiate(triangleReference, transform.position, transform.rotation);
    }```
hard tapir
#

Thank you!

thorn kiln
#

So, I've been given a script to fix as an exercise. I can kinda get it working if I make the list public instead of private, but I don't get why that matters?

slow blaze
#

I don't see how making the List public helps

thorn kiln
#
    // Update is called once per frame
    void Update()
    {
        TimeToNextText += Time.deltaTime;
        Debug.Log(TimeToNextText);

        if (TimeToNextText > 1.5f)
        {
            TimeToNextText = 0.0f;

            CurrentText++;
            if (CurrentText >= TextToDisplay.Count)
            {
                Text.text = TextToDisplay[CurrentText];
                CurrentText = 0;
            }
        }
    }
#

There's the update section too

#

And thats all of it

naive pawn
#

hint: the issue is there, not in your previous screenshot

slow blaze
#

yeah the script has issues, the list being public or private is not one of them

thorn kiln
#

Weird that changing that makes a difference then

naive pawn
#

it makes the list serialized, which doesn't seem to be the intent of the script unless you have more instructions that say otherwise

#

ah, nvm, i see the issue now.

#

yeah ok there is indeed an issue with the first screenshot, and making it public does fix it, but it is most likely not the intended fix.

slow blaze
#

Oh what issue is that cuz I don't see it

slender nymph
#

||making the list serialized tells unity to create an instance for the list. it is not initialized otherwise||

slow blaze
#

Oh lmao I didn't know that

slender nymph
#

it should be fairly obvious by the runtime exception thrown though

thorn kiln
#

I get errors on line 25 and 44, which is TextToDisplay.Add("Congratulation"); and if (CurrentText >= TextToDisplay.Count), which isn't super helpful if the issue is with .Add(), because the course hasn't taught that

naive pawn
#

did you read what the error said?

slow blaze
#

What's the error?

slender nymph
#

NRE

thorn kiln
#

Yes, one of the erros I don't understand.
"NullReferenceException: Object reference not set to an instance of an object"

naive pawn
#

if you're getting the same error on 2 lines where one has Add and the other doesn't, then it's probably not an issue with the Add think

slender nymph
naive pawn
thorn kiln
#

Vaguely. Don't understand Instance.

naive pawn
#

an instance of a type means some existing object of that type, something you might get from construction

thorn kiln
#

Yeah, it's just jargon to me

naive pawn
#

...yes, that's what jargon is

thorn kiln
#

I might know what you're saying if I saw it, but the words don't translate

naive pawn
#

0 is an instance of int, 0.0 is an instance of double
from a monobehaviour, gameObject is an instance of GameObject, transform is an instance of Transform, transform.position is an instance of Vector3

naive pawn
thorn kiln
#

Not really, no

slender nymph
#

try answering that question and it might actually help

thorn kiln
#

If I knew the answer I'd know the answer

slender nymph
#

you know how to read, right?

thorn kiln
#

Your condescension is very helpful

slender nymph
#

well all i'm asking right now is for you to literally read the exception and provide the first word. this is not anything technical in any way, it's just reading

thorn kiln
#

"Null"

slender nymph
#

and do you know what null means

thorn kiln
#

Nothing

slender nymph
#

and you're saying that does not give any hint as to what the issue might be?

#

here's a hint: ||it's null||

thorn kiln
#

It gives me a hint that I'm not connecting to an answer, do you get that?

naive pawn
#

buddy if you don't know (if our leading questions aren't effective) then just say so

#

we do not need to play this game of sass

slender nymph
thorn kiln
#

Okay, we've got to the point of "you're bad at this, just don't do it", so I'll just figure it out myself

naive pawn
#

also, have you tried googling "nullreferenceexception"

slender nymph
proper bobcat
# thorn kiln _Vaguely_. Don't understand Instance.

So lets imagine we write a script that is of type Enemy. So if you created a new enemy from that blueprint, that would be an instance. An instance is a single concrete thing versus the class which is just a blueprint for how the individual instances should be and act.

naive pawn
slender nymph
thorn kiln
#

Well asking you isn't gonna get me anywhere either then in that case, so why should I care?

naive pawn
#

you aren't gonna learn ever if you only expect spoonfeeds

#

figuring stuff out is what learning is

slender nymph
#

hell, i even outright stated exactly what the issue is as my first message in this issue

naive pawn
#

more than i was willing to say, even 😆

thorn kiln
#

Yeah, foolish of me to come to the #💻┃code-beginner channel and expect anything besides people smarter than me to be condescending that I'm not as smart as them

naive pawn
#

no-one is saying that

#

we come to this channel with the expectation - the knowledge, even - that the people here will be very unexperienced and know relatively little

what we're asking from you is effort

#

and also to be less defensive, that would also help

thorn kiln
#

Here's the thing, I get it, you're all so much smarter than me at Unity and C#, but that's clearly given you egos that refuse to let you accept that the way you're trying to explain things isn't working for me, and rather than change, you just get angry at me for not learning the way you're instructing me to

naive pawn
#

no-one is angry here

sacred cradle
#

hi how do i get the objects behind the stencil shader object to not be rendered? Also how could i get everything outside the stencil layer to not be rendered in the little window?:

Shader "Examples/Stencil"
{
    Properties
    {
        [IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 0
    }
    SubShader
    {
        Tags 
        { 
            "RenderType" = "Opaque"
            "Queue" = "Geometry"
            "RenderPipeline" = "UniversalPipeline"
        }

        Pass
        {
            Blend Zero One
            ZWrite Off

            Stencil
            {
                Ref [_StencilID]
                Comp Always
                Pass Replace
                Fail Keep
            }
        }
    }
}
naive pawn
#

again - please stop the overly defensive behaviour

#

i even said before - if our explanations don't work, say so instead of being passive aggressive

slender nymph
thorn kiln
#

I try, but you guys don't understand that I don't know how to explain what I don't know, and it just makes you get more condescending with each message

naive pawn
#

there was no condesension here, just further probing questions

fickle plume
naive pawn
thorn kiln
#

If you don't see the condesension, then you're either blind, or you're just too smart to see how different these things come off to someone who doesn't know everything you know

naive pawn
#

no, there just.. wasn't any. there were some that perhaps could be read as such, but i assure you, no-one was being intentionally condescending

hard tapir
#

Does any1 know how to limit the speed of a 2d rigitbody object?

thorn kiln
#

I don't know how "you know how to read, right?" isn't condescending

fickle plume
naive pawn
thorn kiln
slender nymph
fickle plume
hard tapir
naive pawn
fickle plume
#

Understanding what reference and instance is the first thing you engage with.

thorn kiln
fickle plume
random lodge
#

So I've never used AI until a few days ago and I'll have to say. It can actually offer you valid suggestions to improve what you have if you use it right. For example I wasn't sure how to use ! in a line of If code with a lot of conditions and it showed me that I could use extra () around the conditions and place the ! before that to make it work. So I learned something there.

naive pawn
#

"if you use it right" is a deceptively high bar

#

if you're a beginner, you will not have the capacity to use it right, tbh.

fickle plume
#

How to cheat yourself from engaging with meaningful learning material. And be content with LLM spitting out small titbits at you, that you will be so excited to find another part of that bit in another random answer. Instead of learning the whole thing from the source at once.

pliant lion
#

i want to implement sword attack in my game so should i attack collider to sword and also should i make sword child of my hand for sword to follow animation

random lodge
#

smh.

sour fulcrum
#

I think you underestimate how many people learn really awful habits and outright lies instead of actually learning

#

like there's tons of people who directly come in this server as a result of it

naive pawn
pliant lion
naive pawn
#

there's no best, period

#

what you suggested could work though

#

you could go with that, or if you think there's a better way, try searching around

random lodge
#

What other people do isn't my concern. I spent some time on Google looking on better ways to use If/conditions and didn't find the formatting I was specifically looking for to do it correctly. Another avenue worked and now I can use that knowledge to know how to and write conditions in other ways and much shorter. But drops it. Whatever. I'm dumb and none of us can use tools adequately.

proper bobcat
#

A couple of different ways of doing melee swings -

  1. Don't use colliders at all. You could just distance check and then do some calculations if you need to at the end of an animation. (Akin to runescape, dungeons and dragons, where its more about stats than physical collisions)
  2. Use a box collider in front of you. Then do some checks at the end of the animation if anything was detected.
  3. Attach a collider or shape cast to the weapon. This would be for some systems that may need to know which body part was hit, more precision, ect..

Many different ways depending on what your combat is like, requirements.

@pliant lion

sour fulcrum
fickle plume
#

To illustrate how much of the information you are missing. Instead of getting a narrow answer you should look at an actual manual page of the ! (Unary logical negation operator). https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators And get a wealth of information about its usage and other operators as well. And while you may not remember everything, you would remember that such additional things exist and where to find them. This is what you are losing polling LLM instead.

thorn kiln
#

You see, the solution being private List<string> TextToDisplay = new List<string>(); was not helpful because the only lists I've had to make in the pathway were all public so I've never had to do this before.
When all the lists I've had to implement before just look like public List<GameObject> targets, I don't have the knowledge inside my head to make connections about why my list is giving me a NullReferenceException, and just telling me to know better is not helpful.

naive pawn
#

okkk let's not extrapolate the wrong thing

#

do the pathways not cover the concept of null or instances at all?

#

and just telling me to know better is not helpful.
you gotta stop pulling these things out of thin air, man

thorn kiln
fickle plume
#

When interacting with learning material, it's up to you to take extra steps to understand it. If you do just bare minimum this is the result you get.
If you see the usage of something under different context - look it up!

hard tapir
naive pawn
naive pawn
rigid pike
#

i am following a tutorial and this appeared out of nowhere and i really hate it (I'm talking about the clipping when the camera is not even close to the objects)
How do i fix it?

frosty hound
rigid pike
#

thank you so much!

rigid pike
zinc tundra
#

Hello! Am really sorry for disturbing, anyone can help about moving my character? I can move my mouse around but my character dont move, like it doesnt have keyboard input or something. There is the code, I dont think i messed up anything serious. I really need help about that to continue my project.

rocky canyon
#

debug the inputs and find out for sure

#

Debug.Log($"Horizontal Inputs are: {moveH}");
Debug.Log($"Vertical Inputs are: {moveV}");

or

Debug.Log("Horizontal Inputs are: " + moveH);
Debug.Log("Vertical Inputs are: " + moveV);

zinc tundra
#

sounds good, where do i paste that? or just around the code?

rocky canyon
#

think it through..

#

|| probably after you assign the input/variables ||

zinc tundra
#

oooo, okay okay lemme try

rocky canyon
#

using Debugs is a good take-a-way from this...

#

never assume codes doing what u expect it to do..
logging messages and variables in the console window when and where something's supposed to happen can confirm

zinc tundra
#

okay so it came out it has keyboard input, since the numbers are changing depends how i press them

#

so wasd stuff works, what coming now?

rocky canyon
#

yea.. for GetAxisRaw it'll either show -1, 0 or 1

zinc tundra
#

yep, thats exactly that happened

rocky canyon
#

and it must be something else

zinc tundra
#

hmm, where do i start?

#

wondering if Debug.Log() would work

#

but if theres no console error and all works, the error am searching just slips thru

rocky canyon
#

you'd want to log the values ur using for the movement

#

make sure those are working as they should.. and then if thats the case it may be something else.. maybe the setup..

#

maybe the forces/ or speed multiplier ur using is too low...

#

rigidbodies have friction.. if the forces aren't strong enough to move it it wont move..

#

you can also log the velocity of the rigidbody after ur move logics
something like Debug.Log($"RB velocity: {rb.velocity}");

short gust
#

maybe it's very stupid question: does GetComponentCount() from gameobject reference is still slow to call quite frequently as is GetComponent<T>() or similar calls? like, does it still iterate trough all components every call (like GetComponent does) or it's only changed on add/remove component and cached internally?

rocky canyon
#

also make sure u don't have any other errors or warnings in the console window..
if theres an runtime error or something sometimes it can keep the rest of the code from running the way it should

short gust
#

it seems logical to me work like I wrote with caching, but I don't know for sure if it like that in the engine, lel

rocky canyon
# short gust maybe it's very stupid question: does GetComponentCount() from gameobject refere...

Unity's pretty good at optimizing itself.. from what i read GetComonentCount() is designed to be more efficient than creating new arrays like GetComponents().Length

Unity internally maintains the component count so calling Count shouldn't need to iterate thru all the components each time
i'd think you'd use it where you need to know the number of components attached to a GameObject without actually needing to accesss the components themselves..

#

never hurts to Cache things yourself tho..
if you have something thats repetitive.. make it a function.. cache it before hand... use whats cached whenever possible

#

Today I learned, tbh

#

didn't know that function existed

#

but if theres no console error and all works, the error am searching just slips thru
-# here's a little tip 👇 you can toggle "Collapse" in the console window and it'll make similar logs Stack so its easier to see whats going on

cunning bramble
#

hi guys i really need help and i need an video to record this

#

wait is it only on my Pc laged the video? :(

#

Pls ping me if you have an idea

rocky canyon
#

soo it has to be up the hierarchy

cosmic quail
zinc tundra
rocky canyon
cunning bramble
rocky canyon
#

for example if i do rb.AddForce(vector1); it wouldn't be strong enough to move it

#

at all

cunning bramble
#

Oh okay so the capsule is gliding not the camera

rocky canyon
cunning bramble
#

What should i do against this?

rocky canyon
#

its not the camera... look at the Transform inspector when u start sliding away

#

its not moving.. so it has to be the ^ player or something above it

cunning bramble
#

CAPSULE name = PLAYER

#

But what is the problem i mean why is it doing this?

#

Because it isnt in my script

rocky canyon
#

movement code.. u should change it...
see whats happening.. (it appears that some vector or something is continued to be fed into it)

#

and if thats not the case.. maybe its b/c u are actually sliding along the ground...

cunning bramble
#

!code

radiant voidBOT
rocky canyon
#

may need to do something in the movement code when ur not giving it input

#

if(input) -> move
if(!input) -> make stop

cunning bramble
rocky canyon
#

debug the values that u use for ur movement... see if they correspond to what u think should happen

cunning bramble
#

yo i am doing this now

rocky canyon
#

the more info the better, but i must step out 🍀 goodluck

zinc tundra
#

and theres no error line in the console

rocky canyon
#

putting a Log in there wouldn't stop the code from working like it was before..
it would just log a line to the console in the meanwhile 🤔

zinc tundra
rocky canyon
#

thats b/c they stack on top of each other

zinc tundra
#

probably because it disappeared, yeah

#

i start to get it but i dont at the same time

#

tutorials are just literally putting the cam into the capsule, pasting in the code and tada it works

cunning bramble
#

:(

rocky canyon
#

did u try cranking up ur Speed/force multiplier

#

see if it moves w/ a greater force..

#

also check if the constraints aren't set to Lock it in a specific axis

cunning bramble
#

do you mean me?

rocky canyon
#

and <insert weird something something that forces u off to the side>

cunning bramble
#

yes but i needs to be so the player dosent move when he is farming

rocky canyon
#

you should instead wrap ur movement in some code or something and turn a boolean on and off

#

canMove = true / false; for example

#

and instead of disabling the entire script just set that bool to false

cunning bramble
#

Oh yes thank you good idea

languid pagoda
#

How do racing games handle AI? I tried implementing it where the AI follow a spline, each node on the spline has a predetermined throttle and breaking percentage. It works but then it all falls apart on the first turn of the 2nd lap since the cars moving faster since its a hotlap and additionally it takes an eternity to tweak each nodes breaking/throttle values.

cunning bramble
#

sorry for ping

rocky canyon
#
public class SimpleMovement : MonoBehaviour
{
    public float speed = 5f;
    public bool canMove = true;

    CharacterController cc;

    void Update()
    {
        if (canMove)
        {
        float moveX = Input.GetAxisRaw("Horizontal");
        float moveZ = Input.GetAxisRaw("Vertical");
        Vector3 move = new Vector3(moveX, 0, moveZ).normalized;
        cc.Move(transform.position + move * speed * Time.deltaTime);
        }
        else
        {
          // some other movement code to keep u in place
        }
    }
}```
#

so instead of simpleMovementScript.enabled = false
just do simpleMovementScript.canMove = false

#

b/c i don't know exactly whats wrong with it..
but the video is proof
when its enabled -> it works
when its disabled -> yeet

rocky canyon
#

vision cones etc

#

so they're basically driving.. not following a pre-determined path

#

cuz thats boring 😄

#

you can probably even make a hybrid of the two.. (so if it can.. it'd follow the spline)
and then when it needs to.. or its disrupted it could actually drive itself

#

until its back on track to rejoin the spline

#

sounds easy enough 🫠 ¯_(ツ)_/¯

languid pagoda
rocky canyon
#

oh it absolutely is..

#

i made an arcade racer a while ago that used sensor arrays

languid pagoda
#

12 cars firing off 20 raycasts/spherecasts etc wont run

rocky canyon
#

had about 15 up front and a few raycasting down to get the surface type

#

but the walls were basically "bumpers" like old-school Ridge Racer 😅

cunning bramble
#

I have the script but i dont see it in the inspector can you take an look poof?

rocky canyon
languid pagoda
cunning bramble
#

!code

radiant voidBOT
cunning bramble
languid pagoda
#

idk why you're using a capsule collider and a player controller on the same gameobject

rocky canyon
#

already told you how u can solve it

#

and yea... this thing is doing nothing but getting int he way and making things more complicated than they need to be

#

this is the Collider and the Controller

#

#💻┃code-beginner message

you should instead wrap ur movement in some code or something and turn a boolean on and off
canMove = true / false; for example
and instead of disabling the entire script just set that bool to false
so instead of simpleMovementScript.enabled = false
just do simpleMovementScript.canMove = false
b/c i don't know exactly whats wrong with it..
but the video is proof
when its enabled -> it works
when its disabled -> yeet

#

CC's dont like being enabled and disabled..

languid pagoda
#

I feel like if he removes the capsule collider his problem goes away

#

but i could be wrong

scenic perch
#

Hey im trying to use VsCode and ive got a few extensions from a video I saw, but idk if they have different settings but some of the Intellisense stuff just doesnt work quite the same for me. For example in this one doing Transform. doesnt bring up any options for me to do after that? and then the second image doesnt have stuff like the purple game objects n all that

zinc tundra
#

||it didn't moved a bit||

rocky canyon
#

try something like Transform.

languid pagoda
rocky canyon
scenic perch
#

Never coded before and not sure what the difference is/whats better to use

rocky canyon
#

u should grab this extension

rocky canyon
naive pawn
scenic perch
naive pawn
#

vscode works fine

naive pawn
#

!ide

radiant voidBOT
scenic perch
#

I believe mine is to my knowledge, I have it set in unity to use VsCode at least

languid pagoda
# naive pawn vscode works fine

Yeah after you find the right combition of extensions to make it work, or you can just check a box when you're installing the editor and get a fully featured ide by default.

scenic perch
naive pawn
rocky canyon
#

ahh cool

naive pawn
naive pawn
# scenic perch

make sure to actually install .net too
command palette -> install .net system wide

languid pagoda
#

does vs code support debugging?

rocky canyon
languid pagoda
#

breakpoints and reading variables while running the game

rocky canyon
#

ya, with the C# devkit + debugger and stuff

naive pawn
#

vscode the ide itself supports those, but not sure about with unity, i don't really use debugging in general lol
i should do that more tbh..

cunning bramble
#

hi @rocky canyon i have made this like you did but i doesnt get shown in the Inspector PLEAS help i dont know xD

rocky canyon
#

i just troll a bit... (i use vscode because i do hardware embedded development as well)

#

its easier to use 1 ide for everything

naive pawn
cunning bramble
#

Urmmm

#

The canMove

naive pawn
languid pagoda
rocky canyon
#

^ my guess as well 😛

naive pawn
#

an entirely separate ide to configure for each language? that's insane

cunning bramble
#

I can show you I DID

#

!code

radiant voidBOT
naive pawn
#

and have you saved and recompiled

rocky canyon
#

then u have compile issues...

cunning bramble
rocky canyon
#

theres really no need to summon the bot everytime u want to post code...

scenic perch
rocky canyon
#

use a bookmark or write it down homie 😄

cunning bramble
#

bookmark?

languid pagoda
rocky canyon
#

ffs

cunning bramble
#

i did write it down but i got told to use this instad

#

Short version

naive pawn
#

yes, this is the wrong format to share code.

#

see the bot embed again.

rocky canyon
#

u can check ur .net tool in the output window i believe

scenic perch
#

I think my issue is some wierd intellisense setting tbh

cunning bramble
languid pagoda
naive pawn
rocky canyon
#

make sure you have No Problems

naive pawn
cosmic dagger
#

@cunning bramble This is not formatted. At least check the pin you keep summoning . . .

cunning bramble
#

Okay so i remove the capsule thing?

naive pawn
#

that was what you were told to do several messages ago, yes

languid pagoda
rocky canyon
#

you don't need (2) colliders especially when they're overlapping

naive pawn
rocky canyon
#

the CharacterController is a collider

scenic perch
languid pagoda
#

and chances are the two colliders overlapping is whats causing your weird slidy behavior

naive pawn
scenic perch
#

Ahh alright

#

Yep that fixed it, it seems

#

tysm, would not have figured that out lol

#

The simple turning it off and on again

naive pawn
#

this has consistently worked actually. wonder why these aren't described in the config instructions

scenic perch
#

Yeah funky stuff

scenic perch
#

(also why doesnt it just auto do it if its needed anyways)

rocky canyon
#

guess the same applies to IDE's too 🙂

naive pawn
#

oh they are mentioned in vertx's instructions

rocky canyon
#

welll its not always needed

I can write my HTML + CSS (webdev) in VScode.. and i wouldnt need any of that crap

scenic perch
#

Hm true

rocky canyon
#

its modular..

naive pawn
#

vertx's is much clearer than microsoft's, damn

naive pawn
scenic perch
#

Ohh okay that makes sense

cunning bramble
#

Okay so i removed the character controller but now i get 100+ error messages so my idea is to complettly delete the capsule or only leave the capsule colider

scenic perch
#

More open-source n all that too which I do enjoy

rocky canyon
#

we just force it to work as hard as visualstudio does >8)

#

im a sucker for the UI + all the extensions

naive pawn
languid pagoda
cunning bramble
#

ahhuurrmmm okay

naive pawn
#

not sure why this is a surprise to you

languid pagoda
#

like are you trolling us right now?

rocky canyon
#

ok fr.. im stepping out this time

languid pagoda
#

we all tell you remove capsule collider and you took off character controller

#

aint no way you''re being fr rn

cunning bramble
#

NO i am just over used today xD i mean i am doing this like since 14 hrs or so

naive pawn
#

ok, rest

#

that is the single most productive thing you can do

cunning bramble
#

ahhh atwhatcost

I am sorry guys i read it it wrong 😂

#

I am stupid sorry

naive pawn
#

nope, you're tired

#

this is what happens when you overwork yourself

languid pagoda
#

This is what happens when you try to jump head deep in development making a game tbh

novel aurora
#

is there an area for C++ in this one?

languid pagoda
#

gotta learn the fundamentals

naive pawn
languid pagoda
#

yes you can ask your question

novel aurora
#

rip

languid pagoda
#

like 40% of my codebase is in c/c++

eternal needle
#

c++ would be offtopic, find a c++ related server or DM them

languid pagoda
#

the engine supports c++ plugins it wouldn't be offtopic this is a code channel not a c# channel

naive pawn
#

let's disambiguate then

#

@novel aurora is your question related to unity?

cunning bramble
#

Okay works now... atwhatcost

novel aurora
#

no, its not related to unity, im doing visual studio

naive pawn
#

cool, this is not the place to ask then

#

case closed

languid pagoda
novel aurora
#

jesus chris, its because i wanted to know if there a SEPERATE AREA FOR IT

#

that all im asking

naive pawn
#

aightt you got your answer we don't need to prolong this unnecessarily

#

you should be able to find prominent c/c++ servers just by googling

#

if not that, then general programming servers like tph or tcd

novel aurora
#

alright

naive pawn
#

(for future reference, this entire server is unity-focused)

languid pagoda
cunning bramble
#

Kinda like this emoji

rocky canyon
winged ridge
rocky canyon
#

the rays in the front were to tell the car if there was another car in front of it.. and how closely to draft it
the rays on the outsides worked differently... the closer to the middle would steer it more aggressively than the ones on the outside.. and i think i also had trigger colliders (like spheres) around it as well for "proximity" type sensors

#

and also i used "ghost" cars.. so the car would "project itself" forward depending on its speed... and all those combined would make the decisions.. then it was all about that fine-tuning of values..
steering angles, the smoothing between those angles.. accel and de-acel speeds and so on

#

they weren't very "competitive" tho ngl.. i was just happy they made it around the track on their own 🙂

#

if i had kept going i probably coulda made it more competitive and drive more aggressively.. but it was really more of a proof of concept (using sensor arrays like a self-driving car would) sonar, lidar, so on

#

In this video we will be making a controller for our car that drives on it's own so the player can compete against the AI drivers.

Join our Discord:
https://discord.gg/cgmnF2edTp

Github Link:
https://github.com/Nanousis/NanousisCarController

TimeStamps:
00:00 Intro
00:39 Learning Racing Lines
03:12 Creating the waypoints
04:00 Braking Zones
0...

▶ Play video
#

see how other ppl do it

summer wren
#

Do you guys like it at the moment? (I use the free icons as assets for testing purposes; Terminal, Explorer, Folder icons)
Just need drag and drop from Desktop to Explorer grid and vice versa now xD

rocky canyon
#

ohh and waypoints.. i forgot to mention.. it would use waypoints to know which way to go around the track..
but it wasn't a spline.. it had to figure out how to get to the waypoints on its own

summer wren
#

Oh gosh how to post video link correctly?

rocky canyon
#

.mp4

#

upload or link

languid pagoda
summer wren
rocky canyon
#

no i had barriers.. there was always something in front

#

but it used distanced + speed + the raycast hit

#

my rays were basically infinite.. (i didn't really cap them..)

#

it was more of the switch statements and conditionals that were always checking the hit comparing the distance all that

summer wren
#

My project is like an OS hacking game with NPC's, networks, players etc hehe. Like Grey Hack eventually. Inspired by that.
I also have a 2D skilling game project with login and register support with NodeJS server yay. Excited

languid pagoda
#

hmm ill probably have to handle it a little differently, my tracks are not flat so sometimes there may not always be a hit

rocky canyon
#

but like if the hit was way way out in front the code would just ignore them

languid pagoda
#

Thanks for all the info

rocky canyon
#

would be the hills and peaks and stuff

languid pagoda
#

this gives me a good general idea

zinc tundra
#

guys.. I imported a character controller asset, without touching it the character keyboard control still doesnt work...

rocky canyon
#

could raycast up into the sky for a good portion

zinc tundra
#

i think am going insane

winged ridge
rocky canyon
#

u can use a system like this + waypoints + triggers and stuff to come up with a pretty decent AI driving

zinc tundra
#

this is the error it got

rocky canyon
#

ya... u can't call Move() on a CC thats disabled

#

lol... if ur CC is disabled.. u might want to run a check in ur code to see that it is

summer wren
#

Anyone interested in such a project? In-game OS system with functional terminal, custom caret, etc? 🙂
Almost have file system and desktop stuff completed.
For potential colab?
I get lonely coding alone.

rocky canyon
#

b/4 calling that function

#

isCCEnabled -> if so we can Move()
isCCEnabled -> if not we shouldn't call Move()

radiant voidBOT
# rocky canyon !collab

: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**

winged ridge
summer wren
rocky canyon
#

no problem 👍

rocky canyon
#

If this is not enabled

summer wren
rocky canyon
#

then the script thats calling Move() gives u this error

zinc tundra
rocky canyon
#

FirstPersonController.cs line number 117 which is the Update() loop that calls ur Move() function or a method with that function

#

line 198 is probably the Move() function..

#

u can't call that on a CC component that is disabled

zinc tundra
rocky canyon
#

ya they're not always accurate

zinc tundra
slow blaze
#

how can I play a gameObject's animation to its end to make a vfx? its a 2D game

rocky canyon
#

but its around-ish

zinc tundra
#

and i literally just pulled it into my project

rocky canyon
#

no clue then.. you'd want to ask them.. hit up their support

zinc tundra
#

i can send there the code

#

but its 750ish line long lmao

rocky canyon
rocky canyon
#

if ur using the prefab they have in there there shouldn't be any errors..

#

else thats a crap asset.. i'd reach out and check or see what teh comments say about it

zinc tundra
#

w8 new error appeared

languid pagoda
#

this has nothing to do with code as you been told

rocky canyon
#

i think they're "winging it" as far as they can

languid pagoda
#

click on your player look in the inspector you got a component disabled

rocky canyon
zinc tundra
#

didnt add or disabled anything

languid pagoda
rocky canyon
#

yea.. but u gotta start using critical thinking..

#

it may be possible.. that its accidently disabled

languid pagoda
#

hell even half of the paid assets on the ass store are junk

#

so ofc the free ones going to be problematic

zinc tundra
#

but a simple w a s d and jump space code man

#

how could be problematic