#💻┃code-beginner

1 messages · Page 272 of 1

unique kestrel
#

the log is running

#

but the first position is not changing

rich adder
#

even with .anchorPos?

#

lerp isn't correct btw, maybe try wiithout it

unique kestrel
#

with anchoredposition:

#

I tried setting the position without Lerp and it didn't work either

rich adder
#

you're putting it inside a canvas group ?

unique kestrel
#

no I just instantiate as a child object of a different canvas

#

there is a canvas group on the canvas

#

I just noticed that

strong condor
#

How do you show the current state of an enum in the inspector?

rich adder
unique kestrel
#

correct

rich adder
#

its visible?

rich adder
unique kestrel
#

actually I don't think it's visible I'll double check

#

it's visible

fiery mulch
#
    // 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

exotic hazel
#

hello inthis line is instance just a name?

night mural
languid spire
languid spire
#

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

unique kestrel
#

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.

burnt vapor
# exotic hazel hello inthis line is instance just a name?

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.

languid spire
# unique kestrel I feel like this is a sizable problem with barrier to entry in programming. Jarg...

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

unique kestrel
#

110%

near wadi
#

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.

languid spire
#

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

near wadi
eternal needle
near wadi
#

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#.

languid spire
#

At the end of the day, you cannot force people to realize the importance of learning and get them to do it

near wadi
#

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

eternal needle
near wadi
proven junco
#
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

near wadi
#

I think i will just have to make my own, and that will help me learn in the process

proven junco
#

still dosnt work

eternal needle
near wadi
proven junco
near wadi
proven junco
near wadi
#

Again, this is not the place to discuss this further. I wish you the best

vast vessel
#

I have adhd, i avoid school work and do c# instead

swift sedge
topaz thistle
#

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?

near wadi
#

did you by chance turn off Domain and Scene reload?

topaz thistle
#

Sorry, I don't understand 😅

near wadi
#

i will screen shot

topaz thistle
#

K thx

near wadi
topaz thistle
#

I have got static fields, if that conflicts with that in any way

near wadi
topaz thistle
#

They are both turned off

near wadi
#

so, it looks exactly like i have it above?, without Enter Play Mode Options checked too?

#

ok

#

well, that was my only guess

topaz thistle
#

Only issue is I have like hundreds of lines of code, U fine with looking through that?..

near wadi
#

!code

eternal falconBOT
near wadi
#

I won't be much help, but maybe someone will

topaz thistle
#

K!

near wadi
#

read the Bot post i sent..

topaz thistle
#

That contains the main stuff

topaz thistle
near wadi
#

Nah, not for more than a few lines 🙂

topaz thistle
#

Ohhh ok

#

Are there any requirements for SceneManager.LoadScene(SceneManager.GetActiveScene().name); to work properly?

languid spire
topaz thistle
topaz thistle
languid spire
topaz thistle
#

Do I need to do that if I'm not downloading it as a game/app?

languid spire
mild crypt
#

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?

topaz thistle
languid spire
topaz thistle
#

I just added the scene

#

Yeah, I'm just confirming

languid spire
#

you only have 1 scene?

topaz thistle
#

Yup

languid spire
#

then it's good

topaz thistle
#

Doesn't seem to have fixed it

languid spire
#

MacOs + Intel ?

swift sedge
topaz thistle
#

Yeah

languid spire
whole idol
#
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());
    }
}

?????????

topaz thistle
#

Mac used to use intel cpus

languid spire
topaz thistle
#

Anyways, any other suggestions?

topaz thistle
#

The main stuff at least

languid spire
topaz thistle
#

Unfortunately, that doesn't seemed to have fixed it

#

Any other suggestions or info u need?

languid spire
#

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

whole idol
#
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?

languid spire
whole idol
#

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;
    }
}

languid spire
whole idol
#

NullReferenceException: Object reference not set to an instance of an object PlayerAnimator.Update () (at Assets/Scripts/PlayerAnimator.cs:21)

languid spire
#

yep and line 21 of the PlayerAnimator script you posted is a blank line so cannot generate an error

whole idol
#

Also, should i add an catch excemption error handler or something?

languid spire
#

this is why you should use a paste site so we can actually see the correct line numbers

