#💻┃code-beginner

1 messages · Page 379 of 1

modest quarry
#

how to make cinemachine camera not change its position on the y axis

#

like if i jump it should not look at me jump

#

i just want it to move along the z axis with player

#

not holding it looks good

carmine elbow
#
public class WaitForAnimation : CustomYieldInstruction
{
    private Animator animator;
    public override bool keepWaiting => animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1;
    
    public WaitForAnimation(Animator animator)
    {
        this.animator = animator;
    }
    
}

Anyone know why this doesn't work for my coroutine?

stable narwhal
#

Use the player gameobjects transform as reference

valid stone
#

what in the actual fuck?

#

I want it to be green (I'll deal with the size of all these squares later) but why is it showing white on the color tab?

eternal needle
valid stone
#

oh....

#

fair enough

#

sorry

ivory bobcat
# valid stone what in the actual fuck?

This is the beginning code channel, for non-code-beginner questions, try #💻┃unity-talk
Make sure to explain what the issue is. As for the color property in the inspector:

Define the vertex color of the Sprite, which tints or recolors the Sprite’s image. Use the color picker to set the vertex color of the rendered Sprite texture.

#

It would alter the color of a white cube - try it.

valid stone
#

it's technically code though....

#

since these are squares I created with code...

ivory bobcat
#

Implies it's an issue with code

valid stone
#

Ignore the vector for now

modest dust
#

You're changing the material color, not the SpriteRenderer color

#

so why do you expect the SpriteRenderer color to be anything else

timber tide
#

what is that instantiation lol

#

what is the issue here? Is it not green or is it

astral falcon
#

Maybe read along first mao 😄

timber tide
#

looks green in the scene though

#

changing color links to _Color too so it should work

astral falcon
#

Check the right side of the game view

timber tide
#

because spriteRender uses _Color for the vertex coloring

valid stone
#

oh ok I get it now

#

bro why is "uh" blocked by the server?

astral falcon
#

to avoid spam

valid stone
#

"......."

astral falcon
#

So still, wondering why all your boxes get green except the last column

timber tide
#

problem with doing it in the shader like that is it'll change the color for all sprite renders using that material

bold osprey
#

does any one have a double sided mesh collider script??

timber tide
#

so ideally change the sprite render's color property

valid stone
#

makes sense

#

well they're all the same color here but still

timber tide
# valid stone oh.....

Actually, it'll create a new sprite render material for each sprite unless you do sharedmaterial. Either way, don't change vertex color in the shader. (less of a problem in URP, but you still need to destroy the material if you aren't using them later)

astral falcon
bold osprey
#

kinda i mean like a double sided mesh for example this dome

#

if its not possible ill figure out another way

valid stone
#

ok new problem here

#

I know my code looks atrocious

#

but the point of it is to basically space out all the squares with the distance between the squares being n * their length (1/4 of their length in this case)

eternal needle
astral falcon
valid stone
#

but they aren't really aligned in the way I want them to be and the space between them certainly isn't 1/4th of their length

astral falcon
valid stone
#

what the

#

I made everything have f

#

this is literally the opposite of what I intended

#

I mean

#

the fact that the squares are in the camera is good

#

but why is the distance between squares bigger than the lengths of the squares themselves?

#

it's -1 -> 1 for x and -16/9 -> 16/9 for y btw if you're wondering about the size of the camera

#

oh I found the problem

#

I need to actually double the size for these guys

#

since in the instantiate, their vectors are multiplied by 2 or -2 and then have to them added -1 or 1 to convert from 0 -> 1, 0 -> 1 to -1 -> 1, 1 -> -1

#

magnificent

#

is that distance actually 1/4 though?

#

I think so yeah

#

I was scared that c# wouldn't allow variable array sizes but since it does I can do it with more than 10 x 10 squares now

teal viper
#

C# doesn't allow changing the array size. Unless you mean something else

crude bone
crisp gate
#

ah yes, the error || || my favourite! this should be easy to fix

wheat rune
#

!ide

eternal falconBOT
wheat rune
#

I've gone over the guide and looked at forums but intellisense is not working for vscode
it recognizes things like what a monobehavior is, and it autocompletes things like int var etc but like not void awake

summer creek
ivory bobcat
#

Make sure Visual Studio Editor is installed and up to date.

wheat rune
ivory bobcat
# wheat rune

Remove Visual Studio Code Editor, it's no longer necessary, obsolete and even conflicts with the newer Visual Studio Editor Package.

eternal needle
ivory bobcat
summer creek
eternal needle
eternal falconBOT
summer creek
#

what?

#

oh okey

summer creek
verbal dome
#

Why would it set isChasing to false when that method is only called when it already is false

summer creek
#

nop

queen adder
#

How can I make the movement of a dynamic rigidbody be precise and constant, instead of slowing down and smoothing out towards the end of the movement?

That does not happen with kinematic movement. But I need dynamic rigidbodies to have collision between characters.

eternal needle
# summer creek https://paste.myst.rs/nd1sgl16

I dont really see which part of this even tries to patrol. I suggest you add debugs, especially like Debug.DrawRay or DrawLine so you can visualize what direction this is trying to move and hopefully that clarify to you why its moving around like this. I suspect it might be do to it only moving in its transform.forward direction which isnt rotating fast enough. You could just have it move in the actual wanted direction instead of just forward. I do have to go so try to learn to add more debugs into what's happening

summer creek
verbal dome
#

One way to get "snappy" movement is to directly change rb.velocity instead

summer creek
hot palm
#

Any idea how this line caused a stack overflow?

OnHover?.Invoke();
#

On Hover is a

public UnityEvent OnHover;
languid spire
#

at a guess you have subscribed a method to the event which allso Invokes OnHover

hot palm
#

Interestingly enough it only happens with one specific instance of that class,

hot palm
#

Removing that fixed it xD

#

Idk why it was there to begin with, trying to revive an old project

#

Thanks a lot!

timber tide
#

Is there a way to declare a prefab as a variant of another if it's already instantiated

#

assuming the makeup of the prefab is similar enough

queen adder
verbal dome
#

Idk what else here would make you accelerate/decelerate over time

#

Showing your full script would help tho

vernal holly
#

I don't understand why is this not destroying the player.
Anything I missed?

verbal dome
simple harbor
#

im new to programming and what not but would someone please help me out with why my selection manager code keeps giving me the cs0246 error ive tried googling it but everything its telling me is something ive already tried

ivory bobcat
queen adder
simple harbor
#

this bit?

ivory bobcat
simple harbor
#

im so new i wouldnt know how to do that

ivory bobcat
#

Right click Text in your script and there should be an action that would allow you to add the missing directive - assuming your ide is properly configured.

simple harbor
#

umm ill see

#

it is not

verbal dome
ivory bobcat
# simple harbor it is not

You'll need to configure your !ide to get proper help on this discord server - part of the rules and it would solve most if not all minor mistakes/syntax-errors like this.

eternal falconBOT
simple harbor
#

oh right mad thank you

ivory bobcat
# simple harbor oh right mad thank you

Don't be afraid to ask for help on any concerns with the configuration though.
The common issues when installing VS or VSC are:

  • VS: user forgets to select the Unity Workload during installation
  • VSC: user needs to manually remove the VSC Editor package - it's obsolete and conflicts with the new VS Editor package.
simple harbor
#

i did it and its still not doing what you said it would when i right click can we call or something and you run me through it real quick

simple harbor
#

vscode

verbal dome
#

What unity version?

ivory bobcat
#

Assuming you've done the configuration steps already, show an image of your package manager

verbal dome
#

For example 2021.1.6f1 didnt work well with the new vscode package for me

#

But 2021 LTS works better

simple harbor
#

2022.3.32f1*

ivory bobcat
#

Show an image of your package manager. Visual Studio Editor should be installed.

simple harbor
#

it keeps locking

#

ill unlock it but i dont think it does anything

verbal dome
#

You still have the old package

simple harbor
#

oh

ivory bobcat
#

Update the Visual Studio Editor package and remove the Visual Studio Code Editor package - it's obsolete now and conflicts with the new Visual Studio package.

simple harbor
#

ok ill do that now

#

im gonna sound slow but hteres no update button or anything

#

and i cant even remove it if i wanted to

verbal dome
simple harbor
#

oh

#

ok

verbal dome
#

Does it not let you remove the other package?

simple harbor
#

no it doesnt

verbal dome
#

So the Remove button is greyed out?

simple harbor
#

yeah

verbal dome
#

Not sure then. Havent seen that lock icon myself - must be a unity 2022+ thing

simple harbor
#

what version are you on

#

and if i change to it would i ave to restart

verbal dome
#

2021.3.39f1

ivory bobcat
simple harbor
verbal dome
#

Okay so seems like the Engineering package is using that package

simple harbor
#

hm ok where would i change that

bleak condor
#

every time i add a box collider to my player, it breaks the movement

verbal dome
simple harbor
#

ight

verbal dome
simple harbor
#

did it

#

visual code stuidir afia editor of what ever it was called is gone

bleak condor
simple harbor
#

he means ss

verbal dome
#

No I don't

#

!code

eternal falconBOT
verbal dome
simple harbor
#

oh fair enough

ivory bobcat
simple harbor
#

ight

#

nothing popping up

ivory bobcat
simple harbor
verbal dome
#

And how does the movement break?

ivory bobcat
# simple harbor

go to Edit > Preferences > External Tools
and regenerate the project.

simple harbor
#

ight

#

it didnt do anything

ivory bobcat
#

Show a screen shot of your packages

simple harbor
verbal dome
#

Not sure if boxcollider2D supports negative scale, that could be an issue

bleak condor
verbal dome
#

Because that doesn't really say anything

bleak condor
verbal dome
#

What if you comment out the CheckForFlipping method?

#

// CheckForFlipping();

fringe plover
#

Found small visual bug, i made component script "Toggle", but inspector still shows UnityEngine.UI.Toggle script icon
P.S if i asign it it will change icon

verbal dome
ashen anchor
#

Okay

ivory bobcat
# simple harbor

I'm not sure why your ide isn't providing intellisense, auto complete and suggestions. Likely it isn't properly configured. Is Text underlined red?

simple harbor
#

no

ivory bobcat
#

Close your VSC Editor and reboot the Unity Editor

simple harbor
#

alright

bleak condor
wanton crater
#

guys i have this while loop in a "OnTriggerEnter" and i have this
WHY DOES UNITY CRASH EVERY TIME I COLLIDE WITH THIS

#

and if i remove the delay it dosent crash but it spawns every object at the same time which makes it kinda laggy so i added a delay and now it crashes

#

im so confused

fossil drum
#

Why is the while loop even there 🤔

wanton crater
#

so it repeats "number2" of times

#

you see its "while (i < number2)"

simple harbor
wanton crater
#

and it does i++ each turn

simple harbor
#

im gonna try reconfiguring it and see if that fixes anything

wanton crater
#

well in theory

fossil drum
eternal falconBOT
verbal dome
#

Because i < number2 wil stay true

wanton crater
#

that's whta im hoping for im making a delay

rich egret
#

how to fix it?

#

i mean, how to change to normal view?

burnt vapor
# rich egret how to fix it?

This is a coding channel. Either share relevant code or use the proper channel. Also, "how to fix it" is unclear.

fossil drum
wanton crater
#

does a for loop fix this?

verbal dome
wanton crater
fossil drum
#

If you use a while loop sure, you would need to yield it if you did that.

#

I think a good coroutine like osmal says is the best way.

verbal dome
#

Yep, gotta yield to make it wait a frame and give the values a chance to change

swift crag
simple harbor
#

show i use vscode or vsenterprise cause looking at the configuring ide it has both but im wondering if one is better then the other

swift crag
#

there is no such thing as "vsenterprise"

#

there's Visual Studio and Visual Studio Code

#

there are different versions of Visual Studio, yes, but they aren't unique code editors or something

simple harbor
#

yeah alright

swift crag
#

I use VSCode, personally

#

Both work well with Unity

simple harbor
#

alright ive followed the steps and what not but its still no configured properly

swift crag
#

did you really just go follow all of the steps for VSCode in the past 60 seconds

#

or do you mean you tried earlier? :p

verbal dome
#

This has been going on for a while

swift crag
#

oh boy

simple harbor
#

yeah

swift crag
#

okay, so show me your package manager window (showing the Visual Studio Editor package) and the External Tools settings

simple harbor
verbal dome
#

You have had that compile error for a while, maybe it is messing something up

swift crag
#

Yes, that will prevent new packages from activating

#

(or old ones from being removed)

simple harbor
#

its to do with what im coding which wa why i came here to begin with but then that editing thingo wont work so im stuck do i delete the script reset unity the redo it?

swift crag
#

Fix the error by adding using UnityEngine.UI; to the top of the offending script

simple harbor
#

nows theres more

#

im not sure what happened

swift crag
#

well, presumably you have not defined InteractableObject

#

let's try something else first, though

simple harbor
#

alright

swift crag
#

close VSCode, hit "Regenerate project files", and double click a script asset to re-open VSCode

wanton crater
#

oh

#

it works in a couroutine :D

swift crag
#

If it's not working, hit ctrl-shift-U to open the Output window

simple harbor
#

ight

swift crag
#

then switch it to C# and scroll up to the top of the log

wanton crater
swift crag
#

Correct.

#

Starting a coroutine does nothing.

#

It does not "delay" the method that started it

#

otherwise your game would freeze

swift crag
simple harbor
#

i cant find that C# thing but shouldnt it already be C#

swift crag
#

screenshot your entire VSCode window.

simple harbor
#

and all of a sudden the dev kit has an error everything is fuck stuffing up

swift crag
#

This is the dropdown I was pointing to.

simple harbor
#

fuck im slow

swift crag
#

It's possible that the .NET Install Tool is having a problem. That would prevent the editor from working.

simple harbor
#

possible

swift crag
#

I'll also need to see the installed Unity extension

simple harbor
swift crag
#

okay, so that's present

#

so, what do you see in the C# output window? My editor spits out something like this

simple harbor
swift crag
#

well that mostly seems fine

#

although it hasn't found any projects

simple harbor
#

hmm yeah idk

swift crag
#

i'd whack it with the "restart computer" stick before continuing

simple harbor
#

ight ill see what that does

deft grail
#

thats why people dont use VSCode

#

VS is easier to setup

verbal dome
#

If you didnt restart unity and vscode after you fixed the compiler errors, I would definitely do that

swift crag
#

although, it also doesn't exist at all on my mac

#

which is a more pressing concern

verbal dome
#

Sadly visual studio often hangs for me especially in a large project

swift crag
#

it's very very obviously a 3000 year old IDE

cosmic dagger
swift crag
#

I used it for C++, because VSCode's C++ extension can't grok templates at all

simple harbor
swift crag
#

That dotnet path looks wrong

#

Did you manually add something to your %PATH% variable?

simple harbor
#

No should’ve have

cosmic dagger
swift crag
verbal dome
#

Oh or you mean you gave up on that and started learning c++?

swift crag
#

"I gave up and started learning C++" is a dreadful sentence

cosmic dagger
verbal dome
#

I see

cosmic dagger
simple harbor
swift crag
#

That's fine, then

#

oh, one thing

#

run dotnet --info

#

maybe this is an ancient version of dotnet

cosmic dagger
simple harbor
swift crag
#

that's the same version I'm using, so presumably it's fine

simple harbor
#

yeah

sage wyvern
#

guys i have a code for basic movement but when i crouch my flashlight becomes smaller and goes higher

#

how do i fix this

swift crag
sage wyvern
#

this happens

swift crag
#

click the vertical dots button there

sage wyvern
swift crag
#

I'm guessing you're scaling down playerBody when you crouch

simple harbor
swift crag
#

that's going to scale everything parented to playerBody

#

Are you trying to reduce the size of a CharacterController or something?

swift crag
simple harbor
swift crag
#

you can change the size of the character controller without scaling playerBody

#

just change the height and center of the character controller

sage wyvern
swift crag
#

I'm a little fuzzy on that

simple harbor
#

hmm ill install the sdk again

swift crag
#

then restart after the installation

sage wyvern
swift crag
#

all of the questions I found asking about this particular line:

The application 'restore' does not exist.

say that this'll happen if you don't have the SDK

swift crag
sage wyvern
# swift crag yes, because you need to adjust the camera's position as well

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

public class movement : MonoBehaviour
{

public CharacterController controller;


public float walkSpeed = 12f;
public float sprintSpeed = 20f;
public float crouchSpeed = 8f;

public float speed = 12f;
public float gravity = -19.62f;
public float jumpHeight = 3f;

public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;

public Vector3 velocity;
public bool isGrounded;
public float playerHeight = 1f;
public float crouchHeight = .4f;

[System.NonSerialized]
public bool crouching = false;
private bool goDown;

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


    //Crouching

     if(Input.GetKeyDown(KeyCode.LeftControl)) 
    {
        crouching = true;
        goDown = true;
        speed = crouchSpeed;
    }
    else if (Input.GetKeyUp(KeyCode.LeftControl))
    {
        crouching = false;
    }

    if (crouching && goDown)
    {
        transform.localScale = new Vector3(1f, crouchHeight, 1f);
        goDown = false;
    }
    else if (!crouching && !goDown)
    {
        transform.localScale = new Vector3(1f, playerHeight, 1f);
    }
}
simple harbor
#

alright done

sage wyvern
#

this is my crouching code

#

i could put the rest in cuz of dc

swift crag
#

!code

eternal falconBOT
sage wyvern
#

this is the complete code

swift crag
sage wyvern
simple harbor
sage wyvern
#

this better

swift crag
#

that's going to cause everything that's parented to it to get squished

#

You should change the height and center of the character controller.

#

Then you need to move the camera up and down so that it's in the right spot

sage wyvern
swift crag
#

Try playing with the height and center in the inspector

#

That will show you the values you need to use

#

(the center should basically just be Vector3.up * height / 2)

simple harbor
#

alight fen is there anything else i needa try

swift crag
#

run dotnet restore in your terminal

#

you should get an error about not providing a project file

sage wyvern
simple harbor
swift crag
#

okay, that looks fine

swift crag
#

everything will stay in the same place

swift crag
sage wyvern
swift crag
#

i don't know what you mean by "what should i do with my crouch"

#

i just described how to make your character controller shorter

simple harbor
sage wyvern
#

playerheight = 1f

#

crouchheight = .4f

swift crag
sage wyvern
#

but idk how to do any of that

swift crag
#

if you have no idea how to change a few fields on a character controller, you might want to stop and switch to some !learn tutorials first

eternal falconBOT
#

:teacher: Unity Learn ↗

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

swift crag
#

that's very odd

simple harbor
#

ight

#

mb i was just having a smoke

swift crag
#

okay, so it now reports that you have a .NET SDK installed (it previously didn't)

simple harbor
#

alright finally getting somewhere lol

swift crag
#

and for a sanity check, show me "dotnet.exe" --info

#

i'm pretty sure that's identical to dotnet.exe --info on Windows, but, you know

#

might as well make sure

rotund sinew
#

I have some buttons that once clicked I want to desactivate I want them to disappear and not be visible, but when I do, it doesn't work, here is the code:

public class UIManager : MonoBehaviour {
    [SerializeField] private Button startServerButton;
    [SerializeField] private Button startClientButton;
    [SerializeField] private Button goBackButton;
    [SerializeField] private Image connectionMenuBackground;

    [SerializeField] private TextMeshProUGUI playersInGameText;

    [SerializeField] private Camera connectionMenuCamera;


    private void Awake() { Cursor.visible = true; }

    private void Start() {
        playersInGameText.enabled = false;

        startServerButton.onClick.AddListener(() => {
            if (NetworkManager.Singleton.StartServer()) {
                Debug.Log("Server started...");
            } else { Debug.Log("Server couldn't be started..."); }

            startServerButton.enabled = false;
            startClientButton.enabled = false;
            goBackButton.enabled = false;
            connectionMenuBackground.enabled = false;
            connectionMenuCamera.enabled = false;
            playersInGameText.enabled = true;
        });

        startClientButton.onClick.AddListener(() => {
            if (NetworkManager.Singleton.StartClient()) {
                Debug.Log("Client started...");
            } else { Debug.Log("Client couldn't be started..."); }

            startServerButton.enabled = false;
            startClientButton.enabled = false;
            goBackButton.enabled = false;
            connectionMenuBackground.enabled = false;
            connectionMenuCamera.enabled = false;
            playersInGameText.enabled = true;
        });
    }
}
#

They are not clickable, just still visible

simple harbor
swift crag
#

disabling the Button component doesn't stop it from showing up. You can deactivate the entire game object, though

swift crag
simple harbor
#

no was i supossed to do that?\

swift crag
#

i forgot to mention it

simple harbor
#

ah ok ill do that real quick

swift crag
#

I wonder if VSCode is still hanging onto something from before the install

simple harbor
#

ight done

#

there was an update

#

yo i think you did something

#

these red squwiggles werent there before

halcyon geyser
#

Doesnt like like Unity is connected ur IDE anymore

willow scroll
simple harbor
#

well when i double clicked on thingo it came up with vscode so i think its still working

lavish gate
#

i dont think this should throw an error? (trying to make an editor)

willow scroll
verbal dome
lavish gate
swift crag
simple harbor
#

yeah but it still wont fix my issue

swift crag
#

your issue was that your IDE wasn't working :p

#

i guess you just have another issue now

#

so what is InteractableObject?

#

where is it defined?

simple harbor
#

im sorry what do you mean

swift crag
#

You're trying to use a type called InteractableObject.

simple harbor
#

yes

swift crag
#

So what is it?

#

Where did you define that class?

crisp gate
#

anyone know a fix to this?

simple harbor
#

!code

eternal falconBOT
simple harbor
shell kernel
#

So I have a 2D-Platformer and i want the camera to follow the player, i got a script cameracontroller like this:

using UnityEngine;

public class CameraContoller : MonoBehaviour
{

[SerializeField] private Transform player;


private void update()
{
    transform.position = new Vector3(player.position.x , transform.position.y, transform.position.z);
}

}

but it doen't work, what can I change to get it work?

simple harbor
#

i still dont really know what you mean sorry im knackered

shell kernel
#

ohh thx

languid spire
swift crag
#

so where is the code that declares a class called InteractableObject?

simple harbor
#

oh i dont have one

swift crag
#

then why did you expect any of this to work?

#

you can't just make up random names that don't exist

simple harbor
#

well actually i assumed it would be my crossair thing

swift crag
#

neither Unity nor C# are magical

#

they can't just guess what you meant

simple harbor
#

oh wait im slow its my interaction info ui thats the class its supposed to be

#

i fixed it

brave pecan
#

Hey guys, a few days ago i asked about my game doesnt work correctly when i builded. (But it works in unity editor). When i build for WebGL, it works perfectly. But for windows or android, it returns Null error when i play. Also If I build other than webgl, i get an error like this :

#

What to do?

vernal bone
#

I'm loosing my mind.
I want to make a bullet to ricochet from walls. But i'm using kinematic rigidbody.
Is there any good way to SetRotation of Rigidbody2D by Vector2?
Or i'm better off with turning it to dynamic and use velocity? Cuz that works.

vernal bone
# wintry quarry Vector2.Reflect

I mean, yeah, but how to translate it to rotation angle for rigidbody?
Like, i have two vector2 variables(reflect and current transform.right)

ivory bobcat
#

What's the issue? Why would you need to rotate it? Can't you just set the forward direction?

#

Or rather right, with 2d.

vernal bone
#

But is it really ok to modify transform and not rigidbody?
And can you just do that like transform.right = reflect?

ivory bobcat
#

Where forward would be your unchanged forward and up would be your new up relative to the reflection.

vernal bone
#

Doesn't seem to work like it should.
I'll stick with dynamic and velocity i guess

tough trench
#

I just started Unity and I'm trying to make a game like Cookie Clicker. I have a button that changes the workerShopActive bool but when I start the game the worker buttons are the only thing that shows, and it says "worker" in the console. When i click the button both button types are not active and it still says worker in the console. does anyone know how to help

polar acorn
tough trench
wintry quarry
queen adder
#

how do i get out of this mode?

verbal dome
polar acorn
#

Nothing here seems to reference any other buttons

wintry quarry
#

or right click the game window tab and un maximize

#

or double click it

queen adder
#

k ty

tough trench
#

in the same script the bool isWorkerButton will change the text it needs how much you can buy of an item and when to show in the shop.

mortal sigil
#

Hi

#

Me and a friend were trying to code

#

How to solve this?

#

It says "there should be a }"

ivory bobcat
#

You're probably missing a }

#

Can't really tell without you actually showing the rest of the code

mortal sigil
#

It would be suggestive content

#

Cause we named the objects

#

Kind of explicit ways

#

So idk if i can

ivory bobcat
#

For every { you need a }

mortal sigil
#

Ok ill see

modest dust
#

Just add a } at the end of the script, the error is pretty straightforward

#

I'm surprised you didn't just try it out after reading the error

tender breach
queen adder
#

how do i fix the project settings bug? (atleast i think its a bug)

slender nymph
#

wdym "the project settings bug"

queen adder
#

it doesnt show

polar acorn
brave pecan
slender nymph
polar acorn
queen adder
swift crag
#

I wonder if Windows threw the window way off screen

slender nymph
#

you do realize that this is a code channel right? and have you tried restarting unity?

swift crag
#

try hitting win-left or win-right after trying to open the settings

tender breach
polar acorn
#

See what they are at that point

queen adder
#

whats happening with the task bar tf

polar acorn
#

that looks like default windows 11 settings

queen adder
swift crag
#

this is not a windows support server

vale olive
#

hello guys i am having a little issue in here, the first print is working good but the sencond if is not getting, can someone help me please?

swift crag
wintry quarry
swift crag
#

unless Isco is itself a game object, I guess

vale olive
#

yes Isco is a game object

#

and i want it to destroy

swift crag
#

i'm very confused by Isco.gameObject.GetComponent<Isco>()

wintry quarry
swift crag
#

the first one is a variable and the second one is the name of a class

vale olive
#

so how do i correct it?

wintry quarry
#

debug your code

vale olive
#

i dont know how to do it, that why i am here ahha

wintry quarry
#

Debug.Log is a good way

polar acorn
wintry quarry
#

Log more than just some static word. Log the values of the things you are checking in your if statements

polar acorn
#

that way you can see if those conditions are true

vale olive
#

how log works?

wintry quarry
#

It prints whatever you give it to the console window

vale olive
#

Like this: Debug.Log(Isco.transform.GetChild(0) != null);

polar acorn
#

Sure

#

That'd print true or false

vale olive
#

okay i am gonna try

verbal dome
vale olive
#

it is not printing anything with that code

wintry quarry
polar acorn
wintry quarry
#

this tells you a lot of information

vale olive
#

the ocupado thing is working, the getcild insn´t

polar acorn
# vale olive

So, it never reaches that line, meaning the first condition is not true

polar acorn
slender nymph
# vale olive

if "the ocupado thing" is working then you'd see both of those logs in the console

vale olive
wintry quarry
slender nymph
vale olive
#

with this code, i want to swith Isco with the child of his. how can i do it ?

#

someone help plase?

swift crag
#

can you explain what you're actually trying to make your game do

#

nothing about components or game objects

cosmic dagger
vale olive
#

it is a fiching game, when the fish is in the bait and collied with the boat, i want it to desapeer

#

when the bait reach the fish, the fich becomes its child

#

so i only want to make the child desapeed

#

desapear

swift crag
#

okay, so why are you destroying Isco?

#

destroy the child

#
Destroy(Isco.transform.GetChild(0).gameObject);
#

(you can't destroy a Transform)

vale olive
#

ok that is what i need it

swift crag
#

making the bait the child of the fish or something

vale olive
#

let me try the code you send

cosmic dagger
#

GetChild returns a Transform. you need to get the GameObject from the Transform and destroy that . . .

bright siren
#

Technically transform is a component so you can destroy, but... Unity is weird

vale olive
#

the code you send his working, but one more thing

#

after the fisch desapear i want to continue fishing the other fish and that is not working

slender nymph
bright siren
cosmic dagger
vale olive
astral falcon
slender nymph
cosmic dagger
vale olive
#

okay okay sorry dude i wait

cosmic dagger
astral falcon
# vale olive i said in that message

No you did not. Youdid not show any code besides the destroy one and therefore we do not know what you tried already. or if you did not write any code yet and asking here for code snippets

neat scarab
#

essentialy i think he's asking that he wants to repeat the destory object more then once

vale olive
#

the only code i use to destroy the game object is this one

cosmic dagger
#

again, how is it not working? obviously you have code, but we do not have your code. you need to provide the code to show us what you did. then we can help provide answers for why it's not working . . .

swift crag
#

where do you reset the Ocupado variable?

#

it's clearly important here

vale olive
#

i dont, i dont know how to reset that and the destroy

swift crag
#

i don't know what it means or where you assign it

#

so it's hard to say much

vale olive
#

ocupado is a bool variable

#

what you need to know?

cosmic dagger
#

i only see code for attempting to destroy a child. i don't see anything about wanting to continue fishing or what that code looks like . . .

vale olive
astral falcon
#

I feel like the very basics are missing here. Either from your code or from your knowledge.

vale olive
#

that is*

#

probably both

#

i am a very begginer

#

so yh

astral falcon
#

I propose you visiting unity learn platform and get the basic tutorials going to get a grasp of how everything works and is tied together

vale olive
#

this is the last thing i need i am with a very short deadline, if you could just help, i would apreciate

astral falcon
#

Im not gonna write code for you, sorry. If you try and come back here with whatever you tested, people will help. But noones gonna write the code for you, but maybe someone is willing to.

swift crag
#

correct

vale olive
#

i did this with a timer, the format is giving me error, can help with this?

slender nymph
#

look real hard at what you are passing as the first parameter

vale olive
#

ohhh

#

i see it

shell kernel
#
using UnityEngine;

public class Healthbar : MonoBehaviour
{
    [SerializeField] private Health playerHealth;
    [SerializeField] private Image totalHealthbar;
    [SerializeField] private Image currentHealthbar;

    private void Start()
   {
        totalHealthbar.fillAmount = playerHealth.currentHealth / 10;
   }

    private void Update()
    {
        currentHealthbar.fillAmount = playerHealth.currentHealth / 10;
    }
}```


Assets\Scripts\Health\Healthbar.cs(6,30): error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\Health\Healthbar.cs(7,30): error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)

So what is wrong with "Image". I don't get it, because I need Images there.
eternal falconBOT
astral falcon
#

!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)

cosmic dagger
verbal dome
#

You didn't even bother to ask a question

#

Btw you are multiplying with deltaTime twice

#

And speed too

astral falcon
#

It walks exactly as you set it up. What do you mean by strangely?

#

Can you please provide some information. We do not see your screen or anything... give some effort in describing

slender bridge
#

you are moving so slow because you have multiplied your speed down to probably near zero. what did you change after Osmal said you were using delta time a million times?

cosmic dagger
#

are we supposed to know what, "walks like in a movie," means?

slender bridge
#

and what is the value of speed ?

#

im confused on the comma

#

do you mean 7.58

#

well have you tried to increase your value in the inspector and see what happens ?

#

You should go look at some tutorials on simple 3d movement. There are a few things that stand out from your code. One being your values need to be normalized so it fixes diagonal movement speed, and two, You will likely run into issues using Translate and your physics/colliders.

astral falcon
#

Google

slender bridge
#

Your new video shows you moving faster? So whats your problem now? Walking throuh walls ?

rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

astral falcon
rich adder
#

the code is working, you're phasing through walls which is the problem of using Translation

vale olive
#

in here, doing scenes connection, what do i put inside the parentheses

rich adder
#

show your players Gizmos in local space mode

slender bridge
#

your are likely not rotating your player to your cameras forward transform

rich adder
#

it literally tells you

astral falcon
rich adder
#

in the scene, to make sure your forward facing is correct in the first place

#

I cant tell if you're in Global or local mode

#

show the whole screenshot , no crop

verbal dome
#

Local because the orientation gizmo in top right points in different direction thinksmart

rich adder
#

ok so the forward seems correct

astral falcon
#

its not in playmode, you should show your gizmo when you turned your camera view

slender bridge
#

Your player is not automatically just going to go forward in the direction your camera is facing when hitting W unless you rotate it to match the camera.

rich adder
#

just realized you're not even doing transform.forward * vertInput

#

you're using world Z

#

first of all you have a rigidbody, dont use translate

carmine narwhal
#

I found a free site in my native language, whit exercises

slender bridge
#

Please take the advice of going to learn basic movement via unity learn or youtube

verbal dome
rich adder
#

velocity or addforce, using the rigidbody component

rich adder
#

good to know. I barely use it 😅

verbal dome
#

I get it mixed up too

slender bridge
#

I don't think i have ever used Translate once.

rich adder
#

rb.AddForce should be in FixedUpdate, you prob want to specificy a force mode

#

also if you dont lock rigidbody rotation on X/Z this will flip your player

#

no Inputs should never be in FixedUpdate

#

thats why i said rb.AddForce should be in FixedUpdate,

slender bridge
#

You generally get input from update and apply physics in fixed update. Also it may be better to modify the .velocity to move your character and if you want abrupt starting and stopping movement use GetAxisRaw

verbal dome
#

Now you should remove * Time.deltaTime because AddForce is already scaled with delta time

#

Make sure to adjust speed to a smaller number after that

rich adder
#

yup thats why your Z barely moves

#

the Time.deltaTime on rigidbody

#

are you rotating the camera individually from the player ?

#

that does not answer my question the slightest

#

show your rotation code

#

any rotation you got sure

#

how many other things are you rotating 🤔

swift crag
#

The player is not rotating. The camera rotation doesn't matter whatsoever.

#

unless you've attached this component to the camera, of course

rich adder
#

so ur rotating both indivudually

summer stump
#

Not sure if it was mentioned, but remove the deltaTime from your mouse input calcs

rich adder
#

oof moment

swift crag
#

This code doesn't care about how anything is rotated. It applies force in the X and Z directions.

#

The rotation of the player and the camera mean nothing.

rich adder
#

it does if they're looking in the wrong direction while moving

swift crag
#

Pressing W moves you right because that's the direction the world Z axis is pointing

verbal dome
#

You have MouseX = -90 which makes your camera rotation different anyway

swift crag
#

you're moving in the direction of the blue cone, no matter what you do with your camera or player

verbal dome
#

Which explains the seemingly flipped X and Z movement

swift crag
#

yeah, and the -90 is clearly there to make you start out looking down the hallway

#

since a -90 degree rotation on the Y axis rotates you to the left

#

You need to make it so that you move in the direction you are looking.

#

not just a fixed direction

rich adder
swift crag
#

Calculate a movement vector by using your forward and right directions.

#
Vector3 move = Vector3.zero;
move += transform.forward * Input.GetAxis("Vertical");
move += transform.right * Input.GetAxis("Horizontal");
move *= speed;
move *= Time.deltaTime;

This would be reasonable.

#

(yes, it's missing a clamp so that diagonal movement isn't faster)

#

well, you'd then need to use that vector

#

you can store it in a variable and use it in FixedUpdate

#

If you do that, get rid of the Time.deltaTime line

#

AddForce can be given a vector

summer stump
#

No. You pass the vector INTO AddForce

#

Change it back, remove the x, 0, z and instead use the vector you made

swift crag
#

which you store in a variable, just like you're currently storing x and z

#

if you don't know how to write C#, you should really stop what you're doing and use !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

No

#

You did not name your vector Vector3

modest dust
#

Dear lord almighty, go learn the basics first instead of blindly guessing

slender bridge
#

As a developer, you have to stop asking "like this?" and learn the basics, make informed code changes, test your changes, ask yourself, is this behavior correct?, if not, understand more , rinse and repeat that process. YOU need to be the problem solver!

swift crag
#

you need to have a basic level of understanding

#

we can't write your entire game for you, nor can we help you write every single line of code

slender nymph
#

if you are asking "like this" and clearly have red underlines in the code, the answer is always "no"

summer stump
#

No "buts", this is very simple.

timber tide
#

do it first and fail then come back

modest dust
#

Nothing, go and !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

You have been told explicitly what to do.

#

You do not have the foundation needed in order to understand it though

rich adder
#

us telling you the line to write there will nothing to your learning

timber tide
#

actually, start with c# first and forgo unity for now

summer stump
#

So you need to build that foundation

rich adder
#

You don't try to drive without taking some lessons first

summer stump
#

Pass the vector you made into AddForce 🤷‍♂️

rich adder
#

you will spend hours on it because you don't understand the basics

modest dust
#

No reason to answer your question if you won't understand it, just copy it, and later come back with more basic issues which wouldn't exist if you took your time to actually learn something

languid spire
#

it wasn't even your walking. You copy/paste without understanding anything

cosmic quail
#

fun fact, you can hover the method (AddForce) and it tells you what kind of parameter it takes in (but yeah u gotta watch some tutorial videos and learn the basics)

rich adder
#

"whats a parameter ? "

cosmic quail
#

the thing you put in the parentheses 😝

slender bridge
#

like this ? (parameter)

swift crag
#

to be pedantic, the thing you pass to the function is an argument

#

the function has parameters

#

but i digress

slender bridge
#

listen here Fen, don't be using that tone with us... its not nice

#

you definately gotta be trolling now

rich adder
#

you wasting more time doing it wrong than learning it once how to do it right..

#

this mentality makes no sense to me

cosmic quail
#

you should go and look up a unity tutorial on youtube

languid spire
summer stump
cosmic quail
rich adder
#

so you see how a vector3 is passed in translate there? its not different than the one in AddForce

#

they both want V3 as direction.

#

put 2 and 2 together

swift crag
#

this example is taking three arguments

#

player.Translate works in the local space of the transform by default, unlike AddForce, which is working in world space

#

i suppose you could just use AddForceRelative

cosmic quail
#

oh the youtube tutorial is telling you to use Translate? sorry wasnt reading the conversation earlier. yeah that tutorial is bad, better use aethenosity's links instead

rich adder
#

you made a separete variable for it called move.

#

its just that is local..

modest dust
#

Either way, if this is your level of programming knowledge then even if you get past the youtube tutorials, you won't be able to make anything of your own (clearly seen here) and instead you'll just spend hours wasting your time (like right now). Just... spend a few god damn days and learn the basics from scratch. C#, then Unity. Most of your issues will be gone.

swift crag
#

oh right, it's AddRelativeForce

queen adder
#

anyone know why this isnt working, im tryna send a player id through my webhook and its just giving me a 400 bad request error:

     private void SendWebhook()
      {
          string playerId = PlayerPrefs.GetString("PlayerID");
          if (string.IsNullOrEmpty(playerId))
          {
              Debug.LogError("Player ID is missing or empty.");
              return;
          }

          StartCoroutine(SendWebhookCoroutine(playerId));
      }

      private IEnumerator SendWebhookCoroutine(string playerId)
      {
          WWWForm form = new WWWForm();
          form.AddField("Player ID", playerId);

          UnityWebRequest request = UnityWebRequest.Post(WEBHOOK_URL, form);
          yield return request.SendWebRequest();

          if (request.result != UnityWebRequest.Result.Success)
          {
              Debug.LogError("Failed to send webhook: " + request.error);
          }
          else
          {
              Debug.Log("Webhook sent successfully.");
          }
      }```
swift crag
#

perhaps your request is bad, then

#

although 404 is not a "bad request"

#

that means "not found"

slender bridge
#

404 is not found

queen adder
#

i mean 400

slender bridge
#

form field Player ID is suspect

queen adder
slender bridge
#

and to my knowledge your key Player ID i don't believe should work

rich adder
#

check if blocked first or just move using a character controller

torpid snow
#

I know this isnt exactly coding, but how do i move the blue circle on my sprite? Im using cinemachine to track my character sprite however the blue circle it tracks is way off and idk how to move it and i cant find anything online.

rich adder
torpid snow
torpid snow
summer stump
rich adder
#

I'm confused by your original question, do you want to move to a spot if its not blocked ?

#

idk wat you mean by " can i make colliders work with offsetting the player "

cosmic quail
#

cant you use a rigidbody for movement instead?

rich adder
#

or character controller

#

you're going to have to not reply "huh" and "wdym" and actually inquire to clear up what your confusion is on

cosmic quail
#

to have collisions, you gotta put a rigidbody component (and a collider) on your player and then instead of changing transform.position you do rigidbody.moveposition instead, for example

wintry quarry
#

Use CharacterController or Rigidbody based movement

#

both will respect collisions

rich adder
#

those two controller respect physics ^^ aka colliders

wintry quarry
#

(btw MovePosition does NOT respect collisions)

#

you would need to move via velocity or using forces

cosmic quail
rich adder
wintry quarry
rich adder
#

I could've sworn MovePosition does not and indeed it didn't after they test 😛

slender bridge
wintry quarry
cosmic quail
#

oh, kinematic enabled means it doesnt?

#

according to navarone's link

wintry quarry
#

kinematic bodies are a whole different story - they don't respect collisions at all they are unstoppable forces

swift crag
#

you will respect the collider -- but not in the gentle way (:

#

you'll respect it by going flying at 30 trillion miles per hour

rich adder
#

nope

wintry quarry
#

My own quote in which I am wrong lmao

rich adder
wintry quarry
#

haha

cosmic quail
rich adder
#

so if you already have a rigidbody use that?

slender bridge
#

if you use character controller, you have to simulate gravity. but character controller has a few out of the box features that make it somewhat easier than rigidbody, but thats still debatable.

zinc kite
#

do I need to be making an input manager with the new input system unity? what is even the purpose of an input manager?

rich adder
#

you don't "need" it

wintry quarry
# cosmic quail wait now i am confused. whats the truth then 😂

MovePosition:

  • If you're kinematic, you will naturally push other objects out of the way correctly (this is good, it was designed for this)
  • But you will be allowed to move inside walls if you are dynamic, and you will get pushed out. Which is not the same as not being able to move into them in the first place
zinc kite
rich adder
#

yes but you're not applying offset to the Rigidbody component, you're doing it to the Transforms directly (which is the same as teleporting)

wintry quarry
#

You should be using the Rigidbody for everything, not just the jumping

cosmic quail
wintry quarry
#

no, velocity or forces

wintry quarry
#

it will go right through the wall

rich adder
cosmic quail
#

but non kinematic means it stops correctly then?

rich adder
#

no as PraetorBlue said, its only because the dynamic is trying to fix the intersecting of you basically teleproing into wall

#

so its pushing it out of the wall

#

I always assumed MovePosition mentiones its a method to move kinematic , i think its meant for that mainly

cosmic quail
#

ok that is weird, i remember someone explaining that moveposition works with collisions because under the hood it actually checks collisions properly while moving it or something. its good to know that its not the case

rich adder
#

maybe they got confused, because you can use Move Position to push other rigidbodies

#

so there is some calculations there for collisions, just not from you. Other rbs

#

they just know where the kinematic is I suppose

#

bruh.. why are you still setting position on the transform

#

we're going in circles

#

how you expect to fix it if you keep doing it wrong

#

we gave you already the advice how to do it

slender bridge
#

You aren't desperate enough to go learn the basics. Or to even understand why you are doing what you are doing.

rich adder
#

desperation fuels excellence

slender bridge
#

Your inability consumes you

swift crag
#

throwing random statements at the wall will not produce a working game

late burrow
#

when i want something like .indexof and to use it in other function does it matter whether i pass int or a list to run indexof on

slender bridge
swift crag
#

i don't really understand your question

rich adder
timber tide
#

MovePosition is garbo and you might as well just use character controller

polar acorn
late burrow
#

idk if list or array

#

whatever that does that

#

i can always .toarray

swift crag
#

this is an ill-posed question

#

it does not make any sense

rich adder
#

int.IndexOf like what?

swift crag
#

if you want to use a method from a class, you'd better have an object of that type

late burrow
#

its question about does it matter if i pass small int or huge array through function

swift crag
#

are you asking if passing an array or list to a function copies it?

#

it does not

late burrow
#

since in array case i believe it could be copied as its kind of primitive

rich adder
#

what is the end goal here?

languid spire
swift crag
#

arrays are not value types

polar acorn
late burrow
#

so same performance ok

rich adder
#

is there issue if you pass everyone the address to the same Building ?

languid spire
#

int is 32 bite. A reference is 64 bits. Not quite the same but very little difference

late burrow
#

yeah just in case of passing 1000 entries long list its always good to ask

polar acorn
#

When in doubt, you could always profile it and see

late burrow
#

i dont believe profiler

languid spire
polar acorn
rich adder
#

it can have whatever quanitity it makes no difference to passing the list around

zinc kite
#

How can i approach Singletons in a local multiplayer game.

rich adder
#

the same way you do it for single player?

#

what makes you think anything changes ?

swift crag
#

perhaps you want something that isn't actually a singleton

#

but rather something that has one instance per player

rich adder
#

also by "local multiplayer" do you mean couch multiplayer/coop

eternal needle
#

Either one, whichever suits your game more. addForce may be trickier to use initially, because you'll need to handle actually slowing the player down. Directly setting velocity to what you want is easier but then you might end up ignoring collision forces

rich adder
#

"setting velocity it obviously didnt work since its same as offsetting atp"

#

wdym by this

#

show what you wrote

#

setting velocity is definitely not the same as setting the trasnforms directly

eternal needle
#

Yea I didnt see the code if it was posted before so I have no clue what you mean

rich adder
#

never seen new code or changes they did

eternal needle
#

Oh

rich adder
#

supposedly the rigidbody is already there for AddForce jump

zinc kite
zinc kite
eternal needle
#

"The manager", which one? Also why does your player need to be a singleton in the first place

rich adder
#

or actual networking

zinc kite
rich adder
#

so if its a singleton you only need 1 , why are you spawning "per-player"

rich adder
#

why does manager need to be "per-player"

swift crag
#

if it's a game-wide manager (e.g. something that controls the match timer), there is only one instance, no matter how many players you have

rich adder
#

this is widly easier since you're only dealing with the same build running

swift crag
#

if it's something player-specific, then it obviously can't be a singleton anymore

#

each player has its own instance

#

in that case, you'd either have each player reference their object, or have a singleton that you can ask for a player's object

zinc kite
timber tide
#

GameManager.Instance.Players[0]

rich adder
#

add players through a list, and just loop through each one

swift crag
#

each player has health. health is a property of the player.

rich adder
#

your manager can get info from multiple players at the same time

#

since they all have the same props anyway

zinc kite
#

oooh, okay.I think i get it now

#

I will try to prototype something out. Thank a lot ❤️❤️

rich adder
#

You probably want to look into events here

#

put an event to when your stats changed and react to changes accordingly

#

each player has their own event when something happens (health changes etc..)

tame parcel
#

hey guys noob question how i make this sword stay stuck to his hand, when the character does a animation the sword just stays still doesnt move

timber tide
#

is it rigged such that the sword doesnt move in any key points of the animation

#

also not really a codding question

tame parcel
#

where should i ask then

quick swift
#

Hey guys! Need some help with my object pickup. I am in for 3 hrs on this and still can't get it to work. The reachtool I've created detects in console the objects ready for pickup , but nor the text appears (pickup) neither can pick the object

kindred pollen
#

am i allowed to ask questions abt scripting for a unity 2d project here or am i missing a channel?

timber tide
#

if it's code and not editor tool specific then this would be the place

kindred pollen
#

awesome

wintry quarry
kindred pollen
#

i am like, extremely new to coding and especially C# (I only have minor javascript experience) so I've been trying to learn off YouTube tutorials. I just completed my first remake of Tetris, but I can't figure out how to properly script a game over. The tutorials i've followed have become a little useless since I mashed together a bunch of them to create my tetris. I'm assuming this is probably really simple and im just way over my head in terms of knowledge.

this is the script i use for behaviors on the tetris blocks themselves: https://hatebin.com/epsqtjubws

this is what i use to control spawning the pieces: https://hatebin.com/fjqknvijut

#

can anyone help me figure out a way to trigger a game over since my code is kinda all over the place.

timber tide
kindred pollen
#

thats how i figured i should do it but im honestly not sure how to actually do that in C# :(

#

like i know the absolute basics and thats it

timber tide
#

what would be the indicies for the top most row

#

iterate over them every frame and check if there is something occupying them

#

or, when you set the blocks, check if it's one of those indicies. Either way works honestly

rocky patio
polar acorn
#

Probably because it's facing backwards

rich adder
#

anything rigidbody movement related goes in FixedUpdate

lethal bolt
#

Is there an way to do this?

rich adder
lethal bolt
#

oh

rocky patio
wintry quarry
rocky patio
#

Or height + 1

rich adder
polar acorn
lethal bolt
rich adder
polar acorn
#

Show a screenshot of the player selected with the transform arrows visible, in both local and global modes

kindred pollen
neon marlin
#

How would i go about getting the euler angle between two Vector3s?

timber tide
#

angle

neon marlin
#

is angle the same as a euler angle

swift crag
neon marlin
#

ive tried googling obviously if im asking here

timber tide
#

it'll always return the smallest angle though if that matters

swift crag
#

If you want the rotation between two vectors, use Quaternion.FromToRotation

#

This gives you a rotation that, when applied to the first vector, gives you the second vector

swift crag
neon marlin
#

i want to rotate an arrow so it points from the first vector to the second vector

rocky patio
polar acorn
#

And do you have any code rotating the object at all?

swift crag
neon marlin
#

yes

swift crag
#

okay, so you want an arrow to have its tail at point A and its head at point B

neon marlin
#

2 points on the 2d plane

kindred pollen
neon marlin
#

well the arrow would be at a screen border and pointing towards the To point

polar acorn
#

Your code does not account for any sort of rotation and will always move the object the exact same direction whenever the same buttons are pressed

neon marlin
#

like a waypoint arrow

swift crag
neon marlin
#

yes exactly

#

it would be the camera

swift crag
neon marlin
#

right

swift crag
#

You want Quaternion.LookRotation.

neon marlin
#

oh

swift crag
#

It's a bit unintuitive in 2D

polar acorn
#

Instead of moving in world space, move in local space. You've explicitly told the code to move in world space which ignores the object's rotation

rocky patio
swift crag
#
var rotation = Quaternion.LookRotation(Vector3.forward, destination - source);
#

LookRotation's main use is to rotate a camera in 3D space

next ravine
#

How would you create GUI from purely script?

swift crag
#

The first argument is the "forward" direction, and the second argument is the "up" direction

#

In 2D, "forward" isn't really relevant: it points into the screen

polar acorn
next ravine
#

no but like

#

CREATE it

swift crag
next ravine
#

not instantiate a prefab

polar acorn
next ravine
#

ohh i didnt know you could do new gamobject

swift crag
rocky patio
swift crag
#

I create most of my main menu via script.

#

I have prefabs for things like:

  • A settings category list
  • A single setting
  • A credit category
next ravine
swift crag
#

If you want to do it entirely via script, then yes: create new game objects and add components

#

note that you'll have to do a lot of legwork for some UI components

#

the "Slider" preset in the GameObject menu isn't just a Slider component

#

It's all of this stuff.