#💻┃code-beginner

1 messages · Page 615 of 1

rich adder
#

haha true but you never know, at least if the instructions were good like KCC or something

cosmic dagger
#

We have no information about the asset you are using or how it is supposed to work. Look through the readme or documentation files on how to set it up properly. Hopefully, there are videos or a walkthrough, but if not, I would contact the author of the asset . . .

smoky river
#

this is what was written on the read me

rich adder
#

well if the prefabs have scripts on them already you don't have to add anything but the prefabs 🤷‍♂️

runic sorrel
#

hey guys having problems with my npc not walking on terrain need help pls dm me

runic sorrel
#

ok thanks well can anyone help here then

rich adder
#

why would I do more work and go out of my way when you can just post your issue here and I may have answer

smoky river
eternal needle
kindred iron
#

@polar acorn i can see my bean body cuz of The Flashlight's light, how can i made it so that it doesnt show my bean in fps mode?

rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
kindred iron
#

or what if its a multiplayer game?

cosmic quail
smoky river
rich adder
kindred iron
smoky river
wintry quarry
cosmic quail
runic sorrel
#

why is everyone a bit salty here. its not a competition. its called a beginner channel for a reason . no need to flex huh

rich adder
# smoky river real

its unrealistic me sitting here doing a walkthrough on how to add animations, this a code channel and regardless you would have no idea where to look if i told you where to go lol. Do the essentials first

runic sorrel
#

lame tbh

violet oracle
#

rq how do i add a grid pattern to a cube

rich adder
polar acorn
# smoky river all i need to know is how to add the animation and then i will (most likely) nev...
Unity Learn

An Animator Controller is a Unity asset that controls the logic of an animated GameObject. Within the Animator Controller there are States and Sub-State Machines that are linked together via Transitions. States are the representation of animation clips in the Animator. Transitions direct the flow of an animation from one State to another. In thi...

smoky river
rich adder
polar acorn
fleet venture
#

How can i simulate dragging a prefab into another object from code.

rich adder
smoky river
fleet venture
rich adder
#

"problems" is as vague as it gets

fleet venture
#

it needs to be directly into it

#

otherwise it messes it up

polar acorn
rich adder
#

did you even read

rich adder
runic sorrel
#

i presume its something to do with the nav mesh perhaps ?

fleet venture
smoky river
fleet venture
#

but that didnt work

polar acorn
#

Were we just supposed to guess?

rich adder
runic sorrel
#

thats what i mean by salty. you are not very beginner friendly

smoky river
rich adder
polar acorn
eternal needle
rich adder
#

complains gets no help while making the person do all the work of inquiring with 100s of questions .

#

smort

rich adder
runic sorrel
#

!code

eternal falconBOT
smoky river
rich adder
smoky river
#

real

rich adder
#

what you're saying is " I want to somehow know how to do all this without prior knowledge but refuse to look at the material to get me there "

#

if you "dont have time" then you dont have the time to invest in yourself, and if you wont, why would others?

polar acorn
# runic sorrel thats what i mean by salty. you are not very beginner friendly

At some point during child development, a child develops what is known as a "theory of mind". The knowledge that other people do not know information until they are told it, even if that knowledge is true. There's an interesting experiment, if you get two children, one around age two or three, and another around five or six and give them the same scenario: "There is a ball in a toy chest. You take it out of the toy chest and put it under the bed when you're done. If you leave the room, and another child comes in and wants to play with the ball, where will they check for it?"

The young child will say "Under the bed" because, after all, that's where the ball is. The older child will know that the other kid has no way of knowing the ball was moved and will check the toy chest first.

Basically, what I'm saying is, you appear to have skipped that phase of psychological development

#

We can not see your screen. You have to say the things that are happening or no one here will know what you are doing

rich adder
#

but don't you know , we are all telepath here

#

🔮 UnityChanLoom

smoky river
polar acorn
#

It's also in the learn link you were sent, I just linked straight to the one on animator controllers

rich adder
#

but they dont have time digi ! they need this NOW. No time to learn.

slender nymph
eternal needle
#

if only discord had a built in counter we could use for the "just need to solve this ONE thing"

smoky river
polar acorn
polar acorn
runic sorrel
smoky river
# polar acorn Then what _is_ the problem

this bundle pack has an animation code and a character, and im trying to find out how to add that animation onto that character, as it is not written anywhere in the bundle

polar acorn
runic sorrel
#

dont need to, just having fun my man. dont take it too seriously x

polar acorn
rich adder
runic sorrel
#

insulting ? wow

rich adder
#

anyway no time to waste on these kiddies. blocked and moving on . goodluck with ya

runic sorrel
rich adder
#

should've spent that time putting effort into your original question instead of crying "salty users"

runic sorrel
#

just an observation

frosty hound
#

Everyone can stop bickering now, thanks.

smoky river
naive pawn
#

let's not pick that back up

red igloo
#

since my game is a 3D platformer and the camera is at a side view I don't want the camera transform orientation I still want to move forward and back with D & A same with the other keys how can I do it?

https://paste.ofcode.org/HA7xfZXrm7An9CSy6PJC7D

rich adder
wintry quarry
#

and use that

polar acorn
#

No need to involve any transforms in that case

fickle plume
#

@smoky river Don't post off-topic here. Read #📖┃code-of-conduct . And if you are not going to invest time in learning about the thing you are asking don't expect people wasting their time doing it for you.

red igloo
wintry quarry
#

yeah but what are forward and back

#

in terms of the game world

wintry quarry
#

not in terms of controls

#

like... is forward just "world right"?

rich adder
#

so you mean D goes to Vector3.Right ?

#

like every other 2D platformer

red igloo
cosmic dagger
red igloo
#

Basically fps movement just the camera at a side view

rich adder
#

oh your forward is Vector3.forward

polar acorn
wintry quarry
#

you drew your back and forward arrows pointing the same direction though haha

#

unless you mean back is the red arrow in Unity

#

which makes no sense to me

rich adder
#

yeah lol thats confusing pointing arrow

polar acorn
#

Yeah, I interpreted it as "Back is into the screen" which seems like a really wonky control scheme

wintry quarry
#

Yeah in that case back would actually be... left and back and forward would not be opposites

rich adder
cosmic dagger
#

That's what threw me off. Even if that was away from the camera (into the screen) it's still drawn and named incorrectly . . .

red igloo
#

Like this? im a bit confused sorry

wintry quarry
#

assuming you want the horizontal input to control "depth"

#

according to your camera angle

red igloo
#

I want to move forward with D not W

wintry quarry
#

(into and out of the screen)

wintry quarry
#

and verticalInput

#

match up whichever one is A/D with Vector3.forward

red igloo
wintry quarry
#

what do you want W and S to do?

red igloo
wintry quarry
#

then you have it correct

#

assuming what you said about vertical input being A & D is correct

#

and horizontal input being W and S

#

er actually

#

you would do Vector3.left

#

or -right

#

if you want W to go into the screen

#

Have you been testing the code or not? It should be pretty straightforward

red igloo
#

just tested it when I press D the player does not go right to move right is W

wintry quarry
#

then you are mistaken about which one vertical and horizontal input are

#

go check that again

