#💻┃code-beginner

1 messages · Page 228 of 1

wintry quarry
#

Then why are you asking in a code channel?

pallid nymph
#

thanks, thanks, I'll keep that in mind 😛

somber ravine
viscid needle
#

me too

somber ravine
#

Ok thanks , new here , very sorry

viscid needle
#

@languid spire pls help

#

hey can you help pls

sage mirage
#

Hello, guys! I have a small issue. I want to pause/freeze my timer counting whenever my game goes over, so whenever my player enters the collider of the other object and triggering game over, as well as to trigger that game over and stop the timer whenever my player getting out of bounds. I have tried like to use Game States with Enum and make it happen but for one reason it doesn't fix. If you want I can provide more information and make a thread for that.

languid spire
viscid needle
sage mirage
#

I have started thinking if I have my UpdateTimer() somewhere else but as I have checked everything is fine at the right place.

languid spire
#

set it to transform.position.y in start. as you are only manipulatiing the .x then you probably want that for .z as well

#

think about it, startpos starts as 0,0,0 what should it be?

viscid needle
#

0, 9.5f, 0

languid spire
#

so set it to that

viscid needle
#

I did they work in the first loop but in the second it goes back to the same 0. Why?

languid spire
#

look what line 12 does

viscid needle
#

Thnks, just had figured that out. Love you

chilly wigeon
#

Hey there, I am facing FileIOPermission present both System.Security.Permissions and mscorlib problem, anyone knows the solution?

languid spire
chilly wigeon
#

@languid spire I was using Gamelift SDK , now i am trying to import Vivox and getting this issue

somber ravine
#

This is my code for player game object , it is a kind of geometry dash game , creating obstacle sprites in the game now , how do i stop the player if it collides with obstacles ?? i tried writing it in the last function of this code

languid spire
languid spire
eternal falconBOT
chilly wigeon
#

AWS gamelift SDK uses System.Security.Permissions assembly as dependency and Vivox uses mscorlib assembly as dependency and both of them has defination for FileIOPermission

#

Thus I am getting issue

somber ravine
chilly wigeon
#

Above is the SS of error @languid spire

sage mirage
languid spire
cosmic dagger
languid spire
sage mirage
#

@somber ravine We don't live at 90's or 00's you live in 2024 bro photos are an old way to show something to people XD

somber ravine
hexed terrace
somber ravine
sage mirage
chilly wigeon
#

Here is the SS @languid spire

obtuse osprey
#

A meta data file (.meta) exists but its folder 'Packages/com.unity.adaptiveperformance/AdaptivePerformanceProject' can't be found, and has been created. Empty directories cannot be stored in version control, so it's assumed that the meta data file is for an empty directory in version control. When moving or deleting folders outside of Unity, please ensure that the corresponding .meta file is moved or deleted along with it.

#

how can i fix this?

languid spire
fathom mist
#

I'm in Unity2D and I have a piece of code that's supposed to trigger a scene change upon a specific item being picked up so the scene will play a cutscene and kick the player back to menu. I have an mp4 of the cutscene but I don't know what to do from there

eternal falconBOT
#

:teacher: Unity Learn ↗

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

chilly wigeon
#

@languid spire I am getting this issue while importing Vivox, is there any suggestion for alternative library for voice chat which I can use with similar features ?

languid spire
chilly wigeon
fathom mist
languid spire
#

timeline is for making cutscenes, you said you already have the cutscene so, no, that is not the solution you are looking for

fathom mist
#

bingienerd i see

west sonnet
#

Can ya'll help me please. This is how you unparent an object, right? I don't know why but it's not working. I've confirmed that canMove is turning to false, I can see it in the inspector, so no idea why it's not working

teal viper
queen adder
#

Does anyone know if this would enable mipmap generation:

Texture = new Texture2D(
                (int)_lottieRenderData.width,
                (int)_lottieRenderData.height,
                TextureFormat.BGRA32,
                mipCount: 0,
                linear: false);

Its 0 but the default is -1 in the unity core

#
public Texture2D(int width, int height, [DefaultValue("TextureFormat.RGBA32")] TextureFormat textureFormat, [DefaultValue("-1")] int mipCount, [DefaultValue("false")] bool linear)
    : this(width, height, textureFormat, mipCount, linear, IntPtr.Zero)
#

I want it disabled

dusk minnow
#

is there a way i can detect if the app is opened the first time

steel smelt
#

@dusk minnow Write something to disk when the app is launched. If there is nothing written, you can assume it's the first launch

naive tapir
#

Is there a good tutorial for a simple idle, run, and jump animation, it would always turn out weird for me cuz the only tutorial I could find was a lil’ bit outdated

ancient holly
#

is there a function that floors to an int but if its too near by a threshold it doesn't?

#

something like

#

if value is 3.995 and it has a threshold of 0.01

#

it will be 4 instead of 3

#

does that exist?

#

guess you could call that weighted rounding

keen dew
#

floor(x + 0.01)

cosmic quail
#

it might fix it

#

if it doesnt then your if statement isnt false

ancient holly
#

almost wrote a new function

whole idol
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WaypointFollower : MonoBehaviour
{
    [SerializedField] GameObject[] waypoints;
    int currentWaypointIndex = 0;
    [SerializedField] float speed = 1f;
    void Update()
    {
        if (Vector3.Distance(transform.position, waypoints[currentWaypointIndex].transform.position) < .1f)
        {
            currentWaypointIndex++;
            if (currentWaypointIndex >= waypoints.Length)
            {
                currentWaypointIndex = 0;
            }            
        }

        transform.position = Vector3.MoveTowards(transform.position, waypoints[currentWaypointIndex].transform.position, speed * Time.deltaTime);
    }
}

Why am I getting this error?

summer stump
#

SerializeField
Not SerializedField

Your ide should have caught that

frosty hound
#

Because your spelled it wrong

whole idol
#

oh

summer stump
#

!ide

eternal falconBOT
whole idol
#

Should this be unlocked?

summer stump
#

Unfortunately that feature adds a bunch of out-of-date packages and keeps them as dependencies

whole idol
#

What engineering feature? I already unlocked it

#

I didnt remove any engineering feature either

summer stump
#

You need to remove the VS Code package

errant spear
#

I don't really know where to ask but i have this error :

'hero' AnimationEvent has no function name specified!

my game run well on test, no bug at all, no animation problem, and the said animation are all named? like i don't know what he's referring to

polar acorn
rare basin
#

on your hero

queen adder
#

correct?

rare basin
#

what is it for

#

if that's some kind of exam we wont tell you

#

obviously lol

low path
#

lol

queen adder
errant spear
rare basin
#

if its correct

#

if its for learning purposes

queen adder
#

I cant

#

it will say its incorrect and I have to wait a whole day to take it again

rare basin
#

you can open up your IDE

#

and check it?

low path
#

why does it make you wait a day?

queen adder
#

yes

rare basin
#

why

queen adder
#

if you fail you have to wait 24 hrs

rare basin
#

so this is a exam

#

so why would we tell you

#

the answer

#

that's not honest exam

queen adder
#

its not an exam exam

rare basin
#

check your skills yourself

#

why would you cheat on learning purpose exam

polar acorn
errant spear
polar acorn
summer stump
frigid flume
#

i have a question that may be very dumb but why isn't the bools recognized ? is it because of the class ?

summer stump
#

If that is a switch statement, then that is the wrong way to write it

#

Also, this is why tiny bits of cropped screenshots are useless

frigid flume
#

you mean before or after when you're saying where ?

frigid flume
#

what do you mean where it comes from

summer stump
#

Where is this code written

frigid flume
#

it's from the same script

summer stump
#

!code

