#💻┃code-beginner

1 messages · Page 378 of 1

swift crag
#

i hope it implements System.Numerics.IAdditionOperators<Quadruple, Quadruple, Quadples>

#

and maybe even System.Numerics.IAdditiveIdentity<Quadruple, Quadruple>

#

(these new walls of interfaces look so silly)

quick pollen
#

2nd of all, your spherecast probably overlaps with a wall, which mistakenly thinks that you're grounded, so you can jump
decreasing the size of the spherecast should fix it

#

it can usually be very small if its at the leg of the player

#

hope this helps

cosmic dagger
#

i only heard of "BigNumber", not that i ever used it . . .

swift crag
#

you also have "big integers", which are...integers

#

those are important in cryptography

#

they don't lose precision; they're variably-sized

hollow dawn
#

@quick pollen THANK YOU I decreased the size from 0.4f to 0.1f and its FIXED!!!

simple furnace
#

Can anyone by any chance help me double check why I am getting this error?

#

I checked every single asset and the script and it still says value cannot be empty.

wintry quarry
#

luckily for you though this is very familiar - it's from an AudioSource

simple furnace
#

Ah

wintry quarry
#

you're trying to play an AudioSource that doesn't have an audio clip assigned

simple furnace
#

Oh I see now.

#

Thanks.

simple furnace
#

Is this one common too?

#

Object reference not set to an instance of an object, what on earth does that mean.

cosmic dagger
# simple furnace

you have a variable that is null (not assigned) on line 17 of your ScoringSystem script . . .

#

it's the most common error you'll see . . .

wintry quarry
simple furnace
#

Welp, time to get use to it then I see.

cosmic dagger
#

the variable, itself, is a reference variable. there are two types: a reference type, and a value type. knowing the difference is paramount and will help you understand where a problem lies . . .

wintry quarry
# simple furnace Object reference not set to an instance of an object, what on earth does that me...

When you have a variable for a class you wrote, that variable is a "reference", because it is used to hold a reference to some specific object. So when it says "Object reference", it's talking about your variable.
"not set to an instance of an object" - this means your variable was not properly set up to point at any object. Yet you are trying to use this variable which is not properly set up. Hence the error.

#

i.e.

public MyClass myVariable;```
This variable is named "myVariable" and it is a reference to a specific instance of MyClass
#

But if you don't assign it, it's not set to an instance of an object

#

And if you try to use such an unassigned variable, you get an error, as you saw

simple furnace
#

Any tips to find the error?

#

I am trying to so hard yet cannot figure it out.

cosmic dagger
swift crag
#

look at the line the error is coming from

#

you are trying to use a null reference somewhere on that line

wintry quarry
#

That will take you right to it

simple furnace
#

Yeah, I still cannot see it

#

Unless it's the 0.

polar acorn
cosmic dagger
wintry quarry
#

scoreText could be null or GetComponent<Text>() is returning null

cosmic dagger
simple furnace
cosmic dagger
#

yes, that is a reference variable. it must be assigned a value before you can access it. make sure you assigned it a value before this line . . .

polar acorn
simple furnace
cosmic dagger
# simple furnace

ok, great. now there is another reference variable, but it's harder to spot because you access it using the GetComponent method . . .

simple furnace
#

This one right?

cosmic dagger
#

GetComponent<Text>() attempts to return a Text component from scoreText, but it cannot find it. probably because you're using the incorrect type . . .

polar acorn
#

Note: TextMeshPro is not Text

cosmic dagger
simple furnace
polar acorn
cosmic dagger
# simple furnace

you need to use the correct type. TextMeshPro is not the Text component; it will be TextMeshProUGUI, but as Digi stated, use TMP_Text as the type instead . . .

void raptor
#

Guys what happened to charactercontroller? I was working on my game and eventually It spawned some errors on script that i didn't edit

slender nymph
#
  1. https://screenshot.help
  2. you probably created your own class called CharacterController and it is trying to use that
  3. also always start with the first error in your console, not the last
simple furnace
slender nymph
#

you need to change the type you are getting from GetComponent to that, not the text property

void raptor
#

Scripts are bugged too

cosmic dagger
void raptor
#

It doesn't show me the inspector elements

slender nymph
void raptor
wintry quarry
slender nymph
#

use it in the browser to send a screenshot then. don't take pictures of your screen if you want proper help here

void raptor
#

Aight

simple furnace
swift crag
#

You probably created your own class named CharacterController

void raptor
#

aight i fixed the errors thank you all

ionic zephyr
#

Is it okay if I check in Update wether my mouse is on top of certain UI element to show an icon???

wintry quarry
#

IPointerEnterHandler/IPointerExitHandler or the Event Trigger component

ionic zephyr
#

Ohh okay

#

those are Interfaces right?

wintry quarry
#

yes

slender nymph
#

you can also just use the EventTrigger component if you don't want to implement those methods manually and want to do something pretty simple in response to the events

void raptor
#

i have a question, how do i build manually a skeleton on a 3d model?

polar acorn
# void raptor i have a question, how do i build manually a skeleton on a 3d model?

Thanks for watching! In this Blender tutorial I cover: How to create a skeleton (Armature) in Blender that lets you control / pose / animate your 3D character! This Tutorial covers the basics of armatures & bones, IK constraints & copy rotation constraints, parenting your character mesh to the Armature (with Automatic weights & to specific bones...

▶ Play video
void raptor
#

thank you

cosmic dagger
#

google is amazing . . .

ionic zephyr
#

Does anyone know how to move an object to front in a UI

slender nymph
#

UI draws in the order it is displayed in the hierarchy, so move it further down in the hierarchy to draw on top of other elements

ionic zephyr
#

the thing is I have a description box which is child of an item slot which is at the same time a child of the grid layout

polar acorn
#

If it's later in the hierarchy, it'll be in front

ionic zephyr
slender nymph
#

if this is like a tooltip thing, then you probably don't want it to be a child of the grid layout so that you can position it however you want on top of everything

polar acorn
#

Or make it a child of a grid layout element, not a child of the grid layout itself

#

That way it draws on top of the element, but is not subjected to the layout rules

ionic zephyr
#

maybe I´ll just add the description box a part from all of the objects

polar acorn
ionic zephyr
polar acorn
# ionic zephyr

Ah, if it spans multiple elements then you'll need to have it not be a child of that element. You'll need to have it further down the hierarchy than the grid elements

#

You probably want a floating tooltip object and position it at the currently hovered object without it becoming a child of it

ionic zephyr
#

In your opinion at least

polar acorn
#

It depends entirely on how visually busy the rest of the screen is. You'll probably need to try both and see what looks best as part of the whole picture

ionic zephyr
#

yeah, you are completely right

#

thanks a lot!

neat scarab
#

i'm having trouble with this condition. I get this return error and i dont know how to pass throught this :/ if anyone knows how to fix that would be really helpfull :)

slender nymph
#

you've messed up your inequality operator. it is instead a null forgiving operator on the GetChild call then an assignment operator trying to assign null to the method call

neat scarab
#

so like, if (Isco.transform.childCount > 0)
{
Destroy(Isco);
}

void raptor
slender nymph
neat scarab
slender nymph
#

no, as i said, the problem is your inequality operator. it should look like != but what you have is ! = which makes two separate operators

neat scarab
#

ohh lol silly mistake, wait a bit

#

let me try

slender nymph
#

i will note that your childCount comparison will likely be faster so just use that anyway

rich adder
void raptor
#

thats why i didn't find the video

rich adder
harsh vigil
#

So, in FPS games there is a thing where you can only see your hands, not body, but other players do see your model and animations. Is there a way to do this in Unity? Thanks for help in advance

swift crag
#

in a multiplayer game, different objects can be activated for different players

#

Each player's game turns off their own character's model

#

and leaves everyone else's character models activated

harsh vigil
#

How do I set that up?

swift crag
#

have you done any multiplayer development yet?

#

this is a pretty foundational thing

harsh vigil
#

Nope, but the character is set up and ready to go

polar acorn
#

Depends on your specific networking framework, but all of them should have a concept of detecting whether any specific object is "yours"

swift crag
#

whether because objects are actually "owned" by clients, or because you just wrote that down somewhere when the game started

harsh vigil
#

Until I setup the multiplayer. What do I do with the character? I have the full body ready to go, but it keeps going threw the camera and its really annoying. That's why I want to add this in the first place

abstract pelican
#

hey guys

abstract pelican
#

How to make the text not duplicate?

swift crag
#

they should get into code that checks if you own an object or not pretty quickly

harsh vigil
swift crag
#

since you need that for stuff like...say, not turning on 16 cameras all at once

#

what are you even using?

#

Netcode for GameObjects?

#

Mirror?

rich adder
harsh vigil
swift crag
#

you need to read mirror's documentation, then

#

you're going to have to get used to reading. multiplayer is complicated

harsh vigil
#

Aight. Can you send me a link please?

swift crag
#

you should also get used to doing a basic google search:

#

"unity mirror documentation"

rich adder
swift crag
#

I don't use Mirror, so I can't tell you anything too much more specific

harsh vigil
#

Is starting multiplayer important at the start of the project? can I do it mid way through game developement?

Also, doesn't the networking depend on what you're using? Like for example using steam has its own way, etc?

void raptor
#

i have this problem that the navmesh didn't map the zones that i circled, and whenever i go in this zone the player just go under the map and it fells the collision doesn't work only in those areas i don't get why

rich adder
#

wildly more difficult to start single player project then inject multiplayer in it

swift crag
#

Steam has a networking system, but that wouldn't really affect the multiplayer library you're using in Unity

harsh vigil
rich adder
harsh vigil
rich adder
#

how do you move it, what are the components on it

#

is player not a navmesh agent?

void raptor
#

wait i'll send you the screens

rich adder
#

it would not fall unless you have code applying gravity

#

also its a trigger

#

do you have some sort of raycasting cause , makes you wonder why it will phase through map lol

void raptor
#

idk but i probably found the error

#

wait

#

now it works

#

when i started making the map with terrain editor i've painted accidentaly holes but i still could see the map so i didnt care and the patterns reminded me of those holes i painted so i just removed them and it works but i dont know why i could see the terrain in those areas if there was holes

rich adder
#

navmesh sould have literally no effect

rich adder
void raptor
polar acorn
eternal falconBOT
rich adder
#

yes please use link, I'd like not to get flashbanged again

#

why is it moving a character controller but you have a kinematic rb on it , didnt even seee a CC component

#

so much strange stuff going on here

void raptor
rich adder
#

yes, the character controller is all you need

void raptor
#

aight

rich adder
#

it already has OnTrigger detections so you dont need another collider or Kinematic rb

#

it mix collider with rb(kinda) all in one

void raptor
#

ok thanks

ionic zephyr
void raptor
#

i have another problem sorry if i disturb. I have this spawn ui script that makes appear "E" keyboard image and a text whenever you are near to an npc, i've added the same script to multiple npc but it works only for one npc in the other npc it doesnt work, they dont spawn even tho the debug says that i am in the area where the ui should spawn. Why? @rich adder

rich adder
void raptor
#

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

public class SpawnUI : MonoBehaviour
{
[SerializeField] public GameObject player;
[SerializeField] public GameObject e;
[SerializeField] public GameObject interactTxt;
void Update()
{
if (Vector3.Distance(player.transform.position, transform.position) < 3f)
{
Debug.Log("E keyboard should spawn in this area.");
e.SetActive(true);
interactTxt.SetActive(true);
}
else
{
e.SetActive(false);
interactTxt.SetActive(false);
}
}
}

rich adder
eternal falconBOT
void raptor
#

damn i forgot to put the backquotes

ionic zephyr
void raptor
#

sorry

rich adder
rich adder
void raptor
#
 public class SpawnUI : MonoBehaviour 
{ [SerializeField] public GameObject player; 
[SerializeField] public GameObject e; 
[SerializeField] public GameObject interactTxt; 
void Update() { 
if (Vector3.Distance(player.transform.position, transform.position) < 3f) 
{ Debug.Log("E keyboard should spawn in this area."); 
e.SetActive(true); 
interactTxt.SetActive(true); } 
else 
{ e.SetActive(false); 
interactTxt.SetActive(false); 
} 
} 
} 
void raptor
ionic zephyr
eternal falconBOT
void raptor
#

!code ```using System.Collections; using System.Collections.Generic; using UnityEngine;
public class SpawnUI : MonoBehaviour
{ [SerializeField] public GameObject player;
[SerializeField] public GameObject e;
[SerializeField] public GameObject interactTxt;
void Update() {
if (Vector3.Distance(player.transform.position, transform.position) < 3f)
{ Debug.Log("E keyboard should spawn in this area.");
e.SetActive(true);
interactTxt.SetActive(true); }
else
{ e.SetActive(false);
interactTxt.SetActive(false);
}
}
}

