#πŸ’»β”ƒcode-beginner

1 messages Β· Page 597 of 1

rocky canyon
#

with a physics raycaster on ur cam it can work w/ regular colliders

rich adder
#

internally is just doing a raycast... the interface methods are what make it more particular

swift crag
#

You do need the physics raycaster. very important.

fleet venture
#

so you put that on your camera

rich adder
#

yes

rocky canyon
#

b/c im never sure which one i need 🀣

#

i just add both

fleet venture
#

the 2d one

rich adder
#

Physics = colliders
Graphic = canvas

rocky canyon
#

^ there ya go

#

ez pz

fleet venture
#

okay that makes sense

rich adder
rocky canyon
#

then ur IPointer stuff just works out the box

fleet venture
#

and then i can implement IBeginDragHandler, IEndDragHandler?

rocky canyon
#

it should..

#

now u can debug.log quickly

#

to test

fleet venture
#

uh its now just stuck to my mouse

deft breach
#

Try this alternatively:

{
    private bool _dragging;
    private static Camera _mainCamera;

    private void Awake()
    {
        _mainCamera = Camera.main;
        _dragging = true;
    }

    private void Update()
    {
        Debug.Log(_dragging);
        if (!_dragging) return;
        var mousePosition = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(mousePosition.x, mousePosition.y, 0);
    }

    private void OnMouseDown()
    {
        _dragging = true;
    }

    private void OnMouseUp()
    {
        _dragging = false;
    }
}```

With this:
```public void AddObject(GameObject instance, bool isBackground)
  {
      gameManager.IncreaseObjectLayer();
      var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
      if (mousePosition == null) return;
      instance.transform.position = new Vector3(mousePosition.Value.x, mousePosition.Value.y, 0);
  }```
But idk Pointers are probably better
fleet venture
#

wdym Pointers?

#

like... c++ pointers?

deft breach
#

Sorry i meant Ipointers

fleet venture
#

ah

#

so not IDrag

rocky canyon
#

when i do Ipointers i dont use teh drag

#

i do ti manually..

#

i use the Down,, Enter, Exit, etc

#

just like the OnMouse ones.. but Interfaces instead

fleet venture
#

well now it doesnt do anything

#

the event doesnt work

#

maybe i forgot something

grand snow
#

Drag is doing the drag threshold for you and some other bits such as tracking the "dragged" object and allowing use of the drop event

rocky canyon
#

u know u can expand ur EventSystem too btw..

rich adder
#

did you use the 2D physics raycaster on the camera

rocky canyon
#

it shows important debug stuff too..

deft breach
fleet venture
#

or XD do you mean adding extra events

fleet venture
rocky canyon
#

it'll have a box below it once it goes into play mode

fleet venture
#

wait how do you do that

#

is it a keybind?

rocky canyon
#

just select the event system

#

then play ->

fleet venture
#

ah

rocky canyon
#

its all the info about what the event system is seeing.. doing.. etc

fleet venture
rich adder
#

this doesnt work now

#

unity borked it with the new Input system

grand snow
# rocky canyon

This is broken and gives like 0 info with the new input system 😦

rocky canyon
#

aww 😭 really?

rich adder
#

you only get clicked events now when selected

grand snow
#

THANKS UNITY

rocky canyon
#

i didnt know it was broken now..

fleet venture
#

.-.

rich adder
#

new Input module is a disgrace

grand snow
#

lets wait for input system no 3

fleet venture
#

ye my teach er wanted us to use the old one

rocky canyon
#

(β•―Β°β–‘Β°)β•―οΈ΅ ┻━┻

rocky canyon
#

until i cant anymore lmao

rich adder
#

someone at unity : lets give them even less info

rocky canyon
#

you get a raise!

rich adder
#

brilliant

fleet venture
#

ok so any ideas why my drag events dont fire

grand snow
#

remember you need the correct raycaster for 3d/2d physics. Also CHECK THE LAYERS

rich adder
#

keep in mind the iPointer methods goes on the object with collider iirc

fleet venture
#

well im trying IBeginDragHandler, IEndDragHandler

#

but i have that

rich adder
#

use links

fleet venture
#

links?

grand snow
#

eyy you need the physics 2d raycaster

fleet venture
grand snow
#

also add a sprite cus the sorting is fucked without one

fleet venture
#

this is on the prefab

#

i have a sprite renderer if thats what you mean

rich adder
eternal falconBOT
fleet venture
grand snow
fleet venture
#

im clicking on this part

#

nothing is in front of it

#

or behind it

rich adder
#

you couldDebug the EventSystem raycast and see if something is blocking the ray

grand snow
#

hide your UI to be sure. Also try adding a rigidbody 2d too

rich adder
#

na raycasts dont need rigidbody just colliders

grand snow
#

ill check a project that uses 2d physics with the event system a lot i forget...

fleet venture
#

wait do i need anything on my EventSystem object?

rich adder
#

input module and event system

fleet venture
#

ok i have those

grand snow
fleet venture
#

that says everything for me

rocky canyon
#

this is why i quit my UI/UX job 😈

rich adder
#

when in doubt Debug it


    [SerializeField] EventSystem eventSystem;
    [SerializeField] Physics2DRaycaster physics2DRaycaster;
    void Update()
    {
        PointerEventData pointerEventData = new PointerEventData(eventSystem);
        pointerEventData.position = Input.mousePosition;

        List<RaycastResult> results = new List<RaycastResult>();
        physics2DRaycaster.Raycast(pointerEventData, results);

        foreach (RaycastResult result in results)
        {
            Debug.Log("UI Hit: " + result.gameObject.name);
        }
    }```
grand snow
#

no idea then, I know this should work though so something must either be in the way or the script is in the wrong place

rocky canyon
#

create new scene -> make bare-bones ass example

#

get it working in that scene.. then u have a nice comparison

fleet venture
#

but thats double the work

rocky canyon
#

not really.. if its Investment into getting ur OG working..

fleet venture
#

and i doubt i can get it to work in there but ill try

rocky canyon
#

it'd def make things simpler.. just use 1 image. 1 canvas 1 of everything

#

no clutter lol

fleet venture
#

where do i put that tho

#

in what script

rocky canyon
#

yall got this πŸ‘ coffee break β˜•

rich adder
#

any script, can even be a new one

#

just reference correct components by drag n drop

#

plop event system and 2d raycaster in there

fleet venture
#

a prefab doesnt work

#

πŸ’€

rich adder
#

well no.. put it on something in the scene why did you put it on a prefab

#

prefab should not reference scene components

fleet venture
#

i hate that you cant do that

rich adder
fleet venture
#

i dont in this case

rich adder
#

you only need 1 script to test the raycaster on

fleet venture
#

why is this ui

rich adder
#

there you go

rocky canyon
#

whoa where do u see that??

rich adder
#

armchair is hitting

rocky canyon
#

wtf ui is that

fleet venture
#

this is rider

#

i have the unity logs opened in rider

rocky canyon
#

ohh thats awesome that u get those logs in rider

fleet venture
#

i lack space in unity

rich adder
#

