#💻┃code-beginner

1 messages · Page 711 of 1

sour fulcrum
#

This server

#

It breaks terms of service

toxic cove
sour fulcrum
#

Second last point in prohibited behaviour in code of conduct

sour fulcrum
#

no

toxic cove
# sour fulcrum

Didn't even think that rule would be in there lol. Sorry, I won't do it again.

sour fulcrum
#

We chilling

#

No one hates you for it or anything just can’t support it here

toxic cove
snow jewel
#

Why am I getting this error even though I assigned the panel in the inspector? Should I send the corresponding script as well?

rich adder
snow jewel
rich adder
#

yea

#

you can search hierarchy t:yourscriptname

snow jewel
#

its only on one of my objects

rich adder
snow jewel
#

i have this method on a button in the scene

    {
        panel.SetActive(true);
        panel.transform.SetAsLastSibling();
    }```

double clicking the error sends me to this line
#

panel.setactive(true) line

#

i just put a debug log and the method is registering

#

the panels are messed up and idk why

rich adder
snow jewel
wintry quarry
snow jewel
#

i fixed it. the problem was cuz the panel wasnt assigned in the prefab. the panel isnt being set active still

#

the panels in my hierarchy are messed up i think because this is a simple show method that just sets the panel active but the assigned panel isnt being set active s

#

could it be because its a prefab?

wintry quarry
wintry quarry
snow jewel
#

hold on

#

yeah the button isnt activating the panel

#

the debug i added is showing up in the console but the panel isnt getting activated

#

nevermind

#

i fixed it

surreal sable
#

Can i get some tips from people?

I'm trying to create a game while handling the backend myself. Admittedly, I'm not much of a game developer however i do have some experience in backend. Do people usually use cookies/jwt?

rich adder
rough granite
#

what type of game uses cookies? especially in relation to unity

rich adder
#

just don't attempt to write your own..seen some sketchy stuff lol

surreal sable
wintry quarry
#

You are making a game with some networked features? What are those features?

surreal sable
#

It is mainly offline but i do want to save user progress

surreal sable
wintry quarry
#

one option is to just use Steam cloud save

#

you barely have to do anything

#

it's much nicer than forcing your users to create a new account somewhere

wintry quarry
surreal sable
#

I think one of the issue that this is kind of a research project where they prefer to store the data onsite or within the big providers (I think they should be fine with something like Azure PlayFab too)

wintry quarry
#

yes there are plenty of services offered by the hyperscalers too

surreal sable
#

Thank you!

rich adder
#

Unity cloud save is pretty good used it plenty of times and their free tier is decent

boreal plinth
#

How do I access a public list? For public variables, it's just

public MoneyManager moneyTotal;
int oldValue = moneyTotal.money;

But when I do similar to lists, it just makes a new list in a different object.

#

The part I'm referring to, I // out

teal viper
marsh canyon
#

question... not sure why but the Mouse Cursor logic doesn't seem to work here

#
    void MenuActivationMethod()
    {
        if (isPaused)
        {
            settingsCanvas.alpha = 1;
            settingsCanvas.interactable = true;
            settingsCanvas.blocksRaycasts = true;

            Cursor.visible = true;
            Cursor.lockState = CursorLockMode.None;
        }
        else if (!isPaused)
        {
            settingsCanvas.alpha = 0;
            settingsCanvas.interactable = false;
            settingsCanvas.blocksRaycasts = false;

            Cursor.visible = false;
            Cursor.lockState = CursorLockMode.Locked;
        }
    }
keen dew
#

Doesn't work in what way?

marsh canyon
#

the cursor stays visible and it doesnt get locked in place

#

the settingsCanvas logic works as intended though

rich adder
marsh canyon
#

I have a TEMPORARY workaround with using Playmaker to grab the isPaused variable and then use FSM logic to do it.... but I am trying to do it in C#

But I can confirm the mouse logic at least works.... with Playmaker. Just not with this code. (Obviously I dont have both at the same time)

boreal plinth
teal viper
boreal plinth
#

Oh you mean the source script. I’ll get that when I’m home

keen dew
teal viper
boreal plinth
#

Okay, then how do I access it because that’s what it told me to do when I looked it up

teal viper
marsh canyon
#

no errors, warnings, or anything

boreal plinth
#

Thank you

marsh canyon
#

turn off the Playmaker FSM but turn on the C# Script? = nothing works
turn off the C# script but turn on the Playmaker FSM? = it works

#

which from a very basic test perspective..... is fine I guess.... but when I do a REAL menu and settings and all that good stuff.... it cant be like this

#

and a lot of online searches seem to say its supposed to be Cursor.lockState or Cursor.visible as shown in the code above

teal viper
naive pawn
#

if you have a specific issue, !ask

eternal falconBOT
naive pawn
#

if you just want work done, !collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

boreal plinth
#

Just a heads up, otherScript.field also needs a declaration which is what I was tryna do

ivory bobcat
#

Was the question resolved?

vernal salmon
#

I'm working on making a platformer player controller template for a tutorial I'm working on but I'm trying to remember which parts of a player controller is best to put in the fixed update. I tried leaving the inputs in update and the rb.velocity in fixed update but it kept making jumping very odd. Should I just leave everything in update or am I missing something?

boreal plinth
#

Nope. I thought I was able to declare it, but it's still acting like there are two different lists

naive pawn
#

what was your question?

naive pawn
#

your description of the issue is kinda vague. perhaps show the issue and relevant !code

eternal falconBOT
vernal salmon
#

with using fixedupdate

boreal plinth
vernal salmon
#

where are you reading the value of the list?

#

it would be like get reference of TimeDisplay and that that reference ex. TimeDisplay.ownedItems

boreal plinth
#

if (listToShowBoughtItems.ownedItems.Contains(objectName))

#

listToShowBoughtItems is the actual script name

#

I just can't rename the tabs on this website

vernal salmon
#

and you're sure this name change is on both the script and unity

#

If you changed the name just in unity it would duplicate the script but inside both scripts it would keep this name

#

That could be your issue

#

Unless you didn't change the name

boreal plinth
vernal salmon
#

and what's the error?

boreal plinth
#

In my game, I purchase a thing, and in the Buy gameobject, it shows the list and it shows that the thing is on the list. When I look at the list on a different gameobject that uses the script, there is nothing on the list

vernal salmon
#

In the script ShowboughtObject have you passed the list where the bought objects go to the listtoshowboughtitems variable? Cause in the script you create a new list but never get a reference to this list

boreal plinth
#

I have listToShowBoughtItems.ownedItems.Contains(objectName), but if that's not what you mean, then I don't know that I have a reference

vernal salmon
#

in the inspector

#

you have to drag and drop the script for the listtoshowboughtitmes into that variable

#

you're trying to get an object from nothing

keen dew
#

You are creating a new ListToShowBoughtItems object instead of using the existing one. It should be [SerializeField] ListToShowBoughtItems listToShowBoughtItems; and then drag the object there

vernal salmon
#

yea

boreal plinth
#

Like this?

vernal salmon
#

make it a [SerializeField] or public first

#

and then put the script into the new filed that will show up

boreal plinth
#

The list? It is public

keen dew
boreal plinth
#

Ah okay

vernal salmon
#

explained it wrong

#

sry

boreal plinth
#

Np. I'm learning. We're good

#

Oh shit it worked

#

Thank you, seriously

sour fulcrum
#

yup, two things to note specifically

anything deriving from MonoBehaviour cannot be made by doing a new() instance of it, they don't work.
even if that worked, this code points to that new instance of it made via code, and not the instance of it that currently lives on the same object that your now referencing correctly

boreal plinth
#

Gotcha gotcha

vernal salmon
#

this worked since you created a new script, it foudn a list but it was empty so it wasn't then activating that if

boreal plinth
#

Yeah

vernal salmon
#

Quick question - For respawning in a platformer game Adding checkpoint mechanic should I reload the scene and set their position to the latest checkpoint or just set their position without reloading scene?

eager spindle
vernal salmon
#

Yeah I was thinking about that. I could maybe make a bool and you can choose for each level

lunar coral
#

hello, I'm trying to make a gun system for my game, so I watched a tutorial showing a system that works for all type of gun, but it doesn't work, do you think there's an issue in the script or the problem is with the particles?

ivory bobcat
#

Maybe you should describe what is supposed to happen and what happens instead

lunar coral
ivory bobcat
#

Have you tried logging any messages?

lunar coral
ivory bobcat
#

Well.. place some logs and see what's occurring and not occurring

lunar coral
#

Okay ill do that

dense mulch
#

Anyone have any idea where UnityEditor.SpriteEditorWindow lives in the Unity codebase now?

daring sentinel
#

Quick question on performance, I'm currently deciding between List or Hashset and this is my use case:

  • n <= 5

  • The idea is that I want to use this data structure to determine whether to pause some coroutines.

  • I don't care about order and while duplicates are not a detriment, it's probably ideal that they are not a thing.

  • The data type of the elements in my structure will be strings.

  • Because I'm using it to pause coroutines, then potentially I would be checking this every frame at runtime.

Pretty much, I feel like because of the frame by frame checking it's probably best to go with Hashsets, due to faster lookup, but because of the number of elements being so small, I'm not sure if I'm just better off going with a list?

#

Sorry if this is the wrong place to ask this, thought it made the most sense to ask in this channel.

#

The reason I have done this frame by frame, is because I'm using coroutines to update progress bars

naive pawn
#

you can start worrying about perf when n gets to like, the 10000's range

#

write what makes sense first, don't worry about perf now - that's called premature optimization

daring sentinel
hot wadi
#

Should I use a Stack to keep track of menus UI?

naive pawn
#

if that makes sense for the behavior you want, sure

hot wadi
#

I'm more concerned about the performance

naive pawn
#

are you gonna have 10000 menus at the same time

#

no? then there's no perf concern. computers are fast
don't worry about perf until either it becomes a problem, or you're dealing with stuff in the millions

teal elk
#
    {
        if (Physics.Raycast(interactionPoint.position, interactionPoint.forward, out RaycastHit hit, interactionDistance, interactableLayerMask))
        {
            if (hit.collider.TryGetComponent(out IInteractable interactable))
            {
                Debug.Log($"Looking at: {hit.collider.gameObject.name}");
                if (Input.GetKeyDown(KeyCode.E))
                {
                    interactable.Interact();
                    Debug.Log($"Interacted with: {hit.collider.gameObject.name}");
                }
            }
        }
    }

what is causing this not to trigger , each interatbale object on with the interactbale layer has a script that implements the IInteractable interface and cuase the interact fucntion implmted on each script , it detects which objects i am looking at but nothing happens when are press e each object has collider and is not set to trigger.

UnityEngine.Debug:Log (object)
Interactor:Update () (at Assets/Scripts/Interactor.cs:17)

Looking at: cardboardBoxClosed
UnityEngine.Debug:Log (object)
Interactor:Update () (at Assets/Scripts/Interactor.cs:17)
keen dew
#

The first thing to do would be to either set collapse on in the console or remove the "looking at" debug because it's probably drowning out the "interacted with" debug. And make sure there are no errors shown when pressing e

shrewd patio
#

Does anyone have been struggling to do a Ladder system with tilemap collider in unity ?

lavish maple
#

can someone help e i have a grind system and a paht with fences the fences should go away if a path is in fron tor to the side my codes js dont work

teal elk
#
{
    public void Interact();
}```
```public interface IInventoryInteractable : IInteractable
{
    void Interact(InventorySystem inventory);
}``` 
will this work as a good enough interacting ssytem or is it bad and not scable  if i need differnt types of interactbale objects in the future
hexed terrace
#

