#💻┃code-beginner
1 messages · Page 272 of 1
with anchoredposition:
I tried setting the position without Lerp and it didn't work either
you're putting it inside a canvas group ?
no I just instantiate as a child object of a different canvas
there is a canvas group on the canvas
I just noticed that
How do you show the current state of an enum in the inspector?
the object u instantiate is a UI object yea and ur moving anchoredPos ?
correct
its visible?
put the inspector in debug mode if its private var
// called once per frame
void Update()
{
float horizontal = Input.GetAxis("Horizontal");
moveDirection = new Vector3(horizontal, 0, 0);
moveDirection *= 5.0f;
controller.SimpleMove(moveDirection);
}
hey, I seem not to be able to implement a very basic character controller simple move function. any thoughts? the controller.Move function works just fine, SimpleMove does not
hello inthis line is instance just a name?
Yes
yes, again. Why do you keep asking the same questions about this?
i dont know
you asked about this at least twice yesterday and were given correct answers by numerous people so I suggest you go and read them instead of just reposting
I feel like this is a sizable problem with barrier to entry in programming. Jargon is difficult to understand for someone that doesn't know the context. I don't think DreadClaw2159 had ill intent, and I believe the answers they received didn't help them much in terms of understanding/enlightenment. That being said, the answers weren't incorrect, they just weren't geared toward the person asking the questions.
despite this, it would be wise for you to either try and understand the details of the answers elsewhere or expand on your question by asking in more detail about the responses, as opposed to simply asking the question again.
Yes, in .NET you first define the type, then the name. Optionally you can start with an accessibillity type (public/private) and you can also make it "static" to define the property/method can be accessed without an instance. Either way the name is always last.
Agreed, jargon can be difficult to understand at first however google is just a few keystrokes away and if I search for C# property definition I find
https://www.w3schools.com/cs/cs_properties.php
which gives a very easy to understand description of this.
I don't think it is too much to ask that people use Google as their first resort rather than as a last one
110%
I am surprised the W3schools are not under the pinned messages. with the myriad garbage sites by people trying to make a penny, the gold can, and does, get buried.
Also agreed, although I am not a great fan of W3Schools it is a very good resource for the absolute beginner especially when it comes to explaining basic concepts and technical terms with which they will be unfamiliar
honestly itll get skipped anyways, a lot of beginners who just jump into game dev dont stop to learn the basics. Its always "just one thing" they need to solve first.
i think its not needed to pin it though. The same could almost be said about stuff like vector math, there has to be some line of "you need to go learn something else first"
I had been avoiding sitting down and learning C# outside of Unity, well, in all honesty because of clinical ADHD, but i got defeated by a getter today :/ so, stepping back and starting at the beginning/basics of C#.
Indeed. i am 100% guilty of that
This is pinned
At the end of the day, you cannot force people to realize the importance of learning and get them to do it
I miss that 2 out of 3 times 🙂 nitpicking, but adding - Microsoft to the end of it would make it stand out more. just little things that help, as we do not all gather info the same ways. I saw it sandwiched between the two Unity links, and it did not always register. Anyhow, no big deal. it is there, and that is good
I really think that for a lot of people, they are just in BS overload. The content of So many sites is just utter garbage, that some start thinking, 'Bah! I'll just learn as i go, because this is not helping'. But yes, the resources are there, and it really is up to the individual to exhibit some self discipline
oof, and then those who think CGPT is going to be a good teacher :/ "I'll just ask it as needed! It won't steer me wrong!"
What i am looking for, which would be exceptionally helpful, are Charts of the common structures with the Names of each portion. like,
private int imAnInteger = 123;
So in this simple demo, that line, in a chart, with the name of each section above it.
Access modifier over private, **Data type **over int, Variable Name over imAnInteger, etc
it seems like you know how a declaration is written. what else are you trying to learn here?
Well, as i said, i am looking for that kind of breakdown for all types of C# structures, like the same breakdown for a getter, or a method, etc, in chart form for easy, accurate access
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InteractionManager : MonoBehaviour
{
public Text valueText;
int progress = 0;
public Slider slider;
void OnEnable()
{
PlayerInteractor.OnInteract += HandleInteractEvent;
}
void OnDisable()
{
PlayerInteractor.OnInteract -= HandleInteractEvent;
}
void HandleInteractEvent()
{
UpdateProgress();
StartCoroutine(ResetSliderAfterDelay(2f)); // Start coroutine to reset slider after 2 seconds
}
public void UpdateProgress()
{
progress++;
slider.value = progress;
StartCoroutine(ResetSliderAfterDelay(2f));
}
private IEnumerator ResetSliderAfterDelay(float delay)
{
yield return new WaitForSeconds(delay);
// Reset progress and slider value after the delay
progress = 0;
slider.value = 0;
}
}
I have tried to do a slider that interacts with my interaction system but I can't get it to reset?
I did get rid of line 25
I think i will just have to make my own, and that will help me learn in the process
I had it in handle interactevent but I put it in update instead
still dosnt work
I havent seen any specific resource which lists stuff like this. The docs do this though for each thing individually with examples, itll probably be quicker to google for the docs compared to pulling up any custom resource you make for it
I'll try to clarify.. I have ADHD. The Docs are not working for the way i think (or don't think) so i am trying to find the method that works for the way i absorb information 🙂
Why is adhd a thing that keeps you from learning c#?
Research will answer that for you. This is not really the forum to discuss this further
I have adhd so maybe dont use ”adhd” as an way of you ”cant” learn”
Again, this is not the place to discuss this further. I wish you the best
I have adhd, i avoid school work and do c# instead
goatr
I do the same thing! Except, I have autism instead
I'm creating a game, but when I reload the scene (with a restart button) and click the play button, I cannot move the player and the ball freezes in the air. Before I provide any scripts, are there any things that are often problems in these situations?
did you by chance turn off Domain and Scene reload?
Sorry, I don't understand 😅
i will screen shot
K thx
I have got static fields, if that conflicts with that in any way
so, it looks exactly like i have it above?, without Enter Play Mode Options checked too?
ok
well, that was my only guess
Only issue is I have like hundreds of lines of code, U fine with looking through that?..
!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.
I won't be much help, but maybe someone will
K!
read the Bot post i sent..
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
That contains the main stuff
I was gonna do inline but I guess I shouldn't 😅
Nah, not for more than a few lines 🙂
Ohhh ok
Are there any requirements for SceneManager.LoadScene(SceneManager.GetActiveScene().name); to work properly?
only in a build, the scene must be in the build settings
Sorry, I don't understand
My scripts btw if u wanted to take a look
did you open the build settings window and add your scene(s) to it?
Do I need to do that if I'm not downloading it as a game/app?
As I said, you need to do that 'In a build'
I have the same problame like yesterday, I opened visual studio and again things that must be colour ist not. like "GetAxisRaw" and it should be yellow. can any one help?
Here?
Does that say 'Build Settings'?
you only have 1 scene?
Yup
then it's good
Doesn't seem to have fixed it
MacOs + Intel ?
it says apple silicon as well
Yeah
Indeed, I thought they were separate platforms
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimator : MonoBehaviour
{
private const string IS_WALKING = "IsWalking";
[SerializeField] private Player player; // Assuming Player.cs contains the Player class
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
private void Update()
{
// Use methods and properties of the Player class
animator.SetBool(IS_WALKING, player.IsWalking());
}
}
?????????
Mac used to use intel cpus
They used to use PowerPC cpus as well but the compiled code is very different
Anyways, any other suggestions?
My code btw
The main stuff at least
Ah.
swap these lines
public void ReloadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
Time.timeScale = 1f;
}
Unfortunately, that doesn't seemed to have fixed it
Any other suggestions or info u need?
No, that should fix it, you were reloading the scene with timescale off so it stays off, turning timescale back on before loading the scene should fix it
you should never rely on any code running after LoadScene unless it's in a DDOL object or in the OnSceneLoaded event
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimator : MonoBehaviour
{
private const string IS_WALKING = "IsWalking";
[SerializeField] private Player player; // Assuming Player.cs contains the Player class
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
if (player == null)
{
Debug.LogError("Player reference is not set in PlayerAnimator script.");
}
}
private void Update()
{
if (player != null && animator != null)
{
// Use methods and properties of the Player class
animator.SetBool(IS_WALKING, player.IsWalking());
}
}
}
help?
What am I doing wrong here?
that error is not produced by that code as posted
so that means it must have been produced by this code.
using JetBrains.Annotations;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] private float moveSpeed = 7f;
private bool isWalking;
// Update is called once per frame
private void Update()
{
Vector2 inputVector = new Vector2(0, 0);
inputVector.y += Input.GetKey(KeyCode.W) ? 1 : 0;
inputVector.y -= Input.GetKey(KeyCode.S) ? 1 : 0;
inputVector.x -= Input.GetKey(KeyCode.A) ? 1 : 0;
inputVector.x += Input.GetKey(KeyCode.W) ? 1 : 0;
inputVector = inputVector.normalized;
Vector3 moveDir = new Vector3(inputVector.x, 0f, inputVector.y);
transform.position += moveDir * moveSpeed * Time.deltaTime;
isWalking = moveDir != Vector3.zero;
float rotateSpeed = 10f;
transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed);
}
public bool IsWalking()
{
return isWalking;
}
}
no, read the error and the stack trace
NullReferenceException: Object reference not set to an instance of an object PlayerAnimator.Update () (at Assets/Scripts/PlayerAnimator.cs:21)
yep and line 21 of the PlayerAnimator script you posted is a blank line so cannot generate an error
animator.SetBool(IS_WALKING, player.IsWalking());
it's not a blank line.
Also, should i add an catch excemption error handler or something?
}
private void Update()
Lines 20,21 and 22 that you posted
this is why you should use a paste site so we can actually see the correct line numbers
Im watching them on my visual studio.
guess what, we cannot see that
oh, i see what you mean.. i thougth you were recommending i use paste site so i can see the line numbers... nvm
anyway i still dont understand what the error is
no, so that we can
so what is the error in these lines?
they look fine to me
as I said, the error cannot be on those lines
so post a screenshot of your VS
obviously your GetComponent is not working.
Notice how you have taken out the null checks
how can you expect help when what you post
private void Awake()
{
animator = GetComponent<Animator>();
if (player == null)
{
Debug.LogError("Player reference is not set in PlayerAnimator script.");
}
}
private void Update()
{
if (player != null && animator != null)
{
// Use methods and properties of the Player class
animator.SetBool(IS_WALKING, player.IsWalking());
}
}
Is so different from the code you are running?
btw, this code is complete nonsense if Player is a monobehaviour
what should it be then?
anyone that knows enough to use the C# null coalescing operators should have taken the time to see if they worked in a Unity context
im just follwing a tutorial though
then I suggest you find a better tutorial, one that actually gives you valid information
ok
one word of advice, if you see a line of code that you don't FULLY understand, read the docs until you do
can someone give me a rotate script for the player
Also look at this code
animator = GetComponent<Animator>();
if (player == null)
{
Debug.LogError("Player reference is not set in PlayerAnimator script.");
}
you check for a non existent player but, for some reason you do not do the same for the Animator
in first person??
we do not do handouts/spoon feeding here
sorry
why did everything disappear but animations work and plus what is that erroe, I mean how to solve it
Quaternion.Euler``` doesnt exist
what does the rest of the error say?
Assets/Content/Prefabs/Player/PlayerMovement.cs(40,38): error CS0117: 'Quaternion' does not contain a definition for 'Euler'
Quaternion TestQuatEuler = Quaternion.Euler(1, 1, 1);```this is my code
do you have your own class/struct called Quaternion?
unity bug. restart the Editor
post !code of PlayerMovement
📃 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.
yeah it was that, tysm
read the bot message, use a paste site
fixed. rider error
why does my camera always depend from my resolution? can't I just make the size not changable?
Does a coroutine automatically set itself to null after IEnumerator finishes? If not, can we stop coroutine from itself?
no, and yes, if you can access the Coroutine returned from the StartCoroutine
thanks it works now just by setting the routine to null
was wondering why coroutine isnt null after yield break
damn good question, logically, as Coroutine is a C# object, once it goes out of scope it should be GC'd and become null, so I can only guess that there is native code trickery going on within Unitys code that is preventing this
I would guess they are using reflection badly which is not automatically GC'd
How do you get a component from a runtime instantiated prefab?
Store it into a variable
you use the return value from Instantiate
can you give me a simple example?
GameObject myPrefab = Instantiate(prefab, parentTransform);
MyComponent myComponent = myPrefab.GetComponent<MyComponent>();
aa okay. Thanks
What if it instantiates at the start. Can I just get component in the start as well? Would that work?
Yes, why wouldn't it?
save it to a class scope varaible
I'd want to put the rigidbody of my player in Player Rb in my attack prefab but it doesn't let me do it, does someone know why?
Wait, you want to put that None (Rigidbody 2D) in another prefab?
no, I want to put the rigid body of my player in the velocity script of this prefab
What is written on your player's Rigidbody? What's its type?
this is my player's rb
it makes no sense for 2 prefabs to reference each other
Is the Velocity script on a prefab?
You most likely need to hook these things up as you instantiate them if they aren't within the same object hierarchy or in the same scene.
I need it to know my player velocity
Prefabs cannot reference scene objects
You cannot reference scene objects in prefab
and how will my prefab know my player's velocity
sure but prefabs are not instantiated game objects and I'm pretty sure you want the reference from the game object not the prefab
So if you have a prefab with your Rigidbody2D, you assign it to the Rigidbody2D of the object in the scene
You can reference to it at runtime when it's spawned
You can assign it via code
oh, I didn't know, but I don't really know how
There're several options to do it, you usually use some sort of find methods
You can find your player by its:
- name
GameObject.Find("Player name").GetComponent<MyPlayer>();
- tag
GameObject.FindGameObjectsWithTag("Player tag").GetComponent<MyPlayer>();;
- type
GameObject.FindObjectOfType<MyPlayer>();
- parent
transform.GetComponentInChildren<MyPlayer>();
You can but you shouldn't ^
I'm looking up on internet but can't find anything to do so
GameObject.Find("MC"); and now how do I get the rb
by getting the rigidbody component
.GetComponent<Rigidbody2D>();
So uhm. This activation event uses the method inside FPEPlayerController on activation. FPEPlayerController is a prefab which gets instantiated at the start. Is this what you mean by "you cannot reference scene objects in prefab"?
Please, make it colorful. cs
using System.Collections.Generic;
using UnityEngine;
public class Structure : MonoBehaviour
{
public int maxGoblins = 2; // Maximum number of goblins this structure can hold
public int goblinCount = 0; // Current number of goblins inside the structure
public List<GameObject> goblinsInside = new List<GameObject>(); // List to hold references to goblins inside the structure
private void OnTriggerEnter(Collider other)
{
// Log the information to debug
Debug.Log("Trigger Enter: Collider Tag - " + other.tag + ", Goblin Count - " + goblinCount + ", Max Goblins - " + maxGoblins);
// Check if the entering collider is tagged as "Goblin" and there's space for more goblins
if (other.CompareTag("Goblin") && goblinCount < maxGoblins)
{
// Destroy the goblin GameObject
Destroy(other.gameObject);
// Add the destroyed goblin to the list of goblins inside the structure
goblinsInside.Add(other.gameObject);
// Increment the goblin count
goblinCount++;
// Update the count display
UpdateCountDisplay();
}
}
private void UpdateCountDisplay()
{
// Update the count display here (e.g., UI text, HUD, etc.)
Debug.Log("Goblins: " + goblinCount + "/" + maxGoblins);
}
}
you could've edited the previous message too.
GameObject.Find("MC");
playerRb = gameObject.GetComponent<Rigidbody2D>();
I did it like that and it still has his own rigidbody
that code makes no sense
It's vice versa.
You have a GameObject in the Scene. It can reference the prefabs.
You have a GameObject in your Assets, which is called a prefab. It cannot reference GameObjects from the Scenes.
yeah I thought so, I'm learning so let me learn, did you start knowing everything?
Hmm all right. Thanks
Started by learning basics through courses instead of trial and error over discord
actually , yes I did because I read the docs when I did not know something
Well, they haven't criticized you, have they?
so you didn't know everything, you had to still consult the docs, asking on discord is just the same just more efficient
chill guys
What doesn't seem to work?
"that code makes no sense", I mean they didn't criticize me but if you have to tell me such a thing tell me also what's wrong
you wrote the code but you obviously spent 0 effort to see what it does
it feels like ontriggerenter method doesnt work because when i try the trigger event, the debug log is not even appearing
They're not obligated to tell you what's wrong. They're not your personal tutor. At least now you know your code is wrong. Politely asking for any further explanations may be a better choice, I suppose 🙂
Yea this isn't efficient. This sort of use isn't what this space is for
Could you give me the objects that're supposed to collide?
the gameobject is goblin with goblin tag
Alright, by giving them I meant some sort of screenshot
and the script i sent is attached to the child gameobject which is just a collider with checked istrigger
Do I have to use FindObjectOfType before getting component in children? Or can I just go GetComponentInChildren?
What's your goal? These methods have different roles.
FindObjectOfType searches everywhere for an object of the type you asked for.
I am trying to get the position of destination from inside door
this is just a prototype, the capsules are the goblins
if you have a reference to the parent gameobject then GetComponentInChildren is fine
"Door" should have a component on it that holds a reference to the transform of the "Destination" object.
You're tring to get Destination's transform.position, right?
From..?
the script inside Door
Inside Door?
so the script attached to Door gameObject?
I meant that yes sorry
So you can just get any kind of component in children
if you have a component on "Door", just give it a Transform field and drag the "Destination" object into it
that would be easier
use GetComponentInChildren when you don't have any plausible way to set that reference ahead of time
you clearly do here (:
https://hastebin.com/share/pudaxecoda.csharp https://hastebin.com/share/rihewavaho.csharp why is the first enemy visible but all the other ones are not??
Well all right. I used GetComponentInChildren and tried to get the destination's position it did not work.
[SerializeField] Transform destination;
assign a reference in the inspector and you're done.
this is just a prototype, the capsules
GetComponentInChildren<Transform>() would wind up giving you the transform of the door. It searches your object and all of its children (including children of children)
so you might as well just write transform at that point :p
I see.
and FindObjectOfType<Transform>() would give you...something
it'd be whatever Transform unity happened to find first
I have a destination script attached to my destination. So I look for Destination object. Then get the component transform.
Its basically just a gizmo script to visualize
and it works now
I have been told to not use [SerializeField] that often and do stuff in the code as much as possible so yea
I dont know people be telling all kinds of stuff haha
whoever told you that is a quack
sure they're not, but if you speak in terms of polite, this wasn't polite by them and second I asked some explanations for my code "politely" something they didn't
This sounds like the opposite of what you should do.
I mean, I really know zero about getting an object component from a prefab, how does it come with effort, I can't know why it doesn't work
Using things like GetComponent and GameObject.Find will produce brittle code that breaks when you rename or rearrange objects
I truly do not know how to work so i am kind of lost at this point. But I will learn in time and find my own ways I believe.
I prefer to explicitly reference what I need.
can you link me to this? perhaps there was some context.
Ive been told that in voice chat. Also a developer friend im working on a game with. So I'm afraid not
Just was showing me the ropes
There is no voice chat here, so I guess that was somewhere else.
Ah yes not from here no.
Let's have a look at your code shall we?
GameObject.Find("MC");
playerRb = gameObject.GetComponent<Rigidbody2D>();
OK.
GameObject.Find returns a game object but, whoops, you don't assign it to a variable for later use
gameObject is a property of the current script so, of course, when you use GetComponent on it it return the component from the current game object
All this you would know if you had bothered to read the docs
There are many ways to build in Unity, and many opinions that come with it. Learning the "Unity way" is probably ideal if you are new to this stuff.
Let's just leave this topic. Try to ask questions without arguing 🙂
https://hastebin.com/share/pudaxecoda.csharp https://hastebin.com/share/rihewavaho.csharp why is the first enemy visible but all the other ones are not?
are they spawning infront of the camera tho?
you mean order in layer?
nope. i mean the Z position
Z position has to be bigger than camera's z
I mean, the whole point of code-beginner is about helping unity beginners, anyways ty and have a great day
well thats the position ur passing to Instantiate so yea
Indeed. And the takeaway here should not be that GetComponentInChildren is evil -- it's just inappropriate in this situation.
In that you are wrong, the whole point of code beginner is getting beginners to learn to help themselves
what about when 2nd enemy spawn , what is this printing
Debug.Log("Enemy spawned at: " + newEnemy.transform.position);
just incase
showing the coords where the enemy is spawned
and making sure the enemy IS spawned
which is
there we go
your pivot on the prefab mustbe wrong
-9.97 is practically close to -10
Can you do math with booleans? Like if a value is true set a value to -1 to flip something for example
the ternary operator can help with this.
foo * (predicate ? 1 : -1)
int the value = theBool ? thing : thing2;
Awesome thanks
ah, C# calls this the conditional operator
It's weird in that it's ternary, rather than binary
a ? b : c
do i reset the enemy's z?
yeah, it's often called the "ternary operator" because it's the only ternary operator you ever see
vs. a binary operator like 1 + 2 or a unary operator like -
Note that the conditional opterator has a very low precedence, so you'll need to parenthesize it in many cases
can you show the original prefab
the transform?
it's trying to apply 1f + true first
this is the whole hirerchy of the prefab ? and is it a prefab or are u just clone scene object
its not a prefab its a gameobject, im cloning that gameobject in a certain interval
why? make a prefab for it
Animator animator;
animator.SetBool("Walking", true);```
this isn't helpful
also where do you assign animtor
in prefab
wut
in the eidtor
editor
using UnityEditor.Animations;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float MovementSpeed = 4;
public Animator animator;
private void Update() {
animator.SetBool("Walking", Player.Speed == MovementSpeed);
Debug.Log(animator.GetFloat("MovementVelocity"));
}
}
screenshot your animator
ok i made one
ok, so what conditions do your transitions have?
Walking == True (Idle -> Walk)
ok so are you spawning prefab now?
Walking == False (Walk -> Idle)
and how does it get into Idle?
ye
it just refuses transition walking animation
it will only transition to Walking if it is already in Idle
why?
idle default animation
becaue that is how you have set it up
yeah thats default
is that not right?
what is the transition to Idle?
what is the log saying for position when you spawn prefab enemy instead?
still 8.42 -4.20 -9.97
during playmode can you show spawnPoint + show hierarchy
also show how you assigned spawnPoint
Af'noon all. I'm displacing a mesh with Shader Graph and was wondering if there was a way to update the mesh collider to conform to the new shape (this only happens on game start, so no worries about performance etc)
thats the issue
enemySpawnpoint is child of another object
show the position of EnemySuff
yup there is the culprit
all holder objects should ideally be at 0,0,0
well if you move it now its gonna move everything so be aware you gotta fix up by resetting all pos
so i make everything its own, then reset enemy stuff, then remake the things child?
Yep. That'll do it.
ye
tysm nav
hey guys, hope u okay. I am making an one button game and i want to know something.I use Input.GetKey and Input.GetKeyDown to make 2 different action but Input.GetKeyDown call my Input.GetKey action for one frame and i dont k if its possible to fix that
what are you trying to do with that?
i will post my code
It is not
oklol
GetKey will run when GetKeyDown does
Make a timer so GetKey only does something when held down a certain amount of time
That will give you a workaround
ok ill try
Sorry for the bump. lol.
bro i cant figure out how to apply these 2 vectors...
new Vector2
what are you doing, this isnt valid
can also do new(stuff,stuf,stuf) since c# 9
Well it is, because I know that you can update a mesh collider, but only through code. But I'm not displacing through code, but through Shader Graph. As far as I know the only way to update a mesh collider is through code.
You can discuss code in #archived-shaders
Well, I guess if it is specifically a mesh collider it should be fine here
Maybe just explain the issue better? I don't really understand it
Why when I changed to legacy text, rebinded everywhere, and now such an error?
whats on line 12 of addscore
you're showing wrong script
why is my animation not unity sucks, why is my animation not transitioning?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class addScore : MonoBehaviour
{
public Text text;
// Start is called before the first frame update
private void OnTriggerEnter2D(Collider2D collision)
{
Score.score++;
text.text = Score.score.ToString();
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
mate I cant read lines like this
which one is 12
text.text = Score.score.ToString();
anyway text or Score is null
Can`t
Errors don't lie
computer is never wrong
I'm displacing an imported mesh using Shader Graph. But I need the mesh collider to update so that it follows the displaced mesh and not the 'original' mesh.
How is that relevant?
do you know what a null is?
No data
it means the object you want to run something on is not there
https://unity.huh.how/runtime-exceptions/nullreferenceexception
Default value of a reference type
show where you assigned text for addScore script
There`s
None
and you wont be able to assign it from prefab if score text is in the scene
Does it do this?
Does what do what?
Null error
well yeah it says None
Since that is a null value, and you try to access it, yes it gives you a null error
doubt
I just changed the text to legacy text
what
Just type text
Yes
Why did you change it to a different incompatible type
wow why would you switch to Text
That`s bad?
yes its old
Yes!
looks like crap on high res
Your text component isn't compatible with that type
So you cannot assign it there
And it changed it to null
Old text type can`t assign scripts?
So now you get errors
Yes, if it IS the legacy text component
Which yours was not
you can assign it just fine, but you haven't and you need a way to find it runtime / passed onto it via spawner of pipe
but having score display inside pipes is bad practice
Omg, again retext code
No
No inside
That`s in main scene
mate, AddScore is inside the pipe prefab
why not just have the score UI tracker in the scene only
public Camera Camera;
float ctransform = Camera.transform.eulerAngles.x - IS_LookVector2Data.y * MouseSensitivity;
Camera.transform.eulerAngles = new Vector3(Mathf.Clamp(ctransform, -90, 90), transform.eulerAngles.y, 0);```
how come, when i look up to 0 degrees, it resets back to 90, the maximum clamp?
You can't just randomly change the types of your variables and expect things to work. TMP_Text is not Text.
I saw like that`s working with standart font
Text will simply not work
With the way you have things set up
You must use TMP_Text unless you want to make a bunch of other changes too
Changes that will make things worse
Ok, thanks, i will back that
im having an issue with a scene which is unloaded and then loads in
When that scene is loaded before play testing the game, it works as intended, but when it is initially unloaded and loads in after, it doesnt work
it has an inputfield
but it doesn't allow me to edit it if the scene loads in after
Perhaps you have multiple EventSystem components in play.
Search for t:eventsystem in the hierarchy's search box when the problem is happening
you'd get errors in the console if this was happening, though
public void ChangeDestination()
{
_destinationTransform.transform.position = new Vector3(-_destinationTransform.localPosition.x,
_destinationTransform.localPosition.y, _destinationTransform.localPosition.z);
}
I just wanna flip the destination's position to -. But this does not work. It should be like -1.68 on the x axis but it goes over to 15
something might be covering it or it spawned behind another canvas?
Okay, add another one
We need to find out if UI interaction is working at all
Throw a button on there.
ok
well, you're mixing up local positions and world positions
so of course it's going to act weirdly!
this is strange..
hm where should I look at?
do you understand what position and localPosition mean?
uhm position is world position. and local is dependant on where the object is
object's forward and back i believe
that is not correct; your position also depends on where the object is
Local position is your position relative to your parent.
this could be the issue but when i added in the button it is below the background
If you're at the same position as your parent, your local position is [0,0,0]
so you do have a background element on UI
i think so yes
Okay so Uhh the problem is that I'm trying to change the world position of destination to local position?
more likely is spawning behind the background then
Right. You need to figure out which space you actually meant to work in.
Hi, i can't assign my buttons using the onclick function and im not sure why
does my background need a canvas
If you want to flip the destination from the parent's left side to the parent's right side, use local position
disable Raycast Target on background Image or fix the order
You've dragged in the script asset itself.
I just need a still image in the background
public void ChangeDestination()
{
_destinationTransform.transform.localPosition = new Vector3(-_destinationTransform.localPosition.x,
_destinationTransform.localPosition.y, _destinationTransform.localPosition.z);
}
okay this works now thanks a lot
you're trying to call a method on the concept of a component
you need to drag in an actual instance of the component from your scene
also, you can make this a lot tidier
_destinationTransform.localPosition = Vector3.Scale(Vector3.left, _destinationTransform.localPosition);
🗿
thats fine but must have a disabled Raycast Target, also the order of hirerchy matters for ui. TopObjects are actually "Behind" bottom objects are Drawn last so they are infront
although it is probably more obvious what this one does
Ooo that is nice to know thanks.
I returned the text
Does this background image wind up in the DontDestroyOnLoad scene?
not sure
but yeah i gave the button a function and it didnt work
well, look at the hierarchy and find out...
didnt click either
is there a DontDestroyOnLoad scene in the hierarchy list?
yeah ur probably clicking the background
the button and inputfield load above the background though
and here's the hierarchy afterwards
and i moved the layer of the inputfield above the background and it still didn't work
what do you mean by "load above" here? are you talking about where they are in the hierarchy?
no there isn't that scene
show us the hierarchy with the background image and the input field visible
visually they appear aabove the background
also the event system in the new scene ?
no only in the scene above (the initial scene)
You have multiple scenes loaded here.
made it work ty 😉
ahh
yes and that is the only time the functions work, not when I unload and then load the scene in
cross-scene event system wont work
works fine for me!
does it? ah shoot
my EventSystem lives in DontDestroyOnLoad and I use canvases in various game scenes
This hierarchy looks good. Background is placed before the input field and the button
oh maybe its the DDOL quirk
what if event system is in isolation, it wont work in another scene right?
so they'll draw in the correct order
Does deactivating the background game object make the field work?
ill try
what do you mean "in isolation"?
like if its inside another scene not DDOL but just additive will still work
Do you have UI elements in other scenes?
yes
They may be drawing on top of your UI elements and blocking them
drag the event system into the "Player 1Name" scene and then unload the other scenes
you can right click a scene in the hierarchy to unload it
check out the event system during playmode and see whats hovering
ya, makes sense
what exactly is an event system
its the brains behind ur UI and the click
yea if u got 2 brains it fuks things up
Oh, did you not additively load the "Player 1Name" scene?
You showed a screenshot of multiple scenes being loaded simultaneously.
nice
coulda just hand dragged em
also whats the most simple way to carry over a string variable into another scene
DDOL
so I thought you were doing additive scene loading
wdym
whats that
if you mean one scene is loaded in the editor and they load in later
yes thats whats happening
loading another scene while other scene is still open
This screenshot shows at least three scenes loaded (one above "Player 1Name", one below "Player 1Name")
yeah but whats the point of that
Did you drag a scene asset into the hierarchy? This lets you work with multiple scenes at once in edit mode
so u could for example load a menu scene on top of ur game scene and have it stick around
many
so ur only unloading the game level
loading and unloading different game areas, for example
and reloading a new one.
oh okay well yes i just need them loaded one at a time
or leaving the world open as you move into a smaller battle scene
Okay, then put an EventSystem in each one
DDOL is DontDestroyOnLoad.. and its meant to tell a script /gameobject to not destroy itself when unload the scene
you can store variables in that script and have them persist from one scene to the next
this is weird, chatgpt reexplained what i want to happen but when chatgpt gave the code it does not change 😆
what i want to happen is the ontriggerenter method should happen on the child of the gameobject where the script is attached
thanks ill watch a tutorial
chatGPT is trash
wish more ppl were like u Zac
appreicate that
and trigger child will call the event if parent has rb afaik
that plugin i downloaded is trash too.. its decent to autocomlpeting single lines and stuff
but if u go and ask it to change ur script to something.. its as bad as chatgpt
the part that makes github copilot not as trash as say "generative" ai, is the fact that it works based on your code you already written and makes guesstimations based on Github repos etc.
i thought this one would do the same.. even says Tracking.. said script at the bottom
but u have to copy and paste it into the window thats right next to ur code..
😅 worthless
yeah just a way to consume "tokens" 😦
the code is working if i put the script to the child, but i want to put the script to the parent but the trigger should be the child gameobject
the parent has rigidbody ?
this one worked..
so put rigidbody on parent if you want child collider to get triigger
so it is working
Not really convinced it's reading a lot of your codebase
github co-pilot is expensive as an autocompletr
i think its not about the rigidbody
huh was under the impression thats what it worked on, the more you wrote. I don't use it personally so I cannot say for sure , just thought it was that way
yeah running GPUs all day is not cheap :p
if you come across a good open source one let me know
id run it locally id care ¯_(ツ)_/¯
Same, but failing to pick up basic stuff from other classes casts a doubt
i run midjourney locally.. no issues
as with all VC-fueled startup mania, you're going to get sticker shock when you start getting charged the actual cost of the service
thats not what I said, I meant if you want parent to get the event put a rigidnody on parent
private void OnTriggerEnter(Collider other)
{
how to make instead of the gameobject itself triggering, its for the child?
ya i didnt even sign up for the trial,, seeing as i may miss the window and get charged for the first month 😄
but the child doesnt, and its working if i put the script there
both doesnt have
explain what you're trying to actually make your game do
not "trigger on a child"
true, it just always looks soo amazing on Youtube vids dont it ? lol
I watch microsoft employees boasting on stream but yeah prob just advertising
it has to be on the child object
what are you implementing here?
or ur parent must have a rigidbody..
the child would be part of the rigidbody parent if has collider
Danny seems to have world experience
i'll take his word for it and wait for some innovations to take place first
AI took merrr jubb
i dont need More AI sniffing around my machine for now
It's a great auto completion engine 😛
^ facts! thast the only thing i see useful for this open source plugin i got
if im making a TV Controller and i type GameObject it fills it in.. GameObject tv;
good boi 🐶
lol
yeah pretty much with context is more useful, they cannot write good code because they do not reason with Logic
Can it take mine for a day, I dont wanna rewrite my inventory system
List<object> items;
ask fivver 😈
that'll be $5
i simply make a public static List<object> stuff; and put everything in it
Thanks FenAI 
invest in Fencoin today
enough exposure for u..
Knowing what you're trying to make your game will help us solve your original problem.
since "make a trigger happen on a child" sounds like an attempted solution to a problem
lol.. id hope so
i want to clarify the method ontriggerenter only works for the one where it is attached?
By default, yes!
When two colliders overlap in a way that causes trigger messages to be sent, the messgaes are sent to the objects with the colliders on them
not really, because the child is just an empty gameobject with collider trigger component
so i just want to put the script to the parent
However, there is one important exception. If a parent object of the collider has a Rigidbody component, then both the Rigidbody's object and the Collider's object will receive a message.
might have to listen for the collision on ur child and tell the parent about it
There's a problem, though...
The trigger messages don't tell you what your collider is
yup maybe a UnityEvent
It only gives you the othe collider.
Bingo.
This is what I do.
@hoary ice this is because having a rigidbody on the parent includes all child colliders together.. such as a composite collider (to make up the body) of the rigidbody
For example, for a soulslike game, I needed hitboxes (on weapons) and hurtboxes (on characters)
I have a Hurtbox component that's attached to the same object as the trigger collider
both the parent and the child doesnt have rigidbody, but the the gameobject colliding with it has
It tells its owner when it gets hit by a Hitbox
then u should do the version where the child listens and tells the parent about it
thats what you need to do
then pass info to the parent
^ would you like to know more?
i need to make 2 scripts then
absolutely
thanks, ill just put the script to the child, lol
[SerializeField] private UnityEvent theEvent;
private void OnTriggerEnter(Collider other)
{
theEvent?.Invoke();
}```
👍 if that works for u
events are super useful. i'd just bite the bullet and implement them
oh wait unity events dont need ? right
but if ur event isnt declared
wdym by that?
private UnityEvent theEvent;
this part. if its not present.. isnt that what the ? is for
or is it listeners?
oh for events ? throws null ref when there are no listeners to the event invoked
Yeah, UnityEvent isn't just a raw delegate.
ahh gotcha
thats why im curious if unity one doesnt ever call null ref
As long as it's been serialized by Unity, it will be initialized to something non-null
not sure
just like when you serialize a List<Whatever>
ahh so its just cause its inspector serialized
The reason that you have to check for null with an event is that the event field itself might be null (if nothing has been subscribed to it)
your unityEvent can't possibly be null as long as it's a serialized field
ok yea makes sense
on the inside, UnityEvent.Invoke() iterates over some arrays and calls everything in them
public event System.Action Whatever; is just a very thin wrapper around an ordinary delegate-typed field
@rich adder https://github.com/spawncampgames/Sandbox I leveled up
and the defualt value of a delegate type is null
what about a unityevent? does it work the same way? why is a delegate not needed?
just looking thru my code and i have both versions.. 1 w/ an event and delegate and my other just a unityevent
not even sure which ones better to use.. except the unity event is exposed in the inspector making some things easier
Ooooookay, been trying this for a while, not sure why this isn't working, but the collider doesn't get updated. Not sure if it's my logic, or if this is being exececuted before the shader graph has done the displacement. 😕
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.
💪 neat
my shite is all over the place, i should start organizing better xD
shader graph's displacement is typically applied during the rendering process, which happens after the mesh data has been processed.
thats mainly what this is for.. i have a set number of assets i tend to use over and over.. but they are scattered thruout projects..
trying to get 1 decent project i can use as a template to start all my projects.. having everything that i need..
and while im at it gonna throw a bone to tutorial watchers and stuff to have a decent project to use as well..
this is actually modifying the mesh data though
(with the more simpple / free assets)
oh, I missed the last part of Spud's message lol
ya but if his mesh data is before his graphs displacement.. the displacement values are present for the mesh data to use
yes, shader graph displacement does absolutely nothing to your mesh
it's purely happening on the GPU
^ its smoke and mirrors
You could write a compute shader that modifies your mesh and then read it back out of the GPU
my water asset uses a component to get the surface level of the water..
and it has to dig into the gpu stuff to make tha thappen
but you can't easily grab the result of the vertex shader
I should probably do that tbh. The amount of 'prototypes' I have that all use different variations of the same scripts is ridiculous. lol.
ya, its a chore for sure.. but worth it if u ever have some off-time
Aah, bugger it all to tits. lol.
I've written the same code in scripts and in a shader before
that was for an infinite runner where I needed to actually position things like lights in the same way that I was deforming meshes on the GPU
much neater than packages, I have made unitypackages for everything 😂
I'm basically making an infinite runner (of sorts) at the minute. lol.
with a cylindrical world, perhaps?
i used to make packages.. (still do if its 1 asset or so)
one where you need to be able to position objects correctly on the deformed mesh? 😛
but zipping entire projects feels safer..
That's what I'm displacing.
moving over the layers/tags/ project settings
true
My idea is basically Space Harrier-esque infinite runner (free left/right/up/down movement with mouse targetting)
But I want to be able to 'collide' with the 'walls'
this means that you're missing a prefab asset
u deleted the asset w/ that prefab in it
You've deleted a prefab.
You may have forgotten to import a package.
If that's the case, importing it will fix the broken references.
just re-install the asset and unless uve changed names and stuff it'll fix itself
imma re install it
or delete that gameobject if u dont need it? lol
if u unpack the asset it'll be its own thing (then u can drag out the pieces of it u need from teh asset into ur own folder) and then delete the asset
just gonna leave this here !vrchat
Join the growing VRChat community as you explore, play, and create the future of social VR! https://discord.com/invite/vrchat
This means that you have a missing component or missing prefab reference.
You're definitely missing some assets.
i just downloaded this from vrcmods, so i really dont know what im doing
are these also assets?
(note that unity has its own physbone system that replaces Dynamic Bone)
Is it hard to create 2D physics calculation? I wanna make a platform fighter but idk if some of the interactions I wanna do like hitstop or something will work with the normal rigidbody physics movement
up to your knowledge
i checked it and i didnt have dynamic bones, so thats why i cant save it
does it work the same? and is it freee?
It's provided for free by VRChat, yes
duly noted, thanks :<
ObjectThrownAnim has an Animator and Brille is a Cube with a material. In this Situaition drops the ObjectThrownAnim to front of the Player, but when OBA is a child of Brille, then it doesn't drop. Why?
can i use ddol on variables alone
or should i just carry over the object which holds the script with the variables
carry object over
kl
Ddol is moving an object to the ddol scene, so it has to be on a script on an object
a script counts as an object?
oh okay nvm
does ddol only carry the variable over to the next scene
and would I therefore need to carry it over for every scene if it is a variable i want to keep
DontDestroyOnLoad is used to prevent a Unity object from being destroyed by a scene transition.
Many kinds of things are Unity objects.
- GameObject
- MonoBehaviour
- Material
- ScriptableObject
- BoxCollider
...
It takes the whole game object, it has nothing to do your variable specifically. A variable may specifically just live on that object
When you pass a GameObject to DontDestroyOnLoad, it gets moved to the DontDestroyOnLoad scene, and is never destroyed by a scene change.
yeah so same question but for the object
ohh okay
thanks
Other kinds of Unity objects can be passed to DontDestroyOnLoad to prevent them from being cleaned up automatically. That's probably not relevant for you, though
(I only very recently learned you could even do that)
what does it mean if ddol only works for root objects
It can't be called on a GameObject that has a parent.
thats weird
I guess it doesn't want to wind up changing the object's parent in the process
since an object in scene B can't be parented to an object in scene A
If a parent is not in DDOL, it will be destroyed in a scene change. If the parent is destroyed, its children are destroyed.
How could a child be in DDOL?
does Application.OpenURL() work on MacOS and Linux?
Im building an SDK for unity but dont currently have access to either OS to test it on.
To be specific, I intend to use this just for loading a website on the native browser.
Yep, it works on my macbook
And I've used it on my Steam Deck too
Opening the file explorer is...less fun
So, its not a code issue, but im trying to connect a NavMeshSurface with another NavMeshSurface that is an Instantiated prefab.. Ive search everywhere, but couldnt find any answers. How do you do that?
I wonder if I can open a file URL with OpenURL, actually...
does it require any additional permissions when it attempts to run on Mac?
I currently use System.Diagnostics.Process.Start to run a per-platform program. It's icky.
Not that I've noticed.
sweet thank you so much.
Make the AI navmesh rebake during runtime as you add extra objects to your scene. You can also add jumps between gaps in the scene
ty bro it worked, i luv you
Your IDE has something to say about that variable. Hover over it and see
can it be a reason why smt isnt workign
Look at what your IDE wants to tell you about it by hovering over it and see
No
hello
You really that insecure that you committed to this despite it being auto deleted the first time? Damn.
is there a way to go transform.forward without a Rigidbody?
the rb causes it to rotate incorrectly
transform.forward is whatever direction the transform is facing
having a rigidbody (or not) is irrelevant
public UnityEngine.Camera Camera;
float DesiredRotation = Camera.transform.eulerAngles.x - Input.GetAxis("MouseAxis") * MouseSensitivity;
Camera.transform.eulerAngles = new Vector3(Mathf.Clamp(DesiredRotation, -90, 90), transform.eulerAngles.y);```
explain what you're trying to do and show your code
Why does this reset the value to 90 when Camera rotation on X axis reaches 0?
because the angle wraps around to 360, most likely
I would suggest not reading the euler angles, modifying them, and writing them back
Euler angles can change in surprising ways (wrapping around at 0 and 360, suddenly changing by 90/180 degrees as you rotate on a different axis..)
Instead, store the angle you want in a float, and use that to set the camera's rotation
Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(pitch, Vector3.right);
given a yaw (left-right) and pitch (up-down) angle, this computes a rotation
you can then just assign that into Camera.transform.rotation
When I rotate directly, the Z axis roll of camera is changing
So i looked up what to do and the docs saying eulerangle
is there another method besides setting eulerangles and rotation
I want the transform.position to move Vector3.forward but this doesnt work
this is moving your position towards [0, 0, 1]
read the documentation for MoveTowards.
"rotate directly"?
you'll need to show me what you did
remember that i can't see anything that you don't show me
float ctransform = Camera.transform.eulerAngles.x - IS_LookVector2Data.y * MouseSensitivity;
Camera.transform.rotation = Quaternion.AngleAxis(Mathf.Clamp(ctransform, -90, 90), Vector3.up) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right);```
Ah, you just have the multiplication backwards
well, no, you have the wrong axes for your AngleAxis methods
Vector3.up is pointing into the sky. That should be your yaw, not your pitch.
see here
yeah it is
transform.eulerAngles.y is character rotation
yeah
Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right);
This is creating an up-down rotation out of that angle
That doesn't make any sense.
float ctransform = Camera.transform.eulerAngles.x - IS_LookVector2Data.y * MouseSensitivity;
Camera.transform.rotation = Quaternion.AngleAxis(Mathf.Clamp(ctransform, -90, 90), Vector3.right) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.up);```still flickering
the camera rotation keeps going around the place
yes, because you should not be reading Camera.transform.eulerAngles.x and clamping that
do this.
float yaw;
float pitch;
store those values in fields.
yaw += lookInput.x;
pitch -= lookInput.y;
yaw = Mathf.Repeat(yaw, 360);
pitch = Mathf.Clamp(pitch, -87f, 87f);
a sample from my player controller
those values are in this: IS_LookVector2Data
right?
IS_LookVector2Data.x is yaw, IS_LookVector2Data.y is pitch?
No. That's your player input.
But yes, that's how you'll use the x and y values.
You need to remember pitch and yaw from frame to frame. The point is that you don't have to worry about them randomly changing
there are multiple valid euler anlges for the same rotation
hence some of your snapping problems
Hey hey! Can anyone tell me how to maintain an object unmovable even though it has a rigidbody compontent? I needed the rigidbody to trigger a collider
public float Pitch;
private void Update()
{
float ctransform = Pitch - IS_LookVector2Data.y * MouseSensitivity;
Camera.transform.rotation = Quaternion.AngleAxis(Mathf.Clamp(ctransform, -90, 90), Vector3.right) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.up);
}
public void InputLook()
{
IS_LookVector2Data = IS_Look.ReadValue<Vector2>();
Pitch = Camera.transform.eulerAngles.x;
}
}
freeze properties
in the rigidbody
Thank you so much 
You can also make the rigidbody kinematic. This prevents it from being affected by physics at all.
That's appropriate if you're moving the rigidbody around manually.
Stop trying to read the euler angles!
just do Pitch -= IS_LookVector2Data.y * MouseSensitivity;
then clamp it
Actually thats whats happening, cause I need to drag the item somewhere, but when clicking off of the object it needs to go back to its original position
pitch -= ...;
pitch = Mathf.Clamp(pitch, -90, 90);
If you don't store the clamped pitch, then the player will be look down to like
-1000 pitch
and then have to push the mouse really far up until the pitch gets back into the -90..90 range
Set the rigidbody to be kinematic and then set rb.position instead of transform.position. That'll make sure the physics system knows what you're doing.
Notably, setting transform.position will malfunction if you've got interpolation enabled on the rigidbody
because interpolation sets the transform's position every frame