#

Yeah based on your code from earlier:

        horizontalInput = Input.GetAxisRaw("Horizontal");
        verticalInput = Input.GetAxisRaw("Vertical");```
What you said is completely backwards
polar acorn
#

Since forward is your left/right

#

and left is your up/down

red igloo
#

just checked what my vertical input was >

#

I FIXED IT! Thanks for the help !!

rich egret
#

The script is designed to rotate a 3D model with the mouse but have it stay in place, but for some reason it doesn't.


public class MovePrefab : MonoBehaviour
{
    private bool isDragging = false;
    private float rotationSpeed = 5f;
    private Vector3 lastMousePosition;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.gameObject == gameObject)
                {
                    isDragging = true;
                    lastMousePosition = Input.mousePosition;
                }
            }
        }

        if (isDragging)
        {
            Vector3 deltaMousePosition = Input.mousePosition - lastMousePosition;
            float rotationAmount = deltaMousePosition.x * rotationSpeed * Time.deltaTime;
            gameObject.transform.Rotate(Vector3.up, -rotationAmount, Space.World);

            lastMousePosition = Input.mousePosition;
        }

        if (Input.GetMouseButtonUp(0))
        {
            isDragging = false;
        }
    }
}```
cosmic dagger
rich egret
pale hazel
#

I honestly have a problem, So Im trying to make that NPC movement I think mario bros had where the NPCs would turn around and go another direction of a platform if they'd fall the more they walk.

I attempted to use raycast to simulate that movement but I ended up with this issue for some unknown reason.

#

Gonna also post the code and other stuff in a minute

eternal falconBOT
pale hazel
cosmic dagger
#

Use a paste site. That's the best option . . .

pale hazel
#
public class EnemyMovement : MonoBehaviour
{
    [SerializeField]
    Rigidbody2D rb;

    [SerializeField]
    Animator animator;

    [SerializeField]
    SpriteRenderer spriteRenderer;

    [SerializeField]
    float Startspeed;

    [SerializeField]
    int directionX;

    [SerializeField]
    LayerMask Hitlayer;

    [SerializeField]
    float Currentspeed;

    void Start()
    {
        ResetSpeed();

        int random = Random.Range(0, 2);

        if (random == 0)
        {
            directionX = 1;
        }
        else
        {
            directionX = -1;
        }
    }

    // Update is called once per frame
    void Update()
    {
        Debug.DrawRay(transform.position, new Vector2(directionX * 10, -10), Color.red, 1);
        RaycastHit2D hitted = Physics2D.Raycast(transform.position, new Vector2(directionX * 10, -10), 0, Hitlayer);

        if (hitted == false)
        {
            Currentspeed = 0;

            int delay = Random.Range(2, 5);

            Invoke(nameof(ResetSpeed), delay);

            Invoke(nameof(ChangeDirection), delay);
        }

        animator.SetInteger("MovementX", directionX);

        rb.velocity = new Vector2(directionX * Currentspeed * Time.deltaTime, rb.velocity.y);
    }

    private void ChangeDirection()
    {
        if (directionX == -1)
        {
            directionX = 1;
        }
        else
        {
            directionX = -1;
        }
    }

    private void ResetSpeed()
    {
        Currentspeed = Startspeed;
    }
}
#

This is the movement code for enemy

#

I know the problem is that Raycast isnt counting the ground as something it sees but genuinely why

#

Might aswell also show what the whole Unity settings of it is, first two pictures are tilemap and grid details for the ground and last two are the enemy's settings

#

Also Note I havent set the animation yet

wintry quarry
#

new Vector2(directionX * 10, -10)
These 10s mean nothing

#

raycast uses a direction for one parameter, and then the distance is in the distance parameter

#

y9ou also didn't show the inspector for the script so it's not clear what you set the layermask to as well.

pale hazel
#

Enemy Movement is the script

wintry quarry
pale hazel
#

its basically this

wintry quarry
#

alright well - your main issue seems to be the parameters to your raycast being wrong

errant moss
#

Hey! can anyone help with unity ar?
I am spawning a prefab on detection of a ref image and the moment it spawn I want to attach the joystick prefab in canvas to it. I'm having a bit difficulty with that.

pale hazel
#

Also I set the distance to 3 and changed the directions a bit and... this happened

#

the enemy is just... suddenly funky

jagged venture
#

Hi, i have this problem, the offset and tilling only moves the silhouette, not the image.
I don't find any solution for this in the internet, has 2 days this problem
Sorry my english

pale hazel
#

It's also what happened last time should've mentioned which is why I tried setting it to zero

jagged venture
#

This is the problem

pale hazel
dense crystal
#

Hey guys im brand new to unity and im having issues with some simple code can anyone help me?
problem is the bird wont jump more than once in this but its picking up my keys. the tutorial is using velocity and i seen thats depercated to now linear velocity.

Code:

using UnityEngine;

public class BirdScript : MonoBehaviour
{
    public Rigidbody2D myRigidBody;
    public float jumpForce = 10.0f;

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

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            myRigidBody.linearVelocity = Vector2.up * jumpForce;
        }
    }
}
dense crystal
polar acorn
dense crystal
#

like this should work in theory? idk why it does that problem

polar acorn
#

The camera is falling

dense crystal
polar acorn
#

If you gave it a rigidbody

#

Show the inspector of the camera

#

Either it's falling or it's upside-down

#

because that bird's Y value is going up

dense crystal
#

omg youre the goat

#

i did that by accident in the start.

dense crystal
polar acorn
#

Sometimes it's a good idea to put some sort of background element fixed in place so you have something to compare movement against

dense crystal
proud escarp
#

Hello guys! I'm trying to learn how to use Animation Rigging.. I'm following a yt video, and did exactly the same (with a different model), but elbow is not moving.. I'll upload a small video if I can

queen adder
#

Is doing a GetComponent on the collider that a raycast from the camera hits every update a bad idea? I know that GetComponents are expensive but I can't think of a better way to get some properties of an object i'm looking at.

queen adder
#

After I get the collider and the gameobject of the collider, I am going to do a GetComponent to get a script

rich adder
#

try hundreds

#

on a slight efficency note, always good idea to have TryGetComponent instead. So you have benefit of null check too

polar acorn
#

GetComponent should be avoided whenever possible, but sometimes that means it is necessary

cosmic quail
#

trygetcomponent is a lot more efficient when getting an interface instead of a normal component right?

rich adder
#

trygetcomponent is just GetComponent with a null check

slender nymph
#

the only "efficiency" difference between GetComponent and TryGetComponent is the fact that TryGetComponent does not allocate in the editor like GetComponent does

cosmic quail
slender nymph
#

and how would that make any difference between GetComponent and TryGetComponent?

polar acorn
atomic crater
#

Hello fellas, I'm a programmer dabblling in unity just recently. I am making a 2d top down game and I want to have a player character shoot a gun at the enemy using a mouse to aim.

I was trying to use raycast2d to detect whether it hits the enemy or not, but I found out that the ray I cast straight up ignore the collision and will always be false. I still can't find an answer after an hour of searching and looking up documents and I think I need help

https://paste.mod.gg/ebapanlyatki/0
This is the code used for the shooting. The object has the required tag and has a correct collision box

