#💻┃code-beginner
1 messages · Page 202 of 1
I believe he's asking why use it in code when you can reference it in the scene
To get the component
I thought so too but I couldnt get it to work before
can you read the editted version?
ie [SerializeField]
What is the difference between those 2
this makes some sense
they appear to be aligned but some small ero could be causing an issue
The update functions are different
That's basically it
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
Is the inspector solution faster?
Does getting the component in the start method slow anything down at all?
neither is going to have any significant performance difference
It slows the start method.🤷♂️
Though it's probably insignificant, unless you're calling it million times.
but the inspector reference slows the scene loading by probably a similar amount 🤷♂️
ah
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
I have a question about animation cross fading
how to close this weird box?
u hit the insert button
Press INS on your keyboard
thanks
The crossfade seems to change the speed of the animation when it's using animator transitions
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
Specifically when I call the attack animation
When blocking is going back to an empty state
#🏃┃animation woes..
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
That will also change the time the normal transition uses
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
Well the "slowdown" only occurs when going from the block blendtree to attacking
When I'm watching the animator in real time
is it an Exittime / no Exittime sort of problem?
It most likely is
do you need the full clip to play or nah?
Well it's blocking, it loops when you hold it
like during that specific transition.. u may could make it have exit time
so the clip will finish completely..
ohh ok
Let me give some mroe context
I think this is more #🏃┃animation type stuff tho
Blocking is the only animation that has a transition that can be interrupted
if it gets interrupted ur transition out of it should probably not have exit time
u can still loop it regardless
well make it longer?
ahh.. well idk nuff about that.. never seen a clip speed up for any reason like so
It slows down
ohh i thought u said it sped up earlier mb
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
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..
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);
}
}
how do i instantiate as the child of the summoner and with a variable offset
Instantiate takes parameters for position, rotation, and parent Transform of the instantiated object
thanks
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
If Im making something like a conveyor belt to move an object that is touching it, is it best to
- add a small amount to the position every fixed amount of time
- set the velocity of the object to a certain amount
- add a force to the object
Using the scale property
Does anyone have an idea what is wrong in this code?
Try spelling correctly
if you look in the setting it's telling you to, do you see an axis called Horizonta; set up?
The name of the axis
Horizona is what you wrote
Hotrizona
capsuleMan is working now 😁 😁
yeah but doesn't scale just use a decimal fraction of the original dimensions of the sprite
I am done learning today
I will be back tomorrow to bother you more (thanks for the help everyone)
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
That would do something pretty different, but sure that would be easy
What is the sprite supposed to be?
an elastic band
current sprite is just a square
of one colour
I wanted an outline but it doesn't work due to the stretching
Then yeah, a line renderer may make more sense. You would just set the end vertex to the mouse position every frame
sounds wayy easier
thanks ill try it
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!
No haha. Lots of games for myself, nothing published.
In both making and playing games, my habit is to restart constantly. I don't even use unity much anymore
It's a hobby for me definitely
you a software engineer or something then?
If Im making something like a conveyor belt to move an object that is touching it, is it best to
- add a small amount to the position every fixed amount of time
- set the velocity of the object to a certain amount
- add a force to the object
I'm a bookkeeper. I have been messing with game dev for about a decade though
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
fair
my mums also getting into accounting, do you think it has a future considering AI?
Tools help people, not completely replace them
id hope so
otherwise software engineering is down the drain
the salary will probably be shit regardless..
I think you are vastly overestimating the state of AI as it is now hahaha
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
ai is a tool
you are so overstating it
fr?
this is not the first thing people said would take all the jobs nore the last
it's essentially taken most art jobs
how do i script every gameobjects with a tag into an array
nah, its taking less than mediocre artists jobs
and created millions more in its place
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
No it objectively has not. You may hear that kind of sensationalist talk in the news, but it is not true.
My wife is an artist, and is doing fine
we'll just be faster
its a great tool tho, we can use it to speed up our discovery process
in every field imaginable
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
hehe, chatgpt definately been abusing ole sparky tripping half the time we speak
I got my workplace to stop doing w2s with a typewriter when I started with them 🤣
Im personally kind of worried tho as someone aspiring to go into digital art fields when Im older
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
does not supprise me
Learn to use it when necessary, and avoid it when possible. It will not take your job
dont bother, the people here are busy talking about other stuff
tf why would I use AI for art
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
Art has a lot of tedious things in it, if it can help with that, it will be great
you don't think it's out of compassion
That is not what I was saying... damn
it isn't perfect yet for art
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
what u mean none of them work? do they not debug anything?
They always return some form of 0, even when I am inputting.
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
Down with Skynet!
Nor will it ever be? And no, I say it because of the amount of money she makes and pieces she sells
and no console errors?
it depends on how you define automate, like we have had tools like houdini for a long long time for procedural art and automation
Nope
so it must be the input..
Might wanna ask in #🥽┃virtual-reality
If it's with the rig
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
I dont really count math simulation I guess, I think for me what I dont want is creation of "original ideas" outside of the original artist's mind
Like I think a tool like auto-colour or ai used to remove backrounds isnt that bad
The printing press takes away all the art in bookmaking! We should destroy then all!
And that's the kind I was saying to use, like wtf
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
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
No one is preventing you from expressing your ideas though. Why do you want to limit what other people can do though?
I missunderstood you
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
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
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
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
Idk I dont really like that, this is probably an unpopular opinion, but I think that one should learn the skills to write an interesting narrative or just stick with having bad writing, at least its genuinely yours
so then it kinda falls back on the best people to do this are the ones that specialized into it
Honestly, ideas are cheap. Implementation is the important part.
i took the time to coach the AI into something interesting
i consider that mine but ya.. i perhaps could put a shit story in there
However original idea you might have, someone probably already thought about it.
ya but unless you trained it on your work, I kinda consider that plagiarizing, unless you credit your thousands of sources
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
thats fair, Idk I think Im just a bit robot-discriminatory
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
Why not go ahead and say that our lives are plagiarizing. Is there any single thing that you're using that was invented and implemented entirely yourself?
#LivingInaSimulation ?
As picasso (may have) said: "good artists borrow, great artists steal."
lol, and ocean 11 uses theft as an artform
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
ive been looking for tutorials on this but can't find anything about the end vertex
It's just the last vertex in the array
Looks like the property is named "Positions"
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
thanks ill try
Here are the parameters ive used
Ok, can you show the code for moving?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
over the limit so ill do it in chunks
Did you read the bot?
use a paste site
Don't post it as text here
oh yh mb
all u got to do is reference a line renderer and use 1 fixed point for the [0] index of the line renderer's positions.. and the mouse position / raycast for the [1] index
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
[SerializeField] LineRenderer thisLine;
void DrawLine(Vector3 first, Vector3 second)
{
thisLine.SetPosition(0,first);
thisLine.SetPosition(1,second);
}```
heres the mapping for the controls also
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?
yh so far its at 10 and 20
But yeah, a rigidbody means it will react to forces. Where is gravity pointing?
no gravity, its in 'space'
Ah, I misread, I thought I saw it still ticked
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
thanks, i have it working now but it still moves like it's 3d but my game is 2d
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)
i ran the game and I don't see it's transform changing
cause it's a line renderer
theres an alignment
im not sure but i think u can set it to be the transform Z and then rotate gameobject
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?
good question
Well you can check the total alive particle count
Is that enough?
LIke the isAlive kinda does that, is true when there are no particles, but does that "send a frame of true" at the beggining of the particle system before generating any? What if I am to have several pulses of particles playing but only care to sync one of them?
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
If you want that much control it might be easier just to call Emit() from your code and track each of those with a timer or something rather than letting the particle system 'run' and trying to figure out where it's at
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
}
I don't think the code you're showing has anything to do with the issue
Do you have anything else that goes onto DDOL?
Yes, the scenes don't do anything when I leave and come back, the only thing they do is play the music.
Yes you have another DDOL object?
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
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
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?
A cooldown
a cooldown?
A cooldown
ok
After making a request, don't let them make the request again for some time.
thank, that seems like a good solution
When am I going to fix this problem...
Can you show a screenshot of the editor when you first start the scene, and one when you start it for the second time
I am on my phone, so I can't download your project file.
If you want, you could do an .mp4 I guess
I don't have nitro
Nitro is not required for anything I asked for
I don't have nitro either
You can upload a video if it's below 8MB afaik.
but to send the video
Do screenshots then. I only really need to see a picture of the hierarchy at those two moments
But yeah, you can upload videos without nitro
I've done it many times and people do it here every day
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)
The hierarchies are collapsed on most of those images. Seeing that was the whole point of asking for the images
does nothing
That's because I change the scene
Click the little arrow...
and?
Should be 50mb here with server boost level three.
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
I think they wanted to see it at runtime when the issue occurs...
I start thinking this is trolling...
what
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
Is the hierarchy expanded here?
Unless they wanted to see the DDOL scene...
"Nothing happens" after returning to a scene for the second time
Oh it's one of those questions.
Nevermind I'm going back to Yakuza you guys have fun
I'm unrelated. Aethenosity seems to be helping them.😛
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
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.
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.
It would also just be unwise for anyone to download your random exe and run it on their computer
for 2d how can i find the pos inside canvas?
!bugs
🪲 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
which pos?
rect transform
@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;
}
}```
is there something like Mathf.Approximately but with settable fluctuation?
i think no
write it yourself
public bool MyApproxmiately(float a,float b, float threshold=1e-5)
Put it in words. What exactly is the fix?
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
if(Mathf.Abs(a - b) <= epsilon) which similar to what approximately is doing under the hood
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);
}
thanks!
if you're going to use for values that far greater than epsilon, proly just use bigger/less ternaries instead
how do i make a script that will crash the application (not close, i need it to show up as a crash)
Gonna make one of those very bad endings where the antagonist breaks the world. :0
why?
btw many ways
List<int> list=new(){1};
while(1){
list.AddRange(list);
}
Diagnostics.Utils.ForceCrash(...)
is this acrash
{
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
silent quits exe though, no UI errors on build
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
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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);
}
sheeesh..links would've been nicer
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
does that work better, sorry didnt realize how long it pastes out
wait
from where did you get that code
i swear 1000% different user yesterday had exactly the same code 1:1
same code for screenwarp works for others ?
maybe they're working on it together same proj 🤷♂️
the code for screenwrap does work for others, just specifically not UFOs, might be the way my spawn command is working
oh ok, what are the key differences between your UFO and the other stuff that works
just the spawning?
they are nearly the exact same code
you are moving your Asteroid and UFO using rigidbody so your ScreenWrap should not set transform.position
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.
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?
not sure if there is a built in formula, but you can use basic trig. In degrees: 360 / x = difference in degrees.
Start from 0, and keep incrementing (360/x) then get the point at (r cos theta, r sin theta)
rotate the radius vector
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);
What's wrong with scale?
how else do you want to change 'size' then
define size
size of UI game object? width/height?
or what
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..
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
not a UI, just a gameObject, and yea, width, height etc
was wondering if there was some method from some package or libarary i could use
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
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
i didint understand anything
but if it's a transform, then all you can do is modify the scale
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
what is a good free program to make UI
not a code question
use photopea.com tho, not a program but basically a free version of photoshop, it works quite well
How do you find the point your camera is focusing on? I'm using an orthographic camera if that helps.
wdym? Cameras don't focus on a point
You got a point, a direction, and the camera's frustum.
which you can derive a focal point from
Can rayhit accept multiple LayerMasks?
yes
One layermask. But you can combine several into one.
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);
}
}
Tyrant a screenshot of the GameObject
You're a tyrant
Mobile keyboard is a tyrant
screenshot the error in the console
How to do that? Considered they are bit mapped so if I want layers 1,2,3 I should sum them or write it manually?
Layer1 | Layer2 | Layer3
bitwise or
is that the only error
its repeated 3 times, from trying to save but idk why this is happening
You have a script that is not derived from Monobehav
This script looks invalid. Take a screenshot of the script asset inspector.
what's the file name
in unity Project its called
FaceObjectToCamera
I'm assuming you're trying to save an object as a prefab with some broken component attached to it.
Im tryna save my changes to a camera crossair But I only just got back on it was fine last night not changed the script for that or anything like so
Script named '' (blank)
rename it, to FaceObjectToCameraa then change it back
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 ()
you have tried restarting Unity, yeah?
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
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.
void Start()
{
rb = GetComponent<Rigidbody>();
rb.AddForce(Vector3.up * 500, ForceMode.Impulse);
}```
!code learn how to format code properly on here to make it readable
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
You're only doing the AddForce in Start() .. sooo.. how many times do you think this will happen, and when?
I had more complicated code but i just wanted to jump immediately on start to test
also just one giant jump
Oh, you made it kinematic, untick that
Whats this error never had before ```c#
'Gun' AnimationEvent has no function name specified!
```c#
[Header("Animation")]
public Animation animation;
public AnimationClip reload;```
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:
- Rotating the object based ont he distance joint and
- 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
I would look at RotateAround
probably some specific tutorials around for it honestly
considering the wave of grappling hook games made recently
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)
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
I'm not sure I see the benefit of dontdestroyonload over static classes
well, the benefit is singleton vs static
In which case do I have to worry about tidying up? The dontdestroyonload?
Yes, keep things tidy
You'll still need to reset the class to what it should be at the start of the game/ round
It's a bit antipattern but I figured if I used a normal singleton I could just replace the instance every run
not really anti, it's one of the reason you use a singleton over static
Thanks!
I've been looking around, I couldn't find any
I guess I'll give that method a shot then. It's the one that makes the most sense to me anyway
rotate around is probably fine then. You can also child the character to the rope and just rotate that too.
loads come up googling "unity 2d grappling hook tutorial"
Yeha but most of them have orientation based on the mouse
not swinging with the rope
The first thing I'd do, in that case, is ... not implement the looking at the mouse code
why is the variable names not showing up in the inspector?
public Navigation insideInactiveNavigation;
public Navigation insideActiveNavigation;
show code for Navigation
That would be a bug in the Navigation editor
:/ ok so it's safe to assume that the upper Navigation in the inspector
is insideInactiveNavigation;
right
yes
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)
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;
}
}```
AI Code?
assume no one knows what your project is. and give some indication as to what agent.health.Die() is
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
you cannot subscribe to a method
What can i subscribe to
an event or a delegate
Ah, so copy/paste?
yep
the image is green above and black in scene, why?..
I think you have more issues to resolve first if unity is freezing instantly, no?
the scene I'm rendering isn't meant to be played as a game, more meant to be a minimap for a different game
ok so somewhere you need to
Texture2D image = RTImage(camera);
kill unity
maybe you missspelled something, had the same thing
dont use while loops ;)
when you do i++ and wrote while a less then 5 or some
ah i meant in for loop
misspelling would mean does not run, not infinite loop
i mean in for loop: for(int i = 0; i>2; a++) or so
true, that would do it
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()
{
}
}
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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()
{
}
}
probably not
so how do I go about running the script so that it takes a screenshot?
I already told you
You told me to put this somewhere
yes, that is what you need to run the method
put it where you want the screenshot to happen
I mean I just need it to run whenever really, just once
but when?
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
that makes no sense
it just has too many components and such
What in the world
my line renderer acts 3d in a 2d space
you're still not making any sense, at which point in your game do you want to take a screenshot
it's not a game really, just a scene made up of a bunch of objects, there's no gameplay, it's just a scene that I want to render
I think he's saying his game doesn't run. It will crash if he tries to run it. He just wants a photo taken of the game world
why don't you just use debug.break() then take one yourself
precisely
what
any ideas?
and how would that help?
I guess just do it in edit mode then
the issue with that is it looks like poo if I just take a screenshot in edit mode
I'm not 100% sure what you mean by "acts 3d"
if you watch the video when it switches directions
it is like it is angled towards the points but moves 3d around it
seems fine to me, if anything force it to render on top
I'm still not sure what you mean. You're talking about the slingshot strings, right?
yeah
at what point do you think it "switches directions?"
you rresponding to me?
no when it goes from the left to the right
but you see how it looks 3d though?
yes, change the sorting layer
Yeah, is that not intentional? You only want the strings to go on the left side of the slingshot?
Your slingshot is 2 sprites
what does that do?
so I assumed it was intentionally set up this way
am I SOL?
the 3d look is not intentional
I want it to look like a 2d line
Are you talking about this right here?
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
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
how can i fix that?
if both points were the same it would be a line
This isn't really code but, you drew the sprite in "3d" so you'll have to redraw it in "2d"
i dont understand
there is no sprite
it is just a line renderer
The slingshot is a sprite and is drawn in perspective. You attached two lines to the two points on the slingshot, which has perspective
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
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
is this a code related question
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
Cinemachine just controls the settings on a regular camera and adds some math and animations and a few other fancy features but on its own, it isnt a camera and doesnt render anything, so you can still use anything that would normally work with a regular camera, youd just need to reference your regular camera instead of your Cinemachine component
but wont the camera currently be pointing elsewhere?
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
Thats a good point, its possible there is a setting within Cinemachine that can take its current view, though im not sure if it would work disabled or when its not controlling the camera (never tried messing with that depth)
oh great ill look for that then
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);
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
It sounds like your trying to call destroy on a prefab, whats the script and line of code that produces the error?
yep just realised im trying to destroy the asset and not the clone
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)
You mean "RotateAround"?
Yes majesty. transform.RotateAround
The first parameter is the point you want to rotate around
put empty gameobjects as children of the main object, then rotate around them
That is the easiest way to find the point you want to rotate around yeah
you knw you can just look up the docs
for it
iirc there is a rotate around point as well
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
I've already read this sir. It is good I learned I could put empty gameobjects as children
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
Can I ask one more question please?
Then you use myObject.transform.position as the first parameter.
you can figure out where that point is from the bounding box of the object as well
Absolutely friend
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
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
so It can be the child sir?
Yes. I know. You assign the gameobject there.
mm, if it is the child that object will move too
Which is probably not what you want
Or, it could be?
No sir
But you probably don't want to "get" the object in update. You probably want to set it once in editor
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"
cringe
I achieved what I wanted to thanks to your help and time sir. @limpid wren I wish you and your family well.
might as well use a transform directly and skip the getter for it
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
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
Also transform.position is apparently quite slow if you're calling it a lot.
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
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
0,0,1
yup
isnt that vector3.forward
yes
it is aswell
but then i thought that is your players current transform
transform.forward is object's local foward
0,0,1 * 5 for example is 0,0,5
would it not be that
so its fine
Vector3.forward is the unit vector defined by (0, 0, 1) transform.forward is the forward direction of the object in the world space
ok thanks
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
so they are both the same
X to toggle between global/ local
they will be the same if the local is pointing in the same direction
ok ty
i just explained it yo you
no, they are both the same if you did not rotate your object
but differ if you did
but in what case would you use one over another
like is there a case where you would use one
and not another
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
if i have
its depednent on the objects rotation
oooooooooooo
set these to pivot and local
transform.forward is the object's "looking" direction
transform.forward for a given object will be the blue arrow on the translate tool
so the blue arrow on the 2nd screenshot is the child's transform.forward
so vector3 . forward non matter what is 0,0,1 but transform.forward depends on the way the object is facing
did you actually read
yes
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.
how do i make a gameObject rotate around a certain point in 2D
did you try google?
yeah i tried but i only found how to rotate it not make it move around a point
tyvm
i don't understand
did you read the docs
about RotateAround?
it's literally right there
This modifies both the position and the rotation of the transform.
yeah i'm reading it right now
Easy man. He is just trying to learn like the rest of us
i don't know what that means
im not talking to you, im trying to teach him how to use google, so he doesnt have such issues later on
it means that it modifies the position and rotation
of the given transform
You have an object. You have another object that will rotate around it.
ok huge
what is a transform
Transform is from Unity library
you can use it like transform.position or transform.rotation
sorry i forgot
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
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
ok thank you guys very much i'll come back i don't find it on google
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
perfect spoon feeding
I actually wrote explanations for him which could make it easier to learn sir. I did not give him the direct code.
I think you need to relax sir.
Someone helped me so I was in debt and I helped someone 🙂 not a big deal.
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
i already found the code in the docs i was breaking it down in pieces i understand i find this very useful
i wasn't planning on copying code anymore unless if i understand it
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?
it means change where it is
no it doesn't
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.
it's not the central point, it's where the pivot is
I mentioned it.
yourDesiredObject.transform.position represents the central point or location in 3D space
that is incorrect
I gave up reading after you got said it wrong in the first 6 words
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.
the center doesn't need refering to/ talking about at all in any of what you said, it's just the pivot
i'm really confused
as i said you are only confusing things
for him
yea exactly xd
let him learn by tutorials/google
and ask certain issues when he has any
he didin't ask you for explanations
and spoon feeding
transform.position is the position the gizmo is ☝️ is located
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
it only appears as the objects center if you have the mode set to that..
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
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 🙂
relax dear sir
And I need to remind you that this guy is asking this for 2 not 3D 🙂
makes no difference
what does it change, dear sir?
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
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
expose the GameObject variable to inspector
and assign it from there
[SerializeField] private GameObject objectToRotateAround;
pivot point is the center of rotation for an object. So If you move the pivot point,the object will rotate around the new location of the pivot point. Since unity tools don't provide direct support for this should be no problem.
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
What did you do so far?
what is a gizmo

dude what is this channel for if no one will answer questions
huh
it's for code related questions
and there are ruels #📖┃code-of-conduct
google first, ask second
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
Basically 3D UI
you cannot declare a variable outside of the class
public class lockpickRotation : MonoBehaviour
[SerializeField] private anchor objectToRotateAround;
{
ok
Do you know what serializefield or anchors are ?
the anchor is the name of my gameobject
serializefield is used to make it accesible in the inspector without making it public
- class names need to start with an uppercase letter
- You declared a variable outside the class body
- anchor is not a type name
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
your class name
|
v
public class AClass{
}
```!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
- No they dont. Thats a convention not a hard rule.
@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
when you declare a class, you give it a name, in your case is lockpickRotation its reccomended for class names to start in a uppercase letter thats the normal naming convention
your right, bad wording on my side
i changed it to start with an uppercase letter but none of the errors dissapeared
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
the reason your getting all the errors is because you created a variable [SerializeField] private anchor objectToRotateAround; outside the class body, the class body is the { } you have to put all your stuff inside those brackets
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
Your variables need to actually be in the class
@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
these guys tell you class, variable, serializefield etc. if you don't even know what these are you wont be able to get help
Visual scripting is easy at first gets harder by time. Coding is hard at first gets easier by time. The choice is up to you prinzegrin 🙂
oh thank you
I would argue on coding gets easier by time part
🤣
I for one miss the days when JonSkeet had everything answered for me in stackoverflow
i'll check the link out
Can't get any more complicated than this 🙂
what in the hell is that shader for
of undeground tunnels?
This is from Unreal Engine. I have no clue about Unity visual coding
ye lol
Do people even use Unity visual coding? They must be madmanss
visual scripting should never be used for systems work, like as a bit of glue a level designer can tap into its useful making whole systems well thats a lot of pasta
I like pasta
Tell that to Unreal devs 🙂
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"
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
add a new line \n
It is a big plus when you can switch quickly between visual and usual code.
its about the same as unreal's, much nicer UI imo
Like "Hello i am cool /n goodbye"
also visaul scripting for more constrained domains is good, like for behaviour trees its great, for shaders it can sometimes be great
yup, but backslash
My keyboard dont haves that
its above the enter key
For Unity shaders it is very good.
Above the enter key is the delete something key
this is how unity visual scripting looks like @mortal bridge
well once it becomes more full featured, i find its a 50 50 chance if i have to drop out and just write hlsl
just copy it from my message
Wow. Look at those names. Getvariable, set position, waitfor next frame, output etc. it is definietly much easier than Unreal's
yeah, and the coolest thing is that in unity you can create custom graph windows for whatever you want
because C++ is high friction comapred to C#
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.
Good point
because unreal overshadows it, and its quite an advanced topic, there are a ton of hidden gem features unity has no one knows about
also unreal ties it to everything, like its version of a prefab already has a BP on it weather you use it or not
also the graph view API is still experimental
Yes. My dog could make a character move in one hour in Unreal
has some friction but works well enough, i wrote a behaviour tree system in it
unity already has a behaivour tree system tough
well, its more of a generic state graph
its mostly just not well docuemented, i had to mostly learn by looking at shadergraph code
did not fit my exact usecase
fair enough
and wanted something very friendly for the designers
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
The objects tou want to reference, are they in the scene?
You could store them in a game manager, then in this object's Start/Awake function fill in those references
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
to me this has always been the unity strength, building editor tools is so easy compared to but one other engine i have used
I may give Unity blueprints a chance today. Although I still think traditional coding is better for beginners
unity visual scripting is good for designers
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
save yourself the compilement time and do it on a separate project
if you wanna just protoype something something quick or make a simple system like, flickering lights, your better of doing it in visual scripting
When designers are not technical
it also can reduce compiling times by not having scripts made for those simple stuff
even if they are technically unless its a true generalist i prefer to only expose certain things to them
yes all of them should be in the scene but most of them are not set to active by default which makes me cant use the gameobject.find thingy. How exactly do game managers work? because I have tried to fill the references on the spawn of each generated object with script attached to them and Start() function but that didnt seem to work.
lowers the damage they can do
That is actually very considerate.
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
The game manager could be a singleton in your scene. You can google that and/or someone else can explain, im a bit busy now
Very good. Although I will stop chatting now since people's questions have the risk of not being seen since we talk and their questions stay up there. See you.
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
@someoneelse pls explain game managers 😄
It's like, you're either making your game, or you're making the tools.
that depends, in a team thats actually the programmer's job, make the tools for the designers to make the game
How can i fix this NEVER had before PC is fine
Do you have many objects?
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
Not many
Never had the issue before its always saved fine
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.
If it is saved just restart.
good tools can save time and make collab easier
also greatly help with consistiency with stuff like art pipeline
I had this issue when I had 250000 batches
You can do a lot with just the inspector and custom inspectors scripts.
scriptable objects themselves with a composition approach can pump out a lot of assets
and its also a once and done thing, you make the tool then you can reuse it in every project without having to touch it other then a few tweaks here and there
i count custom inspectors and property drawers and menutiems as tooling
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
if it's not reaching the second log, then there's an error before that.. look at the console
i wrote it incorrectly^
it's reaching the log, it just never detects the collisions with objects under enemyLayer
how do i fix this thing
Is enemyLayer a layer or a LayerMask?
Different things
What is enemyLayer set to? Is the enemy set to that layer?
it's a layer in unity
You need to use a layermask
it'd give a compile error if it wasn't declared as a layermask ?
i have te enemy object set as a normal layer
Both are ints
Or a layermask can convert to int
And the input parameter layerMask is an int
do i need to write a script that sets the object's layermask or can i do it in unity's UI somehow?
you need to declare this enemyLayer correctly
how have you declared it
Well that's correct then
that's correct
that's the attacking object
that's the enemy object
that's correct too
i'm not sure what other issue could there be
You are using 3D OverlapSphere
But with 2D colliders
Won't work
WORKS
You're joking, right?
thank you <3
no
Do you actually have 250k batches...
I used to
ok good
hmm I wonder why
turns out you dont have enough freedom to try something stupid even if you have a good PC
big batches = better than many small batches
to be honest
I recommend 1250 batches max if you plan on high end ngl
yes
I got 500 and I'm supposed to have fps in the range off of 200-260 which is insane
why
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
wish I could
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
3500USD video game
Pros:
You get a PC
Cons:
Its not very cheap
I've noticed that, sometimes, EditorLoop is clearly including non-editor code
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
I said free. Not included. Mrbeast can give away trillions why cant you
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
vectors do not create garbage
Vector3 is a value type.
99% of cases creating a vector is barely worse then creating a float
A vector3 is 3 floats after all
@ocean doveI thought my joke was funny. Why do you not laugh
and is passed by value
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
there is literally no difference
I guess the constructor is still a function call
its a copy any time you pass it
There's no off topic here. There's no need to validate your bad jokes either.
"bad". okay.
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