eternal falconBOT
rich adder
#

why didnt you just paste it into a link, what did you do to the formatting

void raptor
#

ok wait

polar acorn
polar acorn
# void raptor yes

Then every frame, every one of these you are not next to disables e and interactTxt

#

The only way they'll ever be active is if this particular SpawnUI happens to run last

#

Because anything that runs after it is just gonna turn them off again

void raptor
#

thanks

elder raptor
#

How do I get the width of a gameobject? Like, not the scale, the current Width of it in the scene as I want to know how much I should move the game object based on the width.

I am doing this float partWidth = partRenderer.bounds.size.z; as z axis seems to be the width but it is giving a very small amount

void raptor
#

ive fixed the code and now it works thanks again @polar acorn

languid spire
#

x is the width

elder raptor
#

So basically what I did right? partRenderer.bounds.size.z

where Part Renderer is basicaly GetComponent<Renderer>()

elder raptor
languid spire
#

yes,x is width, z is depth, y is height

elder raptor
#

Or am I wrong?

rich adder
elder raptor
#

Ahh

#

Lemme try

rich adder
elder raptor
#

Nope

#

It's X

#

Man but it's moving a bit too much, lemme check with Debugging Values

rich adder
#

btw in Center mode you may not be seeing where the true origin is

swift crag
#

Center throws me off whenever I accidentally enable it

elder raptor
#

Ohh

#

so it should be Pivot

#

I feel it's giving incorrect values

#

It says the width is 0.3669179

but 0.206 is the amount I need to move the object to position it exactly at the end of that slice

rich adder
#

no idea whats is supposed to look like , I just see a screenshot UnityChanLOL

rich adder
#

when you move a transform thats where you move from

elder raptor
rich adder
#

you have the size but you have to figure in the offset of pivot

elder raptor
#

The pivot for each slice is at the centre of the entire object

#

Is that bad?

#

Because I am moving the whole object, not just a slice

rich adder
#

what is it you're trying to do exactly line up knife with cuts?

elder raptor
#

Yess

#

I have different "Fruits" which have different cuts of different widths, so I am trying to make a dynamic way to move the fruit so it lines up under the knife

rich adder
#

are they all different sizes?

elder raptor
#

Yeahh a bit

rich adder
#

gotta do some mathin

elder raptor
#

I did make a way that moves based on a fix offset which does work but it looks kinda weird in some areas.

rich adder
#

you mean putting sepearate objects between cuts?

elder raptor
#

No no, I just put a default offset of 1.5f and made it move 1.5 to the left after every cut

rich adder
#

ah yeah that wont work for not evenly sliced cuts

#

i was thinking the hackey way of putting gameobjects between each cut and then you have "pivot" spots to line up

elder raptor
#