eternal falconBOT
frigid flume
summer stump
#

See how they are in different classes though?

#

You have to reference the achievements inventory class to access the variables

frigid flume
#

nice

frigid flume
frigid flume
#

just write the same line of code in the class ?

summer stump
frigid flume
#

i don't know x)

summer stump
frigid flume
#

thanks for the link ^^ i followed a few tutos and guides but there's still a lot of thinjs i havn't discovered yet :)

summer stump
#

I recommend avoiding youtube at first btw

frigid flume
#

or maybe they were but i havn't understood well '-'

whole idol
#

does anyone know what these errors are?

swift crag
#

Something went wrong internally with the editor

#

Restarting usually fixes that kind of thing.

#

I sometimes see that when undoing and redoing things that modify a list in the inspector

#

e.g. "serialized object disappeared!"

lost anvil
#

if i change this script to an interface would that make it so i can reference and use it from other scripts?

https://gdl.space/duxisolubo.cs

so like if i had a rock that i could throw, i could pick it up and throw it but not in the same script

timber tide
#

Interfaces are usually for specifying an implementation, and such that you could reduce what needs to be passed in a reference.

#

You've may seen examples of like an IInteract interface that people like to implement, and it's pretty helpful by exposing the character's interact method without having to pass the whole character reference.

lost anvil
#

so would using an interface be a good choice for my case?

timber tide
#

And when it comes to polymorphism, it doesn't always have to be a character, as you can implement an IInteract on a box if it implements that specific interface.

#

It depends on your requirements, but for that specific script I can't think of many reasons why someone would have a IPickup implementation.

#

Some examples of character interfaces is having a root interface of IEntity that branches into IPlayer and IEnemy

lost anvil
#

well, what i want is to have different functions for different items that only can be used on Pickup()

timber tide
#

in that case the implementation of that behavior would be on the item itself

lost anvil
#

how would i get it to only work on pickup() though?

hexed terrace
#

IPickup

public class SomeThing : Monobehaviour, IPickup
{
    public void Pickup() {} // this method is forced because of the interface
}```

Then you can do `GetComponent<IPickup>();`
timber tide
#

thing is, you probably only going to have a single type that you pick up and that being a type of Item.

#

so interfaces wouldn't make too much sense here either

lost anvil
#

what about abstract classes actually

timber tide
#

But going back to what I said previously that you can implement interfaces to lessen the amount fields, properties, or methods that the reference of the item exposes, so sure you can add one.

lost anvil
timber tide
# lost anvil what about abstract classes actually

I usually just stick to abstract classes, but I do have interfaces like an IInteractable because there are many types that you can interact with unlike picking up a single type. (Depending on your implementation, but usually everything I pickup derives from a type of Item)

lost anvil
#

so would making the script an abstract class be a better fit?

timber tide
#

If you want items to behave differently on pickup, you would have a OnPickup() method that you'd implement as an abstract method.

#

on the items themselves

lost anvil
#

so i would need an OnPickup() method on EVERY item i want to pickup?

timber tide
#

You don't have to implement the functionality, but if you add an abstract method it needs to be eventually there in the derived class.

lost anvil
#

alright gotcha thanks

misty hedge
#

How do I get a custom composite to show up in Unity's Input Actions GUI?

ionic zephyr
#

in a card game is it better to use cards as scriptable objects or objects of a class "Card"

summer stump
ionic zephyr
#

by default data you mean stats and that stuff?

summer stump
ionic zephyr
#

oh ok

#

and what do you mean with mutable data and instances

summer stump
#

Do you know what an instance is at all? Not sure how much I have to explain for that part

ionic zephyr
summer stump
summer stump
ionic zephyr
#

like a SO "Card" and a Class "Card"

halcyon geyser
#

Id give it different names

ionic zephyr
#

Okay, I guess it is less confusing that way

halcyon geyser
#

You could have ur "Card" class, but Id name ur SO script SO_Card

ionic zephyr
#

for values that do not change at all

#

and the Class for alterable values

#

And the deck should be a List of GameObjects or a List of objects of the class "Card"?

halcyon geyser
#

List of SO's

summer stump
#

I would do CardData. Try not to have types in the name. It's recognized as a code smell

halcyon geyser
#

Whatever suits you 😅

ionic zephyr
#

But I don´t really know how to use both

summer stump
summer stump
halcyon geyser
#

What?

summer stump
halcyon geyser
#

Oh no

#

was talking to Pingu

ionic zephyr
#

image, description

halcyon geyser
#

Name

summer stump
misty hedge
summer stump
#

In MTG, you may have attack, defense, cost, image, name, landType, etc

ionic zephyr
#

yeah take that for example

misty hedge
#

ty!

ionic zephyr
summer stump
#

The Class should have all the same, which would be copied FROM the SO

#

And maybe more references needed to just run the game

frigid flume
ionic zephyr
summer stump
frigid flume
#

i can't understand that x) excuse my dumb

#

which reference should i use ?

#

singleton ?

summer stump
#

foo is a reference to that class

#

So, foo.MyValue

#

Are you following a tutorial?

frigid flume
#

not really

#

i just want to change a variable on click for now

ionic zephyr
summer stump
frigid flume
summer stump
#

public class Card : MonoBehaviour
{
public string Name;
}

And all the rest of those values I mentioned

ionic zephyr
sage mirage
#

Hey, guys! I have an issue with a functionality of my game and I stuck like 3 days already can't find the solution. So, I have an UpdateTimer() method where I am updating the timer, whenever the game is not over. What I want to accomplish is whenever the game goes over to freeze that timer. I have tried to use boolean to make it happen but nothing happened. I have checked every possible way to fix it, like I have watched so many tutorials etc. I am really thinking if I just lost something or put something in my code and now I can't notice that. Please can someone help me with that in thread? Is someone available like for 20-30 minutes and help me find the solution.

summer stump
ionic zephyr
#

referencing each other?

summer stump
#

You CAN do it that way I guess, but that gets muddier imo

frigid flume
ionic zephyr
summer stump
#

I would just have the exact same variables in both the class and so, and just copy from the so to the class when you create a card in during runtime

summer stump
frigid flume
#

i all the tutorials that i've followed i can't remeber any use of reference

ionic zephyr
#

but only alter them in the Class

summer stump
#

Right at the top

summer stump
ionic zephyr
#

So in some way I am creating the same card but two times, one in so and one in class

frigid flume
#

so i should write that ?

summer stump
frigid flume
#

what a victory

#

thanks for your help

summer stump
frigid flume
summer stump
frigid flume
#

yes that's it thanks

#

it took me a long time to undestand x) but maybe i hardly understand guides due to my non-perfect english level

ionic zephyr
summer stump
median ruin
#

How do you start/stop a particle system in scripting?

ionic zephyr
summer stump
frigid flume
#

OMG it works à merveille

queen adder
#

I am getting errors for my code saying that in my MazeNode code there is not definition for RemoveWall but i have a public method right here and I've become more confused

summer stump
#

The class has NO data in it to start with. You create it, get the SO you want the card to be, and copy the data into the class. Then from then on you only use the class

ionic zephyr
#

OOH

polar acorn
eternal falconBOT
ionic zephyr
#

my god @summer stump, you really clarify my questions

#

thanks a lot

summer stump
#

No problem at all. Glad I wasn't too confusing lol.
I can be that way a bit sometimes

ionic zephyr
#

never bro, thanks again

#

Is there any command to copy the values of the Scriptable Object to the object of "Card"?

queen adder
#

theres the full code for everything so far

polar acorn
ionic zephyr
polar acorn
#

it might not have compiled and you can force a recompile by restarting

swift crag
#

Yeah -- assuming your IDE is working, it's not seeing the errors that Unity is seeing

#

which suggests that Unity hasn't seen the latest changes

summer stump
queen adder
median ruin
#

I've tried using ParticleSystem.play() and
ParticleSystem.stop() but I don't seem to be able to start it again after?

polar acorn
median ruin
#

Using GameObject.Enabled won't work since it hides the particles

queen adder
median ruin
#

I'm not sure how to properly pause a ParticleSystem

queen adder
polar acorn
#

and look to make sure they all have walls

ionic zephyr
#

what is an enum exactly?

queen adder
polar acorn
polar acorn
#

Because your error makes it pretty clear that there is at least one MazeNode that doesn't have walls set

queen adder
queen adder
#

how do i fix this?

polar acorn
zinc warren
#

https://hastebin.com/share/muyoqulaxe.java

Hi, can someone check over my code bc im trying to render 3d objects in a ui but it dosnt display it for some reason

rocky canyon
#

that sir is a blank page

icy junco
#

whats difference with the TMP and just normal text ?

rocky canyon
#

TMP is superior

#

text is fuzzy and nasty

polar acorn
rocky canyon
#

TMP has rich text capabilties

#

text doesnt

polar acorn
#

there's literally no reason to use legacy text, ever

#

That's why it's under the "Legacy" menu, you're not supposed to use it, it's provided purely for legacy purposes in case a project was made before TMP was a thing

icy junco
#

owkay thx guys

zinc warren
obtuse osprey
rocky canyon
zinc warren
rocky canyon
#

is the texture present?

zinc warren
summer stump
eternal falconBOT
obtuse osprey
summer stump
obtuse osprey
#

im trying to make a quit button as the first proper bit of code and ive gotten like 6 diffrenet error messages and none of what im trying works lol

somber ravine
#

Where can I ask cinecamera doubts?

summer stump
rocky canyon
obtuse osprey
somber ravine
#

Thnx

obtuse osprey
#

then im going to try make the game

#

ive spend like 2 days and all ive got is this

#

none of the buttons work unfortunately

summer stump
obtuse osprey
#

just making the background on gimp took me 30 mins

summer stump
#

And the code that it calls?

obtuse osprey
rocky canyon
obtuse osprey
#

coppied of a youtube tutorial since what chatgpt told me didnt work

summer stump
obtuse osprey
#

also new error message with this new script

summer stump
#

Can you show the inspector for the button?

rich adder
#

just fyi Application.Quit doesnt work in the editor

zinc warren
rocky canyon
#

alright.. i was making sure it wasn't 0,0,0

obtuse osprey
#

it seems the script is incorrect

rocky canyon
# zinc warren
if (renderTexture != null)
{
    rawImage.texture = renderTexture;
}```
rich adder
rocky canyon
#