3x ` then cs at the start of a code block

teal elk
carmine ocean
#

hey i have an issue when making a camera controller, im really new and this is the first real attempt at unity so please do inform me of any mistakes, i was following a tutorial and i found an issue where i cant move the camera left and right could someone help me out?


public class FirstPersonCameraController : MonoBehaviour
{
    public Transform Player;
    public float mouseSensitivity = 2f;
    float cameraVerticalRotation = 0f;

    void Start()
    {
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        float inputX = Input.GetAxis("Mouse X")*mouseSensitivity;
        float inputY = Input.GetAxis("Mouse Y")*mouseSensitivity;

        cameraVerticalRotation -= inputY;
        cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation, -90f, 90f);
        transform.localEulerAngles = Vector3.right * cameraVerticalRotation;

        Player.Rotate(Vector3.up * inputX);
    }
}```
#

(im on win11 and my unity vers is 6000.0.51f1)

wintry quarry
carmine ocean
wintry quarry
carmine ocean
#

what would you need to see?

wintry quarry
#

Your hierarchy and the inspectors of the objects involved

carmine ocean
#

is this good?

wintry quarry
carmine ocean
#

and i apologise i just realised what you ment by heirarchy

wintry quarry
#

You put the script on both objects

#

This script should only be in the Main Camera object

#

It should not be on the Player object

carmine ocean
#

oh yeah its fixed now

#

thank you so much

teal elk
# teal elk i will always be inherting from the IInteractable

i change to using thsi isntead for now using UnityEngine;

{
    void Interact(InteractableContext context);
}```
```public class InteractableContext
{
    public InventorySystem Inventory { get; private set; }
    public GameObject Interactor { get; set; }

    public InteractableContext(InventorySystem inventory, GameObject interactor)
    {
        Inventory = inventory;
        Interactor = interactor;
    }
}```
warm tree
#

Hi. I started coding movement in a 2D project and I'm only using basic shapes right now (rectangle for player, ground, walls etc). I made a Slide that works, the problem is that if I'm too close to the obstacles that I want to slide under, my boxcollider size and offset aren't reduced fast enough it seems, so I stay stuck on it and don't go under. I put the boxcollider.size and offset code in the Input to change the size immediately, I even tried putting Physics2D.SyncTransforms(); under the boxcollider code, but it's not working. Any tips?

hot wadi
#

I don't understand why OpenMenu() breaks my pause logic, even though isPaused is set to true

{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        if(_isPaused == false)
        {
            _isPaused = true;
            OpenMenu(_pauseMenu);
            PauseGame(_isPaused);
        }
    }
}

public void OpenMenu(GameObject menu)
{
    if(_menuList.Count != 0)
    {
        _menuList.Peek().SetActive(false);
    }
    menu.SetActive(true);
    _menuList.Push(menu);
}```
#

It does not load the assigned UI menu, nor does it pauses the game, unless I remove OpenMenu()

keen dew
#

That code will only do anything if _isPaused is false so if it's true then not doing anything is expected

hot wadi
keen dew
#

You need to do some debugging and make sure no errors show up when you press esc

grand snow
#

with a function that easy to understand it should be clear whats wrong

hot wadi
#

Oh, I have to instantiate the _menuList stack first. It did not recognize the reference of the stack

grand snow
#

oh so there was a null ref exception?

hot wadi
#

Yeah, I did not see it earlier

ivory bobcat
keen dew
grand snow
#

in editor it wont eat up inputs but esc will force a mouse unlock

patent wedge
#

so in my game the player will be able to sit down so should i have the camera seperate and just disable player movement or is there a cleaner method?

rich adder
patent wedge
rich adder
patent wedge
patent wedge
rich adder
olive yoke
#

Beginner here notlikethis

#

Can't manage class 11th and this together atwhatcost

slender nymph
#

just FYI, this isn't a social space. if you need help with something then !ask otherwise please don't spam nonsense in the channels

eternal falconBOT
west garnet
#

I have a scene change where the player as to walk to a portal to have the final boss fight,
the enemies need the player Transform to detect where it is but because the player only goes to the boss fight scene when he walks through the portal how can i put the players transform in the Enemies script inspector? dont know if this sounds dumb or not

wintry quarry
#

What do the enemies use the player's Transform for?

west garnet
# wintry quarry What do the enemies use the player's Transform for?

okay this may sound very dumb ( and it is )
this is for my programing class and the prof just gives us scripts and doesnt tell us anything abt it which is honestly pretty stupid and i have complained
the players transform its in a state machine that he did and just gaves us without any explanation
i think its for player detection but honestly not quite sure as he just gave us the script and told us to use this

wintry quarry
# west garnet okay this may sound very dumb ( and it is ) this is for my programing class and...

well without details it's hard to say. There are a few options in general though:

  1. Opportunistic assignment. Basically using something like a physics callback (OnTriggerEnter) when the player gets near the enemies to get the reference.
  2. Use the singleton pattern with a static accessor property, assuming there is only one player object at any given time
  3. Something like FindWithTag
  4. Use a static event for the player to announce his entrance to the scene and pass the references
ivory bobcat
#

To get coding help, usually you'd provide some necessary information about the problem/behavior, share code and screenshots etc

west garnet
wintry quarry
#

you already have it

#

(no idea how that's related to "keeping health" etc though, that doesn't make sense to me)

west garnet
west garnet
west garnet
rich adder
#

this professor get their teaching license in a cereal box ?

slender nymph
#

sounds more like this person isn't paying attention in class and skipping classes so they aren't fully understanding the information provided by the teacher

rich adder
#

could be yea

#

programming has a lot of concepts, its very rare they will throw you to the wolves like that

west garnet
west garnet
rich adder
#

sounds like you didnt pay attention last semester then lol

#

its still pretty awful if you actually asked for clarification and they "refused"

west garnet
ivory bobcat
#
{
    player = PlayerManager.Instance;```
west garnet
rain trench
#

hey guys, how do i stop my sprite from completely stopping movement in any direction when it collides. it wont slide on the floor thing i made like i wnat it to, it just stops moving no matter what i do

rich adder
rain trench
#

alright umm

rich adder
#

"what I want it to do" vs "what I coded it to do " are different thing

rain trench
#

alright, i coded my triangle to move when i press wasd (using addforce). i have another square below it with rigidbody2d and boxcollider2d and the triangle falls and hits the square and stops moving. i try to move it with wasd but that doesn't do anything. it works while the triangle is falling though.

#

my script is here: ```cs
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
InputAction moveAction;
public float speed = 5;

Rigidbody2D rb;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    moveAction = InputSystem.actions.FindAction("Move");
}
void Update()
{
    Vector2 moveValue = moveAction.ReadValue<Vector2>();
    rb.AddForce(moveValue);
}

}

ivory bobcat
#

Look in the inspector and verify the force being applied to the Rigid body?

rain trench
#

wdym

ivory bobcat
#

Check the rigid body component in the inspector

#

There ought to be some visible fields below (may be collapsed) that show velocity and other useful data.

#

A random example from the net

arctic flame
#

Hows the documentation?

rain trench
#

they are basically stuck at 0

cosmic quail
ivory bobcat
polar acorn
#

Try logging moveValue and rb.linearVelocity after your addforce line

cosmic quail
#

is the movevalue too low?

ivory bobcat
#

I was trying to avoid spamming the console but that would be the best method

cosmic quail
#