I thought of another way to make it by using a raycast from the knife that will make the object move until it stops hitting the current slice you are supposed to cut but it sounds a bit overkill and might have room for errors

rich adder
#

or just do the math and count each size of the slice through collider/mesh
you have to factor in the offset of the center

scenic saffron
#

how do i make it so that i don't have to add the 2. vector because you cant add Vectors?
My Code:

bRB2D.velocity = (BulletSpawnPosition * 11) + prb2D.velocity;
elder raptor
#

So basically, use the collider's width instead right?

scenic saffron
polar acorn
scenic saffron
rich adder
#

@scenic saffron yes you can't do V3 + V2

#

and vice versa

elder raptor
#

Okay lemme check

rich adder
#

You can cast though

#

or keep it all v3

polar acorn
# scenic saffron

You can't add two different kinds of vectors. You'd want to either cast BulletSpawnPosition to Vector2, or prb2D.velocity to a Vector3

willow scroll
# scenic saffron

This is pretty strange how these 2 lines of code cannot be added to Vector2 and Vector3 respectively

public static Vector2 operator +(Vector2 a, Vector3 b) =>
    new(a.x + b.x, a.y + b.y);

public static Vector3 operator +(Vector3 a, Vector2 b) =>
    new(a.x + b.x, a.y + b.y, a.z);
elder raptor
#

I think I figured a sweet spot just to use the shortcut method of moving the fruit the same value. I will just make it a bit dynamic based on the fruit, I feel that's easier as I am running out of time xD

#

Thanks for the advice <3

carmine narwhal
#

Hey I´m have been using chatgpt for my game and it has worked up till now when i try getting a targetingsystem to work. I have googled but tutorials never show misstakes. and i cant figure this one out. my debug logs say that target is being found but for some reason the targetindicator doesnt show up, the targetindicator script doesnt get initilzed. I´m guessin it is something in the code i dont understand. but i also dont know where to find the answer.

willow scroll
quick pollen
willow scroll
elder raptor
#

Sorry for the ping @rich adder but I should Local Scale and Transforms in my case right?

carmine narwhal
simple furnace
#

I got a question, when creating code for player movement what tends to be the leading cause behind ASDW key set moving the player in different directions?

elder raptor
willow scroll
simple furnace
elder raptor
# rich adder the localScale to do what ?

I mean Local Transform to move them back to their original place. I thought I would reuse the same Gameobjects instead of destroying and instantiating them again. I think this concept is called Object Polling, so I want to reset the position of the slices back to their places, so wanted to know if I should use Local Transform values

#

I have a big confusion with local and global at times as it's been a while since I used unity 😭

rich adder
scenic saffron
#

Why is my Player sometimes just stopping for no reason and slowing down by like 50% when landing from a Jump?

        if (Input.GetKey(KeyCode.A))
        {
            rb2d.AddForce(new Vector3(-300 * Time.deltaTime, 0,rb2d.velocity.y));
        }
        if (Input.GetKey(KeyCode.D))
        {
            rb2d.AddForce(new Vector3(300 * Time.deltaTime, 0,rb2d.velocity.y));
        }
        
        if(rb2d.velocity.x  >= 6)
        {
            rb2d.velocity = new Vector2(6f, rb2d.velocity.y);
        }
        else if (rb2d.velocity.x <= -6)
        {
            rb2d.velocity = new Vector2(-6f, rb2d.velocity.y);
        }
elder raptor
#

Ahh okay okay thankies

willow scroll
# carmine narwhal yea but since there is noway to learn i kinda have to. i cant afford courses tha...

You're not getting anywhere, using the code you cannot understand. It's also important to know what ChatGPT's code usually doesn't make sense and is absolutely useless unless writing the patterns or asking for the small snippets, which cannot be found on the web. In the latter case, you'll still surely have to modify them to

    1. Work properly and not throw any errors
    1. Work specifically for your game
elder raptor
rich adder
#

valid

#

Unity is a 3D engine

#

the z just gets 0'd out

elder raptor
#

I meAn Yeah but you can't go Z innit

#

True true

rich adder
#

its easier to do operations with v3 since transforms are all v3

elder raptor
#

Ahh makes sense

willow scroll
elder raptor
#

Rigid Body 2D

willow scroll
carmine narwhal
elder raptor
#

😭 my bad if I am wrong

#

no attack

willow scroll
rich adder
#

nah they were using V3 + V2 earlier ,its a correct guess

elder raptor
#

Ahhh I see

carmine narwhal
#

nvm got it to work 😄

elder raptor
carmine narwhal
elder raptor
#

Let's not include college cuz college overpriced 😭

timber tide
willow scroll
# elder raptor Why are you using Vector 3 for 2d?

It's also important to not forget about Vector3s in 2D games, as z axis is used to correctly layer the objects. Simply using Vector2s results in z axis being 0, which can place the object with initially another z position in the undesired position and make it not visible to the camera

willow scroll
scenic saffron
carmine narwhal
summer stump
#

I have never spent money on lessons

#

It is a waste

#

Tons of free resources

carmine narwhal
willow scroll
eternal falconBOT
#

:teacher: Unity Learn ↗

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

timber tide
#

if you want courses then do something non-engine related like shader coding and concept of computer graphical design

#

those are pretty fun and educating

rich adder
#

i guess now days free is expected

carmine narwhal
willow scroll
#

And don't simply repeat everything. Add your own changes.

rich adder
#

you might be doing too much at once

carmine narwhal
rich adder
elder raptor
#

Is it possible to run a script even if the Gameobject is disabled?

carmine narwhal
rich adder
#

you only realize later on how much of this basic stuff you're doing but on a bigger level

#

from there you can easily read the Unity API and so forth

timber tide
summer stump
#

But it's been a while since I tested. Could be wrong

elder raptor
timber tide
#

well, it applies to per component (script) or if you disable the whole gameobject then it'll apply to all.

timber tide
#

but otherwise you can still call methods of those scripts with them disabled or not.

elder raptor
#

That's the issue, the gameobject has several child objects which have renderers

summer stump
elder raptor
#

I mean yeah, I can do that using a for loop, but I hoped there might be a better approach

#

Lmaooo alright alright will do it

summer stump
#

Not really. Could have all renderers under one parent, and the code on the root

#

Disable the renderer parent and keep the root active

timber tide
elder raptor
#

I called it in the start method of the script

timber tide
#

oh, right if it's in start it wont run.. but awake may still work? I forget actually

carmine narwhal
# rich adder from there you can easily read the Unity API and so forth

i have done a course in C# in Highscool level, cause that was the only short one i could do at the same time as work. and i wrote some simpleprograms, i even tried to make my first "Game Idea" into a console program i got it to work, but it got to be to much work with classes and shit so i gave up that idéa it feels like it is some functions of C# that isnt taught.

elder raptor
#

Wait lemme test it out

timber tide
#

Start wont work because the update loop never starts, but awake may work as you're creating it

elder raptor
#

Nope Awake is not called either

timber tide
#

I usually will keep my stuff enabled, but disable it in start (for prefab stuff)

elder raptor
#

Yeahh, I will disable the gameobject after getting the values instead

carmine narwhal
rich adder
void raptor
#

I can't either

elder raptor
#

Ping pong game is pretty easy ngl

carmine narwhal
timber tide
#

why dont ya make some tictactoe in c#, battleships, checkers, ect first

void raptor
elder raptor
#

Or make Text Based Games

rich adder
elder raptor
#

That's what I started with

#

Just watch Brackeys 😔

void raptor
simple furnace
#

Hey guys is Character Controller automatically an collider?

languid spire
elder raptor
summer stump
simple furnace
rich adder
void raptor
simple furnace
elder raptor
simple furnace
summer stump
#

Or above it, and apply gravity 🤷‍♂️

languid spire
elder raptor
void raptor
#

How can you be awake for 18 hours?

simple furnace
#

Back to figuring out collision scene change.

languid spire
elder raptor
#

