#💻┃code-beginner

1 messages · Page 519 of 1

steep rose
#

your code is doing exactly what you are telling it to do, from what I'm seeing

swift sedge
#

on my computer, Alt + 225 is ß

rocky canyon
swift sedge
#

ohh

#

my brain isn't braining

rocky canyon
#

mine either i still cant find this widget

gray coral
#

yes just the player locally flip outward

rocky canyon
#

mines different

steep rose
#

We would need to see some code that rotates the orange ball on the Z axis, also it looks like you are flipping the orange ball

#

not your parent of the orange ball

languid spire
#

not quite sure why you would expect to see a difference, flipping a circle about it's pivot point will just give you the same circle in the same position

gray coral
#

player code

steep rose
gray coral
languid spire
steep rose
#

oh my bad

languid spire
gray coral
languid spire
#

you have not showed what you want the final position to be

steep rose
#

you seem to be scaling it

languid spire
gray coral
#

it rotates to the left or right

#

when player collides it needs to flip so y-as points outwards again

steep rose
rich adder
#

scaling is a way to flip btw

languid spire
#

@gray coral why not show us a before and after image of what you want to achieve so we can stop all this guess work

rich adder
#

btw to flip it you can literally just do
transform.up *= -1

steep rose
#

on the parent mind you

#

from the image he provided it look like he is rotating the orange ball

gray coral
odd widget
#

Which one is a better practice, having a collection of bool in a dictionary, or just a bunch of public bools? The context is that the bools will be set and read often from different scripts

steep rose
#

the orange ball is the parent, im an idiot

gray coral
#

yes

odd widget
wintry quarry
#

In what context

#

what's the purpose of them

steep rose
wintry quarry
steep rose
#

I should have said the Player not parent

wintry quarry
#

e.g. HashSet<string> is better than Dictionary<string, bool>

steep rose
odd widget
#

Aaah okay, i’ll look into it

#

I haven’t learned about it’s existence until now

odd widget
#

Thankyou!

gray coral
#

to show what i want

steep rose
#

then rotate it 180 deg

#

you can scale it as well but that does not seem to work

languid spire
#

not a rotation a flip, a rotation would also move the red arrow

steep rose
#

are you scaling the player OBJ and not the actual player parent?

gray coral
wintry quarry
#

(that just rotates it, by the way)

rich adder
#

your X will still be flipped too

odd widget
#

So what i’m getting is that hashset is like a list but it’s more efficient if we use it on normal variable but not class?

gray coral
#

aslong y faces outwards is good

#

i dk how to record with unity otherwise i showed you what iam building

wintry quarry
#

I have no idea what that means

#

no

#

a HashSet is a set

#

not a list

steep rose
rich adder
#

they are extremely efficient

wintry quarry
odd widget
#

Aaah okay

#

i get it now

#

thanks!

rich adder
#

and lists are nothing more than arrays on steroids lol jk
they are arrays that resize

odd widget
#

yea i'm familiar with array and list

#

but this is the first time i encountered this one lol

rocky canyon
#

its just a buzzword for me

rich adder
#

wait till you learn about Queue and other collections lol

rocky canyon
#

i see it all the time. but no where near ready to use em

odd widget
rocky canyon
#

Queues are cool

odd widget
#

Anyway, thanks again

rocky canyon
rich adder
rocky canyon
#

we've already listed off

  • arrays
  • lists
  • queues
  • hashsets
languid spire
#

Stack ?

rocky canyon
#

Stack

#

i was missing that one

#

yup

languid spire
#

HashTable

#

Dictionary

rocky canyon
#

omg. how did i forget that one

odd widget
#

I’ve been meaning to learn about hastable

rocky canyon
#

KeyedCollection 🤯

#

isnt that a dictionary? lol

languid spire
#

and then you have the Blocking Collections as well for multi threading

odd widget
#

But I haven’t encountered a problem that needs me to use it yet

wintry quarry
#

HashTable is just the non-generic dictionary in C#

rocky canyon
odd widget
#

Oh really

#

That’s really nice to know

languid spire
rich adder
rocky canyon
rich adder
odd widget
#

Most of my learning comes from asking people “how can i do this stuff better instead of going goblin mode on the coding” and people would tell me more efficient stuff that i never know even existed

#

I cannot read docs like those lol

#

I’m too zoomerbrained

steep rose
#

you should have the mental capacity to read documentation

languid spire
#

and, preferably, remeber it

rich adder
#

tbh the Microsoft docs used to be shit, its gotten better though

#

less robotic now

languid spire
#

it's a shame Unity package docs are so shit now

rich adder
#

they should convert it like the NGO ones, is good because it goes through github so we can actually submit revisions or add more info with PR

gray coral
#

this is what i make, at the second jump you see the ball doesnt really correctly moves up. some suggestions how to fix it?

vocal orchid
#

Hi

#

I am trying program a corutine with a condition

rocky canyon
#

give us !code examples too

eternal falconBOT
rocky canyon
#

hatebin working today? niice

vocal orchid
#

If persecution is true, so the corutine "Persecution" is active but if the false, the corutine "Persecution" is desactive and the corutine "Patrol" is active

odd widget
#

after trying to implement the hashset, i got confused. what i'm trying to do is to make a state true or false. like if i were to use dictionary it would be {("clock", false), ("note", true)} how would i do this using hashset. more importantly, how to set the true or false of a hash set if it only contains value

rocky canyon
#

so i assume ur using a while()

vocal orchid
rich adder
wintry quarry
#

you are waiting a bunch and then doing nothing

#

these are poointless

rich adder
eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

slender nymph
wintry quarry
#

your whole coroutine, in fact, is pointless, since you just have a while loop that doesn't pause inside it

rocky canyon
#

ya that while loop could be in update.. if theres no waiting needed

rich adder
rocky canyon
#

or if statements even

wintry quarry
#

The problem with dictionary is you actually have three states:

  • Not in the dictionary
  • in the dictionary and false
  • in the dictionary and true
#

for hashset there are two states:

  • not in the set
  • in the set
#

so the hashset is a better pure boolean solution

vocal orchid
#

¿¿¿

