#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 269 of 1

rocky canyon
#

ahh, you already sniped the problem tho

#

from now on, thats what that error means.. it means ur trying to access something that isn't there

crisp sand
#

I have a cube that has InteractableObject

polar acorn
rocky canyon
#

(ScriptName.cs, LineNumber)

polar acorn
#

Find out which thing is null

crisp sand
#

i just checked

rich adder
#

a prefab uh oh

polar acorn
crisp sand
#

omw

rocky canyon
#

run ur checks thru code.. b/c visibily u may not see the issue. the code will str8 up tell you

crisp sand
ivory bobcat
polar acorn
rocky canyon
#

selectionTransform.GetComponent<InteractableObject>();

ivory bobcat
#

It'll either return blank (null) or the component

polar acorn
#

Log that after you log selectionTransform

crisp sand
#

both interaction_text and interactableObject are null but it may be because i wrote the log in the wrong part of the code

polar acorn
crisp sand
#

okay

rocky canyon
#

        Debug.Log($"Interaction Text:  {interaction_text}");
        Debug.Log($"Selection Transform:  {selectionTransform}");

        var interactableObject = selectionTransform.GetComponent<InteractableObject>();
        var itemName = interactableObject.GetItemName();

        Debug.Log($"Interactable Object:  {interactableObject}");
        Debug.Log($"Interactable Name: {itemName}");```
crisp sand
#

the only thing null is interaction text

rocky canyon
#

well assign ur text object ๐Ÿ˜‰

polar acorn
crisp sand
rocky canyon
#

it isn't getting assigned

#

this line of code doesn't assign it properly

crisp sand
#

maybe because its textmeshpro instead of text?

rocky canyon
#

๐Ÿ’ฏ

final kestrel
#

Hey all! Say I have an abstract class with a virtual method in it. Can I still override it from outside without inheriting it?

rich adder
rocky canyon
#
using TMPro;
public class Footastic: MonoBehaviour
{
    private TMP_Text interaction_text;```
polar acorn
final kestrel
#

Well yes I didnt think about it

#

Thanks

rich adder
#

interface is like abstract but more modular

rocky canyon
marble night
#

WHY DOES ANY UNITY METHODS like awake, update MAY STOP WORKING ON ALL UNITY EDITOR VERSIONS?

crisp sand
#

kinda sus if you ask me

rocky canyon
#

lol

marble night
final kestrel
rich adder
summer stump
polar acorn
final kestrel
rocky canyon
#

w/o caps this time.. we already know ur angry

marble night
#

xd

rich adder
ivory bobcat
final kestrel
#

and where should I look for resetting my mouse position in the middle of the screen in a first person game? I cannot find anything on the internet

crisp sand
#

i think im making the reference right but it still says that it is null

rich adder
ivory bobcat
polar acorn
ivory bobcat
#

Get component doesn't promise anything

rich adder
ivory bobcat
#

Assuming the info ui isn't null first

final kestrel
eternal needle
rich adder
final kestrel
#

I thought it was related with mouse position.

#

well yes

rich adder
crisp sand
#

It works thaks

final kestrel
#

oh so I just need to reset camera position

rich adder
#

so you mean when you teleport you want to look into another direction?

rocky canyon
bleak pasture
#

Is there a way to batch change all the shaders from old asset store purchase demo scenes to URP/simple lit so I stop having purple surfaces in demo scenes ? I dont think it can be done easily from the unity editor UI so I guess some unity editor code will be neded for this ??

rich adder
marble night
#

and nothing happened

final kestrel
rich adder
rocky canyon
#

ur going to have to rotate the camera... and reset ur values for ur mouse look script

ivory bobcat
polar acorn
rocky canyon
#

soo ur camera doesnt snap back to ur current mouse position

final kestrel
#

so if im looking down while teleporting my rotation changes as expected but my camera view does not.

polar acorn
#

Turn those back on

rocky canyon
ivory bobcat
#

If you've got an error later that's supposedly acquired from there then likely the component isn't on the object

bleak pasture
marble night
final kestrel
# rich adder in what way it does not

So im looking at the ground when I initiate the teleport. My position changes, my character's rotation changes but I am still looking at the ground when I come out on destionation

bleak pasture
#

youtube is only offering that I do it by hand but with hundreds of prefavs and materials that doesnt work for me

rocky canyon
#

ur gonna burn bridges if u keep responding like that

final kestrel
rich adder
rocky canyon
#

ya, so ur gonna have to disable that script.. teleport.. change the values to zero out ur mouse.. and re-enable the script

summer stump
final kestrel
marble night
final kestrel
#

then enable back

rich adder
# final kestrel Yes

You can also just assign the camera view the LookDirection of the teleport-point

rocky canyon
#

ya, but u may still need to change hte camera rotation.. and / or the values u have for ur mouse. depending on how ur look script works..

#

it may be the case that as soon as u re-enable the mouse look script it snaps back where it was

rich adder
#

yeah worth checking that first

final kestrel
#

hm okay. I will try disabling it.

rocky canyon
#

start 1 part at a time

#

write u a script to disable it -> teleport and -> reenable it

#

and go from there

final kestrel
#

all right.

rich adder
#

I think the cam object will still be rotated, you need to assign new rotation

rocky canyon
#

yea, i was under the assumption it was parented to his player..

#

my teleport systems always include a rotation too

rich adder
#

even so you're rotating on the X if you teleport with X looking down, you're gonna stillbe looking down until you reset X rot

rocky canyon
#

ya, true.. liek i said. it maybe all of the above situation

rich adder
#

yea would def do one step at time

rocky canyon
#

disable, teleport, reset camera, reset mouse values, re-enable

#

lol

final kestrel
#

thanks for the answers I will look into those.

rocky canyon
#

took me a while to figure that out.. i had a similar problem.. had to cache my mouse delta's and then add an offset to em

ivory bobcat
final kestrel
#

When I tried resetting my camera controls got weird

#

I press W and I go backwards and such

rocky canyon
#

so the mouse didnt reset the camera as soon as i enabled it.. cuz even after rotating the camera.. the mouse look took over and snapped it back..

#

cuz mouse delta's are just there

rich adder
rocky canyon
#

it all happens at once.. u teleport and before u realize it ur mouse controls are back

rocky canyon
#

all 1 frame.. disable -> teleport -> reenabel

final kestrel
#

I am using a coroutine

rocky canyon
#

then no wait between them..

final kestrel
#

stop teleport and start teleport

rocky canyon
#

same concept.. all at once

#

do it in the start tele coroutine

final kestrel
#

uhm i wait like .5 seconds

rocky canyon
#

yea at teh end..

#

dont wait between the enable and disable of the mouse loook

