#💻┃code-beginner

1 messages · Page 390 of 1

vast vessel
#

the DialogCallBackData class defined at the top should hold a reference to a dictionary, and i want the DialogEventCallback method defined at the bottom, to change the dictionary in the method PlayDialog on line 70
https://hatebin.com/bywlmqltus

#

dont worry about it.

burnt vapor
#

Optionally take the boolean result from Remove and see if it return true. If it's false there was no instance found

#

I'm not sure why it would not remove it, though? What do you think might happen?

vast vessel
#

i just kinda slapped a ref prefix in my class constructor

burnt vapor
#

Well you definitely don't need to use pointers

#

And rarely do you need ref

vast vessel
#

oh pointers!

vast vessel
#

sounds like the way to go now that you mentioned it

burnt vapor
#

Because C# is a managed language and most things are reference types

#

Pointers are mostly only used when you communicate with a language that exposes these

vast vessel
#

the only place that i am using pointers in the code i sent are required by the fmod plug in im using

burnt vapor
#

So in the case of EventInstances you have a Dictionary with a string key and object value. The value is a reference type.

#

If you have this exact reference type then you can do comparisons by reference, which is the defualt in C#. If you remove items from a Dictionary you can specify the unique string key otherwise

#

It's hard to determine where callBackData comes from here since you used a pointer but considering you don't seem to instantiate another reference this should remain the same reference

#

Only with value types this is different, as a copy is returned instead. This is usually what C and C++ does with everything unless you start using pointers

vast vessel
#

seems like it worked!

#

no crashes!

#

the reason i got crashes was that the plugin required me to have DialogEventCallback be a static method, and i didnt know how to pass my data to it when it was static

#

since i couldnt add any new params to the method

#

so i had it be private and it crashed the editor

burnt vapor
#

I don't get why that would crash, weird

echo matrix
#

yooi

burnt vapor
echo matrix
#

what are some good free lip sync solutions

#

i am using cc4 model

vast vessel
vast vessel
#

its a package that integrates the fmod audio engine into unity

#

and thats how fmod, which is a seperate program interacts with unity

thin river
#

Hello, I am really stucked now 😄

I have two scenes. Where one is showing the loading progress bar, that shows % and loading text. The second scene is the main game scene.

I was thinking that I can load the game scene asynchrounously and set operation scene activation to false and receive the information from game scene in loading screen (Like the game scene will be reporting the state of loading...).