wintry quarry
#
bool note = mySet.Contains("note");``` @odd widget
#

for your example it would just be a set containing note

odd widget
#

oh

wintry quarry
#

and not containing clock

odd widget
#

that makes a lot more sense!

#

thankyou!

#

no tenor gif rip

vocal orchid
#

@rocky canyon

rocky canyon
#

whats up (╯°□°)╯︵ ┻━┻

#

i really dont understand what ur going for.. can u tell us what ur wanting to accomplish?

#

besides "desactive and corutine and active other"

vocal orchid
#

I want what stop a corutine with base a condition

#

I start a corutine with base a same condition

rocky canyon
#

if it were me i'd put my logic in the update, cache the Coroutines and stop and start them that way

rich adder
#

can also use a while loop with a specific bool you can set to false anytime

rocky canyon
#

if(blabla){newCo = StartCoroutine(blabla);}

#

StopCoroutine(newCo); etc

wintry quarry
rocky canyon
#

^ all good options

rocky canyon
#

i just like caching my coroutines

#

so i dont have phantom ones runnin

rocky canyon
vocal orchid
#

I will try with all thores options, ok¿

naive pawn
#

linkedlist

rocky canyon
#

ok ok.. i see the flex

rich adder
#

SQL

rocky canyon
#

mySQL?

#

thats a database

#

we aint even on the same level now

rich adder
#

😏

naive pawn
#

sql is a language

#

mysql is a database that supports sql

rocky canyon
#

yea, i remember those dark days

naive pawn
rich adder
#

tuples, when you're too lazy to make a struct

rocky canyon
#

u should make a thread and list EVERY thing u can think of

#

i'll go back and look at it when im not as busy

#

maybe..

naive pawn
#

oh yeah, heaps, trees, and graphs

rocky canyon
#

we only concerned about c# around these parts

rocky canyon
#

great way to go about it

rich adder
rocky canyon
#

same.. almost all my data goes in a struct or an SO

#

right or wrong.. it feels right

rich adder
#

i hate that unity doesn't support the latest c# we can't even field initilizers for struct so its annoying they all have to start at 0/default value

rocky canyon
#

calm down now.. is 9 not good enuff?

rich adder
#

never!

#

I mean most is syntax sugar but dammit..give me file-scoped namespaces dammit..

rocky canyon
#

thats facts.. the way i see it i know enough now (without knowing close to everything) to do almost everything i need to do..

rich adder
#

i hate the indentation when i'm using namespaces in unity

rocky canyon
#

now is it optimal?

#

thats a different story

rocky canyon
rich adder
vocal orchid
#

Well, it's working an part.

#

The corutine "Patrol" not start

rich adder
#

!screenshots

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

naive pawn
# gray coral why not?

it's code, we want to analyze it as code, with text search, copying stuff, etc, not as an image

vocal orchid
#

Not working,

naive pawn
#

that's not how you stop coroutines

#

what are you even trying to achieve there?

vocal orchid
#

Wait and stop the corutine

naive pawn
#

recursion is not the tool for this, you should probably just use a loop instead

naive pawn
#

you don't need an explicit StopCoroutine here

vocal orchid
#

Well, i don't use Stop else a return null?

naive pawn
#

you don't have to do anything

#

just let the function finish normally

rich adder
# gray coral i thought you gonna get hacked

staring at screenshot of code is the most unintuitive way to help someone because you cant select anything easily, copy and paste.
its also annoying af on a phone screen to zoom in and stuff. Its okay for showing something visuals, code doesn't need to be

vocal orchid
naive pawn
#

waiting for what?

#

you aren't doing anything after 4 seconds, so what's the point

#

if you want to check again, use a loop, which is the proper tool for that

gray coral
rich adder
toxic yacht
# vocal orchid Not working,

Calling Persecution() is done to create new Coroutines (or to be more accurate new IEnumerators). To stop a specific coroutine, you want to save a reference to it (to end it from outside the coroutine), or use yield break (to stop it inside the coroutine):

void StartCoroutine()
{
  if (myCoroutine != null)
    StopCoroutine(myCoroutine);  // <- stop coroutine from outside
  myCoroutine = StartCoroutine(MyCoroutine());
}

Coroutine myCoroutine = null;

IEnumerator MyCoroutine()
{
  if (somethingIsTrue)
  {
    yield new WaitForSeconds(1.0);
    yield break; // ,_ stop coroutine from inside
  }
  // other stuff 
}

just like that guy said, in your case, manually stopping the coroutine isn't needed since it will automatically end when it reaches the end of the function.

#

I wrote that from muscle memory did I mess up my sytax or something?

languid spire
rich adder
languid spire
#

yes, I thought that StartCoroutine() and StartCoroutine(MyCoroutine()) would conflict but of course it will use the override

sterile radish
#

my game uses a dialogue system that displays text on a screen with one character at a time using a coroutine. it gets this text from a dialogue object which has lines of text + other stuff. how would i improve this coroutine so that if the text inside the dialogue object was something like "<b> bold text </b>", it would display the text as bold?

rich adder
#

probably not trivial since you are also splitting / breaking the RichText tags

languid spire
keen dew
#

TMP has maxVisibleCharacters just for this

sterile radish
#

i'll check it out, thank you!

#

it's working :). but i was wondering if i could expand this with my own custom tags? like if it was "<w> wavy text </w>" the text would move along a sine wave or something. how would i let the typing coroutine know that whenever "<w>" and "</w>" in a line it should make the text wavey and not to type out the "w" and "/w"?

rich adder
#

maybe with help of regex

#

probably least efficient way but you can store all the found words within as "wavy" words and then go from there

stuck palm
#

can you return the items in a grid layout?

rich adder
#

you would prob iterate the children n get specific item

stuck palm
rich adder
#

you can probably just link those together with the event system no ? or Navigation layout thing in UI .

stuck palm
rich adder
#

maybe you could just do your own grid in code like 2d array, to store the actual x/y grid

stuck palm
rich adder
#

its just some type of grid navigation system, not sure if it has a name tbh

#

table navigation ? columns and rows navigation ? lol idk

sterile radish
#

hi, i kind of opted for a different approach where i use a tag detector for each character that is currently being written. i'm just having trouble on what i would do after i figure out "inTag" is true.

https://hatebin.com/qehjljlbhm

wintry quarry
rich adder
light flint
#

hi guys

#

Have you all encountered this situation before?

#

Using the same drawing code, encountering completely different color results on "OnGUI" and "OnRenderObject"

#

😭

sterile radish
# wintry quarry what is a "tag detector"? What's the goal here?

basically im making a dialogue system that types out a sentence one character at a time. similar to how you can type "<b> </b>" to make a text bold, i wanted to implement my own version of that with "<w> </w>" to have wavy text. my question was just asking how i would apply the wave effect to the character once i know it's in a wavy tag.

sterile radish
burnt vapor
north kiln
burnt vapor
#

So if you enter the tag, look for </w> or something and then just proceed with the code on the inner string

rich adder
# sterile radish i'm pretty sure regex would've been better but the syntax kind of scared me off ...

you just made an overconvolued way instead myguy, it was like 3 lines of code lol.

 string input = "This is a <w>WavyScooter</w> inside a string with another <w>WavyWordd</w>.";
        string wavePattern = @"<w>(.*?)</w>";
        MatchCollection matches = Regex.Matches(input, wavePattern );

        foreach (Match match in matches)
        {
            Debug.Log("Wavy Words: " + match.Groups[1].Value);
        }```
You have the words, after that you can just iterate them for the effect you want
replace pattern with any tag you want instead of `<w>`
`match.Groups[1]` gives the word without the tags
`match.Groups[0]` gives the word with the tag too
light flint
sterile radish
rich adder
light flint
#

This is OnGUI

sterile radish
light flint
#

Terrifying image processing

#

This is OnRenderObject

rich adder
# sterile radish okay, thank you for the help!

np.
also next time if you had any confusion or question you could've just asked lol would've gladly showed how to put it to use instead of ignoring it then doing it another way, i mean defeats the purpose of asking for help no?

young spindle
#

Problem with Input System / Build

north kiln
light flint
#

Because all of my game textures use Graphics.DrawTexture to draw

cosmic quail
polar acorn
#

...why

light flint
#

Because the original project was based on SlimDX, this is a porting project

polar acorn
#

Might be worth taking the time to recrate the graphics as an image and using Sprite Renderers

light flint
#

😭

polar acorn
#

If the point is to port it to a modern engine, it's probably going to take some effort to modernize the asset pipeline

north kiln
#

GUI.DrawTexture might use a gamma corrected material. No idea though

light flint
#

GUI.DrawTexture can indeed display correctly, but Material cannot be used. I will try some algorithms for color conversion

rancid tinsel
#

whats the difference between Pause() and Stop() for audio sources?

#

like why would you use one over the other

languid spire
polar acorn
#

You can't unpause an audio source that was stopped

rancid tinsel
#

i got that, the bit im confused about is then whats the point in using Stop instead of just resetting it and pausing

#

or is that basically what stop does?

upper nymph
#

hey guys! I have an issue with my code, its a really weird one and im not sure how to explain... anyone free to call and help? (im a beginner at this stuff TnT)

polar acorn
#

that's really all there is to it

eternal falconBOT
upper nymph
#

It isn't working working for me...

steep rose
#

what is not working

upper nymph
#

like using the API script refrencing stuff, the trouble shooting etc

steep rose
#

I mean't what is not working in your script

#

you need to tell us for us to help you

upper nymph
#

the issue is regarding scene changing in Unity, but what I don't understand is that the same exact thing worked for the 2nd scene, but then when i try for the 3rd scene, it doesn't work

upper nymph
polar acorn
#

Show !code

eternal falconBOT
steep rose
polar acorn
#

And explain in more detail what "doesn't work" means. What are you expecting to happen and what actually is

upper nymph
#

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

public class SceneChanger : MonoBehaviour
{
public void LoadScene(string scenename)
{
Debug.Log("Loading scene: " + scenename);
SceneManager.LoadScene(scenename);
}
}

The code is generic and should work, the only thing i should have to change is scene name. This is attached to the canvas, and there is a button to be clicked in order for this to run.

upper nymph
#

I am expecting a scene change, but nothing happens

wintry quarry
#

Make sure there aren't errors

upper nymph
#

ya

wintry quarry
#

and make sure the code is actually running

wintry quarry
upper nymph
#

the console doesnt say any errors or anything actually

wintry quarry
#

it should be printing at least the results of Debug.Log("Loading scene: " + scenename);

upper nymph
#

thats where im getting stuck.... Im not sure why it isnt doing that. It is working for another scene, where it says "Loading Scene H1"

wintry quarry
#

If not, you probably forgot to include an Event System in that scene

upper nymph
#

the thing is, i didnt include it in the first either

upper nymph
#

the scene that works with this code

wintry quarry
#

just not on purpose

#

it gets included when you create a button

#

or any ui element

#

but if you just copied the button from another scene, it won't be there

#

and things won't work

#

so the thing is, you need to check if you have an Event System in the scene that isn't working

steep rose
#

tutorials usually forget to tell you that you need an Event system for any UI to work correctly