not me 😄

ivory bobcat
#

Maybe it's not related to the script but rather your Input Action?

#

Log move value as Digi suggested

#

If it's always zero, you've simply got no input from the action - misconfiguration etc

rain trench
#

No it works when I’m in the air or when i lock y value but it immediately stops everything when i hit the square below

ivory bobcat
#

Do you've got some script that disables/stops your input?

rain trench
ivory bobcat
#

Do you've got any errors in the Unity Editor console window?

rain trench
#

No

ivory bobcat
#

Can you show a screenshot of your move value and linear velocity?

#

Console logs like Digi had suggested

rich adder
ivory bobcat
#

If they're able to move in the air but not on the ground and it's inverted by chance... UnityChanWIP

rain trench
rich adder
#

I wonder if they move addforce ground may have too much friction for the amount of force applied

rain trench
#

thats what i was thinking but idk how to change friction

rich adder
#

they do have physics material you can change it on, before doing that you should confirm thats what it is also have you logged the velocity like suggested, whats the value on ground

ivory bobcat
#

The normal process would be creating a new physics 2d material, modifying its parameters (friction etc) and applying the physics material to the object

upbeat dirge
#

Hi everyone what is the correct way to get value from multiple input after click on a button or press enter?

rich adder
#

almost everything in computers is input -> output

upbeat dirge
rich adder
upbeat dirge
#
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class GetInputOnClick : MonoBehaviour
{

    public Button SendBtn;
    public TMP_InputField TextInput;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        SendBtn.onClick.AddListener(GetInputOnClickHandler);        
    }

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


    public void GetInputOnClickHandler()
    {
        Debug.Log("Log input:" +  TextInput.text);
    }
}

rich adder
upbeat dirge
rich adder
upbeat dirge
rich adder
upbeat dirge
azure hemlock
#

is there way to make compiling faster

#

i diaabled domain rolaid, helps but still super slow

#

10seconds per code change

#

driving me insane

rich adder
azure hemlock
#

im on i7 12th

#

i would of have but i9 is too expensive

frosty hound
#

You have two options:

  1. Better hardware
  2. Purchase HotReload on the asset store
#

Unity is addressing the compiling times in Unity 7, but until then it is what it is.

azure hemlock
#

hotreload is low key garbage no? causes lots of errors ? correct me

frosty hound
#

How do you want me to correct you?

azure hemlock
#

am i wrong

frosty hound
#

Why do you think you're right?

#

In your opinion, how is it "low key garbage"?

azure hemlock
#

idk maybe cuz unitys already builtin hotreload is 🗑️

frosty hound
#

When I say purchase HotReload on the asset store, I mean the third party plugin.

azure hemlock
#

yes yes, but how does it work how is it any different

frosty hound
#

Because it works? The underlying nitty gritty is irrelevant.

quick fractal
#

It's high key pretty good

slender nymph
frosty hound
#

There's that to. Domain Reloading has nothing to do with compiling times when making code changes. You're getting confused there too.

#

That's for starting up play mode.

azure hemlock
#

true not for compiling but reloading large code suffers

#

regardless of compiling

frosty hound
#

Hence, get Hot Reload

azure hemlock
#

anyway i will look at that hotreload

polar acorn
#

Do you want solutions or do you want to complain?

#

Because it sounds like you just want to complain

azure hemlock
#

any bad limitations?

frosty hound
#

Like, as in worse than waiting however long you are for code compiling?

azure hemlock
#

limitations like doesn't support some libraries, maybe reflection or generics or doesn't reload some things

frosty hound
#

You can read the documentation and reviews for that, if those limitations exist.

azure hemlock
#

alright then thanks. one more question how did u know un7 will fix it is there blog and any idea when un7 coming

rain trench
#

Are there alternatives to using addforce for movement or is that the primary suggestion?

polar acorn
#

Tons.

Setting velocity directly
Using MovePosition
Using a CharacterController
Using transform
Using Kinematic Character Controller
Using Animations with Root Motion

#

It depends on how you want it to move

azure hemlock
#

usually never move your character with a rigidbody. unless you know what you are doing

polar acorn
#

Of all of the wild things I suggested Rigidbody is not the one you should be saying to avoid

#

Rigidbodies are fine

azure hemlock
#

not for 3d character controllers though

#

you have to manually calculate physics

ivory bobcat
#

Depends on how much you'll have to do-undo.

azure hemlock
#

and use collision functions unity provides

polar acorn
azure hemlock
#

and calculate tangent

#

physics engine is not for characters

polar acorn
#

It is if you want your character to have physics

azure hemlock
#

you want something deterministic and fully controllable

polar acorn
#

Again, it depends on what you are trying to do

azure hemlock
#

yes just what j said

#

unless you know what you are doing, any of the above (except transform position) is not good

polar acorn
azure hemlock
#

rootmotion yes

#

transform position + capsule collision functions and a custom gravity are the best

#

and not hard to code

slender nymph
polar acorn
#

You'll need to code all of your collision logic by hand

#

If you're going to do that, you really should be using a Kinematic rigidbody

#

If you specifically want to avoid dynamic physics, the step down from that is "Kinematic Rigidbody using MovePosition" not "Manually via transform"

ivory bobcat
azure hemlock
#

hey, i proposed/advised against the usually correct solution and its your choice.

rain trench
#

Something that bounces like slime

rich adder
#

there is no softbodies by default

ivory bobcat
#

Check out the asset store, perhaps

rain trench
#

oh ok

polar acorn
#

It's actually a very very complicated problem in game development

rain trench
#

isnt the asset store for assets? What other stuf is in there

polar acorn
#

Softbody physics are significantly more difficult to compute

rain trench
polar acorn
rain trench
#

Isnt softbody a component then

rich adder
#

no

rain trench
#

Oh

polar acorn
#

It's actually a very very complicated problem in game development

#

Softbody physics are significantly more difficult to compute

rain trench
#

But u cant obtain new components or smth?

polar acorn
rain trench
#

Idk 🤷

rich adder
ivory bobcat
rain trench
#

alright

#

Thanks

hybrid tapir
#

for CCD usage in scripts, is unitywebrequest the only way to do it?

i was thinking i could add another
using this;

wintry quarry
hybrid tapir
#

cloud content delivery

wintry quarry
hybrid tapir
#

thanks for that

rotund root
#

why isn't my projectile moving?

public class Fireball_Behaviour : MonoBehaviour
{
    public float fireballSpeed = 10f;

    private void Update()
    {
        transform.position += transform.right * Time.deltaTime * fireballSpeed;
    }
wintry quarry
polar acorn
rotund root
wintry quarry
#

but you absolutely don't want to move a Rigidbody via the Transform like that

covert summit
#

Send code

polar acorn
# rotund root

You don't appear to have this component on the object, or you haven't saved it. There's no fireballSpeed on this component

wintry quarry
#

It's there

#

It's called Fireball_Behaviour

polar acorn
#

There's a script with that name but it doesn't match the field defined in the code snippet

wintry quarry
#

oh you're right

polar acorn
#

So it's either a different component with that name or it hasn't been saved

wintry quarry
#

yeah probably you haven't saved your code @rotund root

#

I saw one variable and assumed it was the speed

rotund root
#

i saved, i can see the green bar on the side

wintry quarry
#

well somethign is wrong because we don't see the right variable in the inspector

covert summit
#

public class Projectile
{
public float speed = 10f;
public Vector3 position;
public Vector3 direction;

public Projectile(Vector3 startPosition, Vector3 moveDirection)
{
    position = startPosition;
    direction = moveDirection.normalized; // Ensure direction is normalized
}

public void Update(float deltaTime)
{
    position += direction * speed * deltaTime;
}

}

polar acorn
rotund root
#

i reapplied the script to the prefab and it shows up now

polar acorn
#

(Assuming the speed is non-zero)

rotund root
# polar acorn Is it moving now?

now i'm getting this error 🐒

        // Fireball spawn
        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (isOnCoolDown == false)
            {
                Instantiate(fireballPrefab, LaunchOffset.position, transform.rotation);
                isOnCoolDown = true;
                StartCoroutine(FireballCooldown());
            }
        }
    }
wintry quarry
#

you didn't assign the prefab variable

polar acorn
rotund root
#

it wont let me drag to it for some reason

polar acorn
#

Definitely looks like you have two scripts with the same name

#

And your variable of the other script, the one with Lifetime

rotund root
#

oh i removed that part when was asking the question above

ivory bobcat
rotund root
#

that's for despawning the fireball

#

oh yeah i know what's wrong now, a typo in the playercontrol cs, thanks to whoever mentioned that and deleted within 1 sec

#

its working now!

unique spear
#

can i get help with unity net code here

tame relic
#

I'm not getting any intellisense on my C# Scripts. I don't know if my code is correct or not since it can't find the references

#

I have the Unity Extension, Visual Studio Editor package on Unity, and C#/C# Dev Kit Extensions

rich adder
remote sparrow
#

Guys I'm making flappy bird with a gun and for my script that spawns the pipes I want to spawn other things to and not have them overlap any idea how?

rich adder
#

there are other ways but are more math heavy

#

you can also do poisson disc sampling

potent eagle
#

What is the purpose of ‘static’ within a function? It makes the code run otherwise it’s void?

polar acorn
potent eagle
slender nymph
#

I understand it’d belong to boolian if I wrote “static bool”
well that's certainly untrue

potent eagle
slender nymph
#

it would be a static method (as in a method not associated with a specific instance of the object) that returns a bool. it has no other association with bool

rich adder
#