(Context info - I don't want to simulate it - as I am generating the map procedurally so I want to report real status of the loading).

But I cannot do that with this approach, as Awake / Start methods are not launched until the scene is activated.....

Can I somehow have two scenes that will be communicating while loading ? Or this is completely wrong approach?

(My next idea is to merge these two scenes and just create loading handler.... but I don't like this idea - I will do it nly when I must to 😄 )

thin river
#

Ok Nevermind!!!

I found out I can load it with Additive flag:

SceneManager.LoadSceneAsync("Game", LoadSceneMode.Additive);

So I can still have my loading scene active... and the Game scene too 🙂 Than handle manually switching the scenes!

tawny bolt
willow scroll
tawny bolt
#

ok

#

wont happen again

willow scroll
#

Also I have never seen someone sending an image of their question

lethal bolt
#

How can i do this so it works on an prefab. I dont know how to get the gameobject of an canvas text.

#

i know i have to get component but i can seem to find out how

buoyant knot
#

first, you should probably finish everything before you call for something’s own destroy

#

if you need to work on a prefab, you need a reference to its gameobject instance

#

i assume you want to work on the instance, and not the prefab file itself

#

when you instance a prefab, Instantiate returns a reference to the thing you just instantiated, which you can use

verbal dome
buoyant knot
#

but doesn’t it call OnDisable instantly?

#

i forget about that part, because OnEnable is definitely called from one line to the next

lethal bolt
#

Is the canvas called an gameobject?

#

or can i use public gameobject on it?

buoyant knot
#

the canvas is a component, which is on a gameobject

lethal bolt
#

oh

verbal dome
buoyant knot
#

ambiguous wording as always

verbal dome
#

I dont think it means it happens immediately

#

But yeah ambiguous

buoyant knot
#

it sucks to have the documentation, and still need to test to find out the details

#

it took me the longest time to figure out that Awake gets called, then OnEnable gets called, all one line to the next, but Start might get called next frame

verbal dome
#

Yeah I think that depends on which stage of the playerloop you instantiate an object

swift crag
#

It's consistent with when instantiation and destruction actually happen

#

Instantiation happens immediately (otherwise it would not be very useful)

lethal bolt
#

Is there an diffrent approach that works?

swift crag
#

read the error

#

you're trying to assign a Text into a GameObject variable

#

don't do that; make a Text variable if you want to store a Text

magic panther
#

https://hatebin.com/lgsrbwyytb

Movement works fine, but the rotation applied in the LateUpdate is extremely tiny, like 0 to 1 instead of 0 to 360 tiny. What could be causing this?

lethal bolt
#

I see the error. but im trying to change the text using an prefab so i couldnt do i the "Easy way"

lethal bolt
#

wdym

swift crag
#

oh, you mean you can't just serialize a reference

lethal bolt
swift crag
#

bceause you're instantiating a prefab with this component on it

lethal bolt
#

This would work

#

The enemy adds 1+ score each time it goes out

#

oh.. hold up

lavish jolt
#

Hello! I have 2 scripts where I set camera rotation. First is FPS Mouse Look and second is camera shaker. How can I combine them to work togather. Now CameraShaker dosen't work at all, because MouseLook every frame sets rotation
https://gdl.space/olihadubac.cs

swift crag
#

!code

eternal falconBOT
swift crag
#

please share large amounts of code via a paste site

swift crag
#

Alternatively, apply it after the camera gets rotated, and have it just adjust the current rotation

#

You could use an event for this

lethal bolt
#

Why cant i add the Text Component into ScoreText?

swift crag
#
public event System.Action<Transform> OnCameraRotated;

public void RotatePlayer(Vector2 delta) {
  // ... 
  OnCameraRotated?.Invoke();
}
swift crag
#

or is this now in the scene?

lethal bolt
#

I swiched because the player isnt an prefab so its easier..

swift crag
#
void OnEnable() {
  mouseLook.OnCameraRotated += DoRotation;
}

void OnDisable() {
  mouseLook.OnCameraRotated -= DoRotation;
}

void DoRotation(Transform cam) {
  // mess with the camera here
}
swift crag
swift crag
#

Show its inspector.

lethal bolt
stoic spear
swift crag
#

That's not a Text

#

that's a TextMeshProUGUI

lethal bolt
#

Oh.

#

Thanks you both (:

zealous hatch
stoic spear
#

if its a first person game

#

instead you can use the mouse delta and just += the local rotation, then you wont be setting it just adding to it

#

here is my view calculation:

    Vector2 cameraAngles
    private void CalculateView()
    {
        inputView *= sensitivity / 10;

        cameraAngles += inputView;
        cameraAngles.y = Mathf.Clamp(cameraAngles.y, -90, 90);

        Quaternion camRot = Quaternion.AngleAxis(-cameraAngles.y, Vector3.right);
        Quaternion playerRot = Quaternion.AngleAxis(cameraAngles.x, Vector3.up);

        camHolder.localRotation = camRot * Quaternion.Euler(camRecoil);
        transform.localRotation = playerRot;
    }```
#

and then in the shake, you can just camRecoil += shakeRotation (or maybe you want to change the name to camShake

gleaming kraken
#

hey guys, so im trying to make the paddle stop the moment that it's on the same y axis as the ball, but for some reason, it still passes by the ball no matter what. Why is this the case?

languid spire
gleaming kraken
#

thank you

swift basalt
#

can someone help me understand this? im new to namespaces and unity in general. LevelData is part of the same namespace.

languid spire
swift basalt
swift crag
#

that merely means that LevelData exists

#

the problem is that SaveMap isn't being declared inside of a class

#

thus the error

languid spire
swift basalt
#

Should I put it inside of the LevelData class? it is for taking a Tilemap and outputs a LevelData

swift crag
#

It could be a static method of LevelData, or it could be a static method in another separate class.

languid spire
#

put it where you want, just follow the syntax of c# when doing so

stoic spear
#

yeah i was gonna say you might want to make that static, so you dont need a specific instance to call it

swift crag
#

otherwise, you'd need to do something very silly like new LevelData().SaveMap(...)

zealous hatch
#
if (PlayerPositionX < gameObject.transform.position.x) {
   transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
    Debug.Log("TURN LEFT");
}
else if (PlayerPositionX > gameObject.transform.position.x)
{
        
          
    transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z);
    Debug.Log("TURN RIGHT");
}```

Nothing else changes the local scale... but the gameobject keeps switching between -1 and 1 when standing to the left of him
dense crater
#

Hi I have a quick question. Im using visual studio as my ide and for some reason syntax highlighting and tool tips just turned off for one of the files im using? It still compiles fine. I don’t know if this is the right place to ask this but any help would be greatly appreciated

swift crag
#

which would then return a second, unrelated LevelData

swift crag
#

or do you see "Assembly-CSharp"?

dense crater
swift basalt
#

can i make it so you can do Tilemap.SaveMap()? or would i have to edit the tilemap code

swift crag
stoic spear
#

im pretty sure you can extend unity classes, yeah

swift crag
#

It'd be an extension method

swift crag
swift crag
#

I wouldn't make this return LevelData, since it's just modifying the LevelData you pass to it

#

either way, you'll use it like this:

#
tilemap.SaveMap(123, someLevelData);
swift crag
#

the magic is in the this keyword

dense crater
swift crag
#

what's the path to it?

dense crater
#

Currently it’s just sitting at the top of my assets folder

languid spire
swift crag
#

yep, that's the next move

#

I had an issue once where Unity somehow wrote duplicate entries into the .csproj files

#

and I had to completely delete them to fix the problem

dense crater
#

That’s so weird, I imagine y’all are right because moving it to a sub folder fixed the issue.

#

If it comes up again I’ll try what y’all said, thanks a bunch!

karmic isle
#

Hey quick question, ive recently finished a tutorial for unity so right now i can move my character left and right

id like to make my character run if i tap left or right twice

im thinking in order to do that I'd need to make a seperate movement script and somehow find a way to where if i tap left twice or right twice my character moves faster

Id like to test myself so pls dont give me the answers but nudge me in the right direction y'know?

stoic spear
#

might want to take a look at the new input system 👀

swift crag
dense crater
#

State machines

karmic isle
frosty hound
#

It's a new (not really, it's current now) way to handle input using events. It's not beginner friendly, and if your'e just learning, doing it the way you're handling it now is probably a better learning opporunity; modifying existing logic etc.

#

But you wouldn't separate it no, as above, you'd modify the existing movement logic that tracks if you've pressed the direction twice.

stoic spear
#

it has a way to set up double-press events very easily

#

otherwise i’m sure you could figure something out with a timer that checks for a second input within the time

summer stump
stoic spear
#

or timer -= time.deltatime every frame atwhatcost

stuck crystal
#

Hey, can anyone tell me what I'm doing wrong?
I am trying to make the jumps increase every 2 seconds but not surpass 2.

stoic spear
#

i used that for a regenerating health system

timid oriole
#

how can I have this code calculate the playercolliders bottom & center of the collider (Physics.Raycast(playerCollider.transform.position, Vector3.down, out RaycastHit hit, 0.2f))

#

I know I use bounds.min I think but not sure where to fill it in exactly

polar acorn
summer stump
stuck crystal
karmic isle
#

oh this is why harder than i thought it'd be

#

words have new meanings

stoic spear
summer stump
#

Better may not be the right word, just cleaner

#

You mentioned one and made it seem negative

stoic spear
#

fairs, i just dont like making a whole seperate method like that if i dont need to

summer stump
#

So I suggested a nice alternative

summer stump
karmic isle
#

dumb question, any reason why theres two horizontal and vertical options?

polar acorn
stuck crystal
#

The more the better.

timid oriole
#

RaycastHit hit;
if (Physics.Raycast(playerCollider.bounds.min, Vector3.down, out hit, 3))

#

Not to sure why this is not working I'm trying to use it as a ground check

#

3 is the raycast max btw

polar acorn
#

Try using Debug.DrawRay with the same start and direction to see where your ray actually is visibly and see if it's where you expect it to be

timid oriole
#

I can just shove it under the physics.raycast line right?

polar acorn
#

I'd put it above the raycast line

#

So it isn't conditional based on the raycast hitting anything

timid oriole
#

why is it asking me for two colors?

#

Just wants me to say Color.Red?

#

nvm

#

oopsi

#

Should I say bounds.center maybe instead

stoic spear
#

you should be able to use the player transform position, but i guess bounds.center works as well

timid oriole
#

I'm trying to have the origin be the collider not the empty game object player though

#

do you mean playerCollider.transform.position?

polar acorn
timid oriole
polar acorn
#

You could also just create an empty child object whose sole purpose is to let you position the raycast origin in the inspector, and use the position of that

timid oriole
#

if (Physics.Raycast(playerCollider.bounds.min.y, Vector3.down, out hit, 3)) getting an error argument cant convert from float

stoic spear
#

are you using rigidbody or character controller for movement?

timid oriole
#

this says bottom of collider on y axis

#

yes

polar acorn
timid oriole
#

the y is a float?

stoic spear
timid oriole
stoic spear
#

kk

summer stump
timid oriole
#

Yeah

summer stump
#

Except in Vector2Int or something, where they are int

stoic spear
#

i would have the player origin point to be at their feet if it isnt already

timid oriole
#

Is there no way to do it from the collider and using bounds.min?

stoic spear
#

i mean there is

stoic spear
#

which object is your script on?

timid oriole
#

the player

#

its an empty object whihc I called the playerCollider and dragged and dropped it so I have reference to it

stoic spear
#

if you got the center of the collider and the player position, they should be the same no?

timid oriole
#

I guess so yeah

stoic spear
timid oriole
#

Yeah I will

stoic spear
#

i dont know if the script is on the parent object or a child

timid oriole
#

on the parent

stoic spear
#

right ok

timid oriole
#

And I guess I didn't do it the way I normally do its all only the mesh

stoic spear
#

looks okay, what is the problem currently?

timid oriole
#

Error message

stoic spear
#

try bounds.center

#

instead of min.y

timid oriole
#

okay

#

do I just have to make it bigger then to reach the ground

stoic spear
#

looks good, yeah you might need to extend it 0.1 or so

timid oriole
#

I adjusted it and it didn't change it at all

crisp oyster
#

Hello

stoic spear
#

did you change the debug ray as well?

crisp oyster
#

As-salamu alaykum everyone 🥰❤️🫂

timid oriole
#

oh no

#

i didnt

#

yep now I did same thing still

stoic spear
#

though this works, if you are on a steep slope with a capsule collider the center of your collider will be a bit off the ground meaning the raycast wont hit the ground. i dont know how to fix this issue and it led to me using CharacterController instead

stoic spear
timid oriole
#

When I hit space at least

stoic spear
#

does the ground check work before you press space?

timid oriole
#

yeah

#

It says I'm grounded but never updates it though

stoic spear
#

might wanna take another look at the gravity/jumping code

stoic spear
timid oriole
#

yes

#

But if I disable it while in air and land again it sets it to grounded

stoic spear
#

its in update() right?

timid oriole
#

yes

#

my movement though is in fixed

stoic spear
#

should be alright

timid oriole
stoic spear
#

seems like rb doesnt have gravity on

timid oriole
#

oh yeah

#

I disabled it I forgot when testing the ray

stoic spear
#

and it could be that you arent jumping high enough to get 5 units of clearance for the raycast

#

check in scene view with the debug line

timid oriole
#

I can jump now fine but I'm able to double jump

#

the debugline no matter the raydistance I set is the same

stoic spear
#

oh, yeah that method is different. instead of putting 5 at the end of the parameters, just multiply Vector3.down *5

timid oriole
#

ill try it

swift crag
#

DrawRay takes a position and a displacement

willow scroll
stoic spear
#

oh

#

wonder why it isnt working then

willow scroll
#

Not sure what's not working

stoic spear
#

maybe debug drawline(collider.center, collider.center + (vector3.down*5))

#

with 2 points

timid oriole
#

I can jump infinite now

willow scroll
slender bridge
#

public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);

timid oriole
willow scroll
stoic spear
swift crag
timid oriole
swift crag
#

the fourth parameter is the duration of the ray

slender bridge
willow scroll
signal sonnet
#

can someone explain to me what the lamda here is for ?

public void MoveTo(int targetScene, int targetSpawn)
        {
            Pause();
            SaveSystem.SaveSceneData();
            UIHandler.FadeToBlack(() =>
            {
                var asyncop = SceneManager.LoadSceneAsync(targetScene, LoadSceneMode.Single);
                asyncop.completed += operation =>
                {
                    m_IsTicking = true;
                    
                    foreach (var active in m_ActiveTransitions)
                    {
                        if (active.SpawnIndex == targetSpawn)
                        {
                            active.SpawnHere();
                            SaveSystem.LoadSceneData();
                        }
                    }
                    
                    UIHandler.SceneLoaded();
                    UIHandler.FadeFromBlack(() =>
                    {
                        Player.ToggleControl(true);
                    });
                };
            });

            
        }
stoic spear
timid oriole
#

the mulitply?

stoic spear
#

first version with the parameter of 5 is good for raycast

#

yeah

willow scroll
cosmic pecan
#

Hey guys, im new to unity here and Got my first game yesterday. So far chatgpt wrote all my code, but i want to learn more. How can i start?

timid oriole
eternal falconBOT
timid oriole
#

less reliable

willow scroll
eternal falconBOT
#

:teacher: Unity Learn ↗

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

cosmic pecan
#

Oh this looks good

willow scroll
stoic spear
#

just use CharacterController thinksmart

timid oriole
#

Idk

#

I don't like character controller very much because my character can't use physics

#

like If I want to throw an item based off my current velocity I don't think u can do that

willow scroll
# timid oriole

The reason why it might not work is you not even using a LayerMask. If your player has a Collider, this is what the Raycast is going to detect and set the boolean to false.

stoic spear
willow scroll
stoic spear
#

i wonder if its possible to still do collision checks with having a rigidbody and a charactercontroler

karmic isle
#

alright chat im stumped, how would I make it to where if i double tap left or right mmy character would run? here's my code if you need it

willow scroll
stoic spear
karmic isle
timid oriole
stoic spear
#

yeah, but there might be a way

karmic isle
#

I SHOULD JUST READ

willow scroll
timid oriole
#

Question and might be silly

#

Can two objects if only one has a rigidbody collide?

#

assuming they both have colliders

polar acorn
timid oriole
#

So even mesh colliders then?

#

because they just fall through my map

rich adder
#

only convex

stoic spear
#

whoops

#

but you can do it apparently

stoic spear
#

by just getting the direction you hit it in and doing AddForce()

timid oriole
#

holy moly one sec

stoic spear
#

so you wouldnt be losing anythign with cc, and it has a super robust ground check

timid oriole
timid oriole
stoic spear
#

v simple

timid oriole
#

oh damn yeah

#

still prefer rigidbody tho :p

rich adder
stoic spear
#

damn, you can even make it go flying by increasing the magnitude and stuff lol

timid oriole
rich adder
timid oriole
#

the items

#

because they fall from the sky

#

at random vector on start

rich adder
#

ok, and they have colliders ?

timid oriole
#

yesh mesh colliders + covex however the ground is a mesh collider without a covex

rich adder
#

thats fine

rich adder
timid oriole
#

nope

#

but they fall at a quick pace could that cause it?

rich adder
timid oriole
#

no scripts moving it just instantiating

rich adder
#

can u show whats happening

timid oriole
#

yeah ill record

storm pine
# karmic isle thank you

No problem, since Unity has a big community is very easy to find common functionality and mechanics on Internet

timid oriole
#

I'm trying to use the amd thing but It's not working

rich adder
whole parcel
#

hey guys! i was working on a pacman game but my pathfinder kinda seems off. can someone take a look at it?

rich adder
timid oriole
#

the items are falling through the map

#

some of them are

rich adder
#

so the player stays on the ground? is just the items ?

timid oriole
#

player no issues

#

its the items yeah

summer stump
rich adder
#

try turning out their collision detection to Continuous

timid oriole
#

dynamic

#

or just continous

rich adder
#

continuous

#

also can you show the spawning script ?

timid oriole
#

that

#

fixed it

#

haha

rich adder
#

oh nice

timid oriole
timid oriole
rich adder
digital kelp
#

Does deactivating an object make it "lose" its instance?

languid spire
#

no

digital kelp
#

This script is on a ui toolkit document, and I make it deactivate out of the way at the start
Then when I need it, it gets activated and I can interact with the UI element and its buttons
However the buttons dont work after reactivation

#

When I just leave it activated from the start the buttons work

#

But not after having being deactivated and then reactivated

languid spire
#

show the full !code

eternal falconBOT
digital kelp
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class ui_tileSelect : MonoBehaviour
{
    public static ui_tileSelect instance;

    private HexTile tile;

    private void Start()
    {
        instance = this;

        VisualElement root1 = GetComponent<UIDocument>().rootVisualElement;

        Button buildButton = root1.Q<Button>("BuildButton");
        Button quitButton = root1.Q<Button>("QuitButton");

        buildButton.clicked += () => ClickedBuild(tile);
        quitButton.clicked += () => DeSelect();

        gameObject.SetActive(false);
    }
    public void SelectTileUI(HexTile hexTile)
    {
        tile = hexTile;
        Debug.Log("SelectMenuUp");
    }
    private void DeSelect()
    {
        gameObject.SetActive(false);
    }
    private void ClickedBuild(HexTile hexTile)
    {
        Debug.Log("building...");
    }
}
summer stump
#

Where do you activate it?

digital kelp
#

from another script

summer stump
#

Well yes

digital kelp
#
    void Update()
    {
        RaycastHit hit;
        ray = cam.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            Transform objectHit = hit.transform;
            //If the object has a selectable component on it, call it.
            //Debug.Log(target);
            //Debug.Log(objectHit);
            if (objectHit.tag != "TileTemp")
            {
                //Debug.Log(objectHit.parent);
                if (objectHit.parent.TryGetComponent<HexTile>(out target)) //hmm
                {
                    target.OnHighlightTile();
                    //Debug.Log("Hit");
                    if (Input.GetKeyDown(KeyCode.Mouse0) && !ui_tileSelect.instance.gameObject.activeSelf)
                    {
                        //Debug.Log(target.GetType());
                        target.OnSelectTile();
                    }
                    if (Input.GetKeyDown(KeyCode.Mouse1))
                    {
                        if (!ui_tileSelect.instance.gameObject.activeSelf) {
                            ui_tileSelect.instance.gameObject.SetActive(true);
                            ui_tileSelect.instance.SelectTileUI(target);
                        }
                    }
                }
            }
        }
    }