#
coroutine(){

disable
teleport
enable

yield return new waitfor...
}```
ivory bobcat
#

You need to disable and enable the component to have it update the transform. The script/execution-of-code will not stop if disabled and re-enabled

rocky canyon
#

yea, i think he's got the teleporting working.. - the camera..

#

if its a CC u have to disable the CC and teleport and renable

final kestrel
#

What is cc Character Controller?

rocky canyon
#

yes

#

if not u can get weird stuff going on

final kestrel
#

Ah yeah teleport works okay

#

So I think must do uhh Reset camera position and face the player in the camera direction

ivory bobcat
rocky canyon
#

this is the teleporting problem

#

if u rotate ur player during a teleport.. ur camera stays looking where the mouse tells it to

rich adder
#

yes they both need same rotation on Y

rocky canyon
#

imma put it on my list to do - today..

#

try to get it muscle memory (exposure)

bleak pasture
rocky canyon
#

you'll use that super often if ur an asset junkie

final kestrel
#

Well I am using an asset. And uh i believe its got something to do with this block

 public void Init(Transform character, Transform camera)
        {

            m_CharacterTargetRot = character.localRotation;
            m_CameraTargetRot = camera.localRotation;

        }
bleak pasture
#

yeah I was about give up on unity because of that, frustrates me a lot having to fix someone else code/assets especially unity enterprises stuff... I just want things to start when I just created a new project...

rich adder
rocky canyon
#

yup, you'll probably have to re-call that function

final kestrel
rich adder
#

I need to know if past asssets are URP compatible

#

the old assets lack that

rocky canyon
#

just so u can delete the one u dont need

#

looking out for my guys

rich adder
#

same my little shitty keypad asset uses both URP and BIRP

rocky canyon
#

and u ignored HDRP like me?

#

๐Ÿ˜„

rich adder
#

yeah lol I figured they can just convert the materials

bleak pasture
#

I bought about 500$ of assets in 2018 and regrets it very much but now that I have them might as well use them (at least the ones who didnt go free/are unmainted/dont work anymore/deprecated)

final kestrel
#
IEnumerator StartTeleport(Vector3 position, Quaternion rotation)
     {
         _firstPersonController.enabled = false;
         _firstPersonMouseLook.enabled = false;
        // _firstPersonController.disableMovement();
        // _firstPersonInteraction.disableMouseLook();
        transform.position = position;
        transform.rotation = rotation;
        StopTeleport();
        yield return new WaitForSeconds(0.4f);

    }

    public void StopTeleport()
    {
        _firstPersonMouseLook.Init(transform , _myCamera.transform);
        _firstPersonController.enabled = true;
        _firstPersonMouseLook.enabled = true;
        
    }

This is what it looks like now

bleak pasture
#

and some of them are just so good even if very old and they were free even if they dont show up in the store now

final kestrel
#

Im passing the destination position and rotation here.

ivory bobcat
rocky canyon
bleak pasture
#

eh to my defense it was mostly bundles assets like from humble bundle or recommendationws from game dev I spoke to IRL (like rewired)

rocky canyon
#

wasn't aware that was urs lol

rich adder
rocky canyon
final kestrel
rocky canyon
#

but w/o the lock and unlock feature u have..

#

just button presses and sounds

rich adder
#

SpeedTutor has my keypad on their list of free assets for october 2023 ๐Ÿ’ช

bleak pasture
#

but over time I realized, they go free, or they make a version X+1 making the upgrade not free, or they stop working or you realize it doesnt actually solve your problem, or if you just had followed unity learning you could have coded something better

rocky canyon
ivory bobcat
final kestrel
#

okay

#

let me try

rich adder
final kestrel
#

Why do I disable the cc though?

#

It enables resetted?

rocky canyon
#

could sell that one.. guarentee'd

ivory bobcat
rich adder
final kestrel
#

but my character's rotation works fine while teleporting?

bleak pasture
rocky canyon
#

its standard practice

#

if u dont do it now ur shooting urself in the foot

twilit ocean
#

I tried getting a code on the web to try and make this red bar follow my mouse movement but anchor to the player. But I'm not sure on how to do that and the code I saw reports an error.

final kestrel
#

ah okay all right

rocky canyon
#

its about the movement.. not the mouselook

#

those are two different systems

final kestrel
#

Well yeah as I said again movement works fine. I will disable cc and reenable it as you say.

rich adder
#

put a cast

#

(Vector3)hammer.position

rocky canyon
#

^ ur mixing two different things

shell sorrel
rich adder
#

you cannot do v2 - v3

#

you can assign them interchangeable but not perform operation on it

rocky canyon
#

float - float, int - int, vector2 - vector2

ivory bobcat
twilit ocean
#

wait what so the "hammer.position" part is a Vector 3?

rich adder
#

yes

twilit ocean
#

,_, is there a manual for that type of stuff

rich adder
#

unity is a 3D engine so all the positions are 3D structs

shell sorrel
#

also just return the worldpoint to a vector3

rich adder
#

yeah just remember to mousePos.z = 0

shell sorrel
#

ScreenToWorldPoint already is a vector3 you are just doing a implict cast because of the type on the LHS

#

also you are using a Orthographic camera right?

#

ScreenToWorldPoint is kinda useless if you are not

rich adder
#

yeah its 2D i think thats default

shell sorrel
#

so yeah return ScreenToWorldPoint into a Vector3

#

set z to what ever you need it

#

then do the subtraction

twilit ocean
#

So this is what yall meant? I'm not really sure I'm getting many instructions at the same time

final kestrel
#

All right I did as you say. Now I just gotta reset the camera view and rotate player towards the view so controls dont mess up right?

rocky canyon
#

for example this is my script where i enter/exit a vehicle

rich adder
rocky canyon
#

lots more to do than to just move the player

rich adder
shell sorrel
#

or set z to be the same as Hammers z

twilit ocean
#

How do I do that?

rich adder
#

yeah assumed hammer was on z of 0

shell sorrel
#

otherwise you will get a direction that is leaning away or towards the screen

twilit ocean
#

mousePos.z = 0 but where should I add it

rich adder
#

mousePos.z = hammer.position.z

rich adder
rocky canyon
#

^ float = float

shell sorrel
#

after the ScreenToWorldPoint

#

before the vector subtraction

lunar fern
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

โ€ข Visual Studio (Installed via Unity Hub)
โ€ข Visual Studio (Installed manually)

twilit ocean
rich adder
#

btw you can just do hammer.right = Direction ?

rocky canyon
#

i was trying to build a compass earlier.. and i was way over thinking it ^ that was the solution

shell sorrel
#

yeah since this is 2d the look direction will not act how you want without some changes

rocky canyon
#

compass.forward = Vector3.forward;

#

now we got North!

#

๐Ÿ™‚

lunar fern
#

i am getting a very wierd error with .net and i dont know a better place to ask than here. i have a image of everything for you too? ive spent 3 days trying to fix it but it still doesnt want to work. thank you in advance

rocky canyon
#

are u running windowsXP?

shell sorrel
#

thats win10

lunar fern
#

im runing win10

twilit ocean
rocky canyon
#

ahh.. okay lol soo ur PC says .net is installed.. but the IDE says nu uh

shell sorrel
#

the ide calls out .net core

#

he only confirms .net 8

lunar fern
#

only runtimes are

rocky canyon
rich adder
lunar fern
#

but i doo have a sdk instaled as you can see

rocky canyon
#

something being accessed is not present

rich adder
#

do you have a camera with the MainCamera tag

shell sorrel
#

or camera was not found

rocky canyon
#

it is tho

#

unless theres rogue scripts

twilit ocean
#

14Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);

rich adder
#

then its prob the camera.main or a clone script with no field assigned

shell sorrel
#

then make sure Camera has mainCamera as a tag in its inspector

rocky canyon
#

Camera must not be main camera

polar acorn
rich adder
shell sorrel
#

it looks like it

rocky canyon
lunar fern
shell sorrel
rocky canyon
#

i dont know nothing about VSCode.. but id guess u missed a step..

shell sorrel
#

yeah i just noticed they prompted the bot for VS but the screenshot is VSCode

rocky canyon
#

hehe, tragedy

lunar fern
rocky canyon
#

VSCode is more involved than VSComm

shell sorrel
#

but yeah i cant help on either, team Rider here

rocky canyon
#

this one?

#

looks available to me

lunar fern
#

yes it is availiable and thats the one ive instaled

rocky canyon
#

just follow all the steps again

#

ya, im team visualstudio

#

Rider when its Free giveaway month

lunar fern
#

ive tried visualstudio too but its the same problem

rocky canyon
#

nah nah, visual studio is ez af to set up

rich adder
lunar fern
#

you know what ima re-install it

rich adder
rocky canyon
#

lol (โ•ฏยฐโ–กยฐ)โ•ฏ๏ธต โ”ปโ”โ”ป

rocky canyon
#

is it a problem to have both installed?

rich adder
#

nah not at all

#

they both use the Visual Studio package in Unity

#

the only thing missing is Intellicode for me

rocky canyon
#

๐Ÿค” i might humour the code guys and see whats the fuss

rocky canyon
rich adder
#

there is Intellisense but no intellicode ๐Ÿ˜ฆ

bleak pasture
#

with copilot now criticizing my searches in bing I hope copilot doesnt start to criticize that you are using other IDE in visual studio ๐Ÿ˜ฆ

rocky canyon
#

i know they do for rider

rocky canyon
rich adder
rocky canyon
#

fancy guy

ivory bobcat
#

It's the commonly missed step - it's not checked by default

rich adder
twilit ocean
#

Hi sorry for delay, had to help grandma. Yes apparently I didn't have a main camera because I deleted the old one by accident. But now this happened.

rocky canyon
#

did u use the thing.right?

#

may need to use the thing.forward or -forward instead

ivory bobcat
#

It looks 2d

rocky canyon
#

ah u right lol

#

im obviously blind af

vast vessel
#

Lets say i have a AI_Firearm script with a Reload(); method, and i also have an AI_Speaker script.

Now I want the Speaker script to run a SaySentance("Reload"); method, when the Reload(); method on the firearm script is called, by subscribing to it inside of the Speaker script like an event.

How do i do this?

rocky canyon
#

do u know how events work already?

rich adder
twilit ocean
# rich adder show current code

Ok so one thing that I'm doubtful of is where the script was made to be in. The player or the weapon, currently the script is on the player tagging the hammer to transform.

vast vessel
#

I dont have events. I just have a Reload method and a SaySentance method

twilit ocean
ivory bobcat
#

You'd replace your previous rotation line

rich adder
twilit ocean
rich adder
#

replace the whole .rotation

twilit ocean
vast vessel
wintry quarry
rich adder
twilit ocean
rich adder
#

instea of Hammer.rotation =
do Hammer.right = Direction

rocky canyon
rich adder
#

or just Action

rocky canyon
#

idk actions yet..

#

but yes or Actions

rich adder
#

its a delegate already

ivory bobcat
#

Action would just be a specific predefined type of delegate

rich adder
#

public event Action OnReload;

vast vessel
#

Ive seen people use += but it dosnt seem to work for me, probably beacuse im doing it wrong :
frm.Reload() += SaySentance("Reload")

All the functions i mentioned are voids

ivory bobcat
#

Same with func

rocky canyon
#

public class AI_Speaker : MonoBehaviour
{
    AI_Firearm firearm;

    private void Awake()
    {
        firearm = GetComponent<AI_Firearm>();
    }

    private void OnEnable() => firearm.OnReload += OnFirearmReloaded;
    private void OnDisable() => firearm.OnReload += OnFirearmReloaded;

    private void OnFirearmReloaded()
    {
        //Reload and Talk
        SaySentence("Reload");
    }

    private void SaySentence(string sentence)
    {
        // Talkie stuff
    }
}```
#