I sleep for a good 8-9 hours a day

languid spire
carmine narwhal
void raptor
short hazel
#

People will barge about how much they're overworked and how f'd up their sleep schedule is, like it's a good thing
What a world we live in

languid spire
elder raptor
elder raptor
#

I lose focus quick, Adhd moment

languid spire
#

don't really know how to say this. If you really want to be great at this job you dedicate your life to it, to the exclusion of all else, not because you have to but because you want to

delicate portal
#

How to draw zigzag lines with unity line renderer so I can apply it to these lines?

short hazel
#

I'm not even gonna comment on that lol

void raptor
languid spire
weak grove
#

i love c# there i said it lol

rich adder
rich adder
weak grove
#

@rich adder i will !

lime pewter
#

I am currently creating a liquid pooling system and am needing to reference all the tiles a part of the pool that are in the "top" position, (the top pool tiles to display fill amount) and am wondering if it is more worthwhile to loop through every tile in the pool (to find the "top" tiles), or to store all the "top tiles" in a list that actively gets added/removed from, for pools that are potentially hundreds of tiles large is a foreach loop over all of them slow? And would storing all the "top" tiles in a list be faster significantly?

#

I assume so, but I am just making sure that a list of GameObjects wouldn't be significantly hard on memory or whatever.

wintry quarry
lime pewter
# wintry quarry Is this a 2D grid? I'm having trouble visualizing what you're describing

Liquid tiles each with a float between 0-1, I am creating a pooling system which will overarchingly control all necessary tiles to save on needing a script running on every water tile when they are "inactive". However, the pool needs to know the "fill amount" of all the top tiles in order to determine if the liquid falling onto a pool should be added, or not. (based on if it can hold more liquid).

#

Currently my script loops through all child transforms of the pool (parent) and checks for a "isPoolTop" bool on each child, when I really could just determine when each tile is added to the pool if it should be a "PoolTop" or not and not need to constantly loop if I had a list storing them.

wintry quarry
bright siren
#

Don't have a script on each tile or a game object per tile. Use pure code to run the pooling and render with whatever is most optimal

lime pewter
wintry quarry
lime pewter
#

I'll draw a reference, one sec.

wintry quarry
#

also I fear the term "pooling" is being conflated or confused here with the whole concept of these being water tiles

#

To be clear are we talking about object pooling?

#

I'm not sure how the object pooling part relates to the "top tile" part

lime pewter
#

Haha, that's true. I am creating a (water) pooling system, so adding water tiles to a "pool" parent, which determines if it should be drained, filled, etc.

wintry quarry
#

so is the idea here that there will always be only empty tiles at the top, only full tiles at the bottom, and only the row in between can have anything between 0 and 1?

#

because the vessel fills bottom up

lime pewter
lime pewter
wintry quarry
#

I would just keep an int currentFillingRow or something

lime pewter
#

So in theory the non "top" tiles don't need to update at all unless a block tile beside them is broken or removed, which it will create a drain, which will remove from the "top" of the pool evenly.

wintry quarry
#

which is the y coordinate of that row

#

unless there can be multiple pools

#

with different levels

#

in which case you can use graph algorithms

lime pewter
gaunt ice
#

https://en.wikipedia.org/wiki/Cellular_automaton

  • and just loop through the top to simulate

A cellular automaton (pl. cellular automata, abbrev. CA) is a discrete model of computation studied in automata theory. Cellular automata are also called cellular spaces, tessellation automata, homogeneous structures, cellular structures, tessellation structures, and iterative arrays. Cellular automata have found application in various areas, in...

lime pewter
bright siren
#

That's an old fashioned sand like water system. But having water that can go round a u-bend, that is difficult!

lime pewter
#

Currently it only needs to run any non pooled tiles and a single looping function for each "pool".

#

So having a "pool" system where it can be drained and filled via the pool itself is much more elegant than default cellular automata would be.

bright siren
lime pewter
# bright siren Oh wow well that's cool. But how? It should know what pressure is behind to clim...

Right, so it's not perfect at the moment but the main idea is that a "top" tile is any tile on "top" so if there is a large pillar of water connected, it will "level" itself between them based on their y coordinate, tiles can also store an overfilled amount based on a simulated pressure of tiles above it, which unlock the ability to flow upwards, adding their overfill amount above them. There are definitely some bumps to level out but it is pretty elegant currently.

#

If you'd like when I get the shaders done I can send how the final result works if you'd be interested to see further!

bright siren
#

Ok well you should GitHub it!

lime pewter
# bright siren Ok well you should GitHub it!

I plan to create a detailed video explaining it, but it is also to be used in my game so I'll likely create a devlog series when the game is further along, I have created quite a few unique systems that I hope to make my project stand out!

elder raptor
#

Color randomColor = colors[Random.Range(0, colors.Count)];
plateMaterial.color = randomColor;

Why is this not changing the material's colour? 😔

languid spire
elder raptor
#

Ohhh

rich adder
#

it only works if color is mapped to _Color in the shader

timber tide
#

usually there's Set methods directly on the material

#

by string lookup

elder raptor
#

The material's colour is not even changing in the first place. Is it cuz I am using a shader from Asset Store?

#

Ohh

timber tide
#

otherwise _Color for vertex color

elder raptor
#

Okay lemme try

timber tide
#

could also make your own color property field and connect it to vertex

elder raptor
#

plateMaterial.SetColor("_Color", randomColor); didn't work either >:(

timber tide
#

is this a custom shader and do you have vertex color connected

elder raptor
#

The shader file does not have a _color

#

So I need to add it right?

rich adder
#

it probably has another name iirc you can look at the material in debug mode to see all the prop names

elder raptor
#

Wait it does

#

_BaseColor then

elder raptor
#

Okay yeah it works, thanks!

timber tide
#

ah, SRP shaders did change the naming convention up a bit

#

still various components that include their own shaders rely on the old naming convention

#

like spriterender for instance

dry tendon
#

Does anyone knows the way to replace the deffault c# script icon that appears on the game assets to a custom one?

#

I've seen that some people do that... But i don't exactly know how

rich adder
elder raptor
rich adder
#

they did not ask about icons of folders

elder raptor
elder raptor
#

Didn't know the inspector thing existed, we learn a new thing everyday xD

dry tendon
dry tendon
rich adder
#

prob less, the biggest version of it you will is the project folder

#

64 at least though

final glade
#

Hello everyone,
So I do not know whether this would be considered an issue more of scripting or not. But I have started looking into 3D game dev, I am now considering recreating the old game Tom and Jerry war of the whiskers as an exercise for me to enhance my skills (not selling just for me).
I watched some tutorials on character animation, so I decided to create a state machine with the help of the input system. The issue is the code doesn’t give any errors but the run and move animations don’t work meaning when I press the specific button to move it doesn’t react to it.
Here is my code:

https://paste.ofcode.org/s8LFkxbubWeDLzrCBs4Bf5
https://paste.ofcode.org/v76rg8MbnY8ZcZ9LZpYHL8

Attached is the inspector of the “Tom Object”

#

Please tell me if any more details are required.

languid spire
elder raptor
#

How do I check whether I am on PC or Mobile?

Is it just "Application.platform == RuntimePlatform.WindowsPlayer" and for mobile "Application.platform == RuntimePlatform.Android"?

languid spire
elder raptor
#

Yeah iphoneplayer for IOS

#

IPhonePlayer

#

I remember doing this in another way using something like #If Platform.OS == Android or something along that line

languid spire
#

those are compile time directives, not runtime tests

elder raptor
#

Ahh

#

So rn, it's

if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.LinuxPlayer)

For PC, I only care about PC right now.

languid spire
#

That is not just PC, it is most standalone platforms

elder raptor
#

Ahh

#

Okayy thankies

final glade
#

Do you have an idea or do you want me to resend ?

languid spire
final glade
languid spire
#

