#💻┃code-beginner

1 messages · Page 150 of 1

open python
#

The AnimationTriggerEvent is kinda slow how do i make it fast?

I want to change to another animation after the current animation ends but it doesn't, if turn on animation loop time it takes two to three loops to take effect.

timber tide
#

I prefer the if if if if if approach myself

open python
#

i mean i could make a function in the Enemy class itself but it defeats the whole purpose of the AnimationTriggerEvent

timber tide
#

can probably just do that in script if you can't get it to work

#

that's the only thing that really sticks out in the video, otherwise basic trigger methods

open python
#

thanks anyways, guess i have to do just that

open sierra
#

Thanks!

#

Thank you!

timber tide
# open sierra Thank you!

some more questions:
what's the difference between an object and a component
how do you get references to other components on the same gameobject
what is a transform

restive ember
#

I think instead of memorizing what each word means, try to understand what an entire block of code does. For me when im reading code I like to try to translate it almost into words so i can understand what its doing better. All you need to do is get the basics of c# and the rest comes with study and practice, once youve gotten to a confident level you can now code in almost any programming language just from your knowledge of c# isnt that cool :D

buoyant knot
timber tide
#

hey, if I got the screen space, I'm going to use it all

buoyant knot
#
    if
         else if
if
               else if
     else
if
if
if
               else if

#

“Mr Interviewer, if you can’t read this code, your programming skills must just be insufficient.”

gaunt ice
#

if can follow nothing, else can follow else if or if, else if must follow if
task: write a backtracking function to generate all possibles control flow
hint: you will need a stack

royal ledge
#