can make sure the rendertexture is being assigned correctly

summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
# zinc warren

ive never done this but i have some friends who have for character weapons stuff

summer stump
#

You put an object WITH that script on it there

obtuse osprey
#

oh i see,

#

so make a game object

summer stump
#

The script could be on the button itself

fading rapids
#

is it possible to change a sprite or sprite color in a different scene if yes do i use getcomponent?

zinc warren
summer stump
#

And just drag the button object into its own onclick funtion

rocky canyon
#

and find out where it faults out

summer stump
obtuse osprey
#

all this just to make a main menu

#

wonder how long its gonna take to even make a text based game

summer stump
obtuse osprey
#

i started it

rocky canyon
#

making a menu is pretty easy.. you can have all ur menu functions in one script.. (public) and u can just assign the same script to all the buttons calling their respective functions

summer stump
obtuse osprey
#

dang ok

fading rapids
rocky canyon
#

ud have to cache the value and then act on it when the scene loads in

summer stump
fading rapids
summer stump
# fading rapids yes

I mean at the SAME time as the main menu, to be clear
Or do you change scenes?

rocky canyon
#

if its loaded in its the same thing as changing anything else.. u can search thru the hierarchy and find the object and change it

fading rapids
#

oh no

#

i chaneg scenes

obtuse osprey
#

i stopped since i couldnt find what it told me to do the lego minigame thing

summer stump
rocky canyon
#

if its not loaded in.. u got two choices.. u can cache the variable like i mentioned and change it once its loaded in.. or load it in to change it

#

id do the first.. b/c if u load it in.. ur gonna have to modify it so its not visible.. or functioning on top of ur menu

fading rapids
#

ty for ur help, just thought of a diff idea for this

rocky canyon
#

if i had to guess it would be a setup issue..

#

but id step thru the code.. one part at a time.. and make sure its functioning as u go

#

u got alot going on in there

#

oh wait.. idk much about it but i see where u create the render texture but ur not saving it or applying it to any material or anything..

#

you create the texture.. modify the camera to look at it.. but then u just destroy the camera

#

and return the texture that u created.. but never done anything else to..

rare quarry
#

why doesn't it work

rich adder
#

put log inside Trigger on like 46

rare quarry
#

they are working seperately

rocky canyon
rich adder
# rare quarry they are working seperately

well doing a KeyDown/ButtonDown inisde an ontrigger 1 frame event, you will never have the required speed/sync to do it
solution is simple. Dont put input handling inside that

worthy merlin
#

How do I access a TextMeshPro in my Logic? I was trying to access it with public Text HighScoreText; but it won't let be drag the object in. Despite being a text object

rocky canyon
#

its not Text..

rocky canyon
#

and you'll need the using TMPro;

supple citrus
#

yo this is stupid but how do i get my scene and game view back :v My computer was asleep and the keys i pressed to wake it up made it disappear

rocky canyon
#

Window

wintry quarry
rich adder
#

or shift + spacebar

wintry quarry
#

Unmaximize it

supple citrus
#

ty catcry

rare quarry
queen adder
#

I've tried to reference the other walls in my code but it ended up messing it up more. How do i fix this code so that each node has all its walls assigned to it during grid generation and then walls are deleted during the maze generation?
https://hastebin.com/share/onohaligom.csharp

#

i made 3 list that each changes the colour of the node and it should be fully green and then have a maze at the end

#

instead i get this

rich adder
rare quarry
#

i made the range 0.001 but still when i click enemy dies

rich adder
rare quarry
#

forgot to set a layer

#

:PP sorry

ruby python
#

Hi all, I'm having a bit of a brain fart and can't for the life of me remember what I'm doing.