#

in the last if block

languid spire
#

and this
Debug.Log("SelectMenuUp");
is in the console?

digital kelp
#

yes, when activated

#

but buttons dont activate

karmic isle
#

hey uhhhh. im tryna copy some of the things I saw on the forum @storm pine sent, do I have to define this first? the "inputanykey"

rich adder
karmic isle
polar acorn
karmic isle
polar acorn
karmic isle
karmic isle
rich adder
polar acorn
karmic isle
#

e...y'know what ill just find a c# tutorial. thanks guys!

whole parcel
digital kelp
# digital kelp ```cs using System.Collections; using System.Collections.Generic; using UnityEng...

found a fix

    public void SelectTileUI(HexTile hexTile)
    {
        tile = hexTile;
        Debug.Log("SelectMenuUp");
        VisualElement root1 = GetComponent<UIDocument>().rootVisualElement;

        Button buildButton = root1.Q<Button>("BuildButton");
        Button quitButton = root1.Q<Button>("QuitButton");

        buildButton.clicked += () => ClickedBuild(tile);
        quitButton.clicked += () => DeSelect();
    }

The buttons needed to be reconfigured after each deactivation

stuck crystal
#

I suck, please help.
I need it to give jump 1 number if it's below 2.

wintry quarry
wintry quarry
karmic isle
whole parcel
stuck crystal
wintry quarry
#