cosmic quail
rich adder
#

they all just object at the end of the day

slender nymph
#

but yes, null checking an object that doesn't derive from UnityEngine.Object will be faster than null checking an object that does, and that is only because UnityEngine.Object has those overridden == and != operators to do its check for fake null

polar acorn
#

And a null check on an interface is the same as a null check on literally any other reference type

polar acorn
rich adder
#

I suppose unity has to do some type of lookup first by InstanceID or whatever

#

that can add some slight compute time

cosmic quail
rich adder
slender nymph
atomic crater
rich adder
#

its probably at most 1 in length

naive pawn
#

drawray doesn't take a direction

#

drawray takes a ray and an offset

#

Draws a line from start to start + dir in world coordinates.

#

dir being the ray and start being the offset for the origin of the ray

rich adder
#

@atomic crater . anyway should Debug.Log($"hit : {hit.collider.name}");

atomic crater
#

oh my lord, that's it

#

The debug said it hits the player object, so that's why it never hits the enemy

#

So the hit detection works as intended after all

rich adder
#

yeah good idea to use ignore layermasks

rocky canyon
#

👍 Debug.Log(Everything);

rich adder
#

its funny how there were Debug.log for everything else BUT the main causer

rocky canyon
#
void Update()
{
    if (Input.GetMouseButtonDown(3)) Debug.Log("Back Button Pressed");
    if (Input.GetMouseButtonDown(4)) Debug.Log("Forward Button Pressed");
}``` just found out i can use the macro buttons on my mouse as simple developing buttons
atomic crater
#

Alright that solves literally everything. Thank you so much for pointing this out to me. I have to wrestle with a new language syntax, and it's good to hear that I just made a simple mistake

devout otter
#

Hey, when im trying to add an onclick event to a button, i dont see my method, which has 2 parameters - in the list. But if i remove 1 parameter - i can see it. Unity does not support onclick event methods with more than 1 parameter?

slender nymph
wintry quarry
#

You can always add listeners in your code dynamically

solid moss
#

Hello Guys,

i am trying to update my Global Volume lens distortion via a skript.

The slider changes during runtime, but not the effect - but if i change the slider manually, it works

anyone got an idea? can post code

slender nymph
solid moss
#

!code

eternal falconBOT
slender nymph
#

have you confirmed that there are no errors and that the code is actually running?

solid moss
#

yes, there are no errors and like i said - the slider is moving, but for some reason it just doesent update in game

#

and idk why :(

#

I've been trying on this for 2 hours now, even with help of chat gpt

slender nymph
solid moss
#

i will ask, ty

solid moss
#

i got it working.. i didnt have the right volume mask selected in main camer->Environment

rocky canyon
#

-# both of these seem to be valid

    moveAction.action.performed += k => OnMove(k);
    moveAction.action.performed += OnMove;

-# even without changing the method

    private void OnMove(InputAction.CallbackContext k)
    {
        Vector2 movement = k.ReadValue<Vector2>();
        Debug.Log($"Move {movement} {k.time.ToString("00:00")}");
    }

i read something like "Unity knows that it needs the context so its automatically included.. my question is is that true.. and even tho im OCD and looove clean code.. something feels wrong about omitting it

broken nest
#

Hey, it's probably something dumb but I got a script on an object with a Debug.Log() in awake and I don't get any console message, any idea how that might happen?

rocky canyon
#

is the script attached to a GameObject..

timber tide
#

Is it disabled by default?

rocky canyon
#

and/or in the scene?

slender nymph
broken nest
#

nvm it's because I checked the thingy that makes it so the messages don't show lmao

#

I knew it was dumb

rocky canyon
# slender nymph Note that the first one is creating a lambda expression and subscribing that. Th...

ohhh!..

    void PlayerInputsUnSubscription()
    {
        // unsubscribe from player action maps
        moveAction.action.performed -= k => OnMove(k);
        moveAction.action.canceled -= k => OnMove(k);
        jumpAction.action.performed -= k => OnJump(k);
        attackAction.action.performed -= k => OnAttack(k);
        interactAction.action.performed -= k => OnInteract(k);
        crouchAction.action.performed -= k => OnCrouch(k);
        sprintAction.action.performed -= k => OnSprint(k);
    }``` so this is bologna?
timber tide
rocky canyon
#

i see..

#

thanks guys.. that woulda went unknown for a while

rocky canyon
#

but slowly im getting the hang of lambdas and anonymous functions

tulip stag
#

Any way to make EntryIDs not serialized by the JsonUtility but still show up in the inspector?

wintry quarry
#

That essentially means custom editors, but also plugins that make custom editors easy

tulip stag
#

😔

wintry quarry
#

Another alternative is to switch to a different JSON Serializer

#

that uses a different serialization mechanism and rules

#

and keep it serialized in Unity

timber tide
#

Probably can just make another list and populate it via onValidate I would think

wintry quarry
#

wouldn't that equally apply to JsonUtility and the inspector though?

timber tide
#

I'm actually a little confused on what this pertains to. Is this to see it in the editor at runtime?

#

In that case you'd just populate another list that's created at that runtime

rocky canyon
#

aye!! cleaned it up a bit

#

still chunky under Subscribe and Unsubscribe methods.. but atleast for the Enable and Disable i got a for loop doing the work

#
    void DisablePlayerInputs(){
        foreach(var action in playerActionReferences)
            DisableAction(action);
    }```
violet glacier
#

Hi, I'm using vcontainer, what are some ways to use coroutines if the script is not a monobehavior?

rich adder
#

You can use async just fine though..

violet glacier
#

Oh I see, what if I inject a monobehavior instance and use that to start coroutines for all the scripts that need to start a coroutine?

rich adder
#

As long as the MB can run sure, it can work I suppose.

#

what exactly you need from coroutine that regular async can't do

violet glacier
#

I guess I don't know how to use regular async

rich adder
#

instead of yield you await

violet glacier
#

Here's an example code I need to use

    public void DelaySequence(float delaySeconds, Action onComplete)
    {
        StartCoroutine(Delay_Routine(delaySeconds, onComplete));
    }

    private IEnumerator Delay_Routine(float delaySeconds, Action onComplete)
    {
        yield return new WaitForSeconds(delaySeconds);
        onComplete?.Invoke();
    }
rich adder
#

Coroutines are like fake async

#

if all you're doing is a delay Async should work just fine

#

You can probably use Awaitable too, I haven't looked into if it works without MB though

#
async Task DelayedMethod(){
await Task.Delay(timeInMs);
//do something```
violet glacier
#

Thanks I'll try that

rich adder
arctic arch
#

Hey guys I use ECS (with Entities Graphics) and want to change the material on a specific entity. Basically in one of my systems I go over all the entities that have my component, and then the children of this are the ones that actually need the changing, so my question is 2 steps, how do I get children of an entity with specific components, and how do I change an entity's Material? (I just started with ecs so I might just be expecting the wrong thing here I honestly dont know)

exotic jacinth
#
using System.Collections;
using UnityEngine;

public class PortalActivator : MonoBehaviour
{
    [SerializeField] GameObject portals;
    [SerializeField] AudioSource audioSource;
    [SerializeField] AudioClip mainmusicTwo;



