#💻┃code-beginner

1 messages · Page 202 of 1

wintry quarry
#

to... get a component reference

river pecan
polar acorn
#

To get the component

hazy crypt
#

I thought so too but I couldnt get it to work before

open apex
river pecan
#

ie [SerializeField]

open apex
hazy crypt
#

this makes some sense

#

they appear to be aligned but some small ero could be causing an issue

polar acorn
#

That's basically it

wintry quarry
# open apex can you read the editted version?

GetComponent vs. inspector reference are two options with different tradeoffs. It just depends which tradeoffs you want to make.
GetComponent means you don't have to drag the reference
But it limits the shape of your hierarchy and which GameObjects the components have to live on.
On the other hand dragging in the inspector is more flexible, but it has the disadvantage that you have to manually do that in every case.

#

Everything in programming/game development is a tradeoff

river pecan
river pecan
#

Does getting the component in the start method slow anything down at all?

wintry quarry
teal viper
#

Though it's probably insignificant, unless you're calling it million times.

wintry quarry
#

but the inspector reference slows the scene loading by probably a similar amount 🤷‍♂️

river pecan
#

ah

rocky canyon
#

when u load up a game no one pays attention to how long the game takes to load..
they care when their frames stutter lol

river pecan
open apex
#

how to close this weird box?

rocky canyon
#

u hit the insert button

river pecan
open apex
#

thanks

river pecan
#

The crossfade seems to change the speed of the animation when it's using animator transitions

rocky canyon
#

normally the fat cursor means <Insert> is on.. and its useful to write over the top of text

#

but also devastating when u dont notice it

river pecan
#

Specifically when I call the attack animation

#

When blocking is going back to an empty state

rocky canyon
#

i dont think its changing the speed per say.. but its blending the keyframes.. so in some cases depending on the animations it may look tha tway

#

you can go and in the clip change the amount of time it take to transition

river pecan
#

That will also change the time the normal transition uses

rocky canyon
#

either manually.. with the or u can drag those little blue handles, as well as the clips, to change how they overlap

#

u can change each transition specifically..

#

each arrow connecting a clip to a clip is its own transistion.. and can have their own settings

river pecan
#

Well the "slowdown" only occurs when going from the block blendtree to attacking

#

When I'm watching the animator in real time

rocky canyon
#

is it an Exittime / no Exittime sort of problem?

river pecan
#

It most likely is

rocky canyon
#

do you need the full clip to play or nah?

river pecan
#

Well it's blocking, it loops when you hold it

rocky canyon
#

like during that specific transition.. u may could make it have exit time

#

so the clip will finish completely..

rocky canyon
river pecan
#

Let me give some mroe context

rocky canyon
river pecan
#

Blocking is the only animation that has a transition that can be interrupted

rocky canyon
#

if it gets interrupted ur transition out of it should probably not have exit time

#

u can still loop it regardless

river pecan
#

It does not have exit time

#

Only transition time

#

0.1

rocky canyon
#

well make it longer?

river pecan
#

That doesn't solve the problem

#

That just makes the attack crossfade slower

rocky canyon
#

ahh.. well idk nuff about that.. never seen a clip speed up for any reason like so

river pecan
#

It slows down

rocky canyon
#

ohh i thought u said it sped up earlier mb

river pecan
#

Oh I see

#

So the problem is

#

BLocking works

#

When you attack while the transition from blocking goes back to the empty state

#

The attack is slowed down

rocky canyon
#

ohhhh, ya, u probably want no transition at all then

#

u probably need it to get back into the attack state as fast as possible..

river pecan
#

Well I'm using crossfade to cancel the attack

#
public class AnimationHandler : MonoBehaviour
{
    public Animator ani;

    public void PlayAnimation(string aniName, bool isInteracting, bool rootMotion, float speed)
    {
        ani.applyRootMotion = rootMotion;
        ani.SetBool("IsInteracting", isInteracting);
        ani.CrossFade(aniName, speed);
    }

}
fleet granite
#

how do i instantiate as the child of the summoner and with a variable offset

wintry quarry
fleet granite
#

thanks

carmine sierra
#

I have two sprites which rotate towards the mouse, how do I make it so they both stretch until they reach the mouse

#

I can show my current script, but I am currently lost

west obsidian
#

If Im making something like a conveyor belt to move an object that is touching it, is it best to

  1. add a small amount to the position every fixed amount of time
  2. set the velocity of the object to a certain amount
  3. add a force to the object
open apex
#

Does anyone have an idea what is wrong in this code?

rich adder
slender nymph
#

if you look in the setting it's telling you to, do you see an axis called Horizonta; set up?

open apex
#

nvm

rich adder
#

The name of the axis

summer stump
#

Horizona is what you wrote

rich adder
#

Hotrizona

open apex
#

capsuleMan is working now 😁 😁

carmine sierra
open apex
#

I am done learning today

#

I will be back tomorrow to bother you more (thanks for the help everyone)

carmine sierra
#

I don't know how ill calculate the fraction it would need to be according to the distance to the mouse

#

is it easier to just use a line renderer compared to transforming the sprites

summer stump
#

What is the sprite supposed to be?

carmine sierra
#

current sprite is just a square

#

of one colour

#

I wanted an outline but it doesn't work due to the stretching

summer stump
carmine sierra
#

thanks ill try it

summer stump
#

Yeah, I don't really work with 2d much, so I'm not sure how to deal with sprite stretching though, sorry

#

And no prob!

carmine sierra
#

out of curiosity do you have any games out

#

I wanna try

summer stump
carmine sierra
#

when you gonna publish then

#

or is it a hobby

summer stump
carmine sierra
#

you a software engineer or something then?

west obsidian
#

If Im making something like a conveyor belt to move an object that is touching it, is it best to

  1. add a small amount to the position every fixed amount of time
  2. set the velocity of the object to a certain amount
  3. add a force to the object
summer stump
#

I'm a bookkeeper. I have been messing with game dev for about a decade though

carmine sierra
#

oh damn

#

like accountant?

summer stump
# carmine sierra like accountant?

No, but getting a degree in accounting right now actually. A CPA requires a masters at least though.
But I should probably stop talkin about all this, as it is off-topic

carmine sierra
#

fair

#

my mums also getting into accounting, do you think it has a future considering AI?

summer stump
carmine sierra
#

id hope so

#

otherwise software engineering is down the drain

#

the salary will probably be shit regardless..

summer stump
carmine sierra
#

as it is now is fine, thats why people still have their jobs

#

and ai is a machine not a tool

#

machines in factories take most jos

#

jobs

rocky canyon
#

ai is a tool

shell sorrel
#

you are so overstating it

rocky canyon
#

lol..

#

but its facts

carmine sierra
#

fr?

shell sorrel
#

this is not the first thing people said would take all the jobs nore the last

carmine sierra
#

it's essentially taken most art jobs

fleet granite
#

how do i script every gameobjects with a tag into an array

shell sorrel
#

just part of the pattern

#

also its not taken most art jobs

rocky canyon
#

nah, its taking less than mediocre artists jobs

#

and created millions more in its place

shell sorrel
#

also also not going to take programming jobs either, will fall victim to the same problem all the low code soultions of the past had and cobol

summer stump
rocky canyon
#

we'll just be faster

#

its a great tool tho, we can use it to speed up our discovery process

#

in every field imaginable

shell sorrel
#

and accouting, it cant even do basic math, and hallucinates things that dont exist

#

not ideal for that, also accounting and law are slow to change the very conservative in how they operate

rocky canyon
#

hehe, chatgpt definately been abusing ole sparky tripping half the time we speak

summer stump
west obsidian
turbid steppe
#

Unity VR beginner here: (SOLVED)

How would I print out what direction the user is pressing on the trackpad.

I have tried these and none work:

    Debug.Log(turn.action.ReadValue<Vector2>());
    Debug.Log(turn.action.ReadValue<float>());
    Debug.Log(turn.action.ReadValue<bool>());

