#💻┃code-beginner

1 messages · Page 180 of 1

languid spire
#

low-end pc is a pain but, tbh, I would rather run a Windows VM on Mac or Linux so I can use VS than suffer the pain that is VS Code

rugged bronze
#

im not sure how to put it since im new to unity but like how do i replace the model in general

languid spire
#

!Code, you should know better by now

eternal falconBOT
rugged bronze
#

mb

cunning rapids
fierce shuttle
languid spire
cunning rapids
#

VS community is free tho right?

languid spire
#

yes

cunning rapids
#

That's more than enough for an Indie dev

languid spire
#

sure

cunning rapids
#

VS and Unity are basically a match made in heaven

languid spire
#

god help the poor Mac devs when VS for Mac depreciates

cunning rapids
#

VSC is good for some coding projects due to its MASSIVE extension store but looking at a Unity standpoint, VS is the clear winner

#

Having a full IDE that is already configured to the game engine is just more productive

timber tide
#

I like naked vs code as an ide

#

for shaders

cunning rapids
#

Is this it?

#

It's that easy to configure VS for Unity?

rare basin
#

!ide

eternal falconBOT
languid spire
#

There was an Eclipse plug-in many, many years ago, I wonder what ever happened to that

languid spire
cunning rapids
#

Damn

#

I've been using configured VSC for small projects

cinder spruce
#

Hello, i want the health value to be same with the max health value when i reload the screen. I decrease the maxHealth value by 10 when i clik a button. health should be equlized with maxHealth on start method in the playerHealth script. In short when i decrease the maxHealth, health value should be the same value as it is
This is StatsExchangeMenu script:
https://pastebin.pl/view/6522f52b

This is playerHealth Script:
https://pastebin.pl/view/e0dfa96a

cunning rapids
cinder spruce
#

when i exit run time and hit play again, the values are equlized

languid spire
cunning rapids
#

I'm good with computers

#

I guess?

#

Not a good programmer tho, evidently 😅

verbal dome
#

I would use Visual Studio but it just doesn't like my hardware I guess. Constant freezes and slowdowns so I settle with VSCode
And I have a decent PC, mid-high tier

cunning rapids
#

Although I think for VS you need the VS package from the unity editor you're using

cunning rapids
cunning rapids
#

Idk how to install it

verbal dome
cunning rapids
#

Specs?

timber tide
verbal dome
cunning rapids
#

DDR4?

languid spire
verbal dome
#

My project is pretty huge though and it did complain about that at some point. Should try with a new project maybe and see if it makes a difference

cinder spruce
cunning rapids
#

Your specs should be more than enough 😭

languid spire
cunning rapids
#

Evidently not

languid spire
timber tide
#

im at 16 too and unity + vs + windows is like 12 gigs, I'mma need to upgrade my stuff soon

cunning rapids
#

What packages are y'all installing tf

languid spire
cunning rapids
#

It's fine

#

I'll clear out my extensions and configure VSC if things go south

#

Just like I did last time

verbal dome
#

My main issue with VS was opening the search menu in some files just made it freeze or ultra slowdown

cunning rapids
#

Had lot of bloatware floating around anyway

languid spire
#

double your memory, you will see the difference believe me

cunning rapids
#

I can buy a new one but this works just fine

timber tide
cunning rapids
#

And titles like TF2 which is my favorite shooter

verbal dome
cunning rapids
cinder spruce
# languid spire all of it

Daamn, it worked! God i have been working on this for hours. I can't thank you enough man, you always help me. I really appreciate it 🙏

turbid lantern
#

does anybody knowhow I can access the properties of a rigidbody through the script?

turbid lantern
cunning rapids
#

Team Fortress 2

timber tide
languid spire
cunning rapids
turbid lantern
cunning rapids
#

Amazing storyline tho

turbid lantern
#

anyway how do I access the properties of something through a script?

#

like the drag of a rigidbody

verbal dome
turbid lantern
#

I have that

#

I just dont know how to access the properties under it

verbal dome
#

rigidbody.mass = 123; for example

#

Nothing special about it

#

(You replace rigidbody with your variable name here ofc)

thorn iron
#

So the manager doesn't need a GameObject and can do FixedUpdates?
Well, the List<Something> instances will be changed throughout the game, so I need to add and delete some instance.

For the time, I thought something like this?
I wish that every class that inherit Entity, would FixedUpdate their list of buff (buffs)

public abstract class Entity : MonoBehaviour
{
    public Buffs buffs;

    public virtual void Awake()
    {
        buffs = null;
    }

    public void FixedUpdate()
    {
        buffs.UpdateBuffs();
    }
}


public class Stella : Entity
{
    // Start is called before the first frame update
    public override void Awake()
    {
        buffs = new Buffs(...);
    }

}


public class Buffs
{
    public List<Buff> buffList;

    // Constructor
    public Buffs( ... )
    {
        buffList = ...;
    }
    
    // Method
    public void UpdateBuffs()
    {
        ... // I decrease a TimeValue by 1 for each buff.  
    }
}
turbid lantern
#

alr thnx

verbal dome
#

So it will indeed update its buffs list

verbal dome
#

Your intellisense would've probably already loaded if you had more RAM

short hazel
#

Given that Windows itself recommends having 4gb for its own OS, you're in for a bad time with win11

languid spire
cunning rapids
verbal dome
#

Disk at 56%

fickle plume
#

@cunning rapids No off-topic media, please

cunning rapids
#

All good 😅

#

Anyways, my case is getting pretty hot

#

VS works fine but I'd rather use VSC

#

!code

eternal falconBOT
cunning rapids
#

Maybe check whether the panel is activated for the first time or if it's being reactivated

#

You can use a bool flag

#

ensure that the targetPosition is set only during the first activation of the panel, and subsequent activations will retain the existing targetPosition

cunning rapids
#
private bool FirstActive = true;

private void OnEnable()
{
    InitializeScrolling();
}
private void InitializeScrolling()
{
    if (isFirstActivation)
    {
        targetPosition = contentPanel.anchoredPosition;
        FirstActive = false;
    }
}
lucid patio
#

it seems like the snap functionality is not being properly reinitialized when the panel is activated for the second time.

cunning rapids
lucid patio
#

Would images help?

cunning rapids
#

Images, videos

#

ANything

#

Besides there are some much more seasoned veterans here that can help as well 😭

#

I'm not the best when it comes to coming up with solutions