upper nymph
#

oh ok i think I understand now, thank you so much for helping me guys!

upper nymph
sterile radish
rich adder
#

i think you got that backwards, you'd need the text to be in the tmp before you can get the verticies

sterile radish
rich adder
#

if you think about it, doesn't make much sense

languid spire
rich adder
prime goblet
#

im having and isue about my code, when i move the player, the rotation changes:

                Vector3 newCamPos = new Vector3(hoverObject.transform.position.x + camDistanceXZ, hoverObject.transform.position.y + camDistanceY, hoverObject.transform.position.z + camDistanceXZ);
                player.transform.position = newCamPos; // Quaternion.Euler(new Vector3(20, 225, 0))
#

it is random but close to the result

rich adder
#

what is this code supposed to do

prime goblet
#

move the player

languid spire
#

is the player object parented to something

prime goblet
prime goblet
#

well the root i guess idk

rich adder
#

its either parented or not, how you not know lol

prime goblet
#

idk if you count the scene as a parent

#

i normally dont

rich adder
#

no scene is not parent, its root

prime goblet
#

ok

#

so no parent

rich adder
#

is that only piece of code on the player?

peak holly
#

Hi, does anyone have some resources on mesh generation using a compute shader, I want to generate a mesh with a dynamic number of vertices (that isnt known at compile time) and i'm wondering how to do that, as all the tutorials i could find on it assume it operates on an existing mesh and deforms it, but doesn't generate new vertices.

sterile radish
#

hi, i've gotten the vertices of each of the characters in the text now using TMP_TextInfo but it doesn't work whenever im playtesting? the text just types out like usual with no addiitonal wavy effects

https://hatebin.com/dhzjojqzmw

gleaming plaza
#

uh I want this ray to hit the ground but it seems like it isn't going anywhere and I don't really know why

wintry quarry
#
Debug.Log($"The ray hit {hit.collider.name};");```
swift sedge
gleaming plaza
#

oh it's hitting the camera area

wintry quarry
#

or it's not hitting anything

wintry quarry
prime goblet
rich adder
prime goblet
#

im not sure

#

there isnt any gravitational force on it

#

no rigidbody

wintry quarry
prime goblet
#

actually, it's a camera object

#

if that matters?

wintry quarry
#

or cinemachine

#

and therefore by changing its position it must change its rotation to keep looking at that thing

prime goblet
#

nope

wintry quarry
#

without seeing your project it's impossible to say then

#

presumably something else is doing it

#

changing position does not change rotation

prime goblet
#

the camera is used to fire a raycast, but im not changing the raycast (if that's possible) im only getting it

wintry quarry
finite mango
#

I've created a scriptable tile object that im using as a tile in my tilemap and it has a function to change its own sprite. How can I actually call this function from a second script? I want the sprite for a tile to update whenever the mouse clicks on it.

In my second script Ive got the following code:

Vector3Int tilePos = fieldsTilemap.WorldToCell(Input.mousePosition);
TileBase tile = fieldsTilemap.GetTile(tilePos);```
but this doesnt get me the scriptable tile object I've created with the function I want to call. Will I need to make a function in the ``fieldsTilemap`` itself to do this?
wintry quarry
gray coral
#

how can i make my sure my z rotation is always aligned with y

finite mango
# wintry quarry ```cs if (tile is MyCustomTileClass myTile) { myTile.MyFunction(); }```

doesn't MyCustomTileClass myTile refer to a specific tile? Wouldn't I want to just check the type by doing tile is MyCustomTile? But either way I can't call the function on that specific tile object. If im comparing to myTile it would always call the function on that specific tile but I want it to call the functionn on the specific tile that I click on

gray coral
#

can i say something like this: transform.rotation.eulerAngles.z = transform.up *= -1;

night mural
gray coral
#

the z rotation make my player move into different direction

wintry quarry
# finite mango doesn't ``MyCustomTileClass myTile`` refer to a specific tile? Wouldn't I want t...

doesn't MyCustomTileClass myTile refer to a specific tile?
Yes.

Wouldn't I want to just check the type by doing tile is MyCustomTile
That's what my code example does, yes.

I can't call the function on that specific tile object. If im comparing to myTile it would always call the function on that specific tile but I want it to call the functionn on the specific tile that I click on
I presumed from your descriptioni that tile is the specific tile you clicked on.

gray coral
#

if i keep it on 0

wintry quarry
#

it's just much simpler and less code

finite mango
#

oh I see. yeah I was misunderstanding it. Thanks for explaining that, I've got it working now

finite mango
rich adder
polar acorn
#

Also transform.up is based off of your current rotation

obsidian mesa
#

Hello, a question, if I have an error in my game that I am developing, which channel should I go to to see if someone can help me?

gray coral
#

when z rotation is frozen

#

even when iam faced towards a way with y, z rotation makes it move up

sterile radish
finite mango
#

How can I make it so each tile (im using my own custom tile class) in a tilemap is a separate instance? right now when I update a value for one of the tiles, it changes for the customTileClass itself and so it changes for every tile in my scene.

prime goblet
#