    private void Start()
    {
  
        audioSource.Play();
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            portals.SetActive(true);
            ChangeMusic();
        }
    }
    void ChangeMusic()
    {
        audioSource.clip=mainmusicTwo;
       audioSource.Play();
    }


}

when the music is changing to second one there's a fps drop in my game . how can I fix it?

rich adder
#

wont know for sure without profiler

exotic jacinth
versed light
#

is there any known bugs going around in unity 6 with custom editors ?

charred spoke
deft grail
#
private void OEnter2D(Collider2D collision)
    {
        
    }

anyone know how to fix terrible completion? Visual Studio Code
i press tab on OnTriggerEnter2D then it just completes like half of it or something, is there a setting for it?

naive pawn
#

have you configured your ide properly?

#

!vsc

#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

deft grail
#

it suggests everything and shows errors all fine

hot harbor
#

is there a way to make coroutines' waitforseconds work in regular update/fixedUpdate functions other than having to make your own counter variable?

deft grail
tulip stag
#

Some very basic beginner programming logic question:
If my static class SheetHelper has a variable of the class Sheet that should aleays point to a Sheet that exists as a variable in GameManager.Instance.activeSheet; will just Sheet currentSheet = GameManager.Instance.activeSheet work? Like, I can intuitively see two things happening and I'm not sure which will actually happen:

  1. Any changes to currentSheet will change GameManager.Instance.activeSheet, meaning that I can work entirely on SheetHelper to do all my modifications on the GameManager's Sheet variable
  2. When assigning currentSheet as GameManager.Instance.activeSheet; I create a new instance of Sheet that's running within SheetHelper that will copy all the information present in activeSheet. It means that no changes happening to currentSheet will affect activeSheet

(PS: does the answer change if SheetHelper is not static? I was hoping to make a SheetManager too that inherits from Monobehaviour and calls functions from the SheetHelper API)

sour fulcrum
# tulip stag Some very basic beginner programming logic question: If my static class `SheetHe...

If my static class SheetHelper has a variable of the class Sheet that should aleays point to a Sheet that exists as a variable in GameManager.Instance.activeSheet; will just Sheet currentSheet = GameManager.Instance.activeSheet work?
no, because thats setting a value, you want to point to a value. for this you want a property.

a property is a Get and a Set function disguised as a field. in your case it would look like this

static Sheet CurrentSheet
{
    get
    {
        return (GameManager.Instance.activeSheet);
    }
}

this means when something tries to get from it, it does that logic to retrieve it.

in your case it can also be simplified to just
static Sheet CurrentSheet => GameManager.Instance.activeSheet

tame mesa
#

Hello,

I have an idea to make a voxel exploration game.

We would like the player to explore a place like in the picture (maybe not as much detail but a notion of immensity)

So a friend is creating the interior model of the cathedral. At the code level however, I would like to know what is the right way to manage this? Do I have to load the element in one go? Finally how to go about it?

I really have no idea how to import something so "big" correctly

rich ice
#

is your friend using magicavoxel? pretty sure big models have to split into multiple parts anyway

#

also this isn't really a code question

tame mesa
#

Forget about elements such as pillars, benches etc

I'm really talking about the structure, the building

rich ice
#

more of a question for #🔀┃art-asset-workflow. this doesn't have anything to do with programming. (i dont really know the specifics of importing bigger models anyway)

#

also, magicavoxel has a maximum object size of i believe 256x256x256 voxels per object. this is far bigger than that limit so it would be split across multiple objects

tame mesa
#

I was wondering if this was the right channel, sorry

cosmic dagger
tame mesa
rugged beacon
#

how do i use this outline script

grand snow
rugged beacon
#

something thats can be toggled forgot to add

grand snow
#

Id share one but it's not mine

chrome apex
#

so if I want to make a make a player controller with an elongated collider but I don't want it to be pushed by forces, the only possible way to do that is to code my own movement systems with raycasts and stuff ,yea?

rugged beacon
#

dang its seem adding sprite outline not simple

grand snow
#

Edge detection isn't super hard in a shader and there are plenty of resources to teach how to do it

rugged beacon
#

yea all the guides i've seen for this use shader graph, i'll look for more ways awhile, keep this as my last resort

rich ice
chrome apex
cosmic dagger
fervent abyss
#

for some unknown reason my code wont work, even though i have other ontriggerenter methods as a coroutine and they all work just fine

IEnumerator OnTriggerEnter(Collider other)
    {
        if(canUse){
            canUse = false;
            if(tap){
                if(tagCheck){
                    if(!other.CompareTag(tapTag)) yield break;
                    onButtonClicked?.Invoke(other);
                } else {
                    onButtonClicked?.Invoke(other);
                }
            } else {
                onButtonClicked?.Invoke(other);
            }
            yield return new WaitForSeconds(delay);
            canUse = true;
        }
    }
fervent abyss
polar acorn
fervent abyss
#

then how do mine work

#

😭

rich ice
cosmic dagger
polar acorn
rich ice
cosmic dagger
#

The method is probably being called regularly, but you have to call a coroutine from OnTriggerEnter . . .

fervent abyss
#

erm

#

lemme record a video

rich ice
#

damn, now i kind of want to double check this myself. that'd actually be somewhat useful if its true

rancid tinsel
#

are non-monobehaviour instances like this automatically cleaned up or how does that work?

grand snow
rich ice
polar acorn
rancid tinsel
cosmic dagger
# rich ice

Did you try waiting for a few seconds and logging after?

grand snow
rancid tinsel
polar acorn
# rich ice

This is documented nowhere, I am on mobile and can't test it but nothing anywhere official says this can be done

rich ice
rich ice
rancid tinsel
grand snow
rich ice
# rancid tinsel whats the issue?

multiple people here (including me) didn't know you could do this

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

public class Test : MonoBehaviour
{
    public IEnumerator OnTriggerEnter(Collider other)
    {
        Debug.Log("damn, this actually worked");
        yield return null;
    }

    public IEnumerator OnTriggerExit(Collider other)
    {
        Debug.Log("damn, this actually worked");
        yield return null;
    }

    public IEnumerator OnTriggerStay(Collider other)
    {
        Debug.Log("damn, this actually worked");
        yield return null;
    }
}
polar acorn
#

Again, put the log after the wait and see if it works

rancid tinsel
#

do what though?

grand snow
rich ice
rancid tinsel
#

my understanding of gc is basically limited to brief conversations in class when doing object pooling lol

rich adder
rancid tinsel
#

but apparently destroying something doesn't make it over and done with

#

which i had no idea about

rich adder
#

correct

rich ice
rich adder
#

its "marked" only for deletion but not deleted yet
until GC comes with its broom and sweeps these gremlins out

rich ice
polar acorn
rancid tinsel
#

oh wait wtf

polar acorn
#

Put some absurd length wait in there and see

rancid tinsel
#

as in no one here knew you could wait return null without it throwing an error?

#

add me to the list, that is WEIRD

rich ice
fervent abyss
#

i have 2 scripts that use coroutine for on trigger enter and they both work

#

but the 3rd one doesnt

rich ice
#