the other half of my delegate event sys

#

now someone can share about actions.. cuz idk

vast vessel
#

This is exactly what i wanted!

#

Ty

rocky canyon
#

no problem.. just use it as an example and u can make all ur events from it

#

just remember to subscribe and unsubscribe..

twilit ocean
rocky canyon
#

if u don't you'll be calling events for no reason

#

or listening for events for no reason rather

twilit ocean
#

this is the code now (hopefully correct this time)

bleak pasture
#

typically you subscribe in awake() or start() and unsub on destroy or during update()

rich adder
#

want to see something

vast vessel
flint falcon
#

I feel kinda stupid but trying to follow a movement tutorial for a 2d character and followed it exactly but my movement is a mess

rocky canyon
#

but i sort my execution orders when i need also

twilit ocean
rocky canyon
#

esp if u unsubscribe in OnDisable ๐Ÿ˜„

bleak pasture
#

thanks Ill keep these advice in notes, my unity knowledge is old havent done it for a while and still going throught the unity learning

rocky canyon
rich adder
rocky canyon
#

Pivot Local mode For Lyfe!

buoyant knot
bleak pasture
#

I said update cuz sometimes you want an update to be faster and you might temporarily disconnect events in certain cases

ivory bobcat
rich adder
#

think you replied to wrong person :p

shell sorrel
#

where you unsub depends on intent

buoyant knot
#

oop youโ€™re right

bleak pasture
#

But all these learning later I still dont know why coroutines exists ๐Ÿ˜ฆ

shell sorrel
#

like do you want to to receive events if disabled or not

bleak pasture
#

I just dont get it especially vs async/Task...

rocky canyon
buoyant knot
#

a lot of my monobehaviours subscribe to spawnedEntityHandler.OnEntityDeath, which is an action that gets invoked when an entity dies. And it is always better to use that sort of thing over OnDestroy

rich adder
#

/jk

twilit ocean
final kestrel
#