:(

obsidian mesa
night mural
sterile radish
lone sable
#

Currently on the built version of my game, I'm getting a "Crash!!!" error. It happens when closing a Menu in my game, which, is fine, helps me narrow it down a bit I Suppose.

My question however is, is there any way to narrow it down easier?

slender nymph
eternal falconBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

sterile radish
#

hi, i'm using regex to find out whenever the dialogue in my game has "<w> </w" tags to make the text wavey. this is my code so far, but it doesn't seem to be making the text wavy? the text is just there with no additional wavy effects

https://hatebin.com/dhzjojqzmw

lone sable
#

Logs weren't much useful when I was looking at them sadly.

I was able to track down the cause however.

wintry quarry
sterile radish
wintry quarry
#

you're copying the vertices from the mesh, modifying your copy, and then letting it disappear in to the void

sterile radish
#

sorry, im a bit confused am i not using the vertices to update the geometry of the input text?

wintry quarry
#

and modifying your copy

#

that's all

#

you're not modifying the original Text object at all as far as I can tell

finite mango
charred fog
#

Could someone please explain to me how the onBecomeVisible function works and how to use it in a script?

sterile radish
slender nymph
nimble monolith
#

Something really weird here.
Sometimes my Visual Studio just stops showing errors and coloring words.
Reopening it fixes for a few minutes.
Is there anything I can do?

gray coral
#

the alignment with the sphere is just not good which causes problems for the next jump.

#

any suggestions

#

the red arrow is how it should be

steep rose
#

shoot a raycast down and use the normal of the surface as the jump direction, unless that does not work for 2D

slender nymph
#

or, assuming the pivot point is in the center for both objects, the direction is just (smallCirclePosition - bigCirclePosition).normalized

steep rose
#

that would work too

night mural
steep rose
#

you are calculating the direction between the 2 manually

slender nymph
gray coral
#

i showed images and video already

#

what i built

steep rose
#

he came in late, but these solutions provided should work

gray coral
#

on collision iam flipping the player ``` private void OnCollisionEnter2D(Collision2D collision)
{

   // Check if the player collided with a platform
   if (collision.gameObject.CompareTag("Platform"))
   {

       // Make the player a child of the platform
       transform.parent = collision.transform;
       isMovingUp = false; // Stop upward movement upon collision

       Debug.Log("Player has collided with a platform and is now attached.");

       // Flip the player by rotating 180 degrees on the y-axis
       transform.up *= -1;

   }

}```

finite mango
gray coral
#

but now the other problem occures, it has contiously has a weird z rotation

#

not centered with platform

steep rose
#

on the collision of an object you flip the character then use one of the solutions above to orientate it correctly

#

thats pretty much it

slender nymph
#

with my solution you wouldn't even need to rotate it. and since you make the small circle a child of the bigger circle you can just use its localPosition as the direction of the jump (just normalize it)

steep rose
#

yup his solution seems like the better option

gray coral
#

idk mate, its just not working. this is the final code ``` private void OnCollisionEnter2D(Collision2D collision)
{

 // Check if the player collided with a platform
 if (collision.gameObject.CompareTag("Platform"))
 {

     // Make the player a child of the platform
     transform.parent = collision.transform;
     isMovingUp = false; // Stop upward movement upon collision

     Debug.Log("Player has collided with a platform and is now attached.");

     

     // Calculate the direction from the platform's center to the player's position
     Vector2 platformPosition = collision.transform.position;
     Vector2 playerPosition = transform.position;
     Vector2 direction = (playerPosition - platformPosition).normalized;

     // Set the player's rotation to face outward based on the platform's position
     float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
     transform.rotation = Quaternion.Euler(0, 0, angle);

     transform.up *= -1;

 }

}

wintry quarry
#
         float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
         transform.rotation = Quaternion.Euler(0, 0, angle);

         transform.up *= -1;```
Both of these last two lines set the rotation
#

so that last flip is based on the direction after the rotation

gray coral
#

its again face to the different angle

slender nymph
#

but if you want to rotate it, then you will need to do so each frame

gray coral
#

player flips that alright

#

just the z slightly rotations is the problem

#

i just dont know.

slender nymph
#

why is it a problem. why do you need to rotate it?

finite mango
gray coral
#

@slender nymph

slender nymph
#

so you've ignored everything i've said up until now

#

because i told you how to solve that

gray coral
#

i tried to implement but, the same problems occurs

slender nymph
#

prove it, show your jump or whatever it is to show you've implemented it

gray coral
#

i kind of works now

#

lol

finite mango
#

how can I reference the object that the script is attatched to?

#

I have a script attatched to a TileMap and currently I have a serialized field to reference the tilemap. I tried using gameObject but then I cant call .setTile() on it.

gray coral
# finite mango I have a script attatched to a TileMap and currently I have a serialized field t...

for example: ```private CameraController cameraController; // Reference to the CameraController script

void Start()
{
// Store the original parent of the player (usually the root of the scene)
originalParent = transform.parent;

// Find the main camera and get the CameraController component attached to it
Camera mainCamera = Camera.main;
if (mainCamera != null)
{
    cameraController = mainCamera.GetComponent<CameraController>(); // Getting CameraController from the camera```
gray coral
finite mango
#

so originalParent is the object that this script is attatched to?

wintry quarry
#

so you'd need to get the Tilemap component if you want to do that

finite mango
#

oh i see

#

thanks

#

yep got it working now

nocturne kayak
#

What's the best way of moving rigidbody objects manually?

#

AddForce seems to yeld some results but feels weird to implement, rb.MovePosition straight up moves through walls if i apply enough force

wintry quarry
#

have you considered setting the body's velocity directly?

nocturne kayak
#

Setting the body's velocity directly might be the way to go but i don't know how much of a problem slowing down would be, right now i'm just exploring options

#

i was using AddForce beforehand and that seemed to yield interesting results although i had to fidget with it to get the code to slown the cube down

wintry quarry
#

you are making some motion that involves handles that's all I got

#

I don't understand what kind of collision behavior you are looking for

#

or how it should behave when the handles are pushed through obstacles

nocturne kayak
#

Right now i'm just trying to be able to drag a handle and it moves, i'm gonna deal with hidden handles as soon as i get to that bridge

wintry quarry
#

looks like you already have that

#

so it's time to move to the next problem

#

I mean are you looking for physical interaction or something? If not this would be very easy to do just with physics queries

#

i.e. Physics.BoxCast

sterile radish
#

how to use regex get rid of the <w> at the start of my dialogue line? my regex currently is Regex.Replace(textToType, @"<\/?w>", "");

wintry quarry
#

is it always there?

#

Why not just myText = myText.Substring("<w>".Length);

#

or myText = myText.TrimStart("<w>");

sterile radish
# wintry quarry is it always there?

no it's only there at certain times when i want it to be. it basically just acts like a bold <b> </b> tag but with a different effect to the text

naive pawn
#

i mean you wouldn't need a \ regardless

#

though that shouldn't matter thonk

zenith cypress
#

Seems to work fine 🤔

sterile radish
#

debug.logging it seems to output the correct text as well

wintry quarry
#

(my guess - you're probably ignoring the result of Regex.Replace)

naive pawn
#

yeah strings are immutable

#

you get a result, the original doesn't change

sterile radish
wintry quarry
#

but you haven't shown your code so we can't say for sure.

sterile radish
wintry quarry
#

what's this do and why are you passing in the raw textToType instead of displayText?

sterile radish
wintry quarry
#

what does CheckTag do

sterile radish
wintry quarry
#

seems like the string originalText parameter is completely unused

sterile radish
#

oh yeah thank you, i'm pretty sure i had forgotten to delete that from before

wintry quarry
#

anyway if the debug log prints it without the tag, then some other code must be addng the tag back

#

or this code is not running with the correct TMP_Text object or something along those line

sterile radish
#

probably the latter?

#

i can't think of anything in the code that could be adding the tags back

lusty stag
#

mb if i'm being stupid, i literally started scripting today, but i can't find how to check whether the player is touching the ground, i tried ray casting (which i looked up online) but it's only detecting that it's off the ground in a specific y coordinate above the ground and if the player goes above or below it, debug log still shown as grounded

#

this is in a 2d project btw

keen dew
#

You'll need to show the code

north scroll
#

hai im trying to use Unity's timeline to do a quick intro scene, first time using it. I have an animation clip added that moves a GO from one spot to another, and Im trying to implement a sound effect to follow but I can't hear anything. The .wav does play a sound tho. Also the game is in VR, not sure if that changes anything although even when the game isnt playing and im in the editor, the sound doesnt play. I tried attaching the audio to an empty GO and attaching it to the (NONE, audio source) track of the screenshot but that also didnt work. Any tips ?

pseudo lichen
#

Is instantiate an expensive function to call? I’d like to make an arena of small cubes and would like to know if it’s a good or bad idea to do it with a loop

charred spoke
north scroll
# lusty stag mb if i'm being stupid, i literally started scripting today, but i can't find ho...

i think the simplest way is to use oncollisionenter() : https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html

//give all ur ground objects a tag
//in the oncollisionenter, check if the tag of the rigidbody's GO has that tag u specified
//if true, toggle a isGrounded bool

there's also an oncollisionexit that u could toggle that bool once they arent "grounded" anymore: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionExit.html

lusty stag
#

ahhh alr tyty

pseudo lichen
thin shale
#

Title: Item Prefab becomes invisible after build to mobile,

hi everyone's i'm a beginner here's and currently are struggling with a bug, can you tell me how to resolve it?

full disclosure, i've juggle throuh some of the code and asset, also i'm using Unity 6, and the game can be found at play store and app store named, "Beat This Dummy 3D"

First Problem invisible item - When i use Unity everything's went smooth, cosmetics of mesh are being renderer perfectly, but when i tried it after downloading the game from app/play store the item simply become's invisible. any ideas what cause this?

The current approach i'm doing is, move the files to Assets/Resources, so at loading screen is taking place, all the files are being loaded at the start of the game, so player can avoid this bug, will it resolve this porblem? i'm still waiting for the review of app store this is killing me

please any input will be a big help for me as this bug been torturing my in this past week 💀

i've attach some screenshoot so you guys can emphasis more on the problem.

chilly halo
#

Does anyone know how to set this? When I right click the executable, it doesn't seem to show the right settings

steady helm
#

Hey! I don't suppose anyone could give me some ideas on how to go about making this.

Billy!
Billy is a fun, physics-based robot that walks around using inverse kinematics for his legs. He can be thrown, knocked over, and generally messed around with [see the video below of Billy for an example].

Billy is from a game on Steam called Karlson, and for a while, I’ve really enjoyed re-watching this video of him. I like it so much that I’ve been trying to make my own version of Billy! The only issue is that physics are hard and so is inverse kinematics 😭.

I’ve been making a lot of progress, but when it comes to actually having Billy react to different situations and be pushed around like he is in Karlson, I’m getting nowhere.

[See the second video for my progress (it’s not that great yet)

for the inverse kinematics im using a mix of Animation rigging and a script called IKFootSolver mines a bit modified but is functionally the same but im 200% sure that is far from what billy uses i can tell this because well mines janky and billy isn't janky

now as for my question after all that yap
how exactly can i go about in both improving the kinematics and improving well billy so i can knock him over and have him actually react to it (by react i mean just let me call a void or something when he falls idk)

chilly halo
chilly halo
nimble monolith
#

Hi, I can't find the option to create a new ScriptableObject!
Any help?

eager spindle
#

unless you're doing this with visual scripting?

swift sedge
#

I don't know why unity doesn't have a ScriptableObject template

eternal needle
#

because it takes 3 seconds to make it from the already existing option to make a new script

eternal needle
# steady helm Hey! I don't suppose anyone could give me some ideas on how to go about making t...

you'd have to show more of how you're actually moving the robot and the player. that first video looks like the robot is a rigidbody and whoever made that has their own rb controller script for it so it hovers. then on collision or whatever logic happens with the dragging, it loses control and can freefall. the main difference id say between the 2 videos is that yours doesnt have some timer for how long billy should be in a ragdoll state for.

#

also when asking questions, try not to include a lot of backstory/irrelevant details. its just easier to help when all the necessary details are clear

swift sedge
#

Billy appears to have both of his legs synchronised with a small offset, and looks to be pushing himself along via a gentle force

#

which allows for smooth movement

thin shale
swift sedge
steady helm
# eternal needle you'd have to show more of how you're actually moving the robot and the player. ...

well im using a fixed update and some simple Vector3 position moveing code at the moment

        float distanceToPlayer = Vector3.Distance(transform.position, player.position);
        if (distanceToPlayer > stoppingDistance)
        {
            Vector3 direction = (player.position - transform.position).normalized;
            transform.position += direction * moveSpeed * Time.deltaTime;
        }

        Vector3 targetDirection = (player.position - transform.position).normalized;
        Quaternion lookRotation = Quaternion.LookRotation(targetDirection);
        transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 5f);

billy finds the straight path from Billys current position to the players position by subtracting one position from the other. The .normalized part makes sure that the direction is a unit vector (length of 1) so Billy just heads in the right direction without speeding up over distance.

the rotation bs is to rotate in the direction of the player

swift sedge
steady helm
#

i hate unity physics so much 😭 (its because i have a clear skill issue in this department)

swift sedge
#

I created a working procedurally animated 6 legged character yesterday, but it isn't physics based

steady helm
#

😭

#

rip

#

if it was physics based that would be specifically epic for me to hear but otherwise it still sounds cool 🤣

#

welp billy is fine for now

#

just wish it was as good as dani's (the guy who made billy)

swift sedge
#

procedural animation takes time

eternal needle
# steady helm well im using a fixed update and some simple Vector3 position moveing code at th...

well then you should really start working on converting this to RB stuff if you want unity physics. im not 100% sure that the 1st video you shown is a rigidbody (since this is literally not possible to know) but it sure looks like how one would move.
it looks like they have a moving/ragdoll mode, where they hover while moving. the arms most likely dont have colliders on them and are just visual to give the impression its moving, so its pretty unrelated to the main movement logic

steady helm
#

but ive also been told alot its just inverse kinematics witch would make sense because ive heard the maker say that before im sure

frank zodiac
#

I dont get the difference between the observer pattern and command pattern.
Observer pattern: singleton (preferably) class that has a bunch of signals and other classes subscribe to those events, then the signal gets invoked whenever you want
Command pattern: singleton (preferably) class that has a bunch of commands and other classes make instances of those commands, then call the command's methods whenever you want
Could someone enlighten me please?

eternal needle
steady helm
eternal needle
#

which is entirely the purpose of IK

steady helm
#

for some parts of its movement anyway

#

🤣 yeah lol

#

sorry if im being rather stupid on the topic (ive been awake for more than 25 hours)

steady helm
#

lol

swift sedge
#

just go to sleep. I'm no doctor... but that sounds bad

steady helm
#

i would but uhm

#

its 10 am so now i gotta do the 24h challange to fix that sleep schedule

#

okay

#

i need a new keyboard i cant type on this one

#

(blaming my keyboard for a skill issue is a top 1 gamer move)

lunar oracle
#

wsp i have problem with URP pipe

#

i have like file of that but i cant import it to graphics in project settings

quaint thicket
#

If I wanted to have a constant line going from my GameObject to another GameObject, and it automatically moves itself when either GameObjects change positions, what would I use?

languid spire
quaint thicket
#

Alright, Mr. AI said the same thing.

hexed terrace
#

this is a code channel, delete and ask about animations in the #🏃┃animation channel

scarlet shell
#

If i have multiple OnEnable for my inputsystem how do I know which gets called first? I'm trying to set the inputsystem = new() in one script but then its trying to load an input before that which causes errors in another script

dire shadow
#

Hey mates, anybody experienced with unityTests?

I'm having an issue importing my scripts, I can't reference them in my tests, is there any issue with the proyect structure?

I can load my prefab but can't reference my script. Also, I tried disabling from the UI one of the scripts my prefab has but the test still executed it, any ideas about that?

hexed terrace
scarlet shell
hexed terrace
#

If it makes sense to do so, control the enabling of the objects so that they get enabled in the correct order

naive pawn
#

there is LateUpdate

scarlet shell
#

It's fine I'll just move all my action calls to Start() and keep the creation of the input system in OnEnable() thanks for help

runic lance
dire shadow
runic lance
#

I think you used to be able to run tests that were in the Tests or Editor/Tests folder a while ago without asmdefs, but I'm not sure if that's still supported

dire shadow
#

Thanks 🙂

#

Couple of q more:

  • It feels to me although I have disabled manually a script, that it still runs, I can programatically disable it on test, but it really feels akward that this happens.
  • The test with this component actually fails by a log error message, why is this the case? Usually in other languages logs really don't matter to your tests, just exceptions.
runic lance
dire shadow
# runic lance the log error is unexpected indeed, you can disable this behavior for a test cas...

Can you configure the log stuff globally?

So, I have a prefab with a bunch of scripts, see image. I have manually disabled the Spawn manager script (I unchecked the checkbox on the left of the name).
But my tests, do seem to execute it's code, at least the awake method, is this expected?

Because, as my code subscribes to an event:

private void Awake()
{
EventDispatcher.Subscribe(EventType.FloorReady, OnFloorReady);
_floorManager = gameObject.GetComponent<FloorManager>();
}

Chatgpt tells me that:

In Unity, the Awake method will still run when instantiating a prefab, even if the script component is initially disabled in the prefab. This can happen because Unity initializes the entire object hierarchy during instantiation, which includes calling Awake on all components regardless of their enabled state.

if this is the case, it feels like I'm doing something wrong tbh

runic lance
dire shadow
# runic lance I don't think you can do it globally, but you can have a method with the [SetUp]...

So would you say this assertion is true?

I thot that when you disabled something from the inspector, it would not run the awake method:

In Unity, the Awake method will still run when instantiating a prefab, even if the script component is initially disabled in the prefab. This can happen because Unity initializes the entire object hierarchy during instantiation, which includes calling Awake on all components regardless of their enabled state.

runic lance
#

the docs say something similar indeed, but you can easily test this
the behavior should be the same in play mode or test mode though

languid spire
past spindle
#

boxBottom.GetComponentInParent<BoxController>().moveable = false;
Anybody see why this line of code wouldn't change the variable "moveable" to false in my Box Controller script?

keen dew
#

Multiple BoxControllers in the tree?

past spindle
#

no, not as far as I can tell

keen dew
#
BoxController controller = boxBottom.GetComponentInParent<BoxController>();
controller.moveable = false;
Debug.Log(controller.name + " moveable changed to " + controller.moveable);

start with this

past spindle
languid spire
past spindle
languid spire
rocky gulch
#

what do i do here

#

i am lost

languid spire
past spindle
languid spire
keen dew
#

It's also possible that some other code then immediately changes the value back to true. You can't see it just by looking at the checkbox.

past spindle
past spindle
languid spire
#

but it does not tell you EXACTLY which objects it is working on

past spindle
past spindle
languid spire
#

and you still have not learned to debug properly

past spindle
languid spire
#

yes, but also to determine if the objects it is working on are the objects you think they are.
A C# script can have many instances, each the same, if you do not KNOW which instance you are talking to then you will not get the outcome you expect

past spindle
languid spire
#

you do you but in my book 'fairly certain' is not certain enough

past spindle
polar acorn
#

If that line of code is running, it's setting that value on that specific object to false.

So, either that line isn't running, that object isn't the one you think it is, or something else is changing it back

burnt vapor
#

Also, this channel has had a ton of people that assume everything around the problem works fine. It rarely is.

past spindle
languid spire
#

I was also, just trying to give a general lesson on how to debug because, tbh, you didn't seem to have much of a clue

final kestrel
#

Hey all. In your games you're working on, do you reload scenes through scene manager? Or do you simply reset all the data to the beginning instead of reloading scene? Maybe like put a fake load screen so player does not see whats happening and thinks its reloading etc? I am currently having trouble reloading my scene.

olive lintel
#

hey guys, sorry for the silly question but I'm completely stuck on this. I'm trying to build a system for mesh culling, but I'm having an issue with arrays and lists while generating the "map" of what gets culled when.
https://hatebin.com/fcpjousaeg

the premise of the system is simple. I have 2 structs that come in to play during runtime, a simple "drawslot" struct, which is just a mesh, a material and an array of matrix4x4s that the system uses for GPU instancing, and another "drawSlotIndexMatrix" struct, which just contains 4 matrix4x4s (for each cardinal direction each mesh might need to be rotated in), and an array of integers, representing the indexs of the "drawslots" it will add these matrix4x4s to when the camera will be viewing the building from said direction.

the issues however, comes while building this "map" of matrices and drawSlots.

you have 4 wall prefabs, each represented by a struct called a "buildSlot". each "floorSlot" contains 4 of these, and the system simply loops over all the wall slots in each floor slot, building a "map" of matrix4x4s and integers to add to an array of matrix4x4s which can be drawn by the GPU as needed.

however, there is an issue. while looping over the 4 walls, the script for some reason beyond my comprehension, as it loops over the 4 walls, it adds the mesh indexs to ALL 4 DRAW INDEXS, and I have no idea why.

am I missing something? or is this just a quirk with arrays and lists I don't understand?

as can be seen in the first image provided, the system should be working (I'm currently only using a simple wall data, with 1 front and 1 back mesh), but in the second image one can see that the script is adding the int "startIndex" to ALL of the elements in the buildMatrices array, causing it to be added to the final "front draw indexs" element 4 times (one for each wall)

#

as can be seen in the video provided, the system is adding matrix4x4s to the drawslots correctly, its just adding all the draw indexs to the drawSlotIndexMatrices as I loop over them.

#

any help is greatly appreciated!

past spindle
past spindle
final kestrel
#

It gets rid of all the additively loaded scenes though.

past spindle
#

Oh, that's beyond me. I've not done a whole lot with scenes yet besides title screens and such.

final kestrel
#

Yeah like im trying to keep my init scene while reloading the currently active scene additively.

past spindle
#

I don't need to have "Is Trigger" checked to use OnCollisionEnter, do I?

wintry quarry
#

OnCOllisionEnter only works with non-trigger colliders

past spindle
#

Thats what I thought

karmic isle
#

Hey I need a little help, Im using the new coding software and ive followed the tutorial to install intellisense but it still seems to not be working

keen dew
#

What new coding software?

karmic isle
#

no, visual studio code.

#

sorry

#

i guess it isnt really new

keen dew
#

!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

wintry quarry
primal jewel
past spindle
#

This is a little embarrassing but I'm having issues with a simple collision. The script seems fine, is saved and assigned in inspector. Neither object has "Is Trigger" checked. The object tagged with "Bomb" has the rigidBody. But the objects are still passing through each other and the Debug.Log is not being triggered. Anybody have any ideas?

void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Bomb"))
{
Debug.Log("Collision detected.");
}
}

wintry quarry
#

if there is no collision, OnCollisionEnter won't run

#

show the inspectors for the two objects.

past spindle
#

You want a screen cap?

wintry quarry
#

yes

fossil drum
past spindle
#

This is for the "Bomb"

#

This is one of the objects with the script. Each wall of that box you see has the script assigned to it

wintry quarry
past spindle
hexed terrace
#

It's been a while - but the OnCollision events only get sent to the gameobjects with the RB on, don't they?

wintry quarry
#

If the box is MOVING it needs a Rigidbody

hexed terrace
#

Looks like the OnCollision is on the wall, without an RB

past spindle
wintry quarry
#

and yeah the script with OnCollisionEnter must go on the parent object with the Rigidbody

#

not the child with the collider

#

you should set the collision detection on both moving objects to continuous as well

karmic isle
#

Sorry thanks for the help before but one more issue, Im trying to make it to where when my player jumps its set to "true" while they're still in the air; but once they land on the ground its set to "false". I already have my ground's tag as "ground" but it still wont set the "isjumping" to false. any help?

keen dew
#

Also if the player doesn't have a rigidbody it suggests that it's not moving using physics

wintry quarry
past spindle
hexed terrace
wintry quarry
#

or things get wonky

keen dew
#

and you need to use physics to move for collisions to work properly

past spindle
wintry quarry
#

did you put it outside the if statement?

#

if you did then you haven't satisfied the requirements for OCE2D to run

karmic isle
#

lol yeah it is, and yes I did

wintry quarry
#

Cna you show the inspectors of the two objects that are colliding?

#

or meant to be colliding

keen dew
karmic isle
#

will do, gimme a sec

karmic isle
#

heres the play area if you need it, though before I hit play I have the box in the air so it can land on the ground, then I get to testing

wintry quarry
#

And can you show a screenshot of your console window too

queen adder
#
    public void Move(InputAction.CallbackContext context)
    {
        horizontalMovement = context.ReadValue<Vector2>().x;
    }
#

Why is Vector 2 wrong in this case?

wintry quarry
#

And what are you trying to accomplish?

queen adder
#

the error in VS Code haha

wintry quarry
#

What error

wintry quarry
#

You know we can't see your VSCode right?

queen adder
wintry quarry
#

just share the error message

#

You should get used to actually reading error messages

queen adder
wintry quarry
# queen adder

You did using System.Numerics;
you need to delete that

queen adder
#

which class should be responsible for updating text of UI of resources like Stone, gold, wood etc ?

I have a class called Resources, that tracks the amount of resources. should i update the UI from it?

wintry quarry
queen adder
wintry quarry
#

basically a script on the UI that listens for events from the game's data model.

queen adder
#

i see i see

queen adder
steep rose
# karmic isle

do you have anything in another script overriding the isjumping boolean?

karmic isle
#

oh what the heck

broken gazelle
#

hey yall .. i jus finished learning simple physics n player movemnts where or what should i start learning 2nd?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

karmic isle
#

I have like five different coding scripts all called the same thing

broken gazelle
karmic isle
#

im gonna delete all of them and just copypaste my script and get back to you

steep rose
#

it should have given you an error if they are the same name and have the exact same variables

karmic isle
#

it didnt for some reason...

umbral bough
#

Hi, is it possible to keep updating the mouse position even if the window is not focused?
I couldn't find much on this because it's a really odd thing to do but I need it in order to avoid executing a shell script constantly which would be inefficient if I am not mistaken.

olive lintel
umbral bough
#

I am making a background music visualizer which means that the window is not focused and therefore, I am not getting mouse position updates

rich adder
umbral bough
#

I already am, cursor is not updating the position

languid spire
#

Are we talking about the Windows OS here?

karmic isle
umbral bough
languid spire
grave bluff
#

I recently heard about "bootstrapping" in unity and I've been skimming around some youtube videos trying to find out how it works

#

what I'm not quite getting is who has the responsibility of actually getting data from the bootstrap scene into objects in the scene

hexed terrace
#

this aint a beginner question

grave bluff
#

at the moment I have a small project with a single scene that has some singletons and I'd like to have a main menu scene where the player can input some numbers and those numbers are shot over to the actual game scene where it gets thrown into a singleton as some init values

#

and I'm curious what best practices are for this

#

actually I think I'm misunderstanding what a bootstrapper is supposed to do lol

past spindle
#

!code

eternal falconBOT
wintry quarry
past spindle
#

https://hatebin.com/suhvbejocj
Could somebody look at this code? I keep getting: Object Reference not set to an instance of an object but I don't see why this wouldn't work.

languid spire
#

on which line

past spindle
#

32

slender nymph
languid spire
#

then sphere is null

polar acorn
languid spire
#

if it was box it would fail on the line before

polar acorn
#

Ah, yes, good point

#

Then it's definitely sphere. The Find is failing.

languid spire
#

@past spindle See what I meant about learning how to debug? It took us literally 5 seconds to see the problem

past spindle
red cedar
#

Does anyone know how to add animation when key get press?

past spindle
languid spire
slender nymph
#

you don't have an object in your scene named Sphere at the time this code runs

red cedar
polar acorn
main karma
#

Hey guys I have this code snippet:

 cam.transform.rotation = Quaternion.LookRotation(newCameraDirection, PlayerCam.transform.up);

This works well if the camera and player are facing the same direction, but when they are opposite directions from one another the transform should be mirrored on the other side of the Vector3.up so that they look synced (see the image attached).
Basically I need the mirrored PlayerCam.transform.up relative to vector 3.up

wintry quarry
main karma
#

Basically my player does a 180* turn when I invert gravity so it faces upside down

#

I have portals like in portal 2

#

the illusion used to break b4 when turning 180* because I was using Vector3.up as the up direction for the Quaternion.LookRotation

#

I changed that to PlayerCam.transform.up

#

but that still breaks the illusion of portals that mirror one another (opposite directions) as it appears in the portal image that the portal flips opposite to the PlayerCam

#

So I need to mirror the PlayerCam.transform.up so that it's going the opposite way when portals are mirrored so the illusion doesn't break

#

I can deal with vectors but not quaternions or rotations, it's beyond me

#

The questions boils down to how do I reflect a vector3 across a normal/axis

wintry quarry
#

it's highly possible I have the order of that diff calculation backwards

queen wren
#

Anybody know nothing about RenderTexuture and Unity 6?
looks like the texuture didn't get updated unless I change any of the camera parameters like Clipping plane (far/near) ¯_(ツ)_/¯

queen wren
#

Nevermind, was messing up the scene and 3 cameras were writing on the same texture 🫣😅

main karma
#

now it works

sterile radish
#

the original text in my game was "<w>Ayo...</w>" . I made custom "<w> </w>" tags and used regex to detect when they popped up in my text. after my regex finds a match, i apply a wave effect to each character of the matched text. the end result of this is supposed to turn the original "<w>Ayo...</w> text into a wavy "Ayo..." text. however my screenshot shows what it displays in game. the wave effect works perfectly fine but the text is all skewed.

(after further debugging it seems like my code uses the displayText for actually displaying it correctly but another script perhaps interferes with it and makes it completely ignore my regex and adds back in the "<w>"

here is my typing script
https://hatebin.com/paqdnbyotw

polar acorn
#

Escaping the slash does what you expect it to.

#

C# string might need you to escape the escape character, so if it still doesn't work, try <\\/?w>

sterile radish
polar acorn
grand badger
#

Is there a AI for Unity yet that automatically creates UI? Even basic? Based on some Model/ViewModel or whatever.

polar acorn
#

You set textLabel.text before the loop, but nothing in the loop is preventing something else from setting that. It'll just continue to loop over whatever text value that text element has, but you're using the length of the parsed text, which is why it's cutting off early

#

So, something outside of this loop is setting textLabel.text to the unparsed string, after this coroutine has started

polar acorn
sterile radish
polar acorn
#

I suppose

sterile radish
polar acorn
#

So, StepThroughDialogue is setting the text each frame that the coroutine is running. If both coroutines are running, this one would "win" since it sets the text most recently

sterile radish
#

right, and because this one is "winning", could it be line 9 that's messing up what text is being shown and what's not?

polar acorn
#

Since the typewriter effect just changes how many characters of the textLabel are visible, whatever the most recent change to textLabel is will be the value of that text box. You'll want to find anywhere that you change that value, and see which ones happen in between textLabel.text = displayText; and textLabel.maxVisibleCharacters = i + 1; in the typewriter coroutine

sterile radish
#

sorry i don't understand your second sentence, could you explain further?

polar acorn
#

Step 1: TypeText sets the value of textLabel.text to displayText. As your log shows, this is the correct string value.
Step 2: Then, something else changes the value of textLabel.text, somewhere.
Step 3: TypeText now reaches the part where it changes textLabel.maxVisibleCharacters, which updates the text in the UI element. This is changing the visible characters of the new value that was changed to in step 2.

So, look at anywhere you change that text, and find out what is setting it in between steps 1 and 3

sterile radish
polar acorn
sterile radish
#

yes it does

polar acorn
#

So that would be why the text now has tags in it

#

because you're setting it to a string that has the tags in it

grand badger
#

asking whether AI is available

polar acorn
#

Yes and I'm telling you how to do it yourself

sterile radish
grand badger
#

how is that not totally irrelevant?

polar acorn
sterile radish
polar acorn
grand badger
#

something other than my generative AI for Unity? 😆

#

anyway the reason I'm asking is because I hadn't had the chance to mess with Muse and other AI assets in Unity, so curious on what the SotA is atm

sterile radish
grand badger
#

I'm tempted to ping the mods to give you a warning.. hope you're not being an arse to newcomers too

polar acorn
#

You should probably have one singular place responsible for changing the text, then you can let other things read the value of the textLabel, and know that it only changes in the one place

polar acorn
sterile radish
grand badger
#

or even this if you're going for nesting coroutine behaviours:

public IEnumerator Write(string text);

Then you could await it with yield return StartCoroutine(typeWriter.Write(dialogueText));

polar acorn
#

I would not recommend using so many coroutines. Use components with Update functions instead.

#

Probably the only coroutine you'd need is the RunTypingEffect, and it should just handle slowly increasing the maxVisibleCharacters over time, and should be able to report when it's "done" for other scripts to deal with

#

the parsing and displaying can be done elsewhere

sterile radish
#

okay, i think for now with my coding ability as well, i'll just remove the text effects part of my dialogue system and let future me expand upon that using my future knowledge along with the points you've stated, thank you guys for the help!

grand badger
hasty dragon
#

how do i set a new parent to a game object

undone pier
#

can someone check out why this scriptable object keep resetting every time unity reload? other scriptable object is fine but this one has a custom editor and it wont save
Edit: solved it

undone pier
#

ok thanks

flat tide
#

Hello! sorry im having a issue with the recent change to Unity 6 was using the version before and the controllers that im using for my 2.5D game no longer works do to a change in the rigidbody.velocity, it wants me to use linear velocity but it doesnt work, here its the code if anyone could help me

#

It was working in the version of unity (2022.3.22f1)

polar acorn
hasty dragon
#

how do i make its scale independant

polar acorn
hasty dragon
polar acorn
#

A child object's transform is based off of its parents.

polar acorn
hasty dragon
#

im trying to do an item pickup with a tutorial

#

i meant without a tutorial

#

i feel like this is dumb

flat tide
lethal meadow
#

then you can sell it for a bazillion dollars

grand badger
steep rose
#

why would you want AI to create UI for you?

grand badger
#

well, for starters, it's my least favourite part in development

eternal needle
#

This is a coding channel

grand badger
#

also, could iterate a lot and create bunch of layouts to choose from rather than working in figma or photoshop or something

steep rose
#

so a template is what you are looking for

#

not AI

grand badger
#

no.

steep rose
#

<@&502884371011731486> I believe you know what to do

#

that was insanely quick, good job

rotund bronze
#

Im using unity 6 behavior Graph, is it possible to release an event from C# side for the Wait For Message node to receive? if yes how could I do it?

amber glen
#

Im trying to create a turn based rpg battle system like in Final Fantasy. I want it so that the damage that the player deals is shown above the targeted enemy. So if the player attacks with a damage of 10, it will create a text and that text will show the damage done. This is what I got so far.

 {
     player.StartAttackAnimation();
     int damage = player.attackPower;
     CreateDamageText(damage, enemy.transform.position); // Pass damage and the targeted enemy to createDamageText()
     enemy.TakeDamage(damage); 
     EndTurnPlayer(player);
 }

private void CreateDamageText(int damage, Vector3 enemyPosition)
{```
It creates the text field and everything is fine, but the text is not visable in the gameview. Its like in another position? Im new to Unity so I dont really understand whats happening. Was wondering if anyone could help me. Thanks!
#
{
    // Instantiate the damage text prefab
    GameObject damageTextObject = Instantiate(damageTextPrefab, canvas.transform);
    
   
    TextMeshProUGUI damageText = damageTextObject.GetComponent<TextMeshProUGUI>();
    damageText.text = damage.ToString();
    damageText.fontSize = 0.5f;
    
   
    Vector3 positionAboveEnemy = enemyPosition + new Vector3(0, 1, 0); 
    damageTextObject.transform.position = positionAboveEnemy;

  
    StartCoroutine(DamageTextAnimation(damageTextObject));
}

// Coroutine to animate and destroy damage text
private IEnumerator DamageTextAnimation(GameObject damageTextObject)
{
    float duration = 1f; // Duration of the animation
    float elapsed = 0f;

    Vector3 originalPosition = damageTextObject.transform.position;

    while (elapsed < duration)
    {
        elapsed += Time.deltaTime;
        damageTextObject.transform.position = originalPosition + new Vector3(0, elapsed * 2, 0); 
        Color color = damageTextObject.GetComponent<TextMeshProUGUI>().color;
        color.a = Mathf.Lerp(1, 0, elapsed / duration); // Fade out
        damageTextObject.GetComponent<TextMeshProUGUI>().color = color;

        yield return null;
    }

    Destroy(damageTextObject); 
}```
wintry quarry
#

You're most likely using a screen space canvas

#

so that's a completely different coordinate system

#

using enemy.transform.position as the position is not going to work

amber glen
wintry quarry
#

One option is to use world space UI instead (canvas render mode - world space)

amber glen
#

Oh I see

#

Just like this?

#

thanks for the help!

wintry quarry
#

you probably don't want ALL your UI to be world space

#

jsut the damage text or whatever

#

switching that is going to pretty much immediately break all the other UI in that canvas

amber glen
#

Yeah it messes up all the panels and stuff

#

Is there a way to just make the damage text world space?

#

Would it require another canvas

wintry quarry
#

yes you make another canvas just for that

sour nimbus
#

How can I make it so that when the character jumps it jumps normally and not bounces? because, for example, if I press several times or hold down, it doesn't always jump the same height and it seems as if it were bouncing.

wintry quarry
sour nimbus
wintry quarry
#

!code

eternal falconBOT
wintry quarry
#

For sharing code in the future, it's better to share the full script as such^

amber glen
#

I created another canvas, and set the render mode to world view and the battle text is a child of that canvas when it gets created. But its creating it off screen? I coded it so it should create it above the enemy position that the player is attacking.

#

10 is the damage the player is doing

wintry quarry
#

pay attention to the position and size of your canvas

#

and the position of your text object

amber glen
#

I set the BattleTextCanvas to the size of the scene. So it covers the whole scene. Is that wrong?

wintry quarry
#

I would most likely just make a small canvas containing only the text

#

and move the canvas around

#

Or just not use UI at all

#

just use TextMeshPro

#

as in - not the UI version

bronze estuary
#

Which IDE is best to use? VS Code, VStudio, Rider

vocal orchid
steep rose
# bronze estuary Which IDE is best to use? VS Code, VStudio, Rider

personal preference really, I heard rider is great but I have no opinion since I do not use it
VSC is lightweight and does require extensions to be installed first before use with unity (basically a glorified text editor)
VS is great overall IDE but is not lightweight and comes with most bells and whistles that and ide provides

steep rose
wintry quarry
vocal orchid
#

Isn't the trigger supposed to allow traversing objects?

steep rose
#

okay so you have a collider stopping your character from moving when you look up im guessing

amber glen
#

vut

steep rose
#

your code could also be the culprit as well

vocal orchid
#

Loocker

#

Entrance_Loocker

steep rose
#

we don't need to see the lockers inspector, just the "looker"s inspector

vocal orchid
#
void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Object_grab")
        {
            grab_message.SetActive(true);
            player.GetComponent<player_controller>().can_grab = true;
        }
        if (other.gameObject.tag == "Entrance_loocker")
        {
            player.GetComponent<player_controller>().can_hide = true;
            hide_message.SetActive(true);
        }
    }

    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag == "Entrance_loocker")
        {
            if (player.GetComponent<player_controller>().hide == true)
            {
                hide_message.SetActive(false);
                exit_message.SetActive(true);
            }
            else
            {
                hide_message.SetActive(true);
                exit_message.SetActive(false);
            }
        }
    }

    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Object_grab")
        {
            grab_message.SetActive(false);
            player.GetComponent<player_controller>().can_grab = false;
        }
        if (other.gameObject.tag == "Entrance_loocker")
        {
            hide_message.SetActive(false);
            exit_message.SetActive(false);
            player.GetComponent<player_controller>().can_hide = false;
        }
    }