well UI is misleading comment but yes its hitting whatever that collider is

fleet venture
#

so then why is the event not firing

fleet venture
#

i can also have it like this

rich adder
fleet venture
#

ye

#

so the event system isnt

frigid sequoia
#

Can I not see the data stored in a Dictionary from the editor? Do I have to like convert it into 2 List or something?

rich adder
grand snow
#

yes dictionary cannot be serialized

fleet venture
#

oh

cosmic dagger
fleet venture
#

so then why does IBeginDragHandler not work

#

oh

#

omg

#

im so dum

rich adder
#

πŸ₯

fleet venture
#

let me test

#

ok that seems to be fixed

#

but now i cant drag it out of the UI again

#

its behind it tho

#

how do i fix that?

#

is it with sorting layers?

grand snow
#

the 2d physics stuff cannot be "over" the UI unless you use a canvas in world

rich adder
#

you should be able to use Screen Space camera then drag camera inside and figure out the correct number

fleet venture
#

so sorting layers or how do i do it

rich adder
#

i just told you how

#

if you scroll up twice you will see it

fleet venture
#

ye you just said to figure out the correct number

#

like number of what

rich adder
#

the plane distance

fleet venture
#

like the z transform?

grand snow
# rich adder it can

it shouldn't be possible with overlay canvases but the other modes i presume can

rich adder
grand snow
#

well yea that is what i thought

fleet venture
#

ok and where do i put screenspace

#

none of the values have it as an option

rich adder
#

go into Canvas, set it to ScreenSpace -Camera

fleet venture
#

i mean it also has a spriterenderer

#

ah the canva

rich adder
fleet venture
#

ah it was on overlay

#

well it renders it correctly so thats somethiing

#

ye that works

rich adder
#

nicee

fleet venture
#

so how do i set you dragging an object

#

like i create the prefab

#

but then i need to set the player grabbing it

rich adder
#

Instantiate returns copy of the object

fleet venture
#

so they dont have to click twice

rich adder
#

so you can do like
var myDraggable = Instantiate(etc. myDraggable.followMouse = true

fleet venture
#

oh but

#

i no longer have the variable

deft breach
# fleet venture like the z transform?

Bro i found the reason why the old OnMouseUp wasnt working:
you have to add this to the start of update:
if (Input.GetMouseButtonUp(0)) { OnMouseUp();}
I tried it myself and everything works perfectly but without the events:
if u want i can send u the old scripts again @fleet venture

rich adder
#

how is it following mouse?

fleet venture
#

i just have this now

#
public void OnDrag(PointerEventData eventData)
    {
        var mousePosition = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(mousePosition.x, mousePosition.y, 0);
    }```
#

sorry for the syntax

#

ther

rich adder
#

ahh.. on drag.

#

why ?

fleet venture
rich adder
#

I would switch it back to a bool

fleet venture
#

you sure?

rich adder
#

100%

fleet venture
#

this sounds like it was more meant to be used

rich adder
#

Moving in Update following is very common

#

especially if you dont want this double click weirdness

fleet venture
#

doesnt work with public void OnEndDrag(PointerEventData eventData)
{
_dragging = false;
Debug.Log("OnEndDrag");
}

rich adder
#

no

#
OnPointerDown => mouseFollow = true
OnPointerUp => mouseFollow = false

Update
if(mouseFollow)
myObj.position = mousePos```
fleet venture
#

or do i use the Ipointer now

rich adder
#

this way you can set mouseFollow from another script too

fleet venture
rich adder
fleet venture
#

no but this ondrag is with events

#

so do i use IPointer?

rich adder
#

also wrong

fleet venture
#

no this was the original code it did not work

rich adder
#

You should never be calling Monobehavior methods manually

#

OnMouseUp would be properly called when it releases from a collider

fleet venture
#

no its only called if you also have a mouse down for some reason

#

this is my original code

#

that did not work

rich adder
#

forget the original code

fleet venture
#

but your code is the same

rich adder
#

no its not

fleet venture
#

OnPointerDown

#

what is that

rich adder
#

that is from the Event System

#

not the MB class

fleet venture
#

AH

#

ok

#

thats what i was confused about

rocky canyon
#

are we getting anywhere guys?

rich adder
#

yes we're in step 2

rocky canyon
#

noice

fleet venture
#

i bet this wont work

rich adder
#

scrapp OnDrag for Uppate mouse follow so bool can be set on spawn, this way object spawns following mouse

rich adder
fleet venture
#

yep doesnt work

rocky canyon
#

i bet on nav

fleet venture
#

i release my mouse button

#

and it still drags

rich adder
#

mate before you yap away it doesnt work

fleet venture
#

untill i click again

rich adder
#

show what you wrote

fleet venture
#

ok

rich adder
fleet venture
rich adder
#

so then be patient and actually listen to the instructions correct , it will work

#

done this 100s of times..

fleet venture
#

okay sorry

#

youre right

rich adder
#

is it on the same object with OnDrag was ?

fleet venture
#

this works just not when dragging from ui

rich adder
deft breach
fleet venture
#

but nav said its bad

deft breach
#

ok then

rich adder
#

No i said Manually calling OnMouseDown is bad

rich adder
deft breach
#

i agree that was stupid

rich adder
#

is it just not releasing ? then yes you just need to set bool back to false obv..

rocky canyon
#

if im understanding u click an original object and then u spawn in a NEWER object..

fleet venture
#

ah okay

rocky canyon
#

that was never had ondown or w/e called

rich adder
#

yup

rocky canyon
#

so onup doesnt get called until u click down again

#

u might need to call ondown maually

#

on ur new object

rich adder
#

UI icon spawns the prefab thats supposed to follow

fleet venture
#

thats what happens

rocky canyon
#

so that onup will be called

fleet venture
rocky canyon
#
PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.position = Input.mousePosition;
newSpriteGameObject.GetComponent<YourDragHandler>().OnPointerDown(eventData);```
rich adder
#

you dont need those though cause you're already holding

rocky canyon
#

something like this to manually call the OnPointerDown or w/e

rocky canyon
rich adder
#

you grabbed the item your mouse should already be down..
all you need is the MouseUp event from the Input itself

rich adder
fleet venture
rich adder
#

thats why we switched away from OnDrag

fleet venture
#

i checked that with debug.log

rocky canyon
deft breach
rich adder
fleet venture
#

OnPointerUP i mean

rich adder
#

You dont need OnPointerUp..

rocky canyon
#

i remember doing something like this.. where another script takes over.. i had to pass the new object into the EventSystem

fleet venture
#

what

#

i do though

#

thats the event

rich adder
#

no you need the left mouse button released..

#

to restore the bool to false

fleet venture
rich adder
fleet venture
#

nope

#

if (Input.GetMouseButtonUp(0)) { _dragging = false;}
with this it works

deft breach
#

great

rich adder
fleet venture
rich adder
#

so it is working as In its following

#

bro ur confusing everything

#

just because one part doesnt work doesnt mean the whole thing aint working

fleet venture
rich adder
#

just say, Yes its working EXCEPT its not releasing

north walrus
#

are autoproperties like this

[field: SerializeField]
public int Age { get; set; }

the best approach for fields that could need custom get; set implementation?

rich adder
#

this way we know yes all you needed was flag to false

fleet venture
rich adder
#

"it doesnt work" implies the whole thing is not working

#

SO IT WWAS WORKING IT WAS JUST NOT RELEASING

fleet venture
#

well the dragging part has been working from the start

rich adder
#

jesus christ

fleet venture
rich adder
fleet venture
#

dont get mad at me

rich adder
#

after we switched to new code

#

I'm not mad mate lol

fleet venture
#

ok

deft breach
#

man if it works that fine so its done here right?

rich adder
#

im just telling you to be more specific next time

fleet venture
#

i will be

#

and yes it now fully works

deft breach
#

we can all be happy now

fleet venture
#

well

#

sort of

rocky canyon
#
    // used via button events
    public void UnfocusEventSystem()
    {
        SettingsMenuEventSystem.SetSelectedGameObject(null);
    }``` i was way off track.. i was thinking the event system was losing the reference.. or referencing the *last* object.. not the newer draggable one..
#

was gonna suggest feeding the new object into the event system as Last Selected

fleet venture
#

just one thing

rocky canyon
#

but u kno.. im not the brightest crayon in the box

rich adder
#

nahh the initial event was never initilized by OnBeginDrag

#

or any of that

rocky canyon
fleet venture
#

is there a way to get the pixels inside of the object where you clicked

rocky canyon
#

Phew..

fleet venture
#

like if i click entirely left of the boject i get 0

#

and if i click entirely right i get like 100

#

ye Because rn it always centers the object when you click on it

#

but i only need to move it by the delta

#

so i need that offset

red igloo
#

So in unity I am making a fps horror game. You can look around with the mouse and to move instead of moving by using your keyboard you move by clicking where you want to go so click to move. I have a issue where when I either repeatedly click at the max click distance or just click a bit close to me instead of the player going to the place where I last clicked the player will just keep moving until I stop clicking which I don't want.

Script (Sorry is the coding is garbage XD) : https://paste.ofcode.org/FP6zGBS2sFdPBnhqyLZrvX

https://streamable.com/3988zv

Watch "My project - SampleScene - Windows, Mac, Linux - Unity 2022.3.26f1 DX11 2025-02-07 16-44-51" on Streamable.

β–Ά Play video
rich adder
#

simple math

grand snow
#

you can get the offset from click pos to object pos and keep that offset when moving it

fleet venture
#

ye but how do i get the offset?

#

ye but how do i get the clickpos, thats what im asking

rich adder
#

you literally have it already

fleet venture
#

oh wait

#

same as in drag

#

ye

rich adder
#

ScreenToWorldPoint

rocky canyon
#

instead of constantly updating it..

#

when u release u'll be able to cache the next clicked position

fleet venture
#

ok got it working ty

copper prism
#

Good evening. Who has a normal code for moving the character right-left with a jump. I just can't get a normal result. The maximum that I could get is that the character jumps only on certain platforms and that's all
in a 2D platform

wintry quarry
copper prism
#

My problem is that the character jumps only on 3 blocks. The rest of them don't.

rich adder
#

whats "ODA platforms "

grizzled current
#

Guys, I dont know what is wrong with this code, But i'm pretty sure i've written this right, for it to dash, or ATLEAST move. It just modifies the X velocity of the Rigidbody, and It even modifies (or so it shows in the console) but the velocity doesnt change in the Inspector. It registers the input, but doesnt perform the dash. Pls Help TwT

copper prism
# rich adder show code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hero : MonoBehaviour
{
[SerializeField] private float speed = 3f; // ΡΠΊΠΎΡ€ΠΎΡΡ‚ΡŒ двиТСния
[SerializeField] private int lives = 5; // количСство ΠΆΠΈΠ·Π½Π΅ΠΉ
[SerializeField] private float jumpForce = 15f; // сила ΠΏΡ€Ρ‹ΠΆΠΊΠ°
[SerializeField] private LayerMask groundLayer; // слой зСмли

private bool isGrounded = false;
private bool canDoubleJump = false;
private Rigidbody2D rb;
private SpriteRenderer sprite;

private void Awake()
{
    rb = GetComponent<Rigidbody2D>();
    sprite = GetComponentInChildren<SpriteRenderer>();
}

private void FixedUpdate()
{
    CheckGround();
}

private void Update()
{
    if (Input.GetButton("Horizontal"))
        Run();

    if (Input.GetButtonDown("Jump"))
        Jump();
}

private void Run()
{
    float moveInput = Input.GetAxis("Horizontal");
    Vector3 dir = transform.right * moveInput;

    transform.position = Vector3.MoveTowards(transform.position, transform.position + dir, speed * Time.deltaTime);

    if (moveInput != 0)
        sprite.flipX = moveInput < 0.0f;
}

private void Jump()
{
    if (isGrounded)
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        canDoubleJump = true;
    }
    else if (canDoubleJump)
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        canDoubleJump = false;
    }
}