@rich adder

  IEnumerator StartTeleport(Vector3 position, Quaternion rotation)
     {
        _characterController.enabled = false;
        _firstPersonController.enabled = false;
        _firstPersonMouseLook.enabled = false;
        // _firstPersonController.disableMovement();
        // _firstPersonInteraction.disableMouseLook();
        transform.position = position;
        transform.rotation = rotation;
        StopTeleport();
        yield return new WaitForSeconds(0.4f);

    }

    public void StopTeleport()
    {
        _firstPersonMouseLook.Init(transform , _myCamera.transform);
        _myCamera.transform.Rotate(0,0,0 );
        _characterController.enabled = true;
        _firstPersonController.enabled = true;
        _firstPersonMouseLook.enabled = true;
    }
}

I did this and it works now

buoyant knot
#

although, it might have been smarter for me to use an interface for this, to call an OnEntityDeath() interface method.

rich adder
bleak pasture
# rich adder unity version of Async

I understand that but I dont know when to use one besides the obvious "call is gonna take longer than a 250ms game loop" like doing animator.something on a 19s animation

rocky canyon
#

i use it as a Sequencer

twilit ocean
#

got it

rich adder
twilit ocean
rocky canyon
#

so its aligned on the .right axis

lunar fern
rocky canyon
#

ones better than none

#

can always try to set up Code later

rich adder
lunar fern
#

think that the solution was that. could have saved me 3 days of reserch with none other with the same problem

bleak pasture
#

I wish I could just use winforms and convert to unity canvas ๐Ÿ˜ฆ for the initial prototype UI

rich adder
#

Oh wait

#

You didnt normalize it

#

that might be issue

twilit ocean
#

my last hope

#

what's that normalize thing

rich adder
rocky canyon
#

sets the lengths to 1

twilit ocean
#

Where do I place that in the code?

rich adder
rocky canyon
twilit ocean
rocky canyon
#

z + x would equal 1.4 (longer than z is and longer than x is)

#

normalizing it gives u a value thats the same length.. but same direction

bleak pasture
#

unity has interesting words like lerp, tween and gizmos. Before that a gizmo for me was that dude in gremlins movie

rich adder
#

none of those are unity terms

#

esp lerping, is not a unity term

#

lerp is short for Interpolation

rocky canyon
ivory bobcat
#

They're found everywhere

rocky canyon
#

normalized red line would end at orange dot

twilit ocean
rich adder
twilit ocean
#

told you

rocky canyon
#

(mousePos - hammer.positon).normalized;

rich adder
#

.normalized is a property

rocky canyon
#

.normalize*

bleak pasture
#

you need to learn some coding it seems

rocky canyon
#

lol.. Normalize(this);

rich adder
rocky canyon
#

^ i like that better

#

keep its more organized

rich adder
#

not between

twilit ocean
rich adder
#

true

rocky canyon
#

im running out of tables to flip j/k ur doing fine

rocky canyon
#

ugh..

rich adder
#

ops yeah i missed a letter too on that lol

rocky canyon
#

good thing i have a project just waiting for me to write more test scripts

#

thats what i meant.. normalizeD

#

the D isn't prevelant ๐Ÿ˜…

rich adder
#

Normalize() vs normalized

#

goddam Unity โœŠ

rocky canyon
#

i use both interchangeable

#

i need to stick to 1

twilit ocean
rocky canyon
#

do all types have a .normalized property?

rich adder
rocky canyon
#

nah

rich adder
#

ohh I meant just vectors*

#

๐Ÿ˜›

rocky canyon
#

lol.. typos be rampant today

twilit ocean
#

Still down

rocky canyon
#

ive already forgotten what ur trying to do? where should it be pointing in this image?

rich adder
rich adder
#

thought it would work, something is wrong obvious im not noticing

rocky canyon
#

well the line def matches the direction

#

oooor.. does it?

#

wouldnt that be behind the player?

rich adder
#

Z seems to be 0 which should be correct

twilit ocean
rocky canyon
#

whoo cosmic mirror

#

ohh thats jank

#

gotta click back into the window btw..

#

for the mouse to be captured

rich adder
rocky canyon
#

when u maximized i dont think u did

twilit ocean
#

Like a pointing gun

#

But it will be used for physicds

rocky canyon
#

ya, i see now. wasn't sure if it was supposed to point at the cursor.. but now i got it

twilit ocean
rocky canyon
#

lol. rage clicker!

#

can u share ur !code in text format?

twilit ocean
#

maybe if I click more it will start working

eternal falconBOT
rich adder
twilit ocean
# rich adder did you check camera thing?