whole idol
#

Im watching them on my visual studio.

languid spire
#

guess what, we cannot see that

whole idol
#

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

languid spire
#

no, so that we can

whole idol
#

ye I get it bro

#

ill use it next time

whole idol
#

they look fine to me

languid spire
#

so post a screenshot of your VS

whole idol
languid spire
#

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?

languid spire
# whole idol

btw, this code is complete nonsense if Player is a monobehaviour

whole idol
languid spire
whole idol
#

im just follwing a tutorial though

languid spire
whole idol
#

ok

languid spire
#

one word of advice, if you see a line of code that you don't FULLY understand, read the docs until you do

queen adder
#

can someone give me a rotate script for the player

languid spire
#

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

queen adder
#

in first person??

languid spire
queen adder
dreamy urchin
#

why did everything disappear but animations work and plus what is that erroe, I mean how to solve it

queen adder
#
Quaternion.Euler``` doesnt exist
languid spire
queen adder
#
Quaternion TestQuatEuler = Quaternion.Euler(1, 1, 1);```this is my code
dreamy urchin
languid spire
queen adder
#

nope

#

fresh project, only added player movement and some 3d assets

languid spire
languid spire
eternal falconBOT
dreamy urchin
languid spire
#

read the bot message, use a paste site

queen adder
#

fixed. rider error

dreamy urchin
#

why does my camera always depend from my resolution? can't I just make the size not changable?

ebon robin
#

Does a coroutine automatically set itself to null after IEnumerator finishes? If not, can we stop coroutine from itself?

languid spire
ebon robin
#

was wondering why coroutine isnt null after yield break

languid spire
#

I would guess they are using reflection badly which is not automatically GC'd

final kestrel
#

How do you get a component from a runtime instantiated prefab?

willow scroll
languid spire
final kestrel
#

can you give me a simple example?

willow scroll
final kestrel
#

aa okay. Thanks

#

What if it instantiates at the start. Can I just get component in the start as well? Would that work?

languid spire
dreamy urchin
#

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?

willow scroll
dreamy urchin
willow scroll
dreamy urchin
willow scroll
#

You should be able to put it.

#

You're doing it wrong then.

languid spire
willow scroll
strong wren
#

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.

dreamy urchin
willow scroll
faint sluice
dreamy urchin
languid spire
willow scroll
#

So if you have a prefab with your Rigidbody2D, you assign it to the Rigidbody2D of the object in the scene

faint sluice
willow scroll
dreamy urchin
#

oh, I didn't know, but I don't really know how

willow scroll
#

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>();
dreamy urchin
#

I'm looking up on internet but can't find anything to do so

dreamy urchin
willow scroll
#
.GetComponent<Rigidbody2D>();
final kestrel
#

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"?

willow scroll
#

Please, make it colorful. cs

hoary ice
#

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);
    }
}
willow scroll
#

you could've edited the previous message too.

hoary ice
#

oh sorry

#

it seems doesnt work because the debug log is not even appearing

dreamy urchin
willow scroll
dreamy urchin
faint sluice
languid spire
willow scroll
dreamy urchin
hoary ice
#

chill guys

willow scroll
dreamy urchin
languid spire
hoary ice
willow scroll
strong wren
#

Yea this isn't efficient. This sort of use isn't what this space is for

willow scroll
hoary ice
#

the gameobject is goblin with goblin tag

willow scroll
#

Alright, by giving them I meant some sort of screenshot

hoary ice
#

and the script i sent is attached to the child gameobject which is just a collider with checked istrigger

final kestrel
#

Do I have to use FindObjectOfType before getting component in children? Or can I just go GetComponentInChildren?

willow scroll
swift crag
final kestrel
#

I am trying to get the position of destination from inside door

hoary ice
#

this is just a prototype, the capsules are the goblins

languid spire
swift crag
willow scroll
willow scroll
final kestrel
#

the script inside Door

willow scroll
#

so the script attached to Door gameObject?

final kestrel
#

I meant that yes sorry

willow scroll
#

So you can just get any kind of component in children

swift crag
#

if you have a component on "Door", just give it a Transform field and drag the "Destination" object into it