private void CheckGround()
{
    Collider2D collider = Physics2D.OverlapCircle(transform.position, 0.3f, groundLayer);
    if (collider != null)
    {
        isGrounded = true;
        canDoubleJump = false;
    }
    else
    {
        isGrounded = false;
    }
}

}

deft breach
grizzled current
cosmic dagger
eternal falconBOT
wintry quarry
deft breach
#

do you have some crazy friction on Physics Materials maybe?

grizzled current
grizzled current
frigid sequoia
#

Just straigh up setting velocity makes it interact very poorly with the rest of physics

wintry quarry
#

the problem is the main movement code is setting the velocity probably - but he didn't show it

deft breach
#

then its probably some other script yeah

grizzled current
#

I feel so stupid. You guys were right, The main "movement" func was called on every frame, which resets the velocity to zero. Thanks a lot tho, I feel relieved lol

rocky canyon
#

use debug logs more often then u even think u should

grizzled current
rich adder
cerulean badger
#

How do I put a method and/or a list of methods in the inspector just like this?

rich adder
#

what do you want to do exactly? whats the end goal here

cerulean badger
#

i have some methods for movement, like dash, jump, etc, and I wanted to change the Input Sequence from Attack Data to a list of methods that needs to be done to the attack to be triggered

cosmic dagger
cerulean badger
cosmic dagger
#

The SO is just a wrapper for your method(s) . . .

rich adder
simple vine
rich adder
#

so you have your DeshSO that you use when you dash

#

and compare it if its part of the attack data list of SOs

rich adder
simple vine
#

wydm

rich adder
#

what is this video supposed to tell us ?

#

there is two, great.

#

how's that help anyone help you ?

copper prism
rich adder
#

you should not be moving like this with a rigidbody

cerulean badger
copper prism
rich adder
copper prism
#

Ok. Thax

rich adder
simple vine
rich adder
simple vine
#

so how do i fix it

rich adder
cerulean badger
simple vine
#

do i need to change anything

rich adder
#

do you think this video tells use WHY its happening ?