and we are supposed to know that how? magic?

final glade
#

Sorry man 💀

hasty sleet
#

You may notice a button on your keyboard named "PRT SC" or similar. Press that button to print your screen.

#

Describe the problem, describe why it's a problem, describe the approach you have tried.

tiny wave
#

A pretty beginner question that I never really thought about until now...

In functions you have your "private void FuctionName(int int1 = 0, int int2 = 0, int int3 = 0)", with the name and default values of all those... but if you just wanted int3 to be 2, would you have to type in 0 for all the things before it, or otherwise how would you skip to a variable?

short hazel
tiny wave
#

sweet thanks

#

now i can save precious 2 seconds

elder raptor
#

Why can't I assign this function

public void OnPointerDown(PointerEventData eventData) { if (eventData.pointerEnter.name == upButton.name) { upButtonHeld = true; } else if (eventData.pointerEnter.name == downButton.name) { downButtonHeld = true; } else if (eventData.pointerEnter.name == leftButton.name) { leftButtonHeld = true; } }

To an Event Trigger?

rich adder
slender nymph
elder raptor
#

This script is attached to a game object that's not the Button. That's why

rich adder
slender nymph
#

the event will pass a parameter of type BaseEventData, and while it likely will be a PointerEventData it isn't stored that way so you'd have to cast in your method if you need to use that data

short hazel
#

The event header shows the expected method signature:

rich adder
#

just call the function you want directly ?

elder raptor
#

okay soo, I have three buttons, Up, Down and left. I want them to continuously run a function when clicked and when you stop pressing it, I want it to stop running the function

short hazel
#

Your method needs a parameter of type BaseEventData to appear here

elder raptor
#

Ohh

#

Okay that worked perfectly, thank you!

marble heron
#

hey! I have this script to clamp the camera movement but it's very rigid, how do I fix it to be more smooth?
using UnityEngine;
using Cinemachine;