usually a coroutine needs to be triggered by a void to run

#

afaik atleast

rich adder
rich adder
#

notably
IEnumerator Start()

rancid tinsel
#

yeah that was my assumption

cosmic dagger
#

They don't need to be triggered by another method to run . . .

rich adder
#

another internal one called by unity void async Awake()

rancid tinsel
#

similar to how Test Runner gives you 2 preset tests, 1 void and 1 ienumerator

fervent abyss
polar acorn
cosmic dagger
#

I can confirm they do work as a coroutine . . .

fervent abyss
#

but LMFAOOOOOO why isnt it documented anywhere

polar acorn
#

Dude raced backwards and found the secret level

fervent abyss
rich adder
rich ice
grand snow
polar acorn
grand snow
#

Real solution: use a debugger

fervent abyss
#

im trying to debug, the method works apparently but it doesnt if check

polar acorn
rich adder
#

Yeah I saw it somewhere, forgot where it was a while back. Iirc might been hidden in docs somewhere

cosmic dagger
fervent abyss
#

muahahahah

#

who knows how many more secret unity has like this

rich adder
#

fun mystery box

rich ice
fervent abyss
#

lol nvm i got it to work

fervent abyss
polar acorn
fervent abyss
#

dont thank me guys for opening a whole new possibility in Unity

#

i guess im just a guy who knows a guy... [proud]

rancid tinsel
#

btw is there an example where a coroutine OnTrigger would be better than just doing regular OnTrigger and calling a coroutine in there?

rich adder
#

Just in time when I pretty much stopped using coroutines xD

rich adder
rich ice
rancid tinsel
#

yeah ig its cleaner, im just thinking i dont think there is a way to grab a reference to that ontrigger coroutine is there?

rich adder
#

aside from that...it cannot be started outside of OnTriggerEnter

#

also you cannot Store the coroutine inside a variable

rancid tinsel
#

yeah

rich adder
#

I suppose you could but it probably wont be the same one unity calls thru MB since they will run side by side

polar acorn
rich adder
#

happens to the best of us 🥹

burnt vapor
#

I could have sworn this was documented, but I guess it isn't

#

That said, imo a bit of a codesmell to coroutine one of them. Would advice you call coroutines from inside the method instead

cosmic dagger
#

That is precisely my point. The fact that you can't store it in a variable is a code smell and a bad idea for me . . .

warm jackal
rich ice
#

dont cross post

rocky canyon
#

its spawning at the same position that this gameobject is

rich adder
#

the issue is they're moving the prefab not the actual instance

rocky canyon
#

ahhh i see

#

this is wrong

#

thats the "prefab reference"

warm jackal
#

can you explain why

rocky canyon
#

the one in the project window

#

ur trying to move the "Original" prefab..

rich adder
rocky canyon
#

not its Instantiated Clone

warm jackal
#

what am I supposed to do to resolve this issue?

rich adder
#

store the instance in a variable to do stuff with

#

Instantiate returns you the cloned object