I want to cast a screenpointray at a certain distance (200m for example) and then have an object point at the 'end point' of the ray. But my mind is drawing a complete blank on how to do it (I can remember how to make the ray 'hit' an object, but not how to do it without hitting an object (if that makes any kind of sense. lol.)

rich adder
rocky canyon
#

is the Vector3 / (2) position of where the ray hit..

rare quarry
rocky canyon
#

then ud just look at that

ruby python
rocky canyon
#

so u want it to ignore all the hits up until the 200m mark?

ruby python
#

I want it to ignore everything, period, but limit the ray length to 200m (this I know how to do, it's the ignoring everything part)

rocky canyon
#

if its ignoring everything until the 200m mark why even use a raycast?

#

just use ur starting position and add 200m to it

#

in the direction..

buoyant knot
#

raycasthit2D has a .distance field for how far it went

rocky canyon
#

he only wants the 200m hit

#

i think

buoyant knot
#

he only wants UP TO 200 m

rocky canyon
#

without hitting an object

#

then whats that mean ^

rocky canyon
#

then why the raycast anyway? 😅

#

im confused tbh

buoyant knot
#

i think 200m is his max search range

ruby python
#

I want the mouse position on screen to control the target point of a weapon (so that the weapon always points at the mouse pointer on screen), but I don't want any objects to 'interfere' with the distance (I know I'm not being very clear, sorry)

buoyant knot
#

raycasts hit colliders

#

the point of a raycast is to ask about where colliders are

#

if no colliders are involved, no raycasts should be used

rocky canyon
#

use a layermask.. and make an invisible plane or collider that ur ray can hit..

#

then it wouldnt be hitting walls obstacles etc

ruby python
#

!code

eternal falconBOT
buoyant knot
#

the UI system has a strange convention with using “raycasting” to hit UI objects, but i don’t think that is what you are looking for here

#

looking at your code will not explain what you want

#

you need to articulate it with words

ruby python
#
//Player Facing Mouse
Plane playerPlane = new Plane(Vector3.up, transform.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float hitDist = 0.0f;

if (playerPlane.Raycast(ray, out hitDist))
{
    Vector3 targetPoint = ray.GetPoint(hitDist);
    targetPointActual = new Vector3(targetPoint.x, 3.12f, targetPoint.z);
    Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
    targetRotation.z = 0;
    transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, mouseSensitivity * Time.deltaTime);

}

I've used this snippet before for top down, but brain is cabbaged and couldn't figure out how to translate it to 3rd person. lol.

buoyant knot
#

oh now that i see the code, that changes absolutely nothing

rocky canyon
#

my guess is hes talkin about something like this.. where that crosshair wouldnt be On top of the wall

#

but more on the ground.. where the mouse is

#

in which case id just use hte ground as the layermask

buoyant knot
#

he wants a weapon to point at your cursor

#

but then something about objects interfering, which doesn’t make sense

#

if you can represent the position of your cursor in world space, you can rotate an object to point at it

#

not sure where other objects are involved here

ruby python
#

Here's a screengrab of my scene. As you can see there are a crapload of different types of objects (trees/signs etc. etc. etc.) so I want the weapon to point at the mouse pointer at a distance of 200m at all times, without all of those objects interfering.

buoyant knot
#
  1. why do any objects interfere
  2. mouse pointer exists in screen space. player is in world space. they cannot be 200m appart because they exist in different space
#

it the cursor is at (100,400), that means 100 pixels right, 400 pixels up

cosmic knot
#

Hi hi I'm new here and I have a question to ask if anybody could help me.

rare basin
#

dont ask to ask

ruby python
#

Which is why I want to use ScreenpointtoRay. So that I can get a point in 3d space to point at. With all the objects in the way it could lead to 'jerky' movement etc. if the mouse goes over something really close suddenly.

rocky canyon
#

they could exist 200 meters apart.. when u use the mouse position to raycast into the world space.. u get that hit position.. and then it could be 1m from the player or 200m from the player

#

w/ a layermask my ray wont end up on top of object or w/e id just cast str8 to the ground

rocky canyon
#

Y axis would always remain the same..

#

no jerky movement

ruby python
#

So I could add an invisible plane 200m in front of the player (parented to the player so it sticks in front?) (sorry, just trying to be clear while I get it straight in my head. lol.)

cosmic knot
#

Basically I'm trying to make a indoor navigation app for android using vuforia and navmesh. The problem I'm facing is that the documentation is quite old of Vuforias site. For example they say that I should import prefab model to my gameobject area target as a child and then go to window -> AI -> navigation and then press bake. Now that option is no longer there

ruby python
rocky canyon
#
       if(Input.GetMouseButtonDown(0))
        {
            Plane plane = new Plane(Vector3.up,Vector3.zero);

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            float entry;

            if(plane.Raycast(ray,out entry))
            {
                dragStartPosition = ray.GetPoint(entry);
            }
        }```
short hazel
rocky canyon
#

theres also this version of raycast.. that u can just create a plane in ur code

ruby python
#

Thank you guys, seriously 🙂

short hazel
#

Then once you hit it, you have the point, and can rotate the player towards (hit.point - player.position)

ruby python
#

Yeah, I knew I had all the code (more or less), was just translating it to be 'forward' instead of up which was boxing my noggin. lol.

rocky canyon
#

noggin boxing..

#

gotta hate that

ruby python
#

uh huh, really shouldn't be doing this stuff after 12 hours of fluid simulation maths. lol.

queen adder
#

Can sm1 explain to me for a second why its not generating a maze kind of just lines with stops in them sometimes? I thought i was careful to make sure that each direction and wall match now im confused.
https://hastebin.com/share/zevikunele.csharp

obtuse axle
#

Hello im fairly new to this, can someone explain why the capsule wont fit in the hitbox in green?

rich adder
summer stump
cosmic knot
swift crag
#

that's how the old system would have worked, too

#

you can set the NavMeshSurface to only care about physics colliders

#

you can also add NavMeshModifier components to make some objects produce non-walkable areas

#

this would be appropriate for a desk, for example

hexed terrace
obtuse axle
#

oh okay thanks a lot

#

mb i didn't where to put that question

hexed terrace
#

read the channel topics 😄

ruby python
#
Plane playerPlane = new Plane(Vector3.forward * 200f, Camera.main.transform.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float hitDist = 0f;

if (playerPlane.Raycast(ray, out hitDist))
{
    Vector3 targetPoint = ray.GetPoint(hitDist);
    dogMiniGun.transform.LookAt(targetPoint);
}

Sorry fells, am I being monumentally dense about this? Can't seem to get this to work at all. 😦

swift crag
#

in what way does it "not work"?

ruby python
#

My weapon doesn't rotate

swift crag
#

that Plane constructor looks very wrong to me

short hazel
#

You're passing weird stuff to that plane

swift crag
#

it takes a normal vector and a position

#

the plane cuts through the camera

#

you probably meant to do new Plane(-Camera.main.transform.forward, Camera.main.transform.position + Camera.main.transform.forward * 200f);

#

this plane's normal vector faces towards the camera, and it passes through a point 200 meters in front of the camera

ruby python
#

Okay, thank you.

swift crag
ruby python
frigid sequoia
#

When declaring an RGB color, is there a way to change the format from 0-1 to 0-255 or do I just have to divide everything by 255?

terse osprey
#

I am using this script to resume my game from a button but once I resume the game and all my inputs and controls stop working

buoyant knot
frigid sequoia
swift crag
#

note that if you're making a Color, the values should be in the [0, 1] range

frigid sequoia
swift crag
#

That's just how most people are used to thinking about colors

#

since that's how you'd edit 8-bit-per-channel RGB

polar acorn
ionic zephyr
#

I want to create a List of transform arrays, is it better to use List of Lists?

buoyant knot
#

depends

hexed terrace
#

is the size of the list going to change at runtime?

buoyant knot
#

do you want a list of lists, or a list of arrays

ionic zephyr
#

To put the precise example. The player can select between different attack formations of 4 determined positions

#

So I imagined the best thing is that all the formations are included in a List and the positions in those formations are in different Transform arrays

valid violet
ionic zephyr
#

Oh okay

valid violet
#

but it is also okay to use List of Lists no big diff on performance if u use only 4 transfroms in list.

night mural
hexed terrace
#

probably better to ask in #🏃┃animation as that doesn't really sound like a code question, for this code channel

sour dawn
#

Sorry, I must have overseen it, as I had looked. Thanks!

hexed terrace
#

best delete from here before posting there, otherwise you'll probably get told off for crossposting

dusk minnow
#

i have these editor stats and when i change a bool in editor;runtime it resets to its value that it had when i started, same with string mat and price,but when i add/remove an element it works, someone knows why, code is nothin thats changing it

hexed terrace
#

because changes in the inspector at runtime aren't saved

fading rapids
#

what happens with time.timescale in multiplayer

dusk minnow
polar acorn
fading rapids
#

xd

#

i mean like when my turs 0 after pressing a button what will happen with oither players

polar acorn
#

Unless you change the value, it does not change

hexed terrace
sterile moon
#

I dont think I am, I'm parenting it to an empty for my 'hands'

polar acorn
#

Depending entirely on how you're handling multiplayer and any timescale changes, this could be literally any result

dusk minnow
hexed terrace
#

🤔

ionic zephyr
#

how can i make a List of Lists?

#

public List<Transform> positions = new List<Transform>();

#

List<positions>?

polar acorn
#

Just put the type in the <>

#

In this case, your type is a List<something>

ionic zephyr
#

List<List<Transform>>?

tender stag
#

calculation in HandleSpeed calculates how much force to add to reach speed limit, problem with it is that it doesnt add the force in the slopeMoveDirection because slopeMoveDirection is only used in the targetVelocity calculation and not in the final calculation, so the force doesnt get added in the direction of the slope but just forward which causes my character to bounce when walking down a slope since the force is added forward and not down for example with the slope angle

Handle Input - Update ```x = Input.GetAxisRaw("Horizontal");
y = Input.GetAxisRaw("Vertical");

moveDirection = orientation.forward * y + orientation.right * x;
slopeMoveDirection = Vector3.ProjectOnPlane(moveDirection, slopeHit.normal);```

Handle Speed - Update ```Vector3 targetVelocity = slopeMoveDirection.normalized * moveSpeed;
Vector3 velocityDifference = targetVelocity - rb.velocity;

slopeMoveVelocity = new Vector3(velocityDifference.x, 0, velocityDifference.z);```

Handle Movement - Fixed Update rb.AddForce(slopeMoveVelocity * acceleration);

basically what i need to do is to include the slopeMoveDirection.normalized in the final calculation to add the force in the direction of the slope instead of just straight as its doing now because slopeMoveDirection.normalized is not involved

frigid sequoia
#

I cannot change the permissions of a method from the child class right? Like if I make this (parent//child) these are two different methods or what?

undone rampart
#

you must use the override keyword if you want to override the parent function, otherwise it will be treated like a new function

polar acorn
#

They're two different methods unless you use override

frigid sequoia
#

Doesn't the virtal makes so I don't have to override?

undone rampart
#

virtual makes it so you can have a base implementation that you can override

ionic zephyr
#

Why cant I see my List of Trasnform Lists in Editor?

#

it is in public

lost anvil
#

if i create an interface for Interact() can i just use that on any object that uses a script i reference the method Interact() in, but in that script i specify what it does?

public class PlayerInteract : MonoBehaviour
{
    [Header("Inspector Variables")]
    [SerializeField] public new Camera camera;
    [SerializeField] public float rayDistance;
    [SerializeField] public TextMeshProUGUI objText;

    // SCRIPT ENABLED VARIABLES

    AudioSource pickupSound;
    Rigidbody itemRb;

    void Start()
    {
        objText.gameObject.SetActive(false);
        objtext = null;
    }

    void Update()
    {
        RaycastHit hit;
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, rayDistance))
        {
            if (hit.collider.CompareTag("Interactable"))
            {
                objText.gameObject.SetActive(true);
                objText.text = hit.collider.gameObject.GetComponentInChildren<TextMeshProUGUI>().text;

                if (Input.GetKeyDown(KeyCode.E))
                {
                    Interact();
                }
                else
                {
                    objText.text = ("Can't Pick Up")
                }
            }
            else if (hit.collider.CompareTag("Untagged") || hit.collider == null)
            {
                objText.gameObject.SetActive(false);
            }
        }
    }
}
polar acorn
#

So you can get whatever behaviour implemetns your Interact method

lost anvil
#

sorry im really confused on interfaces and stuff could you give an example maybe

polar acorn
#

and then you could call Interact on it

lost anvil
polar acorn
#

You would call it on whatever object you want to get the component from

lost anvil
#

on whatever script is on the object i want?

polar acorn
#

What object do you want to get an IInteractable from

lost anvil
#

one i can interact with like a cube i can pick up

polar acorn
#

How do you intend to know which object that is

lost anvil
#

by sticking a script on there calling IInteractable?

polar acorn
#

How are you going to decide which IInteractable to call the function on

lost anvil
#

idk

buoyant knot
#

randomly of course

polar acorn
lost anvil
polar acorn
#

You could put an IInteractable on every single object if you want

lost anvil
#

yeah that was my plan

polar acorn
#

how are you intending to know which one you want to interact with

buoyant knot
#

in general, when you GetComponent<IInterface>(), you want to find a unique answer, OR you want to call GetComponents<IInterface>() to get an array, and call your method on all of them

lost anvil
polar acorn
#

To get the IInteractable component

lost anvil
#

so variable.GetComponent<IInteractable>().Interact(); ?

polar acorn
#

yes

lost anvil
#

alright cheers 👍

ionic zephyr
#

how can I resize my main camera?

buoyant knot
#

get a bigger monitor

ionic zephyr
#

I mean, instead of a rectangular size, I want a square

night mural
#

there's a resolution dropdown at the top left of the play mode window

buoyant knot
#

check camera settings

#

and target resolution

timber tide
#

or in this case

#

get smaller monitor

buoyant knot
#

or apply black marker to the left and right sides of your existing monitor

rocky canyon
#

if your game has a resolution of 1024x768, you can realize that 768 is 3/4 of 1024. So, if you change the width dimension to .75, 1024 will become 768 and the view will be square. However, the view will now be off center. To fix this, change the x value to 0.125

scarlet skiff
#

someone help i think i messed up my project, i was makign siome changed to my character and...??? everything got displaced? i panicked a bit and then ctrl + z a little too much and now i think i ended up removing waaayyy to much but the character is still messed up??? all of its sprites r like in one position...

now i cntrl + y everythign back cuz i remebered that i made a change to the player perfab itself but like how do i reverse that? and it looks fine i nthe prefab editor but not in the scene... help this stresses me out

tender stag
#

maybe send screenshots

scarlet skiff
#

i think its because i moved everything udner a new parent called body

#

well not eveyrthing but yea

#

cuz some parts werent part of the prefab

#

maybe i should have updated the prefab and added thsoe parts

rocky canyon
#

if the prefab is fine but the version in teh scene isn't you can just delete it pull the prefab back in

#

Revert changes also works

scarlet skiff
rocky canyon
#

ud have to fill in the references

scarlet skiff
rocky canyon
#

yea, at the top of the prefab (when u click the scene) at the top if theres overrides u can revert them back to w/e the prefab has set up

#

but i think thats when u change stuff of the prefab (in the scene)

#

not in the prefab window

#

like here.. on this prefab ive changed all those things (in the scene)

#

if i hit revert.. it'll all go back to whats the prefab view has

#

if i hit apply.. it'll change the prefab to w/e the scene version has

ionic zephyr
#

In an RPG game, my team of characters should be a List?

scarlet skiff
rocky canyon
#

its at the top of the inspector.. when u click the prefab in the scene view..

#

if its not there.. ur prefab stuff has already been saved.. and it is wat it is

scarlet skiff
#

but i dont htink ishould override cuz i got something i didnt save i nthe prefab

#

is there just no way to revert the prefab change itself

#

without override

rocky canyon
#

there two different things... override is when u force the prefab to take on the changes of the version you have in the scene..

#

the revert is the opposite.. it forces the prefab in the scene to take the settings u have of the prefab version

tender stag
#

how can i improve on this```float targetMagnitude = moveSpeed;
float forceMagnitude = targetMagnitude - rb.velocity.magnitude;

Vector3 force = slopeMoveDirection.normalized * forceMagnitude;

rb.AddForce(force * acceleration);```

#

the movement works

#

but it feels slippery

rocky canyon
#

add a physics material.. with higher friction..

tender stag
#

i already have that

rocky canyon
#

then adjust the forces that you'll need to overcome the new friction

#

well make it higher

tender stag
#

its already at 0.9

scarlet skiff
#

here is the thing:
In scene there are important things not part of the prefab attached to it. But everything under the players body took a new position due to a perfab change.

in the prefab the character looks right at least, but doesnt have some of the important stuff attached

#

am i.... cooked?

rocky canyon
#

if its that bad off and u cant just apply or cancel the settings ur gonna have to manually fix it

rocky canyon
#

when theres no input it'll dampen the velocity and slow it down a bit faster

scarlet skiff
rocky canyon
#

no clue.. u can unpack the prefab in ur scene..

#

that way u can have both versions of it.

#

in order to fix it

#

it'll make it a regular object

scarlet skiff
#

lol what i just unparented everythign under the body and dleted it in the prefab and... everythign went back to normal? i think

rocky canyon
#

lmao idk man.. ¯_(ツ)_/¯

scarlet skiff
#

😭

#

god is good 🙏

rocky canyon
#

gotta pay more attention man

scarlet skiff
#

fair enough..

#

i suppose i should update the prefab now

#

to add the new stuff

#

so in case i need to override i nthe future

#

also.. am i tripping or do i just not have a override

rocky canyon
#

thats the prefab view...

faint sluice
rocky canyon
#

^ when u select the prefab from the scene (the regular inspector)

#

is where ur override / revert stuff is

#

u have prefabs inside prefabs btw

obtuse osprey
#

im on the newest version of unity going through one of the unity pathways and i cant see the option for any of the mircrogames it is telling me to do anyone know why or how to fix?

hexed terrace
#

Use the same version as the pathway is for

#

also, this is a code channel..

naive tapir
hexed terrace
#

If you can't find a relevant channel, then #💻┃unity-talk is the place to ask.. not a random channel!

scarlet skiff
faint sluice
frigid flume
#

Hello ! here is my script that works well, when i click the bfa1 buttons its color changes to green. But i want two more things :
I want the default color of the button be red if a bool is false, and green if a bool is true,
and I want to switch these colors on click (make button red if it was green, and make it green if it was red). For the moment, on click (CaseFA1) the color is changed to green.
How should i do ?
I tought i could check the value of bool on start, and check it on click too. But i'm not sur how great it would work to copy/paste the last block of Code. Maybe should i create a changetored function and a changetogreen fonction ? does it works if not affiliated to any object ?```using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.UI;

public class SaveData : MonoBehaviour
{
public AchievementsInventory inventory = new AchievementsInventory();

public Color green;
public Button bfa1;
public void Start()
{
    LoadFromJson(); //loads the bool value
}
public void CaseFA1() // on click
{
    inventory.fa1 = !inventory.fa1; //switch the bool 
    SaveToJson();
    ColorBlock ccbfa1 = bfa1.colors;
    ccbfa1.normalColor = green;
    ccbfa1.highlightedColor = green;  //changes color to green
    ccbfa1.pressedColor = green;
    ccbfa1.selectedColor = green;
    bfa1.colors = ccbfa1;
}```
ionic zephyr
#

In an RPG Game the Team of characters should be a list?

faint sluice
scarlet skiff
faint sluice
#

Although I would extract method and change colors from there for clarity purposes

ionic zephyr
ionic zephyr
#

for example take FF7

scarlet skiff
#

if you are often going to run code that is related to all the chacarters in a party, then yea adding them all to a list would probably be beneficial

ionic zephyr
#

Imagine a charcter isnt on the party any more

frigid flume
#

ccbfa1 stands for colorchangebuttonforceachievement1 x)

faint sluice
#

Less redundancy

frigid flume
#

yes but why i don't do that is because it actually changes the color of only the bfa1 button

#

so i'd have to make a function for each button ?

faint sluice
#

ChangeColor(Button, Color)

frigid flume
#

i'll try that but i'm not very familiar with it ^^

#

thanks for the help

scarlet skiff
#

but yea u probably do need a list to create a group/party

#

idk i havent done that yet, perhaps a more experienced game dev can take over

faint sluice
#

In the end how you want to store your party characters entirely depends on your use case

tender stag
#

should i be clamping velocity in fixed update or can it be in update?

#

Vector3.ClampMagnitude

fathom frigate
#

One message removed from a suspended account.

timber comet
short hazel
timber comet
timber comet
fathom frigate
#

One message removed from a suspended account.

polar acorn
short hazel
#

Looks like you renamed your script from PlayerContol (from the warning and file name) to Example

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

short hazel
#

For maximum compatibility, the class name and file name must match

lost anvil
#

How would i go about using tweens to animate this item from being on the ground to the players hand?

        item.transform.SetParent(camera.transform);
        item.transform.localPosition = new Vector3(0.79f, -0.53f, 1f);

i already have everything else setup i just need this animation, im using DOTween

polar acorn
fathom frigate
#

One message removed from a suspended account.

polar acorn
short hazel
lost anvil
short hazel
scarlet skiff
#

Okay so i have this problem, and.. i dont know how to really describe it but ill try:

I am trying to make my player be able to parry some projectiles, the approach that i have is that there would be an invisible hitbox that makes a list and adds all the parryable projectiles in it (on trigger enter 2d) and removes them if they are no longer in range. The reason i have made it this way rather than a gameObject that gets enabled/disabled when the player parries is because i only want the player to able to parry (play the animation and such) if there is a parryable object in range. The player sort of "kicks" the projectile away rather than some approach games have where you just shield and whatever touches it well gets blocked or whatever, or you can hit with ur sword and if nothing is there then well nothing happens.

The problem with this is... since the hitbox is under the player parent, when it comes in contact with this hitbox it counts it as hitting the player as well, and i dont want that to happen.

I could spend a whole lot of time splitting the player into two parents.. and making a paarent for those two, then redistributing the scripts correctly.. and all that jazz.

I have also though of going to the script that handles the players collisions and change it make all methods ignore collision if it also collides with the parry hitbox... but...

  1. idk which solution to choose
    and
  2. maybe there is a 3rd better solution?
fathom frigate
short hazel
lost anvil
#

alright thanks

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

tender stag
#

i need to add opposite forces in the direction which the rigidbody is moving, how do i do that? ```cs
float targetMagnitude = moveSpeed;
float forceMagnitude = targetMagnitude - rb.velocity.magnitude;

Vector3 force = slopeMoveDirection.normalized * forceMagnitude;

//If input keys are pressed
if(isWalking)
{
rb.AddForce(force * acceleration);
}
else
{
//If the player is moving
if(rb.velocity.magnitude > 0)
{
//Add force to stop player
rb.AddForce();
}
}```

#

here

frigid flume
tender stag
#

how can i only clamp velocity of a rigidbody excluding the y?

polar acorn
#

Get a copy of the vector with zero y, then clamp it

#

then copy the old y over and set velocity to that

tender stag
#

is this fine?

#

also should that be in fixed update?

teal viper
# tender stag

This would reset the y velocity to 0. If that's what you want, sure.

clear seal
#

how do i make the serialefield stuff

polar acorn
clear seal
#

()

#

on my english keyboard

polar acorn
#

parenthesis?

clear seal
#

ye

polar acorn
#

you type them

rocky canyon
clear seal
rocky canyon
#

they're right there next to the enter key

polar acorn
short hazel
#

Square brackets

clear seal
short hazel
#

For attributes

clear seal
rocky canyon
polar acorn
#

I have no idea what layout that is

short hazel
clear seal
#

ah forget it

rocky canyon
#

they're right htere.. just figure out the key u need to push to get it

clear seal
polar acorn
#

But it looks like you just press the keys

rocky canyon
#

< [ { (

clear seal
polar acorn
#

The bottom left character seems to be the one they type unmodified

#

so just like

short hazel
#

Try combinations of the key with Alt, Shift, Ctrl, Fn (if laptop) and it'll eventually input the right ones

rocky canyon
#

thats not a regular english keyboard

polar acorn
#

press those keys

clear seal
clear seal
#

i just checked

polar acorn
#

Press these buttons, without any modification, and send whatever it is they type

clear seal
short hazel
#

I mean you don't know the layout of your own keyboard? It's tied to where in the world you bought the computer

polar acorn
clear seal
#

^^ ¸¸ alone
^^¨¨with shift

polar acorn
#

Okay, so, I guess the bottom left theory is out. I have no idea how your keyboard works, but you probably should. Find whatever key combination types the bottom left symbol on your keys

short hazel
#

Do you have an "Alt Gr" key on there? On the right of the space bar. You might need to use that

rocky canyon
#

lmao... soo confusing searching around for that.. every thread saying something different lol

north kiln
#

Apparently it's Alt Graph (IBM says alternate graphic), but it just sounds like an angry alt key to me

rocky canyon
#

i didnt realize how many different keyboard layouts there are

#

i knew about qwerty vs azerty but apparently theres even sub-types

short hazel
#

Yep I have to use that for these on my layout: ~{[|\@]}. Makes typing more inconvenient when programming

rocky canyon
#

3 keystrokes = 1 character

#

(╯°□°)╯︵ ┻━┻

lost anvil
#

any idea why when i drop my item whilst its being picked up with a tween animation it phases out of existence? i tried using a coroutine and yield new waitforseconds to make the player wait for the animation to be over before he is able to drop it but that didnt work.

short hazel
# lost anvil any idea why when i drop my item whilst its being picked up with a tween animati...

Most likely because the tween on the local position is still in progress when the object gets unparented. The frame of reference of the object suddenly changes (the local position is identical to the world position when an object has no parent), but the tween continues applying modifications to the local position. You'll probably find your objects near the world origin (0, 0, 0) when you make the bug happen.

lost anvil
#

that would make sense

short hazel
#

Solution: kill the tween if the object is dropped before it's completed

lost anvil
#

alright ill have a crack nice one

tall sierra
#

Hello everyone. I have a question about Images & RawImages and I don't know WHY it works that way...
Basically, when I run this code :

public Image image; // Ref set in editor
public void SetImg() { image.sprite = Resources.Load("Sprites/MyFileName") as Sprite; }

It sets the Image to none instead of the correct one

However, when I do the exact same with a RawImage instead :

public RawImage rawImage; // Ref set in editor
public void SetRawImg() { rawImage.texture = Resources.Load("Sprites/MyFileName") as Texture; }

It works properly and as intended.

I would appreciate an explanation as I can't really put my finger on it. Thanks

ivory bobcat
tall sierra
tall sierra
#

I know, I'm loading as a Sprite for Image and as Texture for RawImage

#

It works when I load it as a Texture for RawImage. Why doesn't it work for Image when I load it as Sprite ?

#

Same exact file

ivory bobcat
#

A png isn't a sprite

tall sierra
#

Ok so. For Image, when I drag and drop it on the "Source image" thing, it works. Why ? Thinkies

ivory bobcat
tall sierra
#

Ok, so I guess I should be loading it as a Texture and making a Sprite dynamically

ivory bobcat
tall sierra
#

The one to the left is a Texture2D and the one to the right is a Sprite

#

So do we agree that loading this as a Sprite should work ?

ivory bobcat
#

I don't know what you're saying but bolt is unknown and the source image expects a sprite according to the docs.

sly wasp
#

How would I make a script where the UV of any white colored vertex group gets controlled by the movement of a bone

ivory bobcat
#

Raw png files are not sprites.

summer stump
tall sierra
#

I know what the doc says and I also know what you're saying. It's okay, thanks for trying to help 🙂

sly wasp
summer stump
grim pecan
#

im trying to make a walljumping code like the one in ultrakill and how would i go about it

amber spruce
#

how do i instantiate a object under a specific object

amber spruce
slender nymph
#

i am aware of what you meant. did you read the docs?

amber spruce
#

yes im still confused

slender nymph
#

did you see how most of the overloads for Instantiate take a parent parameter to specify the parent of the object being instantiated?

amber spruce
#

yeah but why is it a transform not a gameobject

slender nymph
#

why would it be a GameObject type? but also why does that really matter? every GameObject has a transform and every Transform has a gameObject

amber spruce
grim pecan
#

bro what was rick tryin to do

amber spruce
#

how do i convert a array to a new type so for example i want to convert it from gameobject to text objects each gameobject has a text component

timber tide
#

text is just a component of a gameobject, so cycle through your game objects and grab each of their text components and stick em in a container

swift crag
#

A GameObject is not a TMP_Text

rocky canyon
#

apparently with linq u can

swift crag
#

It doesn't matter that the game object happens to have a text component on it

#

It's not a text component

amber spruce
swift crag
#

You can iterate over a bunch of game objects and try to get a TMP_Text from each one, sure

#

But it's very important that you understand that this is not just "converting" the game objects into something else

north kiln
#

You can make a new array. .Select(g => g.GetComponent<TMP_Text>()).ToArray();

rocky canyon
#

see ^ magic

swift crag
#

and I also have to wonder why you can't just reference the text components from the start 🤔

amber spruce
#
NetworkClient[] networkClients = NetworkManager.Singleton.ConnectedClientsList.ToArray();

players.Select(networkClients => networkClients.GetComponent<NetworkObject>().OwnerClientId).ToArray();

so smth like this or no

swift crag
timber tide
#

if you right click where the underline is at the error, VS will fix it for you (implement interface methods or something along that line)

swift crag
#
players.Select(networkClients => networkClients.GetComponent<NetworkObject>().OwnerClientId)

For each player, this tries to get a NetworkObject from the player, then gets OwnerClientId from the NetworkObject

#
players.Select(player => player.GetComponent<NetworkObject>().OwnerClientId)
#

a better-named rewriting

#

this doesn't make sense, though

north kiln
#

Then you haven't configured your !ide, as has been requested multiple times

eternal falconBOT
amber spruce
polar acorn
#

Did you consider doing all of the other steps too

north kiln
#

!ban 1145389547350413323 rabid homophobia in bio

eternal falconBOT
#

dynoSuccess el_conquistador____79724 was banned.

north kiln
#

👋 cya fucko

polar acorn
#

A well, that took care of that

swift crag
#

L + no ide + homophobia in bio

swift crag
#

this is an anonymous function that has one argument

#

the argument is named player

#

this function just returns whatever you give it

#
public List<int> Foo() {
  return players.Select(player => player.id).ToList();
}

public List<int> Bar() {
  return players.Select(GetId).ToList();
}

public int GetId(Player player) {
  return player.id;
}
#

Foo and Bar do the same thing.

ivory bobcat
swift crag
#

you don't need parens for a single-argument anonymous function.

#

but yes, you, more generally, use parentheses for the parameter list

ivory bobcat
#

Where yours would be (player) => player.GetComponent<NetworkObject>().OwnerClientId

#

Was simply being explicit

amber spruce
#

aight thanks

swift crag
#

Select is a LINQ extension method. You add using System.Linq; to access it.

#

It works on any enumerable thing: lists, arrays, etc.

#

for each item in the enumeration, it runs the method on it

#
List<int> numbers = new() { 1, 2, 3 };
List<int> doubled = numbers.Select(x => x * 2).ToList();
#

ToList() makes a new list out of the sequence

ivory bobcat
# amber spruce how do i convert a array to a new type so for example i want to convert it from ...

Relative to what Mao said #💻┃code-beginner message , it'd look something like this if you aren't using linqcs Text[] texts = new Text[gameObjects.Length]; for(int i = 0; i < gameObjects.Length; ++i) texts[i] = gameObjects[i].GetComponent<Text>();With the above, the new array would have a bunch of nulls wherever a component wasn't present. A List implementation would look something like thiscs List<Text> texts = new List<Text>(gameObjects.Length); foreach(GameObject go in gameObjects) if(go.TryGetComponent(out Text text)) texts.Add(text);

worldly laurel
#
{
        Debug.Log("You Win!");
}```


This is my trigger code, I have rigidbody2D, I have 2 objects only, a player and a box, both with colliders, the trigger is on for the box and for some reason the trigger refuses to go off when colliding. Im using the input system as well, with some code for movement if that effects much (im extremely new, apologies)
#

Movement code:





private Vector2 movement;
private Rigidbody2D rb;






private void Awake()
{
    rb = GetComponent<Rigidbody2D>();
}

private void OnMovement(InputValue value)
{
    movement = value.Get<Vector2>();
}

private void FixedUpdate()
{
    rb.MovePosition(rb.position + movement * speed * Time.fixedDeltaTime);
}```
ivory bobcat
#

How to post !code

eternal falconBOT
ivory bobcat
#

Show the inspector for both objects

worldly laurel
ivory bobcat
worldly laurel
#

oh yes, apologies

ivory bobcat
worldly laurel
#

No, both are gameobjects

#

well, initially empty objects

ivory bobcat
#

The one above seems to have a canvas renderer and a rect transform rather than a standard tranform component.

worldly laurel
#

With this, theres still no text displayed when the colliders meet

ivory bobcat
#

Physics 3d and physics 2d are different

wintry quarry
worldly laurel
#

Thank you both

sly wasp
#

https://hatebin.com/gwwtooejgp

I was trying to code a script where the white vertex color has its UV moved according to a bone's position. I got it to target the color, but the only problem is that it cycles through random colors of the texture and does not follow the bone

teal viper
sly wasp
#

I am using vertex colors so the script knows where to control the UVs

#

It is one mesh so the eyes are not separated

#

Also the eyes are flat

teal viper
#

Okay, well, you're only changing the uvs, so it just samples different positions of the texture.

sly wasp
#

How would I make it move based on the position of the selected bone and have a limit of how strong the movement is?

teal viper
#

Wdym by "make it move"?

#

Uvs are in range of 0 to 1. Using bone position to calculate gonna result in some unrelated numbers.

#

In the first place mapping bone position to uvs sounds like a crazy idea. What are you trying to achieve?

sly wasp
#

What I mean by making it move?
Well the eye is included in the body's texture, so I'd like to move the uv of it up and down based on the bone's x and y position.

teal viper
#

Okay, I see...🤔

sly wasp
teal viper
#

You'll need to define the uv positions range of the eyes and maybe use a Lerp to map bone local positions to uv coordinates.

#

With your approach its gonna be pretty performance heavy though. Normally custom shaders are used for this kind of stuff.

sly wasp
#

How would you do shaders

#

With this stuff

thorn holly
#

So I have a class, ClassA, and ClassA contains a field of the type ClassB. Each instance of ClassB is a field of an instance of ClassA, and no instance of ClassB is assigned to multiple instances of ClassA. I’m trying to make it so that if you take any given instance of ClassB, it can reference the ClassA it’s a field of. My issue is that I can’t edit ClassB, as I got it from a library. The only idea I’ve come up with is looping through every instance of ClassA and checking if the field contains that specific instance of ClassB, but I feel like that’s really inefficient. Any better ideas?

rough nest
#

i'm a little confused, i have the variables defined publicly but it only lets me use isGrounded?

#

and i have saved the script for the controller

teal viper
# sly wasp How would you do shaders

Ideally, you'd have eyes as a separate mesh rendered by a separate material.
If they're a part of a bigger mesh, you'd need to pass in additional data(probably a float2 would do) to your shader describing the position of the eyes as well as a mask texture defining the area of the eyes. In the fragment shader you would then sample the mask to see if the pixel is in it and if it is, shift the sampling position by an amount calculated from the passed in eye position data.

teal viper
#

If classB is extendible, you can extend it and add a field to reference classA too.

rough nest
#

sorry, should have posted the error as well

ivory bobcat
#

CC has it's own isGrounded

rough nest
#

wait

ivory bobcat
#

It's likely not referring to your isGrounded you posted above

teal viper
#

Where do you have is walking defined?

rough nest
#

i uh, forgot that unity has its own character controller

#

oops

#

yeah, that's why

#

i changed it to my script and it works fine now, sorry lol

amber flower
#

!docs

eternal falconBOT
acoustic sun
#

I am still getting this error: Unity CS2012: Cannot open 'Assembly-CSharp.dll' for writing. This happens when I edit and compiling scrips and this would always pop up. I have moved my files out of OneDrive and put them in Desktop (not connected to OneDrive) but I am still getting that error. I tried to delete the library folder but it won't allow me because Windows swears Assembly-CSharp.dll is being used by something. I was told it was an Antivirus situtation but, its still not allowing me after I made the file clear of any viruses. Is there any other solutions?

teal viper
#

Also, your desktop was under one drive if I remember correctly. That's why I suggested moving the project to C root.

acoustic sun
rugged beacon
#

im on my first project atm, been trying to find a guide on 2d tilemap chunk load as the player moves but cant find anything on youtube, anyone found a guide for this ?

timber tide
#

Does the tilemap not handle a lot of that for you already?

vale cradle
#

hi can anyone please help me

#

I am working on a 2d platformer game and i have made c# scripts for healthbar and health so the problem is that my script's are not giving any error, I have made a private void Update()
{
if (Input.GetKeyDown(KeyCode.E))
TakeDamage(1);
}

#

this

#

in my health script

#

so when ever i press E

#

one heart will turn black but when i am testing it out in unity all my hearts are turning black at once and also my player stopped jumping

#

there is no error showing up in unity either

modest dust
#

First of all !code

eternal falconBOT
modest dust
#

Second of all, show more of it, specifically the TakeDamage method

vale cradle
#

okay

#

can you just check my code?

modest dust
#

First you'd have to send it

vale cradle
#

using UnityEngine;
public class Health : MonoBehaviour
{
[SerializeField] private float startingHealth;
public float currentHealth { get; private set; }

private void Awake()
{
    currentHealth = startingHealth;
}
public void TakeDamage(float _damage)
{
    currentHealth = Mathf.Min(currentHealth - _damage, 0, startingHealth);

    if (currentHealth > 0)
    {
        // player hurt
    }
    else 
    {
        // player dead
    }
}

private void Update()
{
    if (Input.GetKeyDown(KeyCode.E))
        TakeDamage(1);
}

}

modest dust
#

once again, !code

eternal falconBOT
vale cradle
#

i don't understand

burnt vapor
#

Please share your code properly

modest dust
#

```cs
// Code here
```

#

Also you're calling Mathf.Min(currentHealth - _damage, 0, startingHealth);

#

Which will just take the lowest value

#

Which is 0, then -1 on the next call

#

You probably want Clamp, not Min

vale cradle
#

Okay

#

thankyou

#

But my player still isn't jumping

modest dust
#

That's another issue

#

If your player is now damaged properly, then debug what's going on when you're trying to jump

#

First update your code if you haven't yet and check if everything is fine

vale cradle
#

yes

#

i did it but my player just doesn't jump or attack

modest dust
#

Show the code for jumping and attacking

vale cradle
#

yes