bool is the type. static means its belonging to class
Eg MyClass.isPositive(num)

polar acorn
#

A static method belongs to the concept of Cat itself rather than any individual cat.

potent eagle
#

Thank you all so much. This definitely helped me understand it a lot more than the tutorial I was watching. I appreciate the help!

west garnet
#

i got this code

void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ 
    
    
    player = GameObject.FindWithTag("Player");
    spawnPoint = GameObject.FindWithTag("SpawnPoint");
    
    
    if (player == null) Debug.LogError("Player not found!");
    if (spawnPoint == null) Debug.LogError("SpawnPoint not found!");
    
    if (spawnPoint != null) player.transform.position = spawnPoint.transform.position;  
    else Debug.Log("No spawn point"); 
}

this is to make the player spawn in a specific point ( might not be the best option )
but the player doesnt spawn in the right place, when i used the debugger all of this happens and then the scene loads which i think this is why
any clue on how can i delay when this script happens or make it load only when the scene is loaded?
i was suggested by a class mate to use a singleton, dont know if that would work or not

wintry quarry
hazy slate
wintry quarry
#

You can change it in code on the Rigidbody

hazy slate
#

do I change that in the inspector like Rigidbody settings?

west garnet
hazy slate
wintry quarry
west garnet
#

wait
if i make the script another way and attach it to the empty

wintry quarry
#

Yes, that latter thing

west garnet
#

wouldnt that make it on start of the second scene?

wintry quarry
#

Start is run on objects, not scenes

west garnet
wintry quarry
#

When you load a new scene, all the objects that are activated in it will run Start after the scene loads

west garnet
wintry quarry
west garnet
acoustic belfry
#

hi, how would this go on 3d?

    {
        if (HasHitValeria) return;
        Vector2 MacheteRange = new Vector2(attackRange, attackRange);
        Collider2D hitEnemy = Physics2D.OverlapBox(meleePos.transform.position, MacheteRange, 0f, victim);
        if (hitEnemy != null)
        {
            if (hitEnemy.TryGetComponent(out valeriaController64 enemy))
            {
                enemy.TakeDamage(meleeDamage);
                HasHitValeria = true;
            }
        }
    }

i know i have to put the vector2 into vector3, but the other parts are what seems complex

#

what "FirstOrDefault()" does?

rich adder
#

its an extra float, adjust the axis as needed . At least with 3D you can use the physics debugger and see what the physics queries look like accurately compared too gizmos

foggy spade
#

public class CameraMovement : MonoBehaviour
{
    public float XRotation;
    public float YRotation;
    public Transform player;
    public float mouseSensitivity = 3f;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

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

    void PlayerInput()
    {
        XRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
        YRotation += Input.GetAxis("Mouse X") * mouseSensitivity;

        XRotation = Mathf.Clamp(XRotation, -90f, 90f);

        transform.localRotation = Quaternion.Euler(XRotation, YRotation, 0);
        player.transform.rotation = Quaternion.Euler(0, YRotation, 0);
  
    }
}
 ``` for some reason my player isnt rotating
rich adder
acoustic belfry
#

btw do this script may present some issues like idk, optimization or smt?

    {
        if (HasHitValeria) return;

        Vector3 macheteRange = new Vector3(attackRange, attackRange, attackRange);
        Collider[] hitEnemies = Physics.OverlapBox(meleePos.position, macheteRange / 2, meleePos.rotation, victim);

        foreach (Collider hitEnemy in hitEnemies)
        {
            if (hitEnemy.TryGetComponent(out valeriaController64 enemy))
            {
                enemy.TakeDamage(meleeDamage);
                HasHitValeria = true;
                break; // Avoid hitting multiple times in one swing
            }
        }
    }```
rich adder
#

you just have to predefine size of collider[] with a variable beforehand

acoustic belfry
tropic sparrow
#

Which is faster on the internet: free Proton 2 multiplayer or dedicated server?

rich adder
# acoustic belfry nonAlloc?

when you do physics queries with multiple results they usually have a nonAlloc version , meaning Non-Allocating . it might be fine if you call this once in a while but calling it often will create a new array every time , it can get slow

acoustic belfry
rich adder
#

define the size of max amount of colliders you think you will hit with Collider[]

acoustic belfry
#

how

rich adder
#

wdym how ? you surely made an array in a varible before

acoustic belfry
#

i dont recall it

rich adder
#

Collider[] colliders = new Collider[MaxSize]

acoustic belfry
#

im just doing random stuff for check if works on 3D

tropic sparrow
#

Which is faster on the internet: free Proton 2 multiplayer or dedicated server?

rich adder
#

those two are completely different things..

#

if you need to ask such questions, you ain't ready to make multiplayer tbh

#

also don't crosspost @tropic sparrow

acoustic belfry
#

the size of the collider?

tropic sparrow
#

I have a 3D aset with a dedicated server and another aset with Proton 2 Free. I want speed and a lot of players. Please tell me which aset is best for me to work with.

rich adder
tropic sparrow
#

both online multiplayer

acoustic belfry
rich adder
tropic sparrow
#

It's vague because I'm a newbie, but I'm looking for help from people like you.

acoustic belfry
#

btw isn't there another way to make this script go 3D?

rich adder
rich adder
#

works the same way except 3D physics engine / colliders

acoustic belfry
#

no but i mean, the [] thing

#

or this issue also would happen on 2D?

rich adder
#

you asked for optimized suggestions way of the code, i said nonalloc is such a thing

#

yes 2D also has two versions of those functions that return multiple colliders

acoustic belfry
#

o h

#

but in theory the code would work good?

rich adder
#

as I said if you don't call it every frame for the most part is fine, but its just another optimization area

acoustic belfry
#

ok

rich adder
#

its more noticeable when you have dozens of objects calling that function . and frequent, creating new array every time has its cost to clean and create every time

acoustic belfry
rich adder
acoustic belfry
#

makes sense

rich adder
#

the function will returns how many have been actually hit.