I have a sort of architecture question. I have a gun which you can upgrade through UI, upgrades can be homing bullets, bullets that curve, bigger bullets etc. You are supposed to combine different upgrades how you like. At the moment i have boolean flags that are set for each upgrade, so in the gun class for example i just check for flags
If (homingBullets){//do smth}
If(bigBullets) {//do smth}
Now there are going to be quite alot of upgrades, is this the way to approach it?

honest haven
honest haven
#

So the return is being called when attack and wont leave and the animation is still showing its prevouis animation. i read about somthing called Rebind(); Could that fix the issue?

light radish
#

Hey guys, what would be the most straightforward way of checking if two objects are colliding?

rocky canyon
#

OnCollisionEnter()

light radish
#

Which is automaticly run when something with a collider enters its colliding field?

royal ledge
timber tide
#

someone asked this question a few days ago

#

do you mean like in half or by 50% opacity lol

buoyant knot
#

#3DProblems

honest haven
#

prob want to create a shader and lerp between the alphas

#

im not 100% sure but thats what i would google

polar acorn
#

Set the alpha to 0.5 and make sure you are using a transparent shader

amber spruce
frosty hound
#

Yeah, you're trying to get something from a collection (array or list) with an index that is outside the range of the collection.

#

Look at PlayerControllerNew.SamuraiAttack () (at Assets/PlayerControllerNew.cs:222)

amber spruce
#

thats this ```csharp
animator.runtimeAnimatorController = SamuraiCombo[ComboCounter].animatorOV;

#

im confused because it works fine but after i attack smth enough times it stops resetting it and goes outside the range

#
public void SamuraiAttack()
{
    if (Time.time - lastComboEnd > 0.5f && ComboCounter <= SamuraiCombo.Count)
    {
        CancelInvoke("EndCombo");

        if (Time.time - lastClickTime >= 0.333f)
        {
            Debug.Log(ComboCounter);
            animator.runtimeAnimatorController = SamuraiCombo[ComboCounter].animatorOV;
            soundEffects.clip = SamuraiAudio[ComboCounter];
            soundEffects.Play();
            animator.Play("Attack", 0, 0);
            Damage = SamuraiCombo[ComboCounter].attackDamage;
            ComboCounter++;
            lastClickTime = Time.time;
            DoAttack();
            Moves moves = gameObject.GetComponent<Moves>();
            moves.PerformPunch();

            if (ComboCounter >= SamuraiCombo.Count)
            {
                ComboCounter = 0;
            }
        }
    }
}

thats the whole thing so im not sure how it is reaching more then is in the array/list

gaunt ice
#
ComboCounter <= SamuraiCombo.Count
amber spruce
vital tartan
#

Index of element is starting from 0 and List Count from 1

gaunt ice
#

i know
but how about .Count is 0

vital tartan
#

So it should be just <

buoyant knot
#

it’s worth mentioning that SamuraiAttack should have very limitted connection to combo count

gaunt ice
#

or at initial ComboCounter = SamuraiCombo.Count

buoyant knot
#

there should be a different object entirely that manages combo count, and tries adding to it.

gaunt ice
#

then your

if (ComboCounter >= SamuraiCombo.Count)
{
    ComboCounter = 0;
}
```is useless
buoyant knot
#

this function also should not be directly messing with the animation controller. this function is just handling way too many different jobs

amber spruce
polar acorn
amber spruce
# polar acorn Before you go in deep trying to fix it, try logging ComboCounter and the size of...

what does this mean

MissingComponentException while executing 'performed' callbacks of 'Player/Attack[/Mouse/leftButton,/XInputControllerWindows/buttonWest]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)

frosty hound
#

That's just a biproduct of your actual issue

#

Fix the real issue, and it will go away

polar acorn
swift crag
#

I believe that, when an exception is thrown in an action callback, you get two errors in the console

#

One is the original exception, and another is just an error logged by the input system

onyx tulip
#

why is my default layer above background layer when i put my characters layer above the background?

swift crag
#

(you can log an error message whenever you want; they're not just caused by exceptions)

amber spruce
#

normally it would do this

polar acorn
amber spruce
#

combo counter is the first one length is the second one

gaunt ice
#

which is the first one.....

ivory bobcat
#

Show the out of range exception error?

amber spruce
#

so for the second image combocounter is 3 4 0 1 2 and length is 5 5 5 5

swift crag
#

Logging both at the same time would help.

polar acorn
swift crag
#
Debug.Log($"Counter: {counter} / Length: {comboLength}");
ivory bobcat
#

At this point I'm assuming it's a missing component exception

swift crag
#

(i made these variable names up)

polar acorn
ivory bobcat
#

Was there a confirmed initial error? UnityChanThink

polar acorn
#

Yes, an out of range exception

ivory bobcat
amber spruce
#

this is what normally happens

then this is what happens when it breaks

gaunt ice
#

there is no animator

ivory bobcat
polar acorn
ivory bobcat
#

So either you're incrementing it elsewhere or the reset isn't occurring.

gaunt ice
#

i think the no animator error causes your if(counter>=count) statement dont execute and then you get many index out bound s

ivory bobcat
#

Likely so. Fix the errors from the top to the bottom.

gaunt ice
#

then the index out of bound is ofc interrupt your program everytime hence the if statement are not executed at all

ivory bobcat
#

Else you may be attempting to fix false positives.

amber spruce
#

yep it was the animator error thanks

polar acorn
#

Always solve errors top to bottom

amber spruce
#

how do i check if the object has a component before i try to get it

polar acorn
#

When an error occurs, the code stops

nimble scaffold
#

Guys I need a help that how to do that wheels will rotate but without wheel colliders pls

rare basin
#
public void OnCancelButtonPressed()
{
      if(abandonMissionModalOpened)
      {
          Debug.Log("pre null check");
          if(abandonMissionModal != null)
          {
              Debug.Log("turning off modal window");
              abandonMissionModal.TurnCanvasGroupOn(false);
              if (isInGame)
              {
                  PauseManager.Instance.UnpauseGame();
              }
              return;
          }
      }

      Debug.Log("turning off options");
}

I have an issue, where the last Debug.Log is still being print, despite the return above, and the logs above prints aswell and im not sure what is going on xd the functions is being called only once, after a keyboard button(or gamepad button) press

ivory bobcat
rare basin
#

sorry nevermind, fixed it

#

i subsribed to the event twice by a mistake

#

(well, didint unsubscribe on scene change)

#

then subbed aggain

smoky mauve
#

is there any way to make an exception on control child size in a vertical layout group, I have a layout with a text and a button under it and when the size of the text adjust the button shrinks, if this makes sense

rocky canyon
#

the button shrinks b/c the area it can be shrinks..

#

it just scales to fit within

#

no clue how to fix it tho, i suck at layout groups.. they're just trial and error for me..

swift crag
#

The button needs a layout group.

#

You currently have this:

  • Root <-- VerticalLayoutGroup
    • Button
      • Text
rocky canyon
#

^ that makes sense.. it should be within it yea, like DIV's in css

swift crag
#

Attach a VerticalLayoutGroup to Button and make it control its child's size

#

If an object has no layout group on it, then it won't be aware of the size requested by its children

#

so it won't ask for any space

rocky canyon
swift crag
swift crag
#
- foo
  - bar
    - baz
rocky canyon
#

ohh okay

#

thanks

swift crag
#
  • what about
  • just one
  • space?
#

that doesn't behave. two spaces it is.

rocky canyon
#

ya that doesnt work

#

yeap 🙂

#

im thankful discord added that feature

#

helps with visualizing the hiearchy

swift crag
#

e.g. I need to switch this to "Layout Properties" to see it

swift crag
#

oh, Raspu did post over there! missed that.

smoky mauve
#

fixed it

#

i crated a lay out group for the text and added it into the original layout group that doesnt adjust the size but the other one does

trail fox
#

!code void EatFood()
{

// Check if there's food nearby
Collider[] colliders = Physics.OverlapSphere(transform.position, 2f);

foreach (Collider col in colliders)
{
    if (col.CompareTag("Food"))
    {
        //  Get the Food script and eat the food
        Food food = col.GetComponent<Food>();
        if (food != null)
        {
            currentHunger += food.nutritionalValue;
            // Remove the food from the scene
            Destroy(col.gameObject);

            
            
            appleEatSound.Play();
            Debug.Log("Player Ate Something");
            
        }
    }
}

} when im trying to eat the object if theres 1 object in the scene that im trying consume it works fine but if theres 2 of the same object it consumes both if im trying to consume only one of them how do i fix this

eternal falconBOT
wintry quarry
trail fox
#

how do i implement that

wintry quarry
#

That is the implementation

calm coral
#

Literally just add break; at the end

trail fox
#

its that simple?? dang

wintry quarry
#

break; breaks out of the current loop or switch statement

trail fox
#

bro it actually worked wtf thank u'

calm coral
#

There's also yield break;

rare basin
#

it's not magic 😄

trail fox
#

im just shocked

#

bro i thought it was complex asf

#

cuz it felt like it

prime drum
#

It so often is wtf. With a couple of omg's thrown in there. "Oh, no my code actually works just fine, but I forgot to add a critical '!' to it", "oh wait, why am I dividing that?", etc.

#

Or the hilarious "argh! I was editing the wrong file all along!"

polar acorn
frank flare
polar acorn
frank flare
#

where is transparent shader?

polar acorn
#

Change it from opaque to transparent

frank flare
#

Ok, thanks, now it works

frosty hound
#

@frank flare this isn't a coding question. In the future, stay in one place.

honest haven
#

I still cant get my attack to work when my player is being instatiated

#

my state is attack yet the animator is showing idle and i can no longer move as it thinks its in attack state. This only breaks when ithe player is instatiated.#

#

attack comes from any state

polar acorn
#

Are you sure you're referencing the correct Animator

honest haven
#

Well there is only one player on the scene and i have clicked that game object and moved around the scene and i can see it swapping. Its only on attack it breaks.

#

this is after attack is pressed

honest haven
#

yes

polar acorn
#

Show the transition from attack to idle

honest haven
polar acorn
honest haven
#

there is no trigger on attack to idle. i have a trigger at the end of the animation

#

The attack does not even play. just goes straight to idle yet this debug is always displaying

#
    {
        Debug.Log(playerState.CurrentState);
        if (playerState.CurrentState == PlayerState.State.Attacking)
        {
            // Player is attacking, disable movement
            return;
        }```
polar acorn
#

I don't think you read my answer

honest haven
#

its state is attack

polar acorn
#

Nowhere in any of the code you sent are you setting the Attack trigger in your animator

honest haven
#

void OnAttackAnimationEnd()
{
playerState.ChangeState(PlayerState.State.Idle);
Debug.Log("no");
}

#

oh sorry wrong code

#
{
    private Animator _animator;
    private PlayerState playerState;

    void Start()
    {
        _animator = GetComponent<Animator>();
        playerState = GetComponent<PlayerState>();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (playerState.CurrentState != PlayerState.State.Attacking)
            {
                Attack();
            }
        }
    }

    void Attack()
    {
        playerState.ChangeState(PlayerState.State.Attacking);
        _animator.SetTrigger("Attack");
    }

    // Animation event handler for the end of the attack animation
    void OnAttackAnimationEnd()
    {
        playerState.ChangeState(PlayerState.State.Idle);
        Debug.Log("no");
    }
}```
#

here is attack

polar acorn
#

So depending on which one executes first, you will either attack first then enter the attacking state, or enter the state and that's it

honest haven
#

but why would this work when my player is in the hierarchy and then break when its being instatiated

polar acorn
#

If you're gonna use a state pattern, you should have the states handle this stuff

honest haven
#

i do

polar acorn
honest haven
#

public class PlayerState : MonoBehaviour
{
    public enum State
    {
        Idle,
        Moving,
        Running,
        Attacking,
        Pause
    }

    private State currentState = State.Idle;

    public State CurrentState
    {
        get { return currentState; }
    }

    public void ChangeState(State newState)
    {
        currentState = newState;
    }
}```
rocky canyon
polar acorn
rocky canyon
#

the yellow one is just picking a random location, and the blue one is set when the ground is clicked.

rich adder
rocky canyon
#

nah, hadn't thought of that.. i was thinking id have to create a timer if it hasnt moved so far in so long then just set where it is as the target

timber tide
#

need some swarm ai

rocky canyon
#

but even that method doesn't seem like it would look all that pretty.

#

would take a bit of time b4 anything happens

honest haven
rich adder
rocky canyon
#

ya, ill give that a try firstly

polar acorn
#

which is largely random

rich adder
honest haven
rocky canyon
rich adder
#

yeah unity lol

rocky canyon
#

so a lower value agent would be ignored by this one

#

but.. higher importance lol.. idk ill just test it

rich adder
rocky canyon
#

okie

rocky canyon
#

still need to tweak the NPC a bit

#

he gets a bit confused

rich adder
#

yeah starts wobbling

#

what is destination for yellow set to?

rocky canyon
#

its randomized

#
   if(masterOverride)
        {
            // Check if the agent has reached the destination
            if(!navMeshAgent.pathPending && navMeshAgent.remainingDistance < 0.1f)
            {
                if(!waiting)
                {
                    ChangeState(NPC_RX_State.IDLE);

                    // Start the wait timer
                    waitTimer = Random.Range(minWaitTime,maxWaitTime);
                    waiting = true;
                }
                else
                {
                    // Continue waiting until the timer reaches zero
                    waitTimer -= Time.deltaTime;

                    if(waitTimer <= 0f)
                    {
                        // Set a new random destination after waiting
                        SetRandomDestination();
                        waiting = false;
                    }
                }
            }
            else
            {
                ChangeState(NPC_RX_State.WANDERING);
                waiting = false; // Reset the waiting flag if the NPC is not at the destination
            }
        }```
#

just some basic stuff to get it moving around

rich adder
#

I think it tries to return to its original stopped position ?

rocky canyon
#

yea it seems that way

#

as long as his destination is the same.

#

he tries to move back

rich adder
#

the higher "importance" agent is in the way like an obstacle lol

#

so it tries to obstacle avoid and gets all weird

rocky canyon
#

yea im wondering if i can maybe use the carve component

#

yea but that wouldnt work.. cuz he then wouldnt be on the nav

rich adder
#

you would have to get real granular with it

#

like detect maybe if indeed was pushed then just set destination to be self instead

#

or something

rocky canyon
#

ya, i think ill just hack it for now.. "Stray NPC" is supposed to represent like a wild animal

#

could just make it run away from the Unit if it gets close enough

rich adder
#

animal sidekick do be wild

rocky canyon
#

fight or flight.. (if unit is in personal space just freeze)

rich adder
#

spazzing is ok lol

rocky canyon
#

lol

#

and this is supposed to be mobile.. so i keep struggling to keep my mechanics correct..
i realized if i keep one thing in my head it'll all work out..

(there is no hovering on mobile)

#

normally i would have it where u can hover the unit first.. and then a menu would pop up allowing u to click a button to navigate or a button to do something else...

#

but since i can't hover imma have to make a single click select it.. and then a click and hold would open said menu..

rich adder
rocky canyon
#

they should def add that onto cellphones 😄

#

like use magnetism or something (like capacitor type stuff) to detect if you are about to click

#

also direction, b/c now i have a toggle where he just faces the mouse position.. but that wont be possible on mobile..
im thinking of having it face the direction its moving unless u click and drag (then it would face that direction).. and tie that into my waypoint system..
soo... if a waypoint has a direction then the navmesh agent will slowly look towards that direction as its traversing to that position.. (slerping from the last waypoint direction to the new waypoint direction)

#

and then if theres no direction assigned to it, the unit would slerp towards its normal facing direction

rich adder
#

otherwise it looks unnaturally stiff

rocky canyon
#

Guess the first step would be to get a better waypoint system.. as right now its just a list of transforms..

#

should probably make a class or struct instead w/ multiple properties

rich adder
#

also would store the results of Navmesh.SamplePosition

#

I had issues agents get weird when destination point isn't exactly on mesh

rocky canyon
rocky canyon
keen blade
rocky canyon
#
  private void Update()
    {
        SeekWaypoints();
    }

    void SeekWaypoints()
    {
        if(waypoints.Count > 0)
        {
            navMeshAgent.SetDestination(waypoints[0].position);

            if(navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance && !navMeshAgent.pathPending)
            {
                // Destination reached, remove the waypoint
                GameObject curWay = waypoints[0].gameObject;
                waypoints.RemoveAt(0);
                Destroy(curWay);

                // Check if there are more waypoints
                if(waypoints.Count > 0)
                {
                    // Set the next destination
                    navMeshAgent.SetDestination(waypoints[0].position);
                }
                else
                {
                    // No more waypoints, stop the agent or perform other actions
                    navMeshAgent.ResetPath();
                }
            }
        }
    }``` heres the Unit script.
#

i just have a AddWaypoint() function where i pass in the Transform of the little blip i instantiate

#

then the agent handles the rest

gritty stratus
#

I take that if we post a bug, we should use pastebin sites in our thread if there are 4 scripts involved?

rocky canyon
#

gives it a more natural feeling.. as if a waypoint is directly behind him.. he almost turns 180 as he starts moving..

trail fox
rocky canyon
#

default settings are bad, lol.. unit will moonwalk half the trip b4 he gets fully turned around

rich adder
#

yeah for sure

trail fox
#

that code is so annoying

timber tide
rocky canyon
#

use some debugs.. see if ur raycast and stuff is working

short hazel
trail fox
#

ive tried its not for somereason

rich adder
timber tide
keen blade
#

i dont really know what to do

timber tide
#

!code

eternal falconBOT
rocky canyon
#

if u cant eleminate any of the code on your own just send links to all of it.. but it will less likely to be read and/or solved..

gritty stratus
rocky canyon
#

but no one can help period, w/o it

swift crag
#

If you understood the code well enough to simplify it, you'd have solved the problem already

gritty stratus
#

It is a heart management system, which I'll post a thread to

timber tide
rocky canyon
#

most likely if ur code is half decent if ur leaving out any important scripts, they'll get asked for

#

BUT.. some of thse paste bin sites allow u to enter multiple scripts

#

hastebin i think

timber tide
rocky canyon
#

github GISTS are a good place to post multiple codes

#

ya, i like all the Debugs 🤤

timber tide
gritty stratus
#

Hearts Management System Bug

timber tide
#

Did you manage to look up how to attach the debugger?

#

It's really useful, especially when you've a bunch of logic you need to specifically dig through to point out the problem

#

Pretty useful such that here I'm just hovering over the values and getting it just then, and you can even do it during the editor runtime (such as attaching the debugger and creating new breakpoints)

shrewd swift
#

the answer is prob 99% no, but i'll ask anyway

can I combine cases in a switch ?
like an or/and

case myEnum.xx || myEnum.yy
//stuff
short hazel
#

On late enough versions of C# yes, try a case Thing.A or Thing.B

shrewd swift
#

thats great

short hazel
#

Or, the old way is to have two cases

case A:
case B:
  // code

A will fall through B

loud cipher
#

renogareFont = Content.Load<SpriteFont>("\Font\Renogare-Regular.otf"); how do i make it so i dont have to copy the whole path?

shrewd swift
short hazel
#

Correct!

shrewd swift
#

well ty for answering

queen adder
#

does anybody know why the Invoke method does not call the function?

shrewd swift
#

for a moment I thought i would be impossielbe since i never seen a switch with combination in years

short hazel
queen adder
#

wait

short hazel
#

What?
Like two lines in OnCollisionEnter you do Destroy(gameObject)

queen adder
#

oh actually I get it

#

the script is a part of the bullet

summer stump
#

The issue is the Destroy call in Start

queen adder
#

is there a way to create a new thread which exists once the original script is destroyed?

polar acorn
#

It doesn't go well

queen adder
#

brother I just want the delayed function call to exist after I destroy the script

modest dust
#

Simply call it on something you won't destroy

cosmic dagger
queen adder
#

I dont have that type of time on my hands

#

I will next time

#

thanks

supple wasp
#

Hey I don't know why but I get this error again

rich adder
supple wasp
#

where can I download it?

#

I do not remember anymore

short hazel
#

google : ".NET sdk download"

loud cipher
#

in the "Controls" part of the code should i ask the position of the player as well as the game time so i dont have to do the "ballPosition += movementInput;" outside the function?

snow girder
#

hey guys, how do i make a rigidbody character?

loud cipher
snow girder
#

and i can't really understand how to make the guy move with a rigid body

short hazel
#

Character Controller and Rigidbody are incompatible

snow girder
#

yep so im trying to switch to rigid body

short hazel
#

If you switch to a Rigidbody make sure to remove the CC, you'll have to redo most of your movement code

snow girder
#

yeah i know, but i don't know how to make him move with rigid body

#

that's the issue

#

cause i tried using the code from like a year or two ago

#

and apparently it's incompatible

short hazel
# snow girder and apparently it's incompatible

There's AddForce, which produces smooth and more realistic movement, and MovePosition which is more crispy and reactive.
The Rigidbody API hasn't changed in a while, so I doubt the code is incompatible

wintry quarry
snow girder
#

which one should i use?

short hazel
#

The answer can be deducted by reading my message one more time

#

But you can try both and see what feels the best

snow girder
#

well alright...

coral basin
#

I heard that using transform.Rotate is bad when dealing with rigidbodies in fixedupdate, what should I use instead?

smoky mauve
#

where's the error?
objects = JsonUtility.FromJson<JsonObjects>(json: jsonFile.text);
This are the two scripts

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

public class Deserialisation : MonoBehaviour
{
    [SerializeField] public TextAsset jsonFile;
    [SerializeField] public JsonObjects objects;
    // Start is called before the first frame update
    void Start()
    {
        objects = JsonUtility.FromJson<JsonObjects>(json: jsonFile.text);
        Text sampleString = objects.Quote;
        Debug.Log(sampleString);
    }

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

public struct JsonObjects
{
    public Text Quote;
}
#

ArgumentException: JSON must represent an object type.

short hazel
#

Your file doesn't contain valid JSON, it seems

snow girder
smoky mauve
#
  {
    "Quote": "echnique 29:\nThe exclusive smile\nIf you flash everybody the same smile, like a Confederate dollar, it loses value. When meeting groups of people, grace each with a distinct smile. Let your smiles grow out of the beauty Big Players find in each new face.\nIf one person in a group is more important to you than the others, reserve an especially big, flooding smile just for him or her.",
    "Author": "alsdñgf",
    "Source": "ewag"
  }]```
#

into a JSON file

polar acorn
short hazel
rich adder
#

use Json.net if you want to avoid doing unused fields

polar acorn
#

And "Quote" is of type UnityEngine.UI.Text which is probably not right

snow girder
short hazel
#

That class name is not really good, I'd call it Quote, simply

#

Because that's what it stores

smoky mauve
#

i was following a YT tutorial

polar acorn
smoky mauve
rich adder
#

mines better, it uses generics 😏

polar acorn
#

Still, Text is a UI GameObject and not what you want

#

You should make an instance of the object in code first and output it as JSON, then use that as a sample of what you should be doing

tender wren
#

Quick question about OnDrawGizmoSelected().

I am generating handles in the above function, but its a bit complex and I do not want to run it every time. Is there a way to generate the handels, then only move them if the transform is updated? Like onvalidate with values of properies, but a onvalidate via transform.

The logic behind transform.has moved works while moving, but if I check against that, when it is not moving it doesn't draw them. Is it expected that these draw every time it loops or is there a better way to do this performance wise?

rich adder
charred spoke
tender wren
#

When doing the loop I am getting the hash value of objects and redrawing them, won't this cause issues if I try and do too many at once?

short hazel
rich adder
open kernel
#

How difficult is it to write a proximity voice chat? And would it be possible to have like a digital microphone which "records" your voice differently depending on where you are standing

rocky canyon
#

basically would be passing it thru some sort of filter

willow radish
#

why cant i add my own font to TextMeshPro?

rich adder
rocky canyon
#

you have to create a font atlas from it

#

asset creator

willow radish
#

i think im blind one sec, but thank you :)

#

i think i got it

#

idk if im doing something wrong, but i got this now but i cant drag it in

night mural
willow radish
#

thanks ill read it!

night mural
#

iirc once the asset exists, you should see the font in the fonts dropdown (you don't drag it in)

willow radish
#

alrighty, well i dont see it in the dropdown so i have done something wrong hahah, but ill read the doc

night mural
#

(it's possible that you do have to drag it in and i forgot)

willow radish
#

dw im sure ill figure it out :)

dusk minnow
#

When i disable a gameobj can i still trigger funktions inside a script of it?

polar acorn
#

so you'd need to call a function manually

dusk minnow
#

ik

swift crag
#

Yeah, being a disabled MonoBehaviour means very little

willow radish
#

when i drag the font asset in it doesnt appear as that font and i get this error

#

wait i think i got it to work

#

So im following a tutorial about a pause menu, what actually is the difference with normal text and TMP?

night mural
#

normal text is old and crappy and everyone ended up using TMP so unity bought TMP and made it the default

willow radish
#

ahh okay okay, so technically it doesnt really matter if you use TMP or not

snow girder
#

how do i check what direction my player is facing

swift crag
#

transform.forward is a vector pointing in the forward direction of the transfomr

snow girder
swift crag
#

in that case, -transform.forward will be a vector pointing backwards

#

there's no transform.back, annoyingly

snow girder
#

ah

#

i see

#

correct me if im wrong but rb.addforce(-transform.forward) will not work right?

swift crag
#

That will apply one newton of force. The force will point backwards.

#

One newton is enough to accelerate one kilogram at one meter per second per second. It's not very strong.

snow girder
#

oh that's very nice

swift crag
#

just multiply the vector by a number

snow girder
#

multiply?

#

why

summer stump
night mural
swift crag
#

because the amount of force applied is the length of the vector

snow girder
#

oh right

night mural
swift crag
#

transform.forward is a unit vector; it has a length of 1

snow girder
#

since it's apply 1

swift crag
snow girder
#

it's applying 1 and 1 * whatever number is yeah

#

okay thank you guys

#

so it's pushing me upwards

#

which is quite interesting

polar acorn
#

Or rather the opposite of the direction it's facing

snow girder
#

can i make it ignore the y axis?

#

oh wait i think i know how

open apex
#

when the player press the key d

#

the player moves

#

but it mantains a certain speed when the player releases it's key

#

I don't c#

#

What is the "else" statement that can be added to maybe rb.AddForce(0,0,0)

rocky canyon
#

can set the rigidbodies velocity to zero in the else statement

polar acorn
snow girder
#

also what do the other forcemodes do? they were kinda the same when i tested

open apex
#

so there is a speed variable

swift crag
#

what?

snow girder
#

I KNOW RIGHT

polar acorn
#

<@&502884371011731486>

swift crag
#

incomprehensible

polar acorn
#

Also in what way is "Adding zero force results in zero force being added" in any way a strange thought

open apex
frosty hound
#

@open apex @snow girder homophobic comments are not tolerated here

open apex
#

you most likely don't have friends

snow girder
#

my bad

frosty hound
#

And if you continue, you're getting kicked. So move on.

open apex
#

it's an it

snow girder
#

insanity

spiral narwhal
#

Why can we serialise fields using the [SerializeField] attribute to enforce encapsulation but not for methods?
I often find myself in the need where I "just" want to have a public method because I may have to select it from the Unity inspector window in events, animations, etc.

open sierra
#

what does translate mean?

#

and what are some other examples you can use "Translate" in?

open sierra
#

gotchu!

polar acorn
rich egret
#

Does anyone know how to make that text delete after half a second?

#

This is what I use but it doesn't work

polar acorn
frosty hound
#

That is how, assuming you pass in the actual GameObject

#

If you pass in a component, it will destroy that instead

rich egret
ivory bobcat
polar acorn
#

and what is currentText

#

maybe just post !code

eternal falconBOT
ivory bobcat
#

Are you calling destroy on the correct object?

rich egret
willow radish
#

might be a dumb question, but im watching a vid about a pause menu, im sure im doing something wrong but i dont know what, first pic is his code

willow radish
#

my bad i just noticed xd sorry

open sierra
#

I'm gonna be asking a bit of dumb questions for yall since I'm new to coding

#

what's a method?

polar acorn
polar acorn
#

Are you getting any errors in the console

rich egret
polar acorn
#

You should also read the message above the error as to why you're getting it

#

You can't add a TextMesh to this object, it already has a mesh renderer

ivory bobcat
open sierra
#

in the highlighted area, how does the math work here?

polar acorn
swift crag
#

it scales the vector by Time.deltaTime, then by 20

open sierra
#

like how does time.deltatime multiply by 20

swift crag
#

they're numbers

#

they just...multiply

polar acorn
swift crag
#

by order of operations, though, it doesn't actually multiply deltaTime by 20

#

((Vector3.forward * Time.deltaTime) * 20)

#

same difference, though.

rich egret
open sierra
#

so it's 1 x 20?

swift crag
#

where did the 1 come from?

polar acorn
polar acorn
swift crag
#

ah, you're talking about the length of the vector, yeah

#

I thought you had turned deltaTime into 1

open sierra
#

is it random?

polar acorn
#

That's why it's a variable you use instead of hard-coding in a framerate

ivory bobcat
open sierra
#

I see

polar acorn
#

Because you don't know how long that frame will take to render

rich egret
#

and im sorry im just a begginer

polar acorn
# rich egret so what to do?

Don't try to add a TextMesh to a prefab that already has a MeshRenderer. Why are you trying to add one at runtime instead of just putting it on the prefab to begin with?

ivory bobcat
#

Reference it as the correct type.
public Whatever ... instead of GameObject.

#

This would ensure whatever you've dragged into that field (available in the inspector) would have an appropriate component.

rich egret
polar acorn
sweet flume
#

I just started on unity hub I created a project I wanna make it 2d but I'm stuck and don't know what to do

ivory bobcat
rich egret
#

@polar acorn @ivory bobcat 💀

rich egret
#

That's because it's a TextMeshPro and not a TextMesh

polar acorn
#

Yes and if your variable were using an actual component type instead of GameObject you would have noticed sooner

rich egret
#

but thank you for the time

#

I appreciate it

native seal
#

should I be using arrays of lists for an inventory system?

polar acorn
faint osprey
#
    {
        if(collision.transform.gameObject.name == "Player")
        {
            CM.Play("FadeToBlack");
            StartCoroutine(WaitForFade());
        }
    }

    IEnumerator WaitForfade()
    {
        yield return new WaitForSeconds(1f);
        SceneManager.LoadScene("basement");
    }```
#

i dont understand why its saying my coroutine doesnt exist

polar acorn
languid spire
polar acorn
#

||😉||

languid spire
#

read the code

faint osprey
languid spire
#

bet

polar acorn
slender nymph
faint osprey
#

no

slender nymph
#

then that line cannot work

faint osprey
#

why does it work in void start tho

slender nymph
#

it doesn't

polar acorn
languid spire
#

look carefully

StartCoroutine(WaitForFade());
IEnumerator WaitForfade()
faint osprey
#

i wanna die

slender nymph
#

make sure that your !IDE is configured so that you don't make silly spelling mistakes like this moving forward

eternal falconBOT
limber narwhal
#

is it best practice to make Action events static?

#

public static event Action<float> OnBetAmountUpdated; this is what i have in my "SlotMachineController" script

#

i've been wondering if i should make it a singleton as well, because it's the only one on the scene 🤔

polar acorn
limber narwhal
polar acorn
#

Basically

#

If you want everything subscribed to this event to get notified, you can use static

open sierra
#

just to make sure I understand this code

this code makes a gameobject, and the gameobject that goes inside of it will be the thing that the line of code will control, basically, the gameobject player will be the same as the attached script object?

#

also why did we use position, why not translate?

limber narwhal
#

ok, because i was watching a tutorial on it last night. what the guy did was make a whole new script just for actions and made it static altogether (even though his game had multiple enemies and would send events on enemy death).

polar acorn
#

this code sets this object's position to the position of whatever you've dragged in once per frame

open sierra
open sierra
ivory bobcat
ivory bobcat
open sierra
ivory bobcat
clever basalt
#

Hello, i have questions about Text Mesh Pro:
For some Reason i unity and visual studio (unity hub install) dont accept
using TMPro;

Ive tried to ReImport all
Reinstalling TextMeshPro
Switching between "Open by File Extension" and Visual Studio
Downgrading and Upgrading(updating) Visual Studio

I found someone saying that i need to add TMPro to my package,json but i havnt found that json anywhere

open sierra
#

orr

#

it doesnt work like that

slender nymph
native seal
#

can I have null gaps in a list or does it automatically resize to fit

ivory bobcat
slender nymph
open sierra
native seal
slender nymph
#

how should i know? you haven't bothered sharing the error or the code

clever basalt
#

go into the package manager and see if

native seal
#

sorry, no need to be rude bro

#
    {  
        for (int i = 0; i < Inventory.Capacity; i++)
        {
            if (Inventory[i].item == _item && RemainingSpaceInSlot(i) > _amount)
            {
                Inventory[i].AddAmount(_amount);
                OnItemsUpdated?.Invoke();
                return true;
            }
        }

        for (int i = 0; i < Inventory.Capacity; i++)
        {
            if (Inventory[i].item == null)
            {
                Inventory[i] = new ItemStack(_item, _amount);
                OnItemsUpdated?.Invoke();
                return true;
            }
        }
        return false;
    }```
polar acorn
native seal
#

private List<ItemStack> Inventory = new List<ItemStack>(54);

#

that is how i made the list

open sierra
slender nymph
polar acorn
#

It's just teleporting to that exact spot

polar acorn
north kiln
#

Ah it's all just semantics again

ivory bobcat
open sierra
#

gotchu gotchu

#

just another quick question

#

I don't understand how we're using 2 vector threes, and why is there a "new"

polar acorn
#

That new vector having a value of 0, 5, -7

native seal
north kiln
slender nymph
native seal
slender nymph
#

well then its count will be 0 because there are no elements in the list. you need to actually Add things to the list

ivory bobcat
open sierra
#

if hte player transform position is changing with the player

polar acorn
open sierra
#

if the player transform position is changing with the player, how is there a 2nd one changing too?

polar acorn
#

You're setting the position of this object to the position of player plus some value

calm coral
open sierra
#

so it moves the "0" but keeps the "5" and "-7"

polar acorn
#

It adds the Vector 0, 5, -7 to the position of player, and sets this object's position to that result

ivory bobcat
#

Maybe look into c# tutorials and check out Unity tutorials for how to do simple stuff !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

open sierra
#

ohhhhhhhhhhhhhhhhhhhhhhh

#

so it sets it 5, -7 above the player?

#

like the location of the camera but it still follows where it goes

polar acorn
open sierra
#

yeee

#

I get it now

ivory bobcat
#

These are referring to coordinates (x, y, z) - Vector.

desert elm
#

how do I actually-
make a unity project into a game/how I turn the unity project into an app?

desert elm
#

sorry- wasn't sure where else to ask
but thanks

native seal
#

basically when you try to swap with nothing it moves the item

slender nymph
#

have you even bothered looking at the docs to see what these methods do?

native seal
#

I did

#

man u dont gotta be rude like that

slender nymph
#

okay and tell me why you are using the Insert method then

native seal
#

im just asking in a beginner discord

#

Inserts an element into the List<T> at the specified index.

#

sounds like what i want

slender nymph
#

right it adds a new element to the list at the specified index

#

that is not what you want. you want to just assign to a specific element so it is no longer null

native seal
#

so what should I write?

#

if i just Inventory[indexTwo] = Inventory[indexOne]; it gives index error

slender nymph
#

that means that one or both of the indices is out of range

native seal
#

i know

#

why tho? i thought you could have null gaps in lists

#

my list capacity is 54

slender nymph
#

again, capacity is not representative of how many elements are actually in the list

polar acorn
slender nymph
#

a list can contain null elements. but you have to actually add them in

polar acorn
#

See which one is the problem

native seal
#

okay so initilize the whole list with null

slender nymph
#

there are beginner c# courses that teach you how to use collections like lists and arrays pinned in this channel. you should start there

slender nymph
native seal
#

should I just use arrays?

slender nymph
#

probably

native seal
#

okay

buoyant knot
#

insert normally means to slide in an entry into the middle of a list

native seal
#

oh and shift everything up

buoyant knot
#

and it costs time because you’re actually shifting the memory for everything after

desert elm
#

oh yeah- and is there a method to fetch a gameobject that was just instantiated by the script?

buoyant knot
desert elm
#

oh

supple wasp
#

what's that?

lavish stone
#

Hi, i am looking for a project template to realize a webview app. Is there a template which is recommended for such a project? I want to display my own website. No matter of costs. If it is a one-time fee.

slender nymph
#

this is a unity server mate

buoyant knot
#

But can anyone here help me with my Spanish homework?

slender nymph
#

or do you mean you want to display your website inside your unity game? 🤔

polar acorn
#

Or display a unity game inside a website maybe?

lavish stone
#

Yes i know. 😄
With unity its easy to build apps for different platforms. And there are many Webview Templates in the assetstore. I just ask if somebody can recommend a template.

slender nymph
#

okay so to confirm, you are referring to displaying your own website within your unity game?

#

and if the question is literally just about which asset you should pick, that isn't a code question

lavish stone
slender nymph
#

again, not a code question

open sierra
#

how does multiplying the inputs work?

#

I undetsnad how this works but after adding the verticalInput and horizontalInput, I don't understand how the math work with these two in them

buoyant knot
#

what type is verticalInput

open sierra
north kiln
#

you should multiply the floats together first by surrounding the lot with brackets to avoid some extra multiplications

buoyant knot
#

you are multiplying a vector by a scalar

#

forward is 0,0,1

polar acorn
open sierra
#

👍

buoyant knot
#

you should just make a single Vector3, and translate by it

#

remember the input is dimensionless, btw

#

which is part of how everything works out in the end

polar acorn
#

Is Angle an actual angle or is it a direction vector

desert elm
#

the "explosionHits.remove(collider)" line should remove all colliders from the list, right?

fresh lintel
#

at moment i'm using that angle for raycast, i suppose it's Direction vector

polar acorn
#

It seems like it's a Quaternion

desert elm
fresh lintel
fresh lintel
eternal needle
desert elm
amber spruce
#

whats the best way to have a boss with multiple stages should i spawn a different object or just change the script or smth

desert elm
#

okay is there a way to remove all colliders from a list then?

eternal needle
desert elm
#

oh okay thanks

languid spire
#

Rule of thumb, if you are removing from a List, iterate backwards

serene barn
#

im trying to do 2d movement and i can't figure it out

#

im just not to sure what to do with vector2

simple citrus
#

Hello, is there an option in unity 2D that prevents the player from being blocked by the tileset because of the Rigidbody?

simple citrus
serene barn
#

i dont know how to do rigidbody movement

simple citrus
#

did you already add a component ?

slender nymph
serene barn
slender nymph
#

that's a known issue with the Box2D physics engine which is what unity uses for 2d. you can use a collider that has a round bottom like a circle or capsule instead of a box collider. and turning the collision detection mode to continuous on the rb should help too

simple citrus
# serene barn yes

with unity you can use the velocity of a rigidbody, That's look like that "rb.velocity = new Vector2(deplacement, rb.velocity.y);",

there is a widespread technique that consists of adding horizontal keys to move your player in a desired direction "Input.GetAxis("Horizontal")". Basically, this function registers the left directional key as =-1 and right = 1, and when you press it, the value takes the key you pressed (otherwise it returns zero).

finnaly you can make the command like that:

horizental = Input.GetAxis("Horizontal");
"rb.velocity = new Vector2(horizental* deplacement, rb.velocity.y);"

#

rb.velocity.y returns the current value of your y velocity rigibody

simple citrus
slender nymph
#

then you also need to address how you control your camera

#

and obligatory: use cinemachine

simple citrus
#

i think i will use 2 box notlikethis but thanks for your tips

simple citrus
serene barn
simple citrus
#

yes

serene barn
#

yes

simple citrus
#

like that

serene barn
simple citrus
#

yes

faint agate
#

I have this weapon switch problem. Lets say Gun1 has 10 bullets and Gun2 has none. When I switch to Gun2, I can shoot only one bullet as if it registers the weapon switched when I click.

#

If you want me to send the scripts I can

swift crag
#

yes, we'll need to see your code

ivory bobcat
#

How to post !code

eternal falconBOT
faint agate
#
using UnityEngine;

public class WeaponSwitching : MonoBehaviour
{

    public int selectedWeapon = 0;
   
    private void Start()
    {

        SelectWeapon();

    }

   
    private void Update()
    {

        int previousSelectedWeapon = selectedWeapon;

        if (Input.GetAxis("Mouse ScrollWheel") > 0f) {
            if (selectedWeapon >= transform.childCount - 1)
                selectedWeapon = 0;
            else 
            selectedWeapon++;
        }
        if (Input.GetAxis("Mouse ScrollWheel") < 0f) {
            if (selectedWeapon <= 0)
                selectedWeapon = transform.childCount - 1;
            else 
            selectedWeapon--;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1)) { 
        selectedWeapon = 0;
        }

        if (Input.GetKeyDown(KeyCode.Alpha2) && transform.childCount >= 2) { 
        selectedWeapon = 1;
        }

        if(previousSelectedWeapon != selectedWeapon) {
            SelectWeapon();
        }

    }

    private void SelectWeapon()
    {
        int i = 0;
        foreach (Transform weapon in transform) {
            if ( i == selectedWeapon )
                weapon.gameObject.SetActive( true );
            else
                weapon.gameObject.SetActive( false );
            i++;
        }
    }

}
#

This weaponSwitch script works fine, I even tried another method so I think its something else causing this problem

ivory bobcat
#

What's the original problem?

faint agate
#

Lets say Gun1 has 10 bullets and Gun2 has none. When I switch to Gun2, I can shoot only one bullet as if it registers the weapon switched when I click.

eternal needle
#

where do you actually shoot?

faint agate
#

where? like the script

ivory bobcat
#

So.. you shouldn't be able to shoot any at all but are somehow allowed to shoot one shot?

eternal needle
ivory bobcat
#

Where's your shooting code?

ivory bobcat
# eternal falcon

Please post the code using an external service link if greater than 15 lines or so.

faint agate
#

thats the gun scirpt

#

like a link redirecting you to the code

ivory bobcat
faint agate
#

thats the gun scirpt

ivory bobcat
#

So, the gun isn't reloading and the elapsed time since last fire is valid.

#

I'm assuming these are the limiting factors in allowing you to shoot

ivory bobcat
#

Log the gunData

#

Is this related to Unity and coding?

pearl lodge
ivory bobcat
faint agate
ivory bobcat
faint agate
#

Gun2 doesnt even have the gun script on it. If switching the gun disables Gun1 and all its childs, than idk how Gun2 is even shooting one bullet.

native seal
#

Why is this giving out of bounds access?

{

    public event Action OnItemsUpdated;
    
    private ItemStack[] Inventory = new ItemStack[54];
    
    [SerializeField] private ItemStack itemTest;

    void OnEnable()
    {
        for (int i = 0; i < 54; i++)
        {
            Inventory[i] = new ItemStack();
        }
    }```
true pasture
#

before I go and make it from scratch is there a easily implemented system that lets the player control the camera in runtime? Basically just like in editor mode.

native seal
#

wdym

faint agate
#

I logged it, it is Gun1's bullet

ivory bobcat
# ivory bobcat Your array size isn't 54

Try:cs void OnEnable() { Debug.Log($"Inventory Size: {Inventory.Length}"); for (int i = 0; i < Inventory.Length; i++) { Inventory[i] = new ItemStack(); } } @native seal

native seal
#

Inventory Size: 54
UnityEngine.Debug:Log (object)
InventoryObject:OnEnable () (at Assets/_Scripts/Scriptable Objects/SO Scripts/Inventory/InventoryObject.cs:43)

faint agate
#

On the player, theres a player shoot script that might give you a bit more info.. one sec

ivory bobcat
ivory bobcat
#

Figure out why Gun1 is firing when you'd expect the shot to be from Gun2

ivory bobcat
faint agate
native seal
ivory bobcat
#

Previously, we were assuming that Inventory that should have 54 elements but it likely did not if there was an out of bounds error.

native seal
#

so what do I need to change

ivory bobcat
#

The console window

native seal
#

wait i think its an issue with onenable with scriptable objects

faint agate
ivory bobcat
#

Log the state of Gun1 on shoot.

#

Log ammo count, can shoot and whatnot.

#

They are the limiting factors.

faint agate
#

I logged to see when it was holding gun 2

#

it said I was holding Gun2 so idk

ivory bobcat
faint agate
#

would I put all that on update

#

if so, I did and when I switched to Gun2, it all stopped

ivory bobcat
#

Before the if-statement.

faint agate
#

what diffrence am I looking for, it says all the same stuff when I switch and shoot the one bullet. When I try to shoot a second time nothing prints

faint agate
#

I really think it has something to do with the playershoot script. It's connected to the gun script but its attached to the player and since Gun1 disables. this is the only thing allowing it to shoot a second time mabye

#

thats the playershoot script

ivory bobcat
#

Question would be why? Did the final shooting and weapon swap occurred immediately at the same time or do you've got some delay to not disable to object till after the final shot?

wraith mango
#

how do i use variables inside of a string, the variable name would be inbetween the {}

#

i didn't know how to explain this to google so here i am lol

north kiln
wraith mango
#

tokens

#

okay ty

eternal needle
#

string interpolation is the name

wraith mango
#

where did i read tokens from lol

eternal needle
#

token refers to the $ you must put at the front

wraith mango
#

alr

faint osprey
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public class LightSwitch : MonoBehaviour
{
    public Light2D L;

    // Start is called before the first frame update
    void Start()
    {
        
    }

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

    private void OnTriggerEnter2D(Collider2D collision)
    {
        StartCoroutine(SwitchTime());
    }

    IEnumerator SwitchTime()
    {
        yield return new WaitForSeconds(0.5f);

        L.enabled = true;

        for(float i = 0; i < 1.8; i =+ 0.05f)
        {
            L.intensity = i;
        }
    }
}
``` why is this crashing my unity every time the coroutine is called
ivory bobcat
#

Incrementation should be +=

faint osprey
#

right

ivory bobcat
#

= +0.1 would just be assigning it the value of 0.1

#

Also, just to let you know that what happens after in the for loop would happen immediately the current frame with no delay.

ivory bobcat
#

There isn't much to work with. Likely you've got a rounding error or the math is wrong.

#

Maybe log some position to see why it doesn't go where you're expecting it to go.

north kiln
#

use Mathf.RoundToInt, Mathf.CeilToInt, or Mathf.FloorToInt depending on what operation you actually want, instead of directly casting to int and hoping that it it works out

acoustic violet
#

im trying to make my first basic project with a light switch and ive been trying to make it so that when i click the switch, the value of TimesClicked goes up by 1 and is then read as text in the game. i keep getting issues converting int to text. i know its easy but i need some help.
Image

north kiln
#

You first need to configure VS

#

!vs

#

!ide

#

MRRR

acoustic violet
#

could you expand on that please

#

like im really beginner

polar acorn
#

It's okay the bot will show up in a bit

eternal falconBOT
#
Visual Studio guide

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

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

ivory bobcat
#

Bot seems to be down

polar acorn
#

there it is

acoustic violet
#

VS seems to be up to date but i still cant see the errors underlined

polar acorn
eternal falconBOT
polar acorn
#

there it is

acoustic violet
#

well i went to the website and i checked the instructions it had

#

and it didnt change anything

north kiln
#

Reopen VS via Unity's Assets/Open C# Project

#

if it's configured fully it should start working

acoustic violet
#

how do i open it via unitys assets, do i just open a new script?

north kiln
#

The menu Assets/Open C# Project

acoustic violet
#

i did that and it brought me to my file folder

#

should i just redownload VS?

north kiln
#

No, just configure it properly using all the instructions on the page

acoustic violet
#

okay

#

so i instialled it via unity hub so ill try that again

north kiln
#

Making sure it has the Unity workload installed, making sure Unity's External Tools preferences are set, making sure the VS Editor package is up to date in Unity

acoustic violet
#

how do i access the dropdown list

north kiln
#

please be more specific

acoustic violet
#

"It's possible to select other versions of Visual Studio that are unlisted and installed in a custom directory.

Select Browse... from the dropdown list."

#

im not where the dropdown list is

acoustic violet
#

yes i see that but where do i find the devenv.exe directory

north kiln
#

Wherever VS is installed

acoustic violet
#

like on the VS installer?

north kiln
#

It says it's within the Common7/IDE directory, where VS is installed

rocky canyon
north kiln
#

Presumably VS is installed in program files

ivory bobcat
rocky canyon
#

usually, unless u went out of ur way to install it elsewhere

rocky canyon
#

dis new?

ivory bobcat
amber spruce
#

ok

north kiln
rocky canyon
#

oh nice, for some reason i was thinking playerprefs was PC only..

#

im sure theres a few lurking around

teal viper
#

How exactly are you moving it? If the concept of being in a tile entirely is important for your game, it should be incorporated in movement logic.

acoustic violet
#

I found that and i selected devenv.exe and i think its showing red squigle lines

rocky canyon
amber spruce
#

basic state machine?

amber spruce
rocky canyon
#

well, the animation system is a statemachine..

acoustic violet
#

Okay vertx i wanna thank u so much

#

i know that was really stupid

#

but thanks it works and i found the issue

teal viper
#

That doesn't explain much.
But if you want it to be an actual snake game, where the game space is divided into discreet tiles, you'll need to move the object such that they are always within a tile or in a temporary moving state between tiles.

rocky canyon
#

its one of those things you'll repeatedly end up using, good to go ahead and learn about em, atleast to expose urself to em

rocky canyon
edgy fox
#

one says Vector3.start one says Vector3.origin, is there adiffereence between the two?

rocky canyon
#

i feel its cheating to have a snake game that uses normal transform translation lol

edgy fox
north kiln
edgy fox
#

oh yeah

rocky canyon
#

you're a beginner?

#

if you go with an RPG, go basic as possible

#

i mean extremely basic

edgy fox
#

why does this register as a hit?

#

the hitbox it hit is highlighted here

#

and there are some barely visible green raycasts

north kiln
#

why are your gizmos so invisible

rocky canyon
#

the perspective of that is really confusing lol

edgy fox
#

and idk how to increase raycast thickness

#

well drawRay thickness

#

or visibilty

north kiln
#

they should still be 1px wide and full color

edgy fox
#

they are 1px wide but I have a 2560x1600 screen

north kiln
edgy fox
#

nvm turned 3d gizmos off

odd mason
north kiln
#

and my stuff looks totally fine

odd mason
#

what im i doing wrong here, it says there are two errors, this is getting annoying

edgy fox
#

3d gizmos apparently murders drawRay

rocky canyon
teal viper
#

I'd do it with lerping instead of velocity, but it's not impossible with velocity or even both
Here's some pseudocode to give a thought:

if !moving and input != 0
  moving = true
  nextDestination = currentTilePos + input //here both tile position and input should be a discreet number, so that you get the next discreet tile position
  t = 0
if moving
  t += deltaTime;
  position = lerp(currentTilePos, nextTilePos, t)
  if t >= 1
    moving = false
    currentTilePos = nextTilePos
odd mason
#

thanks

edgy fox
#

alright the same bug recreated - what causes this to read as a hit?

north kiln
edgy fox
#

drawline vs drawray?

#

like whats the difference

north kiln
#

!docs

eternal falconBOT
teal viper
edgy fox
#

one goes forever?

north kiln
#

I mean to draw the ray and the hit, instead of just drawing the complete cast without knowing where it terminated

#

No

edgy fox
#

whats line vs ray difference

north kiln
teal viper
#

One is between 2 points. The other has an origin and direction.

edgy fox
#

ah yeah ok

teal viper
#

But do read the docs

edgy fox
#

alright

rocky canyon
edgy fox
#

yeah realized now

rocky canyon
#

i was already painting.. had to finish

edgy fox
#

mathematically though unity rays function kinda like line segments since they still have a finite length

#

and mathematically lines are also line segments

#

(the mathematician in me speaking)

rocky canyon
edgy fox
#

so true

rocky canyon
#

but yea, u got the idea

edgy fox
#

but for the debug code you gave me, what would the point ray.origin be?

north kiln
#

the origin of the ray

edgy fox
#

so just transform.position?

north kiln
#

yes

rocky canyon
frail star
#

If I have this

[System.Serializable]
public class Wave
{
    public string name;
    public GameObject enemyPrefab;
    public int count;
    public float rate;
}

How Can I get access to the enemyPrefab for each wave?

rocky canyon
#

referenceToWave.enemyPrefab;

edgy fox
#

how is this a hit?

#

full code block

rocky canyon
#

also what does the console say?

north kiln
#

Can you open Window/Analysis/Physics debugger

#

and enable Collision Geometry

edgy fox
edgy fox
north kiln
#

in the scene view for me

#

in my version it's an overlay

edgy fox
#

what tab of the physics debug

north kiln
#

Any

edgy fox
#

hmm I don't see collision geometyr

rocky canyon
#

u dont have the bottom right overlay?

edgy fox
#

nope that isn't there for me

north kiln
#

Can you move the window so you can actually see the bottom right of the scene view?

edgy fox
#

:/

#

it was under it

#

alright after I select that what do I do?

north kiln
#

Can you see what it's hitting now?

edgy fox
#

its hitting something with a different layermask

#

it's hitting something with mask fakeWall but the mask says to only hit realWall

north kiln
#

show how you declare the mask

edgy fox
#

(wallMask is realWall)

north kiln
#

and show the object it's hitting?

edgy fox
#

wait nvm it still says its hitting WallEZ

#

wallEZ is the only rendered wall here

#

and thats what the debug log says its hitting

#

with its hitboxes highlighted

north kiln
edgy fox
#

already did

north kiln
#

No, you didn't

edgy fox
#

unless I misunderstand what youre saying

#

oh

#

what do you mean then?

summer stump
#

It's about the second (context) parameter of Debug.Log

edgy fox
#

so would this ping it?

north kiln
#

Yes

edgy fox
#

what does the ping look like because there are no visible changes

summer stump
edgy fox
#

ah true

#

Debug.Log($"Hit object {hit.transform.name}@{hit.transform.position} from {transform.position} with run index {i}", hit.transform.gameObject);

#

Debug.Log($"Hit object {hit.transform.name}@{hit.transform.position} from {transform.position} with run index {i}", hit.transform.gameObject);

summer stump
edgy fox
#

oh ok