honest haven
#
    {
        if (_target)
        {
            Debug.Log("Player found");
            Vector3 direction = (_target.position - transform.position).normalized;
            float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
            Quaternion rotation = Quaternion.Euler(0, angle, 0);
            _rigidbody.rotation = rotation;
            moveDirection = direction;
        }
    }

    private void FixedUpdate()
    {
        if (_target)
        {
            _rigidbody.velocity = new Vector3(moveDirection.x, moveDirection.y, moveDirection.z) * moveSpeed;
        }
    }``` trying to make an npc follow player. the npc does rotate but does not move
cunning rapids
#

Oh damn

#

Sorry man I don't really know how to help witht his issue

#

I'll try think of something

#

Although I think some people here would notice the problem and help as well

#

Just not many active rn

potent garnet
#

How do you make the rotation radius smaller when using the RotateAround method?

honest haven
#

Thanks

gray lintel
#

How do i make any gameobject instantiated from default tiles to save changes made to them during edit mode? I am able to instantiate gameobject using tiles in the tilemap and rotate them using "GetInstantiatedObject(position)" but when i go into play mode those changes are neglected, i think it is because it re-instatiates the gameobject and thus removes any changes made to it. I though of instantiating them using the prefab itself but i heard that it would be less performant, especially when dealing with a large amount of gameobjects which is the case. If more info is needed i can provide

summer stump
gray lintel
#

thank you for the help, i am not claiming, i am a little confused about how this works hence why i am having trouble, i also am having trouble finding more information about it to educate myself

rich egret
#

HI! its possivel to set tag to image??

rare basin
#

you set tag to game objects

#

image is a component that is assigned to a game object

shy ruin
#

Can anybody help with me with making a random maze generation system, I could acomplish this, but I also need some random rooms placed in the maze, like maybe a office room, or a big courtyard. I just can't figure out how I would put it down in the maze, get rid of walls that are overlapping it, and connect it by doors. Can anybody please help?

rare basin
#

ask exact questions

shy ruin
#

Ah, let me make it exact, how I would I place rooms in a maze without them overlapping?

rare basin
#

in what meaning overlapping

#

offset each room position

#

so they dont overlap

shy ruin
#

So, I have a maze right, and I need to like slap down a courtyard in the middle, and of course that would overlap the maze walls, so how would I fix that?

gray lintel
livid oracle
#

cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LogicScript : MonoBehaviour
{
public float playerScore;
public Text scoreText;

[ContextMenu("Increase Score")]
public void addScore()
{
    playerScore = playerScore + 1;
    scoreText.text = playerScore.ToString();
}

}

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

public class PipeMoveScript : MonoBehaviour
{
public float speed;
public float deadzone = -70;
public LogicScript logic;

// Start is called before the first frame update
void Start()
{
    logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}

// Update is called once per frame
void Update()
{
    transform.position = transform.position + (Vector3.left * speed) * Time.deltaTime;

    if (transform.position.x < deadzone)
    {
        Debug.Log ("Pipe Deleted");
        Destroy(gameObject);
    }

    if (logic.addScore())
    {
        speed = speed + 0.2;
    }
}

}

//I am getting 2 errors (cannot convert void to bool and cannot convert double to float) can someone help me fix this?

eternal falconBOT
rare basin
#

is your IDE configured?

#

your errors should be highlilghted in the iDE

livid oracle
rare basin
#

if (logic.addScore()) i assume addScore() is a void type function

#

and you are using it like a bool function

livid oracle
rare basin
summer stump
deep quarry
#
Vector3 startPos = new Vector3(transform.position);

Why do I get the 'Vector3' does not contain a constructor that takes 1 arguments error? Isn't transform.position a Vector3?

#

nvm, i am dumb

#

Vector3 startPos = transform.position; obv

west sonnet
#

I have a method that's being called on a Collision Trigger. Is it possible to stop the method from being played again while it's playing, even if there is another collision trigger?

Basically, I've got an enemy that can punch. The enemy will detect when the player is in front of them, but I don't want the player to be able to punch again when it is mid-punch

west sonnet
rare basin
#

you should have some bool determining if enemy is already being punched

#

or not

#

and only apply punch logic, if he isn't already punched

faint osprey
#

how do you instantiate something so that it doesnt become a child of the transform you want it to instantiate at

rare basin
faint osprey
rare basin
#

you can pass position as a parameter

#

public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);

gray lintel
# summer stump Then pooling is not necessary. You brought up performance and instantiating many...

yea i did as an alternative instead of using tiles, because i really wanted it to work as tiles instead because everything else i coded using tiles and it would be an hassle to have to change things just for the gameobjects but if that is the case then i guess i will have to not use tiles or custom tiles for the gameobject instatiation and instead do the normal gameobject instatiation way using my custom brush.

faint osprey
rare basin
faint osprey
#

spawnedBullets.Add(Instantiate(bullet, new Vector3(spawnPos.position.x, spawnPos.position.y, spawnPos.position.z), Quaternion.Euler(0, 0, 180)));

rare basin
#

it's not parenting anything there

#

so the parenting happens in other place

#

you can just do spawnPos.position btw

#

instead of breaking it to new Vector3(x,y,z)

tender hound
#

how do i resize gameobjects to screen size? i have a static board which i draw on the tilemap but i wanted to make it playable for tablet and phone or do i need to make different games ?

summer stump
tender hound
rare basin
#

idk, not in code

tender hound
rare basin
#

but it is the wrong channel, so wdym @tender hound

warm anvil
#

Good afternoon Fen. Quick question for you on these two pieces of code you have. Are you using the Player Input component and if so, are you setting the Behavior to Unity Events or C# Events. Thanks

rare basin
#

via unity events or c# events

gray lintel
# summer stump Then use tiles, cache it, and read the values from it. I'm confused

Ok, so i paint the tiles using my custom brush, then i rotate the gameobjects that each gameobject tile instatiates during edit mode because it is way more efficient than having all the tiles orientations, but the rotations dont apply in play mode, it only works in edit mode. You keep telling me to cache it and read the value, in this situation where do i do that? In my custom brush?

west sonnet
#

In Unity2D, what would be the best way to create an punching animation? It's on a person that doesn't have arms, so just a floating hand, Rayman style

summer stump
west sonnet
warm anvil
#

@swift crag Based on other reading I'm doing as well, your code rather sounds like it was fit for Unity Events. The two pieces of code you provided seem to be two separate pieces of a jigsaw puzzle so I'm sure there's parts that don't link together or demonstrate how the event is fired was all so I figured I'd ask

rare basin
#

no

summer stump
west sonnet
#

It's 1 sprite and it would be a hand flying towards and backwards from the player

gray lintel
west sonnet
#

The fist is a seperate object to the body

rare basin
west sonnet
#

My bad

rare basin
#

i'd just use DOTween

short hazel
summer stump
rare basin
#

in your Punch() method or whatever you have, just move the object that is supposed to be punched

#

DOLocalMove(endPosition, duration)

#

you can then assign stuff like

warm anvil
rare basin
#

DOLocalMove(endPosition, duration).OnStart(() => isPunching = true).OnComplete(() => isPunching = false);

west sonnet
#

This is what my game is going to be like. The hands rotation follows the players position. Ignore the hand flying forward when it touched the player, it's not meant to be like that

short hazel
west sonnet
#

Hmmm okay, I'll give it a go. Thank you

cunning rapids
#

Yo guys is dotNET SDK 8.0 active?

short hazel
#

Not for Unity

west sonnet
rare basin
#

then your endPosition is wrong

cunning rapids
rare basin
#

remember that's it's local position, not world

west sonnet
#

I created a SerializeField, put my player into it and then as my endPosition, I put player.transform.position

rare basin
#

That is world position

west sonnet
rare basin
#

And you are using local move function

west sonnet
#

Ooh okay

rare basin
#

DOMove, DOLocalMove

cunning rapids
#

Guys what the hell

short hazel
# cunning rapids Why not? Also, if not, what SDK environment should I use?

It's just not supported. Unity uses the old Mono backend. Work is in progress to get it working with the Core CLR which modern .NET runs on.
If you're configuring your code editor, follow the guide.
If you're making a managed plugin (DLL), the documentation has instructions on how to create a compatiable one

cunning rapids
#

I installed .NET SDK 6.0 but the folder didn't appear in the C:\Program Files (x86)\dotnet\shared\ folder

#

Only 5.0.something

#

Wait I'll try to repair the installation

swift crag
short hazel
swift crag
#

Oh, I was thinking about the wrong code.

short hazel
#

You're stuck with .NET Framework 4.8 (max) or .NET Standard (2.x)

cunning rapids
cunning rapids
#

I'm trying to reconfigure VSC

swift crag
west sonnet
#

I'm getting this weird behaviour now. I'm guessing it's because the hand is parented to the body and when the body moves, it goes weird?

short hazel
cunning rapids
swift crag
cunning rapids
#

I installed it through the link

short hazel
#

A restart or logout/login is required to apply changes made by the installer

#

Once done, run dotnet --list-sdks in the command line to list installed versions

cunning rapids
#

This is my directory of the .dotnet folder

cunning rapids
#

On the computer?

short hazel
#

Of course

#

What else would you want to restart, your microwave?

cunning rapids
#

That's... pretty fucking stupid

cunning rapids
short hazel
#

Once it's installed

#

Tha PATH is updated and a reload is needed

summer stump
cunning rapids
summer stump
#

Or the restart does it automatically

short hazel
#

.NET is not installed in your user folder

#

It's in C:\Program Files\dotnet\sdk

#

But using the command line to check is easier

cunning rapids
#

I see them

earnest atlas
#

Im confused? whats it is complaning about?

[SerializeField] private GameObject _heartPrefab;
[SerializeField] private GameObject _gemPrefab;
public int MaxHealth = 3;
public int CurrentHealth;
private readonly int _score = GameController.Instance.Score;
private int _scoreMemory = 0;

private void Start()
{
    CurrentHealth = MaxHealth;
    CreateHearts();
    
}```
half patrol
#