{
    public Transform Hammer;

    public Vector3 Direction;

    void Update()
    {
        Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);

        mousePos.z = Hammer.position.z;

        Direction = mousePos - Hammer.position;
        Direction.Normalize();

        Hammer.right = Direction;
    }

}```
rich adder
twilit ocean
#

found it

rich adder
ivory bobcat
twilit ocean
#

the camera was the issue apparently

rich adder
#

nice

rich adder
#

seems now it points to correct direction

twilit ocean
#

well, have you seen the game "Getting over it".

rich adder
#

if you mean the Pivot, you have to change that inside the Sprite editor

rich adder
twilit ocean
# rich adder the climbing game?

yeah. So I heard the base mechanic is the hammer orbitating around the player than the player orbitating around the hammer when it finds ground.

Either way, how do I acess the sprite editor to change the pivot?

radiant tulip
#

Hey y'all, can I make questions in this channel?

twilit ocean
rich adder
rich adder
#

rotate the new parent instead of hammer

radiant tulip
#

I just wanted to make sure to not mess things up on the first time I talk on this server ;-;

twilit ocean
radiant tulip
#

When I do this Camera.main.WorldToScreenPoint(Input.mousePosition); it always gives me the same position when I click on an object, no matter where I click on said object. Got an EventSystem put and everything works smoothly (clicking on objects trigger certain events and all) but now I want to try to click n drag an object, and they're not moving cause of that problem

languid spire
#

This
Camera.main.WorldToScreenPoint(Input.mousePosition);
should be
ScreenToWorld

twilit ocean
rich adder
radiant tulip
twilit ocean
radiant tulip
#

Lemme try again actually to make sure it was that

ruby axle
rich adder
#

this way you change rotation to rb.rotation

#

so it moves with physics properly

rich adder
#

you can try to just give it no friction physics material on player collider, but thats a crapshoot sometimes

radiant tulip
rich adder
twilit ocean
rich adder
radiant tulip
radiant tulip
rich adder
# twilit ocean xd

haha yeah you have to turn off gravity and also constraint position of rigidbody

#

also does player have rigidbody? i believe that also needs one if you want to affect it from the stick

rich adder
#

then use a raycast

#

or there is also OnMouseDown and OnMouseUp you can use

#

set bool to true when down

#

Update to follow mousepos

twilit ocean
radiant tulip
#

This is my code

rich adder
#

also it doesnt work on colliders, unless you put a Physics2D Raycaster on the Camera

rich adder
radiant tulip
radiant tulip
rich adder
#

but if ur colliders are 3D

twilit ocean
ruby axle
radiant tulip
rich adder
rich adder
ruby axle
#

oh and btw i am using a character controller

#

no rigidbody in the project

twilit ocean
radiant tulip
rich adder
rich adder
#

did you see the link I sent ? it explains about the camera nearClip

ruby axle
radiant tulip
shell sorrel
#

use ScreenPointToRay

rich adder
shell sorrel
#

then use that to cast on a plane

radiant tulip
radiant tulip
rich adder
rich adder
ruby axle
shell sorrel
#

that link from before perfectly explains hows to hook up these 2 things to solve this problem

rich adder
ruby axle
radiant tulip
radiant tulip
shell sorrel
#

just make sure the plane is facing the correct way

radiant tulip
#

The plane should be faced like the canvas or the camera?

rich adder
shell sorrel
#

yeah would help to see the game it really depends on how you want things to work

bleak pasture
#

my plane disappeared after switching to URP but I have a lot of other problems to fix before this ๐Ÿ˜ฆ

#

It uses to be white/gray bricks on the floor

rich adder
radiant tulip
#

the camera looks like the first one and the canvas for the UI

rich adder
shell sorrel
#

ok lets back up a sec, what are you trying to accomplish with this position from the mouse

#

what you want to do with it really matters for what we will cast agaisnt

radiant tulip
# rich adder which thing you are trying to drag and where

This is the food menu that appears when im playing the game, the buttons for the next and previous food works cause theyre UI, but the food in between them is not (this case the fish, sorry if it doesnt show that well the light is still under work), and im trying to drag that

bleak pasture
#

not all problems can be solved by clicking stuff in the inspector or in some editor menu

rich adder
radiant tulip
radiant tulip
shell sorrel
#

yeah ignore the plane then

#

use Physics.Raycast

rich adder
#

so your ray / drag will know thats the Mouth area

shell sorrel
#

that will get you a raycast hit and you can see if that ray hits the fish

radiant tulip
rich adder
#

yeah !

#

once you're dragging the fish you can check with a Tag or put a component that it is indeed the mouth area

summer stump
radiant tulip
shell sorrel
#

yeah if it shows in the event system you could just implementing the dragging of the FIsh with the event system

#

IDragHandler, IDropHandler on the fish

radiant tulip
#

Instead of the fish object, can I do it in the gameObject that holds that object?

#

On the FoodHolder

covert sinew
#

Managed to polish off an issue I was having with my item moving script

Basically, when I try to use the "move item" function, if a slot was being removed, it would displace all index values higher than itself, due to the way lists automatically "collapse" removed index slots in them

So now the move-item script has a check if a slot is being removed, and if the slot being removed is a lower index than the slot it's adding something to.

It really is a shame Unity doesn't have a built in function for moving something from one index to another, as far as I know. I'm having to use "Remove" and "Insert" instead, which can be a bit finicky.

cosmic dagger
shell ice
#

Hello everyone , I am making a 2d turn based game and i want to do something like this :

whenever i select a unit some buttons will be displayed , each one of them is an option of what the unit can do ( Attack , Move , Wait ... )
And i want to make everything else unclickable whenever these 3 buttons are displayed ( except setting and pause menu and things like that )

the issue i'm finding here is i cannot find a way to make elements impossible to interact with whenever i am in the state where the buttons are displayed

what solution would you recommend for this please

cosmic dagger
twilit ocean
#

Hi I've been trying to find where the option to change the pivot is for 20 min now with no success? Anyone got an idea where it should be?

#

Even the guids on the internet seem to be different from mine

#

I really cannot find the option to change the pivot

#

Do I have to make a sprite for the object to change the pivot?

rocky canyon
#

u should just use an empty container then

twilit ocean
#

Making an empty container to deal with it every time might make everything a mess in the long term.

#

But maybe it's the sprite

rocky canyon
fast swan
#

my models are broken help

rocky canyon
#

if u spawn it in, it'd have the child set up already

#

did you use code to break them?

fast swan
#

you guy know what gorilla tag is

swift crag
#

this is not a modding server

fast swan
#

ik

#

im making a fan game and i can see through my models

swift crag
#

when you get very close to them?

fast swan
rocky canyon
#

then the model

#

s normals are inside out

swift crag
twilit ocean
# rocky canyon

I'm already using this system. But, to prevent bugs I'm constantly lerping the pivot of the hammer towards the empty container.

I found the sprite editor but can't use it.

swift crag
#

You can't make assets that refer to scene objects.

rocky canyon
#

you have to click the arrow next to the texture.. to expand it

swift crag
rocky canyon
#

to show the sprite

#

ur draggin the wrong object

swift crag
#

CanvasGroup lets you set a few things for any UI elements on or beneath the component's object, including opacity and, vitally, interactability

fast swan
#

now i cant even import models into the game

swift crag
#

You can make the rest of your UI non-interactable

rich adder
#

You have to select the asset first , then in the asset importer you have the Sprite Editor

rocky canyon
#

to Sprites

swift crag
polar acorn
swift crag
#

By making that canvas group non-interactable, you will not be able to click on "Some Button"

fast swan
twilit ocean
#

Dude I alt-tabed and came back and it worked

rocky canyon
#

they look to be set to sprites but just checking

polar acorn
fast swan
twilit ocean
#

We are so back

#

Thanks for the help, but apparently it was caused by unity's quirckyness

rocky canyon
#

dont drag the sprite in.. @twilit ocean the window should show the sprite u have selected

polar acorn
# fast swan um tf

That appears to be where you've set your model's pivot in whatever 3D software it was made in

shell ice
rocky canyon
rocky canyon
polar acorn
eternal falconBOT
fast swan
#

yay

covert sinew
# cosmic dagger It sounds like an array would work better since you can't remove or add elements...

I need to be able to change the size of hte inventory, since I don't plan on it having limited slots, is the main issue with using an array. Lists are easier to change the length of, and easier to insert things into the middle of them, too. Either way, I managed to fix the problem by detecting whether or not an entry was being fully removed, and if it was being fully removed from a slot lower in the index than the slot it was being added to.

desert moon
#

Yeah, I'm still stuck on this. The camera is still jittering

rich adder
desert moon
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainCamera : MonoBehaviour
{
    public static MainCamera singleton;
    public Transform targetObject;
    Rigidbody rb;

    // Start is called before the first frame update
    void Start()
    {
        MainCamera.singleton = this;
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    public void UpdatePos()
    {
      transform.position = targetObject.position;
      transform.rotation = targetObject.rotation;   
    }
}

Not gonna use Cinemachine

I've rolled it back to this though

rich adder
#

why would you not use cinemachine ?

#

its gonna be better than any hacky solution you do

desert moon
#

I don't see how Cinemachine is gonna magically fix the problem I'm running into.

rocky canyon
#

lol, it literally does

rich adder
#

my guy wants to slice bread with their teeth instead of a bread slicing knife

summer stump
polar acorn
desert moon
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using UnityEngine.Networking;


public class ActorCamera : MonoBehaviour {

    public ActorBase user;

    Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    public void LateUpdate ()   {
        
        //This was originally rb.position
        transform.position = user.transform.position;
        transform.eulerAngles = new Vector3(user.lookAngle.x,user.transform.eulerAngles.y,0);
        MainCamera.singleton.UpdatePos();

    }


}

Bruh... this fixed it.

summer stump
#

Obligatory "still just use cinemachine"

rich adder
#

still wont be as good

#

but goodluck with that

rocky canyon
#

Not magic, just Smart ๐Ÿ™‚ lol

rich adder
#

stiff robotic follow ๐Ÿ’ฉ

rich adder
#

Oh camera collider? yesplz

cosmic dagger
rocky canyon
#

rigidbody -> cc transition

rich adder
rocky canyon
#

lol went out feet flying

rich adder
hidden sun
#
        {
            // Register callbacks, which are triggered when a player message is received
            var callbacks = new SubscriptionEventCallbacks();

            callbacks.MessageReceived += @event =>
            {
                Debug.Log(DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK"));
                Debug.Log($"Got player subscription Message: {JsonConvert.SerializeObject(@event, Formatting.Indented)}");
            };

            callbacks.ConnectionStateChanged += @event =>
            {
                Debug.Log($"Got player subscription ConnectionStateChanged: {JsonConvert.SerializeObject(@event, Formatting.Indented)}");
            };

            callbacks.Kicked += () =>
            {
                Debug.Log($"Got player subscription Kicked");
            };

            callbacks.Error += @event =>
            {
                Debug.Log($"Got player subscription Error: {JsonConvert.SerializeObject(@event, Formatting.Indented)}");
            };

            return CloudCodeService.Instance.SubscribeToPlayerMessagesAsync(callbacks);
        }
    }
``` What is @event? i need to make methods so i can unsubscribe when i want
covert sinew
# cosmic dagger So then, what problem are you having? ๐Ÿค”