nothing else

karmic isle
#

https://learn.unity.com/project/unit-1-driving-simulation I had followed this one btw lol, good tutorial

Unity Learn

In this Unit, you will program a car moving side-to-side on a floating road, trying to avoid (or hit) obstacles in the way. In addition to becoming familiar with the Unity editor and workflow, you will learn how to create new C# scripts and do some simple programming. By the end of the Unit, you will be able to call basic functions, then declare...

wintry quarry
rich adder
karmic isle
#

thank you so much

rich adder
whole parcel
languid spire
rich adder
whole parcel
#

i stored the board like this

#

bc unity tilemapping was giving me unexpected results

rich adder
summer stump
#

Why not... show the code?

whole parcel
#

how do i show code

rich adder
#

!code

eternal falconBOT
summer stump
eternal falconBOT
rich adder
#

double kill!

polar acorn
#

DOUBLE KILL

whole parcel
rich adder
#

i get it

whole parcel
#

does this work?

#

that's my graph manager code

#

and this is my node class

rich adder
#

what about script that moves the enemy

whole parcel
#

that's the pathfinder logic

whole parcel
#

the positioning of my grid is also kinda wacky

#

like the centre is (0, 0)

#

so i hv to add offsetting to make top left (0, 0)

#

i feel like the path finder logic is mainly correct, and moreso a problem w my grid

#

and how i process it in code

bleak glacier
#

Is there an equivalent to public Rigidbody2D myRigidbody; but for circle colliders? I don't see any other way to make a script reference a circle collider.

brazen wigeon
#

Does anyone know how to make a code for moving our characters up, down and left to right, but using Android buttons specifically for mobile games, I've followed chatgpt but there are still errors like the character doesn't move or the code is an error, but it's the same as what is displayed on chatgpt.

#

Honestly, it is very difficult to find sources of inspiration, especially on YouTube, and in my area there are very limited people who understand game making, especially for mobile games