hits = Physics.Overlap(..., colliders,..
for i ; i < hits 
var hit = colliders[i] ```
acoustic belfry
#

something like this?

private Collider[] hitResults = new Collider[5];
 protected void constantMeleeAttack(float attackRange, Transform meleePos, LayerMask victim, float meleeDamage)
 {
     if (HasHitValeria) return;

     Vector3 macheteRange = new Vector3(attackRange, attackRange, attackRange);
     Collider[] hitEnemies = Physics.OverlapBox(meleePos.position, macheteRange / 2, meleePos.rotation, victim);

     foreach (Collider hitEnemy in hitEnemies)
     {
         if (hitEnemy.TryGetComponent(out valeriaController64 enemy))
         {
             enemy.TakeDamage(meleeDamage);
             HasHitValeria = true;
             break; // Avoid hitting multiple times in one swing
         }
     }
 }```
#

also this still works, right?

    {
        HasHitValeria = false;
    }```
rich adder
#

everything works the same..

#

hitResults would go in Physics.OverlapBoxNonAlloc, check docs for signature if you switch it

rich adder
#

and you will need for loop instead of foreach because you need to iterate by index

acoustic belfry
#

huh?

#

idk, my only idea, was to be able to hurt the player if touches it, but if doesnt, then dont hurt it again until is reseted

#

it was based on this other func

    {
        Vector2 MacheteRange = new Vector2(attackRange, attackRange);
        Collider2D hitEnemy = Physics2D.OverlapBox(meleePos.transform.position, MacheteRange, 0f, victim);
        if (hitEnemy != null)
        {
            if (hitEnemy.TryGetComponent(out valeriaController64 enemy))
            {
                enemy.TakeDamage(meleeDamage);
            }
        }
    }```
rich adder
#

if it worked before , everything should work the same

acoustic belfry
#

ok

tropic sparrow
#

Nav, you who know a lot, please tell me your opinion of this asset, could it or not give money when completed and would it be for mobile: https://assetstore.unity.com/packages/templates/systems/advanced-multiplayer-game-template-241288?srsltid=AfmBOoquvd3FzO3VbO7TKd2y65zCksS44EgTf1BP1ogfK0Q-TVH_VeQf&utm_source=chatgpt.com

Use Advanced Multiplayer Game Template from Redicion Studio to elevate your next project. Find this & more Systems and templates on the Unity Asset Store.

meager gust
rich adder
meager gust
#

especially if you're new to networking.

#

sorry.

rich adder
#

yeah seriously, if you want to make something with networking do like tic tac toe or something , build your knowledge up

meager gust
#

Every week someone with 1 week of unity experience wants to know how to build GTA 5

subtle sedge
#

Quick question for more expericened unity devs. How long do you think it will take to create a simple pokemon like battle engine (nothing really fancy just basic combat)

tropic sparrow
#

Bro, that template doesn't have Proton, the store would only incorporate real conoras, that's easy with cha GTP, the 3D models are made for you on a page with animation yet, I don't understand where the complication lies.

meager gust
#

but this is ridiculous

rich adder
#

integrating proton or whatever framework is the hard part

#

you will have "good assets" with busted ass networking

meager gust
#

At the very least, you should know how clientside prediction works like the back of your hand, if you want to pull this off

#

implementing gameplay code on top of an existing multiplayer engine is not easy

#

especially when it ties into rollback

tropic sparrow
#

That's right, I agree with you, I mean, it doesn't work with your current online system, right? It's not Proton, well, it has a dedicated server, something like that.

rich adder
#

being dedicated or not is irrelevant to the framework, ie Proton

#

dedicated just means you host it on a computer somewhere else other than your / users pc

meager gust
tropic sparrow
#

Yes

#

In conclusion, no one recommends this asset, right?

rich adder
#

yeah merging something like proton into a custom built system is going to be even more diffcult, you're better off starting simpler and build your knowledge up, you might not even want template by that time

meager gust
rich adder
#

no, especially if you're looking for an asset to be turn key solution

#

everytime something goes wrong you have contact the developer of the asset

#

if you try to put another networking framework they will probably hesitate to help even more

meager gust
#

It says it uses Mirror

rich adder
#

hmm better than custom I suppose

tropic sparrow
#

Bro, I'll tell you what I have: a 2D shooter game with 7 characters, each with different weapons, a points system or points table for deaths and functional kills, a store to exchange characters for game points, everything already implemented, Proton 2 Free also implemented, a cap purchase system, maps ready, I only need rankings and to change Proton Premium, what do you think?

rich adder
#

Mirror is somewhat documented okay at least

meager gust
#

mirror is mainly client authoritative afaik

#

hack fest

#

not suitable for building a GTA clone

rich adder
#

yeah I recall that was its main selling point it was more friendly for client side prediction

#

or was that Fishnet

meager gust
#

fishnet is more server auth

#

but its still a complete mess

#

even when you have a network engine suitable for rollback, its still very difficult to write proper rollback gameplay code on top of it unless you know rollback like the back of your hand

meager gust
#

(its photon, not proton)

meager gust
# tropic sparrow what do you think

Nobody can answer your question unless you know what you want.
Do you want client authoritative or server authoritative? Do you know the difference?

#

Sounds to me like you haven't even scratched the surface of research for this project

tropic sparrow
#

I want and I have a functional multiplayer server implemented, I want to earn money by purchasing characters within the game

meager gust
#

You can slap something together with mirror fast using client authoritative networking, but it will be vulnerable and people can hack away to their hearts desire

#

Or you can build something secure with server authoritative networking (Which requires a significant amount of networking knowledge usually)

#

All of the unity netcode engines do something different. It depends on your knowledge level, how much money you have to burn, how much time you have to burn. Etc.

tropic sparrow
#

If you were me, what would you do? And it seems to me that they are making fun of Proton. The premium is not worth it, perhaps at $95 a year.

meager gust
#

christ

acoustic belfry
# acoustic belfry something like this? ```cs private Collider[] hitResults = new Collider[5]; pr...

btw just saying, wich code's better, the one im replying or this one?

protected void ConstantMeleeAttack(float attackRange, Transform meleePos, LayerMask victim, float meleeDamage)
{
    if (HasHitValeria) return;

    Vector3 boxSize = new Vector3(attackRange, attackRange, attackRange);
    Collider[] hitEnemies = Physics.OverlapBox(meleePos.position, boxSize * 0.5f, Quaternion.identity, victim);

    foreach (Collider hitEnemy in hitEnemies)
    {
        if (hitEnemy.TryGetComponent(out valeriaController64 enemy))
        {
            enemy.TakeDamage(meleeDamage);
            HasHitValeria = true;
            break; // Stop after first hit
        }
    }
}```
acoustic belfry
rich ice
rich ice
#

yup UnityChanThumbsUp

meager gust
#

and you'll have a very universal damage system

#

let me know if you need an example

tropic sparrow
#

If I had everything I already have in my 2D shoter project with an integrated controller system, what multiplier system would you put: Proton Premium or Mirror or something else?

meager gust
#

Its photon. not Proton.

#

Photon and Mirror are completely separate in terms of their capabilities

#

do you want server authoritative or client authoritative networking?

#

If you can't answer this, then you need to do more research on what it means.

meager gust
#

one sec

acoustic belfry
#

no i mean

what i want is that if the victims, wich are some npcs that share the same code with same func in common, are damaged once, can't be damaged again until the the reset func is set

#

thats all

#

nothing else

meager gust
#

yes

tropic sparrow
#

authorized customer wish in my game

meager gust
#

that is probably fine @acoustic belfry

acoustic belfry
rich ice
eternal falconBOT
#

:teacher: Unity Learn ↗

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

meager gust
#

game networking gets extremely complicated

#

and I think you need to do more research rather than trying to slap something together within a week

#

Photon does this.

#

if you don't know what you're doing, then you can fully expect someone to hack your server and generate infinite money.

tropic sparrow
#

photon is then appropriate

meager gust
#

If you know what you're doing

#

then sure

#

anyone can generate packets and send it to a server saying "I completed a quest. Give me 5000 tokens"

#

running photon doesn't prevent this, unless you write your code securely

tropic sparrow
#

In conclusion, Photon is more hackable, right?

meager gust
#

no

#

you're ignoring everything I'm telling you

#

or maybe theres a language barrier here I dont know

tropic sparrow
#

exolicame for brutes

rich ice
#

pretty sure they're just trolling

tropic sparrow
#

And what is the best template for you to start and make money quickly in 2D multiplier?

meager gust
#

jesus christ

#

I think roblox might be your speed

tropic sparrow
#

Please pass me the Roblox Mobile template.

frosty hound
acoustic belfry
meager gust
acoustic belfry
#

But i meant, wich one of the two are better?

acoustic belfry
meager gust
#

which I dont think I can answer

#

they look completely identical to me

junior ivy
#

Hi, I have super simple tile generator but I can't see anything (verts: 3 in the preview). No errors.
All tiles are added to the scene with proper transform, material and mesh.
Camera can move (tested for z=0 and z=-100).
Can you help?

public class Tile
{
    public const int size = 32;

    public Tile(Vector2 position, Material material)
    {
        var gameObject = new GameObject($"Tile_{position.x}_{position.y}");

        MeshRenderer renderer = gameObject.AddComponent<MeshRenderer>();
        MeshFilter filter = gameObject.AddComponent<MeshFilter>();
        Mesh mesh = new Mesh();

        mesh.vertices = new Vector3[]
        {
            new Vector3(0, 0, 0),
            new Vector3(0, size, 0),
            new Vector3(size, size, 0),
            new Vector3(size, 0, 0),
        };

        mesh.uv = new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1)
        };

        mesh.triangles = new int[] { 0, 2, 1, 2, 3, 0 };
        mesh.RecalculateNormals();
        filter.mesh = mesh;
        renderer.material = material;
        gameObject.transform.position = new Vector3(position.x * size, position.y * size, 0);
    }
}

public class TestGoScript : MonoBehaviour
{
    void Start()
    {
        Dictionary<Vector2, Tile> tiles = new();
        Material ground = Resources.Load<Material>("Materials/Ground");
        ground.color = Color.red;

        for (int x = 0; x < 10; x++) {
            for (int y = 0; y < 5; y++) {
                var tile = new Tile(new Vector2(x, y), ground);
                tiles.Add(new Vector2(x,y), tile);
            }
        }
    }
}
acoustic belfry
meager gust
#

neither of them are "simple" because you're hardcoding your damage system rather than using interfaces

acoustic belfry
#

Oh, ok, well thanks

meager gust
#

you dont need to worry about optimization at this level

#

your processor spins billions of times every second

acoustic belfry
#

Well, thanks :3

ivory bobcat
junior ivy
wintry quarry
junior ivy
#

as you can see from the code, 50 squares with the same material (or red if not found)

ivory bobcat
# junior ivy literally this:

You can click the scene tab while the application is running and see where the objects-tiles are and the camera direction etc

wintry quarry
#

they need to be clockwise, not counterclockwise

#

check scene view and rotate the camera

junior ivy
#

I've spent literally 30 minutes of conversation about indexes with AI, couldn't understand it. I swear it was easier for me to learn in low level API 😄

#

what's the proper index then?

wintry quarry
#

the only way to make progress with procedural mesh generation is to get a notebook and a pen and DRAW the vertices, labeled

#

you want to be forming clockwise triangles

junior ivy
#

unity is working on counter-clockwise indexes for face meshes

#

afaik clockwise indexes are used for culling as per befault shader settings in unity

#

so what is wrong with my index then?

wintry quarry
#

Your vertices are like this:

1 2

0 3

0, 2, 1 is a counterclockwise triangle

#

you need clockwise triangles to be visible with the default material

#

you need to visualize things on paper to work with procedural meshes

sonic harbor
#

I'm a beginner to coding. Can someone give me advice for the best way to start?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

sonic harbor
#

Thank you!

junior ivy
# wintry quarry you need clockwise triangles to be visible with the default material

it didn't help

I changed the code based on unity doc:

mesh.vertices = new Vector3[]
{
    new Vector3(0, 0, 0),
    new Vector3(size, 0, 0),
    new Vector3(0, size, 0),
    new Vector3(size, size, 0),
};

mesh.uv = new Vector2[]
{
    new Vector2(0, 0),
    new Vector2(1, 0),
    new Vector2(0, 1),
    new Vector2(1, 1),
};

mesh.triangles = new int[] { 0, 2, 1, 2, 3, 1 };
mesh.RecalculateNormals();
mesh.RecalculateBounds();

I found that standard shader is just not rendering... when I change to other shaders it stars to render something...

rich belfry
#

how can I debug this
TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 544?

#

or is this harmless

#

seems like it's only an error that appears in the editor

#

when i delete the main camera the error stops appearing

acoustic belfry
# rich adder everything works the same..

sorry for bother, but in theory, this is what you wanted me to do?

protected void constantMeleeAttack(float attackRange, Transform meleePos, LayerMask victim, float meleeDamage)
    {
        if (HasHitValeria) return;
        Vector3 meleeRange = new Vector3(attackRange, attackRange, attackRange);
        Collider[] hitValeria = new Collider[5];
        int hitsCount = Physics.OverlapBoxNonAlloc(meleePos.position, meleeRange, hitValeria, Quaternion.identity, victim);
        for (int i = 0; i < hitsCount; i++)
        {
            if (hitValeria[i].TryGetComponent<valeriaController64>(out var enemy))
            {
                enemy.TakeDamage(meleeDamage);
                HasHitValeria = true;
            }
        }
    }```
north kiln
#

You should declare the array in the class scope so it's allocated once in the lifetime of this object

acoustic belfry
north kiln
#

Anywhere in a class outside of a method

acoustic belfry
#

ok

north kiln
#

So yes, the area where you might declare variables, which is typically at the top of a class

acoustic belfry
#

i just realized to this moment, i can make variables anywhere that isn't a method

#

cool

foggy spade
#

public class CameraMovement : MonoBehaviour
{
    public float XRotation;
    public float YRotation;
    public Transform player;
    public float mouseSensitivity = 3f;

    public float BopAmount;

    public Vector3 OrigPos;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

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

    void PlayerInput()
    {
        XRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
        YRotation += Input.GetAxis("Mouse X") * mouseSensitivity;

        XRotation = Mathf.Clamp(XRotation, -90f, 90f);

        transform.localRotation = Quaternion.Euler(XRotation, YRotation, 0);
        player.transform.rotation = Quaternion.Euler(0, YRotation, 0);

    }


}
 ``` for some reason my player isnt rotating
ivory bobcat
#
Debug.Log($"Player input x: {xRotation}, y: {yRotation} and sensitivity: {mouseSensitivity}", this);```
foggy spade
#

my camera is rotating smoothly, but my player doesnt rotate even though its rotation is updating

ivory bobcat
carmine ocean
#

i ran into a bug i cant even fathom, when i change my X, Z position and any sort of rotation, my Y axis changes positive, this occured after i added a rigidbody to my player, please tell me if you need anything to help me diagnose this issue

ivory bobcat
carmine ocean
ivory bobcat
carmine ocean
#

all of the input is basic fps movement controls

#

W,A,S,D and mouse camera movement

ivory bobcat
#

Assuming this is a coding issue, if you don't provide any code I won't be able to determine why the value becomes negative.

carmine ocean
#

sorry i was having complications


public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 10;

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

    // Update is called once per frame
    void Update()   {
// Movement Controls

        var dir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

        transform.Translate(dir * moveSpeed *Time.deltaTime);
    }
}

