#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 123 of 1

rare basin
#

anyway just make it the otherway

#

your exp should look if the playre entered it

#

then get playerstat component and increase the xp

woven crater
#

ah. i wanna make the player look if exp enter it . thinking i can get better performance cuz exp will be instanciated alot during run time

gaunt ice
#

please pool them

woven crater
#

okay

#

feel like im asking about everything lol. but i feel like there are so many way of doing thing if i go on my own and pick the wrong one without knowing a better way of doing it i might stick with it for a very long time

plush cave
#

i have a player GameObject that has tons of children, and some of those children have children of their own and even those have children of their own and so on, so how do i loop through everything under that player object?

modest dust
languid spire
#

99.99% of the processing there is in the GetChild and the SetActive, the rest is virtually irrelevant, a very odd way of writing for statements though

verbal dome
#

Yeah, see the foreach way of looping children in caesar's example above @uneven current

pastel sinew
#

Does anyone have an idea how I can get rid of the deadzone that is present when using a G29 steering wheel in Unity?

#

The x value seems to have the deadzone while the sticks Vec2 is fine. Cant really use the Vec2 value though since using the left pedal changes that value as well.

solemn wraith
#

Just wondering, does the magnitude of the vector Physics2D.gravity matter? i.e. does it have an influence on the actual gravity felt?

verbal dome
solemn wraith
bleak prism
#

Is there a way to put a colour in a collider ?

#

Idk if that makes sense

#

Just wanted to add like a colour on the collider

#

for debugging the pick up range

gaunt ice
#

no code question, collider "color" is global setting iirc

#

you can set it somewhere in preference or project setting -> gizmos or physics
forgot completely

bleak prism
#

I'll check it out

#

thanks

terse raven
#

Hi again. I've been watching and following CodeMonkeys series on Pathfinding using unity DOTS. And I've gotten to a point where he's started talking about the entity component system. However I've installed the package and it looks like its in experimental. Should I be using the ECS or not?

lone ember
#

void Start(){
    renderer.material.color = Color.black;
}

void OnMouseEnter(){
    renderer.material.color = Color.red;
}

void OnMouseExit() {
    renderer.material.color = Color.black;
}

Is this how you usually code a "hovering selection" in a menu

golden ermine
#

Hi guys, I have a code for NPCs that does this: when player distance to NPC is 2.5 or lower and I press E while my mouse is over player it should start conversation but for some reason it wont detect my mouse over NPC object, it detects it in weird angles like when I look at his feet from angle it will detect that my mouse is over him and I dont know how to fix it. This is my dialogueManager script that goes on NPC: https://hastebin.com/share/nujupeqaqi.csharp and this is NPC script in which I put all dialogues: https://hastebin.com/share/qoqurapugo.csharp

lone ember
willow scroll
#

If yes, then yes. This will work if you have a collider.
Consider not repeating the same parts of code more than 1 time. It's bad for the readability.

willow scroll
gaunt ice
#
void Start(){
    OnMouseExit();
}
```you can do this
willow scroll
languid spire
# lone ember

I think the problem is in your question, there is no such thing as 'usually', if it works for you it's good

gaunt ice
#

depend
it guarantees the initial state at least the same as the state after mouse exit

willow scroll
#

Anyway, creating a method like Hover(Color value) will be great too

#
private void Hover(Color value) =>
    renderer.material.color = value;
abstract finch
#

How would I be able to set a transform rotation to look at another target based on speed value rather than lerp?** Using a constant rotation speed.**

vast vessel
abstract finch
abstract finch
#

It doesnt seem to be working, the parameters do change but the transform itself isnt.

    {
        Vector3 lookDirection = _target.position - transform.position;
        // The step size is equal to speed times frame time.
        var step = _speed * Time.deltaTime;
        var rot = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(lookDirection), step);
        Debug.Log(rot);
        // Rotate our transform a step closer to the target's.
        transform.rotation = rot;

    }```
lavish roost
#

My Debug.DrawLine() doesnt show up even after enabling gizmos and double checking if the position is correct im not sure why im not seeing it

public class Grid
{
    private int width;
    private int height;
    private float cellSize;
    private int[,] gridArray;

    public Grid(int width, int height, float cellSize)
    {
        this.width = width;
        this.height = height;

        gridArray = new int[width, height];

        for (int x = 0;  x < gridArray.GetLength(0); x++) 
        {
            for (int y = 0; y< gridArray.GetLength(1); y++)
            {
                Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x, y + 1), Color.red, 10000f);
                Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x + 1, y), Color.red, 10000f);
            }
        }
        Debug.DrawLine(GetWorldPosition(0, height), GetWorldPosition(width, height), Color.red, 10000f);
        Debug.DrawLine(GetWorldPosition(width, 0), GetWorldPosition(width, height), Color.red, 10000f);
    }

    private Vector3 GetWorldPosition(int x, int y)
    {
        return new Vector3(x, y, 0) * cellSize;
    }
}
public class GridManager : MonoBehaviour
{
    private void Start()
    {
        Grid grid = new Grid(200, 180, 16f);
    }
}
wintry quarry
#

That's nonsense

#

You're supposed to use Quaternion.LookRotation

#

That's why it wasn't working

abstract finch
#

ahh

timber tide
#

the docs just show it plugging in two rotations

#

so if you've two transforms then wouldnt that suffice?

north walrus
#

How to make a personalized cursor that works both with mouse and gamepad with unity input system? I need the ability to hover, exiting hover etc like old input system

timber tide
#

you still probably want to use IHandler interfaces

rich adder
steep mist
#

any idea why i have this error when following along with a tutorial. the debug menu doesnt show an error

#

i think i followed exactly but i just can't seem to see what I missed

lavish roost
rich adder
#

clearly there is a class missing

steep mist
#

it is

#

i think you had helped me with that a few weeks ago

rich adder
rich adder
wintry quarry
#

The error is showing it lowercase

steep mist
steep mist
rich adder
#

well there is nothing on line 101 so clearly they don't match

steep mist
#

even the lines above have the correct case

languid spire
#

just show where you declare voxelData in the script

rich adder
steep mist
#

it wont let me clear it

serene barn
#

correct me if I'm wrong when I refer to vector I can either refer to vector1(x), vector2(x, y), or vector3(x, y, z)

languid spire
#

no

serene barn
#

right?

rich adder
serene barn
languid spire
#

there is no such thing a vector or Vector

serene barn
#

so theres only 2 vectors. Vector2 and Vector3

languid spire
#

3, you forgot Vector4

rich adder
summer stump
serene barn
buoyant knot
#

Is Tuple<int, int> effectively the same as (int x, int y) but with better syntax?

steep mist
serene barn
summer stump
rich adder
#

try again

summer stump
serene barn
#

oh okay

#

so the way i describe it from the x, y, z, vector2 can only refer to two of those and vector 3 and refer to 3 of those and I don't want to really know about Vector4

willow scroll
willow scroll
serene barn
willow scroll
steep mist
willow scroll
#

Anyway, you surely have to understand that Vector2 is for 2D coordinates, and Vector3 for 3D

serene barn
willow scroll
#

So you'll use Vector2 when you have to scale a UI image that obviously doesn't have a z value

rich adder
willow scroll
rich adder
#

yeah

willow scroll
#

then ok

rich adder
#

as long as you're not insulting someone

willow scroll
#

thought you can get banned for this.

serene barn
#

im doing ruby's adventure and its's only my first 30 minutes into it

rich adder
#

I'm surpised it still works

willow scroll
rich adder
#