steep rose
eternal falconBOT
vocal orchid
steep rose
#

correct

#

we need that script in a paste site

vocal orchid
#
void Update()
    {
        if (!hide)
        {
            moveInput = playerInput.actions["Move"].ReadValue<Vector2>();
            if (playerInput.actions["Run"].IsPressed()) //!crounch
            {
                speedCurrent = speedRun;
            }
            else
            {
                speedCurrent = speedWalk;
            }
            movement.x = moveInput.x;
            movement.z = moveInput.y;
            movement = cameraTransform.forward * movement.z + cameraTransform.right * movement.x;
            movement.Normalize();
            // if (crounch)
            // {
            //     transform.localScale = new Vector3(1, 0.6f, 1);
            // }
            // else
            // {
            //     transform.localScale = new Vector3(1, 1, 1);
            // }
        }
    }
steep rose
#

okay so you are using the camera's direction, use the players transform instead

#

you can also add an orientation object under your players hierarchy as well and use that transform

steep rose
# vocal orchid How¿

add an empty object as a child facing in the forward direction of your player and reference it in your movement script then use its transform

vocal orchid
#

I have it

steep rose
#

is that the orientation object? that does not seem like it is

amber glen
#

How do you set this 3D text so that its in front of everything else?

#

Right now, it goes behind everything