public class FirstPersonCameraController : MonoBehaviour
{
    public Transform Player;
    public float mouseSensitivity = 2f;
    float cameraVerticalRotation = 0f;

    void Start()
    {
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        float inputX = Input.GetAxis("Mouse X")*mouseSensitivity;
        float inputY = Input.GetAxis("Mouse Y")*mouseSensitivity;

        cameraVerticalRotation -= inputY;
        cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation, -90f, 90f);
        transform.localEulerAngles = Vector3.right * cameraVerticalRotation;

        Player.Rotate(Vector3.up * inputX);
    }
}
ivory bobcat
#

There isn't any random bug that I'm aware of that sets the y component of rotation to negative when etc

carmine ocean
#

yeah i apologise it was saying i couldnt send the message

keen dew
#

Is there any other issue than the value in the inspector? Does it still work otherwise correctly?

carmine ocean
#

i can walk, look perfectly it just also adds to the Y-Axis

keen dew
#

None of that code uses the rigidbody to move or rotate so if you want to use rigidbody physics you have to switch to using the rigidbody to move

carmine ocean
#

oh shoot i just realised

#

thank you ill change it and see if that fixes it

#

LMAO so i changed the movement and it puts me back down but when i look i get sent up

#

i should be able to fix that too thank you nitku

ivory bobcat
ivory bobcat
keen dew
#

That's not a solution to this problem

ivory bobcat
#

Yeah, we aren't aware of the movement system. They've only mentioned that when moving, they're down (on the ground, perhaps) but when immediately looking, they get sent back up.. unless they're referring to simply their forward movement direction being where they're looking at instead of horizontal to the floor etc...

keen dew
#

I'm guessing rotating the player moves the collider inside the ground and the physics engine then ejects the player up to fix the collision. But the physics components already follow the transform position, doing that manually is only needed in very niche situations. And movement/rotation should be driven by the rigidbody instead of transform

naive plank
#

How would I go about moving on low poly terrain, still following the mesh but without that bumpy, slow, and getting stuck feeling?

manic sparrow
#

do i just place the script in the object itself or am i missing something else?

uneven citrus
#

I'm confused on how to do outlines on my pixel fonts (16px sized font)
I've been off unity for a while coming from Godot.
In godot I just activate the outline button and tell it the color/pixels I want to go outward (4px)

But in unity, the "out"line goes inward, making it look horrendous. The outline seems to give a gray blur to the inner white too

here's my expectations (which I get done in Godot) and what I get in unity attached

I'm probably doing the font settings wrong but I can't figure out which ones I should go for and not have them super blurry (increasing the padding for instance made it unreadably blurry)

manic sparrow
#

currently im trying to make the player look at the point at which the raycast from the screen hits the aimmask (that being a large transparent cylinder that follows the player around) but the if statement never seems to be fulfilled so am i implementing the layer wrong?

        
        RaycastHit hit;
        
        if(Physics.Raycast(ray, out hit, Mathf.Infinity, aimMask))
        {
            //raycast hit, return position
            Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow);
timber tide
#

Remove the mask and check if it's actually hitting any collider first off

#

I would even draw the ray outside of the method to actually see if it's pointing correctly

manic sparrow
manic sparrow
rotund root
eager elm
rotund root
# eager elm have the script that creates the fireball set a direction on it. Instantiate() r...

it's now acting like a boomerange what did i do wrong😭

using System.Collections;
using UnityEngine;

public class Fireball_Behaviour : MonoBehaviour
{
    public float fireballSpeed = 10;
    private float direction = 1f; 
    bool isFacingRight = true;
    public void SetDirection(float dir)
    {
        direction = dir;
        transform.localScale = new Vector3(direction * Mathf.Abs(transform.localScale.x), transform.localScale.y, transform.localScale.z);
        Debug.Log($"Fireball direction set to: {direction}");
    }

    private void Update()
    {
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
        {
            isFacingRight = true;
        }
        else if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
        {
            isFacingRight = false;
        }
        if (isFacingRight)
        {
            direction = 1f;
        }
        else
        {
            direction = -1f;
        }
            transform.position += Vector3.right * direction * fireballSpeed * Time.deltaTime;
    }

    //removed despawn logic related stuff so it wont clog the chat that much
        }
    }
}
eager elm
#

I would also suggest to let the player set the direction as Vector3. Right now you have a hard coded "Vector3.right" in your fireball script. By having the player pass a vector you can have it easier to add things like shooting up or at 45° later on.

rough sluice
wintry quarry
#

also show your Rigidbody inspector - and double check that rotations are constrained

#

Also remove the PlayerInput component, since you're using the generated C# class - there's no need to have PlayerInput there

soft lotus
#

What would be the best way of making a ui element accessible in 2 or more scenes? Should i just copy it over to every scene used, or is there some way to keep it?

For context, my game is a visual novel, and i want the save menu to be accesible from both the main menu and the actual game scene, and i was thnking of how to best go about it

hexed terrace
#

Using multiscene loading

patent wedge
#

hi, i'm adding resolution options to my game so i'm trying to filter by the refreshrate but it seemingly doesn't work