Please Note: We are aware that this project is getting older - Ruby's 2D Adventure will be updated in 2023.

#

its 2024

#

wassup

serene barn
willow scroll
#

you gotta try that

steep mist
#

i have this error now

serene barn
rich adder
rich adder
#

somethin on line 19 is Null

willow scroll
#

I needed 3 days though

#

so I think you can do it till tomorrow

serene barn
steep mist
#

i don't see anything obvious to me thats on line 19 or any above it

willow scroll
gaunt ice
#

you can serialize the variable and drag and drop the component to it

languid spire
gaunt ice
#

then you can delete that line

willow scroll
steep mist
steep mist
#

i'm following a tutorial

#

and i think i didnt capitalize world

willow scroll
#

I see. Well, it's a mistake

rich adder
#

you followed wrong or tutorial is shite

steep mist
#

i coulda sworn i changed that already

steep mist
rich adder
#

:doubt

steep mist
#

but its more than i could do on my own

steep mist
#

at least it makes some sense, most tutorials don't explain what code does

rich adder
willow scroll
#

Ain't their mistake

rich adder
#

im aware

rich adder
steep mist
#

i forgot a capital that i thought I fixed

rich adder
willow scroll
willow scroll
rich adder
#

mind as well use javascript

willow scroll
rich adder
#

then you're doing it wrong ๐Ÿคทโ€โ™‚๏ธ

willow scroll
#

I either serialize it or find it (when using prefabs)

rich adder
#

if you say so. Talk to me about it when you learn a bit more on reflection

steep mist
rich adder
rain wedge
#

Does anyone know why my webgl build is not working. I tried turning off the compression format and then building. I'm unsure what the errors mean.

rich adder
#

which button are you pressing? afaik you need a local server to use WebGL locally

rain wedge
steep mist
rain wedge
#

kk

#

thank you

steep mist
#

web design is where my knowlege ends, no idea how to apply any of that to unity and video games

rich adder
rich adder
rain wedge
#

i went into build and run

#

and clicked on the build and run button there

#

is this what you were asking?

wintry quarry
rich adder
rain wedge
#

when i did that

#

errors popped up

rich adder
rain wedge
#

ill take a screenshot

stark holly
#

do you guy have any playlist for me to watch to start coding using unity dont mistake me, im not new to coding i used to code in Lua for around half a year.but switching to unity is completely new to me any suggestion?

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

rich adder
stark holly
#

is that a playlist or a long article

rich adder
#

they are playlists

stark holly
#

oh ok thank gonna look into it

ripe glen
#

how i can create textmeshpro text gameobject fully from script?

serene barn
#

unity does not like something because its taken 2 minutes to complete a domain

languid spire
rich adder
serene barn
#

i did it i MADE MOVEMENT!

#

just realized that i did the y movement differently form the guide, i made a separate vector 2 variable for the vertical

steep mist
steep mist
polar acorn
serene barn
#

so in this guide it's asking me to do a tile map but there are more options thine the guide is saying.

#

anyone nows how tiles work

summer stump
steep mist
#

which one is Praetor?

#

ah nvm i see

#

never knew that missing curly braces or semi colons is what caused errors in lines above. thats definitely something i felt any of my courses should have explained rather than saying its a hard and fast rule( it actually has a reason)

rich adder
languid spire
steep mist
#

its usually the second half of rule one that gets me. because sometimes i don't know what the error is asking me to change

languid spire
#

that is why google exists

steep mist
#

thank goodness for google

#

and if all else fails theres reddit and discord

languid spire
#

indeed, in my day we just had books

queen adder
#

hey guys while coding, i noticed code completion on tutorial videos, I use Jetbrains, JetRider to open scripts, how do i make my code completion work while typing? its enabled, but it doesn't suggest things that other tutorial videos show.

short hazel
eternal falconBOT
woeful hedge
#

how to check the directory of builded files in game?

rare basin
#

what do you mean?

#

also is this a code related question?

woeful hedge
#

I said in game

#

so it is

rare basin
#

what are builded files in game?

#

when you make a build, you choose the output directory

queen adder
short hazel
#

What code editor are you using?

rare basin
#

and choose your ide in external tools

#

also can hit regenerate project files

#

then edit->open c# project

woeful hedge
#

ahh I need to know where the .exe files and MonoBleedingEdge things when the builded Game runs
I'm not struggled at finding builded games in real life

rare basin
#

you specify the directory when you make a build

#

unless i dont understand what do you mean

short hazel
#

You select the build output directory yourself

woeful hedge
#

๐Ÿ’€ I really sucks at explain

rare basin
#

when you click "Build" you specif in which folder the build should be made

#

you can find .exe and all files in that folder

woeful hedge
#

I mean when User plays the game, the launched game should know where the program itself located

languid spire
rare basin
#

when the user launches the game

#

it depends where he installed it

#

or unpacked or whatever

#

he can launch it from desktop for example

short hazel
#

Do you want to retrieve the install location at runtime?

#

From code

woeful hedge
#

When a user runs a built game, I want to know where the executed .exe file is located.

languid spire
#

Environment.CurrentDirectory

woeful hedge
#

Thanks

#

I really need to learn english more bruh

queen adder
short hazel
rare basin
#

no

queen adder
#

Jetrider?

short hazel
#

There's no need to restart if you did all the steps

rare basin
#

follow all the step

#

ALL

queen adder
#

Jet Brains Rider

rare basin
#

and it will work

queen adder
#

I enabled code vision, code completion as well

#

as on by default

rare basin
#

thats not related

short hazel
#

Do you get errors underlined directly in the code?

#

Code completion is context-aware, which means if you type stuff somewhere where not many completions are available (like outside of a class), you won't get many suggestions

queen adder
#

well i see on a tutorial video

#

of him typing

#

using UnityEngine

#

and it shows up

#

mine doesnt

summer stump
winter saddle
#

Hi I'm trying to use the new input system, I found two ways to check whether the sprint Key is pressed or no:

Keyboard.current.leftShiftKey.isPressed
sprintAction.triggered

Is there a difference between each one of these? I suppose the second one will check all the mapped keys in the sprint action, such as leftShift, the gamepad key for sprinting, etc.. Or no?

short hazel
#

The first one does not use your Input Actions Asset

winter saddle
#

Ah okay

short hazel
#

The second one does. It's better to use the second one if you have any processors or triggers on the action

queen adder
#

sorry

winter saddle
short hazel
#

The New Input System is more event-driven, so it's quite the amount of changes required in your code if you want to use it as such

#

But you can absolutely use it with action.triggered for a poll-based input like the old one

winter saddle
teal solstice
#

nah i just think visual studio hates me at this point ๐Ÿ’€

short hazel
summer stump
winter saddle
teal solstice
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class RoomManager : MonoBehaviourPunCallbacks
{
void Start()
{
Debug.Log("Connecting...");

    PhotonNetwork.ConnectUsingSettings();
}


public override void OnConnectedToMaster;
{
base.OnConnectedToMaster()

    Debug.Log("Connected to Sevrer");

    PhotonNetwork.JoinLobby();
}

}
...

followed a tutorial, did everything just as they did, but my launcher just wont work, gives me many errors, as i know this is probably something simple to fix, im pretty new to coding so for me i dont really know.

hexed terrace
#

!code

eternal falconBOT
short hazel
#

New to coding, do not start with multiplayer games

hexed terrace
#

Also, if you're following a tutorial.. and there's works, but yours doesn't .. you missed something/ did something wrong

teal solstice
rich adder
#

have you developed and shipped a complete singleplayer game yet? otherwise you aint even close to ready