rich adder
white oak
#

I am trying to have the player pick up boxes and there will be 10 of them. But I dont want them to be able to pick up more than 1 box at a time but I cant find anything on how to do this. This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BoxPickup : MonoBehaviour
{

public GameObject PickupPrompt;
public GameObject BoxOnPlayer;
// Start is called before the first frame update
void Start()
{
    BoxOnPlayer.SetActive(false);
    PickupPrompt.SetActive(false);
}


private void OnTriggerStay(Collider other)
{
    if (other.gameObject.tag == "Player")
    {

        PickupPrompt.SetActive(true);

        if (Input.GetKey(KeyCode.E))
        {
            this.gameObject.SetActive(false);
            BoxOnPlayer.SetActive(true);
            PickupPrompt.SetActive(false);
        }
    }
}


private void OnTriggerExit(Collider other)
{
   PickupPrompt.SetActive(false);
}

}

eternal falconBOT
white oak
north kiln
#

You shouldn't test for input in physics callbacks

#

Also you should use CompareTag, not equality to compare tags

#

To answer your question, just cache a reference to the box you're carrying and set the reference to null when you drop it

white oak
#

I am trying to have the player pick up boxes and there will be 10 of them. But I dont want them to be able to pick up more than 1 box at a time but I cant find anything on how to do this. https://hatebin.com/tjplqdrkbf