I am using this as a reference:
XRI RightHand Locomotion/Turn (Input Action Reference)

This is what I use as my turn reference and it works.

SOLUTION:

I found out I needed the primary 2D axis. You can find what inputs the controller is making by going to Window > Analysis > XR Interaction Debugger

summer stump
west obsidian
west obsidian
#

I dont find any gratification in the creation of a piece from a text prompt

#

it is not creative, it is plagiarism of other's work

shell sorrel
#

Art has a lot of tedious things in it, if it can help with that, it will be great

carmine sierra
summer stump
carmine sierra
#

it isn't perfect yet for art

shell sorrel
#

but its not replacing proper visual design and its nearly impossoble to get the ai art to work with the technical aspect if your game and its limitations

rocky canyon
turbid steppe
west obsidian
#

I dont feel like we should keep training models for art, art is a form of personal expression, I dont like the idea of something that tries to "automate" that

rocky canyon
#

Down with Skynet!

summer stump
rocky canyon
shell sorrel
turbid steppe
rocky canyon
#

so it must be the input..

summer stump
rocky canyon
#

it must be zero..

#

yea b/c i dont know nothing about the VR inputs

#

turn. w0t?!

shell sorrel
#

also its going to be self consuming , once it starts using ai art all over the internet as training data things will get worse fast with its quality

west obsidian
#

Like I think a tool like auto-colour or ai used to remove backrounds isnt that bad

summer stump
summer stump
rocky canyon
#

ai isn't always gonna be text prompt -> draw a picture.. if ur gonna compete in any area in the future you'll want to adopt what it becomes

west obsidian
#

I more so dont love when you ask for a view of a sunset and it adds in the silhouettes of some people sitting next to eachother as a creative touch

teal viper
west obsidian
shell sorrel
#

like with my work, it took me a week to teach the artists how to make content for our game, because it does a lot of shader trickery for getting extra varration and keeping memory down. there is no way it could be done with prompts to a machine that only understands patterns in language and not the logic and reasoning

west obsidian
#

I can see your point

#

I just worry about the fact that some people try to use AI to come up with the ideas and execution of those ideas from scratch

#

Idk I dont have all my opinions solidly formed

rocky canyon
#

hey, AI can write a captivating story line..

#

with a little guidance ofc

#

i suck at that.. sooo if it can fill in the gaps of my game w/ interesting cutscene narrative stuff, so be it

shell sorrel
#

also worries about AI taking over programming for example, think will hit the same problem as low code langauges meant to bis people to write. which is they dont know how to write a requriement

#

and english is not a very explict langauge for communicating logic

west obsidian
shell sorrel
#

so then it kinda falls back on the best people to do this are the ones that specialized into it

teal viper
#

Honestly, ideas are cheap. Implementation is the important part.

rocky canyon
#

i consider that mine but ya.. i perhaps could put a shit story in there

teal viper
#

However original idea you might have, someone probably already thought about it.

west obsidian
shell sorrel
#

often what seems like orginal ideas are came up with by muliple people around the exact same time frame, it has happened alot with important inventations

#

its because once the requirements are meant, people see the new ways to build on old ideas

west obsidian
#

thats fair, Idk I think Im just a bit robot-discriminatory

rocky canyon
#

supposedly its original tho, I've never heard the story my game plans to implement. Its basically the narrative, and story stucture that i was after

teal viper
rocky canyon
#

#LivingInaSimulation ?

summer stump
#

As picasso (may have) said: "good artists borrow, great artists steal."

rocky canyon
#

lol, and ocean 11 uses theft as an artform

shell sorrel
#

really a lot of great ideas and approaches to things often end up being old ideas twisted and applies to new things

#

do i have to go back a few hundred years and credit everyone in that chain

carmine sierra
summer stump
oak mist
#

Yo i have a question. I dont know if this goes under coding or simulation, but i have this asset im trying to give movement to. But when i run the game it just spins around and flies off. It can still be controlled, and the torque does help a little, but im so confused. This only happens when the asset is a rigid body, if it isnt it behaves normally

oak mist
#

Here are the parameters ive used

summer stump
#

!code

eternal falconBOT
summer stump
#

That is a good amount of thrust, but I guess it's a spaceship, so that should make sense

#

Although, it is a comparatively tiny amount of mass

oak mist
#

over the limit so ill do it in chunks

summer stump
#

use a paste site

#

Don't post it as text here

oak mist
#

oh yh mb

rocky canyon
oak mist
rocky canyon
#
    [SerializeField] LineRenderer thisLine;

    void DrawLine(Vector3 first, Vector3 second)
    {
        thisLine.SetPosition(0,first);
        thisLine.SetPosition(1,second);
    }```
oak mist
#

heres the mapping for the controls also

summer stump
# oak mist Here are the parameters ive used

Have you tried reducing any of these parameters. You add 20newtons of relative force (scaled by deltaTime at least) every frame you have the OnTilt input, I wonder if that's just too much?

oak mist
#

yh so far its at 10 and 20

summer stump
#

But yeah, a rigidbody means it will react to forces. Where is gravity pointing?

summer stump
oak mist
#

but when its at 10 and 20, its doesnt rotate as much

#

but it still succums to constant rotation

#

ill increase the weight

#

damn i cant say weight/g

#

mass

#

oh nvm

carmine sierra
rocky canyon
#

u can modify the positions as u need to before u pass them into the line renderer

#

like setting w/e axis ur not using to be 0 for example

#

and use w/e material u'd like to make it fit the style.. (turn of its shadow too, u dont need those if its not a 3d space)

carmine sierra
#

cause it's a line renderer

rocky canyon
#

the transform wont, it'll be inside hte component

#

the Positions of the LR

carmine sierra
#

yeah i found it thanks

#

is there any rotation though?

rocky canyon
#

theres an alignment

#

im not sure but i think u can set it to be the transform Z and then rotate gameobject

frigid sequoia
#

Can I get information from a Particle System such as when all the particles form a pulse have dissapeared or do I have to rely on just the time the particle system has been playing?

carmine sierra
#

damn well ill just try tomorrow then

#

thanks for the pointer

verbal dome
#

Is that enough?

frigid sequoia
#

Probably I am being like way too specific with this questions, I think I can work just with the isAlive with a few simple workarounds

verbal dome
#

Not sure if that is possible

#

Could use multiple particlesystems though

night mural
supple wasp
#

Hello, how can I do this? It always works when I go to one scene and return to another, the scene does nothing.


public class GameManager : MonoBehaviour
{
    private static GameManager instance;

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject); // Evita que el objeto GameManager sea destruido al cargar una nueva escena.
        }
        else
        {
            Destroy(gameObject); // Destruye el objeto si ya existe una instancia del GameManager en otra escena.
        }
    }

    // Aquí iría el resto de la lógica del GameManager
}
summer stump
#

Do you have anything else that goes onto DDOL?

supple wasp
#

Yes, the scenes don't do anything when I leave and come back, the only thing they do is play the music.

summer stump
supple wasp
#

not just that

summer stump
# supple wasp not just that

noT just that? Or is that a typo? Haha. I'll go forward thinking you meant no just that.
This is kinda tough. I don't really have any info to go on here.
Can you show a screenshot of the editor when you first start the scene, and one when you start it for the second time

supple wasp
#

Look, I have the test project already done. I can show it so you can see it.

#

here is the game just do what I say go to the play button it's the green one and then move in the game with the W S A D then press ESC and exit it's the red button and do the same thing again and you'll see what I'm saying

#

To exit from the beginning, press the red button

cobalt creek
#

So i have game where it allow user to get server infos to connect to, and allow them to display city and country of server. what is good way to stop user from spamming http requests to get that data?

cobalt creek
#

a cooldown?

teal viper
#

A cooldown

cobalt creek
#

ok

teal viper
#

After making a request, don't let them make the request again for some time.

cobalt creek
#

thank, that seems like a good solution

supple wasp
#

When am I going to fix this problem...

summer stump
#

I am on my phone, so I can't download your project file.

#

If you want, you could do an .mp4 I guess

supple wasp
#

I don't have nitro

summer stump
#

I don't have nitro either

teal viper
#

You can upload a video if it's below 8MB afaik.

supple wasp
#

but to send the video

summer stump
#

But yeah, you can upload videos without nitro

#

I've done it many times and people do it here every day

fierce shuttle
#

If the video file is larger than 8 MB, theres also a nice site called "streamable" that lets you upload video files I think up to 25 or 50 MB (dont remember the limit, but its higher than discords)

supple wasp
#

Everything is normal, right?

#

but when I go again

summer stump
#

The hierarchies are collapsed on most of those images. Seeing that was the whole point of asking for the images

supple wasp
#

does nothing

supple wasp
summer stump
#

Click the little arrow...

supple wasp
static cedar
summer stump
#

And that isn't during runtime 😭
But honestly, with names like GameObject(4) it'll be hard to infer anything important.
I'm just not sure.

Add debug statements in the updates of scripts that should be doing things. See what is running and what isn't

teal viper
supple wasp
teal viper
#

I start thinking this is trolling...

supple wasp
#

what

summer stump
# supple wasp

Ok, nothing is lost in that first scene. Good good. Nothing looks to be duplicated either. But yeah, that third picture has the scene collapsed again
I recommend doing what I said above, adding debug.logs around and seeing what isn't being called

teal viper
#

Unless they wanted to see the DDOL scene...

polar acorn
#

What is the actual issue that is happening

#

I came in late

summer stump
polar acorn
#

Oh it's one of those questions.

#

Nevermind I'm going back to Yakuza you guys have fun

teal viper
#

I'm unrelated. Aethenosity seems to be helping them.😛

summer stump
#

I have accounting homework due at midnight! I'm only procrastinating while I take a break for my brain to not melt
I gave an answer imo. Debug it. Not much I can do from my side

supple wasp
#

Let's see those who have a PC want to try the game, I have one of the tests, I can pass it so you can see what I'm saying.

teal viper
#

Most people here are busy. I'm at work for example. You shouldn't expect random people from discord to be testing your game. You should do it yourself or hire testers.

night mural
#

It would also just be unwise for anyone to download your random exe and run it on their computer

delicate bane
#

for 2d how can i find the pos inside canvas?

magic lake
#

!bugs

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

rich adder
delicate bane
#

position

#

for x and y

rich adder
vale karma
#

@teal viper i found a fix for the timing or transform y position to fix the states alternating so quick what do ya think? ``` public override void UpdateState(PlayerStateManager player)
{
playerMovement.RigidbodyMovement(baseSpeed);
bool fallStateChange = false;
if (playerMovement.IsFalling())
{
fallStateChange = true;
}
Debug.Log(fallStateChange);

    if (playerMovement.IsGrounded() && fallStateChange)
    {
        player.SwitchState(player.WalkState);      
    }  
}```
    {
        Debug.Log(rb.velocity);
        if (rb.velocity.y < Vector3.zero.y)
        {
            return true;
        }
        else
        {
            return false;
        }
    }```