short hazel
#

You have a syntax error, it should be pointed out in your code directly by a red underline

teal solstice
#

It was like IED or smth

short hazel
#

Make sure it is configured properly by reading through the !IDE guide below again

eternal falconBOT
ripe glen
#

is Awake on ScriptableObject will execute when game will run?

wintry quarry
ripe glen
#

but will it run on game execure

teal solstice
wintry quarry
short hazel
teal solstice
short hazel
#

If that's not the case, look at the Solution Explorer in VS and make sure the projects are there and are loaded

short hazel
#

There should be at least one named "Assembly-CSharp". If it says "incompatible" or "unloaded" for it, right-click and select "Reload with dependencies"

teal solstice
#

yup that fixed it

#

thank you so much man.

#

your a life saver

#

now ima tryi t again :)

wooden minnow
#

What does XR mean?

frosty hound
wooden minnow
#

Ty

boreal tangle
#
void Start()
    {
        grid = new GameObject("PlayerGrid").AddComponent<Grid>();

    }

does someone know why 2 grids are created when this runs?

languid spire
#

because it's running twice, you have 2 objects with this script on it

boreal tangle
#

I thought of that but I cant even see the script

#

oh I see it ty

#

Does someone know what the Tilemap class is because "Tilemap" doesnt work

languid spire
boreal tangle
#

i tried and it says tilemap but the name doesnt work

languid spire
#

have you imported the package?
have you added the correct namespace?

boreal tangle
#

I thought unity engine included everything

languid spire
#

don't just think, know, that is why documentation exists

boreal tangle
#

ok ty

rare basin
#

t: Player

#

if you type that in the hierarchy, it will show only game objects with Player component attached to it

boreal tangle
#

never knew that thank you

boreal tangle
#
public class interactableTileMap : MonoBehaviour
{
    Grid grid;
    private Vector3Int mousePostion;
    Tilemap tilemap;
   [SerializeField] Tile tile;
    void Start()
    {
        grid = new GameObject("PlayerGrid").AddComponent<Grid>();
        tilemap = new GameObject("Tilemap").AddComponent<Tilemap>();
        tilemap.transform.SetParent(grid.transform);
        
    }

    // Update is called once per frame
    void Update()
    {
     
        mousePostion = tilemap.WorldToCell(Input.mousePosition);
        if (Input.GetMouseButtonDown(0))
        {

            tilemap.SetTile(mousePostion, tile);
        }
    }
}
#

does someone know why I am unable to set a tile in game with this code?

#

I have tile set to a Tile asset and I moved the grid to the top of every gameobject so it should render first

river roost
boreal tangle
#

ok ty

teal solstice
#

been coding for the past hour, and im getting this error,
Debug.LogError("Can not Instantiate before the client joined/created a room. State: "+PhotonNetwork.NetworkClientState);
from the multiplayer launcher

river roost
boreal tangle
#
 mousePostion = tilemap.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition));

I converted it but it still does not place anything

prisma blaze
#

is it better to set values in the start or awake method instead of declaration?

#

i noticed that the editor does not update values if you change it in the field declaration

rocky canyon
#

awake for self.. start for others

#

(set up yourself in awake) (grab references to other things in start)

#

allows their awake to run and set themselves up before grabbing

prisma blaze
#

thanks

timber tide
#

set them editor if you can. Usually awake is used like a constructor to develop the behaviours, or perhaps constuct types which you otherwise couldn't serialize with the editor

prisma blaze
#

but setting them in editor won't change the value in the code

#

is that the intended way

rocky canyon
#

it will..

#

if u have a script that sets a float to 5.. myFloat = 5f; then it will automatically put a 5 in the inspector...

#

if u change that to 10.. the code will use a 10 for that variable

#

the code will still say 5.. but it uses w/e is set in the inspector

prisma blaze
#

so it works both ways, i didn't know that

rocky canyon
#

if u press the three dots in the right corner of the component in the inspector and press Reset

#

it will put w/e u have in the script back in the inspector

prisma blaze
#

thanks, that's useful

waxen oracle
#

Is it possible to make a new gameobject in code of a given asset?

#

So if i have a cube asset which is an object, can i create that in code

frosty hound
#

Doesn't really make sense what you're asking. Are you wanting procedurally create a mesh or instantiate your cube?

waxen oracle
#

Instantiate i think

crisp mountain
#

is it fine to ask questions on what a certain snippet of code does? im following a tutorial for walking on walls and am having trouble figuring out whether a certain snippet rotates the player or the camera

ivory bobcat
#

If the snippet is self contained, it should be fine. Else you'll need someone to possibly look over the entire tutorial to figure out what that piece of code does. Doesn't hurt to try.

true pasture
#

can i put rich text on this variable? it seems to not register

prisma blaze
#

i have this ramp model i downloaded. i have a player character that is constantly moving forward. i want the player to go up the ramp. the player has a rigid body

what do i need to do and code to make this work?

crisp mountain
#

it appears to be self-contained, so here it is:

#

its only mentioned briefly

ivory bobcat
crisp mountain
#

im trying to figure out if it rotates the player or the camera

#

it is in a movePlayer script

ivory bobcat
#

So foward and right are two directions.

#

h and v are scaled

#

The resulting move direction is that of the two added together and normalized.

#

You'd get the diagonal or rather the sum of the two directions.

short hazel
#

\c is not a valid escape sequence, unlike \n (newline) or \t (tab) for example

ivory bobcat
uncut hornet
#

can somebody explain to me how refering to components work? ive watched alot of tutorials and read alot of forums but nothing seems to work

ivory bobcat
#

If processed continuously, the object would be spinning towards it's right direction.

ivory bobcat
#

If you've got a reference to the object, use GetComponent to acquire a reference to the component

uncut hornet
#

ok so this doesnt work

#

and is it completly wrong or what, like im just not understanding

short hazel
#

Not public = not visible

ivory bobcat
#

It needs to be public or serialized to be visible in the inspector.

uncut hornet
#

hold on

short hazel
#

You need to configure VS Code so it shows these errors in the code directly

#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

uncut hornet
#

ok well

uncut hornet
#

oh bruh

ivory bobcat
uncut hornet
#

ok sorry

#

i diddnt know it wasnt configured

ivory bobcat
#

If it were configured, you'd get a red squiggly line under TMP_Text and have the action to automatically add the missing namespace

uncut hornet
#

ok well, like i said, diddnt know

#

but yeah thanks anyways

somber sierra
#

hi

teal solstice
twilit marsh
#

so I have a little question, i am going to install a different version of unity in order to get microgame so I could continue my course, do I have to install all the modules for build support as well or simply install the 1.27GB dev tools? This might no be related to coding because I just started to use Unity and I'm doing a course to get started

teal solstice
languid spire
twilit marsh
#

idk, the comment from the course say to install the version 2021.3.33f1 because the current version I first donwloaded does not have microgames. I'm literally doing a "Get started course" so I don't know what other things to get since it's from the comments

#

btw am I allow to post screenshots for context?

languid spire
twilit marsh
languid spire
twilit marsh
#

I see

#

so just the dev tools for now

languid spire
#

yep, then you're good to go

twilit marsh
#

k thx

distant prairie
#

hey guys ive recently encountered a weird error which doesnt let me work on my project. on this message i answered to my old messages (my old problem) and now i have a new problem. my unity doesnt let me install the editor application, i tried the other version aswell but encountered the same problem. is there someone that knows about this problem?