simple vine
#

i just send a photo

rich adder
simple vine
#

how its all the info

#

the depth make it does it but i need it

rich adder
#

why didn you just say you were trying to do a camera stack..

#

jesus

simple vine
#

i never done a camera stack

rich adder
#

anyway just separate the layers and use culling

simple vine
#

how

rich adder
#

aren't you following a tutorial or something?

simple vine
#

what tutorial

rich adder
#

so you're just guessing your way ?

rich adder
#

make the list match the sequence you want

#

if both lists match then you're good, or you can check when it goes wrong while adding elements to list, then do whatever depending on behavior you want

cerulean badger
#

ok then, thx

rich adder
# simple vine how

Camera1. Remove WeaponLayer from it
Camera2. Remove all layers except WeaponLayer

sand snow
#

im trying to insantiate a UI text that says "achievement unlocked" when i reach a certain score, my problem is that when i instantiate the gameObject it doesnt show in my UI

#

i think its because im putting the postion in incorrectly, how do i make it show on the canvas and not the camera

shy axle
#

My input action looks like this. How can I detect specifically left being pressed down? Something like ```cs
input.actions["Move"].["WASD"].["Left"].started += ctx =>

rich adder
#

btw you should generate the c# class

#

using strings is ugly

shy axle
rich adder
#

lol ok

shy axle
rich adder
# shy axle how

go to the input action asset, in the inspector tick the Generate C# class checkbox

#

give it a name that isn't taken

#

then you can use actual type safety properties

#

Awake () myInputs = new()
OnEnable() myInputs.Enable()
OnDisable() myInputs.Disable()
myInputs.Player.Move etc..

sand snow
#

does anyone know how to instantiate a UI element onto the canvas and not the camera

rich adder
#

so private MyInputs myInputs

#

obv make a better name but dont take ones unity made already like PlayerInput

shy axle
#

lmfao wrong pic πŸ˜‚

rich adder
#

thats a garbage name for example

shy axle
#

yeah

#

is there a way to change it

rich adder
#

I had weird luck changing it

#

make the changes and hit apply and hopefully it works

#

otherwise try re-generate after you delete the old class

#

the class shouldn't be touched after, since each time an action map save is made it updates it

void dawn
#

Hey dumb question but I have some low poly textures I wanna use but they all look blurry , anyway I can fix that ?

lament harness
#

nav its just settings like toggle fullscreen and quality

rich adder
#

so just for the ingame?

lament harness
#

yea

rich adder
#

or permanent between sessions

lament harness
#

perma

#

between sessions

rich adder
#

PlayerPrefs should be acceptable

lament harness
#

yea im trying to use them but idk how to for toggles

rich adder
shy axle
rich adder
#

then use ternary

shy axle
#

maybe movementInput

#

when do people mostly use camel case?

rich adder
#

well action asset can contain multiple action maps

#

You can do MyPlayerInputs or something

#

idk

rich adder
lament harness
rich adder
#

you can also group them together with a struct then json string it

#

that will take care of not having to do each setting seperate

lament harness
#

public void SetFullscreen(bool isFullscreen)
{
Screen.fullScreen = isFullscreen;
PlayerPrefs.SetInt("fullscreen", isFullscreen ? 1 : 0);
PlayerPrefs.Save();

i have this

#

right now

#

how do i like

rich adder
lament harness
#

make it save between sessiosn

rich adder
#

just load the value back

#

put it where you need it

lament harness
#

because its always toggled

#

when i go to settings

rich adder
#

this is probably also the worst thing to test in the editor btw lol

#

since you can't really fullscreen it

rich adder
#

otherwise you have to test something else that works in editor

#

quality setting might work I suppose

lament harness
#

how do i do it

#

with quality

rich adder
#

isn't it QualitySettings.SetQualityLevel ?

solid jay
#

Hey
I want to create a free cam. The problem is that it Clamps the x rotation to 90 and - 90 and I dont know why, since it doesnt do this for the y rotation but its the same Code

Code:
https://pastebin.com/HkJ8u1HH

rich adder
#

this look cursed transform.localEulerAngles +=

solid jay
#

well I first did it with tranform.rotate but that didnt work at all

rich adder
#

You should manually touch the eulerAngles

#

Rotate wants specific amount to rotate by

#

you can aslo just transform.rotation = quaternion.euler

#

either way you should clamp sepearate floats then pass those

swift crag
#

Yes, it's easiest to just store the yaw and pitch values in fields

#

and to then set the rotation based on those

solid jay
#

I dont want to clamp them, they the x-axis is but I dont want that

rich adder
#

oh so you don't want clamp

solid jay
#

yes but it does it on the x-axis

rich adder
#

then just rotate without clamp just dont manually touch the euler angles cause you're experiencing gimbal lock
the angles are really meant to stay between -180 / 180
the inspector is just...a special case..where its done internally

shrewd gazelle
#

Hey guys this might be a bit iof a confusing question but Ill try to make it as clear as possible so I made a public bool called isclimbing in my player script and then inside the ladder script I refrenced the player and then accesed the bool by doing _player.isclimbing and then now I added a box collider to the ladder and added a script to it and trying to aceesss the bool I tried doing the same thing that I did in the ladder script but it didnt work so i assumed you can only refrecne from another script one in a prefap so Im trying to acess the isclimbing bool to the cube game object script that I added to the ladder prefap you guys know what I should do and if any clarification you guys ant let me know becuase I am going crazy on this I dont want the day to end without me finishing this😭

frosty hound
#

First of all use punctuation, that's barely readable.

#

Secondly, to get the bool off an object, you need a reference to that object. If your box has a collider on it, you can have it do it's own OnCollisionEnter check for the player and react accordingly.

#

But really, your ladder should not be the one deciding on logic, it should be told what to do. The player should be the one determining if it's in range to use a ladder or not, and if the player interacts with it, then the player should tell the ladder it's being used (and thus, it can react accordingly).

shrewd gazelle
# frosty hound But really, your ladder should not be the one deciding on logic, it should be to...

So all the logic is inside player the only thing in the ladder happening is if the player press e the bool turns on and then the player handles everything . And then whe you said you need a reference is it possible to get a reference on the box collider again because for some reason it worked on the ladder script but in the box colider script it wouldnt work I assumed you can only reference from a script one time per game object in prefab but Im a beginner so I was just guessing

#

Oh mb no ping forgot

frosty hound
#

What's the purpose of the box collider?

#

And no, any number of objects can reference the same object

rich adder
shrewd gazelle
#

So when the player climbes and the box collider come up from the ground and wait for the player to go down if the player goes down and hits it with their leg the box collider will make the player let go of the ladder and the box will hide again

rich adder
#

just identify that you entered a Ladder trigger

shrewd gazelle
#

If it dosnet make sense Ill try to reexplain

rich adder
#

which box collider are you referring to?

#

the box collider come up from the ground

shrewd gazelle
#

Its attached to the ladder so when the player starts the invicible box collider is hiding under the ground the player starts climbing it goes up a little bit waiting for the player to go down if the player goes down and hits it its make the player let go and the collider goes under the ground again

#

Its attached to the ladder prefab

rich adder
shrewd gazelle
#

yes

rich adder
#

are you putting one for the top too ?

shrewd gazelle
#

Yah thats something ill work on later

rich adder
#

and I guess you can only go up and down, not side to side?

shrewd gazelle
#

this is the ladder

rich adder
#

delete this one, send it as link from site in ⬇️

eternal falconBOT
solid jay
shrewd gazelle
#

Nav excuse me I gotta do something now do you mind if I comeback in like an hour will you be here

rich adder
#

by showing code + screenshots too b

rich adder
#

t.rotation = Quaternion.Euler still uses eulers but you can set specific angles to object

#

if you dont want that but just continuous rotation then use rotate

tulip stag
#

So, I turned one of my interfaces into a monobehaviour; and I need to go back and edit every single one of the many, MANY inherits to remove every variable that's being implicitly inherited. I'm just wondering, is there a quick and easy way of doing so? Sooooo many scripts 😭

rocky canyon
#

navigate thru them via the IDE

rich adder
cosmic dagger
rocky canyon
#

u can right-click and rename to mass-edit

#

not sure it'll work in ur case but helpful to kno

tulip stag
cold elbow
#

i have an object colliding with another object but when I try to detect their collision it doesn't, what could be the problem

rich adder
tulip stag
#

This is me reaping what I've sown (not reading the documentation before going ah! that's it! this should be an interface!)

twin bolt
#

I have this code here which is meant to check if the door is closed or open. Issue is, the ClosedROT = -90, but angle difference is at 120, so it doesnt think the door is closed even though it is. ``` Quaternion closedRotation = Quaternion.Euler(0, ClosedROT, 0);

    angleDifference = Quaternion.Angle(transform.rotation, closedRotation);

    if (angleDifference <= 2f || angleDifference >= 358f)
    {
        if(open)
        {
            GetComponent<Rigidbody>().isKinematic = true;
            ClosingSound.Play();
            open = false;
        }
    }
    else
    {
        if (!open && !Controller.GetComponent<DragDoor>().isDragging)
        {
            GetComponent<Rigidbody>().isKinematic = false;
            OpeningSound.Play();
            open = true;
        }
    }```
tulip stag
robust otter
#

guys do you maybe know why the guy is teleporting and running away from the ball i have ai navigation.

#

its like the animation keeps replaying and he runs away

rich adder
#

dont know if there is a bulk way to remove that from different files

rocky canyon
cerulean badger
#

I've seen people make customized groupings like what we see here in Advanced Settings inside their scripts, organizing several variables and stuff. I want to know how do I do this, becuz I cant find it on internet

rich adder
tulip stag
#

Omg. Figured out a good way.

rocky canyon
#

OnTrigger is similar:

The Three Commandments of OnTriggerEnter:
Thou Shalt have a Collider on each object
Thou Shalt tick isTrigger on atleast one of them
Thou Shalt be moving via a Rigidbody on at least one of them

tulip stag
#

In case anyone else finds themselves in the same predicament as I:
If your interface is similar enough, Ctrl F ~> Replace (in entire solution) is a pretty decent quick fix. Just make sure you have a back up of your parent script because it's gonna delete it on your parent script too

robust otter
rocky canyon
#

thank Digiholic.. they're his 3 Commandments.. posts them everywhere he goes 😈

solid jay
rich adder
#

two components fighting for control over transform

#

never a good mix

robust otter
#

Ok

robust otter
#

Thanks

rich adder
#

dont use pastebin

#

!code

eternal falconBOT
rocky canyon
#
  • Base Object (main movement (code or something on this object)
    • Graphics (graphical object.. animations and stuff should target this object and animate locally)
#

that way u can move the base object w/o screwing up the animation on the graphics

#

and vice-versa

rich adder
#

ohgod

#

why are you doing thistransform.rotation.x inside a euler

#

rotation returns a quaternion

#

quaternion values clamp at 1

#

don't use quaternion vals

solid jay
#

then can you please tell me how i should do it

rich adder
#

something like

  currentYRotation += mouseX * rotationSpeed * Time.deltaTime;
transform.rotation = Quaternion.Euler(0, currentYRotation, 0);```
etc
rocky canyon
#
    void HandleRotation()
    {
        float turnInput = Input.GetAxisRaw("Horizontal");
        float rotationAmount = turnInput * TurnSpeed * Time.fixedDeltaTime;
        Quaternion turnRotation = Quaternion.Euler(0,rotationAmount,0);
        transform.rotation = transform.rotation * turnRotation;
    }```etc
#

rb.AddTorque(rotationThrust * Time.deltaTime,ForceMode2D.Force);

hasty dragon
#

i tried making a character with the character controller component, i added gravity and the character does fall, but the collision doesnt touch the ground

rich adder
#

* Time.deltaTime in AddForce/Torque ?

rocky canyon
rocky canyon
#

its the skin of the collider

rich adder
#

ur just seeing the skin

hasty dragon
#

ohhhh so thats what skin is

rocky canyon
hasty dragon
#

yeah i saw it, why is it so high by default?

rich adder
#

yes you want to keep it fairly decent so you don't clip into stuff

rocky canyon
rocky canyon
#

as a first person char u cant tell..

#

it helps w/ things

rich adder
#

it helps smooth out collision with different heights

hasty dragon
#

im making a third person game, the map is in a building

rocky canyon
#

.08 is a pretty fair value

hasty dragon
#

so it doesnt matter i think

rocky canyon
#

u can probably go to .25 if u want

rich adder
rocky canyon
#

.025*

rich adder
#

you can shift the mesh child however offset you want from the ground

#

plus use things like IK for feet to make illusion of touching ground completely

rocky canyon
#

u could easily change it to fixed.. or just omit all together if it was in fixedUpdate like it should be

#

i dont have many rb's laying around lol i will fix that right now tho so more copypasta later on isnt so brackeys

rich adder
#

i just know that addforce already accounts for Time.fixedDeltaTime no ?

#

or maybe I misread

rocky canyon
#

i done it right elsewhere. lol

#

🀦

rocky canyon
rich adder
#

ohh okay

rocky canyon
#

even the deltaTime accounts for it

#

if its in the fixedupdate loop

#

some c# guru learned me that not too long ago

rocky canyon
hasty dragon
#

do i need to reinstall cinemachine to every new project?

rocky canyon
#

which does rely on time.deltaTime

#

goood catch

rocky canyon
rocky canyon
lost haven
#

Hey guys! I'm new in game deving stuff so i need your help. I'm using unity and now im stuck. I have a code, that spawns prefab on "CounterTopPoint" . The code itself works but the visual seems to be offset and doesnt appear on the "CounterTopPoint". Can you please share how to fix that?

rocky canyon
#

show the instantiation code

lost haven
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ClearCounter : MonoBehaviour {

[SerializeField] private Transform tomatoPrefab;
[SerializeField] private Transform CounterTopPoint;

public void Interact() {
    Debug.Log("Interact!");
    Transform tomatoTransform = Instantiate(tomatoPrefab,CounterTopPoint);
}

}

rocky canyon
#

make sure ur prefab doesn't have an offset from any of the child objects

#

if they have any

#

` not '