tawdry mirage
#

is there something like Mathf.Approximately but with settable fluctuation?

gaunt ice
#

i think no
write it yourself

public bool MyApproxmiately(float a,float b, float threshold=1e-5)
teal viper
vale karma
#

i tried to find our previous conversation about why the movement state machine would jump more than once, due to it reentering the state multiple times from the IsGround check still returning true. One fix i had and the other person offered was the timing method to add a fraction of a second buffer before being able to jump again. and yours was something along the lines of velocity Y or something, but i forgot.
But this seems to only change the bool when the rb velocity.y is negative, then doesnt change it again until it leaves the state. Then recreates the variable with the value of false again once its entered

bright zodiac
#

here's unity's

        // Compares two floating point values if they are similar.
        public static bool Approximately(float a, float b)
        {
            // If a or b is zero, compare that the other is less or equal to epsilon.
            // If neither a or b are 0, then find an epsilon that is good for
            // comparing numbers at the maximum magnitude of a and b.
            // Floating points have about 7 significant digits, so
            // 1.000001f can be represented while 1.0000001f is rounded to zero,
            // thus we could use an epsilon of 0.000001f for comparing values close to 1.
            // We multiply this epsilon by the biggest magnitude of a and b.
            return Abs(b - a) < Max(0.000001f * Max(Abs(a), Abs(b)), Epsilon * 8);
        }
tawdry mirage
#

thanks!

bright zodiac
#

if you're going to use for values that far greater than epsilon, proly just use bigger/less ternaries instead

noble summit
#

how do i make a script that will crash the application (not close, i need it to show up as a crash)

static cedar
#

Gonna make one of those very bad endings where the antagonist breaks the world. :0

gaunt ice
#

why?
btw many ways