willow scroll
#

that would be easier

swift crag
#

use GetComponentInChildren when you don't have any plausible way to set that reference ahead of time

#

you clearly do here (:

austere monolith
final kestrel
#

Well all right. I used GetComponentInChildren and tried to get the destination's position it did not work.

swift crag
final kestrel
#

All right thanks for the answers.

#

I'll do that

willow scroll
#

this is just a prototype, the capsules

swift crag
#

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

final kestrel
#

I see.

swift crag
#

and FindObjectOfType<Transform>() would give you...something

#

it'd be whatever Transform unity happened to find first

final kestrel
#

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

rich adder
dreamy urchin
swift crag
dreamy urchin
swift crag
#

Using things like GetComponent and GameObject.Find will produce brittle code that breaks when you rename or rearrange objects

final kestrel
swift crag
#

I prefer to explicitly reference what I need.

swift crag
final kestrel
#

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

swift crag
#

There is no voice chat here, so I guess that was somewhere else.

final kestrel
#

Ah yes not from here no.

languid spire
# dreamy urchin I mean, I really know zero about getting an object component from a prefab, how ...

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

strong wren
#

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.

willow scroll
austere monolith
rich adder
austere monolith
#

you mean order in layer?

rich adder
#

Z position has to be bigger than camera's z

austere monolith
#

yeah

#

it is

dreamy urchin
rich adder
#

spawnpoint and camera z pos

austere monolith
#

oh spawnpoint

#

lol

rich adder
#

well thats the position ur passing to Instantiate so yea

austere monolith
swift crag
languid spire
rich adder
# austere monolith

what about when 2nd enemy spawn , what is this printing
Debug.Log("Enemy spawned at: " + newEnemy.transform.position);

#

just incase

austere monolith
#

showing the coords where the enemy is spawned

#

and making sure the enemy IS spawned

rich adder
#

which is

austere monolith
#

8.42, -4.20, -9.97

#

is that what you asked for?

rich adder
#

there we go

#

your pivot on the prefab mustbe wrong

#

-9.97 is practically close to -10

stuck palm
#

Can you do math with booleans? Like if a value is true set a value to -1 to flip something for example

swift crag
#
foo * (predicate ? 1 : -1)
rich adder
stuck palm
#

Awesome thanks

swift crag
#

ah, C# calls this the conditional operator

#

It's weird in that it's ternary, rather than binary

#

a ? b : c

rich adder
#

isnt taht ternary ?

#

oh

austere monolith
swift crag
#

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

rich adder
austere monolith
#

the transform?

swift crag
#

it's trying to apply 1f + true first

austere monolith
rich adder
# austere monolith

this is the whole hirerchy of the prefab ? and is it a prefab or are u just clone scene object

queen adder
#

animation controller wont transition

#

im setting bool as true and it wont.

austere monolith
queen adder
#
Animator animator;

animator.SetBool("Walking", true);```
austere monolith
#

ok

#

ill do that

rich adder
#

also where do you assign animtor

queen adder
rich adder
#

wut

queen adder
#

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"));
    }
}
austere monolith
queen adder
languid spire
queen adder
queen adder
rich adder
queen adder
#

Walking == False (Walk -> Idle)

languid spire
#

and how does it get into Idle?

austere monolith
queen adder
#

it just refuses transition walking animation

languid spire
#

it will only transition to Walking if it is already in Idle

queen adder
#

idle default animation

languid spire
#

becaue that is how you have set it up

queen adder
#

is that not right?

languid spire
#

what is the transition to Idle?

rich adder
austere monolith
#

still 8.42 -4.20 -9.97

rich adder
#

also show how you assigned spawnPoint

austere monolith
ruby python
#

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)

rich adder
#

enemySpawnpoint is child of another object

#

show the position of EnemySuff

austere monolith
rich adder
#

yup there is the culprit

austere monolith
#

lol

#

so i delete enemy stuff and make everything its own?

rich adder
#

all holder objects should ideally be at 0,0,0

austere monolith
#

oh

#

so i just do that?

rich adder
#

well if you move it now its gonna move everything so be aware you gotta fix up by resetting all pos

austere monolith
#

so i make everything its own, then reset enemy stuff, then remake the things child?

ruby python
#

Yep. That'll do it.

austere monolith
#

tysm nav

proven inlet
#

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

rich adder
proven inlet
#

i will post my code

proven inlet
#

oklol

summer stump
#

GetKey will run when GetKeyDown does

summer stump
# proven inlet oklol

Make a timer so GetKey only does something when held down a certain amount of time

#

That will give you a workaround

proven inlet
#

ok ill try

scarlet skiff
#

bro i cant figure out how to apply these 2 vectors...

summer stump
summer stump
rich adder
#

can also do new(stuff,stuf,stuf) since c# 9

ruby python
#

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.

summer stump
#

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

wraith valley
#

Why when I changed to legacy text, rebinded everywhere, and now such an error?

rich adder
#

you're showing wrong script

queen adder
# queen adder

why is my animation not unity sucks, why is my animation not transitioning?

wraith valley
#
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()
    {

    }
}
rich adder
#

which one is 12

wraith valley
#
text.text = Score.score.ToString();
rich adder
#

anyway text or Score is null

wraith valley
#

Can`t

summer stump
rich adder
#

computer is never wrong

ruby python
wraith valley
#

That`s cant be null

summer stump
rich adder
wraith valley
rich adder
summer stump
rich adder
wraith valley
#

There`s

rich adder
#

None

summer stump
#

So it is null

rich adder
#

and you wont be able to assign it from prefab if score text is in the scene

wraith valley
summer stump
wraith valley
#

Null error

rich adder
#

well yeah it says None

summer stump
#

Since that is a null value, and you try to access it, yes it gives you a null error

wraith valley
#

Yesterday that`s worked

#

Lol

rich adder
#

doubt

summer stump
#

Yesterday you had it assigned

#

I saw it

wraith valley
#

I just changed the text to legacy text

summer stump
#

You changed something

#

Well yeah. That is a massive change that would mess it up

rich adder
wraith valley
summer stump
#

Why would you do that

#

You had it working as TMP_Text

wraith valley
summer stump
#

Why did you change it to a different incompatible type

rich adder
#

wow why would you switch to Text

wraith valley
rich adder
#

yes its old

summer stump
#

Yes!

rich adder
#

looks like crap on high res

summer stump
#

Your text component isn't compatible with that type

#

So you cannot assign it there

#

And it changed it to null

wraith valley
#

Old text type can`t assign scripts?

summer stump
#

So now you get errors

summer stump
#

Which yours was not

rich adder
#

but having score display inside pipes is bad practice

wraith valley
#

Omg, again retext code

wraith valley
#

No inside

#

That`s in main scene

rich adder
#

mate, AddScore is inside the pipe prefab
why not just have the score UI tracker in the scene only

queen adder
#
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?

swift crag
wraith valley
summer stump
#

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

wraith valley
#

Ok, thanks, i will back that

carmine sierra
#

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

swift crag
#

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

carmine sierra
#

just one

#

the scene's ui loads but the input field doesn't work

swift crag
#

Do other UI elements work?

#

e.g. do buttons change color as you click on them?

final kestrel
#
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

carmine sierra
#

there's only one ui element

#

which is the inputfield

rich adder
#

something might be covering it or it spawned behind another canvas?

swift crag
#

We need to find out if UI interaction is working at all

#

Throw a button on there.

carmine sierra
#

ok

swift crag
#

so of course it's going to act weirdly!

final kestrel
#

hm where should I look at?

swift crag
#

do you understand what position and localPosition mean?

final kestrel
#

uhm position is world position. and local is dependant on where the object is

#

object's forward and back i believe

swift crag
#

that is not correct; your position also depends on where the object is

#

Local position is your position relative to your parent.

carmine sierra
#

this could be the issue but when i added in the button it is below the background

swift crag
#

If you're at the same position as your parent, your local position is [0,0,0]

rich adder
carmine sierra
final kestrel
#

Okay so Uhh the problem is that I'm trying to change the world position of destination to local position?

rich adder
swift crag
queen adder
#

Hi, i can't assign my buttons using the onclick function and im not sure why

carmine sierra
swift crag
#

If you want to flip the destination from the parent's left side to the parent's right side, use local position

rich adder
swift crag
carmine sierra
#

I just need a still image in the background

final kestrel
#
public void ChangeDestination()
    {
        _destinationTransform.transform.localPosition = new Vector3(-_destinationTransform.localPosition.x,
            _destinationTransform.localPosition.y, _destinationTransform.localPosition.z);
    }

okay this works now thanks a lot

swift crag
#

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

swift crag
#
_destinationTransform.localPosition = Vector3.Scale(Vector3.left, _destinationTransform.localPosition);
wraith valley
rich adder
swift crag
final kestrel
wraith valley
swift crag
#

UnityEditor errors are usually not your fault

#

restart the editor

wraith valley
#

I returned the text

swift crag
carmine sierra
#

but yeah i gave the button a function and it didnt work

swift crag
carmine sierra
#

didnt click either

swift crag
#

is there a DontDestroyOnLoad scene in the hierarchy list?

rich adder
carmine sierra
swift crag
#

no, just look at the hierarchy

#

this hierarchy has one scene in it

#

called Dev Room

carmine sierra
swift crag
#

and here's the hierarchy afterwards

carmine sierra
#

and i moved the layer of the inputfield above the background and it still didn't work

swift crag
carmine sierra
swift crag
#

show us the hierarchy with the background image and the input field visible

carmine sierra
rich adder
#

also the event system in the new scene ?

carmine sierra
carmine sierra
swift crag
#

You have multiple scenes loaded here.

wraith valley
carmine sierra
rich adder
#

cross-scene event system wont work

swift crag
rich adder
#

does it? ah shoot

swift crag
#

my EventSystem lives in DontDestroyOnLoad and I use canvases in various game scenes

swift crag
# carmine sierra

This hierarchy looks good. Background is placed before the input field and the button

rich adder
#

oh maybe its the DDOL quirk
what if event system is in isolation, it wont work in another scene right?

swift crag
#

so they'll draw in the correct order

#

Does deactivating the background game object make the field work?

carmine sierra
#

ill try

swift crag
carmine sierra
#

no it doesnt

#

so think the scene is just loading incorrectly

rich adder
swift crag
carmine sierra
swift crag
#

They may be drawing on top of your UI elements and blocking them

carmine sierra
#

ill try that

#

unloading all other scene

swift crag
#

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

rich adder
#

check out the event system during playmode and see whats hovering

carmine sierra
#

it worked

#

after putting an eventsystem in each scene

rocky canyon
#

ya, makes sense

carmine sierra
#

what exactly is an event system

rocky canyon
#

its the brains behind ur UI and the click

carmine sierra
#

so one in each scene is fine but not if two are loaded

#

ohh okay

rocky canyon
#

yea if u got 2 brains it fuks things up

swift crag
#

Oh, did you not additively load the "Player 1Name" scene?

#

You showed a screenshot of multiple scenes being loaded simultaneously.

rocky canyon
#

coulda just hand dragged em

carmine sierra
#

also whats the most simple way to carry over a string variable into another scene

rocky canyon
#

DDOL

swift crag
#

so I thought you were doing additive scene loading

carmine sierra
carmine sierra
#

if you mean one scene is loaded in the editor and they load in later

#

yes thats whats happening

rich adder
#

loading another scene while other scene is still open

swift crag
# carmine sierra

This screenshot shows at least three scenes loaded (one above "Player 1Name", one below "Player 1Name")

rocky canyon
#

u can load multiple scenes together

#

the camera will just overlap them

carmine sierra
swift crag
#

Did you drag a scene asset into the hierarchy? This lets you work with multiple scenes at once in edit mode

rocky canyon
#

so u could for example load a menu scene on top of ur game scene and have it stick around

rich adder
rocky canyon
#

so ur only unloading the game level

swift crag
rocky canyon
#

and reloading a new one.

carmine sierra
swift crag
#

or leaving the world open as you move into a smaller battle scene

swift crag
rocky canyon
#

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

hoary ice
#

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

carmine sierra
rocky canyon
#

wish more ppl were like u Zac

carmine sierra
#

appreicate that

rich adder
rocky canyon
#

but if u go and ask it to change ur script to something.. its as bad as chatgpt

rich adder
rocky canyon
#

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

rich adder
#

yeah just a way to consume "tokens" 😦

hoary ice
#

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

rocky canyon
rocky canyon
#

this one worked..

hoary ice
#

no

#

the one triggering it has one

rich adder
# hoary ice no

so put rigidbody on parent if you want child collider to get triigger

hoary ice
#

so it is working

strong wren
rocky canyon
#

github co-pilot is expensive as an autocompletr

hoary ice
#

i think its not about the rigidbody

rich adder
rocky canyon
#

Tabnine is another one..

#

but also expensive imo

rich adder
#

yeah running GPUs all day is not cheap :p

rocky canyon
#

if you come across a good open source one let me know

#

id run it locally id care ¯_(ツ)_/¯

strong wren
rocky canyon
#

i run midjourney locally.. no issues

swift crag
rich adder
hoary ice
#

private void OnTriggerEnter(Collider other)
{

how to make instead of the gameobject itself triggering, its for the child?

rocky canyon
hoary ice
#

both doesnt have

swift crag
#

not "trigger on a child"

rich adder
rocky canyon
swift crag
#

what are you implementing here?

rocky canyon
#

or ur parent must have a rigidbody..

rich adder
rocky canyon
#

Danny seems to have world experience

#

i'll take his word for it and wait for some innovations to take place first

rich adder
#

AI took merrr jubb

rocky canyon
#

i dont need More AI sniffing around my machine for now

strong wren
#

It's a great auto completion engine 😛

rocky canyon
#

^ 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

rich adder
#

yeah pretty much with context is more useful, they cannot write good code because they do not reason with Logic

eternal needle
rocky canyon
#

ask fivver 😈

swift crag
#

that'll be $5

#

i simply make a public static List<object> stuff; and put everything in it

eternal needle
#

Thanks FenAI UnityChanThumbsUp

swift crag
#

invest in Fencoin today

rocky canyon
#

enough exposure for u..

swift crag
#

since "make a trigger happen on a child" sounds like an attempted solution to a problem

rocky canyon
#

lol.. id hope so

hoary ice
#

i want to clarify the method ontriggerenter only works for the one where it is attached?

swift crag
#

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

hoary ice
#

so i just want to put the script to the parent

swift crag
#

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.

rocky canyon
#

might have to listen for the collision on ur child and tell the parent about it

swift crag
#

There's a problem, though...

#

The trigger messages don't tell you what your collider is

swift crag
#

It only gives you the othe collider.

rocky canyon
swift crag
#

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

hoary ice
#

both the parent and the child doesnt have rigidbody, but the the gameobject colliding with it has

swift crag
#

It tells its owner when it gets hit by a Hitbox

hoary ice
#

if i put the script to the child, it works

#

but not if i put to the parent

rocky canyon
#

then u should do the version where the child listens and tells the parent about it

rich adder
#

then pass info to the parent

rocky canyon
#

^ would you like to know more?

hoary ice
#

i need to make 2 scripts then

rocky canyon
#

absolutely

hoary ice
#

thanks, ill just put the script to the child, lol

rich adder
#
[SerializeField] private UnityEvent theEvent;
    private void OnTriggerEnter(Collider other)
    {
        theEvent?.Invoke();
    }```
rocky canyon
#

👍 if that works for u

#

events are super useful. i'd just bite the bullet and implement them

rich adder
#

oh wait unity events dont need ? right

rocky canyon
#

its a null checker iirc

#

so prob not

rich adder
#

they don't throw null if nothing listens

#

unlike c# event

rocky canyon
#

but if ur event isnt declared

rich adder
#

wdym by that?

rocky canyon
#

private UnityEvent theEvent;

#

this part. if its not present.. isnt that what the ? is for

#

or is it listeners?

rich adder
#

oh for events ? throws null ref when there are no listeners to the event invoked

swift crag
#

Yeah, UnityEvent isn't just a raw delegate.

rocky canyon
#

ahh gotcha

rich adder
#

thats why im curious if unity one doesnt ever call null ref

swift crag
#

As long as it's been serialized by Unity, it will be initialized to something non-null

rocky canyon
#

not sure

swift crag
#

just like when you serialize a List<Whatever>

rich adder
#

ahh so its just cause its inspector serialized

swift crag
#

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

rich adder
#

ok yea makes sense

swift crag
#

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

rocky canyon
swift crag
#

and the defualt value of a delegate type is null

rocky canyon
#

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

ruby python
rich adder
#

my shite is all over the place, i should start organizing better xD

rocky canyon
rocky canyon
#

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..

swift crag
rocky canyon
#

(with the more simpple / free assets)

swift crag
#

oh, I missed the last part of Spud's message lol

rocky canyon
#

ya but if his mesh data is before his graphs displacement.. the displacement values are present for the mesh data to use

swift crag
#

yes, shader graph displacement does absolutely nothing to your mesh

#

it's purely happening on the GPU

rocky canyon
#

^ its smoke and mirrors

swift crag
#

You could write a compute shader that modifies your mesh and then read it back out of the GPU

rocky canyon
#

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

swift crag
#

but you can't easily grab the result of the vertex shader

ruby python
rocky canyon
#

ya, its a chore for sure.. but worth it if u ever have some off-time

ruby python
rocky canyon
#

heres my actual starter project

#

and this is what ive gotten it down to

swift crag
#

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

rich adder
ruby python
#

I'm basically making an infinite runner (of sorts) at the minute. lol.

swift crag
rocky canyon
swift crag
#

one where you need to be able to position objects correctly on the deformed mesh? 😛

rocky canyon
#

but zipping entire projects feels safer..

ruby python
#

That's what I'm displacing.

rocky canyon
#

moving over the layers/tags/ project settings

rich adder
#

true

ruby python
#

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'

valid crest
#

hi, hello , i need to know what to do here

swift crag
rocky canyon
#

u deleted the asset w/ that prefab in it

ruby python
#

You've deleted a prefab.

swift crag
#

You may have forgotten to import a package.

#

If that's the case, importing it will fix the broken references.

rocky canyon
#

just re-install the asset and unless uve changed names and stuff it'll fix itself

valid crest
#

imma re install it

rocky canyon
#

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

rich adder
#

just gonna leave this here !vrchat

eternal falconBOT
valid crest
#

delete the game asset?

#

it says im missing a script

swift crag
# valid crest

This means that you have a missing component or missing prefab reference.

valid crest
swift crag
#

You're definitely missing some assets.

valid crest
#

i just downloaded this from vrcmods, so i really dont know what im doing

#

are these also assets?

swift crag
#

(note that unity has its own physbone system that replaces Dynamic Bone)

stuck palm
#

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

valid crest
#

i checked it and i didnt have dynamic bones, so thats why i cant save it

valid crest
swift crag
valid crest
#

duly noted, thanks :<

stoic glen
#

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?

carmine sierra
#

can i use ddol on variables alone

#

or should i just carry over the object which holds the script with the variables

carmine sierra
#

kl

eternal needle
carmine sierra
#

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

swift crag
#

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
    ...
eternal needle
swift crag
#

When you pass a GameObject to DontDestroyOnLoad, it gets moved to the DontDestroyOnLoad scene, and is never destroyed by a scene change.

carmine sierra
swift crag
#

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)