celest holly
#
public class Shoot : MonoBehaviour
{
    public GameObject bulletPosition;
    public GameObject bulletPrefab;
    private Camera cam;
    [SerializeField] private VisualEffect muzzleFlashEffect;
    public float bulletLife = 4f;

    private Quaternion defaultRotation;

    [Header("Recoil")]

    [SerializeField] private float minRecoil;
    [SerializeField] private float maxRecoil;
    [SerializeField] private float recoilSpeed;

    private void Start()
    {
        cam = Camera.main;
        defaultRotation = transform.rotation;
    }
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            ShootBullet();
            HandleVisuals();
        }
    }

    public void ShootBullet()
    {
        GameObject bullet = Instantiate(bulletPrefab, bulletPosition.transform.position, cam.transform.rotation, null);
        Destroy(bullet, bulletLife);
    }

    private void HandleVisuals()
    {
        StartCoroutine(Recoil());
    }

    IEnumerator Recoil()
    {
        float recoilIntensity = Random.Range(minRecoil, maxRecoil);
        Quaternion targetRotation = Quaternion.Euler(recoilIntensity, transform.rotation.y, transform.rotation.z);
        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, recoilSpeed * Time.deltaTime);
        yield return new WaitForSeconds(0.5f);
        Debug.Log("Reset");
        transform.rotation = defaultRotation;
    }
}

Can anyone tell me why the recoil is extremely broken? its an fps controller if that affects it

north kiln
#

Are you using a text mesh pro input field? Because it doesn't inherit from input field

#

Then use TMP_Input or whatever it's called

short hazel
#

Yes because the type you used in the code is for the old input field component

boreal tangle
#
public class interactableTileMap : MonoBehaviour
{
    Grid grid;
    Vector3Int mousePostion;
    Tilemap tilemap;
   [SerializeField] Tile tile;

    // Start is called before the first frame update
    
    void Start()
    {
        grid = new GameObject("PlayerGrid").AddComponent<Grid>();
        tilemap = new GameObject("Tilemap").AddComponent<Tilemap>();
        tilemap.transform.SetParent(grid.transform);
        
    }

    // Update is called once per frame
    void Update()
    {
     
        mousePostion = tilemap.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        mousePostion.z = 0;
        Debug.Log(mousePostion);
        
            tilemap.SetTile(mousePostion, tile);
        tilemap.RefreshTile(mousePostion);
    }
}

Does some one know why when this code runs the tiles arent added to the tile map? I have tried refreshing the tilemap and setting the mouse position's z to 0 but it still does not work. The code should set the cell to tile when the mouse is over it.

spice dock
#

I am wondering how do i make Vector3.Slerp more pronounced i am making some sort of procedural movement and this is how it looks rn

#

Im using it to move feet transform from current to RaycastHit.point

somber sierra
#

my colliders wont make contact with each other, how do i fix this? when i increase one there is this invisable like force that creates a tiny gap between them. but im trying to do a tag system to detect ground so i cant spam jump if im not on the ground. currently im using the ground tag to take care of this but, the player and the ground never make contact (i used debug.log to find if it was even true in the first place)

uncut hornet
#

how do i get the text to change tho? the script is on the player object

short hazel
#

.text = health.ToString()
You need to convert it to a string beforehand, otherwise you'll get an error (cannot convert int to string)

uncut hornet
#

got it, where would i include that

short hazel
#

Think about it for a second

uncut hornet
#

oh im dumb

#

ok but im getting this error "TMP_Text.SetText(string, bool)' is a method, which is not valid in the given context"

short hazel
#

Yes because you do not need the SetText() anymore

uncut hornet
#

oh really?

#

so .text does that for me

short hazel
#

Yes that variable contains the text displayed on the screen

uncut hornet
#

i dont really understand what this error means

short hazel
#

You tried to access something on a variable that is null (that did not have a value)

uncut hornet
#

how would i fix that in this context? i cant think of any variable that is null

#

i have the text and the health and im just trying to set the text to the health (i think)

#

and the bool but i never use that

eternal needle
#

you dont need to think of which is null, the error already tells you what line it is on

north kiln
#

Go through the resource I linked and read

uncut hornet
#

ok but i have on start health is set to 100

short hazel
#

at ... PlayerHealth.cs:27
Line 27 of PlayerHealth

uncut hornet
#

alright ill read it

#

what am i suppossed to be reading that helps here? i literally just have a variable and it is not null and it is giving me an error that says its null. i understand that this page is supposed to help me but ive read all of this and now i know nothing more relating to what i need help wtih

#

so clearly i am not getting help here

#

thanks for the attempt

short hazel
#

i have a variable and it is not null
The error says otherwise

#

You think it is not null, but in reality it is null

uncut hornet
#

no

#

its 100

#

i know that health is 100 because i wrote down health = 100

grand hare
#

Should I use git when working on my projects?

short hazel
north kiln
robust condor
#

So I have a vector3 math problem. I have an object at position A and an object at position B. Object at position A should move 1f towards the Vector3.forward of position B. How can I do this?

uncut hornet
#

DUDE

north kiln
uncut hornet
robust condor
#

The vector3.forward of object B

short hazel
uncut hornet
#

what you told me to put

north kiln
robust condor
#

Yes

#

Because object A forward is facing a completely different way

short hazel
north kiln
uncut hornet
#

but how is it null when it is this? or am i just stupid

short hazel
#

Because in the code, the line right above, you're overwriting the variable value

north kiln
uncut hornet
#

im still getting that error even when removing the line above it

short hazel
#

Show your updated code, the full class

#

!code

eternal falconBOT
uncut hornet
robust condor
#

@north kilnOkay nice, but this is continous, how do I move it X float?

#

It doesn't stop moving

short hazel
wintry quarry
#

E.g. If you have it in Update it's going to happen every frame

#

Just a matter of making it run when you want it to run.

uncut hornet
#

oh my god im so dumb. the error just diddnt go away. thats my fault. it works now

#

thank you and sorry for being rude

wintry quarry
#

Not sure what "move it x float" means

robust condor
#

Ah I see, I do have an if check but for some reason it does not go to false, so I must investigate

normal mango
#

what does this warning mean?

wintry quarry
#

Your Card class is a MonoBehaviour

#

you're trying to create them with new

#

That's not allowed. As the error says.

normal mango
#

what can i do instead? im following a guide from a few years ago, hence the problem

rich adder
#

make this class non-mb

wintry quarry
#

just read it

#

There's no way the guide from a few years ago is doing it the way you're doing it

#

you probably added : MonoBehaviour to the class when the tutorial did not.

normal mango
#

4 year old video

rich adder
#

ur looking at wrong class

#

also what a shit name for a class xD

normal mango
#

lol

wintry quarry
#

DO everything the same way as in the video, and it will work

rich adder
#

omg just noticed they're using notepad++

wintry quarry
#

oof

#

Yeah, shit tutorial ๐Ÿคฃ

#

it's very possible someone who is using notepad++ might also have just made this mistake in the tutorial too

normal mango
#

๐Ÿ’€

rich adder
#

lol curiosity is peaked, now i gotta look at the series

normal mango
#

ya theres also no narration...........

#

but somehow its 70+ episodes and even goes into opponent AI

rich adder
normal mango
rich adder
#

oh my for once I will say the ScriptableObject cards from brackys would be better than this..

#

wow you actually did follow correctly

#

the tutorial is just bad

normal mango
#

welp lol

rich adder
#

I can only hope and assume they make it into a regular class at a later point..

#

they even put a constructor..

normal mango
#

atp should i just look for a different tutorial

rich adder
#

this is step 1 and its already bad, I'd say so

normal mango
#