Oh God, thank you for warning me cause that's what I was doing!
Setting rb.position queues up a position change for the next physics update
it's a straight teleportation, unlike rb.MovePosition, which actually moves the rigidbody through space
(which is mostly relevant for non-kinematic rigidbodies)
but I guess both kinds could hit things between the start and end points as long as you have continuous collision detection enabled
That's going to go on my Unity notes, thank you so much for your help
public float Pitch;
private void Update()
{
float ctransform = Pitch - IS_LookVector2Data.y * MouseSensitivity;
Camera.transform.rotation = Quaternion.AngleAxis(Pitch, Vector3.right) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.up);
}
public void InputLook()
{
IS_LookVector2Data = IS_Look.ReadValue<Vector2>();
Pitch -= IS_LookVector2Data.y * MouseSensitivity;
Pitch = Mathf.Clamp(Pitch, -90, 90);
}```its still rotating the Z axis
and its not rotating up properly either
you still have the pitch and yaw swapped around
yaw first, then pitch
i moved it around twice
is there a way i can send videos over 50 mb
Camera.transform.rotation = Quaternion.AngleAxis(Pitch, Vector3.up) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right);```
i mean to switch the two Quaternion.AngleAxis methods around entirely
i did this and i did```lua
Camera.transform.rotation = Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right) * Quaternion.AngleAxis(Pitch, Vector3.up);
yeah i did everything
that's also wrong
Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.up) * Quaternion.AngleAxis(Pitch, Vector3.right);
I would suggest just storing both Pitch and Yaw instead of reading back the Y rotation, but this should at least work properly
i tried earlier that it didnt work
well, try it again.
just same result, flicking over
📃 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.
Camera.transform.rotation = Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.up) * Quaternion.AngleAxis(Pitch, Vector3.right);
Camera.transform.eulerAngles = new Vector3(Camera.transform.rotation.x, Camera.transform.rotation.y, 0);``` my camera isnt moving now
rotation.x is not the X-axis euler angle
it's the first component of the quaternion
get rid of that second line entirely
u said no more euler angles
you don't need it.
oh i forgot that was there
that second line was trying to interpret the X and Y components of the quaternion -- values in the [-1..1] range -- as Euler angles
same result
power just glitched, brb
now its saying cancelled look callback on inputsystem
hey @swift crag , how could I face if I want each character to have an specific boost (For example: All characters have a Shooting Component but one character specifically has this special "boost" that allows him to shot bullet but these can follow the target). Should I make Another script for each boost for every character or is there another way
and we're back
in an error, or..?
yeah in console
show it to me.
i just deleted all the code
NullReferenceException while executing 'canceled' callbacks of 'Player/Look[/Mouse/delta]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass10_0:<set_onBeforeUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType)
UnityEngineInternal.Input.NativeInputSystem:NotifyBeforeUpdate (UnityEngineInternal.Input.NativeInputUpdateType) (at /Users/bokken/build/output/unity/unity/Modules/Input/Private/Input.cs:105)
i dont know who bokken is
you'll see that in various places
that's a filepath from the system they actually built Unity on
i just reset my code and its still doing this
There will be a second error that has the actual exception
which no sense because it wasnt earlier
This is just the input system complaining that an exception was thrown while it was handling input.
depends on how customizable you want this to be -- the most basic thing would be to just make an enum that has various kinds of upgrades
[System.Flags]
public enum Boosts {
HomingAttack = 1 << 0,
DoubleJump = 1 << 1,
Whatever = 1 << 2
}
This will let you pick from one or more boosts
This page describes what that weird syntax means
well, then something is null!
figure out what's causing it
Usually Input System errors come along with another error in the console, that will contain more info
well, that'll make it a lot harder to fix the code, then
Thanks!
if you rewrite it, just store pitch and float in fields and completely avoid reading transform.eulerAngles -- that keeps things straightforward
[System.Flags]
public enum Boosts {
HomingAttack = 1 << 0,
DoubleJump = 1 << 1,
Whatever = 1 << 2
} I read the page but it is still unclear how this works for me
I get the bitwise stuff
if (boosts & Boosts.HomingAttack != 0)
// you have a homing attack
If you need to be able to include more complex things, like a specific amount of speed boost, then you might just want to have a plain old C# class that holds all of the data
[System.Serializiable]
public class Boosts {
public bool homingAttack;
public float speedBoost;
}
this is easier to work with
well, if (boosts.homingAttack)