carmine sierra
#

what does it mean if ddol only works for root objects

swift crag
#

It can't be called on a GameObject that has a parent.

carmine sierra
#

thats weird

swift crag
#

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

summer stump
# carmine sierra thats weird

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?

dire torrent
#

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.

swift crag
#

Yep, it works on my macbook

#

And I've used it on my Steam Deck too

#

Opening the file explorer is...less fun

crystal fiber
#

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?

swift crag
#

I wonder if I can open a file URL with OpenURL, actually...

dire torrent
swift crag
dire torrent
dense arch
quartz mural
#

what do the 3 dots means?

crystal fiber
polar acorn
quartz mural
#

can it be a reason why smt isnt workign

eternal needle
#

Look at what your IDE wants to tell you about it by hovering over it and see

hexed terrace
queen adder
#

hello

frosty hound
#

You really that insecure that you committed to this despite it being auto deleted the first time? Damn.

quick ruin
#

is there a way to go transform.forward without a Rigidbody?

#

the rb causes it to rotate incorrectly

swift crag
#

having a rigidbody (or not) is irrelevant

queen adder
#
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);```
swift crag
queen adder
swift crag
#

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

queen adder
#

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

quick ruin
#

I want the transform.position to move Vector3.forward but this doesnt work

swift crag
#

read the documentation for MoveTowards.

swift crag
#

you'll need to show me what you did

#

remember that i can't see anything that you don't show me

queen adder
#
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);```
swift crag
#

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.