alright then

rich adder
#

https://youtu.be/aPXvoWVabPY
this should get you somewhat started much better

When making a game you need a good way of storing data. This is where Scriptable Objects come in! In this video weโ€™ll learn how to use them by looking at an example: Making cards for Hearthstone.

โ— Project on GitHub: https://github.com/Brackeys/Scriptable-Objects

โ™ฅ Support Brackeys on Patreon: http://patreon.com/brackeys/

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท...

โ–ถ Play video
#

I know, brackys I know.. but this one is okay

normal mango
#

tbh ive just been really stuck, need to cook up a card game quick for a competition, at least the bare bones, but most guides i see dont go in-depth into the game logic of the cards, and im too confused on where to go after that

#

the extensiveness of this tutorial was why i picked it up initially, even though it was scuffed

wintry quarry
#

Card games are quite complex

#

they'll require a strong understanding of Unity fundamentals

#

as well as programming fundamentals in general

rich adder
#

very exhausting too , I made only 2 and it drains me

wintry quarry
#

especially if you're looking at Hearthstone or MTGA for inspiration

#

MTGA is a software engineering wonder to be perfectly honest

normal mango
#

rip, only planning on making the cards be like "draw 2" or "double attack", more akin to old yugioh

#

knew more complex stuff was out of my field

#

but its already lookin hard...

wintry quarry
#

You can probably do something pretty simple without too much grief but it gets very complex very fast

#

especially if any of the cards modify the effects of any other cards in any way

#

or if there is ever a chain reaction of events

obsidian wasp
#

what kind of game that is 2d should I make as a beginner

fierce shuttle
# obsidian wasp what kind of game that is 2d should I make as a beginner

You could try to recreate a "classic" game like pong, brick breaker, top-down chess, checkers, connect 4, solitaire, etc or try searching for games that fit something you want to focus on learning such as animation, physics, UI, etc - if youd rather create your own small 2D game, id then maybe start with a GDD and Trello board to plan out exactly what assets youll need, and the scale of the game, though the latter may be a bit complicated if its your first ever project, it can take a lot of trial-and-error

crisp mountain
#

yeah, typically you need a little bit of experience with basic games before you work on basic projects

#

from what ive heard, a good first few are pong clones, mario clones, and vampire survivors clones

#

all are easier to program in comparison to big projects

winter saddle
#

Hi, why don't I have information about the code like the left screenshot?

fossil drum
winter saddle
fossil drum
#

Interesting UnityChanThink

winter saddle
#

Is that what they call IntelliSense I'm not having?

wintry quarry
#

missing semicolon

fossil drum
#

Well, you need to put a ; first, but I don't expect that to fix your summaries.

rich adder
wintry quarry
#

btw why are you mixing use of InputActionAsset and your (confusingly named) generated C# class PlayerInput?

winter saddle
#

Yeah yeah I'm just tinkering with stuff now, but I'd like to know why I don't have information about the code like the previous screenshot

winter saddle
wintry quarry
#

then it will work

winter saddle
#

fixed it

wintry quarry
#

btw you can just do moveAction = playerControls["Player/Move"]; for example

#

instead of that long form you have

winter saddle
#

Oh that's good, didn't know that, thanks

fossil drum
# winter saddle

Perhaps its because you miss all the other Solutions in your project? It probably grabs the summary from there is my guess.
You can enable those in your preferences and recompile your project.

winter saddle
#

Sorry I don't understand what do you mean xD

#

okay I'll enable now

fossil drum
#

!vs

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)

winter saddle
#

where in preferences?

#

Okay I'll follow this

#

thank you!

fossil drum
fossil drum
winter saddle
#

Ah okay

#

Git packages should be on?

fossil drum
#

Not sure which one to be honest, I guess Build-in or registry

winter saddle
#

Ok I'll try now

fossil drum
#

Then regen project files, and reopen your Visual Studio to load the new stuff.

winter saddle
#

It was Registry packages! Thank you so much

fossil drum
#

๐ŸŽ‰

winter saddle
#

I was always copying the code in google to see what it does.. lol

obsidian wasp
frosty hound
#

Start with whichever interests you the most

#

One isn't a stepping stone to the other, despite the fact the number 2 comes before 3.

#

Which would be like saying one should learn to drive a motorcycle before a car because it has less wheels.

tender breach
frosty hound
#

Fix your formatting, you've been told this before.

#

And show how you're setting the value to true

summer stump
gaunt ice
#

I am on my phone and i may overlook your code
Your use the spawn only in start and it is meaningless to set it to true in ontriggerenter

tender breach
#

So I shouldn't use it in start?

tender breach
frosty hound
#

Your braces are on the same line as your code for starters.

#

What IDEare you using?

tender breach
frosty hound
#

Then don't ask questions until you're actually prepared to give people your attention? ๐Ÿค”

#

Seems like the logical level of respect

#

Anyway, as above, what IDE are you using? There are hot keys for auto formatting you should use.

summer stump
gaunt ice
#

Your start wont run after ontriggerenter

timber tide
#

using transforms and rotation for a tetris game (it looks like?) is more work than needed. Should just stick to a 2D array

tender breach
frosty hound
#

And it's a statement

north kiln
#

There's a wild amount of repetition; why is all this split up into different almost identical clauses, when each section could just be wrapped in the shared one?

tender breach
#

Ok, I moved the bool, but there's a new problem. I only want the gameObject to spawn once.

obsidian wasp
#

how would I make something not visible? like text for example

tender breach
gaunt ice
#

so where you want it to spawn in your code, just put the code there

tender breach
#

It spawns more than once when I put it in OnTriggerEnter

gaunt ice
#

use a bool to check if the object is spawned

pliant mist
#

I want an enemy to move towards the player unless it is a certain range and if it is in a slightly larger range it will shoot, it acts super strange moving even when it looks like it should not. https://gdl.space/logisadovi.cs

frosty hound
#

@tender breach If you're going to ignore the question, you simply won't be posting here.

frosty hound
pliant mist
#

i just need to rb.velocity to 0

#

how do I do that?

#

rn I'm doing transform.forward * 0 but that's ugly

frosty hound
#

Set it to zero

#

You can use Vector3.zero

tender breach
frosty hound
#

Not my question, which I asked twice. You can scroll up to find it because I'm not posting it a third time.

tender breach
#

What question am I ignoring?

gaunt ice
#

what ide you use

tender breach
#

Vistual Studio

queen adder
#

Why is my sprite behind the backround?

It's got a higher Order in layer

tender breach
frosty hound
tender breach
#

Stop complaining about the formatting, I tried my best

frosty hound
frosty hound
tender breach
#

Can you just help me?

#

With the bool

frosty hound
#

Fix your formatting?

tender breach
#

With the bool

timber tide
#

Mesh component != sprite component

frosty hound
#

Sprite ordering isn't the same as a mesh. Move it physically in front of the mesh.

timber tide
#

it doesn't even have a layer option so idk what you're comparing both of them to

uncut hornet
#

my camera just isnt rotating. even when i attach the script to the camera and remove the Cam. from the transform

shrewd basalt
#

hey is there an easy way to get the direction from point A to point B? (3d)

shrewd basalt
#

oh thats fun

north kiln
eternal falconBOT
shrewd basalt
#

but there should be a way to modify the individual values of a quaternion right?

north kiln
shrewd basalt
#

oh its the funny

#

does this work

#

apparently it doesnt

north kiln
#

You haven't paid attention to anything I've said

#

Configure your IDE before doing anything else

#

Don't access the quaternion.

#