bleak glacier
#

I'm trying to detect a click on a sprite and I've only found half finished explanations. I'm assuming I need to use a circle collider but I can't find a way to reference it to be able to detect the click with a script.

wintry quarry
warm condor
#

Hi guys, I have this line of code ,and several others that are like it, that applies a velocity on the player using the rigidbody2d (for example, the walking code is rb.velocityX = 4 * MovementDirection; ). My issue is that I have this line of code in the FixedUpdate() function, and when I run the game and I walk, the speed that I am going is 3.74... This doesn't happen in the update function, so what could be the problem?

bleak glacier
wintry quarry
warm condor
wintry quarry
#

Also double check if you have drag/linear damping on the Rigidbody

polar acorn
bleak glacier
wintry quarry
#

it works just fine

whole parcel
warm condor
bleak glacier
#

It works now

#

Maybe a typo

wintry quarry
# bleak glacier Maybe a typo

definitely.
Note there's nothing special about Collider2D or Rigidbody2D. This is the same process you use to reference ANY component or asset in Unity

whole parcel
#

i hv the positioning for all of these nodes. is there a way to place a one by one square to check if it's being mapped to the right positioning through code?

wintry quarry
whole parcel
#

objects?

wintry quarry
#

yes objects

#

for example a prefab of a "square"

#

whatever that means to you

#

perhaps a cube MeshRenderer or a SpriteRenderer

whole parcel
#

i just want to debug my grid

#

like drawing aline should do

#

debug.drawline?

wintry quarry
bleak glacier
#

Am I going to learn anything by yoinking other peoples code and mashing into what I need to make? I know it's an ongoing joke that that's what programmer do but I'm concerned that I'm not learning a whole lot.

summer stump
#

You may see patterns, but underatanding takes more

hollow forum
#

Im trying to code a simple orbit simulation but im not sure how to actually apply the force to the external planet

#

i saw something about some addforce methods or sm but idk

#

this is my current code

wintry quarry
#

you definitely don't want to use Update.

hollow forum
#

i have watched this video already

#

but was kinda confusing

wintry quarry
#

what part are you confused by

hollow forum
#

how to actually apply the force i have calculated using code

#

i saw online about a rigidbody.addforce

wintry quarry
#

but yes for a Rigidbody, you use AddForce to add forces, naturally.

hollow forum
#

it just doesnt show up when i try to add it to a rigidbody

wintry quarry
#

wdym by "it doesn't show up"

hollow forum
#

on the intellisense

#

but i just typed it manually and it seemed to have worked

wintry quarry
#

that sounds like a problem with your intellisense

#

is your IDE configured properly?

hollow forum
#

i just followed a tutorial on how to set up vscode for unity

swift crag
#

if you don't see this in the bottom left corner, it's not working properly

#

(well, not that exact project count, but you need to see "Projects: ")

whole parcel
#

my pathfinder seems to be working fine when i turn off my walls tilemap. but when i turn it on, it seems to get "stuck" in the walls. why can that be?

swift crag
#

perhaps the wall tilemap has a collider

wintry quarry
whole parcel
#

it has a tilemap collider

hollow forum
#

what allows me to see projects in the bottom left

whole parcel
#

but i gave it a no friction material

wintry quarry
hollow forum
wintry quarry
#

just use layer based collisions and disable the interaction entirely

whole parcel
#

that fixed it

#

tysmm

hollow forum
#

does a AddForce only take two arguments?

#

and is it a vector2 or just a value

short hazel
hollow forum
#

i read that it takes the x and y value of the force then adds that to the rigidbody

#

but doing that gives me an error

short hazel
#

2D or 3D rigidbody?

swift crag
#

and what is the error..?

hollow forum
#

2d rigidbody

#

no overload method for Addforce takes 3 arguments

short hazel
#

Yeah so this one only has one overload available. It takes a Vector2, and optionally a force mode

#

Two arguments maximum

swift crag
#

ah, it doesn't have a separate overload for separate x and y forces

hollow forum
#

ok i had also a vector 2 with both combined forces

hollow forum
#

ive got the force working and its moving

#

but my forces are staying constant even though the distance from the planet is changing

#
        ```
errant niche
#

i just started programming with unity and watched some tutorials, and they all did these 2 lines of code for movement. I dont understand what this exactly does, can someone explain it to me please?

rocky canyon
hollow forum
#

OH MY GOD

rocky canyon
#

pretty sure u need to square the distance (seperately)

hollow forum
#

YEA I DID I FORGOT THE BRACKETs

wintry quarry
languid spire
hollow forum
#

sorry

#

but its now doing weird things lmao

errant niche
wintry quarry
#

it's literally just reading the input data

#

and putting it in a variable

errant niche
#

what inputs though?

wintry quarry
#

The axis named "Horizontal" is going into a variable named horizontalInput

timid bridge
errant niche
#

that makes sense

#

so its just the location of the object that is put into the variable?

wintry quarry
errant niche
#

right

wintry quarry
#

it's just detecting input from input devices

#

i.e. keyboard/gamepad

#

nothing to do with object locations or anything like that

errant niche
#

and what exactly is horizontal or vertical input?

#

i dont really understand that

wintry quarry
#

Whatever you define it as

errant niche
#

ok

wintry quarry
#

by default "Horizontal" is the D and A keys on the keyboard

#

and left and right on a joystick

errant niche
#

oh ok thats what i didnt know thanks

timid bridge
#

You can look it up and change it here

wintry quarry
#

but you can change it to whatever you want

errant niche
#

i just started programming with unity so thanks for helping me

wintry quarry
#

Oh also the arrow left/right keys on keyboard

errant niche
#

ok thanks

timid bridge
wintry quarry
errant niche
#

so vertical is just a and s?

rocky canyon
#

w and s

#

and up and down arrows

errant niche
#

yeah

wintry quarry
errant niche
#

ok thanks

errant niche
rocky canyon
errant niche
#

if i edit the name to something else, will i also need to do

#

Input.GetAxis("newName")?

rocky canyon
#

yes

errant niche
#

ok

rocky canyon
#

like if add a new Axis called TurretDirection

#

Input.GetAxis("TurretDirection");

errant niche
#

ok thanks now i understand

#

if i press w or upArrow, what exactly gets saved in the variable ?

rocky canyon
#

one... [1]

errant niche
#

and if i press s?

rocky canyon
#

and if u press down its -

wintry quarry
#

You can cehck for yourself

errant niche
#

ok

rocky canyon
#

1 and -1 but u can debug these values ^

errant niche
#

thanks

rocky canyon
#

same with A - D left is -1 and right is +1

errant niche
#

is it a good idea to use these values to make movement?

wintry quarry
#

Get used to using Debug.Log to test things

rocky canyon
errant niche
#

ok thanks so much for the help

rocky canyon
errant niche
#

now it makes so much more sense to me why everyone uses it

rocky canyon
#

fast and easy

errant niche
#

yeah

rocky canyon
#
        // Check for W key input (move forward)
        if (Input.GetKey(KeyCode.W))
            moveDirection += Vector3.forward;

        // Check for S key input (move backward)
        if (Input.GetKey(KeyCode.S))
            moveDirection += Vector3.back;

        // Check for A key input (move left)
        if (Input.GetKey(KeyCode.A))
            moveDirection += Vector3.left;

        // Check for D key input (move right)
        if (Input.GetKey(KeyCode.D))
            moveDirection += Vector3.right;```