I WAS having an issue where when trying to make a "move function" that removes an item from one slot and inserts it into another, it would insert it into the "wrong" slot, because it would use List.RemoveAt, and then List.Insert, where the removal would disjoint the indexes if it happened at a smaller index value than the index it was inserting at.

What I ended up doing to fix this is to just have the game detect if the removed entry was a lower index than the added entry, and if so, to reduce the index too be added to by -1, so it still moves it into the same "slot" reletive to other items in the inventory.

rich adder
#

adding @ means you can use that as variable name no problem

rocky canyon
#

and gives away that theres also another variable of the same name

rich adder
#

so you could name something public float @class

rocky canyon
#

well.. not always tru.. but most times

distant hawk
#

Hello, I'm a new devlopper, I'm currently recreating the watermelon game everything is going great but now I have two problems:
1 I can't create a scoring system, let me explain, I want to create a system whose role will be to give a certain number of points when my fruits of the same level (named element, which starts from 0 to 7 to indicate the class of the fruit) collide, this one destroys the current fruit to make room for the next fruit, example element 0 with 0 = 1 so the role of the script will be to fetch from a file the fruit that has the name of element 1 to make it appear, at which point I want it to display the example score: element 0 = 5 SCORT
element 1 = 10 SCORT
element 2 = 15 SCORT
element 3 = 25 SCORT
element 4 = 30 SCORT
element 5 = 40 SCORT
element 6 = 55 SCORT
element 7 = 70 SCORT
but I can't...
2 I'd like to create a system that displays the next fruit to appear, on an image right next to it,
can you please help me?

I need help with a scoring system and displaying the next fruit.

Translated with DeepL.com (free version)

rocky canyon
#

whats the rule with special characters in variable names?

#

_ and @ are the only two i feel comfortable using

rich adder
#

cause they have many uses in c#

#

oh and @ before a string lets you not have to escape \

distant hawk
# distant hawk Hello, I'm a new devlopper, I'm currently recreating the watermelon game everyth...

code Fruit :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fruit : MonoBehaviour
{
[HideInInspector] public MoveCloud MoveCloud;
public int fruitIndex;

private void OnCollisionEnter2D(Collision2D collision)
{
    var incomingGameObject = collision.gameObject;
    if (!gameObject.activeSelf || !incomingGameObject.activeSelf)
        return;

    var fruit = incomingGameObject.GetComponent<Fruit>();
    if (fruit != null)
    {
        if (fruit.fruitIndex == fruitIndex)
        {
            fruitIndex++; 
            if (fruitIndex > 7)
                fruitIndex = 0;

            GameObject nextFruit = Instantiate(MoveCloud.fruitsPrefabs[fruitIndex]);
            nextFruit.transform.position = transform.position;
            Fruit nextFruitScript = nextFruit.GetComponent<Fruit>();
            nextFruitScript.MoveCloud = MoveCloud;
            nextFruitScript.fruitIndex = fruitIndex;
            incomingGameObject.SetActive(false);
            Destroy(incomingGameObject); 
            Destroy(gameObject); 
        }
    }
}

}

eternal falconBOT
distant hawk
# distant hawk Hello, I'm a new devlopper, I'm currently recreating the watermelon game everyth...

code MoveCloude
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCloud : MonoBehaviour
{
[SerializeField] private float mouvementSpeed = 5f;
[SerializeField] private float minXPosition = -2.6f;
[SerializeField] private float maxXPosition = 2.6f;
[SerializeField] private float delayBetweenFruits = 0f;

private float lastFruitTime;
private int maxFruitSpawn = 1; 
private List<int> fruitElements = new List<int>(); 

public GameObject[] fruitsPrefabs;

void Update()
{
    if (Input.GetKey(KeyCode.Q) && transform.position.x > minXPosition)
    {
        transform.position -= new Vector3(mouvementSpeed * Time.deltaTime, 0, 0);
    }
    else if (Input.GetKey(KeyCode.D) && transform.position.x < maxXPosition)
    {
        transform.position += new Vector3(mouvementSpeed * Time.deltaTime, 0, 0);
    }

    if (Input.GetKeyDown(KeyCode.Space) && Time.time - lastFruitTime > delayBetweenFruits) 
    {
        int numFruitsToSpawn = Random.Range(0, maxFruitSpawn + 1);
        for (int i = 0; i < numFruitsToSpawn; i++)
        {
            int currentFruitElement = GetNextFruitElement(); 
            if (currentFruitElement != -1)
            {
                GameObject newFruit = Instantiate(fruitsPrefabs[currentFruitElement]);
                newFruit.transform.position = transform.position;
                lastFruitTime = Time.time; 
                Fruit newFruitScript = newFruit.GetComponent<Fruit>();
                newFruitScript.MoveCloud = this; 
                newFruitScript.fruitIndex = currentFruitElement; 
            }
        }
    }
}

private int GetNextFruitElement()
{
    int randomElement = Random.Range(0, 4); 
    fruitElements.Add(randomElement); 
    return randomElement;
}

}

rich adder
#

jesus

#

my guy spammin this shit

swift crag
rocky canyon
#

hes using a language translator. may take him a minute

distant hawk
#

!code properly

eternal falconBOT
rich adder
#

lmao