And use the correct method to modify members of a struct returned by property

summer stump
# shrewd basalt oh its the funny

Rotation returns a quaternion. A quaternion is 4 values. It is not what you see in the inspector. You do not want to mess with it at all. As Vertx said

Also keep in mind that a configured IDE is required for getting help here

timber tide
#
  public float GetModifiedSpeedFromCurve()
  {
      return currentSpeedCurve.Evaluate(stateTimeNormalized) 
          * AbilitySO.SpeedData.BaseSpeed;
  }

Say I want to loop my curve a specific amount of times over this normalized time instead of once throughout the duration, something like stateTimeNormalized / loops or modulo

gaunt ice
#

sounds like integration

timber tide
#

is this that really complicated of a problem. I expected a single operator lol

#

brain sleep

cursive delta
#

So I opened a project after a long hiatus from Unity. Am I tripping or is there a reason why I can't drag objects around the hierarchy? I can click them and see their properties in the inspector but I can't click and drag them around

timber tide
#

maybe got it locked on the UI somewhere

cursive delta
charred spoke
#

Just try restarting the editor

cursive delta
teal viper
# cursive delta

Can you try holding your mouse button for a few seconds before moving it?

rare basin
#

Is this a code related question?

nimble scaffold
#

Happy new year everyone

strong sorrel
#

is it possible to disregard warnings that popup?

#

this is giving me a warning however, I account for it in a different way that does the same thing. its just not recognizing that other way and therefore still shows

wintry quarry
#

Warnings can be ignored, errors cannot

#

You need to read the error message

teal viper
#

I think it's just the color scheme. Seems like a warning/yellow to me.

strong sorrel
north kiln
#

What IDE

strong sorrel
north kiln
#

You should always await async Task calls because you will eat exceptions otherwise

gaunt ice
#

if the SyncXXX returns you an error then this coroutine never end

strong sorrel
#

is this not effectively accounting for it?

north kiln
#

Why use a Task if you're not intending to await it? Use async void

strong sorrel
#

I can try that

strong sorrel
gaunt ice
#

async void is fire and forgive

strong sorrel
#

id never used a task before but i was trying to follow the documentation

#

i guess i was just a little unclear on that bit

#

thanks for all of your guys help

deft salmon
#

hi. im trying to make a ui pop up when you hover over an item/object in-game .i kind of got it to work but it only pops up when i hover over the leaves of the tree and not the trunk part. is this a skript problem or asset problem.

#

!code

eternal falconBOT
deft salmon
cursive delta
#

It might just be the project, I imported an asset which might've broke it

#

Nvm looks like it's all projects, I'll just try again tomorrow maybe a pc restart is needed

teal viper
deft salmon
#

wait

#

i must have not noticed it

#

ok

#

i think it was a glitch

#

heres the real image

queen adder
#

Who let me cook

teal viper
deft salmon
#

oh ok

grim oyster
#

I'm sort of following along this hex grid tutorial https://catlikecoding.com/unity/tutorials/hex-map/ and I'm currently looking at the way they handle color & terrain textures... The way they handle it in the terrain tutorial is by using a texture2darray and then passing a value to the shader to have it know which terrain to use for a specific hex tile.

What are the advantages to this approach as opposed to having one texture material and then using UVs to map the hexes to a specific terrain? Just trying to understand the thinking behind this approach

A tutorial series about the creation of hex maps in Unity.

ripe gale
#

Hey im watching a unity tutorial but I don't seem to understand what does the f after number means

gaunt ice
#

float

ripe gale
#

I got that its float

#

but what does float mean

#

what does it do

gaunt ice
#

if you dont type the f and decimal by default is double then you will get compile error

ripe gale
#

I didnt type the f in my code and it worked exactly the same

#

no errors

gaunt ice
#

since it is 7, no decimal point

#

but if you type 7.0 then error

ripe gale
#

Oh so I should type f only if it has a decimal point?

north kiln
#

Generally, yes. Except if it's unclear and could provide different results with integers, like division

#

Though it's harmless to specify

gaunt ice
#

yes, since double cant implicitly convert to float
in c# any number in higher precision cant implicitly cast to number with lower precision

ripe gale
#

ah i got it thanks for the help!

solemn bobcat
solemn bobcat
# ripe gale Oh so I should type f only if it has a decimal point?

Not really. You type f if you want it to be decimal. There are some methods like Random.Range that work differently depending on the argument types, e.g. Random.Range (0, 2) will return a random integer in range [0, 2>, so it's always 0 or 1. On the other hand Random.Range (0, 2f) returns a float (because 1 argument is float), which can return any number in range [0, 2], so it can be a value like 0.001f or 1.356f. Also when it comes to math, the result is usually integer if all numbers also are integers, but the result will be different type if numbers are of different type, so 7/2 will return 3, but 7/2f will return 3.5f

static cedar
#

Float is 32 bit. And there is double, which is float but can be used for way bigger numbers. Then decimal which is even bigger than double.

#

If you were to type just whole numbers, it will be int, then the compiler will secretly cast it to whatever type of number is reasonable. (int to float/double/decimal)
But once you start putting . and make it a fraction, it defaults to double and compiler won't automatically cast that to float for you since. Presumably because float is smaller in bit size than doubles.

eternal falconBOT
lavish terrace
#

DontDestroyOnLoad() and Start() have some weird interactions,

im trying to have a refrence to an object with the DontDestroyOnLoad method using the Start method, its not happening

lavish terrace
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ClassManagerScript : MonoBehaviour
{
    public ClassScriptable ClassData;
    private Transform SummoningPoint;
    private bool ClassSummoned = false;

    public void Start()
    {
        DontDestroyOnLoad(this.gameObject);
    }

    public void SummonClass()
    {
        SummoningPoint = GameObject.FindGameObjectWithTag("SummoningPoint").GetComponent<Transform>();
        Instantiate(ClassData.ClassPrefab, SummoningPoint.position, SummoningPoint.rotation);
        ClassSummoned = true;
    }
}
lavish terrace
languid spire
#

that should be in Awake

lavish terrace
#

hold up i think i found the probelm ๐Ÿ—ฟ

lavish terrace
#

this might be it

#

forgot to add the tag ๐Ÿคฆโ€โ™‚๏ธ

robust condor
#

I am implementing a market of goods per town, so 5 towns, 5 markets. What is a good pattern to access these market and check prices for multiple systems. I feel like using 5 instances of marketmanager does not seem good?

golden otter
low perch
#

yes

languid spire
sullen iron
#

how would i animate the camera of the player with the animation does playing the animation for the animator in the camera do the job? cause it kinda doesnt do it for me

west sonnet
#

I made a player movement script and everything was fine, but once I parented the camera to the player, my player started twitching when moving to the right. This doesn't happen if the camera isn't parented to the player.

teal viper
#

Share the controller code

#

!code

eternal falconBOT
teal viper
#

Probably due to your condition in Flip:

if (IsFacingRight && Horizontal < 0f || IsFacingRight|| Horizontal > 0f)
#

That would be true whenever you're moving right

west sonnet
#

Oooh damn, I accidently put or instead of and

#

Thank you!

late jolt
teal viper
late jolt
teal viper
#

!code

eternal falconBOT
gilded pumice
#

Ok I have a frustrating code issue. I want to make it so when a button is pressed, collisions between two objects are ignored. The code I have is this:

if (collision.gameObject.CompareTag("Bookcase") && phaseWalls == true)
{
Physics.IgnoreLayerCollision(6, 3, true);
}

phase walls is a publically declared bool set to false. Using the code in update method

if (Input.GetKeyDown(KeyCode.Space))
    {
    phaseWalls = true;

    StartCoroutine(PhaseWallTimer());
}

}
IEnumerator PhaseWallTimer()
{
yield return new WaitForSeconds(7);
phaseWalls = false;

}