queen adder
#

transform.eulerAngles.y is character rotation

swift crag
#

transform.eulerAngles.y is your yaw

#

your left-right rotation

queen adder
#

yeah

swift crag
#

Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right);

This is creating an up-down rotation out of that angle

#

That doesn't make any sense.

queen adder
#
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

swift crag
#

yes, because you should not be reading Camera.transform.eulerAngles.x and clamping that

swift crag
#
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

queen adder
#

those values are in this: IS_LookVector2Data

#

right?

#

IS_LookVector2Data.x is yaw, IS_LookVector2Data.y is pitch?

swift crag
swift crag
#

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

radiant tulip
#

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

queen adder
#
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;
    }
}
queen adder
#

in the rigidbody

radiant tulip
#

Thank you so much UnityChanThumbsUp

swift crag
#

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.

swift crag
#

just do Pitch -= IS_LookVector2Data.y * MouseSensitivity;

#

then clamp it

radiant tulip
swift crag
#
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

swift crag
#

Notably, setting transform.position will malfunction if you've got interpolation enabled on the rigidbody

#

because interpolation sets the transform's position every frame

radiant tulip
#

Oh God, thank you for warning me cause that's what I was doing!

swift crag
#

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

radiant tulip
#

That's going to go on my Unity notes, thank you so much for your help