robust otter
rocky canyon
#

root motion probs

robust otter
#

nah i had it off

#

it was just the animations fault

rocky canyon
#

lol.. poor animator

robust otter
#

😊

rocky canyon
#

but if its not in place its root motion.

#

the animator was in charge of moving the transform.. which some ppl like..

#

i doo not

robust otter
lost haven
twin bolt
#

Whats the best way to check if a objects rotation equals a float?

rocky canyon
#

simple == would result in an approximation..

rocky canyon
#

.x etc

twin bolt
rocky canyon
#

float valueToCompare = transform.rotation.eulerAngles.y;

#

or transform.localRotation.eulerAngles.y;

twin bolt
rocky canyon
#

then compare that

#

reading them is fine.. even manipulating them is fine too if u know what ur doing..

#

if ur intending on comparing to a float.. ur observing its EulerAngles anyway

twin bolt
#

okay thanks

coral cape
#

I have a empty gameobject with a script on it that should be spawning objects all around my canvas, it does spawn copys as I see them in the heirarchy but I cant seem to ever see them in game, I've messed with layers, ordering of the heirarchy, and what object I attach my script too to no avail. Some of that might make no sense I'm sorry lol, I'm new and confused

rocky canyon
rocky canyon
#

you'll see where it is.

#

we need more info as well.. the prefab ur spawning what is it? UI component?
the code that spawns it.. what values are they using?

