#💻┃code-beginner
1 messages · Page 189 of 1
bc i needed it to make a quaternion 😮
im sure there are plenty more things in there that arent even needed, ill get to them soon
Quaternion.Euler(0, yRotation, 0)
yea i guess your right haha, i think i did that bc last time i got in a kerfuffle for doing math inside a MoveRotate() method with a quaternion
its not related but i miss on my part
so my intellisense stopped working, how do I get it back?
!ide
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
does anyone know why my "if (Input.GetKeyDown(KeyCode.Space))" inside "playersCombat()" method only works once?
Is the object getting disabled/deactivated perhaps?
i dont know but i didnt put any condition to disable it yet.
this in the entire code:
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerCombat : MonoBehaviour
{
[SerializeField] bunnyStatScripts _bunnyStats;
[SerializeField] GameObject _gameOverScene;
[SerializeField] int _damage;
int _newHealth;
void takeDamage()
{
int _newHP = _bunnyStats._health - _damage;
_newHealth = _newHP;
if (_newHP == 0)
{
_gameOverScene.SetActive(true);
}
}
void playersCombat()
{
if (Input.GetKeyDown(KeyCode.Space))
{
takeDamage();
Debug.Log("you pressed space");
Debug.Log("HP: " + _newHealth);
}
}
void Start()
{
_gameOverScene.SetActive(false);
Debug.Log("HP: " + _bunnyStats._health);
}
void Update()
{
playersCombat();
}
}`
check if the method is running
which method? playersCombat()? if so, then it runs but only once
yes, or update, since your update will call that method
you can log in ondisable to find out the one that disables your object
Wdym "I don't know". Can you not pause the game and look in the hierarchy/inspector???
i tried what u said and paused after pressing space and the object where the script is, is still active but pressing space again does nothing anymore
ondisable?
are there any error
i used debug.log and yea it only shows once
public void method(){
if(some condition){
log
}
}
```is completely different from
```cs
public void method(){
log
if(some condition){
}
}
```the above one is not the way that verify the method is running
btw i guess there are errors
does basic movement go in a state machine or in a regular class on its own?
Can you take a screenshot of the whole console window?
Not quite sure what you're asking. What state machine are you referring to?
im probably too inexperienced to even describe it, but im trying to break my movement up into states so I dont get spegeti code like i did last time. The catch is i have it set up but dont know exactly how to actually code the movement in there. Im sure i just need to watch a few more vids and be patient
how do you code rigidbody movement in a stamemachine? theres no fixedupdate to use
i did what u said and this is what showed on the console now
sure
Pressing space works just fine. You have Collapse on in the console so you see each log only once.
The problem is that you never change _bunnyStats._health
Again, what do you refer to by "state machine"?
State machine is a programming pattern there are millions of ways to implement one,but most of them have some for of state update, so your question doesn't make sense.
im following this tutorial https://www.youtube.com/watch?v=Vt8aZDPzRjI
Learn the fundamentals of programming State Machines in Unity with this new video break down!
This tutorial explains important concepts of the State Pattern, and how to use State Machines when programming! Today we will walk through an example project to showcase the benefits of using state, the state pattern and state machines in Unity!
This ...
- You're free to update the states in whatever update you want.
- You're not limited to only one update. You can implement both a regular and a fixed update in the states.
- You don't have to move the character from within the states, they could just be setting some important variables, like movement speed for them to be used in the actual character movement logic.
so your saying I could run private void FixedUpdate() { } in the EnterState and it will continue running while its in that state?
If you call it from a MonoBehaviour, sure.
In which case it would have to be public
thats weird, but useful
Why is it weird?
ill try with making a movement script and changing the values in the states
tysm yea it works fine now
and calling FixedUpdate on EnterState, Idk, just being new to it FixedUpdate and Update are intimidating to use correctly
They're just methods called by unity regularly. There's nothing special about them
wait hold up, if i am correct, void Update() { currentState.UpdateState(this); } basically means it uses the code in that method in the StateManager Scripts Update function, so you wouldnt have to write an update fuction inside the state manager, you could just write ```void FixedUpdate()
{
currentState.UpdateState(this);
}
im not going to write my movement code in there, bc it will only make my code redundant, but just a thought
Assuming, you keep both, you'll get state update called on both updates, likely messing up the logic in it.
no just having it in the managing script
it is challenging to break up this code correctly
Not sure if this is the right chat for this, but I can't find anything more appropriate. Can I make the red image render on top of the other item slots?
Next time if you don't know where to ask, use #💻┃unity-talk
Move the image object below the item slots in the hierarchy
I need it to be a child of one of the slots.
Can't do that 🤷♂️
Will have to rethink whatever it is your doing.
Damn.. ok thanks.
Can someone explain to me if i write public float someFloat = 5.0f; and save it then i change the value to 2.0f and save why unity still thinks my float is 5?
You're probably looking at the wrong instance
it's like once it declared it's set to stone and i only can change in editor not via script
because that's the default value, the actual value comes from the inspector
If you don't want the inspector to set the value then don't make it public
but isnt the inspector value should update according to script?
What makes you think it's not changing?
Show the log
because i can see its not updatin in the editor. same with bools once i say in script bool = false then i delete the false part (by defaut bool are true), it still false in the editor.
Likely you're referring to a different instance
Show where you've changed it in code
And log the value after
can someone help me with my web swinging movement codee please?
Quick question, I'm well aware this can't possibly be the correct way to do this, but I'm not sure what the correct way is (I'm checking if the camera is within a set box, marked out by the corners) (Corners 1 & 2 are Vector 3s) (It's a 2D game) (This little overcomplicated if statement doesn't work anyway) (I think I'm addicted to brakets)
lol forgot to attach the screenshot
you can create a Bounds and then use the Contains method
If you have a specific question, im sure someone may be able to help if they know a solution - what have you tried so far, and what is the result your trying to achieve?
... so how do I do that? "public bound box;"
locking onto objects and being able to swing from them. but i have got that working but i keep swinging from the first place i shoot even when i am not holding my trigger button down
👍 thanks!
Cool feature
i have a 2 slider mouse X and Y sensivity. on valuew change i save it to player prefs: PlayerPrefs.SetFloat("mouseX", mouseX.value); and i load it with mouseX.value = PlayerPrefs.GetFloat("mouseX", 2.0f);. this works fine, even if i change scene still work. but for my mouseY it's working in the main menu (it loads the default 2.0f) but i can't load it in the game(after scene change).
What do you mean by not being able to load it?
Did you save the player prefs?
So your issue is that your swing logic is happening all the time instead of only when you press the relevant input? What does your !code look like?
📃 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.
i mean the value changing to 0 even if i save it after change and load it on awake
hii, when I assemble objects together (in VR) and I take the parent object, and I move the object in all directions, the objects which are assembled on it slide a little, it floats and I want to know if it is possible which remains fixed and no longer moves at all as if it were a single object ?
So you've called the save function from player pref?
but in the main menu always loads the correct sat value
Else you'll be working with a local copy that'll not update the file till after the application closes
i use the slider on value change thingy to call a save function which should save the value of the mouseY. same thing as i showed with the mouseX but with Y
So you called the player pref save function?
im pretty sure but let me debug the heck out of it.
where does this go?
You'd probably want to have it called before the scene has changed
Havnt worked with VR, though sounds like your child objects might have rigidbodies and colliders, if you dont want them to respond to physics, you can disable their colliders and freeze the constraints on the rigidbodies or remove their rigidbodies as well
I need physics and their collisions
If you have physics, things will slide and react to collision objects, alternatively then you could either freeze the constraints, increase the drag, set to "is kinematic" or force the position and rotation by code
i guess i solved it by a noob mistake im too shy to admit. however thank you for your time trying to help me.
Hi, quick question, if I want to have a 1st person camera and a 3rd person camera on input, is it better to have 2 cameras and switching between them or changing all of one camera values ?
if I slip the constraints I will not be able to take the object in my hand and assemble it myself
having 1 camera is better imo, especially when you apply post processing so they don't override each other
Are there any tips for trying to do a camera-based third person character that moves respective to the normal of the ground?
Like I feel like I'm missing some key component; like if upside down and you still want them to move forward, but that's technically upside down.
You could freeze it after youve assembled it, and unfreeze it when you need to move it again, or you could try some of the other suggestions and see if they help
I have dumb peoblem
do you know how to freeze the object once assembled and remove the gel once it is recovered?
Thats what freeze constraints does, it prevents a rigidbody from moving due to physics on specific axies, so you can toggle the axies you want to allow or disallow movement on as needed
I’ve programmed before and I decided to get back at it it using unity.learn and I realised that in the course the code is very well badly coded, it uses tons of unnecessary public variables and weird forms of writing simple code?
Does transform.rotation = (grounded) ? Quaternion.LookRotation(transform.forward, ground_normal) : Quaternion.identity; look bad? Trying to make my character constant stand upwards following the ground normal, and while it works with slopes going towards the X axis, but fails to rotate correctly with slopes going on the Z axis
Nevermind, played aroudn a bit and transform.rotation = (grounded) ? Quaternion.FromToRotation(Vector3.up, ground_normal) : Quaternion.identity; did the trick
you dont need the brackets around grounded btw
if your character’s collider moves at all upon rotation, this will not work
I'm trying to look for lines of code to freeze the positions when I place the object and unfreeze when I take it but I can't find it
Heres the docs for how to use rigidbody constraints: https://docs.unity3d.com/ScriptReference/Rigidbody-constraints.html
I have noticed that while at full screen in Game mode (but doesn't need to be actually running so is not script related), if I tab, the interface moves slighty, like it is resizing even though the screen size is not changing at all; I can not be sure of what's actually happening cause it only happens at full screen and I cannot check the inspector casue as soon as I exit full screen it resets back; is this normal? Is something wrong in my interface setup or what?
If you know it's not script related then don't post to a code channel. If you mean the game's interface then post a video or screenshots to #📲┃ui-ux
Oh, you are rigth, there is a specific chanel for that, I though this was more of how the canvas is coded thing, sry
C# and Unity
It freezes the position when it is not on the slot but I still have the problem :/
probably cars aswell and driving logics
If the constaints are frozen and it still slides, then its possible something else is the problem, could you maybe record a video showing the issue and your rigidbody settings?
yes
hey so im currently working on a save and load sysetm using jsons i have ran into the problem of how do i save like the actual scene in it because for example i have enemy spawners placed throughout the scene and when you go past a certain area they spawn a few enemies how do i save those spawned enemies???
guys the guy in the tutorial is trying to teach me how to make collisions and he says i need layers, when he goes to the layer section there already are 2 layers assigned but for me there arent. how can i assign them to my player and to the background? here are the pics of reference:
left pic is his right one is mine
you can't "save" entire scene
save what data you exactly want
enemies positions
enemies health etc
if i save the gameobject can i then use that to instantiate it since its a prefab or do i need to drag the prefab from the editor
If you drag it from editor you will use that exact object. IF you drag it out of prefab folder it will make new one.
If you just want to spawn you should use the one in Prefab folder.
Doesnt look like you have any constraints frozen here, alternatively you could try toggling "is kinematic"
nvm i figured it out
I found a solution I set its parameters to the maximum
When making weapons why should I use raycast to check for hits instead of generting a bullet?
Considered raycast is pretty much instant
i dont understand the addforce function at all
https://docs.unity3d.com/ScriptReference/Rigidbody2D.AddForce.html im reading this rn
It adds a force to the rigidbody. The force modes might be a bit confusing but this infographic should help clear that up
basically i want to add a force leading from the direction the player's gun is firing in
recoil as a jumping mechanic basically
{
[SerializeField] AudioClip ShotgunClip;
[SerializeField] AudioSource audioSource;
public Rigidbody2D playerbody;
public Transform transform;
[SerializeField] private float thrust = 832998f;
Vector2 launchcalculation;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
PlayerShoot();
}
// Vector2 rotationshit = transform.rotation;
print(transform.rotation.eulerAngles.z);
launchcalculation = (transform.rotation.eulerAngles.z,thrust);
//transform.rotation.eulerAngles
}
void PlayerShoot()
{
audioSource.PlayOneShot(ShotgunClip);
playerbody.AddForce(transform.position * thrust, ForceMode2D.Impulse);
print("player shoot");
}
}
launchcalculation refuses to take eulerangles.z as a parameter
Why are you using a position as a direction
Why are you trying to store a tuple into a variable of type Vector2
Honestly what is even the point of launchcalculation, you never use it
Hi. I tried to find the difference between 2 types of security modifiers: "Empty" and "Private". I know that private can only be used in the same script, but it's the same with an empty one. Is there a difference and what is it? On the Internet, as usual, they talk about everything except this.
When no access modifier is provided, private is assumed
Whenever I try and click the button underneath the text it dosen't work because the text has a hitbox, is there a fix?
Oh, I get it. Thanks
Prolly should've posed in UI but whatevs
Disable Raycast target on the text
weird question
it's 2 different approach
it depends on your game design
if you want raycast hits (hit-scans), or projectile-based hits
lasers (hitscan), arrows (projectile based)
I noticed that at high speeds triggers happen to fail
if you are moving throught modifying the transfomr position directly then it might happen
need physics for proper collisio ndetetion
and different collision detection mode for fast objects, like Continous
I’m using Input.GetAxis but I want it to only work when I press w and when I press x it does nothing
i dont understand why my script isnt adding force to another rigidbody2d
basically with the script i have rn i want to make it so that it adds the force to the player character
Show code
just experimenting with adding forces for now, have this rn
using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] AudioClip ShotgunClip;
[SerializeField] AudioSource audioSource;
public Rigidbody2D playerbody;
public Transform transform;
public Transform crosshairpos;
[SerializeField] float thrust = 1f;
Vector2 knockback;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
PlayerShoot();
}
// Vector2 rotationshit = transform.rotation;
print(transform.rotation.eulerAngles.z);
// launchcalculation = (transform.rotation.eulerAngles.z,thrust);
//transform.rotation.eulerAngles
Vector2 direction = crosshairpos.position;
Vector2 knockback = direction * thrust;
print(direction);
print(knockback);
}
void PlayerShoot()
{
audioSource.PlayOneShot(ShotgunClip);
//playerbody.AddForce(transform.rotation * thrust, ForceMode2D.Impulse);
playerbody.AddForce(transform.up, ForceMode2D.Impulse);
//print("player shoot");
}
}
this works fine when i add a rigidbody to the shotgun object
but doesnt work on the player character for some reason
Does your player character set their velocity to a fixed value at any point
this has nothing to do with mass and gravity scale
just using a basic getaxisraw
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Playerr : MonoBehaviour
{
public float moveSpeed;
public bool isMoving;
private Vector2 input;
private Animator animator;
public LayerMask solidObjectsLayer;
private void Awake()
{
animator = GetComponent<Animator>();
}
private void Update()
{
if (!isMoving)
{
input.x = Input.GetAxisRaw("Horizontal");
input.y = Input.GetAxisRaw("Vertical");
Debug.Log("This is input.x" + input.x);
Debug.Log("This is input.y" + input.y);
if (input.x != 0) input.y = 0;
if (input != Vector2.zero)
{
animator.SetFloat("moveX", input.x);
animator.SetFloat("moveY", input.y);
var targetPos = transform.position;
targetPos.x += input.x;
targetPos.y += input.y;
if (IsWalkable(targetPos));
StartCoroutine(Move(targetPos));
}
}
animator.SetBool("isMoving", isMoving);
}
IEnumerator Move(Vector3 targetPos)
{
isMoving = true;
while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
{
transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
yield return null;
}
transform.position = targetPos;
isMoving = false;
}
private bool IsWalkable(Vector3 targetPos)
{
if (Physics2D.OverlapCircle(targetPos, 0.2f, solidObjectsLayer) != null)
{
return false;
}
return true;
}
}
``` idk what i did wrong but for some reason my code wont make me collide as intended even tho i did as the tut said
this the vid https://youtu.be/dbMm2_M3Wfc?si=SrZSqoJapYnSq390
Sorry for this video's bad editing :( I will improve!
Chapters:
00:00 - Intro
00:12 - Recap
00:56 - Theory on collisions
02:50 - Create Layers
03:59 - Create the object
08:02 - Coding the logic
14:33 - Debugging
15:54 -Testing the game
Links
Visual Studio Download: https://visualstudio.microsoft.com/downloads/
Character Sprite: https://gith...
So you're teleporting the character every frame without regard to the forces currently acting on it. Your addforce is working, but any movement it confers is overwritten by a teleport to a specific spot
if your player is a dynamic RB, then yes
if your player is anything else, then no
dynamic RB is always at the mercy of the physics engine. Kinematic RB only goes where you tell it to. I recommend you choose carefully.
Kinematic RBs work by MovePosition. Dynamic RBs work by AddForce and velocity
@polar acorn help me out lil bro 
Just fyi #📖┃code-of-conduct
Looks like your player has no collider or rigidbody
Wait, your player is a UI element? Interesting
so look, the tut didnt say nun about that but i still made it work using the tut and chatgpt but there is one issue. whenever i collide with something the distance between me and that "solid object" is too great
i just did as the tutorial says man i have no idea if its right or not
the distance of collision is too big is what im trying to say
I remember there being a better practise than abusing recursion, what was it again?
private IEnumerator IncrementAge()
{
_age++;
if (_age > EXPECTED_LIFE_TIME)
{
Die();
}
else
{
yield return new WaitForSeconds(10);
StartCoroutine(IncrementAge());
}
}
Just loop? If the age is overlifetime die and break
If not, continue looping
Recursion can be fine, but in this case, you are creating a new IEnumerator each time
Can you give an example
I'm not sure which part needs an example
while
if age to big
Die
Break
else
Wait
Yield null
Might not need that yield null actually
The while condition could also be the age
while age
Yeah, that's what I thought
private IEnumerator IncrementAge()
{
_age++;
while (_age <= EXPECTED_LIFE_TIME)
{
yield return new WaitForSeconds(10);
StartCoroutine(IncrementAge());
}
Die();
}
So something like this?
No, the age increment needs to be inside the loop. And get rid of the start coroutine
The whole point is to remove the start coroutine
Ah yeah right
private IEnumerator IncrementAge()
{
while (_age <= EXPECTED_LIFE_TIME)
{
_age++;
yield return new WaitForSeconds(10);
}
Die();
}
can someone help me with fixing my collision issue? my character to solidObject collision works but for some reason the distance between them is bigger than intended
look at the collider gizmos
what is that and where is that
i would not store an age variable tbh
the green outline of your collider in scene view
I would store a timestamp for birth, have a property to interpret age, and a single coroutine to call Die() after a single wait call
everything is right with that. thats the problem the collision distance is greater than the outlines
No it's not an actual age, it's more of a game design choice
by how much? There's a "default contact offset" setting in physics settings which is like an additional buffer
How are you determining "collision distance"
What value is it and what are you expecting
can i somehow show u in vc by sharing screen because my explanations are pretty bad
same goes for u "
do you need to know about accurate collision distances?
no
are you using Physics2D?
make a thread and post screenshots
fair enough
!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.
yes
ok, i can explain a bit then
ok
Physics2D uses Box2D. For math reasons, all edge and polygon shapes have a radius tied to them for collision purposes.
This includes basically all Collider2D except circle colliders (and maybe capsule colliders?)
The default edge radius is something like 10^-4
If you get the “distance” between two colliders, this radius gets added in (depending on the type of query).
So if you get the distance between two Circles that are 1 appart, unity says distance =1. If It’s between two box colliders 1 appart, unity will say something like 0.998
This becomes relevant when you try to put two things into contact, and so the distance between them is very sensitive to that edge radius. The default edge radius is based on default contact offset, which is a setting in Physics2D project settings, and if you ever change this value, then everything will break.
@hallow gate
btw this affects the results of a LOT of Physics2D queries, like Collider2D.Cast, and Collider2D.Distance
Why am I getting error links on my this code?
https://gdl.space/zizereveqo.cpp
Error code CS8803:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs8803
that seems mad complicated for some reason i just followed the tutorialist and he didnt show me any of that he just showed me code and that was pretty much it
how relevant it is depends on what you are doing
if you need to move something to a precise location to be right in contact with something else, it becomes relevant. Or if you are trying to do something specific with the distance between two things in contact, it is relevant
Ur missing a ending bracket for ur class MRW419
Looks like you're missing the end curly brace
im just trying to make my character kiss the edge of the solidobjects and not to "social distance" himself from it yk?
that sounds like this will be relevant then
@buoyant knot there was a thread made above
#💻┃code-beginner message
Where would it be at?
I see it now, I misplaced it in the middle
Ah yeah. That'd do it
is your IDE configured?
Hi all, has anyone had issues with reloading the current scene a player is in?
I have a scene that instantiates a lot of procedurally generated content and deletes some other content. When I use SceneManager.LoadSceneAsync I'm expecting the scene to revert to it's original state, but the content I generated or deleted previously does not reset.
Async scene loading is inherently additive scene loading. Do you explicitly switch to the new scene when it's done loading or just let it pop in? Do you have any objects in a DontDestroyOnLoad object? Those ones will persist whether you're using additive loading or not
Yes, code would be nice to see how you're handling the scene transition. A before and after screenshot of the hierarchy would be nice too
I'm using LoadSceneMode.Single, I do have some objects with DontDestroyOnLoad but I don't need those to be reloaded
Thanks for the reply, I'll get the code and hierarchy examples
groundedCheckDistance = GetComponent<MeshCollider>().sharedMesh.bounds.size.y / 2;
I am getting following error for this line of code:
NullReferenceException: Object reference not set to an instance of an object
so there is no MeshCollider on the object
a null reference exception has one, and only one, cause: you attempted to access a member from null
that proves nothing
that's not the only thing that can be null (:
There is a MehCollider to the object ^^
notably...
We could still be looking at the wrong object.
another object could have a RocketController but no MeshCollider, after all
You can find out exactly which object is responsible for many kinds of errors by clicking once on the error message in the console
it'll take you to the offending object in the hierarchy or project window
we do not even know this is RocketController
How do I add a Mesh to it?
first post the stack trace for the error
this code is probably wrong, especially if anything has been scaled or rotated.
Yea, I've scaled up the "Rocket", in which the RocketController is onto
for multiple reasons:
- A MeshCollider must be given a mesh asset. If you have a MeshRenderer parented to whatever this object is, then you'd have to make sure you assigned the same mesh asset
- You're checking the bounds of the mesh asset itself. This is not the bounds of the collider.
not gonna generate a NRE
yes, but I think the design is wrong even after fixing the NRE
sharedMesh is null so it's throwing up
indeed
What are you trying to accomplish here?
not "get the ground check distance" or "find the bounds size"
explain what you're actually making your game do
I want to know wheter the Rocket is on the ground or not. Therefore, I get half of the length of the meshcolliders size and perform a Physics.Raycast with it.
are you trying to detect when the rocket is properly landed, or just when it's hit the ground at all?
when it's hit the ground at all.
I would suggest using Rigidbody.SweepTest
It tells you if the rigidbody would hit anything when moved in a certain direction.
This sounds applicable.
Thanks for the input. But I still want to learn why the MeshCollider gives an error.
Log the result of GetComponent<MeshCollider>().
Then, log the result of GetComponent<MeshCollider>().sharedMesh
One of these will be null.
It doesn't matter if the component exists if you grab a null reference from it and then try to use it
Note that this would detect if you're pressed up right against a wall. You could use the RaycastHit to check the normal of the surface you hit and see if it's close to vertical.
But if you just care about resting on any collider, then that should work fine
Solved it. However I get a new error, saying Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.. I suppose I need to make the Rigidbody Kinematic?
A kinematic rigidbody is not affected by physics.
That is probably not what you want.
You need to...
- Delete that MeshCollider
- Attach a MeshCollider to the same object as your MeshRenderer
- Make the MeshCollider convex.
A convex collider is shaped like shrinkwrap.
It doesn't have any holes or dents. It's a much simpler shape to reason about
Alternatively, just slap a box collider on it and call it a day
It's probably good enough
You can use multiple colliders, too: a Rigidbody will use all colliders parented to it
MissingComponentException: There is no 'MeshCollider' attached to the "Rocket" game object, but a script is trying to access it. You probably need to add a MeshCollider to the game object "Rocket". Or your script needs to check if the component is attached before using it
yes, because you no longer need to get the MeshCollider at all
you should remove that code
what code? the get groundcheck one?
the code that tries to get the MeshCollider.
so how will I then get the size of the MeshCollider? :3
you don't
you don't need it at all; you can just ask the Rigidbody if it would hit anything
that's why I suggested using this method. it's way simpler and more reliable
your method would fail for any ship that's wider than it is tall (think a flying saucer)
"The more you learn, the more you realize how little you know"
You'll never really ever know it all.. just enough to get by.
It's also just fundamentally unsound. You're asking for the object-space size of a single mesh's bounding box. This isn't how big the rendered mesh is in the world (and also doesn't care about how the renderer is rotated)
Why is this returning 1? Am i missing something?
The way i understand it, Mathf.Sign returns 1 if the value is positive, -1 if it is negative and 0 if it is 0?
i see, cant always rely on chatgpt
You should never rely on chatGPT, it doesn't know anything. It just chains words together.
Check the documentation
wouldnt go that far but yeah
Do UI Image have tilable settings? I want to create something like healthbar and so far its decreasing is size to middle
It literally does not know things. It has no memory, it has no concept of comprehension. It builds a probability curve of text based off of existing data, choosing words that are most likely to come in that order. It is a fancy version of the predictive text feature on your phone, just with more data.
there is no concept of "fact" only how common a set of words are
most of the "magic" is just the enormous amount of data shoved into it
you can simply put pivot not in the middle of rect transform
but yea there is tiled mode, stretch and fill iirc
although for healthbar i would use Fill and change that
this is a code related channel 🤷
and you could test it in 10 seconds 😄
Its just UI image looks like its not having sprite parts
you need sprite to be assigned to the Image to be able to set the mode, for healthbar set it to Filled and manipulate the fillAmount in code, anyway this is not a proper channel for that
I had no sprite set to it so I couldnt manipulate the value
Lets say i have a script that needs refrances to 3 other scripts on the same component.
Is it better to have them be public properties and assign them in the inspector? Or will it just be fine if i have them be private and assign them in Wake(), with TryGetComponent?
fine on awake when its on same object
Wont the latter will increase my Scene load times if i have that script on many game objects?
Its not GameObject.Find so most likely not
You can totally serialize it
I just dont like serializing
Hmmm. Well i guess ill go with it, since serializing them and having them show up in the inspector will just make things more messy.
I mean, if i dont need to see them and assign them in the inspector, then why should i have them serialized?
No. Even when assigning them in the inspector, the engine needs time. There is a negligable difference between serializing the reference and a getcomponent call
But serializing is best
Dependency Injection when assigment in inspector isnt possible (runtime spawns)
I never understood the "I dont want my inspector cluttered"
this is nonesense statement
I dont like serializing objects I need in multiple objects. I just find it at 1 place and access it like this
I only understood one word of that, and that is the word inspector
Also whats wrong with wanting a cleaner inspector?
its nonesense
DI interfaces still elude me
somehow making eveyrhing by guide they dont want to work
DI interfaces?
whats DI have to do with Interfaces
DI interface
So, when i have object pooling, reuse an object, and then reassign its properties based on my needs, in a Init function thats DI?
yes but what about them?
I dont remember
they are the same way used as any other type
Wdym?
its when you "inject" a required reference
if your pooling needs to inject something in the pooled objects sure
Interfaces are used quite often in traditional DI pattern
its part of the SOLID principles
Well I tried implementing them when was working with windows and then in android with dagger, but in first case it didnt work in second it absolutly broke my app
https://gdl.space/zezuwamubu.cpp
My character isn't looking around and I don't know why
strange, I use it very often esp with traditional .NET apps.
{
float forwardInput = Input.GetAxis("Vertical");
float rightInput = Input.GetAxis("Horizontal");
characterMovement.Input(forwardInput, rightInput);
}```
Where does this lead?
I probably will get it at some point. It wasnt really needed at that stage and was more of experiment of mine
I don't think they were saying that the d stood for DI
Just that the concept of separation by using interfaces aligns with SOLID

that's not what they meant lol
where is CharacterMovement
My character moves i just need to have it look
@polar acorn world canvas?
The canvas your image is on. Is it a world space canvas or a screen space one
btw you should notmultiply Time.deltaTime on mouse Inputs
Brackeys!! 
how do I check
permanent wound
What did you set the canvas to when you made it
Add debugging the values making sure they are what you expect them to be
new DataHold(_images[0],0,GameController.Instance.Health)
I want to save link to Instance otherwise it will just save the value. Is it possible?
how do I make it so that I can move in the photo?
Well when i turn with my mouse, nothing happens
thats not debugging..
Either move the image on the canvas instead of the camera, or use a world-space UI so that the camera moving actually matters
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/HOWTO-UIWorldSpace.html
thats stumbling on the same problem
You mean the logs don't show in the console?
but I followed this tutorial and it worked for him
This tutorial series teaches you how to take 360 images and make a virtual tour with points of interest in unity.
Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com
Any comments or questions welcome. Enjoy the video!
oh boy..
if i have more than one class in a script how can i acess a variable from it . if i do the normal thin like: ...GetComponent<.....>()....=0, it s says that isn t a definition for that.
Hundreds of people tell us they followed tutorials, and there is always something they missed
Well if it doesn't at all, I can asume that they are zero or there's a mistake within my code that doesn't read the code
Did you add debug.logs?
assuming is never a good option in dev/coding
you have to BE SURE
Have only one class in a script, first of all.
Second, getcomponent finds a type, so script files are irrelevant to it
so which one is easier?
They don't move the image in this tutorial. They've made a UI that they hide when you start the tour
The image doesn't move
so for example i have GameObject.GetComponent<"Player">().health
not the script just the int
No quotation marks
Remove those
i did
GetComponent<Player>().health
Player is a component not a string
Ok, so what is the issue then?
It says there is no Player or no health?
but 14:30 of the tutorial he can move the photo
Player is the script
fari and it's within the Lateupdate
Class, not script
Component = Script
Nothing happens pass that
fari ?
He's not moving a still image, he's rotating the camera inside a sphere with a texture on the inside
yes
This tutorial is specifically on how to make a menu that swaps that material based on your input
The menu doesn't move
This is part 3. Did you view the first two parts
Show your sphere then
Fair and scatch that. everything goes through but I can't turn my camera
The menu is not supposed to move when you click the button it brings you to the first photo and you're supposed to be able to move in the photo
"everything goes through"
show what you did and what values you are getting, its all guess work from this end rn
Right, so show your actual sphere with the texture you're trying to move inside of
Well I put simple messages saying that it works
Okay so you do have the sphere. Show the inspector for the object that controls the camera's movement
thats not good debugging, no. You Debug VALUES
No, the one that moves the camera
Whatever object has that script on it
Also you haven't assigned any sites to this object
Wait, is the issue that the menu picture doesn't go away?
After what digi said, show the button's onClick in the inspector
What values would I put?
No the issue is when I click the button on the menu I go to the first photo but I cannot move around
Still waiting to see where you are actually moving the camera
um ok for example
void LateUpdate()
{
Debug.Log($"xAxis value is : {xAxis}, yAxis value is : {yAxis}");
Quaternion newRotation = Quaternion.Euler(xAxis, yAxis, 0f);
Camera.main.transform.rotation = newRotation;
}```
Now i have can t refference to the variable because the class from the other script has to be MonoBehaviour
It has to be a MonoBehaviour, yes
Component is a type, which MonoBehaviour inherits from
so besides that what can i do
GetComponent only works for things that inherit from it
What do you WANT to do? This is an xy problem
what are you trying to do in the first place ?
i wan to do an DataSaver
What about it
it should be probably a Plain class that holds data
Those put a lot of errors
No
No show the object that moves your camera
There is no script that moves anything there
what is the error show me
You should know which script has code that moves the camera. Show that one
I see you have two tour managers
#💻┃code-beginner message
And should the CamerController not be ON the camera? Could be wrong since I haven't seen the code
where do you see two?
this one and the one you showed before
the one that had nothing in it
One in the message I just linked..
I kinda can't since it's on my friends computer and he gotta get Discord. ((Were in school in a game design class. The teacher isn't a coder))
So your camera controller is rotating this object, which seems to contain the camera and the sphere. So it's moving everything at once
That's not what the tutorial had. Just sayin
so why are you talking for your friend
Well idk what to tell you, the line I sent you would produce literally 0 errors
what did I do wrong
What digi just said
Actually they have the spheres on the wrong object
Ahhh, got it
Why are your spheres a child object of your camera controller
I am wondering: if you put a script onto a prefab, will the script's constructor be called, or would I have to use start/awake?
https://pastebin.com/4bXgddkL I want to acces the variable from stats class to acess it from other scripts.
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.
Don't use Constructors on monobehaviours
Monobehavior and SO dont have constructors
you cannot have constructors on Monobehaviour scripts
again I followed the tutorial unless I did it wrong and made a mistake
well you can technically
Point taken. Any idea why?
Unity creates the object for you already
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 145
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-2-09
You've made your spheres child objects of WorldCenter
you can, technically, make a MonoBehaviour IDisposable, ever tried it?
Is that wrong?
Yes
The screenshot there is from the tutorial. Notably, the spheres are NOT children of WorldCenter
yes as i said, you CAN, you said "you cannot"
how do I fix that?
ok, pedant, should not, happy now?
Make them... not children?
Instead of doing that, don't
do I drag them ontop of the worldcenter?
Uh no
That would make them children of WorldCenter. Which they already are
Drag them into a blank space
So they are children of the scene only
then what should I do instead
I literally JUST told you
You should scroll up like two posts
can somone help me plz
you was sent that link already
did you check it?
bro just ignored responses then askss again, A+
he probably looked on it, "nah thats too hard/weird imma ask again"
"I dont understand it, so let me ask again instead of asking for clarification on what I dont understand"
"can you some help me, please give direct instructions" kappa
like this?
No...
tbh the links are not relevant to his problem, it's a POCO
all three?
WorldCenter needs the camera as a child
Yes, of course
if ur following a tutorial just make it look like the tutorial.
You access them the same you access everything else in c#
true but the class resides on a MB i think
@carmine elm SaveDataObject.stats.something
not clear how they want to grab it
The poco could be held by a singleton, then he accesses it through that
Or a serialized field
Both of which are shown in the unity.huh.how link
there is a field for it though
public SaveDataObject SaveDataObject;
so they need to access that field i assume from DataManagerSaver which is MB
i hope ur mispelling the name of that variable
ohh ur not..
public SaveDataObject SaveDataObject; this is no bueno right?
having the exact same name as the class
Please read the things you're being told to do
why did you move the camera
yea it works but VS sometimes takes a shit
that was never suggested
I would never use same name though
like this?
Make the spheres not a child object of the camera controller
ive noticed lately that Unity lets u name the class differently from the filename now
yes
i dont do that, b/c its asking for errors imo
now it should work?

I usually do public SaveDataObject CurrentSaveData {get; private set;}
yes only in 2023+ versions tho
maybe a unity backing field if needed in inspector
imma stick to normal naming.. (same as class) b/c i already confuse myself
yes same, dont see a reason to have different file name than the class
would be confusing to me and other programmers in the team
absolutely
for MB?
yessir
class BossFight, filename NormalMobFight lol
yeah I rather keep MB named same as filename
That is a 2022+ change
useful for POCO sometimes
yea ig
it works now thank you sooooooooo much for the help @summer stump @polar acorn
eg one file can contain multiple classes related to each other
having a bunch of files for small classes sometimes is more clutter
yea, thats a good example..
i was thinking the same.. if u have multiple classes within 1 file..
u can chose w/e is relevant
Just wished we had File-Scoped namespaces tho 😭
when colliding with a gameobject that is a parent, is it possible to check for what part of the parent it collided with? say that the parent has a collider but also a child of the parent has a collider, can u check which one it collided with? code wise
Is this okay, or should I use getComponent?
Edge e = Instantiate(Resources.Load("Prefabs\\EdgePrefab")) as Edge;
I think the Collision holds info on which collider was hit
what reason you want to do this ?
cuz im doing something like this but its not exactly working
(i know that using names instead of tags or wtv is bad but ill clean it up later)
full method
both the force field and the shiled have trigger colliders
wait.... is it cuz none of them has a rigidbody? i think i didnt give either a rigidbody..
- You never want to check by name
Use tag, type, layer, ANYTHING else
well, thats atleast (1) reason
- if you have a rigidbody on the parent, it will treat all the colliders as a composite collider
I always recommend simply having the OnCollision/OnTrigger code ON the children, and pass pertinent collision data up to the parent
thing is i want it to ignore the force field, not collide with it, and just collide with everything else
Yup usually my child colliders send data to parent
Then disable collisions between those layers with the layer matrix I guess
well.. i want some projectiles to bypass, and some not
currently i have 4 layers for the collision, to do it via layers, id need 2 more layers for this
do i just do it anyways?
or try a diff appraoch
what should I consider when choosing to use a singleton vs a static class?
Yeah, that's why doing it that way sucks.
Make the forcefield a child object and just check that it's the right thing
if (collision.gameObject.TryGetComponent(out Projectile proj)) {
if (proj.type == typeICareAbout)
}
Something like that
static class = helper functions and such
singleton for gameplay persistance
imo
Just personal thing I do, so take it as opinion and not fact.
static can cause more problems than it can solve sometimes
the instance itself is static and is fine for me when doing singleton
helper functions are things that generally don't need state. the static class is just a namespace. if you have something in unity that is part of your game logic and has state, you generally want to be able to control it with scene controls, etc.
like reloading a scene or something will just reinitialize. otherwise you will have to manually re-initialize the static class, which is another place bugs can happen.
you have to make everything in a static class static or else methods can use members etc.. its kinda bad pattern imo
also, monobehaviors can't be static classes, so you can't do things like update
okay so for example, I have a Save System and and Item Database, does it make more sense to make them singletons or static
also you cannot see static variables in unity inspector etc
the save system just saves/loads all stuff on exit/enter and the item database holds a SO that has all the items avaliable in my game
Singleton imo
I have both for a save system
the system that deals with System.IO is static class
the one that interacts with MBs(gets data to pass to static IO class) is static instance (singleton)
Ok, yeah that's fair
i think static class is fine for a save system because you can make the save system without any state - it reads stuff from disk, puts it int your game objects, etc., or does the opposite.
same with the item database no?
database , system file same crap
i just holds a list of items that can be accessed
personally i'd not use a static class for the database because i'd like to be able to plug it into the unity inspector
thats why i use an SO to hold all the items
use the most basic database . Json file xD
but if you want to just have it completely separate, that's fine i guess
lol what if i just do something like this tho? it has to be true if it wants to run the code that is usually run when colliding with the player, and considering the force field is a trigger collider, it might work?
SO cant be serialized at all
yea
its not about json
Serialize the data on the SO not the SO itself
I do
then it should be no problem
my save system saves the name and then gets the name on load
to build the item
i know thats not my issue im just wondering about the singleton/static thing
thats bad
I put a POCO on the SO and serialize the POCO
getting names sounds horrid
singletons are more for like... managers/controllers within the game itself. things you definitely dont' want/can't do with a static class
wdym poco
Plain old C# object ( a regular class)
why can't you though
well again, if you have a manager that needs monobehavior functionality, it can't be a static class
Again, the first thing you should do is remove anything that is checking the name
or if you need to use the inspector
okay so thats the only difference really
and also, it's easier to deal with scene changes/reloads using monobehaviors
This was my recommendation in case you missed it
#💻┃code-beginner message
yeah but it's a big difference
what are you trying to do ? I dont understand exact use case
Have some projectiles stopped by the force field and some pass through is my understanding
Ohh wouldnt the Ignore collision method work here?
so you make a seperate class for each item on top of the SO for the item?
Yeah. They expressed concern over adding a bunch of layers though
I dunno how many they need
Oh, or do you mean the PROJECTILE would ignore it for different types...
Yeaah, I hear you
if the arrow hit the force field, canHitPlayer is set to false, otherwise its set to true, in the players collision script, i check if the player collided with the arrow and if canHitPlayer is true, only then id run the script that damages the player, destroys the arrow etc
Oh so its not working like that ?
depends on the usecase but I need a POCO yes for mutable data, since SO should not be mutable
what do you mean?
its what i was gonna try, is what i meant, so i was asking iof that could work, rather than using collision2d,ignore()...
I dont see the issue with rebuilding from my database with a name
could also use a guid
they both can work, one of them will still make arrow hit player collider tho no?
Ignore collision method will make the arrow pass player completely, so its a design choice
a guid for what?
yes, i do wanna hit the players colliders, just not the force field
and it works now!
when I save the data on quit, i save each item's name, index in inventory, and stack amount
then when I load the game back up, it rebuilds the items using the name
fetching the SO/item from the database
yeah you're recreating it
I used guid before when making items that cannot respawn if you Load a game
like chests that already hold items picked up etc
had to tap into the SerializableDictionary realm
it was annoying
so what I'm doing is bad?
the only issue is when changing item names and using a GUID wouild fix that, I just haven't implemented it yet
Where did I say that?
you said
Ohh I thought you meant you were getting references back by names, I misread
Does anyone know if there is a C# script for a 2d game, basically I want to create a mechanic, that after the knife cuts the bread (goes through all the bread collision) changes the sprite
is there an exact c# script for the specific thing you want ?
not likely.
dissect the problem into smaller ones and build it yourself
maybe on collision exit?
do you have an example of this ?
yes
Im trying to make a game, in that game I will pick the knife with the mouse then i need to cut the bread
and i had that idea
You could def do a raycast from mouse to the bread collider or something
Ye sure cuz i dont have no idea how to do this
well, for example "pick the knife with mouse"
How to move objects with mouse, step 1
something like that
oh i already know how to do that
well there you go
when you solve those smaller issues you build up to the thing you want
Hello i have an error on a code that " SceneManager.LoadScene" giving me this error "Severity Code Description Project File Line Status Deleted Details
Error CS0117 'SceneManager' does not contain a definition for 'LoadScene' Assembly-CSharp D:\GAMES BY ME\Pixel Run\Assets\Scripts\menum.cs 22 Active
"
How can i tell if i have collided with the parent of a group and not a child? When I tried collision.transform.name(name) it still fired on the child object
You have made a script named SceneManager
I have reasrched with no lick
i just added this at begging "using UnityEngine.SceneManagement;"
And because you have made a script named SceneManager, your code is trying to use that instead of the one from UnityEngine.SceneManagement
i dont have any script called like that
Are you using visual studio?
Yo could anyone spare a second?
how come I get this hold on when I hit play?
Go to the line the error is on, put your cursor over the SceneManager text and press F12. Screenshot what comes up
It magically just fixed, thank you
is that bad?
if its not entering playmode and stuck, yes lol
otherwise just disable the Domain Reloading and you're gonna be in playmode in a fraction of a second
no it just takes a long time 30s-1minute
disable this then
https://docs.unity3d.com/Manual/DomainReloading.html
void Start()
{
CursorText = GameObject.Find("/GameHUD/Popup/CursorText");
CursorText.GetComponent<Text>().text = text;
CursorText.SetActive(false);
}
Is this incorrect? What does "Object reference not set to an instance of an object" mean?
I'm doing some practice with the basic movements, I managed to make a cube move, rotate and jump.
I would like to implement a jump similar to Mario Bros but in 3D, can you help me?
but yeah you possibly have lots of script doing GetComponent, or something heavy in Start/Awake @storm imp
Rigidbody addforce?
It means something on that line is null but you're trying to use it anway. What line has the error
I did all basic movements with AddForce/Torque
Then either the find fails or it finds an object that does not have a legacy text component on it
Ok so how do you want your jump to be different
I see
How can i tell if i have collided with the parent of a group and not a child? When I tried collision.transform.name(name) it still fired on the child object
Using this method I was only able to make the cube jump by a set amount
And u want it to jump by an inset ammount?
which error ?
Nullexception
hey
then your object hit has no parent
computer says otherwise according to you, so i incline to always believe computer
Totally fair, but i can see that a parent is attached with a name
dumb dumb question, i have a .unitypackage file thing i wanna import, but it's not showing up as a .unitypackage file extension thing, it showing as GZ, help pls, (very new to unity)
then its probably not the collision.transform you think it is
There are multiple types?
Is there a different way than gameobject.find
I want if I immediately release the jump button the cube jumps a little and depending on how much I press it (not infinitely) it jumps more, just like in Super Mario games
hey, so im trying to get the value of the angular velocity in an rb2d in order to make a drifting-type system, although its constantly at 0. Currently I'm changing the rotation of the object dependent on the mouse location on screen, anyone know why its constantly set to 0?
In update have an if statment looking for jump button pusing up, and if you release it stop
show where you put the debug and which object
Find is not recommended for use, but it's not Find that's the problem in your case. You're using GetComponent with a component type that isn't on your object.
In numerous games, characters have variable jump height. What this means is that the more your press the jump button, the more the character will remain in the air, or even jump a little higher ( think super mario games ). In this tutorial, I’ll show you a simple way to implement this kind of jumping in your games.
I see... I might have misunderstood my components name
^ nvm
How do I get TextMeshPro from a GameObject?
The script is attached to a cube that is also a child,and the aim is that i want the if statement to fire only if the object the script is on hits the parent of the other one
Does it also work for 3D?
physics are physics, and math is math
I didnt need a debug cause it theew an error
just use Rigidbody vs Rigidbody2D
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
dusty code
since you putting it out there for the world to see, clean your monitor bro
use the browser version
very dumb of school...
u just blocked the only person thats probably gonna help ya
oh u mean teh website is blocked
that will fix it
i read that wrong
Lol ok i get it i wont picture
pretty
@rich adder I could use my hotspot if u think u would be able to help with the text code tho?
certainly wont hurt
Alr
Can I somehow remove first line of the text and add a new last line?
Also you should always Debug.Log(collision.transform.name)
sure why not?

how
i been using this website like wildfire lately

Thats what I kinda did but didnt find a solution
what did you google exactly
are you making some new cutting edge thing? if not google has solutons
probably.. just the search keywords yea..
This debugs the corret thing and then immidetly the error
I can't figure out how to get the component type "textmeshpro" from a gameobject? I looked up a unity forum thread but couldn't find a good answer
Maybe its because theres a difference between transform and gamepbjext?
depends on what do you want
text mesh pro is an asset
and it has multiple components
like TexMeshProText etc
or TMP_Text
I want to access this component
TMP_Text then
Why are there so many similar names?
TextMeshPro is the Asset
Text(UI) is the type of Text component
not that diffcult
TMP_Text is the baseclass for Any of TMP text (UI and Mesh)
yea, TextMeshPro - Asset
TMP_Text - text component of TextMeshPro asset
https://pastebin.com/6f3aFPX8 thats all my save stuff anyone know how i can save only a single thing i dont want to save the players position and health just the players skin and i dont want it to save player.playercontrollernew.skin i have a different value i want to save it as
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.
Wait im trying to see if i collied with the parent object and not a child but woulnd this code fire if it hits a child too because it returns the parent name?
um.. then.. dont save what you dont want to save?
and save only things you want to save? 🤔
wouldn't have guessed it would be tmp_text from the name of the component
could just look at the docs
you dont need to guess anything
instead of assuming things just test them
how do i save another value as playerskin and only save that keep the rest the same
would you prefer the original name TextMeshProUGUI
put another value to save instead of the one you are putting now? idk what do you mean lol
I would, or merely the component name
you are not suposed to guess, you are suposed to read the docs
i like..
i use it for everything.. then if i need a specific i'll change it if/when it doesnt work
how do i have it only save the specific value i want to save without overwriting the others
too long to type 
i have 0 clue what do you mean
save the things you want
make a function that just saves that 1 part
and dont save thing you dont want
instead of saving all of em..
well unlike you I like my time spent on doing code not looking up what things are named
hello im new to unity u think a 2d platformer is way to go for first thign
docs are part of coding
lmao.. thats a weird thing to say..
yea it's insane xd
oh lord.. this statement is nonsense
unlike u I like driving my car, instead of going out and purchasing a car first
some people thinking logics are just crazy xD
which is why you are here asking stupid questions and I am answering them
just like a small 1
Use the correct class name. TMP_Text is the safest bet
how does the layerMask bitmask thing work?
think even smaller
but yea a simple 2d game would be the best first project
I'm seeing someone use negative integers and I'm confused
just like 1 where u jump and collect like barrells or smt
TMP_Text doesn't seem to work
ya, sounds good man
public void Save()
{
float playerSkin = selectedOption;
SaveObject saveObject = new SaveObject
{
playerSkin = playerSkin
};
string json = JsonUtility.ToJson(saveObject);
SaveSystem.Save(json);
}
so this wont overwrite the players location and health right
thanks
Will Instantiate(this) create a new copy of the entire game object of the script?
yes
assuming this is a MonoBehaviour, yes
Including the parents?
no
i believe w/o anything else.. ya this is referring to the GameObject
mo
only the children
Okay thanks
no it is not
then its the MonoBehaviour?
TMP_Text is not in the namespace editor says
Does anyone know how could I use code to make it so I can grab, drag, and resize UI elements like this in game like I can in the editor? Similar to what I'm doing in this video.
it is this class
What? It's not in what namespace? If you get an error message, share the full message.
ahh, ok my mistake
Did you import the TMPro namespace
did you include the using TMPro; using statement?
or did you import TMP Essentials at all
no because they rather spend time coding
lmao
The type or namespace name 'TMPro' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'TMP_Text' could not be found (are you missing a using directive or an assembly reference?)
find an asset that does it for you.. if not thats a ton of coding.. an entire system
Do you have TextMeshPro installed at all
ya, answer the question
I don't know if I do
did you include the using statement ^
if only there was something that told you which namespace
if ur not sure then its probably not installed
yes
TMP is installed by default in most new projects
the only thing u need to do is go in there and import the essentials
Ok, good to know.
it just overwrites the other save info
doesnt that just Import like materials and shaders n stuff
Thought it was supposed to be simpler...
then make other function
I don't think that's relevant
and dont save the other things
no clue what it does, lol.. Anytime i add a TMPro element the popup thing pops up and asks me to import em
The namespace is part of main package
life's not easy
i didnt save those things i only saved the skin and it just delted the other things
the TextMeshPro package is already in Unity but yes it asks for that to import the materials and shaders first time, idk why
You should still install it. Otherwise you're making all your font assets yourself
Don't talk to me if your just gonna be rude
ahhh okay.. never knew exactly what it does.. so its just the basic stuff.
I recall someone had pink font without it
oh, was that what that was caused by?
ive never seen pink text before 👀
lol
but i always import those starter things.. so thats probably why
Usually fixed it after they did Import Essentials, unless the prefab or whatever was already using the missing Liberation font + shader
wait nvm thats the mapping
my version is 2022.3.11f1
sorry won't waste my time on you anymore
The TextMesh Pro UPM package is already included with the Unity Editor and as such does not require installation. TextMesh Pro "TMP" does however require adding resources to your project which are essential for using TextMesh Pro.
i was gaslit !
where is your script file? Is it inside a folder with an assembly definition?
ive never read teh TMP docs.. nows a good time i guess 😄
not sure what that means
show us
I used to read the old ones but they finally made it somewhat legible for UnityPakage one
where is your script file
what folders(s) is it in
Without it your text will have no fonts or materials so it is essential. It's just not related to this problem, since it doesn't introduce any new code
yeah sometimes a Regen Project Files fixes this
unless the error is Unity not VS ofc
Curl error..
In explorer? unity project?
@rich adder i know you dont care but for closures sake thank you and i was suppsosed to do col.collider.gameobject.transform.name
you're many versions behind lol
where did that second error come from?
Either one? It's the same file structure
i think he means what folder within the project
yes
that smells like a networking problem
lol, no clue thats a new one for me
click on the darn thing
Assets\FPS\Scripts\Game
what makes you say that lol
I was just trying to get you to debug objects you hit, but yeah that makes sense why it would need the collider.gameobject not the transform
ok and are there any assembly definition files in any of those folders? What is "FPS"? is that a premade asset thing?