#

read it

hidden sun
# distant hawk !code properly
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCloud : MonoBehaviour
{
    [SerializeField] private float mouvementSpeed = 5f;
    [SerializeField] private float minXPosition = -2.6f;
    [SerializeField] private float maxXPosition = 2.6f;
    [SerializeField] private float delayBetweenFruits = 0f; 

    private float lastFruitTime;
    private int maxFruitSpawn = 1; 
    private List<int> fruitElements = new List<int>(); 

    public GameObject[] fruitsPrefabs;

    void Update()
    {
        if (Input.GetKey(KeyCode.Q) && transform.position.x > minXPosition)
        {
            transform.position -= new Vector3(mouvementSpeed * Time.deltaTime, 0, 0);
        }
        else if (Input.GetKey(KeyCode.D) && transform.position.x < maxXPosition)
        {
            transform.position += new Vector3(mouvementSpeed * Time.deltaTime, 0, 0);
        }

        if (Input.GetKeyDown(KeyCode.Space) && Time.time - lastFruitTime > delayBetweenFruits) 
        {
            int numFruitsToSpawn = Random.Range(0, maxFruitSpawn + 1);
            for (int i = 0; i < numFruitsToSpawn; i++)
            {
                int currentFruitElement = GetNextFruitElement(); 
                if (currentFruitElement != -1)
                {
                    GameObject newFruit = Instantiate(fruitsPrefabs[currentFruitElement]);
                    newFruit.transform.position = transform.position;
                    lastFruitTime = Time.time; 
                    Fruit newFruitScript = newFruit.GetComponent<Fruit>();
                    newFruitScript.MoveCloud = this; 
                    newFruitScript.fruitIndex = currentFruitElement; 
                }
            }
        }
    }

    private int GetNextFruitElement()
    {
        int randomElement = Random.Range(0, 4); 
        fruitElements.Add(randomElement); 
        return randomElement;
    }
}
rich adder
#

please USE LINKS for large code

#

these are not good for viewing comfortably on phone scrolling back n forth

rocky canyon
#

lol different person.. crossposting his code in a block

hidden sun
#

tried to help him

rocky canyon
#

mmhmm needs a pastebin at this rate

#

he done flooded out his original question

rich adder
#

we need dyno to detect if you're adding like more than 6 lines inside `

distant hawk
#

cs
code NextFruit
using UnityEngine;
using UnityEngine.UI;

public class NextFruitUI : MonoBehaviour
{
public Image[] fruitImages;

void Start()
{
    foreach (Image fruitImage in fruitImages)
    {
        fruitImage.enabled = false;
    }

    UpdateNextFruit();
}

public void UpdateNextFruit()
{
    int nextFruitIndex = Random.Range(0, fruitImages.Length);

    fruitImages[nextFruitIndex].enabled = true;
}

}

rocky canyon
#

we dont need all your scripts either.. but now that i say that.. why is MoveCloud spawning fruits?

hidden sun
#

๐Ÿคฆโ€โ™‚๏ธ

rich adder
#

mission failed

swift crag
hidden sun
distant hawk
hidden sun
#

or oooon site

rocky canyon
rich adder
rocky canyon
hidden sun
#

cuz he didn't know how to use it

cosmic dagger
rich adder
#

the bot explained everything , they just need to read it

cosmic dagger
#

You just moved up (hidden) everyone else's question(s) for help . . .

distant hawk
rocky canyon
#

no worries, just repost your code as a hyperlink (using one of those websites linked above) and your original question again

distant hawk
#

Hello, I'm a new devlopper, I'm currently recreating the watermelon game everything is going great but now I have two problems:
1 I can't create a scoring system, let me explain, I want to create a system whose role will be to give a certain number of points when my fruits of the same level (named element, which starts from 0 to 7 to indicate the class of the fruit) collide, this one destroys the current fruit to make room for the next fruit, example element 0 with 0 = 1 so the role of the script will be to fetch from a file the fruit that has the name of element 1 to make it appear, at which point I want it to display the example score: element 0 = 5 SCORT
element 1 = 10 SCORT
element 2 = 15 SCORT
element 3 = 25 SCORT
element 4 = 30 SCORT
element 5 = 40 SCORT
element 6 = 55 SCORT
element 7 = 70 SCORT
but I can't...
2 I'd like to create a system that displays the next fruit to appear, on an image right next to it,

link code MoveCloud : https://hatebin.com/zsbnosrzqm
Link code Fruit: https://hatebin.com/qdfjrlaooc
can you please help me?

rich adder
#

AI code :\

rocky canyon
#

idk, i used to write alot of comments when i first learning.. could be not

distant hawk
rich adder
#

gottem

rocky canyon
#

self-snitching

rich adder
#

this is gonna be hard to explain though cause of the language barrier

rocky canyon
#

facts.. might as well long-format it

distant hawk
rocky canyon
#

you'll need a queue or get ur fruits 2 ahead of current

#

no way to randomize it and predict it at the same time

rich adder
#

plenty

rich adder
#

yes Randomize 2pieces piece first, or randomize the whole lineup and put it in a list.

distant hawk
rocky canyon
#

i think a buffer/queue better.. cuz u'd be chasing the dragon with the 2 piece idea

rich adder
#

yeah agreed

rocky canyon
#

you'd want a queue of 3 atleast

#

or 2 minimum

rich adder
#

I deleted my msg cause i realized Queue would not be good, they need List or array

rocky canyon
#

the next piece and the one after..
once u swap pieces.. u randomize and grab the new one to fill the last ones place

rich adder
#

so they can access the second

distant hawk
#

if I've understood correctly, I have to manage to arrange 3 ramdon fruits in advance? and then manage to display them?

rocky canyon
#

2piece list would be ideal for beginner to use Add() Remove()

#

two**

rich adder
rocky canyon
#

the next piece and the one after

rich adder
#

also why storing fruits as int

#

store them as Fruit

#

public List<Fruit> fruitPrefabs // possibles to spawn

rocky canyon
#

pretty drawing ๐Ÿ˜„

wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class WelcomeSceneGameManager : MonoBehaviour
{
    // Start is called before the first frame update

    public AudioClip audioClip; // creating variable for audio
    private AudioSource audioSource;
    void Start()
    {
        audioSource = gameObject.AddComponent<AudioSource>(); //taking link component
        audioSource.clip = audioClip; // assign variable to component
        audioSource.loop = true;
        audioSource.Play(); //play
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void click()
    {
        SceneManager.LoadScene(1);
    }
}
distant hawk
wraith valley
#

Help please

#

Doesn`t work changing map

rocky canyon
#

scenes?

rich adder
#

make sure it runs

wraith valley
#

Sorry

wraith valley
rocky canyon
#

do u have scenes in ur build settings?

polar acorn
pliant marsh
#

why is scenemanager not working properly, Normally it should be a different colour if its working but its just plain white and not doing anything

wraith valley
rocky canyon
#

SceneManager <--

wraith valley
polar acorn
rare basin
eternal falconBOT
wraith valley
polar acorn
#

Where are you calling click

wraith valley
#

I don`t understand

rocky canyon
#

Debug the method.. see if it runs..

#

debug the SceneManager.LoadScene(1); see what it is

polar acorn
wraith valley
polar acorn
#

What is running click

wraith valley
#

Working now

distant hawk
wraith valley
polar acorn
wraith valley
rich adder
rocky canyon
#

what about scoring system?
just score++;
you can add 1 everytime u slice a fruit.
if fruits are worth different amounts.. u could do as navarone mentioned earlier.. and have a class called Fruit.. could store a public int fruitValue;

#

then when u hit the fruit u could access its fruit script and add that value to ur score instead.. score += fruitIjustSlashed.fruitValue;

rich adder
#

they do have a Fruit class just not sure whats inside

#

oh wait its in the second link

rocky canyon
#

oh, outta all the scripts he sent that wasnt 1 of em?

#

๐Ÿ˜„

rich adder
rocky canyon
#

ya perfect

rich adder
#

overconvoluted af

rocky canyon
#

just add it in there

#

if fruit (make money)

distant hawk
rich adder
#

lol

wraith valley
pliant marsh
rich adder
#

have you bothered looking at the documentation what the proper class Is ?

pliant marsh
#

how does one do that?

rich adder
pliant marsh
#

ok

polar acorn
rocky canyon
#

doesn't even have to be a good search. " how do i load a new level in unity " results in teh same link... just a few places down

novel void
#

How do I read local rotation.x of a transform in degrees between 360 and 0

novel void
#

That always results in some number that's 0 or very close to 0 randomly, not actually affected by the rotation of the object. (this object has no parent)

#

i need something that spits out the same value as the inspector transform component shows (it has some trickery that makes it nicely readable for humans).

wintry quarry
novel void
#

i've been punching my pc screen for like 6 hours on this

wintry quarry
#

which is a quaternion thing

#

which is not euler angles at all

novel void
novel void
#

Debug.Log(Mathf.DeltaAngle(transform.localEulerAngles.x, 0));

wintry quarry
#

What number are you expecting?

pliant marsh
# rich adder wild

this still didnt work, i have another scene switcher script that works perfectly fine and the errors unity is giving me make absolutely no sense.

novel void
#

A number between 0 and 360 or -360 and 0, just something that actually changes in degrees.

carmine turret
#

whats the easiest way to figure out the vector2 for my raycasts direction?

wintry quarry
#

How is your object rotated

novel void
#

starts at 0,0,0 rotation.

rich adder
carmine turret
#

For example, I want it to go roughly 20 degrees ccw from -vector.up

wintry quarry
rich adder
#

SceneManagment is nonsense @pliant marsh

#

it should underline red

carmine turret
#

I have no clue how I would go about making that calculation

wintry quarry
novel void
#

that code spits out -40 and as the object is given angular momentum, it changes to some number like -40.0264837 and goes back to -40 as the object slows down. It never moves more than 0.1 in value away from -40 even if the x rotates 180 degrees

carmine turret
#

Ahh thank youu

pliant marsh
novel void
#

it's not your code that's the issue it's something in the project

wintry quarry
pliant marsh
polar acorn
rich adder
#

You dont see the difference ?

polar acorn
#

You're using the right one

carmine turret
novel void
carmine turret
#

You're EVERYWHERE on unity forums

wintry quarry
#

I'm all over the place

pliant marsh
rich adder
polar acorn
carmine turret
#

Actually little confused on this.

    private SlopeCheck(){
        RaycastHit2D slopecheck = VisualPhysics2D.Raycast(transform.position, Quaternion.Euler(0,0,-20) * Vector2.up, groundDistance * 1.2f, groundedLayer);
        return slopecheck.normal;

Gives me an error on return saying its void and should therefore not have an expression after return, but... its not void is it?

#

Perhaps Im misunderstanding c# syntax

polar acorn
carmine turret
#

Ahh. so a normal would be float right?

#

for the angle

polar acorn
pliant marsh
rich adder
polar acorn
#

See what RaycastHit2D.normal is

carmine turret
#

gotcha

polar acorn
pliant marsh
rich adder
#

You have clear syntax issues

carmine turret
#

Vector2 it seems. thanks!

rich adder
#

or you didn't save

polar acorn
# pliant marsh

Yeah, you need to configure your !ide so you can see all of your syntax mistakes

eternal falconBOT
polar acorn
#

Also, what nav said I don't think you've saved your script

pliant marsh
#

everyone just told me that doesn't work

polar acorn
#

The import is still needed

novel void
#

i replied wrong person sorry

polar acorn
#

but you've got other syntax errors

pliant marsh
#

ok

polar acorn
#

and also you need to configure your IDE to see them

pliant marsh
#

ok

young lava
#

So I've been trying to implement a knockback system to my 2d top down game. For testing purposes, I just added this code to my player movement script. However, when I press the key, the player does not move. Was wondering if anyone knew the solution to my problem!

summer stump
polar acorn
young lava
#

ahhh yes i do

summer stump
#

You can either disable velocity setting for a time, use addforce for everything, or use adding to velocity with some kinda clamping

#

Probably other ways too that I can't think of

young lava
tender stag
#

better way to do this?cs IInteraction interaction = hit.collider.gameObject.GetComponentInParent<IInteraction>() ?? hit.collider.gameObject.GetComponentInChildren<IInteraction>();

#

the difference is GetComponentInParent and GetComponentInChildren

#

i want either that or the other

#

look through both

#

alright dont worry i got it

cosmic dagger
#

but yes, you can change this to avoid using GetComponent to search children or the parent . . .

tender stag
#

that the layout was the same anyways

#

i just got confused for a second

cosmic dagger
quartz mural
#

how comes this doesnt work?

rich adder
quartz mural
rich adder
#

could also do public bool IsPlayerUnit => isPlayerUnit;

quartz mural
#

nope

#

doesnt work

rich adder
swift crag
#

not the name of the variable the property tries to return

quartz mural
#

THAAAAAAAANKS

#

mb

#

sorry

swift crag
#

did you actually try it?

rich adder
quartz mural
#

no no its on me

#

oh wait i have a problem

#

isPlayerUnit is being used

quartz mural
#

but if i change the actual name

#

cuz there different

#

it dont work

#

acc sorry

rich adder
quartz mural
#

idk how#

#

but apprenlty i haev

#

im trying to use it in this script

#

so i need to do the get thing

rich adder
quartz mural
#

if i dont add the get thign at all

#

then there not linked so

#

so it cant access

rich adder
#

the error is telling you why thas wrong

quartz mural
#

lemme add the get thing

#

then ill show u

rich adder
#

ok

quartz mural
#

ok theres nothing wrong with tthe link

#

but when i use that variable

#

in the same script

#

its an error

#

and it sasyy

rich adder
#

please make a sentence at least before hitting send

quartz mural
rich adder