marble turret
#

Is there a way to require a serialized/exposed field in the inspector to accept instances of scriptable objects that implement a certain interface?

rocky canyon
#

do the values in the objects transform/rect transform match what u expect.. or logged..

rocky canyon
#

ive had to expose a gameobject instead

coral cape
#

Ive found them ouside the canvas earlier, but I've dialed them into be within the screen, still just no visibility
The UI component question confuses me, I dragged the image from my project files into my heirarchy.
And this is the code:

#

Thank you for ur help!

rocky canyon
#

as the transforms are not the same.. as for example a 2d sprite.. (which basically operates within worldspace)

cosmic dagger
rocky canyon
#
RectTransform newUIElement = Instantiate(yourUIElementPrefab).GetComponent<RectTransform>();
newUIElement.anchoredPosition = newPosition;
#

i wonder what that would do @coral cape ^

#
        Vector2 newPosition = new Vector2(
            Random.Range(-canvasRectTransform.rect.width / 2, canvasRectTransform.rect.width / 2), 
            Random.Range(-canvasRectTransform.rect.height / 2, canvasRectTransform.rect.height / 2)
        );``` would spawn them across the entire canvas if its scaling correctly
hasty dragon
#

where is the or thingy on the keyboard

#

im on qwerty

rocky canyon
#

usually above the tab button

#

` ~

#

just copypasta it if u cant find it

rocky canyon
hasty dragon
#

`~

#

i nede the II thingy

rocky canyon
#

the || thing

#

is above the enter usually \ backspace

#

with the Shift modifier

rocky canyon
marble turret
coral cape
#

I'm afraid I'm confused lol, I really am trying, I just dont understand where I would put that in my code?
This is it when running, it shows 5 clones on the left side as it should spawn 5

I've been messing with what you sent and getting errors with "-canvasRectTransform", am I supposed to be "using" a lib at the start? I only have "using UnityEngine;" rn

rocky canyon
#

what about POCO Interfaces?

twin bolt
wintry quarry
#

Also any UI element would need to be Instantiated as a child of a Canvas to actually show up

rocky canyon
#

right now ur spawning them (outside) the canvas... which would be world space..

#

for example my little icon here is UI / under a canvas.. it has a Z position of 0

#

which is clearly different.. than what a 0 position (in the world is typically) which is center of the world

#

these are using rectTransformComponent.anchorPosition = as well.. and not transform.position =

#

firstly you'll want to instantiate them as children of a canvas (if they are UI components.. which ur Orb that u have selected in ur screenshot is) i think since its under the canvas

rocky canyon
# coral cape I'm afraid I'm confused lol, I really am trying, I just dont understand where I ...
public class DONTCOPYME: MonoBehaviour
{
    public GameObject uiPrefab; // Your ORB
    public RectTransform canvasRectTransform; // The RectTransform of the Canvas

    void Start()
    {
        // Instantiate the UI element as a child of the Canvas
        GameObject SpawnedUIELEMENT = Instantiate(uiPrefab, canvasRectTransform);
        Vector2 randomPosition = new Vector2(Random.Range(-400, 100), Random.Range(-400, 100));
        SpawnedUIELEMENT.GetComponent<RectTransform>().anchoredPosition = randomPosition;
    }
}```
#

also im a bit confused.. b/c it seems u got a little bity world down there in the corner. is this spawning stuff game-play? game-play should usually be done in world space.. if u r dealing w/ canvas it should be for display/ui stuff only

#

evil orb has me thinking a bit..

willow breach
#

Hey, Im trying to use DOTween for the first time but it's not working...
I have a 2d square prefab with this
transform.DOMoveX(100, 1);
a log is being printed before so i know it's getting there but nothing happnes.. no error either
am i missing something? in the tutorials it doesnt seem like there is a step up and on their doc it seem ineed to do DOTween.Init(); but there is not .Init() in using DG.Tweening
πŸ™

twin bolt
#

Why isnt this working? Tolerance = 2 ``` Quaternion currentRotation = transform.rotation;

    // Preserve the current X and Z rotation, but set Y to ClosedRot
    Quaternion targetRotation = Quaternion.Euler(currentRotation.x, ClosedROT, currentRotation.z);

    // Get the shortest difference between current and target rotation
    float angleDifference = Quaternion.Angle(currentRotation, targetRotation);

    // Check if within tolerance
    if (angleDifference <= tolerance)```
coral cape
#

That all makes sense, i think lol, I def have a lot to look into, and yeah the evil orb is gameplay, I was confused what I was even doing when I went to scene and saw everything crunched in the corner lol. Just confused between things that seem the same but are clearly different in reference, will put a photo on the screen in any way I can then get confused how to manipulate it when I probably didn't add it right.

#

So to see if I understand correctly, I should have interactable gameplay objects like enemies outside of my canvas? the canvas should be specifically for overlays like UI and displays

rocky canyon
# coral cape That all makes sense, i think lol, I def have a lot to look into, and yeah the e...

ya it can be overwhelming to beginners..

  • screen space ( like where the cursor resides (mousePosition) is based on ur screensize and resolution )
    • for example going from 0 - 100 could be the full screen (sometimes u dont know)
  • UI RectTransform stuff ( usually operate like a normalized value.. .5 x .5 is dead center.. top left is 0,1 bottom right is 1,0 etc )
    • this is true b/c of scaling b/c usually your canvas will scale.. some of the values above may be a bit wrong b/c i cant remember the order the screenspace goes in) the anchorPosition is based off of the element its a child of..
  • Then world-space is split into local/global but its the game stuff.. (like where u create a cube.. its dead center of all the axis)