int a = (int)resolutions[i].refreshRateRatio.value;
int b = (int)Screen.currentResolution.refreshRateRatio.value;
if (a != b) return;
``` it always returns true
keen dew
#

It's debugging time! Put in Debug.Log($"res: {resolutions[i]}, a: {a}, b: {b}"); before the condition and see what it prints

patent wedge
ivory bobcat
#

So, a != b should yield false

patent wedge
keen dew
#

You'll have to show the full context. There's no indication here that that particular statement would cause the issue.

#

Having return inside a loop will stop the loop from continuing further so if the list of resolutions is in a different order in a build it can certainly cause it behave differently

patent wedge
keen dew
#

break stops the loop. return stops the entire function.

#

which includes the loop

polar acorn
#

If the loop is the last thing in the function, the two are identical

keen dew
#

(what did you think return does?)

patent wedge
keen dew
#

That's continue

patent wedge
keen dew
#

It's not really possible to tell what you should do without seeing the whole thing

patent wedge
#
for (int i = 0; i < resolutions.Length; i++)
        {
            int a = (int)resolutions[i].refreshRateRatio.value;
            int b = (int)Screen.currentResolution.refreshRateRatio.value;
            if (a != b) continue;
            
            string option = resolutions[i].width + "x" + resolutions[i].height;
            options.Add(option);
        }
ivory bobcat
patent wedge
ivory bobcat
#

And what options were found?

#

If you can see the resolution options given and found, you'd be able to verify what went wrong.

#

For instance, if you're getting no options.. you'll want to check if there were no resolutions, your screen resolution and why none had matched

patent wedge
rich adder
patent wedge
# rich adder index out of sync ?

sorry i didn't give much context.

Resolution resolution = resolutions[index];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreenMode);

this is how i'm setting my resolution but because the array has all the elements while the dropdown only has a few they don't match.

naive pawn
# patent wedge ``` for (int i = 0; i < resolutions.Length; i++) { int a = (...

you could simplify the flow here

        for (int i = 0; i < resolutions.Length; i++)
        {
            int a = (int)resolutions[i].refreshRateRatio.value;
            int b = (int)Screen.currentResolution.refreshRateRatio.value;
-           if (a != b) continue;
+           if (a == b) {
                string option = resolutions[i].width + "x" + resolutions[i].height;
                options.Add(option);
+           }
        }
#

would probably be less confusing/easier to work with if you haven't gotten ahold of continue/break/return yet

rich adder
#

then you can also use that for Options in dropdown

patent wedge
keen dew
ivory bobcat
balmy cape
#

Hey guys anyone know any AI movement systems that can copy animal behaviour cause I’m making a nature game

patent wedge
#

is there anyway to have a folder access somewhere outside of the project?

rich adder
#

thats why things System.IO exists, or even Application.persistentDataPath

patent wedge
# rich adder ofc

no not like getting stuff for save files. i mean that let's say i have a sfx folder on my desktop and i want a folder in my unity project to access that.

rich adder
sour fulcrum
rich adder
#

ya just put them in the project, whats the big deal

patent wedge
#

also how can i only have one function execute in edit mode in update?

sour fulcrum
#

Why

patent wedge
# sour fulcrum Why

because i have telephone poles that in update will auto rotate themselfs but only need to be executed in edit mode

sour fulcrum
#

The short answer is no

#

Honestly im sure rotating them in update will be fine

grand snow
grand snow
#

make sure that editor only code uses conditional compliation like my example to avoid errors when attempting to build

sour fulcrum
grand snow
#

Yes or cheat and do UnityEditor.EditorUtility.SetDirty()

patent wedge
grand snow
slender nymph
#

why does it need to be in Update? can it not just be a context menu item to trigger it manually?

sour fulcrum
#

Can also just realistically be in update forever if it’s just transform stuff tbh

#

You can do better once you get more comfortable

silver fern
#

are there any disadvantages in using a signal to trigger a method in another component script over accessing the method directly

slender nymph
#

by "using a signal" are you referring to an event? or do you mean something else?

silver fern
#

oh yeah unity event, sorry

grand snow
#

godot brain moment

rough sluice
polar acorn
#

There's a small amount of overhead if using an event to invoke a method versus just calling the method, but it's very slight and shouldn't be worried about. If the workflow of using an event makes the code cleaner (less two-way coupling, better encapsulation, expandability, etc.) it's worth it

slender nymph
# silver fern oh yeah unity event, sorry

then no, there are not really any disadvantages. really only advantages as it would mean your objects don't necessarily need references to each other as data can be passed through the event

rich adder
silver fern
#

alright thanks

grand snow
#

unity event subscriptions done in the inspector are slower vs code subs

#

Why? inspector way needs to use reflection to locate the function to call

slender nymph
#

yeah but it's a difference that's not really even worth worrying about too much because it's a one time cost at the time the object is instantiated

grand snow
#

Yea probably fine but a real event will be best and probably gets more optimisations (if any exist)

#

If we can trust mono 😐

patent wedge
#

i know i keep asking questions but for some reason gamepad input doesn't work in build.

slender nymph
patent wedge
slender nymph
#

okay so have you considered providing any useful information at all?

patent wedge
slender nymph
patent wedge
slender nymph
#

the game is 64x
UnityChanHuh
i have also updated the asset
what asset

nobody here can read your mind, provide useful information

#

and have you bothered checking the logs for the built game? there may be errors you don't know about

patent wedge
naive pawn
#

buddy we aren't sitting over your shoulder

#

we don't even know what you're building for

rough sluice
#

What is that white board? How should I remove that? I don't know how is that get added:

rich adder
#

also not a code question

rough sluice
patent wedge
#

i fixed it! it was steam input.

modest hollow
#

real

rich adder
acoustic belfry
#

Hi, for a weird reason my laser doesn't appear, why?

{
    Debug.Log("ShootedRifle is even shooting");
    rifle_amount--;

    // Get a ray from the camera in the direction of the mouse cursor
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    RaycastHit hit;
    if (Physics.Raycast(ray, out hit, Mathf.Infinity, demons))
    {
        Debug.Log("ShootedRifle has Shooted");
        Debug.Log("ShootedRifle hit 3D: " + hit.collider.name);

        EnemyBase enemy = hit.transform.GetComponent<EnemyBase>();
        if (enemy != null)
        {
            Debug.Log("ShootedRifle's enemy isn't null");
            enemy.TakeDamage(5, 1, 3, 3, transform);
        }

        // Draw tracer from weapon to hit point
        lineRenderer.SetPosition(0, transform.position);
        lineRenderer.SetPosition(1, hit.point);
    }
    else
    {
        // If nothing is hit, draw tracer forward
        lineRenderer.SetPosition(0, transform.position);
        lineRenderer.SetPosition(1, transform.position + ray.direction * 100);
    }
}
west sonnet
#

Anyone got any ideas on how I could do this? This is using TextMeshPro

frosty hound
#

BulletsLeft is a float type, text expects a string.

#

You can convert it with BulletsLeft.ToString();

keen dew
#

Why is BulletsLeft a float? Can you shoot partial bullets?

west sonnet
#

Thanks

#

No, I'm just so used to using floats lol

#

But I'll change it to int

rocky canyon
#

$"{BulletsLeft}";

rich ice
#

BulletsLeft + "" necoarcDerp

gaunt raptor
#

i have an object that i want to make it move like a human spine but its really hard to animate it manually and i just find out about rigging is it the answer to my problem?

frail hawk
#

yes

gaunt raptor
acoustic belfry
#

now im realizing, the line appears, but small and inside of the player

frail hawk
#

probably the rotation of the line renderer that has to be fixed too

acoustic belfry
frail hawk
#

pause the game, rotate the transform , test alignment and use world space on the line renderer

#

until you find out what fits

frail hawk
#

you can use a parent gameobject, there are many ways

acoustic belfry
frail hawk
#

i just wanted to give you a hint what the problem might be and in most cases it is the rotation of the line renderer

acoustic belfry
#

oh

frail hawk
#

you will have to find out

acoustic belfry
#

well, thx

rough granite
raven pilot
#

🤔 what's wrong with it 🤣

rich adder
hazy slate
rough granite
# raven pilot 🤔 what's wrong with it 🤣

nothing just a whole lot easier to use string interpolation for anything that needs me adding values to a string. Im not left spending 5 minutes fumbling my keyboard typing with the quotes and +

mortal sky
#

Hi. I would like to know what's the proper way to organize large-scale UI. Pause menu, Game Over menu, Main menu, Inventory, etc.
Is it adviseable to have multiple canvases, for example? Tips like these would help figure out my problem.
Excuse me if this is not the most proper channel.

mortal sky
#

Thanks, that channel didn't appear on my sidebar.

muted rampart
#

hey insanely simple question, my model isnt facing transform.forward whats an easy to fix for this?

rich adder
muted rampart
#

let me reword my bad, i just noticed the empty object i

#

its under is the one with the wrong transform

#

do i just make a new empty object?

#

moving the model alone seems to move the empty's transform too..

wintry quarry
#

you need to switch to Pivot mode to see the actual object position

#

You can toggle this with the Z key

muted rampart
#

no right here the blue line isnt the same way as the model's blue line this is the empty;s transform

#

running the code makes it act like this is its forward

#

so it chases me with its side

wintry quarry
#

I'm not disagreeing that your model is oriented improperly

#

Make sure your tool handle position is set to Pivot and the rotation is set to Local in order to properly be able to work on fixing it

muted rampart
#

Huh.. the model;s pivot is like off to the side..?

wintry quarry
#

Go fix it in blender

muted rampart
#

ok

#

isnt this correct?

#

Oh wait is that point thing the pivot? im a bit new to this

wintry quarry
#

show the full unity window

muted rampart
wintry quarry
#

select the actual object with the MeshRenderer

round mirage
#

Hello actually i have this to make move my player Vector2 axe = new Vector2(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal")); rb.linearVelocity = new Vector3(axe.y * speed, rb.linearVelocity.y, axe.x * speed); but if i rotate the player he dont go forward he keep the axis of the world does something like rb.linearVelocity.local exist to make it go in the way i want ?

muted rampart
#

Oh holy shit im dumb

#

well the mesh parts are kinda all seperated

wintry quarry
muted rampart
#

do u want me to send each's pivot...?

wintry quarry
wintry quarry
#

are any of the rotations wrong?

muted rampart
wintry quarry
muted rampart
#

one of them

#

how do i uh

#

do that

#

😓

stuck current
#

Hey I’m making a bullet that can work for both the enemy’s and players but I don’t know how to make a targeted layer mask that only detects

wintry quarry
muted rampart
#

ohh shit wait

wintry quarry
stuck current
#

That only detects the targeted layer

muted rampart
#

this is supposedly the "front" view is that the wrong thing?

wintry quarry
muted rampart
#

just rotate n ez pz?

stuck current
#

Wait….: should I be doing this with tags

wintry quarry
#

something like:
"bullets fired by the player should only be able to hit enemies and bullets fired by enemies should only be able to hit players"

#

something like that

wintry quarry
wintry quarry
stuck current
wintry quarry
# stuck current Yeah I want that

you can set up the layer collisions in the layer collision matrix (in physics settings), then when you spawn the bullet just set it to the layer you want.

stuck current
#

I’ll look into that

#

Thanks

wintry quarry
#

you can make a field in the script that shoots them like public int bulletLayer; then set that layer on the bullet when you spawn it

muted rampart
#

ok i fixed it !!! the reasons for it blending into the floor was cuz i had the model all wrong and for it to be facing me with its side was also with its model, i just fixed it by rotating it and moving it slightly up 👍 ‼️

#

yeah now that i think abt it testing before giving it all those details was important 😭

twilit olive
#

can anyone recommend me some tutorials on 2d isometric games with height AND characters?

I've followed tutorials on just making the isometric levels and got to a good point where i can create the isometric level but actually putting a character with a sprite on it almost immediately starts giving me trouble (feet clipping into the floor, not being hidden correctly behind walls, etc etc)

#

most of the tuts i see seem to only cover the level creation though...

rocky canyon
# twilit olive can anyone recommend me some tutorials on 2d isometric games with height *AND* c...

Learn how to order your player sprites to be able to walk behind objects. Understand how unity sprite layering, order in layer and the sprite sort points work.

In this video we go over how sprite layering is prioritized, what a sorting layer is. How to set the sprite order in a layer and the sprite sort point so that you can get your player and...

▶ Play video
#

just grabbed the first one i saw.. but use keywords like "[unity] isometric map sorting order" and you'll find some stuff thats relevant

#

thats the way most tutorials work.. most of them are going to be covering a specific topic.. you gotta go thru ur game and figure out what types of issues you're gonna have and then learn each subject and adapt them for ur own use-cases

#

or like me as a beginner just stumbling upon things i didn't know or realize i had to do..

its more about figuring out what the thing im having trouble with is called (or the best way to phrase it) and then finding relevant sources for me

#

asking around is surely a good way to do that tho.. (figuring out what keywords i need to use)

twilit olive
#

thats why i came to ask, because i know this idea isnt a unique one yet every tutorial i can find doesnt cover what i need

#

they only do tilemap sorting (the tiles work fine on their own)

#

or they do the 2d y-sorting for a topdown (not suitable for my case)

rocky canyon
#

what perspective are u working with?

twilit olive
#

isometric

rocky canyon
#

with sprites?

twilit olive
#

yep

#

making the isometric tilemap works, i have the map, but adding something on top of it that moves dynamically keeps not hiding properly behind walls or getting covered by tiles that it should be on top of

lavish violet
#

is there a website where I can steal other peoples code?

rocky canyon
#

https://www.youtube.com/watch?v=CTf0WjhfBx8 heres another one.. its basically sorting order depending on which plane ur on..

the positions are what really matters.. ur either in front of something (closer on a certain axis) or ur behind something (farther on a certain axis)

✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=CTf0WjhfBx8
This is a quick tip for sorting sprites based on a Front Top Down perspective like in Pokemon Red and Blue.

If you have any questions post them in the comments and I'll do my best to answer them.

🔔 Subscribe for more Unity Tutorials https://www.yo...

▶ Play video
#

its still going to be sorting order.. and distances thats whats relevant

#

same applies to a 2.5 game wehre ur using a 3d space and 2d sprites on top.. (the player or object still relies on being farther or closer than that object (just comparisons).. based on the players feet/ a trees base (trunk) etc

rocky canyon
twilit olive
#

unfortunately, that is not the case

#

see this screenshot from this video

rocky canyon
#

mhmm

twilit olive
#

player is on the same y axis, but on the left they should be rendered behind the wall, on the right they should be rendered in front of it

rocky canyon
#

ohh thats true i didnt think of that

#

so in that case u'd have to compare BOTH axis's

#

if its behind pivot AND its left of pivot = behind

#

and then the negative of that = in front

#

or a combination of certain things

#

but yea i think the logic behind it is still the same.. but how the system is built could vary

twilit olive
#

well, thats not the end of it either since this screenshot also doesnt exactly represent my scenario (this video isnt using a tilemap, or at least not unity tilemaps)

rocky canyon
#

i usually only work in 3d im a bit out of my realm.. but i can help keep searching for something relevant

twilit olive
#

thats why im asking, since i feel like this should be a common issue

#

isometric games are a bit rarer but not unheard of

#

and if unity has some built in settings or config to support this, id like to make use of it before trying to bash my head at some sort of sorting myself

twilit olive
rocky canyon
#

you may find people that know more about it in #🖼️┃2d-tools its not so much as a code question as it is a general concept

rocky canyon
#

as well as all ur players / pieces

twilit olive
#

right but youd need to affect tiles individually

#

regardless, ill go check 2d-tools

#

thanks for the redirect

acoustic belfry
#

Hi, how i can turn this into 3D?

 {


         Debug.Log("ShootedRifle is even shooting");
         rifle_amount--;
         Vector3 mouseposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         mouseposition.z = 0;
         Vector3 shootDirection = (mouseposition - transform.position).normalized;

         RaycastHit2D shootedRifle = Physics2D.Raycast(transform.position, shootDirection, Mathf.Infinity, demons);
     if (shootedRifle)
     {
         Debug.Log("ShootedRifle has Shooted");
         Debug.Log("ShootedRifle hit 2: " + shootedRifle.collider.name);
         EnemyBase enemy = shootedRifle.transform.GetComponent<EnemyBase>();
         if (enemy != null)
         {
             Debug.Log("ShootedRifle's enemy isn't null '");
             enemy.TakeDamage(5, 1, 3, 3, transform);
         }

         lineRenderer.SetPosition(0, transform.position);
         lineRenderer.SetPosition(1, shootedRifle.point);
     }
     else
     {
         lineRenderer.SetPosition(0, transform.position);
         lineRenderer.SetPosition(1, transform.position + shootDirection * 100);
     }
 }```
polar acorn
acoustic belfry
#

my bad

#

i tried to do this, but for a weird reason, the line doesn't appear, is just, inside the player

    {


            Debug.Log("ShootedRifle is in the func");
            rifle_amount--;
            Vector3 mouseposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            mouseposition.z = 0;
            Vector3 shootDirection = (mouseposition - transform.position).normalized;

            RaycastHit2D shootedRifle = Physics2D.Raycast(transform.position, shootDirection, Mathf.Infinity, demons);
        if (shootedRifle)
        {
            Debug.Log("ShootedRifle is even shooting");
            Debug.Log("ShootedRifle hit 2: " + shootedRifle.collider.name);
            EnemyBase enemy = shootedRifle.transform.GetComponent<EnemyBase>();
            if (enemy != null)
            {
                Debug.Log("ShootedRifle's enemy isn't null '");
                enemy.TakeDamage(5, 1, 3, 3, transform);
            }

            lineRenderer.SetPosition(0, transform.position);
            lineRenderer.SetPosition(1, shootedRifle.point);
        }
        else
        {
            lineRenderer.SetPosition(0, transform.position);
            lineRenderer.SetPosition(1, transform.position + shootDirection * 100);
        }
    }```
polar acorn
acoustic belfry
#

huh?

#

what you mean?

#

the line is literaly inside the player, is like it lays it down

#

i can see it cuz i move, and there is

#

(yes, the line doesnt go until i shot again, i did it that way so i can check where the line is)

#

no idea what happened

#

but now works

#

but with an small issue

#

why the line looks like this?

polar acorn
#

I don't know which line you're asking about but it's going to draw between the two positions you give it. If those positions aren't correct, you probably need to change which positions you give it

acoustic belfry
polar acorn
dense mulch
#

Do all Undo operations obviate the need to call SetDirty? So like e.g. if I call Undo.RegisterCompleteObjectUndo(obj, "change obj") would I also need to call EditorUtility.SetDirty(obj) afterward?

acoustic belfry
#

i just create it and was like that

polar acorn
acoustic belfry
#

doesn't allow me to modify it

teal viper
polar acorn
acoustic belfry
#

oh, ok

#

well, thanks

earnest wind
#

Newsoft JSON has this very cool thing called [Default Value] (from System.ComponentModel) and also ShouldSerialize

How could i make so that in a array i could tell the serializer each default value inside it?

for example [0] default is 0, [1] is 1, [2] is 0.5 and until [7] its 0.5..?

#

it is possible to use ShouldSerialize to not serialize when the array is the default

private static bool AreArraysEqual<T>(T[] a, T[] b)
    {
        if (a == null && b == null) return true;
        if (a == null || b == null) return false;
        if (a.Length != b.Length) return false;

        for (int i = 0; i < a.Length; i++)
        {
            if (!a[i].Equals(b[i])) return false;
        }
        return true;
    }
earnest wind
#

so we waste space

wintry quarry
#

Are you expecting the array to usually have mostly default values?

earnest wind
#

also yes

earnest wind
#

but yeah that would be bad

wintry quarry
#

Instead of directly serializing the array, you could serialize a list of overrides. e.g.:

overrides: {
  { "index": 5 , "value" : .442321 },
  { "index": 7 , "value" : .02345 }
}```
earnest wind
#

and i could put the default value for each slot inside the dictionary so that the serializer wont serialize it?

wintry quarry
#

or:

overrides: {
  { "5" : .442321},
  { "7" : .02345}
}```
earnest wind
wintry quarry
#

so you would basically just start with the default array and iterate over the overrides to replace values in the default array.

#

it wouldn't be part of serialization

#

although I'm sure in newtonsoft you could make it part of serialization somehow

#

it has a ton of features

earnest wind
wintry quarry
#

Yeah you could totally write a custom jsonconverter for that type that does this, I think

#

basically just creates the default array then iterates over the overrides and applies them

earnest wind
#

Ah! so it starts as 0 and just if it is 0 it overrides to the "my default" which would be 0,1 and 0.5...0.5??

#

that would for sure work!