is

private GameObject attack;

same as

private GameObject attack = default;

?

warm anvil
#

is
private readonly int _score =
correct?

short hazel
earnest atlas
#

No it shouldnt?

#

Its created before Health object

short hazel
#

That's pretty much the only line that could cause the error

earnest atlas
#

Yeah I moved it to a different place and now its fine

short hazel
#

Show how GameController's Instance is made

earnest atlas
#
private static GameController _instance;
private bool _isPaused;
public PlayerControls PlayerControls;
public int Score = 0;

void Start()
{
    PlayerControls = new PlayerControls();
}
public static GameController Instance
{
    get
    {
        if (_instance != null) return _instance;
        var gameControllerObject = new GameObject("GameController");
        _instance = gameControllerObject.AddComponent<GameController>();
        DontDestroyOnLoad(gameControllerObject);
        return _instance;
        ```
honest haven
short hazel
#

new GameObject("GameController")

#

Unity doesn't like when you do that in a field declaration. Accessing GameManager.Instance runs the code in the get, which creates the object if that's not been done yet

cunning rapids
#

So the joke's on you

#

Because my laptop is already a microwave in on itself

short hazel
#

Sure with enough voltage you can make anything emit pretty nasty EM waves

cunning rapids
#

Wouldn't be very healthy though

short hazel
#

But it's out of scope of this Unity server

cunning rapids
#

For crying out loud

#

I already reinstalled

#

I checked the directory and it did in fact have the required SDKs

#

I'll try manually changing PATH

short hazel
#

Spelling mistake

cunning rapids
#

First command, yes

#

Check the first screenshot

#

Didn't output anything

#

Alright should work now

#

Let me check

#

I'm making progress

#

@short hazel Progress. It's a different error now :)

#

Kill me

frosty hound
cunning rapids
short hazel
#

Who knows? Did you check the first error about the nonexistent path?

ornate olive
#

what should i use to replace time.deltatime

rare basin
#

there is no replacement for that

cunning rapids
rare basin
#

do you know what is time.deltatime?

#

you can use unscaled delta time

cunning rapids
#

deltaTime calculates time in between frames

#

Time is fixed

ornate olive
#

he told me lol idk

honest haven
#
            _rigidbody.velocity = new Vector3(velocity.x, _rigidbody.velocity.y, velocity.z);``` what can i do about this the longer he chases me the faster he gets i want his speed to be constant to what i set moveSpeed too
cunning rapids
rich adder
rare basin
#

i know what it is

rich adder
cunning rapids
rich adder
#

also gpt script UnityChanNo

ornate olive
rich adder
# ornate olive thx

ideally you want to only grab inputs in Update and carry over to FixedUpdate

honest haven
rich adder
wintry quarry
rich adder
#

you prob aren't normalizing the moveDir

#

yup

honest haven
#

sorry cat turn pc of 2 secs

#

should have got a case with power button on its side lol

#
    {
        if (_canChase)
        {
            Vector3 direction = (_target.position - transform.position).normalized;
            float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
            Quaternion rotation = Quaternion.Euler(0, angle, 0);
            _rigidbody.rotation = rotation;
            moveDirection = direction;
        }
    }

    private void FixedUpdate()
    {
        if (_canChase)
        {
            Vector3 velocity = moveDirection * moveSpeed;
            _rigidbody.velocity = new Vector3(velocity.x, _rigidbody.velocity.y, velocity.z);
            SetAnimationState("Run");
        }
        else
        {
            _rigidbody.velocity = Vector3.zero;
            SetAnimationState("Idle");
        }
    }```
rich adder
#

they're unstoppable, one time my cat tipped a whole arizona ice tea can onto my desktop

#

funtime

cunning rapids
#

I have c# but not omnisharp?

honest haven
#

i normalized the rotation under update. do i need to also do it on the velocity?

rich adder
cunning rapids
rich adder
faint osprey
#

how do i set a gameobjects velocity relative to its transform.right

cunning rapids
rich adder
cunning rapids
#

I use vsc

rich adder
#

I get it

cunning rapids
#

So what do I do

rich adder
#

!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

rich adder
#

make sure you did all the steps

short hazel
#

Latest C# extension does not use Omnisharp anymore, it's based on the C# Language Server which comes with the extension itself

cunning rapids
#

This one?

rich adder
#

yup

cunning rapids
#

Oh thank God

honest haven
cunning rapids
#

I was about to have a panic attack

rich adder
honest haven
#

no slowly speeds up over time.

cunning rapids
rich adder
honest haven
#

also shakes or vibrates as it runs which is weird

cunning rapids
rich adder
honest haven
#

yes

rich adder
cunning rapids
rich adder
#

ok so install it

cunning rapids
#

ALl of them

rich egret
#

Someone know how to do GetComponen but with ScriptableObject??

rich adder
cunning rapids
#

Through unity?

#

Or...?

honest haven
cunning rapids
rich adder
rich egret
#

Someone know how to do GetComponen but with ScriptableObject??

languid spire
frosty hound
cunning rapids
cunning rapids
#

You're right

#

Can't believe I din't notice that

rich adder
#

you just need .net sdk 8

cunning rapids
#

Such a simple mistake

cunning rapids
#

I already have that installed

rich adder
#

no need to get previous ones

#

alr jus grab sdk .net 8 then

honest haven
cunning rapids
rich adder
#

did you try without Y rot frozen?

#

i think it might be fighting the code

#

also rigidbody should be rotate with MoveRotation/rb.Rotation/AddTorque

cunning rapids
#

I uhm

#

Already did that...

rich adder
#

make sure it says SDK

#

restart PC after

cunning rapids
rich egret
rich adder
ornate olive
#

how do i fix this

cunning rapids
rich adder
rare basin
rich adder
cunning rapids
#

I'll try again

rich adder
rare basin
#

sorry for the ping

frosty hound
ornate olive
cunning rapids
rich adder
cunning rapids
eternal falconBOT
cunning rapids
#

Classic syntax error

#

Anyways @rich adder just restarted my pc

#

dotnet seems to be working fine

rich adder
#

ok so its install

#

do dotnet --list-sdks

#

so we make sure

warm condor
#

Hey, I know that I can set the peramater in the animator by unisng functions like Animator.SetBool, but is there a way I can see if I that peramater is true or false if it is a boolean or saving a value within the peramater into another value?

cunning rapids
#

Same error

rare basin
#

GetBool()

rich adder
rich adder
rich adder
frosty hound
#

Great

rare basin
warm condor
cunning rapids
warm condor
cunning rapids
rich adder
cunning rapids
#

Yup

rich adder
#

hmm are you sure SDK was installed

rich egret
frosty hound
#

!mute 981301314527035433 10d Instead of a ban, you get a mute.

eternal falconBOT
#

dynoSuccess hacking69 was muted.

cunning rapids
rich adder
cunning rapids
#

Elaborate

rich adder
#

ima gonna make a thread so we dont flood

cunning rapids
#

Very fair

rich adder
#

VSCode Config

earnest atlas
#

How to call on Trigger for 2d circle?

Also does it has OnTriggerEnter2D and OnTriggerExist2D?

languid spire
earnest atlas
#

So far looked it up and not sure if it works with it.

Atm trying to understand how to make Box Collider only trigger on Layer with player

languid spire
#

2D Sphere? Does such a thing even exist?

earnest atlas
earnest atlas
#

Yeah tired atm

cunning rapids
#

OnTriggerEnter2D works

#

For triggers...

earnest atlas
#

Its apparently the only one so this why I couldnt find specifically for circle

cunning rapids
#

I'm pretty sure there aren't triggers for specific shapes bud

#

A trigger is a trigger

rich adder
#

yup

#

as long as it matches the collider being either 2D or 3D
eg
OnTriggerEnter2D for 2D colliders set as trigger, obv
OnTriggerEnter is for 3D colliders set as trigger.

cunning rapids
#

OnCollisionEnter2D and OnCollisionEnter are for 2D and 3D colliders that aren't triggers, respectively

earnest atlas
#

Whats better trigger or collision enter?

rich adder
#

they do different things

polar acorn
cunning rapids
#

Nothing is objectively better

#

They have different fundamental uses

earnest atlas
#

Trigger is enough to make kill objects

#

I want something that detects player in some radius

#

Activly

cunning rapids
#

You can't PHYSICALLY collide with triggers

#

You can go through them

earnest atlas
#

Yeah I know that

rich adder
#

Trigger is enough to make kill objects

cunning rapids
earnest atlas
#

Yeah Ive got the idea, on trigger then with raycast

late burrow
#

how to trully determine if its better to use list of array

rich adder
earnest atlas
#

Btw if I want real time transform data from different object, how should I do it? Just GameObject.Find?

late burrow
#

i dont know what changes what

earnest atlas
#

Or is there better way>

late burrow
#

i have option of making either 2 same arrays or 1 list

uneven nacelle
#

If I have a script to place an object to my cursor and a script when I click on an object to open a panel.

How can I get rid of the situation to open the panel when I place the object?

languid spire
late burrow
#

one array just to determine size

earnest atlas
late burrow
#

one for actual array

#

or i can just keep adding to list and have just one

rich adder
earnest atlas
#

Shouldnt scene load delete all object on previus scene?

frosty hound
late burrow
#

yes but is changing size 1000 times wont be less optimal than just 2 arrays

polar acorn
#

Show code

#

Full !code

eternal falconBOT
polar acorn
#

static

#

static variables exist forever, shared between all instances

#

It doesn't matter how many Finish scripts you have on how many scenes, a static variable is created once and shared between everything forever

#

absolutely not

cunning rapids
#

@polar acorn can you join a thread I need help configuring vsc but navarone is offline

polar acorn
#

don't use static unless you actually have a good reason why

eternal falconBOT
cunning rapids
#

with .NET

polar acorn
#

It has to be public to be accessed outside of the class

#

static is a completely different thing

#

not static

#

So reference the object properly

#

Tell it which Finish you want to change the levelCompleted of

#

You need to tell the code which Finish you want to access the value of

#

each one has its own copy of the variable

warm anvil
#

Back to my computer now. So if you don't mind me asking a few questions regarding Unity's new input system and Events

I'll start at the high-level then I can dig a little deeper to create a learning foundation.

When you add the new input system and add the Player Input component and decide at this point: Should I use Invoke Unity Events vs. Invoke C# Events in Behavior area (the attached picture). Is the choice basically "do you want to define the code and mapping of methods and events in the Unity Editor vs. directly in the code?"

polar acorn
#

What do you mean by "what type of reference"

queen adder
cunning rapids
#

A reference just refers to an object in your project

#

Hence the name

warm anvil
cunning rapids
#

But... do you know what a Serialized reference is?

queen adder
#

Well yes whats ur question? Sorry I prolly missed it

polar acorn
#

Those are many different ways to reference things

#

use whichever one fits your situation

cunning rapids
#

Basically means you can assign private variables through the inspector

warm anvil
queen adder
#

Yes it's up to you?

warm anvil
#

aka is your practice to drag and drop objects and work more in teh editor vs. directly mapping it in the code rather than the editor

queen adder
#

Are you asking what most ppl use?

warm anvil
#

not necessarily what other people do but more direct about what that choice overall decides

earnest atlas
#

getComponentInChildren will get component of parent object or not?

I want access to animator to change animation

queen adder
#

Unity events use drag and drop via editor while the Invoke C# events will make you use code?

warm anvil
#

pretty much

queen adder
#

Yeah it's up to you

#

You just pick a option for the "Behaviour" and go from there

earnest atlas
#

I didnt actually need that cause I forgot the script Im working in is inside correct object

queen adder
#

If ur looking for where the events are for "invoke unity events" click on events right under the Behavior option on Player Input

warm anvil
#

ty. yup, that's pretty much the area that I'll reference next. As I mentioned, I'm starting slow to build a solid foundation of knowledge on it while getting comfortable with syntax especially when it comes to Events.

So moving a little deeper...

#

So if a tutorial to implement some feature shows they were using Invoke Unity Events (and had the mapping setup in the editor in the area you mentioned) and let's say I preferred (for now particular reason) to keep in the C# Events as the behavior choice.....

queen adder
#

It won't change anything

#

It's the same thing

earnest atlas
#
public void Detected() => _triggeredByPlayer = !
_triggeredByPlayer;

Is there better way to flip true and false?

warm anvil
#

Are the basic steps to "convert" from Invoke Unity Events to C# Events to have a reference to the Input system (mine happens to be called InputActions and to have at least these three methods to translate it?

    private InputActions _input;

    private void OnEnable()
    {
        _input = new InputActions();
        _input.Humanoid.Backpack.performed += HandleBackpack;
        _input.Humanoid.Enable();
    }

    private void OnDisable()
    {
        _input.Humanoid.Backpack.performed -= HandleBackpack;
        _input.Humanoid.Disable();
    }

    public void HandleBackpack(InputAction.CallbackContext context)
    {
        print(context.phase);

        if (context.performed)
        {
            print("Attack performed");
        }
    }
queen adder
#

Show the whole class

#

And that doesn't look right to me

warm anvil
#

me?

rare basin
#

dont use print

queen adder
#

Yes spring

rare basin
#

use Debug.Log

queen adder
#

It's the same thing

rare basin
#

no its not

warm anvil
#
using UnityEngine;
using UnityEngine.InputSystem;

public class InputSystemController : MonoBehaviour
{
    private InputActions _input;

    private void OnEnable()
    {
        _input = new InputActions();
        _input.Humanoid.Backpack.performed += HandleBackpack;
        _input.Humanoid.Enable();
    }

    private void OnDisable()
    {
        _input.Humanoid.Backpack.performed -= HandleBackpack;
        _input.Humanoid.Disable();
    }

    public void HandleBackpack(InputAction.CallbackContext context)
    {
        print(context.phase);

        if (context.performed)
        {
            Debug.Log("Attack performed");
        }
    }
}
queen adder
#

Yall be worried about such small details for no reason

rare basin
#

it's not a small detail 😉

#

you don't have a call stack with print

#

just an empty console message

queen adder
#

Oh OK thanks for the information 👍

warm anvil
#

but more or less those three methods are what it takes to convert from Invoke Unity Events vs. C# [and doing it yourself in code], right?

queen adder
#

I normally get a reference to play input and get the input actions from that

#

I'm on my phone so I might type this wrong

warm anvil
#

mind giving me an example please?

queen adder
#

I'm gonna code it give me one second

polar acorn
queen adder
#
PlayerInput playerInput = Getcomponent<>();
InputAction action = playerInput.Actions["ActionName"]
}```
polar acorn
#

They're identical

queen adder
#

Documentation for the win!!

rare basin
#

thought its pure c# method

#

didint know unity overrides it

summer stump
#

The only difference is that print doesn't expose the second parameter of Debug.Log

slender nymph
scarlet skiff
#

ok so if i have too many things of the same type collide with an object, it doesn't run its OnColliosnEnter method sometimes, what can I do to approach this?

queen adder
#

Did that help? @warm anvil

rare basin
#

so why did they split it into print and debug log

rare basin
#

couldn't just keep one?

scarlet skiff
slender nymph
scarlet skiff
#

or thats the explanation i can come up with

polar acorn
scarlet skiff
#

well there is an if statement in there that doesnt have Destroy() in it, but i check there is no way the condiotons are true, just in case i removed it now and ill try and see

warm anvil
# queen adder Did that help? <@266990656122126357>

allow me to ask a couple follow-up questions so it sinks in.

What I typically notice when people place a GetComponent in the Awake method is so they don't need to click-drag that component in the Editor. Is that what the first line is accomplishing?

PlayerInput playerInput = Getcomponent<>();

slender nymph
warm anvil
#

If so, not sure I've seen it in that specific syntax

#

it might not be typed to what I'm used to since you said you were on your phone

true heart
#

if im using a list of prefabs to spawn things in and using the number where an item is as there id how can i then later using a prefab that was spawned in know what id they have?

queen adder
#

You have to reference PlayerInput

visual hedge
#
            for (int i = 0; i<StatusList.Count; i++)
            {
                    var go = Instantiate(BuffIcon, target.ui.BuffPanel.transform);
                    go.GetComponent<Image>().sprite = StatusList[i].SkillIcon;
            }

Let's say I have 5 instances of those BuffIcons, right? What is the best way to remove exactly the one I need to remove?
Doing buffs system and well, basically displaying the buffs above the hero head, when certain buff expires, it's icon shall disappear from the buff display above the head.
As far as I understand, the method above doesn't actually keep track of the object it instantiated. So I guess I have to somehow mark / name / etc the instantiated thingie for it to be able to be targeted, right?
So, please, any efficient suggestions?

polar acorn
queen adder
#

And yes that syntax is wrong

polar acorn
queen adder
#

PlayerInput playerInput = GetComponent<PlayerInput>();

timber tide
#

embrace dictionary

queen adder
#

You just need to add the type

#

@warm anvil

warm anvil
visual hedge
timber tide
#

iterate

polar acorn
true heart
rich adder
#

as a basic

polar acorn
rich adder
#

the only shite is that Unity doesn't serialize them

#

you cannot view them in inspector without workarounds

warm anvil
# queen adder You just need to add the type

How about this line you said:

InputAction action = playerInput.Actions["ActionName"]

Is the the purpose of that and does that potentially replace one of these three methods in my code?

    private void OnEnable()
    {
        _input = new InputActions();
        _input.Humanoid.Backpack.performed += HandleBackpack;
        _input.Humanoid.Enable();
    }

    private void OnDisable()
    {
        _input.Humanoid.Backpack.performed -= HandleBackpack;
        _input.Humanoid.Disable();
    }

    public void HandleBackpack(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            Debug.Log("Attack performed");
        }
    }
west sonnet
#

I've got this bit of code here which I'm using to get the enemy to punch the player. How can I get the enemies fist to return after being pushed into the player?

#

Right now, the enemy just pushes their fist into the player

rare basin
#

where do you call the EnemyPunch?

timber tide
#

well, you need a point where you decide to recall it

visual hedge
rare basin
west sonnet
#

so it's called every 2 seconds instead

queen adder
#

I'm at work spring

rare basin
#
transform.DOMove(Player.transform.position, 1f)
.OnComplete( () => 
{
  // return after completing
});

@west sonnet

warm anvil
scarlet skiff
#

ok so i found the problem, its the hasNotInteracted = false;
originally, it is set to true, then once the fireball has interacted, it is set to false, this is so when its reflected, it cant hurt the player if they touch, the problem seems to be that the method is actually run too many times, cuz besides the reflection thing, this hasNotInteracted = false; was mainly a solution to a problem where a fireball (single) managed to do 2 damage instead oif one, which means it decrementet the hp twice, which could only happen if the method was run twice

west sonnet
rare basin
#

then do the same you do, but to the original position

timber tide
#

could use a curve too if you want fancy movement

rare basin
#
var initialPosition = transform.position;

transform.DOMove(Player.transform.position, 1f)
.OnComplete(() => 
{
    transform.DOMove(initialPosition, 1f)
});
#

you can also set different eases by .SetEase() etc

queen adder
#

Someone else can prolly help u spring sorry @warm anvil

warm anvil
#

no need to apologize. ty for your help so far. have a great rest of the day!

rare basin
#

transform

#

not Transform

west sonnet
#

I tried that too, also didn't work

#

Do I have to put it in Start()?

rare basin
#

put it before you call the move tween

#

like i showed you

west sonnet
#

Ooh I see

#

In the same method

polar acorn
#

individual object's transforms do

west sonnet
scarlet skiff
slender nymph
little cradle
#

hi, how do I correctly make a list count condition?

I'm just trying to do this:

            Debug.Log(keyframes.Count);
            if (keyframes.Count > 1) Debug.Log("HUH");

but even though the keyframes.Count is 0, the condition is met for some reason :[

wintry quarry
wintry quarry
polar acorn
earnest atlas
#

If I have an object with children, and I want those chidlren not to move when parent does.

Do I need to add Static Rigid Body to them?

polar acorn
#

If you don't want them to move with the parent, they should not be child objects

little cradle
polar acorn
little cradle
#

welp I guess it's my fault somewhere then, I'll check

polar acorn
#

Show the actual !code

eternal falconBOT
glass crest
#

Hello, is it possible to make a switch statement of a vector? if so what could be a valid case?

silver heron
#

guys i want to create 3D games but i have no knowledge about game dev. Should i start with 2D at first?

slender nymph
#

why

warm anvil
slender nymph
#

there is literally no reason to start with 2d if you only want to make 3d games. the programming concepts are the same and there are thousands of tutorials/courses for learning both

polar acorn
#

2D isn't "3D but easier" they're essentially the exact same thing

silver heron
polar acorn
#

It's just different physics components and a different camera projection

silver heron
#

so start with 3D?

polar acorn
#

Start with whatever you want

silver heron
#

alright thanks!

timber tide
#

2D assets harder than 3D

silver heron
#

good to know haha

timber tide
#

unless you like drawing frame by frame

silver heron
scarlet skiff
earnest atlas
#
void MoveTowardsWaypoint()
{
    var targetPosition = _wayPoints[_currentWayPoint].position;
    transform.position = Vector2.MoveTowards(transform.position, targetPosition, _currentSpeed * Time.deltaTime);
}

Any idea why this is not moving an object towards position?

It looks like its working (looking like working at least)

scarlet skiff
earnest atlas
#

I mean is object getting destroyed when it deals dmg?

polar acorn
earnest atlas
#

FixedUpdate

scarlet skiff
rare basin
polar acorn
eternal falconBOT
rare basin
#

that's not the purpose of FixedUpdate

earnest atlas
#

I might have gotten lost and added it therre

timber tide
#

fixedupdate can work but you also multiply by deltatime in your step

#

so there's inconsistency

slender nymph
#

putting that in FixedUpdate is perfectly fine. it just runs on the FixedUpdate timestep instead of every single frame

rare basin
#

yes and i believe this is not theirs desired goal

west sonnet
#

If I move while the enemy is mid-punch, it messes up the position of their fist and I can't figure out how to fix it. Can anyone help me please?

slender nymph
west sonnet
#

Here's my code that handles the fist movement

earnest atlas
rare basin
timber tide
rare basin
#

more designer friendly approach

polar acorn
amber spruce
#

how do i refernce a scene?

timber tide
#

I use movetowards with fixedupdate for my own physics stuff

polar acorn
#

Whichever one runs last wins

earnest atlas
#

I forgor that

#

Need to remove X movement

amber spruce
earnest atlas
#

Wait no

#

That is not working atm

west sonnet
polar acorn
amber spruce
rare basin
amber spruce
#

so do i just have to make a new script each time i want a cutscene to do a different scene

earnest atlas
#

I think issue is floatingmovement

west sonnet
rare basin
#

becaues you are overriding the hand position somewhere else

#

and it's intefering the ongoing tween

west sonnet
#

That's the only thing I can think of

#

Or that the enemy is moving while punching

#

and so the hand returns to it's initial world position, instead of relative to the enemy's body (parent object)

slender nymph
#

cache its local position and use DOLocalMove instead of DOMove

west sonnet
#

How could I cache the local position?

slender nymph
#

the same way you do its world position but using the localPosition property instead

west sonnet
slender nymph
#

show the !code

eternal falconBOT
rare basin
rare basin
vague dirge
#

Hello, I have a blend tree for my animations that contains the walk and run cycle of my character (among others), and how can I do a smooth transition between the animations when assigning a value to the blend tree (it directly switches from walk to run without transitioning as in the classic Animator) ?

vague dirge
#

Sorry

rare basin
#

the first paraemeter you pass to DOMove/DOLocalMove

slender nymph
#

maybe some day we'll see their current code so we can actually point to the specific issue with it instead of trying to guess what they need to do/change

west sonnet
#

is that correct?

rare basin
#

no

#

if you use DOMove then operate entirely on world position

#

why do you mix it

#

initial pos as local, and target pos as world - big no no

#

either world or local, dont mix it

west sonnet
#

I see, THank you.

earnest atlas
#

Is there a way to flip sprite without flipping axys?

slender nymph
#

rotate it or use one of the Flip<axis> properties on the SpriteRenderer

rare basin
#

you can google them all in 10 seconds

earnest atlas
#

You have people here with almost 0 skills in C# asking basic questions. Me asking rarely something that I dont know if even exist wont kill you

rare basin
#

sure, was just wondering

earnest atlas
#

I throw the question just incase I dont find it beforehand. At same time Im looking it up.

rare basin
#

and don't do it

#

you might find the answer, and in the meantime someone is writing you the answer on discord (and wasthing his time, because you already found the answer somewhere else)

earnest atlas
#

well that didnt work cause that did exactly SAME Thing

#

It flips transform

wintry quarry
#

just put the renderer on a child object\

rare basin
#

always separate your graphics from logic

wintry quarry
#

You can then do whatever you want with it and it won't affect anything else

earnest atlas
#

amount of rewrite I have to do omg

wintry quarry
#

Rewriting code is a normal part of the development process

#

everything in the game typically gets rewritten 3-5 times before release

earnest atlas
#

Issue is not borking it while moving logic

rare basin
#

what's borking

earnest atlas
#

Breaking everything cause you didnt think of needing to move logic

rare basin
#

that's the part of learning

#

need to fix old code/architecture

#

in order to progress and make your life easier

earnest atlas
#

Okey I changed 2 entire lines

#

Lets see if it explodes

teal mantle
#

Hello guys i have aproblem with the animation. In the follwing video you can see my character. After i run and stand still again the eyes of the character are bigger or just a litle different. But they are still animated. Anyone knows something to this?

half patrol
#

Hello, i made a simple attack and I ran in to an issue when OnTriggerEnter2D was detecting collision for only once. when 'enemy' is already inside the collider OnTriggerEnter2D was not triggered unless enemy RE-entered players collider. I fixed it by switching RigidBody2D's sleep mode to Never Sleep. I do not understand the connection between these. can someone explain please?

timber tide
#

if you want continuous collisional trigger callback then you use OnTriggerStay

teal mantle
modest dust
rare basin
teal mantle
half patrol
#

do you mind if i send you in DM a short screen video of what i am trying to tell you with my broken english?:D

timber tide
#

If it's a one time thing I'd just use overlap circle

slender nymph
#

i'd recommend using a physics query like an overlapbox or something for that instead of relying on physics messages

timber tide
#

otherwise may need to add your own cooldown inside of a trigger method

half patrol
timber tide
#

either a timer to compare against, or add a flag that resets everytime a attack is completed (you would store those that were hit inside of a list which you clear after every attack)

half patrol
#

got it

#

thanks

half patrol
timber tide
#

no clue

half patrol
# rare basin you know you can just google it?

good fellow Xaxup. first rule of a programmer is to first google. so i did. i didnt found explanation uderstandable for my newbie gamdev brain so i decided to ask a good Mao to explain in a beginner section of this channel.

earnest atlas
#

Stackovefrow solutions sometimes are just bad. There were many ocasions when reccomended solution or no longer works or is explained so bad that you are even more confused then before

half patrol
#

true that. i rare use stackoverflow now. it has too many old solutions which doesnt work anymore

earnest atlas
#

Any idea why this happens? Its only with right side. It gets stuck there sometimes.

void MoveTowardsWayPointAndWobble()
{
    // Move towards the waypoint
    var direction = _wayPoints[_currentWayPoint].position - transform.position;
    transform.Translate(direction.normalized * _currentSpeed * Time.deltaTime);

    // Set sprite flip based on direction
    _sRenderer.flipX = Mathf.Sign(direction.x) > 0;

    // All in the name of looks
    // Fancy wobble
    var newY = _initialPosition.y + Amplitude * Mathf.Sin(Frequency * Time.time);
    transform.position = new Vector2(transform.position.x, newY);
}```
earnest atlas
#

You see log below

#

Its stuck at like 0.3 there

ivory bobcat
#

And where was the log done?

earnest atlas
#

bottom left

ivory bobcat
#

In code

wintry quarry
#

We don't even know what code is logging that or what that distance has to do with anything

earnest atlas
#

Thats distance to the point

wintry quarry
#

what is the code being shown and how is it related?

earnest atlas
#

It fees like it just loses all the speed

wintry quarry
#

The distance of what to what point?

earnest atlas
#

Thats movement

ivory bobcat
#

Perhaps the log is incorrect.

earnest atlas
#

Its suposed to go from one point to another. I have transform of 2 points and it goes from one point to another

#

Hmmm... I think its getting stuck on something?

ivory bobcat
#

Perhaps the points aren't correct (working blind here)

rare basin
earnest atlas
#

Im just gonna leave that voodoo bug

slender nymph
#

ah, employing the ol Ostrich Algorithm

wintry quarry
rare basin
#

you have a null error

#

in your console

earnest atlas
#

Im not exactly sure whats it complaining about

rare basin
#

then check it?

earnest atlas
#

Well I just restarted it

#

But Im pretty sure that null is not to blame

rare basin
#

any error might lead to several issues (even not related to your main issue)

earnest atlas
#

No idea what broke here

wintry quarry
#

That's an internal Unity editor bug

rare basin
#

ah that's just unity being unity

#

clear it

earnest atlas
#

Yeah im not getting nulls

#

Im getting a stuck on a corner bird tho

open apex
#

Hello, quick question. I have been studying C# on Unity for a while. I am not expert, I have been following a basic series of tutorials. At this point would suggest me try to build my own game by watching specific tutorials or just keep on learning with tutorials? (maybe just code?)

scarlet skiff
#

in many games when u get hit, there is a brief period where u are invincible, usually with lower opacity to the character and blinking, is that usually an animaiton? cuz like the player can still do all the other movements, which require animations, so cant be, or do ppl do it via a method that use IEnumerator and StartCoroutine that delay setting the opacity back and forth to create a blinking effect

woeful lagoon
#

Hey guys, do prefabs keep their serialized assigned objects? (when spawned in)

#

It seems like It doesn't in my game

scarlet skiff
#

they dont

slender nymph
woeful lagoon
#

How do I connect them

rare basin
#

animator override controller

scarlet skiff
#

u have to assing those objects to the spawner, then in the spawner use those objects to set the objects in the spawned object

woeful lagoon
#

I am spawning them in using hte network spawner

#

How would I do that

slender nymph
scarlet skiff
#

oh damn

scarlet skiff
timber tide
west sonnet
#

Is it possible to have more than one OnTriggerEnter2D in a single script?

woeful lagoon
#

It doesn't let me add the camera in the searilized while in runtime

slender nymph
west sonnet
#

Actually just thought about it, I don't think I would

slender nymph
woeful lagoon
slender nymph
#

then provide more details about what exactly you are doing and what exactly is happening that you are not expecting to happen

woeful lagoon
#

I am spawning in a network player, with a network object script under it, I have a camera that I need to activate and thus am using a script under the player, but when I spawn the charcter in the script fails to activate the camera likely due to the breaking of the seralized field

west sonnet
#

Does anyone know what this means? It appears when the player dies and the game is restarted

slender nymph
#

sounds like you aren't stopping the tween when the player is destroyed

slender nymph
rare basin
#

handling the null for you

#

you are doing a tween on a null object

west sonnet
#

Is it an issue I should fix or is it safe to ignore?

woeful lagoon
#

Alright

rare basin
#

it's better to fix it

slender nymph
west sonnet
#

I guess it's because the tween is one an enemy and the enemy is killed?

#

Wait no, the enemy isn't killed

#

How is the enemy becoming null when the game restartts?

rare basin
#

how do you know its the enemy causing that error?

slender nymph
#

didn't i already answer this?

west sonnet
rare basin
slender nymph
#

and yet it is accessing the player's transform

tawdry quest
#

Dont think this is beginner related, its prolly more like general level as i didnt find anything on google

west sonnet
slender nymph
#

either way, if either object is destroyed you probably need to restart kill the tween

west sonnet
#

as in, in that sentece

elder osprey
#

I am not sure what I am doing wrong, but for some reason the ground check i have set up is not working, the hit variable is constantly zeroed out, causing IsGrounded() to always be false. Here is my script: https://hastebin.com/share/etelupecez.csharp

#

I am using a spherecast

west sonnet
rare basin
#

then you will get normal unit null error reference

#

with call stack

slender nymph
rare basin
slender nymph
#

because the issue is that you are likely not stopping the tween when the object is destroyed

rare basin
#

but are you killing the ongoing tween?

west sonnet
slender nymph
#

show the code

rare basin
#

yes so that doesnt mean

#

its killing the ongoing tween

#

you just prevent from starting a new one

#

you can cache the tween

#

in Tween yourTween;

west sonnet
#

The bool turns to false when enemy dies

#

EnemyPunch() is in Update()

rare basin
#

it doesnt kill the tween

#

as i said multiple times

#

cache the tweens, and kill them in Destroy() method

west sonnet
#

How can I kill the tween?

rare basin
scarlet skiff
slender nymph
#

you do not have a tag called Arrow

scarlet skiff
#

oh might have forgotten to add it

west sonnet
#

Would I destroy the method that the tween is inside of?

slender nymph
#

that sentence does not make any sense

rare basin
#

what do you mean by destroying the method

scarlet skiff
#

problem sovled, thanks

rare basin
#

there is no such thing as destroying a method

west sonnet
#

You can only destroy objects, right?

wintry quarry
#

In C# you can't destroy anything actually

slender nymph
#

you can only destroy UnityEngine.Objects

slender nymph
scarlet skiff
rare basin
#

that is a terrible idea to check things by name

scarlet skiff
#

i dont see anything wrong, but the method for fireball collision inst exactly doign anything

slender nymph
#

right off the bat i see you are basing logic on gameobject names which is a terrible idea

rare basin
#

also that Update() method is unreadable

slender nymph
#

use tags or check for components. do not compare the name

rare basin
wintry quarry
scarlet skiff
open apex
#

Why do I not have the choice to "Build"?

slender nymph
#

because you have a different platform than the one your project is set to selected. also not a code question

scarlet skiff
scarlet skiff
slender nymph
open apex
#

thanks

open apex
slender nymph
open apex
#

OHHHHHHHH

open apex
little cradle
#

I'm trying to add an object to a list on a specific index, how can I do it?, if I try to do e.g. myList.Insert(33, myObject) it gives me an error ArgumentOutOfRangeException: Index must be within the bounds of the List., am I doing it wrong, or does list not support doing it that way?

wintry quarry
#

the error tells you exactly where you went wrong

slender nymph
#

well you have to insert it at a position that actually exists in the list. otherwise you can just append it to the end of the list using Add

wintry quarry
#

Also note the difference between inserting an element, adding an element, and setting an element.

little cradle
#

okay, so I think this might be an xy problem, so I want to make a keyframes list, and I want to put them in a specific time, my idea was to set the keyframes' index to the exact time so I could get "current and next" keyframes easily (just count from lower to higher index), so I'll instead ask, is there a better way, any documentation or something similar I can use/read or do?

honest haven
#

https://gdl.space/azavodopun.cs hi can some one please have a look and tell me if im using states correctly. Any just before i attack i get some animation flickering

languid spire
west sonnet
#

I'm trying to make a prefab of my enemy but when I do, the references in my scripts don't apply.

#

references to other objects

#

Is this not possible?

slender nymph
little cradle
languid spire
#

array[index] = value

little cradle
#

alr alr, tysm

rare basin
#

if you want to dynamically manipulate the size

rare basin
#

the array has fixed size

#

you can modify the existing indexes

languid spire
#

you are missing his point completely

rare basin
#

how can I add values to the array "in runtime"?,

#

so im answering

languid spire
honest haven
queen adder
#

I have a problem, when i import my prefab to my project it appears that error but when i import for another project, it doenst have errors

scarlet skiff
#

collision.gameObject.name

isnt really doing its job as a condition...

this script is attached to a player, the shield is a child of the parent player, so idk how to detect a collision between specifically the fireball and the shield..

slender nymph
#

remember how it was suggested to use tags or components rather than gameobject names?

#

also note that the collision.gameObject cannot both be a fireball and a shield if those are completely separate objects

scarlet skiff
scarlet skiff
#

im checking if the fireball is the shield, rather than if they are colliding

#

i have this script in another one and i forgot to chaneg that part, but then... how DO i check if they collided wit heach other?

slender nymph
#

in the shield you can check if it collided with a fireball. in the fireball you can check if it collided with a shield

#

you don't need to check both in each

spring coral
#

is there any way I can define some bounds without creating a collider?

wintry quarry
#

what kind of functionality would these "bounds" have?

scarlet skiff
#

shame that its not possible to do it in the collision script but id have to go to the fireball,although i suppose it makes sense cuz id need to use the OnCollision method

#

thanks tho

spring coral
#

its just so that I can do certain calculations on it like getting the closest point from a position

zealous oxide
#

hey peeps. i've got a game object with a line renderer + physics2d raycast thats facing transform.right, but im having trouble successfully rotating the object on a 2d plane to line up with another specific game object, in this instance, the player character. i'm not well versed in quaternion stuff. full code for the spawned game object is here https://hatebin.com/iosfkcnugy Now, i could clamp the x and y rotation axis I believe but this doesnt seem elegant or and is more of a band aid solution. I do have some alternative code i've written for a different demo that faces the target object but it does so without a delayed rotation which is what im after.

spring coral
#

i could just drop a collider in the scene and remove all of the collision layers on it to do the same thing, but is there a better way to handle this?

teal viper
#

Cause it sounds like you want an actual collider.

spring coral
#

hmm, its only purpose would be for me to just fetch the closest point from another position

#

i wouldnt be using the collision detection or anything like that

teal viper
#

Bounds seem to have a method for getting the closet point.

#

You can't rotate it in space though

spring coral
#

ohhh, hmm thats def a limitation

scarlet skiff
#

cuz i set it true in OnCollision

#

and i check if its true in another OnCollision

spring coral
#

ehh, i could just use a collider i guess

scarlet skiff
#

where do i go from there?

ivory bobcat
#

What're you trying to accomplish?

teal viper