rocky canyon
#

if its ortho or something u can find a good bounds to follow.. w/ the camera gizmo especially

#

the only thing UI related is the fuel stuff..

#

i just took some time to layout everything and get some good X and Y values i can use for the main gameplay stuff

rocky canyon
#

i ask everyone if their first time using dotween just b/c u never know

coral cape
#

Thank you so much for all your help!

willow breach
rocky canyon
#

mmhmm

#

where u selected which modules to install

willow breach
#

it seleced all without asking me

#

ill try to reimport

rocky canyon
#

just wanted to make sure u installed the Sprites package

#

or physics2D if its a rigidbody.. but ur using transform.. so probably not

willow breach
#

i created new scene with one 2d square with this script
void Start() { transform.DOMoveX(100, 10); }
but nothing happens

#

ok i went to preferences and reset it and now it worksπŸ˜…

shrewd gazelle
#

Hey Nav just wanna make sure your here just to not explain my problem again

shrewd gazelle
#

ok Ill explain my problem hey guys so I made a script called a ladder and put a refeence on it to access variables from another script which is for the player and got a varibale called isclimbing by doing _player.isclimbing now i added a cube gameobject to the ladder prefap and attached a script to it and trying to acess the isclimbig variable again just like how I used it in the ladder script I tried to get a refrence from the playercontroller script but it didnt work so wanted to ask for your guyses suggestions

#

if there any confusion please let me know and I will explain again

rocky canyon
#

does that script reference the player? _player ??

wintry quarry
#

Show us exactly what you tried and what happened when you tried and how that differed from your expectations

shrewd gazelle
#

so my goal is to get a reference to the bool in the player script i did this in the ladder scriptprivate FirstPersonController _player; _player = other.GetComponent<FirstPersonController>();_player._isclimbing = true; and I succeded in getting the varibale from the ladder script now I tried to get the bool to the cube I added to the ladder prefab which has a different script one sec let me get it

wintry quarry
unique spear
#

i dont know if it would work but did u determine the bool as public?

wintry quarry
#

!code

eternal falconBOT
shrewd gazelle
#

yes I did DMS

#

let me try the thing Preator gave me

#

one sec

polar acorn
shrewd gazelle
wintry quarry
#

Yes now can you explain what's going wrong with this code?

shrewd gazelle
#

so the other script I believe I called cube thing in link you gave me i cant acess the _isclimbing variable

slender nymph
wintry quarry
#

you need to share the code that's not working

shrewd gazelle
#

it is in there

wintry quarry
#

and explain what errors you get

shrewd gazelle
#

arent there two tabs

wintry quarry
#

can you explain what's wrong with it

#

Are you getting an error?

shrewd gazelle
#

It wont let me acess the variable it keeps telling me that the first person controller is unrecognizable

wintry quarry
#

this is too vague

shrewd gazelle
wintry quarry
#

The actual precise error message is important.

shrewd gazelle
wintry quarry
#

see what it says?
"Are you missing a using directive"?

#

Notice in your other file you have this:

using StarterAssets; //  to access FirstPersonController
#

that's called a "using directive"

#

since that other class is in a namespace, you need this to use that class here.

#

Also - your IDE should be automatically suggesting to fix this error for you

#

If it's not doing that, you haven't configured it properly

shrewd gazelle
#

I couldve sworn that i did that Just put it in now its telling me this now

sand snow
#

hey does anyone know why when i instantiate a UI text its not showing on my screen, i checked the postion and everything is fine, but for some reason the text is just invisible and im not sure why

polar acorn
shrewd gazelle
sand snow
#

well

#

no

#

because i turned it into a prefab and deleted it from hierarchy

polar acorn
polar acorn
sand snow
#

so how do i do that

polar acorn
shrewd gazelle
sand snow
polar acorn
simple vine
#

this isnt working and idk what button it is

slender nymph
eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

unique spear
polar acorn
shrewd gazelle
#

ohhhhhhhhhhhhhhhhh

simple vine
polar acorn
rocky canyon
#

start be like who tf is "other"

shrewd gazelle
#

this reminded me of blue prints from unreal

unique spear
polar acorn
slender nymph
#

or maybe look up some tips on how to ask questions

simple vine
polar acorn
simple vine
polar acorn
simple vine
#

idk

#

there was no button

polar acorn
simple vine
#

idk

unique spear
#

@shrewd gazelle did it work?

simple vine
#

but what button should i do or do i send the script to see

polar acorn
# simple vine idk

So, figure out what you actually want to do and what is happening then try again later

shrewd gazelle
#

working on it

simple vine
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class pause : MonoBehaviour
{
public GameObject pausemenu;
public string sceneName;
public bool toggle;
public SC_FPSController playerScript;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        toggle = !toggle;
        if(toggle == false)
        {
            pausemenu.SetActive(false);
            AudioListener.pause = false;
            Time.timeScale = 1;
            playerScript.enabled = true;
            Cursor.visible = false;
            Cursor.lockState = CursorLockMode.Locked;
        }
        if (toggle == true)
        {
            pausemenu.SetActive(true);
            AudioListener.pause = true;
            Time.timeScale = 0;
            playerScript.enabled = false;
            Cursor.visible = true;
            Cursor.lockState = CursorLockMode.None;
        }
    }
}
public void resumeGame()
{
    toggle = false;
    pausemenu.SetActive(false);
    AudioListener.pause = false;
    Time.timeScale = 1;
    playerScript.enabled = true;
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
}
public void quitToMenu()
{
    Time.timeScale = 1;
    AudioListener.pause = false;
    SceneManager.LoadScene(sceneName);
}
public void quitToDesktop()
{
    Time.timeScale = 1;
    AudioListener.pause = false;
    Debug.Log("the game will quit");
    Application.Quit();
}

}

#

thats the script

slender nymph
#

!code

eternal falconBOT
simple vine
#

is there anything for button

simple vine
slender nymph
#

but do you know how to read?

simple vine
#

yea unless i cant spell that word

slender nymph
#

because if you do, you would see that was not instructions to learn how to code. it was instructions for how to correctly share your code

simple vine
#

i understand cide and learn

#

code not cide

slender nymph
#

but apparently you don't understand the words that are being said to you

simple vine
#

sure then

sand snow
polar acorn
sand snow
#

inside of the ()?

#

im sorry im pretty new to this so some of the termonology is a little confusing still

simple vine
#

FIXED

shrewd gazelle
shrewd gazelle
slender nymph
#

alright well then i'm not helping you any further. i do not help people who refuse to actually bother learning the basics

shrewd gazelle
#

dude I watched an entire udemy tutorial

#

Ill show yo if you want they dont go into specifics

#

this something that you learn in a project

slender nymph
#

and yet you're still just blindly guessing at how the code works

polar acorn
unique spear
#

public GameObject player;
firstpersoncontroler _player;
in start method
_player = player.getcomponent<firstpersoncontroler>();

if not working maybe try
_player = getcomponentinchild
or
_player = getcomponentinparent