#

way better than garbage like this ^

errant niche
#

thats what i did in the beginning

rocky canyon
#

lol me too

#

but u learn quickly why its bad

#

when u can use 2 input axis's for 4 degree's of movement

#

w/o needing 4 if statements

errant niche
#

yeah much better

hollow forum
#

with my orbital simulation

#

the orbiting particle just flies away and leaves and im not sure why

#
{
    // Start is called before the first frame update
    
    public GameObject Planet1;
    public GameObject Planet2;
    public float GravitationalConstant;
    public float distanceX;
    public float distanceY;
    public Rigidbody2D rb1;
    public Rigidbody2D rb2; 
    public float forceX;
    public float forceY;
    public Vector2 totalForce = new Vector2(0, 0);

    
    void Start()
    {
        
    }
    
    // Update is called once per frame
    void Update()
    {
        rb1 = Planet1.GetComponent<Rigidbody2D>();
        rb2 = Planet2.GetComponent<Rigidbody2D>();
        
        distanceX = (Planet1.transform.position.x - Planet2.transform.position.x);
        distanceY = (Planet1.transform.position.y - Planet2.transform.position.y);

        if (distanceX < 0){
            distanceX = -distanceX;
        }

        if (distanceY < 0){                                                     
            distanceY = -distanceY;
        }       

        if (distanceY == 0){
            forceY = 0;
        } else {
            forceY = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceY*distanceY));
        }

        if (distanceX == 0){
            forceX = 0;
        } else {
            forceX = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceX*distanceX));
        }


        totalForce = new Vector2(forceX, forceY);

        rb1.AddForce(totalForce, ForceMode2D.Force);
    }
}```
#

this is the code

wintry quarry
#

only FixedUpdate

#

for two - why have two separate references?

    public GameObject Planet1;
    public GameObject Planet2;
    public Rigidbody2D rb1;
    public Rigidbody2D rb2; 

Why not just delete the GameObject one and use rb1 and rb2 exclusively?

#

You can assign them in the inspector

#

for 3 - Add some Debug.Logs to see how much force you're actually ending up adding

hollow forum
#

im not sure how to access the position for the other planet

#

i can see the force cause it changes in the inspector

languid spire
hollow forum
#

what does that mean

wintry quarry
rich adder
# hollow forum what does that mean

if(float == float) is a bad idea
floats are approximate numbers they are not precise.
If you would either use < or >
Equality check can be used withhttps://docs.unity3d.com/ScriptReference/Mathf.Approximately.html

wintry quarry
#

don't confuse force and velocity

languid spire
hollow forum
#

thats just doing it so when the distance = 0 the force doesnt go undefined

languid spire
#

but 0.0000001 != 0

rocky canyon
#

thats the point tho.. its an inaccurate comparison

#

odds are it'll evaluate false when it should be true

hollow forum
#

no i mean if y = 0, then i cant run the program cause unity gives me an error

#

and it may just do weird stuff

#

i dont wanna risk it

rich adder
#

what

hollow forum
#

trust me

#

i couldnt run

#

it

#

cause

#

anything over 0 is infinity

rich adder
#

are you just making stuff up?

hollow forum
#

no mums life

#

trust me

#

im not

wintry quarry
hollow forum
#

it genuinely wasnt working

#

idk what was going on then

#

but it was giving me an error saying the force vector was (0.000008, infinity)

wintry quarry
#

why not just:

distanceX = Vector2.Distance(rb1.position, rb2.position);```
rich adder
wintry quarry
# hollow forum idk what was going on then

probably because you did:

forceX = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceX*distanceX))```
And dividing by zero is bad and gives you nonsense answers
rocky canyon
#

i like Mathf.Approximately

errant niche
#

why does this say this when the horizontal axis input is set up?

rich adder
wintry quarry
#

read it closely

rocky canyon
#

Horziontal

hollow forum
errant niche
rocky canyon
#

Hzntalia

errant niche
#

thanks

wintry quarry
rocky canyon
#

lol

wintry quarry
#

they shouldn't ever be able to get that close - they should have collided before that

rocky canyon
#

i made a 2D black hole once..

#

i would destroy the outer one if it ever got close enuff to cause problems

timid oriole
#

Guys for having a lot of grass would I do that through coding or something else

rocky canyon
#

maybe then increase the original force b/c you know now its 2 blackholes

timid oriole
#

I'm getting really mixed answers online of how to go about grass

rocky canyon
#

but i doubt tahts how pyhsics works

timid oriole
#

the grass have shaders on them u mean?

rich adder
#

thats one way people do grass

#

also not really a coding question regardless

timid oriole
#

Is there a proper channel to ask these questions

rich adder
rocky canyon
#

ive used this grass asset before

#

works pretty good on URP

timid oriole
#

is it a grass mesh with the shaders on it

hollow forum
#

is the attractive force just not strong enough

summer stump
timid oriole
rich adder
#

each has their own pros and cons

timid oriole
#

for sure yeah

#

guess it depends on what u wanna do

rocky canyon
#

are ur objects oriented correctly? @hollow forum

stuck palm
#

how can i catch errors coming from any source get its message and stack trace?

rocky canyon
#

w/ the X facing right.. and the Y facing upwards?

rich adder
#

oh I think @rocky canyon does this stuff @stuck palm

timid oriole
#

imo I really love valheims grass

#

but that's all the positive I have to say about that game lol

dreamy dune
#

when building an interaction system is it better to use raycast or the onmousehover function?

hollow forum
dreamy dune
rich adder
#

OnMouseOver is very sus and unreliable also you dont have layers

rocky canyon
stuck palm
rocky canyon
#

not sure i'm able to help but i can try

stuck palm
#

so like if an error shows up the notification system will find it and display to the player

rocky canyon
stuck palm
#

yeah

rich adder
stuck palm
#

apparently Application.logMessageReceived can do something like this

wintry quarry
tacit estuary
hollow forum
#

then im putting that in a vector2

hollow forum
rich adder
hollow forum
#

i have disabled that

rocky canyon
#

i'll have to dig thru my source and see how its printing the debugs in my console

stuck palm
rocky canyon
#

its free

#

it automatically set up for Debugs to appear in the console.. im pretty sure u can reverse engineer it

stuck palm
#

might just use tthis tbh

rocky canyon
#

yea its pretty easy to use..

stuck palm
#

for debugging at least, will probably remove in real builds

tacit estuary
hollow forum
#

ok i made them both negative

#

now it just goes around a little bit

#

and it gets fired across the screen like a particle accelerator

rocky canyon
#

once my testing is over then i'll remove it

#

(or make it a cheat thing w/o giving out the password/way to access it)

sly pivot
#

Hi, i was trying to compile a build of my game and it's giving me errors that I've never encounter before while building, i don't have any idea what to do, can someone help me? it's an android game

rocky canyon
#

gradle gradle gradle

sly pivot
#

what is gradle? sorry im very new to this

rich adder
#

it builds your android app

languid spire
stuck palm
tacit estuary
# hollow forum ok i made them both negative

if you want the objects to orbit from gravity, the gravitational force must always point towards the planet. It would be best to calculate a vector from the satellite to the planet, and multiply the magnitude you calculated.

hollow forum
#

im hoping to use Gm1m2/r^2

stuck palm
#

@rocky canyon yeah i was correct

rocky canyon
#

i knew it was in there

#

sorry i made u install it.. lol a bit busy to look for myself

tacit estuary
#

That works, create a vector from the orbiting object to the planet cs Vector2 dir = planet1.transform.position - planet2.transform.position; dir = dir.normalized * Vector2.distance(forceX, forceY);
and use dir into your addForce

tacit estuary
sly pivot
hollow forum
wintry quarry
tacit estuary
#

oh it’s the transform.position

#

not sure where the float is coming from though 😅

hollow forum
#
distanceX = (Planet1.transform.position.x - Planet2.transform.position.x);
        distanceY = (Planet1.transform.position.y - Planet2.transform.position.y);

Vector2 dir = Planet1.transform.position - Planet2.transform.position;
        totalForce = new Vector2(forceX, forceY);
        Force = dir.normalized * Vector2.Distance(forceX, forceY);

        rb1.AddForce(totalForce, ForceMode2D.Force);
wintry quarry
#

Force = dir.normalized * Vector2.Distance(forceX, forceY); < this line?

hollow forum
#

yes that line

wintry quarry
#

show screenshots of your error and your IDE etc

hollow forum
wintry quarry
#

Yeah Vector2.Distance(forceX, forceY); doesn't make any sense

sacred orbit
#

The player's camera can't move up or down on this script and I have no clue why, does anyone know?

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

public class CameraMovement : MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;
    public Transform Player;

    float xRotation;
    float yRotation;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;

        Vector3 currentRotation = transform.rotation.eulerAngles;
        xRotation = currentRotation.x;
        yRotation = currentRotation.y;
    }

    private void Update()
        float mouseX = Input.GetAxis("Mouse X") * sensX * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * sensY * Time.deltaTime;

        yRotation += mouseX;
        xRotation -= mouseY;

        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}
wintry quarry
sacred orbit
#

btw sorry for block of code between yalls convo

tacit estuary
wintry quarry
hollow forum
wintry quarry
tacit estuary
#

ah

#

I was trying to find something similar to Math.hypot 😄

sacred orbit
#

btw, why should you get rid of Time.deltatime there?

rocky canyon
#

planets leave orbit! lol

sacred orbit
#

is it just for camera movement stuff you dont do that?

hollow forum
wintry quarry
#

camera is irrelevant

#

mouse input is the reason

rocky canyon
hollow forum
rocky canyon
tacit estuary
wintry quarry
hollow forum
#

still flying opposite direction

tacit estuary
#

it’s not that bad, but both will work :)

tacit estuary
hollow forum
#
    {
        rb1 = Planet1.GetComponent<Rigidbody2D>();
        rb2 = Planet2.GetComponent<Rigidbody2D>();
        
        distanceX = (Planet1.transform.position.x - Planet2.transform.position.x);
        distanceY = (Planet1.transform.position.y - Planet2.transform.position.y);

        if (distanceX < 0){
            distanceX = -distanceX;
        }

        if (distanceY < 0){                                                     
            distanceY = -distanceY;
        }       

        if (distanceY == 0){
            forceY = 0;
        } else {
            forceY = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceY*distanceY));
        }

        if (distanceX == 0){
            forceX = 0;
        } else {
            forceX = GravitationalConstant * ((rb1.mass * rb2.mass)/(distanceX*distanceX));
        }

        
        Vector2 dir = Planet1.transform.position - Planet2.transform.position;
        totalForce = new Vector2(forceX, forceY);
        Force = dir.normalized * Mathf.Sqrt(forceX*forceX + forceY*forceY);


        rb1.AddForce(Force, ForceMode2D.Force);
    }

}
wintry quarry
#

p1 - p2 is the direction FROM p2 TO p1

#

so that would be the direction of force to apply to P2

#

you are applying it to P1

#

aka - backwards

hollow forum
#

do i flip it

#

planet2 - planet1

wintry quarry
#

yes

#

but you need to apply forces to both planets, right?

hollow forum
#

i just want one to orbit the other

spare mountain
hollow forum
#

its still flying in the opposite direction wtaf

#

it now flew in the opposite direction towards the planet but it didnt curl around

#

probably means the force isnt strong enough

rocky canyon
#

in my version u have to add an initial force to get teh orbit to start

#

or else the planet just gets sucked into the sun

tacit estuary
hollow forum
#

i just did that by putting an add force in the start function

spare mountain
rocky canyon
#
public class Orbit : MonoBehaviour
{
    public Rigidbody2D sun;
    public Rigidbody2D planet;
    public float gravitationalConstant = 1f;

    void Start()
    {
        Vector2 distanceVector = planet.position - sun.position;
        float distance = distanceVector.magnitude;
        float orbitalSpeed = Mathf.Sqrt(gravitationalConstant * sun.mass / distance);
        Vector2 tangent = new Vector2(-distanceVector.y, distanceVector.x).normalized;
        planet.velocity = tangent * orbitalSpeed;
    }

    void FixedUpdate()
    {
        Vector2 distanceVector = sun.position - planet.position;
        float distance = distanceVector.magnitude;

        if (distance == 0f) return;

        float forceMagnitude = gravitationalConstant * (sun.mass * planet.mass) / (distance * distance);
        Vector2 force = forceMagnitude * distanceVector.normalized;
        planet.AddForce(force);
    }
}
``` heres my version if it helps
#