This works, I can't move through the object at start until spacebar is pressed, then I can, and 7 seconds later the bool is set back to false (I can see this is the case because the public access modifier lets me see when the box gets ticked on and off). The problem is, that if statement in the collision enter method never re evaluates, so it never turns off again. Any ideas? I can post whole code if need be but didn't want to have too much written here.

teal viper
eternal falconBOT
queen adder
#

how can i edit this properly?

gilded pumice
#

https://paste.ofcode.org/pRhgpEpKAfYY6kdfAH8guT

So yeah again,

Ok I have a frustrating code issue. I want to make it so when a button is pressed, collisions between two objects are ignored. This works, I can't move through the object at start until spacebar is pressed, then I can, and 7 seconds later the bool is set back to false (I can see this is the case because the public access modifier lets me see when the box gets ticked on and off). The problem is, that if statement in the collision enter method never re evaluates, so it never turns off again. Any ideas? I can post whole code if need be but didn't want to have too much written here.

The last else if was just a last ditch effort to force it to evaluate going back to false, that didn't work obviously

golden otter
#

edit it on blender

queen adder
teal viper
#

Your second script uses a raycast to determine if the player is pointing at the object to display the text.

neon fractal
#

Can someone explain and show me an example of how to synchronize variables via rpc for a health script. Using netcode for gameobject

neon fractal
teal viper
gilded pumice
#

yes that worked thank you, but I'm still confused as to why the way I had it wouldn't have worked

#

that bool would be set to false, and shouldn't that if s

#

statement re evaluate when I collide with the object again?

teal viper
#

So that if statement is never evaluated.

gilded pumice
#

ohhh yeah duh. thanks for the explanation

inland cobalt
#

Hey all, I'm currently working on the fundamentals to a simplistic chess game and i've ruin into a possible future roadblock that may require me to redesign how i've written my code.

I have an 8x8 chess board defined by a 2d array of Square objects "squares"

public static Square[,] squares;```

This is then populated with standard `Square` objects. All `Square` objects have the variables:

occupyingPiece, which is a `Piece` Object (Shown Below)
position, the position on the chess board and in the array, self explanatory
instantiatedObject, a `GameObject` that is the instantiated object whenever a square has a piece on it

When i want to alter a piece's position or destroy it i edit the values of the `Square` in that part of the array.
If i want to move it, the initial square will have it's occupyingPiece and instantiatedObject set to null, while the new position's `Square` in the array gets the previous occupyingPiece and instantiatedObject, then  the object's transform is also changed for it to visually move


Below is a snippet from Pieces.cs, which outlines each of the individual pieces' behaviour and caluclating the valid squares that they're able to move to the Pawn is just one example of an implementation, this would be done for every piece in the game
```cs
 [CreateAssetMenu(fileName = "Piece", menuName = "Chess/Piece")]
 public abstract class Piece : ScriptableObject
 {
     public Colour colour;
     public GameObject prefab;
     public abstract Vector2Int[] GetValidSquares(Board.Square[,] boardState);

 }


 [CreateAssetMenu(fileName = "Pawn", menuName = "Chess/Pawn")]
 // Individual Piece Definitions
 public class Pawn : Piece
 {
     public const short VALUE = 1;

     public override Vector2Int[] GetValidSquares(Board.Square[,] boardState)
     {
         return null; // Placeholder for now
     }

 }```
#

In doing this i've realised there might be an issue in my logic, If i want to move a piece by clicking on it in the actual game space, that piece is just an object with no actual logic behind it, as the Square holds all the information for that GameObject, so I get the feeling that the way i've done it isn't great. Does anyone have any recommendations of how else i should do this so that I can easily use the logic for the piece when the player is actually looking at the gameObject in the game space? Hope that makes sense and thanks for reading. If you need anymore context lmk.

teal viper
#

There are innumerable ways to go about it, but if you want to avoid altering the code too much, you could make the square to subscribe to an event of a Piece that triggers when the players clicks on it.@inland cobalt

inland cobalt
desert elm
#

hm, this line of code doesn't appear to work, judging from the fact that the length of the array is zero- there is no error message, would you have any idea as to why it doesn't function?

teal viper
#

Then let some kind of board manager know what piece/square is selected. And when you click another square, move the piece from the selected square.

teal viper
inland cobalt
teal viper
#

And to pass it you can use events.

inland cobalt
#

Alright, thanks

teal viper
desert elm
teal viper
desert elm
teal viper
desert elm
teal viper
desert elm
#

that explains much, thanks

bleak prism
teal viper
inland cobalt
#

Hey all, back again with a problem i've ran into.

Here's an example chess board in my scene. What i want to do is to figure out what square my mouse is hovering over, by getting its coordinates. Now my initial idea was to draw a ray from the mouse aiming straight down so that it would hit the board in the appropriate square, but i'm struggling to figure out how to go about doing this, if anyone could offer me any suggestions that would be greatly appreciated.

Also to note the chess board may not be a birds eye view like shown in the picture, the camera could be looking at an angle as if you were at a real chess board for example

quartz wedge
bleak prism
#

I basically have that

bleak prism
#

noted

teal viper
inland cobalt
inland cobalt
#

transform the hover position into the board local space

teal viper
#

basically, it returns the position relative to the object.

#

Then, depending on where the pivot point of the board is and the tile sizes, you would calculate the tile coordinates.

inland cobalt
teal viper
#

Yes. But you wouldn't transform the mouse position.

#

You need to cast a ray at the mouse and get the hit position. You need the position on the board in 3d space. Not a 2d mouse position in screen space.

inland cobalt
teal viper
#

yes

inland cobalt
# teal viper yes

How would i cast it in the direction of the mouse if the mouse position is 2 dimensional though? Thats the bit im unsure on i think

inland cobalt
# teal viper <https://docs.unity3d.com/Manual/CameraRays.html>

Alright, so i'm casting a ray like this towards the mouse

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);```
You said i need to cast a ray at the mouse and get the hit position, but i'm not getting any raycast hits out from the Physics.Raycast function
```cs
        if(Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity))
        {
            Debug.Log(hit);
        }
teal viper
#

What code? What about answering my question?

teal viper
#

Ok, well multiplying by a method is not gonna work(or do anything even if it did).

inland cobalt
teal viper
#

You mean the rb rotation line?

#

Does it work if you comment out the code in Update?

#

Is your camera on the same object as the script?

#

I don't see how it would've worked.

#

Move the camera to a child object.

#

Yes.

#

before what?

#

What object is the script on?

#

Take a screenshot of it's inspector.

#

There seem to be more components

#

Probably lack of interpolation on the rb or your movement/rotation breaking it.

inland cobalt
#

@teal viper Sorry to bother you again, I've written this fucntion now that mostly works, but as you get to the edge of the field of view, the values seem to get increasingly innacurate, which im unsure how to solve, i think its because of the way the rays are being done and that the ray should stop at the mouse position and go down instead of continuing onwards, any idea?

Here's my code

    Vector2Int? GetSquareAtMouse()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            return new((int)hit.point.x, (int)hit.point.z);
        }

        return null;
    }```
teal viper
inland cobalt
#

Ah, of course, I completely forgot about that, thanks again