rocky canyon
#
private GameObject theSpawnedObject;

    void SpawnObject()
    {
        // Fait apparaître un nouvel objet à la position du spawner avec une rotation par défaut
        theSpawnedObject = Instantiate(cubePrefab, transform.position, Quaternion.identity);
    }```
#

theSpawnedObject.transform.position = Vector3.MoveTowards(spawner.transform.position, player.transform.position, speed);

#

understand?

warm jackal
#

okay I think I got it

cosmic dagger
# warm jackal can you explain why

You are moving the original prefab, but that is the object you are using to instantiate clones from. The original prefab is not in the scene. It is not the instantiated object in the scene. You need to move the instantiated object you created from the prefab . . .

rocky canyon
#

-# good luck 🍀

warm jackal
#

the spawned object is a clone of the prefab that why whit the prefab it dont work

#

the prefab inst in the scene

cosmic dagger
warm jackal
#

okay I understand now

#

thank you everyone

rocky canyon
#

i think unity needs to create a little console log for this type of stuff ;D

warm jackal
#

yes I agree

rocky canyon
warm jackal
#

I didnt got this

rocky canyon
rocky canyon
warm jackal
#

ahhh okay

#

but it dont seem to work anyways, am I missing something ?

rocky canyon
#

show ur script again..

#

and whats not working? be more specific

warm jackal
#

let me show you

cosmic dagger
#

Yeah, you probably skipped a step . . .

warm jackal
#

just wait a minute let me try something

#

something is wrond whit my speed float

#

I have the impression that this defines the spawn point of my object that I want to move

rocky canyon
#

pro-tip: for modifiers (multiplication)
its always good to start with 1 and then modify it during run-time to find the best fit for you..

#

b/c anything * 1 = anything..

#

soo its a good base-line

warm jackal
#

yes

#

when i change speed it just move the position of my clone

cosmic dagger
warm jackal
#

yes sorry

rich ice
#

btw, if you're using OBS. you can use the remux recordings button (right under show recordings) to change the recording from an mkv to an mp3

warm jackal
#

okay didnt know that

rocky canyon
warm jackal
rocky canyon
#

ahh well that should work fine too..

#

just slot in the Player's transform for the Initialization method

warm jackal
#

i dont change the position on my video, just the speed

rocky canyon
#

i copied ur code.. works that way as well..

warm jackal
rocky canyon
#

heres both scripts i used in the video.. (they're your scripts just refactored a bit)

#

not sure why changing the speed variable affects ur instantiated object at all

#

the speed variable only matters when u instantiate it..
it sends the speed variable to the **Follow **script in its initialization..
after that the Spawner script shouldn't matter at all..
if you change the speed variable.. it wont affect anything until you go to spawn another gameobject
then that new speed variable gets sent to the initialization method for that prefab

warm jackal
#

It help me to understand the two script you send me

#

thank you a lot

#

for a beginner like me its very important

sterile radish
#

how can i delete the stuff in a json file but still keep the file itself?

grizzled carbon
sterile radish
#

yes

grizzled carbon
#

you should be able to open it with a code editor / notepad and delete the contents

sterile radish
#

oh sorry i meant as if there was a way to do it through code

rocky canyon
#

to help a bit.. but also for people to take it as an example and compare it to theirs

eternal needle
#

And overwrite it

#

At that point, could you not just delete the file? It's not like theres anything to read from it anymore

rocky canyon
drowsy mason
#

can i ask here what software is the easiest to learn how to make simple game's idk for example clicker or 2d game

#

unity?

rocky canyon
#

you'll mostly want to learn a little bit of everything if ur a solo dev

#
  • Image Software
  • Audio Software
    mainly
drowsy mason
#

idk how am i supposed to start

#

like idk mainly how do i make levels/maps etc

rocky canyon
#

curated them quite a while ago
-# a few tools i use..

rocky canyon
rocky canyon
#

!ide the most important step tbh.. if u dont have a configured IDE you can't really get much help.. its a requirement

eternal falconBOT
rocky canyon
#

if you're bad at art you can use third party assets.. the Unity Asset Store has plenty..

drowsy mason
#

so i can for example download tilemap asset?

rocky canyon
#

for levels and stuff

rocky canyon
#

theres tons of them

#

some may already be cut up and sliced
some may not be..
you'll want to be familiar with the sprite-editor and how to set up ur textures to be 2D / Sprites

obtuse ether
#

im trying to figure out how to find the position of the gameobject the player collides with so the player knows which direction to fly away from, and i dont really know how to get it can someone help me lol

#

trying to not watch that many yt tutorials bc i end up going braindead and just copying the code w/o understanding what it does

#

lol

rich adder
#

float by itself doesnt do much

#

if(transform.position.x > other.position.x) // if he's to my right
if(transform.position.x < other.position.x) // if he's to my left

obtuse ether
#

alr

cosmic dagger
deep moon
#

i am having rotation issue and for some reason its not even starting, its performing then canceling

obtuse ether
#

i was thinking about just some basic flat knockback

obtuse ether
#

but im just curious about how you get the direction of an object

rich adder
#

nextpos - currentpos

deep moon
cosmic dagger
obtuse ether
#

i did make a little gun that points torwards your mouse but i dont really understand whats happening

#

since i kinda just braindead copied the code 💀

obtuse ether
#

the most i understand is finding where the mouse is compared to the gameobject using mousePos - transform

#

and then my brain kinda melts

rich adder
#

thats not a comparison

#

(b-a) gives magnitude

obtuse ether
#

oop

#

-# i worded it wrong im kinda dumb ignore me lol

rich adder
obtuse ether
obtuse ether
#

and then do i normalize this and multiply it by how strong i want the knockback to be???

rich adder
obtuse ether
#

oh

slender nymph
obtuse ether
#

so the code works

#

but instead of going away from the object

#

it ends up going torwards the object

#

i havent tested the code yet im just saying what would end up happening if i just kept the code as it was

slender nymph
#

remember that direction is calculated as (endPosition - startPosition) so if you want it to go away from this object, then this object's position would be the startPosition

obtuse ether
#

ah alr

obtuse ether
#

also how do u make ur text like that lol

slender nymph
#

`text here` to make text here

obtuse ether
#

Player.AddForce((collision.gameObject.transform.position - transform.position).normalized * KBForce);

#

ohhhhhhhh

#

tysm lol

primal cliff
#

would there be a reason I can't drag some text into the script component of an object's inspector? my script has using TMPro; at the top and this is what I'm trying to drag in, it won't let me. I've also double checked that it is a text mesh pro text I'm using & also tried to assign both the object & the text component

obtuse ether
#

gonna test out the code rq and see if this works thanks a lot to all of u who helped

#

i now half understand what im doing 💀

rich adder
primal cliff
rich adder
primal cliff
#

if it changes anything, I'm not using a canvas for it (please don't ask me why...) and I just have it in the scene as you would a typical object

rich adder
#

are you sure its a UI text

#

oh..

slender nymph
rich adder
#

so you need TMP_Text // this works for both ui and non UI as its base class

primal cliff
#

ah right

azure wraith
#

Which channel do I use to ask for code help

slender nymph
primal cliff
#

how would I rewrite it? Do I still keep using TMPro; at the top but just change the public TextMeshProUGUI into public TextMeshPro?

slender nymph
#

just change the variable's type to TMP_Text

azure wraith
#

I think its this channel then

slender nymph
#

it's the parent class for both TextMeshProUGUI and TextMeshPro so you can put an object of either of those types in it

azure wraith
#

ok

primal cliff
#

that's neat

#

I also just tried it and it works, thanks

obtuse ether
#

and it does knockback me

#

but like

rich adder
#

use ForceMode.Impulse

obtuse ether
#

it only happens like 1% of the time

obtuse ether
#

what does that do

slender nymph
#

yep, gotta make sure you're using the right forcemode. also make sure you aren't overwriting any force applied by assigning velocity each frame

azure wraith
#

I am making a simple movement system within 2D Core using Gameobject Circle and RigidBody2D

Whenever I click W, the circle doesn't move up at all. Why?

using UnityEngine;

public class PlayerScript : MonoBehaviour
{
    public Rigidbody2D PlayersRigidBody;
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W) == true)
        {
            //    Debug.Log("Player clicked double U");
            PlayersRigidBody.linearVelocity = Vector2.up * 10;
        }
    }
}
obtuse ether
#

just trying to understand all of this so i can use it in future projects

rich adder
# obtuse ether what does that do

basically its trying to get to apply all that force over time, in One physics frame, which isn't ideal. For that case something like Impulse is best cause it applies it all at once right away

obtuse ether
slender nymph
rich adder
slender nymph
obtuse ether
rich adder
#

its very handy

azure wraith
#

but ill try

obtuse ether
#

but like for osme reason

#

its always just making it go down?

#

and it doesnt react when you land from above???

azure wraith
slender nymph
#

note that your if statement only checks if the key was pressed this frame, so you should not see that log every single frame, only each time you start pressing W

azure wraith
#

Yeah I know, I did a debug.log within Update() and it sent a log every frame
I then removed that log and placed it into the if statement only.
Whenever I clicked W it did not send a log

slender nymph
#

do you have any errors in the console?

azure wraith
#

If you mean
⚠️
and or
🛑
then no

obtuse ether
slender nymph
#

wait, you said you had the Adaptive Performance package logging things every single frame. are you using the Device Simulator to test your game? because remember, android devices do not have a W key 😉

obtuse ether
#

you can just check Input.GetKeyDown(KeyCode.W) cant you?

obtuse ether
slender nymph
slender nymph
azure wraith
azure wraith
#

oh

azure wraith
#

let me try

slender nymph
#

obviously that wouldn't make any difference . . .

slender nymph
azure wraith
#

wheres gameview

slender nymph
#

it's the tab literally called Game

#

do you see that or the Device Simulator when you play the game

azure wraith
slender nymph
#

shocking, you're using the device simulator

azure wraith
#

Uhm, I was clicking W within scene

slender nymph
#

that doesn't matter

obtuse ether
#

😭

azure wraith
#

Do I need to download some random game viewer

slender nymph
#

the scene view is not what is collecting your input. it is just showing the current state of the scene so you can edit it.

obtuse ether
#

I was gone for a bit

slender nymph
obtuse ether
#

So the issue was he was in scene view not game view?

azure wraith
#

oh

#

so I realized I can switch it to game

#

let me try noooooooooooooooooow

slender nymph
azure wraith
#

🤞

#

it worked

#

yeah uh ignore that

obtuse ether
#

Never say that again

slender nymph
#

yeah let's keep the brain rot and reaction images out of here

azure wraith
#

Yipeee

#

next quetsion

#

if I can generate one

#

How can I check if a gameobject is standing on a floor

deep moon
#

how efficient is new input system compared to old one?

slender nymph
azure wraith
#

what

slender nymph
azure wraith
#

are raycasts fine

deep moon
#

that makes one much better than the other?

slender nymph
# azure wraith are raycasts fine

a raycast is an example of a physics query, yes. though it has no width so you might want something with more volume if you want more precise ground checks

azure wraith
slender nymph
# deep moon idk, like is there really much difference between them?

the differences are mainly in how they are used and the features they support. in my opinion the input system is much better and definitely worth learning over the old input manager, and that is because it has more ways to gather input, for example you can do event based input instead of manually polling for input in your own code, or you have the option of manually polling the input if you so choose. the input manager pretty much requires you to manually poll the input with no built in alternative so you either end up with worse looking code, or you end up reinventing the input system's event based approach for yourself 🤷‍♂️

deep moon
#

yeah, i just wanted to know cause idk which one is better, and also another issue i am having is that my character when it rotates, it goes back to its original facing direction when i let go wasd

#

and also for some odd reason, it isnt starting, its just performing and canceling

#

its so weird

#

my friend was tryna help me, and he didnt understand whats going on either

slender nymph
#

you'd have to show relevant !code

eternal falconBOT
deep moon
slender nymph
#

yes, that's what i said, isn't it?

deep moon
slender nymph
deep moon
slender nymph
#

read it and find out

deep moon
#

i just paste my code in there?

cosmic dagger
#

Hmm, thought I sent this a long time ago?

obtuse ether
#

And wow ig the variables were just not well named lol

cosmic dagger
obtuse ether
#

I just copied the code of the yt tutorial and they didnt really explain too much abt it so i could only rly guess

#

Based off of the var names

cosmic dagger
#

It's used for the rotation, but it's not actually the rotation. that the problem with that one . . .

slender nymph
#

another fun fact about that code: the Mathf.Atan2 is not necessary! Just assign the transform.right (or transform.up depending on it's "forward" direction when not rotated) to the direction (in this case the variable rotation)

cosmic dagger
#

It's not, haha. You can easily assign the direction (heading) to the object's forward-facing direction to skip all the calculations . . .

primal cliff
#

This script doesn't seem to work, any idea why? (I've used a log to check that the method is running) I did nothing in the animator except add the animation

rich adder
primal cliff
#

I removed the log, it was just above the script I showed in the image and it was just a string to let me know that the method with the script inside it is being called

#

so I think it's an issue with the way I wrote the animator.play thing

cosmic dagger
primal cliff
#

does it matter? I already said that the method which contains that line is being called, I think it's just a problem with that line

#

It's in the Attack() method called from this script

#

and it's being called correctly because I put a Debug.Log in Attack() before the animator.play line, there is also nothing else in Attack() method

#

ahh nevermind, turned out to be a problem with the way I was using the animator

cosmic dagger
primal cliff
cosmic dagger
#

I was just reading about it . . .

kindred iron
#
IInteractable interactableObj;

if (Input.GetKeyDown(InteractKey))
{
    if (hit.collider.TryGetComponent(out interactableObj))
    {
        AudioSource.clip = InteractAudio;
        AudioSource.Play();

        interactableObj.Interact();
    }
}

InteractText.text = interactableObj.InteractSentence;
InteractText.GetComponent<CanvasGroup>().alpha = 1;

**InteractText.text = interactableObj.InteractSentence; **
it gives error when i type like that this
but its ok when i write like this, why?:

IInteractable interactableObj;

if (hit.collider.TryGetComponent(out interactableObj))
{
    if (Input.GetKeyDown(InteractKey))
    {
        AudioSource.clip = InteractAudio;
        AudioSource.Play();

        interactableObj.Interact();
    }
}

InteractText.text = interactableObj.InteractSentence;
InteractText.GetComponent<CanvasGroup>().alpha = 1;
slender nymph
#

in the first example, what is the value of interactableObj when that first if statement is false

slender nymph
#

exactly, it hasn't been assigned, it's not even null, it's just unassigned. you can't use something that hasn't been assigned

#

now of course, you'll still get NREs if the hit object doesn't even have the relevant component on it, so your other code that uses that variable should also be within the if statement. then you can just inline the variable declaration instead of declaring it separately

kindred iron
#

but why the second one works

#

i didnt get it

slender nymph
#

because it is being assigned in that TryGetComponent call

kindred iron
#

with using out?

slender nymph
#

yes

kindred iron
#

oh ok tysm for the help

queen adder
#

for now i only have player object "balloon" which flies upward, however later on line i wanna do another character that moves downward rather than fly upwards. Users can choose what type of player to play "balloon" or something else(smthing that moves downwards

i dont wnat to get my player input or player objects to be a cluster fuck so i was thinking in the future to have all type of character scripts in this 1 player object and have a class to handle checking what have the user chose to play and as a result i disable all other script components for other characters and enable only the character that the user chose

Is this a good smart approach?

my bad for the terrible english. it has been a tiring day, I am just writing quickly

fleet venture
#

What is the best way to store and load a prefab?

#

just the name?

#

or is there some identifier i can use to also easily get it, seems hard to get it with the name. I would just use a dictionary but that appears to not be serializable

#

there arent that many objects i need to use this for so a dictionary WOULD work if it showed up in the editor

slender nymph
#

there are serializable dictionary assets you can get, but what is the actual purpose of wanting to get a prefab by its name? can you not just serialize the reference to the prefab in the component you need it in?

fleet venture
#

there is a few prefabs you can choose frmo and i need to store which one you chose in a database and load from it

fleet venture
#

is that the best solution?

keen rampart
#

why is it

#

flying

wicked pulsar
#

@keen rampart Can you comment out the following?

    {
        Suspension();
        GroundCheck();
        //CaculateCarVelocity();
        //Movement();
    }```