shrewd gazelle
slender nymph
polar acorn
eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

long jacinth
#

If I want to get something in a list by index how do I do it

slender nymph
#

just use the indexer on the list? just like you would an array because that's basically all a list is

long jacinth
unique spear
#

Tell me it it works

slender nymph
#

they don't need the player gameobject variable at all because it is entirely unnecessary

#

if they can drag in the gameobject anyway then they can just use the correct type of variable and not bother with getcomponent

untold perch
sand snow
untold perch
#

Unfortunately, I have not found anything about this. You can also add friends if the PlayerID does not exist.

slender nymph
shrewd gazelle
#

justr wanted to share that with you becuase you helped alot

unique spear
#

Thanks

shrewd gazelle
#

And the info about the other. Component was an eye opener not gonna lie @slender nymph

#

Wow this feels so good after a day and half a day and half of trying to get this πŸ˜‚

faint osprey
#
   {
       change.x *= m_Data.YawSensitivity;
       change.y *= m_Data.PitchSensitivity;

       Vector3 euler = m_SpringArmKnuckle.eulerAngles;
       float yaw = euler.y;
       float pitch = euler.x.Remap360To180PN();

       pitch = Mathf.Clamp(pitch - change.y, m_Data.MinPitch, m_Data.MaxPitch);

       Quaternion yawRotation = Quaternion.Euler(0, yaw + change.x, 0); 
       Quaternion pitchRotation = Quaternion.Euler(pitch, 0, 0); 

       m_SpringArmKnuckle.rotation = yawRotation * pitchRotation;
   }```

for some reason my spring arm is only rotating the yaw and not the pitch and i dont know why
rancid tinsel
#

I'm assuming the answer is yes, but can you can call OnDestroy() when just destroying a script component, not the whole object right?

#

idk why you wouldn't be able to but OnDestroy often makes me scratch my head as it is

rich adder
verbal dome
rancid tinsel
#

I only found out today that you can destroy a class

verbal dome
#

You don't "call" OnDestroy, unity calls it automatically

rich adder
rancid tinsel
rich adder
rancid tinsel
#

what is the actual difference between the two

#

or is it just right terms but essentially the same

rich adder
timber tide
#

component is just fancy word for object attached to a gameobject

faint osprey
#
    {
        change.x *= m_Data.YawSensitivity;
        change.y *= m_Data.PitchSensitivity;

        Vector3 euler = m_SpringArmKnuckle.eulerAngles;

        float yaw = euler.y + change.x;
        float pitch = euler.x.Remap360To180PN() - change.y;

        pitch = Mathf.Clamp(pitch, m_Data.MinPitch, m_Data.MaxPitch);

        Quaternion yawRotation = Quaternion.Euler(0, yaw, 0);
        Quaternion pitchRotation = Quaternion.Euler(pitch, 0, 0);

        m_SpringArmKnuckle.rotation = yawRotation * pitchRotation;
    }```

does anyone know why its rotating the yaw but not the pitch
rich adder
#

You wouldn't be able to call Destroy() on a Poco for example

#

needs to be UnityEngine.Object (component though specifically or gameobject)

verbal dome
#

Then find out why it is probably the wrong value

rancid tinsel
#

i see, thank you

verbal dome
#

@faint osprey It's usually better to keep track of your angles in separate floats instead of reading from euler angles

faint osprey
verbal dome
#

I meant pitch, not pitchRotation

#

I can't read quaternions

faint osprey
#

oh right

#

just stuck at 98

#

89b sorry

timber tide
#
Quaternion yawRotation = Quaternion.AngleAxis(yaw, Vector3.up);
Quaternion pitchRotation = Quaternion.AngleAxis(pitch, Vector3.right);```
can get rid of euler there and just use AngleAxis
faint osprey
#

ill try that

verbal dome
#

That won't fix it

timber tide
#

was just a suggestion, not a fix

faint osprey
#

its like the clamp is just keeping it at 89

#

and not letting it go lower

swift crag
#

have you verified that your angles are in the range you think they are?

#

e.g. by logging the yaw and pitch values

faint osprey
#

idk what the range is tho

#

cause the min max values are in 0-360 and the pitch is -180 to 180

tiny wind
#

how do I write an IF statement to check if the current scene is a certain int

sacred cradle
#

hello, how do i make public lists like this? Kinda where you can have your own public variables INSIDE of the list items.

#

i couldnt find an image where there was dropdowns for each item but i hope i explained what i mean well

zenith cypress
#

If you have a list of a class, you'll get a foldout for them. If it is something like an asset, you won't without third-party editor extensions.

sacred cradle
#

alr

#

how do i add a class to a list

#

tbh, i dont even really understand classes

#

thanks

stark burrow
#

Should I use animating colliders or multiple raycasts if I want to make melee swing?

sacred cradle
dapper mirage
#

Hey everyone this might be a silly question but I am trying to use a canvas for the UI of my game but it is leaving a huge line in the middle of it. Why is this happening?

supple sand
#

That’s showing you the rectangle of the canvas.. ie the screen

simple vine
#

how do i fix this

rancid tinsel
#

just made a new project and a new script and Visual Studio is no longer showing errors or anything - they only show up in the Unity console

#

any idea what might have happened?

#

I tried restarting VS a few times

#

but that didn't help

trail heart
simple vine
#

its not killing or movin

#

the monster isnt moving

#

or killing the player

eternal falconBOT
rancid tinsel
#

its been configured for over a year and now suddenly isnt

#

its also configured on the project i was just working on before this one

teal viper
strong wren
trail heart
simple vine
#

i try it dont work

rancid tinsel
trail heart
simple vine
#

what

teal viper
# simple vine what

You provided literally 0 info on your project, the issue and what you have tried so far. We can't help you without it.

simple vine
#

do i send someone the project then to help fix it

teal viper
#

No. Provide a proper explanation and relevant code. We still don't even know what the issue is. And know nothing about the context of the issue

simple vine
#

so i added the code for walking and moving but it dont work and i dont know what to do

trail heart
teal viper
simple vine
trail heart
#

Use the code formatting to post it this time

teal viper
eternal falconBOT
simple vine
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class Obunga : MonoBehaviour
{
public NavMeshAgent ai;
public Transform player;
Vector3 dest;

void Update()
{
    dest = player.position;
    ai.destination = dest;
}

}

#

why did it send

simple vine
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class obungaJumpscare : MonoBehaviour
{
public Animator obungaAnim;
public GameObject player;
public float JumpscareTime;
public string sceneName;

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        player.SetActive(false);
        obungaAnim.SetTrigger("Jumpscare");
        StartCoroutine(Jumpscare());
    }
}
IEnumerator Jumpscare()
{
    yield return new WaitForSeconds(JumpscareTime);
    SceneManager.LoadScene(sceneName);
}

}

#

jumpscare

teal viper
#

Stop

simple vine
#

why

teal viper
#

Read

#

You were told to share !code correctly several times.

eternal falconBOT
simple vine
#

what do i do with that

teal viper
simple vine
#

there 5 links

#

which one