List<int> list=new(){1};
while(1){
  list.AddRange(list);
}
north kiln
rich adder
#
{
    for (int i = 0; i < 99; i++)
    {
        Instantiate(gameObject);
    }
}``` also works
#

holy sshit this function doesn't fuck around 😆
Utils.ForceCrash(ForcedCrashCategory.FatalError);

#

crashed my whole unity

#

UnityChanThink silent quits exe though, no UI errors on build

fiery notch
#

hello, i have a problem with my screenwrap, the player and the "asteroids" prefab screenwrap, but my "UFO" prefab spawns correctly, but doesnt screenwrap, what could i be doing wrong

eternal falconBOT
#

mad No

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

rich adder
#

!code

eternal falconBOT
fiery notch
#
 void Update()
    {
        float yPosition = transform.position.y;
        Debug.Log("yPos:" + yPosition);
        //doing this allows for the screen to wrap with no regards to screen aspect ratio
        Vector3 viewportPosition = Camera.main.WorldToViewportPoint(transform.position);

        //need the ship to wrap on the opposite side it came from
        Vector3 moveAdjustment = Vector3.zero;
      
        if (viewportPosition.x < 0)
        {
          
            moveAdjustment.x += 1;
            
        }
        // need to have the opposite, so if you go the other way, then you will wrap around as well, this prevents you from always spawning on the same side
        else if (viewportPosition.x > 1)
        {
            
            moveAdjustment.x -= 1;
        }
        //this is essentialy the same as left and right screens, except swap out X for Y since you are working with the top and bottom screen.
        else if (viewportPosition.y < 0)
        {
            
            moveAdjustment.y += 1;
        }
        else if (viewportPosition.y > 1)
        {

            moveAdjustment.y -= 1;
        }
      
        //the reason for doing this method of screen wraping, is to cover for the possibility of hitting two screens at once, such as a corner.

        transform.position = Camera.main.ViewportToWorldPoint(viewportPosition + moveAdjustment);

        transform.position = new Vector3(transform.position.x, transform.position.y, 0);

    }
rich adder
#

sheeesh..links would've been nicer

fiery notch
#

does that work better, sorry didnt realize how long it pastes out

rare basin
#

wait

#

from where did you get that code

#

i swear 1000% different user yesterday had exactly the same code 1:1

rich adder
rich adder
fiery notch
rich adder
#

just the spawning?

fiery notch
#

they are nearly the exact same code

languid spire
#

you are moving your Asteroid and UFO using rigidbody so your ScreenWrap should not set transform.position

wraith wadi
#

when i load my scene in unity i want some buttons to be at 150 transparency and when i hover mouse on them then transparency should be 255.
i can do this in inspector but how can i do it via script?
i never worked on UI before in unity so i don't know much about it.

vast vessel
#

how do i generate X evenly spaced vector3 positions, on the circumference of a circle, considering the origin, radius and normal vector of the circle?

eternal needle
gaunt ice
#

rotate the radius vector

scarlet skiff
#

any better ways of changing the size of a gameObject during run times? (without using scale)

 Vector3 newSize = new Vector3(2f, 2f, 2f);
 AdjustColliderSize(newSize);
ivory bobcat
#

What's wrong with scale?

rare basin
#

define size

#

size of UI game object? width/height?

#

or what

ivory bobcat
#

I think you meant.. "Can I change the scale of a game object in scene without modifying the scale property of Transform?".
It would be dependent on what you're trying to do. If you're just wanting it to look visually smaller, you could probably shrink the renderer or some other strange hack..

rare basin
#

well i think they meant to change collider size

#

as the function name suggest it

#

and he's trying to do that by modyfing the scale of the game object the collider is on

#

if so there is Collider.size you can set

scarlet skiff
#

was wondering if there was some method from some package or libarary i could use

rare basin
#

width, height is for UI elements

#

so you cannot change "width and height" for "normal" (transform) gameObject, only for rect transforms

#

what are you trying o do

scarlet skiff
#

dang

#

laser shooter moves in the ax axis a random amount of distance, but before it does so a "danger area" (just a red rectabgle with an animation, which has animation event that sets a bool in the laser shooter to true). problem is i want the danger area to be the same X size as the shooters total travel distance

#

currently the spawner spawns the shooter, which spawns the danger area, and once said bool is set to true, then the shooter does its job and shoots the laser

rare basin
#

i didint understand anything

#

but if it's a transform, then all you can do is modify the scale

scarlet skiff
#

There is a laserShooter, it shoots laser.
This laser shooter comes from a spawner, called a laserShooter Spawner.
the laserShooter, once instantiated by the laserShooter spawner, does the following:
Spawn a big red rectangle (called danger zone)
the danger zone has an animation, once its played, a bool value in the laserShooter script is set to true
Once that value is true, the laserShooter starts moving, and then shoots out (instantiates) a laser

the danger area is supposed to be covering everything from top to bottom in the Y axis, but the x axis its szie is suppsoed to be the same as the laserShooters travel distance.

meaning if laserShooter spawners decides to spawn a laserShooter at x = 5.4. then the danger area should start at 5.4

Then the laserShooter decided a random distance to travel, say 3.
then the size of the danger area should be 3, from 5.4 to 8.4

#

modifying the scale bases the new size on the original size of the dnager area prefab, since scale is a % increase, so it would be hard to make it work

#

unless maybe danger zone x size starts at 1? idk

#

or maybe i hsould just make the laserShooter spawner spawn the danger area too

noble summit
#

what is a good free program to make UI

scarlet skiff
#

not a code question
use photopea.com tho, not a program but basically a free version of photoshop, it works quite well

opaque knot
#

How do you find the point your camera is focusing on? I'm using an orthographic camera if that helps.

languid spire
#

wdym? Cameras don't focus on a point

timber tide
#

You got a point, a direction, and the camera's frustum.

#

which you can derive a focal point from

earnest atlas
#

Can rayhit accept multiple LayerMasks?

hexed terrace
#

yes

teal viper
#

One layermask. But you can combine several into one.

night sparrow
#

Whats this error mean?

Please change the script to derive from MonoBehaviour or remove it from the GameObject 'NameTag Parent'.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)```

Im so confused as the script looks correct from what I can see!

```c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FaceObjectToCamera : MonoBehaviour
{
    void Update()
    {
        transform.LookAt(Camera.main.transform);
    }
}
teal viper
hexed terrace
#

You're a tyrant

teal viper
#

Mobile keyboard is a tyrant

night sparrow
hexed terrace
#

screenshot the error in the console

earnest atlas
night sparrow
gaunt ice
#

bitwise or

hexed terrace
night sparrow
#

its repeated 3 times, from trying to save but idk why this is happening

earnest atlas
#

You have a script that is not derived from Monobehav

teal viper
# night sparrow

This script looks invalid. Take a screenshot of the script asset inspector.

hexed terrace
#

what's the file name

night sparrow
#

in unity Project its called
FaceObjectToCamera

ivory bobcat
night sparrow
ivory bobcat
#

Script named '' (blank)

hexed terrace
night sparrow
#

Errors still

Error while saving Prefab: 'Assets/Resources/Player.prefab'. You are trying to save a Prefab that contains the script '', which does not derive from MonoBehaviour. This is not allowed.
Please change the script to derive from MonoBehaviour or remove it from the GameObject 'NameTag Parent'.
UnityEditor.SceneManagement.StageNavigationManager:Internal_SaveCurrentStage ()
hexed terrace
#

you have tried restarting Unity, yeah?

night sparrow
#

Yep

#

I also cant save due to this

hexed terrace
#

remove the component, so you can save and close the prefab
open the script in VS, select all and copy
delete the file from Unity

#

create a new one, paste in the copy

night sparrow
#

Okay

#

Thanks

sweet meadow
#

I downloaded a character asset from the asset store and pulled a prefab from the folder and put a rigidbody marked as "Is Kinematic" and made a small script to make him jump up only, but he won't jump. The code is so simple and works on primitive objects, does anyone have an idea, I can't seem to figure it out.

rare basin
#

maybe show the code?

#

we're not wizards 😄

sweet meadow
#
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.AddForce(Vector3.up * 500, ForceMode.Impulse);
    }```
hexed terrace
#

!code learn how to format code properly on here to make it readable

eternal falconBOT
hexed terrace
#

You're only doing the AddForce in Start() .. sooo.. how many times do you think this will happen, and when?

sweet meadow
#

I had more complicated code but i just wanted to jump immediately on start to test

#

also just one giant jump

hexed terrace
#

Oh, you made it kinematic, untick that

sweet meadow
#

oh that doesnt register forces

#

woops

#

Thanks

night sparrow
#

Whats this error never had before ```c#
'Gun' AnimationEvent has no function name specified!


```c#
    [Header("Animation")]
    public Animation animation;
    public AnimationClip reload;```
arctic ibex
#

Okay so I have a pretty simple game with a lasso/swing mechanic, but I want the movement to be based on the current rotation of the object, so how would I go about:

  1. Rotating the object based ont he distance joint and
  2. Moveing based on object rotation

Gif one is what it's like right now, gif 2 is what I want it to be like

#

All I would really like is some links to relavant unity doc as I like figuring things out myself, I just have no clue where to start with the rotation based things

hexed terrace
#

I would look at RotateAround

timber tide
#

probably some specific tutorials around for it honestly

#

considering the wave of grappling hook games made recently

limpid wren
#

So clearly there are a lot of methods I could use to transport data between scenes. Static classes, dontdestroyonload etc. But are there any considerations or pitfalls I should take into account when doing this?

At the moment I'm mostly interested in transporting something like the game result to the score scene. (Like who won, damage dealt type things)

timber tide
#

all you need is dontdestroyonload

#

for singletons, otherwise static is fine

hexed terrace
#

One consideration is that you have to deal with the tidy up, the unloading of classes that are no longer needed/ shouldn't be around any more

limpid wren
#

I'm not sure I see the benefit of dontdestroyonload over static classes

timber tide
#

well, the benefit is singleton vs static

limpid wren
hexed terrace
#

Yes, keep things tidy

#

You'll still need to reset the class to what it should be at the start of the game/ round

limpid wren
#

It's a bit antipattern but I figured if I used a normal singleton I could just replace the instance every run

timber tide
#

not really anti, it's one of the reason you use a singleton over static

arctic ibex
arctic ibex
limpid wren
timber tide
hexed terrace
arctic ibex
#

not swinging with the rope

hexed terrace
#

The first thing I'd do, in that case, is ... not implement the looking at the mouse code

rare basin
#

why is the variable names not showing up in the inspector?

  public Navigation insideInactiveNavigation;
  public Navigation insideActiveNavigation;
languid spire
#

show code for Navigation

rare basin
#

it's unity's navigation

#

for selectables

languid spire
#

That would be a bug in the Navigation editor

rare basin
#

:/ ok so it's safe to assume that the upper Navigation in the inspector

#

is insideInactiveNavigation;

#

right

languid spire
#

yes

rare basin
#

alr

#

ty

vast vessel
#

Hey guys. Im trying to subscribe to the agent.health.Die() method but i cant. It says that its a method group so it cannot be assigned.
I dont get what the issue is.

agent.health.Die += targetAgents.Remove(agent)
fallen lodge
#

So I have this script attached to a camera in my scene, and I'm trying to just render a single frame and take a screenshot of it essentially, but how do I actually go about running the script? The scene is too complex to render more than one frame without freezing unity, so I just need 1 frame rendered

using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Camera))]
public class SnapshotCameraScript : MonoBehaviour
{

    // Take a "screenshot" of a camera's Render Texture.
    Texture2D RTImage(Camera camera)
    {
        // The Render Texture in RenderTexture.active is the one
        // that will be read by ReadPixels.
        var currentRT = RenderTexture.active;
        RenderTexture.active = camera.targetTexture;

        // Render the camera's view.
        camera.Render();

        // Make a new texture and read the active Render Texture into it.
        Texture2D image = new Texture2D(camera.targetTexture.width, camera.targetTexture.height);
        image.ReadPixels(new Rect(0, 0, camera.targetTexture.width, camera.targetTexture.height), 0, 0);
        image.Apply();

        // Replace the original active Render Texture.
        RenderTexture.active = currentRT;
        return image;
    }
}```
languid spire
#