See what happens.
keen rampart
#

is still getting flinged

wicked pulsar
#

Okay. Try commenting out the entire FixedUpdate() method, then.

keen rampart
#

okay

wicked pulsar
#

First of all, this line: carRB.AddForceAtPosition(netForce * rayPoints[i].up, rayPoints[i].position); has me thinking about what "up" means when your car isn't right-side up. You're going to have bugs resulting from this line. Not sure it's relevant yet, but I wanted to point that out.

rich adder
rich adder
#

oh those arent wheel colliders?..nvm then

keen rampart
keen rampart
rich adder
#

yeah nvm that only worked for wheel collider

wicked pulsar
rich adder
#

it used to bounce if it was too light

#

yeah just realized its a raycast approach

keen rampart
rich adder
#

yea def check your pivot points then

obtuse ether
#

aaa i just want to ask abt smth

#

so i have a basic enemy move script

#

where it just moves forward until it goes into a trigger that makes it change direction

#

but i also want to add a radius around the enemy where if the player is inside, it will instead target the player

keen rampart
obtuse ether
#

so i just attached a collider to a empty

#

but now instead of changing direction when the enemy goes inside the trigger

#

it changes as soon as the view range touches the trigger

wicked pulsar
obtuse ether
wicked pulsar
# obtuse ether yeah

Check your project settings for the collision matrix. You may have some layers that shouldn't interact with each other.

obtuse ether
#

alright

keen rampart
obtuse ether
#

is that this?

wicked pulsar
#

I'm not using this in my project, so it being filled in won't be correct for you.

obtuse ether
#

alr found the 2D

wicked pulsar
#

Which layer are your player and enemy rigidbodies on?

obtuse ether
wicked pulsar
#

If everything is on default, everything will detect everything.

obtuse ether
#

ohhh

keen rampart
#

also if i leave the car body out the ray points also jsut

#

tweak out

obtuse ether
#

first time learning abt this lol

#

i think i know what to do now

#

just need to give them diff layers right