/// <summary>
/// An add-on module for Cinemachine Virtual Camera that locks the camera's Y co-ordinate when the player reaches a certain position
/// </summary>
[SaveDuringPlay]
[AddComponentMenu("")] // Hide in menu
public class LockCameraY : CinemachineExtension
{
[Tooltip("The y position where the camera's y position will be locked")]
public float lockYPosition = -11f;

// Reference to the player transform
public Transform player;

protected override void PostPipelineStageCallback(
    CinemachineVirtualCameraBase vcam,
    CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
{
    if (stage == CinemachineCore.Stage.Body)
    {
        var pos = state.FinalPosition;

        // Check if player's y position is less than or equal to the lockYPosition
        if (player != null && player.position.y <= lockYPosition)
        {
            // Lock the camera's y position to lockYPosition
            pos.y = lockYPosition;
        }

        state.RawPosition = pos;
    }
}

}

final glade
# hasty sleet By default, send images in acceptable formats. Taking physical pictures of your ...

Basically, I am trying making a 3D player animation using the input system.
The issue is it shows that it reacts to the buttons but nothing is reflected on screen, I tried using debug.logs but it seems to working fine so I don’t think the issue is in the code.
For example when I click left shift nothing happens although the character is supposed to run.
Code link:

https://paste.ofcode.org/s8LFkxbubWeDLzrCBs4Bf5
https://paste.ofcode.org/v76rg8MbnY8ZcZ9LZpYHL8

Attached are the ss

shell laurel
#

Hey guys, I have a question regarding the input actions on my Quest 2. Basically, I want to reference the grab button or any button on my right controller and log something out. I set up the project via the Unity VR core template, and there are XRI default input actions defined, but I have no idea how to use them. Do you guys know how to do it?

teal mason
#

When I load a new scene, why is my 'Explosion' audio source no longer applied to my Handle Event script?

slender nymph
#

most likely you had it assigned via inspector, and i'd guess that the root object there is probably a singleton that destroys itself if an instance already exists. so when you loaded back into that scene the new instance loaded by the scene destroyed itself because an instance already exists in the DDOL scene. so any references to that instance (or any of its child objects) will be "null"

teal mason
#

The audio manager parent object is a singleton.

#

If that's the case, would I need to assign the prefab to the script?

slender nymph
#

i have no idea what you are referring to there. but your options are to either redesign your audio system so you don't have to rely on inspector references since those will be destroyed when you reenter the scene or get a reference to the existing instance of the objects in Start when the scene loads instead of assigning via inspector

teal mason
#

Got it. Thanks for your help!

final glade
hybrid wedge
#

Having trouble deleting stay projectiles in 2D

#

They fly out of my scene, I tried making a rectangle around my play area that catches them and deletes them I’ve tried messing with layer matrixes, colliders, istrigger

#

Nothing

timber tide
#

why not add a timer to them

steep sedge
#

Hi, Does anyone know how to make a waiting method? I'm been trying every since I started Unity and could never get it to work. Here is my corutine so far

#

Wait is this considered to go in advanced channel?

timber tide
#

no, but consider

#

!code

eternal falconBOT
queen adder
#

how do i setup ide tf

steep sedge
timber tide
#

your code is small enough such that you can use the ``'cs option there but the pastebins for larger code for future reference

steep sedge
#

I still dont get why I need this

#

oh nvm

#

mb

timber tide
#

bleh cant example it else it formats it

#

says it on the info up there anyway

steep sedge
#

I forgot to read the posting rules sorry

timber tide
#

the bin is fine though and mostly preferred as discord still hard to read on mobile (and people will sometimes post hundreds of lines of code)

steep sedge
#

ah ok

steep sedge
timber tide
#
IEnumerator wait(float waitTime)
{
    float counter = 0;

    while (counter < waitTime)
    {
        counter += Time.deltaTime;
        yield return new WaitForSeconds(5);
    }
}

you need to return the WaitForSeconds

#

well a few things here. You send a waitTime into your method

#

but you're using wait for seconds which actually shouldnt be what you want

#

so your code should be something like

IEnumerator wait(float waitTime)
{
    float counter = 0;

    while (counter < waitTime)
    {
        counter += Time.deltaTime;
        yield return null;
    }
}```
#

that's really it

#

WaitForSeconds is another way to wait, but it's not frame time specific so it's less preferred in a way than doing this

steep sedge
#

It just made the wait into doing nothing. Theres no counting or anything

timber tide
#

it does count. It adds deltaTime each frame. The most basic way to add a timer to your code

#

just in a coroutine

steep sedge
#

Wait so should I put it in a FixedUpdate if I don't want it to depend on frame rate?

#

because I don't see any type of pause

#

Both codes do not work

slender nymph
#

show what you actually tried

#

and keep in mind that starting a coroutine does not delay the code on the lines following the StartCoroutine call unless you yield the call inside of another coroutine

snow girder
#

why does this line break if its multiplied by time.deltaTime

slender nymph
#

define "break"

snow girder
#

as in it doesn't work

slender nymph
#

be specific

#

nobody here can see your screen or read your mind

steep sedge
#

Is it possible to yield outside of the corutine to pause it?

teal viper
#

Doesn't work, as in doesn't subtract?

snow girder
slender nymph
teal viper
snow girder
#

so try debugging the value its getting subtracted by?

snow girder
#

and i can see it already

teal viper
#

Doesn't matter

snow girder
#

alright

steep sedge
teal viper
snow girder
snow girder
#

interesting

teal viper
snow girder
steep sedge
snow girder
#

nvm it does

#

somehow

#

still goes to zero when multiplied with time.deltaTime

teal viper
snow girder
#

interesting

#

then how i would make the variable scale with time

#

since if your fps are high it'll go faster right?

timber tide
teal viper
#

Well, how much do you want it to decrease? And how often?@snow girder

snow girder
#

was planning on testing that after i got this figured out

polar acorn
steep sedge
polar acorn
#

Track the value as a float and cast it whenever you need to display it or use it as an int

steep sedge
snow girder
#

i'll do that

timber tide
timber tide
#
IEnumerator wait(float waitTime)
{
    float counter = 0;

    Debug.Log("We have waited for: " + counter + " seconds");
    while (counter < waitTime)
    {
        counter += Time.deltaTime;
        yield return new WaitForSeconds(5);
    }
}

But like I was saying, you're using two different waiting methods here which is not what you want to be doing

polar acorn
#

What is this coroutine even doing? Counter is a local variable so it seems to just be wasting time for no reason

summer stump
#

Because w is forward and d is to the right... thus together they make a diagonal.
What do you expect it to do?

steep sedge
steep sedge
summer stump
polar acorn
slender nymph
steep sedge
steep sedge
slender nymph
#

lol no it isn't

eternal needle
#
        float counter = 0;

        Debug.Log("We have waited for: " + counter + " seconds");

surely you see why this log does nothing for you

slender nymph
polar acorn
swift crag
steep sedge
#

Also chill out I just want to solve this issue

summer stump
#

Odd. If the x variable is 0, then it shouldn't go to the side based on that code.

Try this instead:

Vector3 moveDir = new Vector3(
  Input.GetAxis("Horizontal"),
  0,
  Input.GetAxis("Vertical")).normalized;

gracz.Translate(moveDir * speed * Time.deltaTime);
summer stump
swift crag
#

StartCoroutine tells Unity to start running a coroutine.

#

It does not "wait" or "pause" until the coroutine is over

#

that would completely freeze your game forever

#

It immediately continues to the next line after starting the coroutine.

steep sedge
swift crag
#

If you want to make CanHit become true after 5 seconds, then you need to set it to true inside of the coroutine

#

When you yield return new WaitForSeconds(5f);, you're telling Unity "please wait for 5 seconds before resuming me again"

#

so if you do something after this statement, it'll happen about 5 seconds later

steep sedge
swift crag
#
        while (counter < waitTime)
        {
            counter += Time.deltaTime;
            yield return new WaitForSeconds(5);
        }
#

This adds Time.deltaTime to counter once every 5 seconds

#

This will be a very small value. It's the amount of time one frame took to render

summer stump
#

Then you changed something

swift crag
#

This doesn't make any sense.

eternal needle
#

if only we had a counter for the number of times people have said this 😆

swift crag
#

If you want to wait 5 seconds, just ask to wait for 5 seconds once

#

at 100 FPS, this would take 500 iterations of the loop for counter to reach waitTime

#

which would be 2,500 seconds of total time

eternal needle
#

instead of guessing, you should be adding debugs to see what specifically doesnt work

swift crag
#

It would take five seconds to complete if you just did yield return null;, which tells Unity to resume the coroutine on the next frame.

steep sedge
swift crag
#

This method will yield a WaitForSeconds with a value of 100 million seconds

#

Unity will wait for 100 million seconds before resuming the coroutine

#

The coroutine will then end.

slender nymph
#

(and nothing happens because nothing was delayed by it)

swift crag
#

i never said anything was counting frames

swift crag
#

This is not counting frames.

#

you sound very confused about some pretty fundamental concepts here

eternal needle
polar acorn
# steep sedge So would this work? https://gdl.space/zatususili.cpp

This coroutine would start, wait, then end, doing literally nothing else. It's a completely pointless coroutine that does nothing.

Again, the code does not wait for the coroutine to end after you call StartCoroutine. The code continues along side it. That's what makes it "Co"

steep sedge
#

So how can I make a code wait

outer coral
#

with a coroutine

polar acorn
swift crag
summer stump
#
void Start() {
  StartCoroutine(Foo());
  Debug.Log("A");
}

IEnumerator Foo() {
  yield return null;
  Debug.Log("B");
  yield return null;
  Debug.Log("C");
}

This will log A, B, C

If i skipped that first yield, it would log B, A, C

steep sedge
outer coral
#

correct

hardy lintel
#

im finding it impossible to find a video for it. does anyone know of a video or forum that talks about adding bounds for a camera in a 3d game? so the camera cant move past a specific point on the x and z lines

hardy lintel
outer coral
#

then you need to code the camera to stay in a bounding box yourself

teal viper
# steep sedge So how can I make a code wait

"make a code wait" is not a very correct statement. That would imply the whole game would freeze and wait for it. If you really want to do it, you can do it with Thread.Sleep. usually what you want in your game is to delay the execution of certain code. That can be achieved with timers and/or conditions in update, coroutines or async.

hardy lintel
swift crag
#

Ever.

#

Stop trying to do that.

#

As we've said multiple times, if you want to do something after a delay, you need to do it in the coroutine. You can make the coroutine wait just fine.

summer stump
steep sedge
#

Ok I fixed it. You need the code before in the corutine and after

polar acorn
steep sedge
#

That cleared some things up

#

ok makes more sense now

#

ty

slender rock
#

Hey all, hopefully quick question, but is the Tilemap feature just for building levels/maps and stuff or can it also be used for game logic? I'm wanting to make a scene that revolves around this 3x3 grid of squares, and I want to be able to move the individual cells around the grid and have the cells talk to each other, so something like
right_neighbor_transform = Grid.GetCell(this.x+1, this.y).transform
as a quick example off the top of my head. Is a Tilemap a good solution for this? I figured I could keep track of the cells in a dictionary of Vector2 -> Cell game object, but actually displaying the grid and having them move around is what I'm stuck on. And by move around I mean for example, swapping the top left cell with the bottom right cell. I've tried using the Grid component but I can't seem to wrap my head around it because the children I add to it just end up stacking on top of each other. Thank you!

timber tide
#

Tilemap uses Unity's Grid class, but you don't need to use Tilemap to use it

#

it's basically just a world space grid that uses world coordinates

timber tide
#

then again, constraining the grid component isn't that much work either

swift crag
#

I've tried using the Grid component but I can't seem to wrap my head around it because the children I add to it just end up stacking on top of each other.

I don't understand what this means.

hybrid wedge
timber tide
#

scroll up to the 100 posts of people discussing timer coroutines

#

or just add the timer in the update loop

slender rock
#

Although now that I think about it, that might have been a UI grid layout

swift crag
hybrid wedge
#

One line of code

#

I’m so dumb

hybrid wedge
polar rune
#

Hi, I'm having trouble getting the tilemap.SetTile() function to work. Here is my code:

#

I'm serializing the Tile assets via the unity editor, and they place correctly when I place them manually using the tile palette

#

any ideas what im doing wrong?

slender nymph
#

where are you calling that method?

polar rune
#

using a unity event, Ive confirmed that the function is getting called using print statements

ember tangle
#

Is there a reason why neither path is taken? Debug.Log("method reached"); if (Physics.Raycast(ray, out hit, Mathf.Infinity, ground)) { Debug.Log("raycast success"); } else { Debug.Log("raycast failure"); }

ember tangle
#

a place where the first debug message is always called

#

but the other two never

summer stump
#

Not a great answer, but ok

#

To respond, no, one should be called

ember tangle
#

This is confusing

#

I'm trying to break up a god object into smaller scripts

summer stump
#

Any errors popping up? That could halt code execution

ember tangle
#

it works in the god object

#

no errors, rest of the code works

#

Ill check though I guess that is the only thing that makes sense

polar rune
#

here is my tilemap if that helps

#

and its attached to a grid component

ember tangle
#

to narrow it down

#

replace foo with what is appropriate

polar rune
#

I've confirmed the function is being called though

ember tangle
#

check for any null?

polar rune
#

how do I do that

ember tangle
#
{
//error message
}```
polar rune
#

right

polar acorn
polar rune
#

its not null

polar rune
ivory bobcat
polar rune
#

ima start a thread so these 2 things dont get mixed up

polar acorn
polar rune
#

tilemap.SetTile() help

polar rune
#

Cursor (which invokes the event)

#

and DrawArrows (which has the function)

ember tangle
polar acorn
eternal falconBOT
polar rune
#

its a little complicated

#

but when gamestate case is MOVE update calls move()

#

and move invokes the event draw arrows in case of the right input

#

I'm pretty confident that drawArrows() is being called

summer stump
misty socket
# polar rune

try this ``` // Game States
public void turnBase() {
// Cursor Movement
float horizontalInput = Input.GetAxisRaw("Horizontal");
float verticalInput = Input.GetAxisRaw("Vertical");

        if (horizontalInput != 0 || verticalInput != 0) {
            Position newPos = currentTile.position + new Position(Mathf.RoundToInt(horizontalInput), Mathf.RoundToInt(verticalInput)); ```
#
            }
            if (Input.GetKeyDown(KeyCode.S)) {
                MoveCursorAndDrawArrows(new Position(0, -1));
            }
            if (Input.GetKeyDown(KeyCode.D)) {
                MoveCursorAndDrawArrows(new Position(1, 0));
            }```
#
            Position newPos = currentTile.position + direction;
            if (board.isOnGrid(newPos)) {
                moveToTile(board.getTile(newPos));
                drawArrows.Invoke(selectedFighter.currentTile, currentTile);
            }
        }

        public void moveToTile(TileData tile) {
            if (tile == null) {
                Debug.LogError("Trying to move to a null tile.");
                return;
            }

            Position relMovement = tile.position - currentTile.position;
            if (!board.isOnGrid(tile.position)) {
                Debug.LogWarning("Trying to move to a tile outside of the grid bounds.");
                return;
            }

            transform.Translate(new Vector3(relMovement.x, relMovement.y, 0));
            currentTile = tile;
        }
    }
}
#

those are just snippets

polar rune
#

ight i figured it out lmao

#

total noobie mistake, I was placing it off my screen so i didnt see it 🤦‍♂️

#

ty for attempted help lol

vast ivy
#

can someone tell me why my gameobject isnt being set to active when I start dragging? I can debug.log and see that dragging is working, but the gameobject is still not being set to active?

 ... ^ rest of code

    public void OnBeginDrag(PointerEventData eventData)
    {
        dragging = true;
        draggedItemIcon.SetActive(true);
        Debug.Log($"Begin Dragging slot: ");
    }

    public void OnDrag(PointerEventData eventData)
    {
        Debug.Log("Dragging");
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        dragging = false;
        Debug.Log("End Drag");
    }
cosmic dagger
#

Locally, it is active, but not in its hierarchy . . .

vast ivy
#

its parent is "inventory" which it turned on when I press tab, I can see it if I turn it on manually but the active state doesnt change when I drag

#

I can see in the inspector when I drag its not even being set to active

cosmic dagger
#

Is the correct GameObject assigned to draggedItemIcon?

vast ivy
#

yup, I have it set to a gameobject ive assigned from dragging it into the variable

hybrid wedge
#

No matter what I do

#

Can someone who’s good with 2D layers help me I can’t get this tank to appear above the background

#

I’ve tried sorting layers, layer matrix, z-axis

#

Nothing

#

Its driving me insane

vast ivy
rich adder
#

also not really a code question

hybrid wedge
#

I know didn’t know where to send it

rich adder
#

show your actual inspectors and whatnot

vast ivy
cosmic dagger
hybrid wedge
#

Ok didn’t know my bad

vast ivy
#

I think i need to restart Unity... its not using updated code

cosmic dagger
vast ivy
#

no errors, I just saved it restarting it now. it didnt print the new debug logs I just added and I changed the text for dragging and it didnt change

#

its still not using my updated code?

#

new code:

    public void OnBeginDrag(PointerEventData eventData)
    {
        dragging = true;
        draggedItemIcon.SetActive(true);
        Debug.Log($"Begin Dragging slot: ");

        Debug.Log(draggedItemIcon.name +draggedItemIcon.activeInHierarchy);
    }

    public void OnDrag(PointerEventData eventData)
    {
        Debug.Log("Dragging ur mom");
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        dragging = false;
        Debug.Log("End Drag");
    }
cosmic dagger
#

The screenshot cuts off the rest of the console. Hard to tell from this small view . . .

vast ivy
#

one sec, I may know the issue

#

I had another script with drag handlers in it, this code hasnt been running...

cosmic dagger
#

I fail to see the connection, but as long as you got it, good . . .

vast ivy
#

I dont completely see why the other script wasnt running but this works for now xD

#

thxs for ur help anyways

flint fulcrum
#

I have a question regarding movement of a simple cylinder

#

when making this

#

wait

#

how to make it with the colors

ivory bobcat
#

How to post !code - look at the large code section (inline isn't preferred for large scripts)

eternal falconBOT
flint fulcrum
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    private CharacterController controller;
    private Vector3 playerVelocity;
    private bool groundedPlayer;
    private float playerSpeed = 2.0f;
    private float jumpHeight = 1.0f;
    private float gravityValue = -9.81f;

    private void Start()
    {
        controller = gameObject.AddComponent<CharacterController>();
    }

    void Update()
    {
        groundedPlayer = controller.isGrounded;
        if (groundedPlayer && playerVelocity.y < 0)
        {
            playerVelocity.y = 0f;
        }

        Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        controller.Move(move * Time.deltaTime * playerSpeed);

        if (move != Vector3.zero)
        {
            gameObject.transform.forward = move;
        }

        // thanks google 
        if (Input.GetButtonDown("Jump") && groundedPlayer)
        {
            playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
        }

        playerVelocity.y += gravityValue * Time.deltaTime;
        controller.Move(playerVelocity * Time.deltaTime);
    }
}

#

moving my little guy is fine

#

But how to make it so when the camera is attached

#

moving forward is based on the camera<s position

rich adder
flint fulcrum
#

Yes

rich adder
#

you normally rotate the player with the input of your Mouse X, that takes care of a child camera

#

then you use transform.forward as direction

flint fulcrum
#

so I did it wrong?

ivory bobcat
#
if (camera) 
    target = camera;
else
    target = transform;
if we moved 
    target.forward = move;```