AI Code?

hexed terrace
vast vessel
#

Its a function in a health script i made that is called when fhe object takes damage and the health value drops under zero

#

That health script is agent.health

languid spire
#

you cannot subscribe to a method

vast vessel
#

What can i subscribe to

languid spire
#

an event or a delegate

languid spire
fallen lodge
#

yep

dusk minnow
#

the image is green above and black in scene, why?..

timber tide
#

I think you have more issues to resolve first if unity is freezing instantly, no?

fallen lodge
languid spire
carmine sierra
#

i did some while loop and my unitys frozen now

#

any idea of how I can fix it

languid spire
#

kill unity

dusk minnow
timber tide
#

dont use while loops ;)

dusk minnow
#

when you do i++ and wrote while a less then 5 or some

dusk minnow
languid spire
dusk minnow
languid spire
fallen lodge
# languid spire ok so somewhere you need to ```cs Texture2D image = RTImage(camera); ```

Well I also had this as a screenshot script, not sure if it'd work easier

using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Camera))]
public class SnapshotCameraScript : MonoBehaviour
{

    Camera snapCam;

    int resWidth = 256;
    int resHeight = 256;

    void Awake()
    {
        snapCam = GetComponent<Camera>();
        if (snapCam.targetTexture == null)
        {
            snapCam.targetTexture = new RenderTexture(resWidth, resHeight, 24);
        }
        else
        {
            resWidth = snapCam.targetTexture.width;
            resHeight = snapCam.targetTexture.height;
        }
        snapCam.gameObject.SetActive(false);
    }

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

!code

eternal falconBOT
fallen lodge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Camera))]
public class SnapshotCameraScript : MonoBehaviour
{

    Camera snapCam;

    int resWidth = 256;
    int resHeight = 256;