its really old.. soo not sure its perfect by any means

#

oh i did the same thing distance == 0f

#

lmao.. oops

hollow forum
#

now its just flown off the screen

#

rb1.AddForce(impulse, ForceMode2D.Impulse);

#

impulse has a value of 1.0

#

10,0

#

and is in the start function

rocky canyon
#

gotta find a value that works for the gravity

#

it has to be exact

#

thats y i use math to figure out the needed velocity depending on the gravitationalConstant

#

if u crank that up.. u also have to crank up the initial vel

wintry quarry
hollow forum
#

no

wintry quarry
#

also why impulse mode

hollow forum
#

this is just an impulse in the start to get it going

wintry quarry
#

ok well you can't just guess at that number

rocky canyon
wintry quarry
#

it's going to need to be the exact orbital velocity for that altitude

rocky canyon
#

i mean you could guess it

wintry quarry
#

or the orbit isn't going to be stable at that altitude

rocky canyon
#

but good luck

hollow forum
#

can you teach me the math

summer stump
#

Simulating orbital mechanics requires knowing orbital mechanics

wintry quarry
summer stump
#

There are lots of sources out there

hollow forum
#

400 hours of kerbal space program is not helping here

rocky canyon
#

or copying from someone that already knows it

wintry quarry
#

that's where I learned almost all my orbital mechanics

hollow forum
#

yea same

#

but idk all of the formulas and stuff

#

like im guessing im tryna find the speed at apoapsis no?

wintry quarry
#

but you should know intuitively that for a given planetary mass and a given altitude, there is exactly one orbital velocity

wintry quarry
#

or an elliptical one

hollow forum
#

as long as it orbits its no issue

#

elliptical would be cooler

wintry quarry
#

technically they're all elliptical

rocky canyon
#

not sure how to make elliptical orbits.. lol i just move the sun a bit after the game starts

scarlet shuttle
#

should camera control go in update or fixed update?

rocky canyon
#

lateupdate

rocky canyon
#

or update. u want smooth camera

rich adder
#

isnt LateUpdate better for follow?

rocky canyon
#

that what ive heard

rich adder
#

in terms of rotating I usually do update tho, not sure if thats 100%

#

ofc anything else i use Cinemachine 😄

rocky canyon
#

i use cinemachine even if i have custom camera's

#

i just put my camera code on an empty.. w/ a vcam tucked inside

rich adder
#

oh yeah i def used Cinemachine just as camera with Body set to none

rocky canyon
#

automatic transitions got me hooked

rich adder
hollow forum
rich adder
rocky canyon
rocky canyon
#

but i assume thats the annoyance ur talkin about

#

ofc u can set preset stuff too

rich adder
#

yeah pretty much

rich adder
# rocky canyon ofc u can set preset stuff too

like going from an FPS camera with 70FOV to 40ish FOV just for "zoom in" effect, blending is acceptable.. But If I want my player to look at a CCTV camera, the transition is ridiculously not needed to from from Player to a CCTV cam

rocky canyon
#

that shuld be much snappier

#

u dont need the out of body tansition i agree

unreal adder
#

i have 93 line script can somebody read and explain my glitch?

rocky canyon
#

!code give it a shot

eternal falconBOT
summer stump
hollow forum
#

what does NaN mean

rocky canyon
#

Not a Number

hollow forum
#

well what is it then

rocky canyon
#

a pigeon?

rich adder
#

burds aren't reall

polar acorn
rocky canyon
#

Hallofax

unreal adder
# summer stump Start by describing the "glitch"

like i making a prototype to like replicate the mechanics of a other game and in that it uses right click to dribblewhich applies less force to the sphere(the ball) and shoot with more force i made it so however long you hold it down it multiplies the force of the shot but whenver i play test it dosent reset the power which it is supposed to do if i click very very fast

polar acorn
#

Such as x / 0 or ln(-1)

wintry quarry
rocky canyon
#

lol ^ well explained

hollow forum
#

well idk how cause im not dividing by zero

rocky canyon
#

when u calculator says ERROR

hollow forum
#

am i rooting a negative number?

rocky canyon
#

thats NaN

wintry quarry
#

Debug.Log is your friend

#

you can find out all these things instantly!

polar acorn
hollow forum
#

yes

polar acorn
rich adder
rocky canyon
#

very nice!

hollow forum
#

i figured it out

polar acorn
hollow forum
#

it was a brain error

rocky canyon
hollow forum
#

ok so it enters the planet now

rich adder
rocky canyon
#

lol, i never thought of a transition /cam

summer stump
rich adder
#

cause it was smooth at the time 😛

rocky canyon
#

he should.. hes got some good stuff

rich adder
#

i just have a bunch of stuff collecting digital dust not going anywhere

hollow forum
#

the planet works like a railgun lmao

#

the particle gets through and it gets fired into empty space

rich adder
#

thanks guys! you inspired me to post some stuff there

rich adder
rocky canyon
#

doesn't need to be extravagant.. im just gonna post some clips here and there

rocky canyon
rich adder
#

!code

eternal falconBOT
hollow forum
#
        
        impulseValue = ((float)(Math.Sqrt((GravitationalConstant * rb1.mass)/distanceX)));
        
        impulse = new Vector2(impulseValue, 0);
        
        rb1.AddForce(impulse, ForceMode2D.Force);
        Debug.Log(impulse);```
#

is my maths in correct for finding the required impulse

#

cause that finds the speed

rich adder
#

where post go

hollow forum
lethal swallow
rich adder
rocky canyon
lethal swallow
#

mb

rich adder
timid oriole
#

So I'm trying to use a co routine to using waitforchanged result

lethal swallow
timid oriole
#

and I'm having issues with the parameters inside

hollow forum
rocky canyon
rich adder
#

can you show which numbers you picked between blends, its cutoff

polar acorn
hoary light
#

hellooo
i am trying to make a suika game
how do i make it so that on click at a certain axis a entity is spawned? kinda a dumb question but im kinda new to unity ngl

rich adder
#

get the mouse world pos and compare

rocky canyon
#

thats cool

lethal swallow
rich adder
# lethal swallow

you got off the important part again
click blendtree Show me the Clips in the blend tree and which values are picked in inspector

hollow forum
rocky canyon
#

In orbital mechanics, finding the tangential velocity (often referred to as initial impulse in your case) is crucial because it determines the initial speed and direction perpendicular to the line connecting the two bodies (e.g., planet and sun). This velocity ensures that the orbiting body (planet) moves in a circular or elliptical path around the central body (sun or another planet).

hoary light