queen adder
#
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

swift crag
#

yaw first, then pitch

queen adder
#

i moved it around twice

fading rapids
#

is there a way i can send videos over 50 mb

queen adder
#
Camera.transform.rotation = Quaternion.AngleAxis(Pitch, Vector3.up) * Quaternion.AngleAxis(transform.eulerAngles.y, Vector3.right);```
swift crag
#

i mean to switch the two Quaternion.AngleAxis methods around entirely

queen adder
#

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

swift crag
#
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

queen adder
#

i tried earlier that it didnt work

swift crag
#

well, try it again.

queen adder
#

just same result, flicking over

swift crag
#

Show me the entire script.

#

!code

eternal falconBOT
queen adder
#

        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
swift crag
#

rotation.x is not the X-axis euler angle

#

it's the first component of the quaternion

#

get rid of that second line entirely

queen adder
#

u said no more euler angles

swift crag
#

you don't need it.

queen adder
#

oh i forgot that was there

swift crag
queen adder
#

same result

swift crag
#

power just glitched, brb

queen adder
#

now its saying cancelled look callback on inputsystem

ionic zephyr
#

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

swift crag
#

and we're back

swift crag
queen adder
swift crag
#

show it to me.

queen adder
#

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

swift crag
#

you'll see that in various places

#

that's a filepath from the system they actually built Unity on

queen adder
#

i just reset my code and its still doing this

swift crag
#

There will be a second error that has the actual exception

queen adder
#

which no sense because it wasnt earlier

swift crag
#

This is just the input system complaining that an exception was thrown while it was handling input.

swift crag
#
[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

swift crag
#

figure out what's causing it

queen adder
#

jump didnt exist

#

fixed

#

i deleted all the code though

short hazel
#

Usually Input System errors come along with another error in the console, that will contain more info

swift crag
#

well, that'll make it a lot harder to fix the code, then

swift crag
#

if you rewrite it, just store pitch and float in fields and completely avoid reading transform.eulerAngles -- that keeps things straightforward

queen adder
#

it all works now fen

ionic zephyr
swift crag
#

You can use this to check if a Boosts value includes a specific option

ionic zephyr
#

I get the bitwise stuff

swift crag
#
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

ionic zephyr
#

Oh okay

#

and there I write all of the boosts?

#

if (homingAttack)

#

{Code]

swift crag
#

well, if (boosts.homingAttack)