#💻┃code-beginner
1 messages · Page 201 of 1
okay, so this is Visual Studio
yeah that not configured
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
This is just what I went off of a youtube video as one option
drums tried to configure the code editor already and had a problem
ok, now compare this to the unity/youtube code to see where you went wrong . . .
Well then glad I came to ask because I was not aware of that at all
there ya go , btw IDE configuration is part of Unity Programming Path
If MonoBehaviour (and all those types) is white, it is not configured
(Unless you forced it to be that way in settings)
Well I went through everything on that section and thought I did everything step by step and correctly.
Alright time for me to go fix some stuff.
Show your workload, the external tools menu, and package manager
make sure preferences -> external tools has the correct version
You said something about the choice of script editor resetting.
Lessgo the SO works now 
Sorry, which part is workload? I know external tools and package manager.
The script?
this would be a screenshot of Visual Studio
showing that you have the Unity workload installed
this is described in the instructinos
Workload is something you do inside Visual Studio
Edit: ah, as fen said
Guess it's time to reread the basics again lol
Could anyone help me Im not sure if this a code Issue or something else, my Player seems to just fall through the map since using Pun 2 Networking and setting it up!
Not sure if i have done something wrong with player or what
Missing a collider?
Dunno how PUN works, but I see a rigidbody and no collider
Not sure, never had one before it worked fine
If you had collisions before, you had a collider
Was your rigidbody always dynamic? Or was it kinematic
Note that a CharacterController is a collider
prolly a dumb question but 2 SOs can have the same order right (since its kinda just priority level of execution)
I had CharacterController , so this is why when i removed it, that has caused it to fall through as No collider
What do you mean by "order"?
So you removed the collider and added gravity. Seems a clear cut case here
the order at the end
This has nothing to do with execution order
It controls where they appear in the Create Asset menu
ohhhhh
you can find this out by reading the CreateAssetMenu documentation (:
mb then
I was skimming through the SO section on their website so must've missed it
mb
Different filename, menuname and order, what exactly is being duplicated here between 2 different SOs 
none of those matter at all
the only thing that matters is the class name
the C# compiler doesn't care about the attribute at all, and filenames are also irrelevant
you can have 1,000 classes whose CreateAssetMenu attribute all give them a menuName of "Foo"
it'll compile just fine
i see
But I'm already going back through the steps
Just sending you thiose anyways
Ok, you didn't show the workload though
The workload is where you get the Unity "extension" (not called that in VS) inside Visual Studio
how do you pull that window up if you installed VS through the Hub?
it looks like the instructions say to open it with the installer, which isn't relevant in that case
I don't use VS so I don't know off the top of my head
At the top there is a menu called tools, and inside you click get tools or something
It's been a while, can't remember honestly
Maybe it actually says Get Extensions?
idk how to use this api
you should probably read the Game Jolt API documentation, then
It looks like this is a component that has a single UnityEvent on it
which will fire upon...auto login!
presumably when the player is automatically logged in to something
Oh my, don't remember how I forgot this step. I did this last time on my wife's computer
this is gonna be a dumb asf error but
SO1:
[CreateAssetMenu(fileName = "EntityConfigs", menuName = "Configs", order = 1)]
public class SpawnManagerScriptableObject : ScriptableObject
{
[field: SerializeField] public float PlayerForce { get; private set; }
[field: SerializeField] public float ObsSpeed { get; private set; }
[field: SerializeField] public float ProjSpeed { get; private set; }
[field: SerializeField] public float ObsDeadzone { get; private set; }
[field: SerializeField] public float ProjDeadzone { get; private set; }
}```
SO2:
```using UnityEngine;
[CreateAssetMenu(fileName = "EntityStats", menuName = "Stats", order = 1)]
public class SpawnManagerScriptableObject : ScriptableObject
{
[field: SerializeField] public float maxhp { get; private set; }
[field: SerializeField] public float minhp { get; private set; }
}```
Error:
Duplicate 'CreateAssetMenu' attribute
what is the duplicating CreateAssetMenu attribute between the 2
this is not required section , at all
again, the class names are the same
they're both called SpawnManagerScriptableObject
so you have two [CreateAssetMenu] attributes on a class named SpawnManagerScriptableObject
hence the error
the workloads something entirely different
you'll need to point drums to that window, then
its part of the guide
the instructions cover how to open it when installing VS manually
they do not tell you how to open it if you aren't using the VS installer
But he said in Extensions in VS right?
Did you install VS manually?
there are no VS Extensions
(probably because you shouldn't have to open that window at all if you installed it through the Hub)
Drums is trying to walk before he crawls 😬
rahhhh finally got it (such a dumb one)
I'm on Visual Studio and theres an extensions tab, unless you mean something else
thanks for bearing with me lol
i need a one-word answer to this question: yes or no
If you installed it manually, then you downloaded the Visual Studio installer. Use that to check that you've installed the Unity workload.
what's the next step for the Gamejolt UI?
I have absolutely no idea what you're doing
most people here aren't going to know how the Game Jolt API works
Ok, brains working now
So "game development with Unity" was already checked, correct?
ok hold on
VS doesnt install without VSInstaller
there's one really goofy problem you might be having
I haven't checked anything else since install
sometimes VS just turns off the project
i believe you want the "Solution Explorer" window
did you show the External Tools page already
the old VSCode extension is installed, but that shouldn't matter
This one right
2019 😬
click regen project files, open script from unity again
screenshot the whole VS including Solution Explorer
(and kill VS before you regen the project files)
this is the "turning it off and on" part of the diagnostic
"Regen proj files" is donde?
The button that says regenerate project files
On VS or Unity?
Oh.
If it doesnt work after that and opening script, then in Solution Explorer def holds the issue
-- removed
mb sorry!
Mother of God
what?
right, because you made a silly mistake
I'm sure I did I've been trying to fix my booboo
well at least now its configured
you seriously can't immediately tell what you did wrong?
Hold on let me look this over for a second
reverse speed!
going zoooooom
Idk, was just doing what one video suggested. Was trying to remember how to make it spin without looking up any hints, got stuck, started from scratch and watched the first youtube video to at least try
probably want to use Time.deltaTime for consistency through different FPS
what you don't want to rotate 500 degrees per frame?
I'm sure once my dumbass actually either figures it out or is finally shown it's gonna hurt
Anything in Update will execute once per frame.
So, you should keep that in mind when deciding how much rotating to do.
Exactly, I don't need smooth.
jk
Imagine that the game is running at 100 frames per second
How many degrees should you rotate per frame to rotate at 500 degrees per second?
Is this an actual math question you're asking me? 😅
I know. Unfortunately. I'm getting ready to take some college classes soon for Math
Well then I need a refresher course for that too.
Umm..one sec
did you fix your original problem first ?
now that's an incredible embed
Yeah it is a bit l o n g isn't it
I have not yet. Trying to figure it out first before I come back cryin for help lol
I'm sure this stuff should be easier than how I feel right now. Once I actually get the hang of it though I'll remember how to fix my errors
no, that would be for 60 frames per second
i specified that the game was running at 100 fps
wrong direction
500 divided by 100 is 5.
My guess would've been 100. I really need to refresh 😬
500 degrees per second. 0.01 seconds per frame.
500 * 0.01 = 5
Multiplying 500 by Time.deltaTime will give you how far to rotate in each frame. Time.deltaTime is how long the last frame took to render.
At 100 frames per second, Time.deltaTime is 0.01, because each frame takes 0.01 seconds
Since your framerate will be varying, Time.deltaTime ensures that you rotate by the correct amount each frame.
Ok well I fixed all the code errors but propeller is still not spinning so going back over it and figuring that part out
debug.log that the script is running
you are telling me to "start debugging" or something else?
Also I assume there's other better ways to learn all this lingo and terminology than Unity Learn? I don't want to limit myself
I want to check for enemy aggro, I think of adding a sphere with OnTrigger that is set to player layer and check OnTriggerEnter to check if enemy should be in aggro state.
Or should I do it with Physics.SphereCast() that is run in corutine every few seconds?
i think they mean to write a line of code in the script like "Debug.Log("Hello")" to see if it shows up in the unity console (and thus proves that the script is actually running)
those physics queries are kinda expensive regardless why do you need casting anyway? best to keep them inside a list and iterate through them to find info
if you do use SphereCast , always opt for -nonalloc
Ah.
So what would you recommend? Mesuring distance between enemies and player?
Hello, how can i make 2 child objects teleport to the same position? I have an attachment system where the player can connect attachments together. I want to set 2 attachments to the same position and rotation while the parent follows it
print something meaningful, not useless text
https://unity.huh.how/debugging/logging/how-to
I meant, if you're enemies are in a list already a distance check would prob be less expensive than quering for physics colliders
but I thought you want to check aggro, then use physics queries
just use nonalloc
Im already doing one direction check to make a raycast that works as LOS trigger. Might as well before normalizing the vector calculate distance
Enemies are not in the list only player is. I get get player position and enemy position and just calculate the distance.
I have NavMechAgent thing. Maybe it has some implementation already?
i need heeelp
what
so i tried to do an fps game but camera dosent work
How are you setting up the camera
bro i swer if i get hit by this again
uhh using an script
Maybe you should actually ask your question first then
Can someone help please
so my camera is there but its not fps yknow
What exactly do you want to do
I'm kinda lost now lol
Set the position of both objects to the same value
Did you actually read the question
@grave forge so you want your camera to look around with the mouse or what you mean exacltly
Did you?
how can i make 2 child objects teleport to the same position?
yea first person cam thats what i want
and rotation while the parent follows it
you're going to need to provdie more information if digi's answer is insufficient
Well I need enemy to pursue player when its nearby and has LOS to it.
You can set rotation too. And parents don't "follow" child objects, other way around
!vscode
Why might the player rotation code under //Rotation work perfectly fine with AddForce but not with AddRelativeForce?
When 'AddRelativeForce' is used (_rigidbody.AddRelativeForce(_playerCalculatedForce, ForceMode.Force); in conjunction with the code under //Rotation, the player rigidbody starts moving in random directions.
private void FixedUpdate()
{
_playerMoveInput = moveDirection;
_playerCalculatedForce = _playerMoveInput;
_playerCalculatedForce = _playerCalculatedForce * _movementMultiplier;
_playerCalculatedForce *= _rigidbody.mass;
_rigidbody.AddRelativeForce(_playerCalculatedForce, ForceMode.Force);
//_rigidbody.AddForce(_playerCalculatedForce, ForceMode.Force);
//Rotation
if (MoveIsPressed)
{
targetRotation = Quaternion.LookRotation(moveDirection); //or moveDirectionRaw
targetRotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotDegPerSecond * Time.deltaTime);
_rigidbody.MoveRotation(targetRotation);
}
}
Full movement script (it is pretty small):
https://hastebin.com/share/abalotunan.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Agent has the code to chaice. I need distance and LOS chrcks
@grave forge Unity has an FPS template already built-in into the Hub
because AddRelativeForce works in local space
and AddForce works in world space
Oh
There is unity asset pack
well time to delete my project i guess
That comes with FPS controller
in local space, Vector3.forward is whatever direction you're facing. in world space, Vector3.forward is a consistent direction (world forward)
I usually do a Dot product for FOV and Raycast to check for barriers / obstacles
Gonna look into dotproduct
wait where is the template at
Then is there some way to convert _rigidbody.MoveRotation(targetRotation); to be AddRelativeForce- friendly?
FixedUpdate is the new version of Update()?
i don't understand your question
https://docs.unity3d.com/ScriptReference/Vector3.Dot.html
https://www.falstad.com/dotproduct/
https://www.geogebra.org/m/Yu6869By
the problem with using AddRelativeForce instead of AddForce is that your input is being interpreted in a different coordinate space
where
this has nothing to do with using MoveRotation to change your rotation
It's not new, it's the physics update step
https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html
AddRelativeTorque/AddTorque is for rotation
well, other than the fact that changing your rotation changes the meaning of a local-space vector
@grave forge Sent you image in DM
And how exactly that works to make Fov?
thats what im asking, the attachments are inside the model.
public void ConnectTo(Attachment attachment)
{
occupier = attachment;
attachment.occupier = this;
baseObject.transform.rotation = Quaternion.Inverse( transform.rotation * attachment.transform.rotation);
Vector3 offset = attachment.transform.position - transform.position;
baseObject.transform.position += offset;
}```
This is my current script, it didnt originally change the rotation but since i'm adding the ability to switch between attachments while building i needed it.
Look at the image, think as if the boxes are the main objects and the arrows are the attachments facing out. How can i always make sure the attachments are at the same position and facing each other (While changing the parent position too)
that code will do amost nothing
That would log the value of your unused, unnecessary value
will rotation by a fraction of speed once and only once
Well I was just told to debug and check so I can see why my propeller still isn't spinning
ah, I know exactly how to do this one
here's what you want to do:
because maths
you need the rotation code in Update
It's spinning exactly as you've told it. A smidge less than one degree of rotation when the object is first created. Check the rotation before playing and after, and you'll see it's very slightly different
ah, duh
Download the Source - https://game.courses/dot/
Determine if an object or character is in front of another, seen by it, or behind it in Unity3D with this simple 2 line c# script. Discover the power of Vector3.Dot and how to use it in a few seconds to make your AI better.
Architecture Course - https://game.courses/architecture/
Become a Member ...
spent today's session setting up SOs for my gameobjects' stats and configs, truly a rabbit hole ngl
the urge to turn every static value into a SO 
tomorrow imma move forward with the buffs system using SOs hopefully wont be as taxing as today
I don't really understand what dot does on non normalized vectors. It returns the angle?
watch video I sent
it explains
It returns the "sameness" of two vectors. 1 If they're facing the same direction. -1 if they're opposite
Hi, does anyone know how to place the dungeons with the straight walls forming a square
@swift crag I guess what I'm trying to ask is, what could be a way to change the code under //Rotation to work with AddRelativeForce? i don't really get how to change //rotation code to be compatible with it
Arent that normalized vectors dot?
yes
I will, im just kinda not home
If you're using physics engine
It's every vector
The rough idea is that you calculate the offset between the parent and the child objects.
Oh I think I understand
root goes where our parent is, and handle goes where we are.
No i dont 😦
no worries , if you need an example ill be home around later
Then we move handle to where we want the child to end up
root is parented to handle, so it moves as well
Then we move the parent to where root is
Since root and handle still have the same offset they began with, the child now winds up exactly at handle
here, let me show you the context I used this in
I used this to attach a ragdoll to a joint.
Do you want it to only rotate on the Y axis (left to right)?
I have to teleport the root of the ragdoll such that the Rigidbody I care about winds up exactly at the Joint's position and rotation.
Oh funy enough I understood it
Yes, correct
can you explain to me what should i set the variables to? i have attachment 1 and 2
I presume you're trying to make attachment 1 move to where 2 is.
attachment 2 is the destination. attachment 1 is the child, and whatever attachment 1 is parented to is the parent
(the parent can be a grandparent, too, or anything further out)
(vector-vector2).Normalize
Same as result of the opearation.Normalize?
So basically you want your transform.forward to rotate towards moveDirection.
I would use cs Vector3.SignedAngle(transform.forward, moveDirection, Vector3.up)
To get the angle from current forward to the desired forward direction, along Y axis (Vector3.up here)
Then I would use AddTorque(0, thatAngle, 0)
guys why dont i have 1st person templates in unity hub
Unity assets its called I believe
If you're looking for the "microgame" templates, those are only available for the 2021 LTS
ok ill install the other version
Thank you, I'll try that!
I might create a version of this that's a coroutine, so that you can visualize each step
Try to understand it too. This is useful stuff
but later; i need to get to work :p
do i need to keep the handle and root
this is the difference using normalize and not using it
it is also surprisingly complex for starting out haha. But it is fun to learn. Anyway, thanks again.
right one shows normalize, you're trying to achieve
Yeah physics takes some math. But you don't have to really do trigonometry, just learn what the Vector3/Quaternion functions do
And first one is around 1.4, because of pythagoras theorem
eh atan2 is needed ill say
for converting mouse position in world space
not necessarily
no, which is why my code destroys them at the end
I do very little trig!
But it depends too
Vector3 and Quaternion are really handy
It's not that needed
Can I use a monoscript like a standard class? By that I mean:
namespace test {
public class Test {
//Fields
public Test() {
}
public Test(...) {
}
public ... get() {
return ...;
}
...
}
}
```?
well being good at trig does help often though
Do you mean a MonoBehaviour?
Or do you just mean a script file that defines a plain old C# class?
This looks like the latter.
no
If a MonoBehavior is a script attached to a game object, no
Just plain script
Test is not "a monoscript". It is true that it's defined in a file that unity imports as a MonoScript asset, but that has no bearing on what Test is
Test is a class.
and since it doesn't derive from UnityEngine.Object, Unity doesn't really care about what you do with it at all
so yeah, you can do whatever you want with it
So I can't define my classes and use them in other stuff?
Of course.
Oh, so I can
The namespace you defined, can be used
yes, as long as the do not inherit from Monobehaviour
Yes, I kinda see the transition between java and C#
Unity starts getting upset if you try to construct something like a MonoBehaviour or ScriptableObject.
I was quite surprised on the similarities C# have with java
My brain just goes nope when anything is related to vectors. Literally just goes nope
True, but I got pretty far while being kinda terrible at it. I do need some refreshers lol
well, you'd better stop bailing out the moment you see a tiny bit of math
Vectors are fun
I despise the "i'm just dumb and i'll never understand math" mindset
Stop putting yourself down
you know coordinate system right?
whats the targetroot?
What helps me is visualizing it. Debug.DrawRay/DrawLine, for example. Visualize all vectors you are working with and it will start making sense
work with it long enough it becomes intutative
puppet.targetRoot? That's the root transform of the ragdoll.
Look at the first script. I made the names generic there.
The second script is there to show you a place where I used that logic.
it still has targetroot
oh! my bad
The usual usecase for that can just be replaced with transform.up = (mouseWorldPos - transform.position)
Yes, Also a very good alternative!
but just in case, you can use that too
True
https://gdl.space/zenadoleza.php
Here, I got rid of all of those redundant transform properties
Transform what = ...
what.transform.position = Vector3.zero;
I do this way too often.
transform.transform.transform.transform.transform.transform.transform.transform.transform.transform.position = ...
transform does have some overhead
So if I have a method where I would call transform 10 times I just cache it (especially in Update/FixedUpdate)
And yeah readability
thanks
let me try
my attachments are rotated 180 degrees (facing inside) so should i just use quaternion inverse for the rotation?
Thanks ya'll that definitely helped and now I also know a few extra things for the future
You'd need to correct for that. Quaternion.Inverse wouldn't be appropriate though
If it's 2D you can probably just multiply by Quaternion.AngleAxis(180, Vector3.forward)
Does this script make the attachments face each other or the same direction?
It copies the rotation of the destination transform.
would somebody mind helping me out quick? got this error after following a tutorial to make a dash
what would this error mean?
i can link the code on a pastebin
It means the thing you're trying to reference does not exist, it is an "empty" variable
oh what the fuck
ok that's a start
When i multiplied the rotation by 180 degrees, the script thinks that these locations are occupied
ty i'll look at this
great avatar-message combo here
it will tell you exactly which line
always open /look the error expanded in Console window
instead of setting fullscreen to true when im changing resolution, i want it to stay the same as what it was, what do i change "true" to be?
oh it says line 49 ok ok
you need to get your !IDE configured. there is a concerning lack of syntax highlighting here
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
sure hope that thing is configured btw, weird colors
Then something on line 49 is null but you're trying to use it anyway
maybe its VS2017 theme 😛
pretty sure types would still have syntax highlighting with that
there are but it just doesnt show in the ss i dont know why
i'm gonna ctrl and f each piece of it to see what's up
maybe it didnt load
screenshot your entire IDE to show that it is configured
if you teach me how
how to what? screenshot? you already know how
would these be the same thing or do i need to make a variable called _rigidbody.velocity
Where do you asign a value to _rigidbody
_rigidbody is the name u gave ur Rigidbody2D
The fact that both color up when you select one shows it's referring to the same variable. It might not have avalue though
i read it..
3 people pinging the same thing but no one gonna say anything else
then surely you know that there is more than just a single step
whenever u reference it (_rigidbody) ur actually referecing the RIgidbdoy2d
oh so it might be the value??
i need to make a value
What do they have to say? It is step by step instructions
yh theres 2 and ive done those 2
Nope, more than 2, that you have to verify at least
prove it
✨ syntaxes
there you go. wasn't reading and following the directions so easy?
so will you help me now or not
ah sorry i can't figure out how to add the variable for my rigidbody.velocity
anyway, to answer your question just get the current state of the fullScreen property
https://docs.unity3d.com/ScriptReference/Screen-fullScreen.html
and RTFM
Are you doing _rigidbody = something anywhere? That puts a value into it
the .velocity is a Vector2
so i replace "true" with "Screen.fullScreen"
what do you think
It means your variable isn't referencing anything - it's reference nothing (null)
i think yes but i wanted to make sure since i have to build and run the game every time to test it so it takes me a while
You could just build like an empty scene if you want to just test full/window
that would take me even longer
sure exporting an empty scene with a few scripts longer alr
How do I "update" OnPointerEnter?
In my game, if I'm hovering over a card, it shows a detailed view explaining what the card does. It only does so, however, if no card is currently selected.
Therefore, in OnPointerEnter, I return out of the method if that bool is true. If I click right click, the selection stops, which works great, but here's the issue:
If the user hovers over a card whilst the lock is active, then right-clicks to remove the lock, the card is not considered "hovered" because right now, I'm not alerting Unity that it should re-evaluate OnPointerEnter. Hope that made sense
u need to keep up with the cards u have currently selected
so would spending all of your time complaining about it here instead of Just Doing It
then u can change the functionallity of what clicks/ hovers do depending on if that card is selected atm
if ive got an animation and its set with a bool and once that bool is true i want the animation to finish even if the bool is set to false during the animation what setting is it to do that
Has Exit Time
i dont see anywhere where i was complaining
thank you
No, that's not what I mean. I want OnPointerEnter to be called again, even though the mouse has not left and re-entered the GameObject
oh, unsure about that oen
Ok
why ?
there are other events
but idk what the usecase is exactly
This is the use case
OnPointerEnter, set bool to true. OnPointerExit, to false. In Update check that bool and run code each frame if it's true
But Unity does not update OnPointerExit and Enter if I don't leave the GameObject with the mouse
I will post a Gif if that's allowed
Well yes I was referring to that
okay, so do your work somewhere else
like, say, Update
OnPointerEnter tells you when the pointer enters the object. That's it.
It would be useless if it ran at any other time.
and you could even do something like flip a bool in OnPointEnter/Exit to tell Update when it needs to do the work
So here you can see that when I right click to remove the "lock" OnPointerEnter is not called because I have not left and re-entered the object
ah ok, i've figured out why i couldn't dash but now i can't move my player character, and when i want to dash it only goes up if i press up on my keyboard and dash
yes, which is why you shouldn't use OnPointerEnter to move the card
you should just use it to set a boolean to true
somewhere else, you can use that boolean to decide what to do
Oh I think I understand. So the objects always no whether or not they are being hovered over?
No matter the lock
know*#
https://pastebin.com/XknAAgRH can somebody help me with this?
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.
i typed the issue at the start
what is this "lock" you are referring to?
So if I click on a card it is considered "locked", so other cards cannot be hovered over if one has been clicked
and that sounds like an issue with your logic rather than how the event system interfaces work
Hm I suppose
use OnPointerEnter and OnPointerExit to do nothing other than set a boolean on the card
decide how to position the card based on that boolean and whatever else you care about
sounds like u have some jumbled if conditionals/ input gathering..
where do you use your inputX variable? or assign to horizontal
Hello. Is it possible to make a Rigidbody ignore collisions with another one based on a tag or something like that? I have a 2D game where the enemies shoot, the bullets have their own rigidbodies, but I don't want them to collide with other enemies
Ok! :)
One last question: Won't that clog Update, though?
like maybe the jump is nested in an if else statement that has to be moving first b4 it gathers the jump.. not sure
your computer is very fast
it will survive running Update 60 times per second on 15 cards
Use layers
oh wops
peep this panel
you'll be able to disable any interactions between layers u wish
I guess that was too much of a begginer question, thank you all!
nah, not at all
ahh yeah you might be right
it sounds that way
most jumps work independently outside the move functions.. when u jump u add a y value to ur overall vector
then when the move function runs, it just has the jump tacked in with it.. but theres other ways too
did u share ur code?
let me lookie
tyty
ya, looks like ur only giving the rigidbody values if ur _isDashing
ah fuck
i dont see any velocity when ur not dashing for example
if(isDashing) {velocity = value with ur dash}else{ velocity = value w/o ur dash}
something like that
should i use that to replace something else or just a new line
well
two lines
just an example.. u shouldnt replace anything w/ it
thats how errors happen.. and people not understanding their own code
i can't move my player character
You only allow the character to move when dashing or jumping.
Well, I guess you sort of are moving in FixedUpdate
Relative to some horizontal variable that is.
if (Input.GetKey(dashKey))
{
movementVector = input * dashForceMultiplier;
}
else
{
movementVector = input * normalForce;
}```
then w/e you move ur rigidbody you have w/e value you need
```cs
playerRigidbody.velocity = movementVector;
That isn't at all used in Update or anywhere that I'm aware of.
this is what im meaning.. change ur values around as u need to.. then w/e u move ur rigidbody you'll have already set which values to use.. whether that be movement w/ a dash or movement w/o a dash
whats usually the best/better method of implementing a simple movement mechanic for a 2d side scroller? Transform.position, rb.velocity, or addforce ?
and are there any others?
uh i never had this problem before when trying to close
rb.velocity
if you move using physics with a rigidbody (by either assigning velocity or adding force) then you won't have to manually check for collisions. if you move using transform.position then you are effectively teleporting the object and you must check for collisions manually otherwise you will run into issues where your collider will penetrate into other objects
ty, what would the use case for the others be tho ?
transform.position if you dont want collisions to work right
AddForce is good to but at times it feels too unpredictable , depends what ur going for ofc
appreciate the explaination :D
now going for 4 minutes
i see, i think I know what u mean. When trying to use addforce, if I keep holding down the button, the addforce just keeps adding so... ty guys
this isn't a code issue and you really just need to be patient. you can force close it if you want, but it's usually best to just let it do its thing
why does one a sprite show up in the middle for one frame? it insta killed me when testing lol
laser code: https://gdl.space/zuvaxinuhi.cpp
laser shooter code: https://gdl.space/italoxorag.cs
I'd do a force shutdown, delete library folder, and reopen to let it rebuild.
i have cheched the animation and it doesnt have a set position in it
you set the position when you spawn it to (0,x) and you do not assign to x so it's just being set to 0,0 until the next frame when that object's Update method runs
also why do you have a variable called x that is being used for the Y position of an object?
i just wanted it to be public in the inspector so i could test what a good value would be, i removed it now
but when u mentioned x, thats for the laser shooter script, not the laser itself
its the laser that spawns at 0, 0 first
its supposed to spawn on the x value of the laser shooter
unless maybe it didnt count it as a local position
something like this i imagine?
Conveniently you have hidden the very thing that shows which position laser is being spawned at
stop showing us tiny snippets of code
it makes it ridiculously hard to understand what's going on
share entire methods in
code blocks
or entire scripts in a paste site
He's explained it perfectly why it spawned on middle for first frame and then moved to desired location
I think it was shared prior but not certain if any changes have been made#💻┃code-beginner message
Fair enough.
@swift crag not to be that guy but he's already shared code haha
#💻┃code-beginner message
All good
Image prefabImage = prefab.GetComponentInChildren<Image>(); i have an image attached to the object and to a child, i need the image from the child, how i do that
I'm used to being shown tiny chunks of code that hide the actual problem 😅
Same 
Image[] prefabImage = prefab.GetComponentsInChildren<Image>();
you'll want index 1
Prefab.transform.getchild(index).getcomponent<image>();
??
ill try that
Could be another child, we don't know how many more images he's stored but ye that's better I guess..as long as we know which index image is at
The spawn position would be the position of the laser object itself.
Scripts do not have positions.
yea thanks guys, i fixed it now
@dusk minnow this is better ^
alr then that 🙂
why not just directly reference the image you need in the inspector?
even better
cant explain but i need the one from above
if you can't explain, then how can you be in a position to implement something?
put a script on prefab that holds a reference to the correct Image. prefab.GetComponent<ThatScript>().image
or reference the prefab by that component's type, rather than GameObject
now you've got absolutely zero instances of GetComponent
for example, here's a pretty tiny example
public class InputActionIconPart : MonoBehaviour
{
public TMP_Text label;
public Image image;
}
(this class now has a bunch of actual logic, but I've removed that to match how it used to work)
all of the members are now private and you interact with it through methods
it's no longer just a "bag of data"
I forget if anyone answered me earlier about if there are other more efficient ways to learn coding and all the fundamentals and stuff besides just Unity Learn?
And the pins here
learning programming does not work like that, 99.9% will depend your ability and the effort you put into it
go see Elon Musk, might be able to get in the Nueralink beta.. and get the programming knowledge downloaded str8 to ur brain
hi peeps, just followed a tutorial to implement player movement 2d and a dash, but it only does horizontal dashes
how do i implement dashes for all directions? https://pastebin.com/q3Anx4TS
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.
Well I know I can understand the stuff once I learn more of it. And I pretty much have been staying up late since setting up my computer so I am very determined to learn all their is to. I plan to try and make a really good game at least in the next 3-5 years or sooner if I really apply myself
knowledge is not even close to being enough, analyic ability, logical thought and pattern matching are things that are very difficult to learn
just like u did the horizontal dash.
instead of multiplying just the horizontal values with teh dash u multiply all the values by the dash
Well then I would like to get better at all of that too. I'm definitely smarter than my fi4rst impression gave off lol.
yeah see, i tried writing an else if statement like "rb.velocity = new Vector2(vertical * speed, rb.velocity.x)" but i'm not sure why they didn't work 😭
what's the keyword for all values
it just comes down to practice and repetition
instead of horizontal
Well I've got plenty of time for practice. And I will repeat things as often as possible.
do u know what that line of code is doing?
Vector2(x,y)
ur multiplying the vertical input with speed for the first value (x)
and then for the y value it seems ur just using the rigidbodies x velocity
w/e that may be..
x, y is normally flipped from how u have it 🤔 (horizontalInput * speed, verticalInput * speed);
or it could just be.. cs Vector2 myVector = (horizontalInput, verticalInput); myVector = myVector * speed;
That would be setting this object's X velocity to vertical * speed and setting its Y velocity to whatever its X velocity used to be
ya, it seems bass ackwards to me
but it could be just b/c of the way ur world is facing
like portrait vs landscape
would something like this work?
nope
oof
GetAxisRaw does not take a boolean as a parameter
And you cannot && two strings to get a boolean
myVector = (Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical"));
oh my
&& is a comparison
omg i'm getting dogged 😭
Also wrong, unless myVector is a float tuple
lol
Vector2
new Vector2()
ahh yea i see
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector2 move = new Vector2(horizontalInput,verticalInput);``` is what i meant to say
the other would've worked too one line if you just had added new Vector2
thats just the basic input... after you grab that u do all the stuff like multiplying with forces and dashes and stuff
this is rough
lol.
it gets easier the more u do it.. but understanding what it is to begin with helps alot..
debug values, watch console logs, experiment etc
thats how u learn
and ofc reading/ studying
https://www.youtube.com/watch?v=GhQdlIFylQ8 is this an ok tutorial for basic c#
This course will give you a full introduction into all of the core concepts in C# (aka C Sharp). Follow along with the course and you'll be a C# programmer in no time!
⭐️ Contents ⭐️
⌨️ (0:00:00) Introduction
⌨️ (0:01:18) Installation & Setup
⌨️ (0:05:03) Drawing a Shape
⌨️ (0:17:23) Variables
⌨️ (0:30:06) Data Types
⌨️ (0:37:17) Working With S...
i had this bookmarked
No
sure
duality of man
Giraffe is ok
anything u expose urself to will be helpful..
Immediate no whenever I see youtube haha
maybe not the best.. but it cant hurt to see what its about
i can't pay for courses because i have no money rn
Who said pay?
so idk what else there is 💀
no need to pay for courses..
the good ones dont pay for shite 🙂
free courses are a dime a dozen
just experiment.. learn.. DO
the most important one being the DO
Literally good resources pinned to THIS channel
if u fail, try again
https://www.youtube.com/watch?v=_cCGBMmMOFw&list=PLFt_AvWsXl0fnA91TcmkRyhhixX9CO3Lw&ab_channel=SebastianLague
heres my favorite
Welcome to this introduction to game development. We'll be starting from the beginning, so no prior knowledge of programming or the Unity game engine is required.
Unity can be downloaded here: http://unity3d.com/get-unity
Watch episode 01: https://youtu.be/9iCnjdXEfMA
If you'd like to support these videos, you can make a recurring monthly don...
it gets ur foot in the door..
should i do both the microsoft one and the sebastian lague one
why not both
like, microsoft first then sebastian
that's what i said
doesn't matter which order
do em both at the same time..
watch a video or two of the playlist.. then go over to text stuff and check out / read a little more context about what u just watched, etc
I'm trying to make a popup that occurs when the player mouses over something and I'm using OnPointerEnter and OnPointerExit to do it, but if I mouse over the UI object, it flickers on an off like enter and exit are consantly calling. I don't really understand why it's doing this
does someone have to go through:
private float a
private float b
void start()
{
a = getComponentBoxCollidersize.x/2
void update()
if (blablbalbla... blablblabla. -725 a)
{
blablbalbal. b
}
this. when they can just measure the objects lenght and get the number then divide by 2 for free? (I know both work. I am asking optimization-wise)
anyone have any ideas for how to do this so it doesn't flicker?
what
Divide by 2 for free?
what does for free mean in this context , im so confused
it's kinda annoying tho for me tho, i'm in my second year in college for game dev in the uk and i don't really know how to do anything game dev wise, and my final project is coming up so i'm kinda just grasping at straws 😭
thats um..school for ya
You dont have to write "a = getComponentBoxCollidersize.x/2" you can just add a mesh collider and look at its X size then divide by 2 is what I mean. then write that number to update manually
yeah, i at least know what variables are, i think :3
lol.. instead of sitting and telling us about how ur losing time.. use that time to be reading/ watching those videos
generally is better if you store the result than GetComponent every frame..
or at least cache the component
GetComponent is pretty expensive in Update
why
GetComponent every frame is being mean to ur processor
I have my project ready I am making adjustments
yeah. That's why I think of removing it
Hence why I suggested GetComponent in Update is bad
cache it Once.. use the reference u cached the rest of the time..
yeah its easy, just store the reference
anyone know a better way to do this?
no thanks I am bored. I will do all manually. Good night.
well depends what ur donig OnEnter ofc
why the hell would you ask if you dont take our advice then
i honestly dont care, its ur project 🤣
ur only hurting your on game's perfomance
To see if there would be any downsides to it.
we just told you...
How?? I will remove getcomponent ffrom all of them
it depends on what? the OnPointerEnter function is on a script that is on a canvas UI element
because what SpawnCampSuggested is how you fix it instead of entirely removing it
but yeah its your project do whatever
wdym
what does OnPointerEnter DO in the script.
I know what function is
oh. it turns on a gameobject that is the mousover text
and turns it off when you stop mousing over
then its blocking the raycast
untick RayCast target in TMP component's extras section
"Oh no, I accidentally made this mesh too big, I need to adjust it's size slightly."
A normal person: Adjusts the size
You: Spends six weeks changing magic numbers, missing some, encountering bugs, and repeating
its in an endless cycle, You enable it it blocks raycast and runs OnPointerExit then disables then blocker, Running OnPointerEnter again
rinse and repeat
this is how u'd cache variables...
- in the Awake() for example (Only runs once.. u get the component and set it)
- then when you use it in Update or w/e you're getting the reference you already set.. instead of GetComponent every time..
Massive downsides
thanks. I did that but it's still flickering. could something else be blocking the raycast besides text?
How could there be downsides to measuring 33 game object's mesh's X value then diving by2 then writing manually 🤣
It has been explained to you over and over
there's a panel behind the button, but no other ui element overlaps
use a bigger collider over the text.. and the text attached to it..
It's terrible
using Text as the collider itself is terrible.. b/c u have to hover exactly over the little bits of the letters
Could be, the best way to find out what it is. Inspect the Event System during playmode
it will tell you exactly whats being Hit
if anything share script as well
omg
the popup is blocking itself i think
i didn't think of that
yep that was totally it
Yeah, that's a common error.
niiice
thanks for this tip! < 3
np!
Indeed! wow surpised you didnt know this one 😏
i usually have that window collapsed
yeah its not very obvious that can be expanded
i only thought it was a preview window
for models and audio clips and whatnot
didnt even think of it displaying data like that
Veryy handy for debugging !
back in the day I had no idea text objects also had Raycast bloking until I found this
It can also display things like layout properties for RectTransforms.
When I'm updating the colour of a UI material, UI elements inside a Scroll View aren't updating. Does anyone know how to force a Scroll View to refresh and adopt the changed colour?
Very useful for understanding why your UI is doing whatever it's doing
yea, game changer!
the scroll view has nothing to do with the color of the graphics that happen to be parented to it
it just moves a RectTransform around
those graphics must have different materials
They have the same material attached
must be somewhere else then where you're not setting them properly
perhaps you're instantiating the materials somewhere
Every UI element adopts the new colour except the elements inside the Scroll View. The actual material itself is being changed
are those objects instantiated ?
I was thinking of UGUI
oh I thought also they meant ScrollRect
ScrollRect is the UGUI component.
this changes things then certainly, Uitoolkit is tricky with binding changes
I haven't learned UIToolkit yet myself, so I can't say too much
It's the element generated when choosing UI > Scroll View in the Hierarchy window
Okay, so this is UGUI.
oh then its the ScrollRect
Do the colors change when you modify the material outside of Play Mode?
Yeah
How are you filling that Container ?
Image
are they instantiated
i'm not sure how you'd put objects in a scroll view that aren't instances
No, these particular ones are just individual objects existing on the canvas
oh, I see what you mean
before gamemode you drag them inside ig
Do you think using prefabs for them would help?
oh na I thought thats why it was different maybe
but nvm
can you maybe make short vid of what's going on with others n stuff ?
Sure
The top boxes are in the scroll view, I placed that single one below outside of the scroll view just to show that it works outside of it
I wonder if your images are getting crushed down to 0x0 size
which could happen depending on how your layout group is set up and how the individual elements are structured
hm, but I'd expect that to happen outside of play mode, too
(and you'd need to have another image in each element, or else the element would just be completely invisible here)
Does it make a difference that these objects are inside horizontal layout groups that have content size fitters?
Do they have a parent that also has a layout group?
You will see a warning in the ContentSizeFitter if so
Yeah they're in horizontal layout groups for the rows, and all rows are nested inside a vertical layout group
Okay, that's not correct.
This is going to screw up the layout calculations, since each horizontal object is going to be trying to set its own size
You should have one content size fitter, and it should be on the "Content" object
The gist of auto layout is that each layout group asks its children for how much space it needs, then asks for enough space to contain them
If you don't have layout groups all the way down, an object will ask for zero width and zero height
ContentSizeFitter is used when you don't have a layout group in your parent
like on the Content object in a default scroll view
btw also could you show how do you change the color in code?
I'm guessing that each item here has a "background" image and a "foreground" image, and then the foreground image is getting shrunken out of existence
i'll need to see the hierarchy to say anything more concrete
- Content <- ContentSizeFitter, VerticalLayoutGroup
- Row <- HorizontalLayoutGroup
- Item <- VerticalLayoutGroup
- Foreground
- Item <- VerticalLayoutGroup
- Foreground
- Item <- VerticalLayoutGroup
- Row <- HorizontalLayoutGroup
an example
had to double check, but yea scroll rect has no effect
You can see it here. It's just a rectangle with the background colour. I just made it as an easy way to make the green border
i thought that was what "BG" would be for
Can we change splash screen images without a pro+ plan?
not until unity 6
material.color = newColour;
newColour being a hex
So I should be able to. I have the latest LTS 2022 version so
Unity 6 isnt even out yet
oh you're not changing the color on the image compoent ?
No, changing the material itself so that every object with that material will update
Anyway, you need to add a LayoutElement to "Classic Skin 1". Turn on Minimum Height to enforce the height. Turn on Flexible Width so that it'll grow to fill the horizontal space.
"Classic Skin 1" should not have a layout group on it. All of its children should also not have layout groups or layout elements on them.
Set all of those children to stretch in both axes, then adjust the left/right/top/bottom properties to create margins as needed (e.g. the "Swatch" should be pulled back on all four sides a little)
Next, make sure that "Row 1" has a HorizontalLayoutGroup. It should be set to control child size in both directions. Turn off "force expand" in both directions.
Next, make sure that "Content" has a VerticalLayoutGroup and a ContentSizeFitter. Configure the layout group as above, and then make sure the content size fitter uses the minium size vertically.
I believe that your current setup is causing the swatch image to shrink down to 0x0 in size
if i wanted to make a physcis lever would i use a configarble joint and lock the other axis?
depends..
what kind of lever, hinge also works
The LayoutElement will control the size of each box. The layout groups will arrange them properly.
i want it to be able to go up and down
oh ok , maybe try doing it how I do it and loop through images u want to change.. My guess its creating a copy of the material maybe or probably what Fen is saying
and the character can move it by grabbing the end and pulling it up or down
a hinge should work just fine IMO
you can check if I'm correct by checking the scene view whilst the game is running. Select the various parts of each skin button and see how large they are.
okay i will try that
configurable joint is prob one of the hardest ones to tinker with
Sounds like a hinge joint to me.
It swings around a single axis
yeah def a hinge
Thanks for going in to so much detail for me. Those changes appear to have made the height 0
Control child size on both axes.
you will want to do that on every layout group
Ah yeah, missed that, thanks. Now Content is 0 altogether. Is that to do with the min height of my Elements, which are currently 0?
Show me the inspector for Row 1
and now for Classic Skin 1
You need a non-zero Min Height
set that to whatever you want the element's vertical size to be
Can someone help with this code, It gives me error Not sure why as the thing i need IS assigned in the inspector script!
public class Health : MonoBehaviour
{
public int health;
public bool isLocalPlayer;
public RectTransform healthBar;
public TextMeshProUGUI healthText;
private float originalHealhBarSize;
private void Start()
{
originalHealhBarSize = healthBar.sizeDelta.x; // Error for the healthBar.
healthText.text = health.ToString();
}
[PunRPC]
public void TakeDamage(int _damage)
{
health -= _damage;
healthBar.sizeDelta = new Vector2(originalHealhBarSize * health / 100f, healthBar.sizeDelta.y);
healthText.text = health.ToString();
if (health <= 0)
{
if (isLocalPlayer)
Debug.Log("Respawn");
Destroy(gameObject);
}
}
}```
```c#
UnassignedReferenceException: The variable healthBar of Health has not been assigned.
You probably need to assign the healthBar variable of the Health script in the inspector.
UnityEngine.RectTransform.get_sizeDelta () (at <f7237cf7abef49bfbb552d7eb076e422>:0)
Health.Start () (at Assets/Scripts/Health.cs:18)
(also, this is a #📲┃ui-ux problem, so we should go there if the problem isn't solved yet)
Thanks Fen, the layout looks right now. However the problem of the colours not updating remains
Aha alright, thanks
if its assigned, check there are copies of this script on other objects
search t:Health inside hierarchy
is this the correct scene 
yes
show me how you assigned it then
Okay so
Player has the script, I selected the "Health" bar the one thats a child of Health BG dragged it into the script into the little box where u can put it and now it looks like
check it during playmode the one spawned, if its empty something else is changing it
Run it after the game starts, when your error is in the console
what have i setup wrong?
why did you not use hinge like suggested ?
what is even the point of asking others if you dont take their responses
i think i added the hinge whilst in game mode and it undid it my bad
I aint sure whats wrong its there and no error now didnt change anything im so confused though
Thanks though
Hey, I'm trying to implement an inventory system with PUN but I keep on getting this error when picking up an item.
This is the part of the script where it calls the add item method
IInventoryItem item = collision.collider.GetComponent<IInventoryItem>();
if (item != null)
{
Debug.Log(item.Name);
Debug.Log("collect item");
inventory.AddItem(item);
}```
and this is the inventory class
```c#
public class Inventory : MonoBehaviour
{
private const int SLOTS = 10;
private List<IInventoryItem> mItems = new List<IInventoryItem>();
public event EventHandler<InventoryEventArgs> ItemAdded;
public void AddItem(IInventoryItem item)
{
if (mItems.Count < SLOTS)
{
Debug.Log("Hit Item");
Collider collider = (item as MonoBehaviour).GetComponent<Collider>();
if (collider.enabled)
{
collider.enabled = false;
mItems.Add(item);
item.OnPickUp();
if (ItemAdded != null)
{
Debug.Log("Add item");
ItemAdded(this, new InventoryEventArgs(item));
}
}
}
}
}
If there's anything obvious I've done wrong please let me know, thanks 🙂
Which line is line 100
inventory.AddItem(item);
inventory is null
casting to a MB to use GetComponent is really weird
will check that, thanks 👍
like would have methods on the interface to do the checks you need, or simple have GetComponent be part of the interface
What's MB?
MonoBehaviour
ah
protected bool isOnPointer;
public void OnPointerEnter(PointerEventData eventData)
{
isOnPointer = true;
}
public void OnPointerExit(PointerEventData eventData)
{
isOnPointer = false;
}
private void Update()
{
HandleHighlight();
}
private void HandleHighlight()
{
if (isOnPointer) HighlightSelf();
else UnhighlightSelf();
}
Because of the way the objects are layered, when the mouse moves from left to right, OnPointerEnter is called before OnPointerExit, and when the mouse moves from the rightmost card to the leftmose, the other way around. However, I would need either to be called in both cases. Any idea how?
You know that there are events for UI element being Selected or Deselected
You dont need to make this system from 0
What does "Selected" even mean in this context
If it's a UI, of course
the selected in this context is mostly for stuff like gamepad/keys navigation
Nope
Also for mouse
When you hover over UI selectable like button
Ok ok but that does not answer my question
It is also selected
Make a manager class that has a variable for the currently hovered card. Have that object use raycasts to detect which card is currently hovered. Whenever that value is different from what it used to be, send a message to the old card telling it to unhighlight itself, then change the selected card, then tell the new card to highlight itself
IInventoryItem item = collision.collider.GetComponent<IInventoryItem>();
if (TryGetComponent<IInventoryItem>(out item))
{
Debug.Log(item.Name);
Debug.Log("collect item");
inventory.AddItem(item);
}```
So I managed to turn it into this using the TryGetComponent but nothing's happened - that means that item is null?
oh right
also this code is far from correct
nuke the first line of it and make it
if (collision.collider.TryGetComponent<IInventoryItem>(out var item))
Oh thanks that's made it better
I'll have to look for a way to make inventory not null as that seems to be the main problem
So I got kind of an esoteric question. I play a lot of games where, if they're not in fullscreen, they have the maximize button greyed out. This irks me to no end. Is it super hard to impliment or something?
heavily depends on the game engine and how UI works
often its done that way so the aspect ratio can be enforced
Well the one Im looking at right now is unity
its prolly so they can enforce the window be like 16:9 or something
that way you can like maximize it on a ultra wide
or because they want to use very exact resoultions
So I have a quick question for the pros, I am trying to code player movement. I 1st learn to make a player move by adding force to it and now I have discovered "CharacterController". Does it really matter or is it really important how you code the player movement? I feel like a b**ch for using something like this instead of hard coding the movement by myself.
u still code the movement.. the character controller is just the component u tell to move. the only thing it does is has built in ground checks and the ability to collide and traverse stairs
If it turns out how you want it, it doesn't matter how you made it.
its really more of what component fits my needs better
does anyone know why this happens? this animation triggers when i click and it kind of glitches when i click but works fine when i hold the mouse button down. also the errors are unrelated
hey guys.
im getting an error saying i haven't given the match argument even though i have. what's the issue?
List<Assault_RallyPoint> validRallyPoints = rallyPoints.FindAll(CanUseRallyPoint);
public static bool CanUseRallyPoint(Assault_RallyPoint rallyPoint) => rallyPoint.shouldLockRallyPoint ? !rallyPoint.occupied : true;
What is the actual error
You should keep this window open
Error CS7036 There is no argument given that corresponds to the required parameter 'match' of 'Array.FindAll<T>(T[], Predicate<T>)' DELTAV D:\Aperture-Delta-V\DELTA-V_HDRP\Assets\Scripts\DeltaVBase\AI_AgentSys\Sequences\Sequence_Assault.cs 55 Active
FindAll needs a second parameter https://learn.microsoft.com/en-us/dotnet/api/system.array.findall?view=net-8.0
or rather
it needs a first one
Should be Array.FindAll(rallyPoints, CanUseRallyPoint);
oh ok it keeps going back to blank without finishing the animation i think
FindAll takes two parameters. You've only given one
https://www.geeksforgeeks.org/c-sharp-array-findall-method/
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
then it's a problem with how you set up the state machine and/or the code controlling it
this is a list not an array, it takes on peram:
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.findall?view=net-8.0
according to your error it's an array, not a list. Show how rallyPoints is defined
would setting an exit time fix anything?
maybe? It depends what you're doing and how your code works.
public List<Assault_RallyPoint> rallyPoints = new List<Assault_RallyPoint>();
show the full script
something isn't adding up
the error clearly thinks it's an array
why do I feel bad when I take on the easy path 😭, rigid body has his own physics, CharacterControl has easy control over character but you have code physics to it
when i use Destroy(gameObject) on an object, the particles it has already emitted also get destroyed
is there another way to do this?
I'm instanciating a little light glow effect that shoots out some particles, but i want to remove it without destroying the particles its already made
Destroy(gameObject, delay)
Stop emission, don't destroy the particle system
Or don't destory it yeah
you can't destroy the particle system and expect it to keep rendering particles
my code is just this
animator.SetBool("Hit", Input.GetMouseButton(0) || Input.GetMouseButton(1));
your code is not just that
it's a lot more than that
for example where is this line?
so i should separate the particle system onto a parent object
destroy the light child component
and stop producing particles then destroy the main one like 10 seconds later?
i mean the code to trigger that animation is just that
You should'n't be using a bool to trigger an animation
you should be using a trigger
If you really want to destory it, set the destoy delay to the lifetime of the particles
its being instanciated every time the player picks up an item so i have to destroy it
ill do this
Destroy(gameObject, delay)
guys I swear im losing my mind, my charater is flying off into the distance and I dont know why
{
private CharacterController _controller;
void Start()
{
_controller = GetComponent<CharacterController>();
}
void Update()
{
Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
_controller.Move(move * Time.deltaTime * Speed);
}
}```
This is one example where CharacterController is used,
And this is another, why would they use "GetComponent" if the game is solo and not multiplayer?
set the delay to the lifetime of the particles
void Update()
{
transform.position = rb.transform.position;
}
private void FixedUpdate()
{
rb.AddForce(transform.forward * forwardAccel);
}
why does this make my object fly
is it olliding with itself?
The rigidbody moves by itself
You're moving twice
AND
Adding a lot of force
it should be gently rolling forward, but its flying off into the sky
What on earth is the point of your Update function
if it's rolling, you're adding force in whatever its forward direction is
which may be up
or down
Actually
The parent object is moving to the position of the ball
it will change as it rolls
Well that's why
Child objects follow parent objects. So you move your parent, then the child follows, then you move the parent again...
Im attempting to ollow this tutorial
why are you doing this
I would guess you set up the scene incorrectly compared with whatever the tutorial is doing
I thought the same but I cant see how
He has an empty game object with some visuals attached
then adds a sphere to add rb forces
Learn how to create Arcade-style Car Driving in Unity with a brand new tutorial!
Download the setup project files here: https://drive.google.com/open?id=1qVal_BSXdE5mYtA_8douoVSKkYNIAM3w
Wishlist 'Scoot Kaboom and the Tomb of Doom' right now at http://bit.ly/scootkaboom !
Get my new Udemy course 'Learn To Create A First Person Shooter With Un...
If you have the patience
its 5 mins in
the objet setup is 2 mins in
This is a weird setup
What does multiplayer have to do with it
Yeah
Why not just add the rigidbody to the model?
anyway without seeing what you did it's hard to say what's wrong
Or have the model be the child
very true
maybe your parent object is rotated incorrectly for example
I would love to find another solution to my goal but Im still a real beginner and this tutorial basically achieves it
make sure this is on local so you can see which wat it's really facing
I dont know enough to find a better solution
u probably should have the rigidbody on the Player
forget about multiplayer, why would you do GetComponenet?
You can make the variable public and just drag to the script in unty
and the collider.. the sphere should jsut be graphics

continue