inland cobalt
# teal viper You don't transform the position into the board local space
    Vector2Int? GetSquareAtMouse()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            Vector3 localPoint = boardPrefab.transform.InverseTransformPoint(hit.point);
            return new((int)localPoint.x, (int)localPoint.z);
        }

        return null;
    }```
I've done this but it still seems to be off like before, have i done it incorrectly?
teal viper
teal viper
#

Implement it.
You should probably look up an fps controller tutorial at this point.

inland cobalt
#

Wait a minute, it looks like it may be rounding it

#

doesnt (int) conversion just eliminate the decimal right?

inland cobalt
#

Ah i know what my fault was, i wasn't accounting for the border being 0.5 units wide, so my measurements were 0.5 off, and the removal of the decimal made it confusing, i was thinking the ray kept going which is why it threw me off

novel shoal
#

for what is a list more useful than an array?

wintry quarry
novel shoal
#

ok thanks

wise pike
#

Iโ€™m a complete beginner coder whoโ€™s following a tutorial online but something has gone wrong and I donโ€™t know what to do from here. Iโ€™m trying to program a 2D pixel sprite to walk and Iโ€™ve followed the tutorial exactly but the script (using C# if that makes a difference) is refusing to attach itself to the Prefab. Iโ€™m saving it onto the prefab and trying to attach it in multiple different ways but it wonโ€™t work, does that mean Iโ€™ve gone wrong in the code somewhere?

languid spire
#

sounds like you have script errors, screenshot your ide and console

wintry quarry
wise pike
#

Sorry for the poor photos, I donโ€™t have discord on my computer but this is the script

wintry quarry
wise pike
languid spire
#

there are obvious errors there

wise pike
wintry quarry
#

because yes you have obvious errors in the code

#

and your biggest issue is your IDE is NOT configured

#

so it's not even showing your errors

#

the first order of business is to configure your IDE

#

!ide

eternal falconBOT
wise pike
#

Ah okay Iโ€™ll do that thank you so much

winter saddle
#

Hi, is it recommended to use the new input system at all? I'm only a beginner and trying to understand it, I configured 3D movement with the help of a tutorial, but I can't get the blend tree movement animations to work at all.

rich adder
wintry quarry
winter saddle
#

what I learnt so far about the old input system is just how to check if keys are pressed etc.

uncut dune
#

just wanted to let you know that just changing to struct worked perfectly thank you!

wintry quarry
uncut dune
#

I wanted to make a keybinding system which is really hard to do with the old one

#

but nah I cant even be bothered with the new one

winter saddle
#

I see, and what I understood from the new input system is that its advantage is to have keybinding for keyboards, gamepads, etc... at the same time

wintry quarry
#

no not at all

#

you can do that in the old system

uncut dune
#

u just got to hand that cash out

winter saddle
#

understood, yeah I'll try talking there

wintry quarry
#

in the default Input Manager you can add multiple bindings for the same axis/button without issue

uncut dune
#

not in the inspector

wintry quarry
#

nobody mentioned rebinding in game

uncut dune
wintry quarry
#

But yes, runtime rebinding is one advantage of the new input system

uncut dune
#

I dislike the new one because for me it overcomplicates what is simple with the old one

winter saddle
wintry quarry
uncut dune
wintry quarry
#

i.e. allowing the player to rebind keys

winter saddle
uncut dune
winter saddle
#

what about people with different keyboard layouts

wintry quarry
#

It's not possible to do so at runtime without creating an additional abstraction layer, no.

winter saddle
#

I see then, it's clearer now

uncut dune
#

goodluck with that

winter saddle
#

no, I'm not making it right now, but that's a project for the future when I'm comfortable after a year or more

uncut dune
#

and for now stick with the old one

uncut dune
# winter saddle what's that?

go to itch.io and find game jams. its where you make a game in a time frame (depends on the game jam) and gets ranked at the end everyone that submitted a game can rate the games

winter saddle
uncut dune
#

normally there is a theme too

uncut dune
#

if you dont have experience in the making of a game

#

with a simple input system

#

imagine trying to make and figuring a harder one out

winter saddle
#

yeah I don't have much experience

uncut dune
#

here you have it

winter saddle
#

great, thanks!

uncut dune
#

no worries

#

and if you are trying to learn start with games with only the default unity shapes

#

my first 2 were like that

#

and both made in 2 days for game jams

winter saddle
#

sure! I'll do that : )

uncut dune
#

goodluck

#

anything just let us know

winter saddle
#

thanks

#

one more thing, I remember having pop ups from unity to use the new input system, which is why I started learning it lol. so to fix that, is using "Both" input systems okay or is there a way to force the old input system without unity pop-ups?

queen adder
#

I use both and I've never had any problems

#

Sometimes just doing Input.foo() is simpler than the boilerplate that comes with the new input system

winter saddle
#

okay so you can have it set to "both" and act as if you're only using the old input system yeah?

queen adder
#

Well....if ur just gonna use the old system just use the old system and don't install the new one

uncut dune
#

exactly

winter saddle
#

ah yeah so I'll uninstall the new input

uncut dune
#

dont waste space in your projects with stuff u wont be using

queen adder
#

Yeah for a beginner anyway just use the old one

#

The new one isnt a requirement

#

And it's really complex

winter saddle
#

okay so I'll leave the new input system for now

#

thanks so much guys

queen adder
#

Yeah ofc

marsh prairie
#

does anyone have idea how to make spotlights toggle on/off according to weather/time of day/fog in the scene ? I tried darkness, tried height of sun, tried density of fog, none is working . I want that my spotlights toggle if the visibility is bad on the scene

long furnace
elfin rivet
fossil ether
#

hey guys, I'm trying to create a mesh from a parametric function but i can't wrap my mind around creating triangles from the vertices. Should i post my code here I don't want to post a big block of text hahah

elfin rivet
#

no

wintry quarry
#

The code from github looks like it shouldn't have those errors

#

try redownloading the file(s)

elfin rivet
#

My friend also got the same error.

wintry quarry
#

but i guess it's possible it has a bug

elfin rivet
#

github said to use a specific version, and I installed exactly the same version

fossil ether
#

When i try to do it like a grid parts of sphere doesn't get rendered

elfin rivet
fossil ether
timber tide
#

also if you havent, get more simpler primitives rendering before the sphere (quad, cube)

fossil ether
#

Yes definitely, I think I rushed a bit too much lol

#

I'm trying to create a parametric surface plotter for my differential geometry class

#

But I really should try to render simpler stuff first

sullen iron
#

is there anyway to move the player with an animation playing

#

or does that not work

novel shoal
#

!code

eternal falconBOT
paper plaza
#

Guys how do i make an interface type object show up on Inspector with [SerializeField]?
Im doing a script to attach to any Interactable/Hittable objects to show up or hide gameobjects based on an event

novel shoal
#

target script:https://hatebin.com/fbcbnfwfqqusing
game manager script: https://hatebin.com/upeosspvgq
basically what those two do is making a game where objects are thrown in the air and you gotta click on them to destroy them, the game faces a gameover screen if they touch a sensor at the bottom of the screen or if you click a "bad" object, so far i couldn't find what i missed because as soon as i start the game, the objects are not instantiated, so that means that the boolean value "isGameActive" is false, but i cannot find why

timber tide
languid spire
#

look at the code

   void Start()
    {
        StartCoroutine(SpawnTarget());
        scoreText.text = "Score: " + score;
        isGameActive = true;
    }
    IEnumerator SpawnTarget()
    {
        while (isGameActive)
polar acorn
paper plaza
timber tide
#

You serialize by the type*, not the interface in this case

novel shoal
paper plaza
languid spire