rich adder
#

your forward looks at your inputs

flint fulcrum
#

i see

#

Thanks

#

and what if

#

I wanted it to always look towards an object

#

wheter it<s moving or not

rich adder
#

a few ways to do it

#

transform.LookAt or Rotate towards etc

flint fulcrum
#

But how can I make it so it looks at another object

#

I got it to work but to look at 0, 0, 0

rich adder
#

you need references

flint fulcrum
#

i need more brain power

rich adder
#

🤷‍♂️

flint fulcrum
#

i'll look at more

#

ty

flint fulcrum
#

is there a way to like lock it

#

because the rotation of the camera just goes flying

ivory bobcat
#

Maybe show us what you've done and what the problem is.

rocky canyon
#

only call the look at once..

flint fulcrum
#

im confused looking at the whole thing

polar acorn
#

Or the other object's Transform

fierce geode
#

Would anyone have any tips on how to make characters stick to the ground when going off ramps at high speed?

#

I think I've found a sort of solution, but it doesn't work if the edges of the ramp and ground aren't exactly alligned

dawn oracle
#

can someone please help me i have a rigged vr model right here with inverse kinematics u can see that it has hands but when i go to play the hand doesnt render the forarm also doesnt render if the camera is posisioned closer so i think its something to do with the camera unrendering things

fierce geode
#

have you tried reducing the near value of the camera?

rocky canyon
#

the camera wont render things closer to it than the near clipping plane

dawn oracle
#

near value?

rocky canyon
#

green being the near clipping plane

#

and the orange being the far clipping plane

fierce geode
rocky canyon
dawn oracle
#

ooo ok so just decrease that

rocky canyon
#

yes.. but dont go lower than u need to

fierce geode
#

maybe, might cause problems if you go too low

dawn oracle
#

ok

#

lemme try it