#

and then tweak how they interact w each other

rich adder
obtuse ether
#

so the layer of the detection can detect the player

#

but not the trigger that makes the enemy change direction

wicked pulsar
wicked pulsar
#

The simplest way around this is to have a child object of your enemy be on a separate layer.

obtuse ether
rich adder
obtuse ether
#

thanks a lot!

wicked pulsar
#

No problem. Also, disable everything in that matrix that you don't need - it'll save you CPU cycles. @obtuse ether

keen rampart
#

in the air

#

is like normal until it touches the floor

#

and then it just start to fling

rich adder
keen rampart
rich adder
keen rampart
rich adder
#

havent seen code but you should also put more debugs

keen rampart
#

this is the code btw

keen rampart
rich adder
keen rampart
#

it does turn red but it just

#

lol

rich adder
#

did you copy this from tutorial or something ? maybe you messed something in the suspension code or something

keen rampart
#

Learn how to create an arcade-style car controller in Unity! This tutorial covers suspension logic, offers valuable insights for game developers. Get ready to build your own unique controller for arcade racing games in unity.
#carcontroller #gamedevelopment #tutorial #unity3d

-------------------------------------------------------------------...

▶ Play video
rich adder
#

I would look over for anything missed

keen rampart
#

basiclly is just a temporary cube

rich adder
#

so sounds like you might've overlooked something

keen rampart
#

the suspension was working before hand

#

wait let me find

#

1s

rich adder
#

at which point did it break

keen rampart
#

wait hold on

#

i have the first part recorded

#

1s

keen rampart
#

this was like the first part of the tut

#

i had only done the

#

suspension part

#

nothing else

rich adder
#

check your accelerationPoint is correct first

rich adder
# keen rampart

I would double check if code is same. . is still broken when you only leave Suspension() ?

kindred iron
#

guys i wanna get the InteractAudioClip value if there is one in the IInteractable interface's script but idk how to do that, can yall help me?
Here's the code:

 IInteractable interactableObj;

 if (hit.collider.TryGetComponent(out interactableObj))
 {
     if (Input.GetKeyDown(InteractKey))
     {
         AudioSource.clip = DefaultInteractAudio;
         AudioSource.Play();

         interactableObj.Interact(); // Main Function
     }
rich adder
#

you mean inside interactable ?

kindred iron
rich adder
#

which classs

kindred iron
#

if there is no value which is called InteractAudioClip, it supposed play default pick up

kindred iron
#

should i send you to all code?

rich adder
#

what do you mean by

if there is one in the IInteractable interface's script
then

kindred iron
#

if (hit.collider.TryGetComponent(out interactableObj))

#

we get interactableObj

#

but i wanna get the script of this

#

interface

#

and this scripts InteractAudioClip sound

rich adder
#

that defeats the purpose of using the interface

kindred iron
#

wdym

rich adder
#

interface is so you just assured no matter which script implements it, you're guaranteed those methods / properties exist

kindred iron
#

so... why does it defeat the purpose of using the interface?

#

i didnt get it

rich adder
#

cause now you have look for a specific script

kindred iron
#

oh

#

so i cant take the script

#

right?

#

i have a question why IInteractable is a component and we try to get this componen then?

rich adder
rich adder
kindred iron
#

how tho

rich adder
#

in IInteractable put an AudioClip property
and you can check if the interactable provides that in the backing field

rich adder
kindred iron
#

what does "is"?

kindred iron
rich adder
scenic saffron
#

How do I change the distance of a vector by some amount

#

Found an answer

scenic saffron
rich adder
#
if(interactableObj.MySound != null) {
AudioSource.PlayOneShot(interactableObj.MySound); //play this sound instead```
kindred iron
#

then what should i write?

rich adder
#

leave it null

kindred iron
#
public class TakeFlashlight : MonoBehaviour, IInteractable
{
    public string InteractSentence => "Pick up Flashlight";
    public AudioClip InteractAudio { get; }
#

like that?

#

or

rich adder
#

basically

#

personally would probably use a separate component

kindred iron
rich adder
#

but that can be more work / abstraction

rich adder
#

I guess it depends

#

like every other thing

neon forum
#

For the Unity UI toolkit, what should I target in my script so that upon pressing a button, the UI will disappear?

kindred iron
kindred iron
#
public AudioClip InteractAudio => null;

Like that or...?

rich adder
kindred iron
#

or is it wrong?

rich adder
pallid heron
#

starting getting these warnings and I can't find anything about this online, anyone know what might be causing this?

dreamy moon
#

anyone know how to fix this error?

dapper mirage
#

Does anyone know why I can physically see the icon of the audioSource component on the gameObject in game?

zenith cypress
#

Gizmos button in the top of the game view toolbar

dapper mirage
#

Thank you :)

broken nest
#

Hey, I got this code

            Debug.Log(Mouse.current.position.ReadValue());
            Debug.Log(sliderCorner[0].x + "corn");
            Debug.Log(sliderCorner[2].x +"corn 2");
            Debug.Log(xPos);```
Somehow xPos is always equal to the sliderCorner[0] even though the mouse position is above that, I don't understand why that is especially since the code works on another project.
Any idea why that could be?
keen rampart
#

but now

#

whenever i drive

#

the car goes

#

crazy

#

😭

crystal bridge
#

Hello, any pros willing to help me in a thread or PM? I have some dialog script issues that was sorta working at first, but when trying to fix issues, I ended up getting less than what I had. It'll be a bit busy hence the request to do a thread/PM.

wicked pulsar
crystal bridge
#

Dialog Disaster XD

dapper mirage
#

For some reason, the code here never gets run

{

    if (collision.gameObject.tag == "Player")
    {
        touchedPlayer = true;

        if (audioSource != null && !audioSource.isPlaying)
        {
            audioSource.PlayOneShot(roar);
        }
        rb.velocity = new Vector3(0, 0, 0);
    }
    else
    {
        Debug.Log("collided with something");
    }
}```
I want the trigger to run this code when the player touches it but the debug.log never happens
dapper mirage
#

works now

rich adder
queen adder
dapper mirage
#

oh nice theres a function for that

#

thank you

rocky canyon
#

i'd also try using lower values and see if that makes any difference.. or atleast slows it down enough for u to visually see whats going wrong

keen rampart
#

i just realized

#

i forgot to freezethe x and z rotation lol

rocky canyon
keen rampart
rocky canyon
#

if u want the cars front end to raise and dip from torque

#

you can get by by tilting the graphics

#

(in local space)

keen rampart
#

since the back tire

#

are floating

#

if i go on a ram

rocky canyon
#

should be able to get the tire to just clip into the ground

keen rampart
#

okay

#

i will try that

rocky canyon
#

u can always scale up the wheels too 😉

#

the graphics ofc

keen rampart
#

ye

#

ok

rich adder
#

you have over a thousand errors

azure wraith
#

I accidently made a gameobject particle system that is supposed to look like dust effects when the player leaves the ground, are there ways to convert it to a component or am I cooked

queen adder
azure wraith
#

what

queen adder
#

The gameobject isnt a particle system itself, it has a particle system component on it

azure wraith
#

the system is inside the player, but it isnt a component