north kiln
#

On pickup, check that the reference is null to confirm you're not carrying anything

white oak
#

how do i use this code thingy im so confused

#

to put it like everyone elses

steep rose
vocal orchid
#

Cinemachine the player camera view's

toxic yacht
steep rose
# vocal orchid Cinemachine the player camera view's

that is not what I said to do, you have to make a new empty and name it "orientation", then place this new object right where the center of your player is, then reference this object in your movement script and use its transform

white oak
north kiln
white oak
finite mango
#

how can I see what index it attempted to call when this exceptionn was thrownn?

north kiln
#

Use the debugger and have it break on exceptions

white oak
ivory bobcat
north kiln
waxen adder
#

I'm running into a problem when toying with camera controls.

I'm trying to make it so pressing Q and E makes it so the camera rotates about a point at set angles. A lot like what xcom did.

Issue is, in xcom, when a rotation occurs, it doesn't seem to change what is at the center of the screen (barring when the elevation of the camera is changed, which makes me curious).

In my current implementation, it unfortunately does change what is at the center of the screen. If anyone has any advice, let me know! If you want to look at the class involved, here it is: https://pastebin.com/Q5uSGmc1

finite mango
# ivory bobcat Seeing the code would probably allow folks to guess, if you're looking for someo...
    private int[,] fieldsCoords = new int[1, 4] {
        // format: {x1, x2, y1, y2} bottom left -> top right
        {-20, -12, 4, 12},
        //{10, 20, -30, -20},
    };

    void Start()
    {
        for(int i = 0; i < fieldsCoords.Length; i++) { // loop through each field
            for(int j = fieldsCoords[i,0]; j < fieldsCoords[i,1]; j++) {
                for(int k = fieldsCoords[i,2]; k < fieldsCoords[i,3]; k++) {
                    Debug.Log("(" + i + ", " + j + ", " + k + ")");
                    var tile = Instantiate(fieldTile);
                    fieldTilemap.SetTile(new Vector3Int(j, k, 0), tile);
                }
            }
        }
    }