rocky canyon
#

.2-ish is a good value i use

dawn oracle
#

i have it at 0.1

rocky canyon
#

hmm i've never walked up a ramp with my body tilted like that

#

seems like i'd fall 😅

fierce geode
#

you don't do that? damn, now im starting to feel a tad silly walking up my ramps like that lol

rocky canyon
#

nah, if u can climb ramps like that..

#

thats talent..

dawn oracle
rocky canyon
#

hell of some calves and ankle muscles

dawn oracle
#

@rocky canyon that didnt work but it def is somthing to do with the camera here i have the camera rotated straight

#

then if i turn it a little bit

#

u can see the hands actually render

#

it happends even in my scene view

lavish magnet
#

Ive imported this unioty environment scene and am getting these 2 errors

#

Line 19

dawn oracle
ivory bobcat
vernal bone
#

How acceptable is moving a rigidbody through MovePosition?

rich adder
#

only makes sense if its kinematic and manually check collisions

vernal bone
#

it is kinematic, but can you elaborate a bit on manually checking collisions?

rich adder
#

moveposition / kinematic movement will phase through walls / colliders unless you manually check for collisions via physics casts n such

vernal bone
#

one more question.
for kinematic rigidbody it's better to use MovePosition or velocity?

rocky canyon
# vernal bone one more question. for kinematic rigidbody it's better to use MovePosition or v...
  1. MovePosition: Moves the Rigidbody to a specified position over time.

    • Takes into account collisions and physics interactions. (not as kinematic)
    • Useful for precise movement or movement based on user input.
    • Provides deterministic behavior in FixedUpdate.
    • May lead to smoother movement compared to directly setting velocity.
  2. Velocity: Sets the velocity of the Rigidbody directly, affecting its movement in the next physics update.

    • Overrides any collisions or physics interactions temporarily until the next physics update.
    • Useful for continuous movement or applying forces to the Rigidbody.
    • Can lead to jerky or abrupt movements if not carefully managed.
    • Requires more careful handling to ensure physics interactions are properly accounted for.
rich adder
#

MovePosition does not account for collisions

rocky canyon
rocky canyon
rich adder
#

other rigidbodies will collide with it, but itself just phases through colliders

rocky canyon
#

ya, but between frames. u get collisions.

#

i. musta misread something originally.

rich adder
#

moveposition is meant to be used with kinematics , it won't account for colliders

#

try it if you don't believe me :p

rocky canyon
#

or im tripping now

#

no its not that i dont believe u.. i just always had thought it did

rich adder
#

iirc the 2D Might behave differently than 3D one

rocky canyon
#

hmmm, its on my todo now to fiddle with it vs velcoity

rich adder
#

for example kinematics have velocity in 2D for some reason

rocky canyon
#

like people substituting it from their failed translation code

rich adder
#

iirc the free kinematic controller uses MovePosition

#

the rest is casts

#

this is so other objects that hit it still react

rocky canyon
#

hm, i got some experimenting to do now

#

found a post from PraetorBlue 😄

#

apparently i wasnt the only one that thought that 😅

rich adder
rocky canyon
#

well w/ the 2nd opinion im not gonna test anything

eternal needle
#

well thats less about MovePosition respecting collisions and about the actual rigidbody not wanting to be shoved in a wall. If you try to move it manually in inspector too, the rigidbody wont just allow itself to be placed in one

rich adder
rocky canyon
#

believe yall, lol.. gotta rewrite something real quick.. and next time im using an RB imma have to give it go.. just to say ive used it

rich adder
rocky canyon
#

b/c im a velocity = kinda guy

rocky canyon
rich adder
rocky canyon
rich adder
#

i guess I never used MovePosition without kinematic so I never tried walls with dynamic

#

learned something new then

rocky canyon
#

i never use MovePosition

rich adder
#

need to double check cause I was having a mandela effect moment lol

rocky canyon
#

im about to make a little demo thing to play around w/

#

the only rigidbody stuff i have is my kinematic cc ive purchased

rocky canyon
#

illusion of physics

#

ya, i was just mistaken

#

seen 1 thing, thought something else was happening.. 🐰

nimble apex
#

what can you do to "await" inside coroutines except using yield return?

#

i ran into situation where i cant use this

rocky canyon
#

really now?

rich adder
# rocky canyon

what about solid walls? also 2D and 3D act different in unity

rocky canyon
#

the other rigidbodies are colliding with it

#

and not viceversa

rich adder
rich adder
rocky canyon
#

they just unclipping themselves

#

and thats why they appear to have bouncy material

#

they shuld just be pushed along with it iirc

#

thats why i prefer me a real RB..

#

and i let someone else make the kinematic ones lol

nimble apex
rich adder
rocky canyon
#

can u make a jerryrigged while loop? and evalulate a timer inside the coroutine?

#

lol that sounded dumber after i said it, and it sounded pretty dumb in my head

nimble apex
#
        //retrieve timezone data from s3 server
        if (BuildDefine.AgentCode != "ZZZ")
        {          StartCoroutine(ResourcesManager.Instance.RetrieveTimezoneFromServerFile(BuildDefine.AgentCode));
        }

        //Language Download And Iniitializtion
        yield return LanguageDataScript.Instance.DownloadAndInitialization().AsIEnumerator();
        while (LanguageDataScript.Instance.isLoading)
        {
            yield return null;
        }```

this is the outer shell of the coroutine, my goal is to "MUST wait until RetrieveTimezoneFromServerFile finished, to the last line"
#
    public IEnumerator RetrieveTimezoneFromServerFile(string code)
    {
        string ip = NetworkManager.Instance.GetResourceUrl();
        Int64 time_stamp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds();
        string version_url = $"https://{ip}/Agents/{code}/sw_main.json";//agents/ccc -> sw_main.json

        bool isSuccessGetFile = false;
        string mainData = "";

        Action<bool, string> callback = (success, data) =>
        {
            isSuccessGetFile = success;
            mainData = data;
        };

        yield return GetTextResources(version_url, callback); //file obtained

        if (string.IsNullOrEmpty(mainData))
        {
            Exception e = new Exception("WARNING! ACCOUNT NOT FOUND");
            GameManager.Instance.ExceptionKey = e.ToString();
            GameManager.Instance.LogOnDebug.LogException(e); //will generate error popup

            if (!NetworkManager.Instance.isServerFileFirstRetrieved)
            {
                NetworkManager.Instance.StopAllCoroutines();
            }

            StopAllCoroutines();
        }
        else
        {
            // deseralize/store timezone string
            TestMaintenanceData testData = JsonConvert.DeserializeObject<TestMaintenanceData>(mainData);
            NetworkManager.Instance.timezoneOffset = testData.timezone;
            NetworkManager.Instance.isServerFileFirstRetrieved = true;
        }

        yield return null;
    }```
#

this is the coroutine

rich adder
#

whats the current issue though with it

nimble apex
#

the problem is , GetTextResources is a server call, it grabs files from servers, it takes time

before it can retrieve files and let me check "mainData"

on outer shell, the language download is already executed

#

its a timing issue

rich adder
#

You can use a UnityWebRequest inside a coroutine

#

it can be ~~awaited ~~yielded there

queen adder
#

how do i fix this (i get it after double clicking a script

gaunt ice
nimble apex
nimble apex
#
//retrieve timezone data from s3 server
if (BuildDefine.AgentCode != "ZZZ")
{
    yield return new WaitUntil(() => ResourcesManager.Instance.RetrieveTimezoneFromServerFile(BuildDefine.AgentCode).IsCompleted);
}```
#

made the coroutine as Task

#

and uses waituntil to do it

queen adder
#

guys how do i get out of this mode?

shadow rain
#

Ive got a script which rotates an object but I want the object to rotate around the player not itself

shadow rain
#

but how could I make it follow the mouse?

burnt vapor
#

Please use the proper channel next time