    void Awake()
    {
        snapCam = GetComponent<Camera>();
        if (snapCam.targetTexture == null)
        {
            snapCam.targetTexture = new RenderTexture(resWidth, resHeight, 24);
        }
        else
        {
            resWidth = snapCam.targetTexture.width;
            resHeight = snapCam.targetTexture.height;
        }
        snapCam.gameObject.SetActive(false);
    }

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

so how do I go about running the script so that it takes a screenshot?

languid spire
#

I already told you

fallen lodge
languid spire
#

yes, that is what you need to run the method

#

put it where you want the screenshot to happen

fallen lodge
#

I mean I just need it to run whenever really, just once

languid spire
#

but when?

fallen lodge
#

Well if I run the game, it'll just freeze on me, which is why I need it to render a single frame and then quit

languid spire
#

that makes no sense

fallen lodge
#

it just has too many components and such

limpid wren
#

What in the world

carmine sierra
languid spire
#

you're still not making any sense, at which point in your game do you want to take a screenshot

fallen lodge
limpid wren
carmine sierra
timber tide
#

what

carmine sierra
languid spire
#

and how would that help?

timber tide
#

I guess just do it in edit mode then

fallen lodge
#

the issue with that is it looks like poo if I just take a screenshot in edit mode

limpid wren
fallen lodge
carmine sierra
#

it is like it is angled towards the points but moves 3d around it

timber tide
#

seems fine to me, if anything force it to render on top

limpid wren
#

I'm still not sure what you mean. You're talking about the slingshot strings, right?

limpid wren
#

at what point do you think it "switches directions?"

carmine sierra
carmine sierra
#

but you see how it looks 3d though?

timber tide
limpid wren
#

Yeah, is that not intentional? You only want the strings to go on the left side of the slingshot?

#

Your slingshot is 2 sprites

carmine sierra
limpid wren
#

so I assumed it was intentionally set up this way

fallen lodge
carmine sierra
#

I want it to look like a 2d line

limpid wren
#

Are you talking about this right here?

carmine sierra
#

no

#

im saying it looks 3d

limpid wren
#

It's two 2d lines

#

attached to different points

timber tide
#

I think technically it does change z because there's no 2D linerenderer, but with that being said, technically everything that's drawn to your screen is 2D

limpid wren
#

sorting layer changes where the lines are drawn, what is in front of what etc

#

but the reason your lines and slingshot look 3d is because they were drawn in perspective

#

as opposed to the ground

carmine sierra
#

how can i fix that?

timber tide
#

if both points were the same it would be a line

limpid wren
carmine sierra
#

there is no sprite

#

it is just a line renderer

limpid wren
#

The slingshot is a sprite and is drawn in perspective. You attached two lines to the two points on the slingshot, which has perspective

twilit heart
#

hey (fixed camera system here like res evil)
i have 6 cinemachine virtual cameras that trigger based on player hitting a collision mesh with the cinmeachine triggeraction turning on the virtual camera the player is in
but its really very painful to set up when all i really want to do is switch on the virtual camera when its inside the cameras view
is there a way to achieve this? as it will make my life much easier by just placing cameras in the best shot views
I saw some discussions about camera ways of doing this with GeometryUtility.CalculateFrustumPlanes but i am unsure how to do this with a cinemachine virtualcamera

limpid wren
#

if you wanted no perspective at all, only 2d, you would need only one line and the slingshot would be drawn from the side perfectly

rare basin
twilit heart
#

chat gpt is recommending generating it from the virtual cameras camerastate lenssettings OrthographicSize, FieldofView etc but i dont much about it to judge its recommendations

fierce shuttle
twilit heart
#

but wont the camera currently be pointing elsewhere?

fierce shuttle
#

Though tbf, I feel like your current approach is certainly the easiest way, have a script on a box collider that takes the cinemachine camera as reference, and disable your active camera for the referenced one when they walk in the trigger, turn that into a prefab and place them where youd like it to start, you can still pose the camera however youd like, youd just also have to position a trigger zone when you want it to activate

fierce shuttle
twilit heart
#

oh great ill look for that then

faint osprey
#

im getting this error message when trying to use the destroy method and i dont know why Destroying assets is not permitted to avoid data loss.
If you really want to remove an asset use DestroyImmediate (theObject, true);

fierce shuttle
# twilit heart oh great ill look for that then

GL - another approach you could try is maybe using a boxcast or several raycasts at the position and rotation of your cinemachine objects, though if you have 2 cameras pointing in a way that the casts could cross eachother, that might cause unexpected results with both cameras "fighting" to change the camera, though the same could happen with a frustrum "in view" check too, a non-problem if your cameras are placed strategically

fierce shuttle
faint osprey
mortal bridge
#

Hello my dear gigachad helpers who help without getting a single dime because they love helping people.

How can I use transform.Around in different places such as (top of the around object, midldle of th earound object, bottom of the around object)

limpid wren
#

You mean "RotateAround"?

mortal bridge
#

Yes majesty. transform.RotateAround

limpid wren
#

The first parameter is the point you want to rotate around

hexed terrace
#

put empty gameobjects as children of the main object, then rotate around them

limpid wren
#

That is the easiest way to find the point you want to rotate around yeah

rare basin
#

for it

shell sorrel
#

iirc there is a rotate around point as well

rare basin
#

everyhing explained

shell sorrel
#

though if always wanting to do it from a certain position i would jsut make it a child of a other object

#

and rotate the parent

mortal bridge
#

I've already read this sir. It is good I learned I could put empty gameobjects as children

limpid wren
#

This line should explain it:
transform.RotateAround(target.transform.position, Vector3.up, 20 * Time.deltaTime);

The first parameter (target.transform.position) refers to the point you want to rotate around

#

So either you yourself figure out where that point is, or you just place an object there

mortal bridge
#

Can I ask one more question please?

limpid wren
#

Then you use myObject.transform.position as the first parameter.

shell sorrel
#

you can figure out where that point is from the bounding box of the object as well

limpid wren
#

Absolutely friend

mortal bridge
#

https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html

this website link dear Xaxup sent says:
public GameObject target;

Do I have to get gameObject's children to assign it in Update? for Instance:

public GameObject targetChildren;
transform.RotateAround(targetChildren.transform.position

or

I assign this script to child of the parent

limpid wren
#

So the "target" can be anything. It refers to the thing you want to rotate around.

#

If you make it "public" or use [SerializeField] a slot shows up in the editor

mortal bridge
#

so It can be the child sir?

mortal bridge
limpid wren
#

mm, if it is the child that object will move too

#

Which is probably not what you want

#

Or, it could be?

mortal bridge
limpid wren
#

So if you set it like this

#

You can just use that gameobject in your code. In my case it would be "myTarget.transform.position"

rare basin
#

cringe

mortal bridge
#

I achieved what I wanted to thanks to your help and time sir. @limpid wren I wish you and your family well.

shell sorrel
limpid wren
#

It's true, that would be faster. But might just be a tad more difficult to understand

#

Why is getting the transform so slow anyway, you'd think they would cache it

shell sorrel
#

think it does the full round trip from native to managed

#

but either way its just more code and doing a step that is not required

limpid wren
#

Also transform.position is apparently quite slow if you're calling it a lot.

shell sorrel
#

really there is no reason to get or write to it more then once per frame

#

get the pos, do everything you want to it, write it back

#

its slow for 2 reasons the managed to native thing, but also setting world position involves walking the whole chain parents

hybrid sundial
#

transform.Translate(transform.forward * speed * Time.deltaTime);i dont see how this works cause how will this move forward if the transofrm.forward is 0 cause anything times 0 is 0

rare basin
#

transform.forward cannot be 0

#

it's a direction

hybrid sundial
#

0,0,1

rare basin
#

yup

hybrid sundial
#

isnt that vector3.forward

shell sorrel
#

yes

rare basin
#

it is aswell

hybrid sundial
#

but then i thought that is your players current transform

rare basin
#

transform.forward is object's local foward

shell sorrel
#

0,0,1 * 5 for example is 0,0,5

hybrid sundial
#

would it not be that

shell sorrel
#

so its fine

rare basin
#

Vector3.forward is the unit vector defined by (0, 0, 1) transform.forward is the forward direction of the object in the world space

hybrid sundial
#

ok thanks

shell sorrel
#

look at the translate gizmo on the object in the editor

#

transform.forward is where the blue arrow is pointing

#

providing editor is showing local space

hybrid sundial
#

so they are both the same

hexed terrace
#

X to toggle between global/ local

hybrid sundial
#

vector3.forward

#

and transform.forward

#

= same/

hexed terrace
#

they will be the same if the local is pointing in the same direction

hybrid sundial
#

ok ty

rare basin
#

i just explained it yo you

shell sorrel
#

but differ if you did

hybrid sundial
#

but in what case would you use one over another

#

like is there a case where you would use one

#

and not another

rare basin
#

they are 2 different things

#

what you said doesnt make sense

#

Vector3.forward is just (0,0,1)
transform.forward is the forward direction of the object

hybrid sundial
#

isnt the forward dir 0,0,1

shell sorrel
#

no

#

if you object was rotated 90 degrees on y, it would be 1,0,0

rare basin
#

if i have

shell sorrel
#

its depednent on the objects rotation

rare basin
#

than this is the parent

#

and this is the child

hybrid sundial
#

oooooooooooo

shell sorrel
#

set these to pivot and local

rare basin
#

transform.forward is the object's "looking" direction

shell sorrel
#

transform.forward for a given object will be the blue arrow on the translate tool

rare basin
#

so the blue arrow on the 2nd screenshot is the child's transform.forward

hybrid sundial
#

so vector3 . forward non matter what is 0,0,1 but transform.forward depends on the way the object is facing

rare basin
#

did you actually read

rare basin
#

what i told you

#

If you apply Transform.Translate(transform.forward * Time.deltaTime), the object will move in the rotated direction of the object.

If you apply Transform.Translate(Vector3.forward * Time.deltaTime) the object will move in the postive Z direction regardless of the object’s rotation.

surreal scroll
#

how do i make a gameObject rotate around a certain point in 2D

rare basin
#

did you try google?

surreal scroll
#

yeah i tried but i only found how to rotate it not make it move around a point

surreal scroll
#

tyvm

rare basin
#

literally first link

#

with copy/pasted your question

mortal bridge
#

@surreal scroll

#

RotateAround also makes it move 🙂

surreal scroll
rare basin
#

did you read the docs

#

about RotateAround?

#

it's literally right there

#

This modifies both the position and the rotation of the transform.

surreal scroll
#

yeah i'm reading it right now

mortal bridge
surreal scroll
rare basin
rare basin
#

of the given transform

mortal bridge
#

You have an object. You have another object that will rotate around it.

surreal scroll
mortal bridge
#

Transform is from Unity library

#

you can use it like transform.position or transform.rotation

rare basin
#

again

#

basic skill you need to learn

surreal scroll
#

sorry i forgot

rare basin
#

google will solve most of your begginer journey issues

#

if you don't know what is a Transform component then you should start by doing a basic C#+Unity course !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

surreal scroll
#

ok thank you guys very much i'll come back i don't find it on google

mortal bridge
#

You would assign this script to the object which you want to rotate around another object.

public GameObject yourDesiredObject;: This line creates a public GameObject variable named yourDesiredObject. It's made public so that you can assign the object you want to rotate around in the Unity Inspector. If it were private, you wouldn't be able to assign it in the Inspector.

void Update(): This is the Unity Update method, which is called once per frame. (I think you know it already)

transform.RotateAround(yourDesiredObject.transform.position, Vector3.up, 66 * Time.deltaTime);: Rotates the object this script is attached to around the position of yourDesiredObject. It uses Vector3.up as the axis of rotation (around the Y-axis), and 66 * Time.deltaTime controls the rotation speed. This line is inside the if statement to ensure that rotation happens only when yourDesiredObject is assigned from inspector.

@surreal scroll I wish you happy learning

rare basin
#

perfect spoon feeding

mortal bridge
#

I actually wrote explanations for him which could make it easier to learn sir. I did not give him the direct code.

rare basin
#

how is that not a direct code

#

tf

mortal bridge
#

I think you need to relax sir.

rare basin
#

sir

mortal bridge
#

Someone helped me so I was in debt and I helped someone 🙂 not a big deal.

rare basin
#

helping - okay, spoon feeding - big no no

#

giving direct instructions and step by step guide with direct code - that's not helping

#

he'll just come with more questions

#

help him how to learn things

#

dont do things for him

surreal scroll
#

i wasn't planning on copying code anymore unless if i understand it

mortal bridge
#

I am glad it helped you sir 🙂 As these gentlemen suggest try to understand. Don't copy paste. Happy learning again

#

@surreal scroll

#

Do you understand what transform.position is?

surreal scroll
#

it means change where it is

hexed terrace
#

no it doesn't

mortal bridge
#

yourDesiredObject.transform.position represents the central point or location in 3D space (even in a 2D game) around which the rotation will occur. The position is set by the yourDesiredObject which you assign in the Unity Inspector, as mentioned earlier. For clarity, even in a 2D context, Unity still uses 3D coordinates.

For example, if you set yourDesiredObject to be a sphere GameObject, the object with this script would rotate around the center of that sphere. The term "center" here refers to the point in 3D space set by the yourDesiredObject's "transform position". It acts as the axis or pivot point for the rotation, creating a circular motion around that central point.

hexed terrace
#

it's not the central point, it's where the pivot is

mortal bridge
#

I mentioned it.

rare basin
#

yourDesiredObject.transform.position represents the central point or location in 3D space

#

that is incorrect

hexed terrace
#

I gave up reading after you got said it wrong in the first 6 words

mortal bridge
#

It's not necessarily the geometric center of the object; rather, it's the position in the world space that serves as the axis or pivot point for the rotation. It defines the central point of rotation, but it doesn't imply the geometric center of the object. I tried to make it easier for him.

hexed terrace
#

the center doesn't need refering to/ talking about at all in any of what you said, it's just the pivot

surreal scroll
#

i'm really confused

rare basin
#

for him

rare basin
#

let him learn by tutorials/google

#

and ask certain issues when he has any

#

he didin't ask you for explanations

#

and spoon feeding

hexed terrace
mortal bridge
# rare basin as i said you are only confusing things

When you look at the gizmo for an object in the Scene view, it typically appears at the object's center. This center is determined by the object's pivot point, which is also the default point around which rotations occur. That's why I said that hence making it easier to grasp

rare basin
#

no it doesn't typically appears at the object's center

#

it depends on the pivot

hexed terrace
#

it only appears as the objects center if you have the mode set to that..

rare basin
#

This center is determined by the object's pivot point

#

that doesnt make sense

#

center isn't determinet by pivot point

#

geometrical center*

#

im done talking to you, just stop spoon feeding people and making begginers confused spreading false info

mortal bridge
# rare basin no it doesn't typically appears at the object's center

The gizmo for an objecty is displayed at the object's origin, which is (0, 0, 0) in local space. It may coincide with the center of the object, especially for simple shapes like spheres or cubes, but it is not necessarily at the geometric center. The gizmo aligns with the object's pivot point. "If the object's pivot point has not been moved", the gizmo will typically be at or near the center of the object. However, if the pivot point has been adjusted, the gizmo will be located at the modified pivot point, and sphere will refer to that point in world space for rotation purposes. Since you can't directly move the pivot point of an object using the standard tools I think this is a good explanation 🙂

rare basin
#

relax dear sir

mortal bridge
#

And I need to remind you that this guy is asking this for 2 not 3D 🙂

hexed terrace
#

makes no difference

rare basin
mortal bridge
#

Changing the pivot point in 2D is harder compared to 3D because tools do not provide direct support for manipulating the pivot point of 2D sprites or GameObjects. In 3D, you can manually adjust the object's position to effectively change the pivot point, but in 2D,the process is harder

rare basin
#

but what are you even talking about right now

#

dear sir

surreal scroll
#

i can't find how to assign a gameobject to be the point to rotate around and i looked it up and i couldn't find it

rare basin
#

expose the GameObject variable to inspector

#

and assign it from there

#
[SerializeField] private GameObject objectToRotateAround;
mortal bridge
split crest
#

private AdRequest CreateAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
.AddKeyword("unity-admob-sample")
.TagForChildDirectedTreatment(false)
.AddExtra("color_bg", "9B30FF")
.Build();
}
i am getting this error at .AddTestDevice after updating google ads can anyone help me this
error- AdRequest.Builder' does not contain a definition for 'AddTestDevice' and no accessible extension method 'AddTestDevice' accepting a first argument of type 'AdRequest.Builder' could be found

noble summit
#

what is a gizmo

rare basin
noble summit
#

dude what is this channel for if no one will answer questions

mortal bridge
#

its this

noble summit
#

huh

rare basin
#

google first, ask second

surreal scroll
# mortal bridge What did you do so far?

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

public class lockpickRotation : MonoBehaviour
[SerializeField] private anchor objectToRotateAround;
{
// Start is called before the first frame update
void Start()
{

}

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

}

#

it's giving 8 errors

verbal dome
rare basin
gaunt ice
#
public class lockpickRotation : MonoBehaviour
[SerializeField] private anchor objectToRotateAround;
{
noble summit
mortal bridge
surreal scroll
#

the anchor is the name of my gameobject

#

serializefield is used to make it accesible in the inspector without making it public

undone rampart
surreal scroll
#

can you please dumb it down a little bit for me or explain what those things are

#

i tried looking up what a class name is and i didn't get any wiser

rare basin
#

To through basic unity tutorials and c#

#

You don't understand the given help

gaunt ice
#
        your class name
              |
              v
public class AClass{
}
```!learn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

charred spoke
mortal bridge
#

@surreal scroll My honest suggestion to someone who declares a variable outside of class would be to first go to learn.unity then complete the pathways. It would be better for you in terms of learning. You don't know the basics right now and what people here will say to you there will be better information on Google and it will be easier both on you and people here so they can focus on more important problems that can't be Googled

undone rampart
undone rampart
surreal scroll
#

i changed it to start with an uppercase letter but none of the errors dissapeared

willow nexus
#

i have a list of stats for each enemy AI to have, such as health, maxhealth, followrange etc. All enemies will have the same base AI script, but the values oni t will make it behave differently. (about 30 stats)

would I be better off making different enemy stats a scriptable object, or are they fine to just be public variables of on a stat script that i'd modify differently for each enemy type
or doesnt it matter and could be either

undone rampart
mortal bridge
#

Don't try to do that right now. Its like trying to walk but you have no legs. First have legs by going to learn.unity or any other tutorial

#

and because you have very little basic knowledge what people say here you won't be able to grasp it very much

polar acorn
undone rampart
#

@surreal scroll agent69 is right, you will have to learn the basics for programming before you start actually programming, but if you just want to make your game and dont bother with code there is also the option of using visual scripting, its up to you

mortal bridge
#

these guys tell you class, variable, serializefield etc. if you don't even know what these are you wont be able to get help

mortal bridge
charred spoke
#

🤣

#

I for one miss the days when JonSkeet had everything answered for me in stackoverflow

mortal bridge
willow nexus
#

what in the hell is that shader for

undone rampart
#

thats not a shader

#

is the new york subway map

earnest atlas
mortal bridge
#

This is from Unreal Engine. I have no clue about Unity visual coding

undone rampart
mortal bridge
#

Do people even use Unity visual coding? They must be madmanss

shell sorrel
earnest atlas
#

I like pasta

mortal bridge
meager sentinel
#

Is there any way to place an enter in a text via code? Like i want to make something like this: textexample.text = "Hello i am cool (Enter) goodbye"

shell sorrel
#

like i have worked in unreal before, and it was nice that BP can override virtual methods on my C++, so i was able to leave hooks for the level designer and fx people to tap into

mortal bridge
#

It is a big plus when you can switch quickly between visual and usual code.

undone rampart
meager sentinel
shell sorrel
#

also visaul scripting for more constrained domains is good, like for behaviour trees its great, for shaders it can sometimes be great

undone rampart
meager sentinel
shell sorrel
#

its above the enter key

mortal bridge
meager sentinel
#

Above the enter key is the delete something key

undone rampart
#

this is how unity visual scripting looks like @mortal bridge

shell sorrel
undone rampart
mortal bridge
#

Wow. Look at those names. Getvariable, set position, waitfor next frame, output etc. it is definietly much easier than Unreal's

undone rampart
mortal bridge
#

😱

#

why Is it not as popular then?

shell sorrel
#

because C++ is high friction comapred to C#

whole field
#

Hello I have run into a problem while working on my fishing top down game: I have a script for random generating prefabs of gameobjects of trees, rocks and mainly LAKES, where I have attached a script for triggering my fishing minigame (image). This script contains references to other game objects (interact window, timer etc.). Is there a way on how to "instantiate" (dont know how to use this word properly :D, so basically just fill) those references everytime the prefab of each lake spawns? I would appreciate any help.

mortal bridge
undone rampart
shell sorrel
# mortal bridge Good point

also unreal ties it to everything, like its version of a prefab already has a BP on it weather you use it or not

undone rampart
#

also the graph view API is still experimental

mortal bridge
shell sorrel
undone rampart
#

unity already has a behaivour tree system tough

#

well, its more of a generic state graph

shell sorrel
#

its mostly just not well docuemented, i had to mostly learn by looking at shadergraph code

shell sorrel
undone rampart
#

fair enough

shell sorrel
#

and wanted something very friendly for the designers

fierce shuttle
# willow nexus i have a list of stats for each enemy AI to have, such as health, maxhealth, fol...

It could be either, the benefit of using scriptable objects means that you can reuse the same stats and numbers on different enemies (for example, maybe "attack speed" is all the same for many enemies), and would allow you to change values of enemies from the file rather than searching through and modifying several prefabs - if you dont need those advantages, then I think a "stats script" on your enemy prefabs work just as fine

verbal dome
undone rampart
#

thats another advantage of unity, if something doesnt fit your exact usecase you can easly make your own thing, in unreal if something does not fit your usecase your fucked

shell sorrel
mortal bridge
#

I may give Unity blueprints a chance today. Although I still think traditional coding is better for beginners

undone rampart
shell sorrel
#

i dont consider it a one or the other

#

the programmers write the systems and expose things to the visual systems for designers and ld's

timber tide
#

save yourself the compilement time and do it on a separate project

undone rampart
#

if you wanna just protoype something something quick or make a simple system like, flickering lights, your better of doing it in visual scripting

mortal bridge
undone rampart
#

it also can reduce compiling times by not having scripts made for those simple stuff

shell sorrel
whole field
shell sorrel
#

lowers the damage they can do

mortal bridge
shell sorrel
#

i do the same on the code side too, like will split things into assemblies, and make sure people cant use something incorrectly easily especially if its something running on a other thread

verbal dome
mortal bridge
timber tide
#

I do like shader graph and vfx graph's visual scripting features, but they aren't something I'd imagine making myself without being paid lmao

whole field
#

@someoneelse pls explain game managers 😄

timber tide
#

It's like, you're either making your game, or you're making the tools.

undone rampart
night sparrow
#

How can i fix this NEVER had before PC is fine

mortal bridge
shell sorrel
#

i wear a few hats, am the lead dev on a few projects but also a tech artist like half my job is making tools

night sparrow
#

Never had the issue before its always saved fine

timber tide
#

oh yeah absolutely, but I'm talking about indie devs. The tools themselves make sense to me, but in reality I don't have time to make these nice logical systems so I can help my own workflow.

mortal bridge
shell sorrel
#

also greatly help with consistiency with stuff like art pipeline

mortal bridge
night sparrow
#

I cant even close anything On Unity 🤣

#

task manager either

timber tide
timber tide
#

scriptable objects themselves with a composition approach can pump out a lot of assets

undone rampart
shell sorrel
night sparrow
solid bough
#

the second log always shows 0 collisions* no matter what i do
i'm sure layers are set correctly
i'm sure colliders are set correctly

hexed terrace
#

if it's not reaching the second log, then there's an error before that.. look at the console

solid bough
#

i wrote it incorrectly^
it's reaching the log, it just never detects the collisions with objects under enemyLayer

noble summit
#

how do i fix this thing

verbal dome
#

Different things

hexed terrace
solid bough
#

it's a layer in unity

verbal dome
#

You need to use a layermask

solid bough
#

reallllyyyyy now.

#

thanks a lot! im gonna get on it

hexed terrace
#

it'd give a compile error if it wasn't declared as a layermask ?

solid bough
#

i have te enemy object set as a normal layer

verbal dome
#

Or a layermask can convert to int

#

And the input parameter layerMask is an int

solid bough
#

do i need to write a script that sets the object's layermask or can i do it in unity's UI somehow?

hexed terrace
#

how have you declared it

solid bough
verbal dome
#

Well that's correct then

hexed terrace
#

that's correct

solid bough
#

that's the attacking object

#

that's the enemy object

#

that's correct too

#

i'm not sure what other issue could there be

verbal dome
#

But with 2D colliders

#

Won't work

solid bough
#

i am?

#

i really am?

hexed terrace
#

Will overlapsphere work with 2d?

#

oh, was scrolled up

verbal dome
#

See Physics2D.OverlapCircle instead

#

3D and 2D physics don't work together at all

solid bough
#

WORKS

ocean dove
solid bough
#

thank you <3

mortal bridge
ocean dove
#

Do you actually have 250k batches...

mortal bridge
#

I used to

ocean dove
#

ok good

mortal bridge
#

It is crazy

#

64 gb ram i9 intel rtx 4090 even cant handle it

ocean dove
#

hmm I wonder why

mortal bridge
#

turns out you dont have enough freedom to try something stupid even if you have a good PC

ocean dove
#

big batches = better than many small batches

#

to be honest

#

I recommend 1250 batches max if you plan on high end ngl

mortal bridge
#

yes

ocean dove
#

I got 500 and I'm supposed to have fps in the range off of 200-260 which is insane

mortal bridge
#

why

ocean dove
#

idk

#

I just optimized my game so well out of nowhere

#

and editorloop (the thing that mostly lags your game in the editor) is like 5-10ms for me so I only get like 80 fps in the editor

mortal bridge
#

adll DLSS 69.0

#

no need for optimization

ocean dove
#

wish I could

mortal bridge
#

just give away free RTX 4090 and 128 GB ram and I9 Intel to people who buy your game no need for optimization

#

work smart not harder

crimson sinew
#

3500USD video game
Pros:
You get a PC
Cons:
Its not very cheap

swift crag
#

like, my PlayerLoop is a mere 2ms

#

my game does not run at 500 FPS

#

That might be because the time to render the frame sometimes winds up getting counted in EditorLoop

mortal bridge
ocean dove
#

You should also avoid garbage collector (aka calling stuff like new vectors in update which make the garbage collector spike)

#

I once had a garbage collector so bad I had a lagspike each like 3 seconds

shell sorrel
swift crag
#

Vector3 is a value type.

shell sorrel
#

99% of cases creating a vector is barely worse then creating a float

ocean dove
#

A vector3 is 3 floats after all

mortal bridge
#

@ocean doveI thought my joke was funny. Why do you not laugh

shell sorrel
#

and is passed by value

swift crag
#

I wonder if re-using a vector3 variable is even any better than constructing a new one each time you need it

#

obviously, from a readability standpoint, it's better

shell sorrel
swift crag
#

I guess the constructor is still a function call

shell sorrel
#

its a copy any time you pass it

frosty hound
mortal bridge
#

"bad". okay.

faint osprey
#

Ive made an animation then played it from code then decided i dont want it so i deleted it but its still playing every time i start the game and i dont know how