the last debug.log before an exception is thrownn is (0, -13, 11) which refers to the (i, j, k) values

#

im trying to make it easier to generate the tiles by having a 2d array of them at the top instead of hard coding the numbers into Start()

ivory bobcat
#

fieldsCoords[i,1] returns an element (value) and not the length of the collection. Will this value be the size of the collection?

finite mango
#

yeah thats what i intended it to do

north kiln
#

Array Length is the number of elements in the entire array

finite mango
#

oh

north kiln
#

Not just the first row

finite mango
#

how can i get the number of rows of the 2d array?

north kiln
#

GetLength iirc

ivory bobcat
finite mango
#

got it, thanks

oak kelp
#

Im having a problem im trying to make it when the Player or Enemy attacks and the Enemy or Player takes damage it flashes white for 0.2 it works when the Player takes damage but not the enemy in the Entity FX Scrpit you can see it switch Materials and switch back but it does not show on the enemy its self

white oak
waxen adder
#

Is there a less instant version of RotateAround? It's a bit jarring for what I'm trying to achieve

eternal needle
waxen adder
hollow slate
#

make a shader and multiply by HDR white (values above 1) to make the texture more white.

main karma
#

does anyone have any idea on how to implement crouching with a character controller?

dire shadow
#

Hey mates, has anybody managed to run unity tests from VS code?