#💻┃code-beginner

1 messages · Page 509 of 1

burnt vapor
#

If you used a method/property/field from the static class, it must exist or your code will not compile

rocky canyon
#

ya, this comment was a face-palm moment lol

burnt vapor
#

It's not optional, you can't just remove it

#

You remove it, you need to remove the code where it's used

rocky canyon
#

ah okay okay.. so im grasping at straws

rocky canyon
burnt vapor
#

Your use case is very useful when it comes to checking certain hooked features or injected dependencies, but not with static classes

rocky canyon
#

alrighty.. i believe i understand what ur saying now.. took a minute 😅

#

thanks.. gonna re-evaluate now, maybe my life choices as well

#

yup, what i thought i was doing.. was indeed, pointless

#

lmao

burnt vapor
#

About this; Why would "Maybe" ever be a good state to have? Not much to do with a state that might or might not exist.
It would either be initialized, or it would not because it either didn't start initializing or it failed with an error (that would be a separate field)

rocky canyon
#

i saw someone mention it might could be done w/ interfaces

burnt vapor
rocky canyon
#

whats a Service Locator Pattern?

languid spire
finite patrol
#

Should I use a singleton for my statemanager? or is there some major issue I havent thought of?

verbal dome
#

What state manager?

rocky canyon
#

singletons and managers pair well imo

finite patrol
#

like a player state manager for example

rocky canyon
#

if theres only (1) player.. singleton sure

verbal dome
#

If you do that then it will only support 1 player

finite patrol
#

ok

rocky canyon
#

If you're leaning toward keeping things simple with static methods, just ensure that your project's build includes the utility class.

#

roger that.. lol

burnt vapor
#

However, that's just gross misuse of the variable

languid spire
#

I'm damn sure the variable will not be complaining

burnt vapor
#

Actually it would, because you now have to either check if it's explicitly true, or check implicitly through .Value

#

No longer can you implicitly check with just the variable

#

I'd say .NET enums are better, but this can be any number due to how these are set up so it's not a whole lot better.

#

But my point is more that any .NET developer that cares about how code is written would not accept this type of code being written into a company's app. Suggesting it to beginners is a bad idea

night valve
# rocky canyon alrighty.. i believe i understand what ur saying now.. took a minute 😅

It seems you treated initialization the same as instantiation. To keep things simple: static class = no instance, so can't be instantiated. But it can be initialized via static constructor(ie set default values for it's members, or instantiate them). The best difference you can see it's making a regular non-static class and define both static and non-static constructor. See how they behave and remember that static class can have only the static one

rocky canyon
languid spire
rocky canyon
#

fused kept on me until i realized 😅

burnt vapor
#

I mean no offense, but I am very much aware of what it takes to write simple code that scales and I have experience with old code bases that cut corners like this. It's not a good idea.

languid spire
silent egret
#

can I do something that looks better than a = something that doesn´t do anything and it will change?

slender nymph
eternal falconBOT
night valve
#

do-while as first thought, but I don't see the issue in value initialization like this

burnt vapor
#

I won't question why you need this to begin with

night valve
#

Also, pretty sure you don't have to cast int to char, it will implicitly get converted by ToString, and use debug.log not console.writeline

burnt vapor
#

No, Console.WriteLine has overloads for all primitive types, so it will display the actual char rather than the number. They indeed should just use Debug.Log, though.

#

Also, ToString would show the number still, not the char equivelant

languid spire
hasty tundra
#

i have an object that moves directly to its target position, and has a delay before moving again. I want to make it so that during that delay, instead of stopping immediately, it instead slowly loses its momentum over a short bit of time, slowing to an eventual stop just beyond that point.

sleek flare
#

Is there any way to only allow domain reloading to happen when I hit the play button? Every time I save a file, and alt+tab to unity to adjust a gameobject it reloads, even if it's not in play mode. Is there a way to do that, or is it only completely on, and completely off?

slender nymph
#

you cannot disable domain reloading during the compilation step

sleek flare
#

Alright, thank you

pastel sleet
#

He i am making a FPS game with photon pun. I do the respawnscreen with a canvas. The canvas has text and a button for the respawn. The ting is. When i try to disable it again once the button is pressed it wont disable. How can i fix that?

using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class ButtonClickDetector : MonoBehaviour
{
    public Button myButton; // Reference to the Button
    public GameObject gameover;

    void Start()
    {
        // Make sure the button is assigned
        if (myButton != null)
        {
            // Add a listener to detect when the button is clicked
            myButton.onClick.AddListener(OnButtonClicked);
        }
    }

    // Function called when button is clicked
    void OnButtonClicked()
    {
        Debug.Log("Clicked");
        gameover.SetActive(false);
    }
}
``` this is the respawn script (for now)
neat ginkgo
#

hey guys, i have a question. so i want to make robot enemiess that are made with inverse kinematics and procedural animation, but i do not know how to make it nor any tutorials that are fitting what i want

slender nymph
hasty tundra
slender nymph
pastel sleet
slender nymph
#

you referenced the one in the scene and not a prefab? if so, then you're likely doing something silly like calling SetActive on it somewhere in Update or something

pastel sleet
#

the gameover is in the prefab yes. But if i put the script also in the prefab it still doesnt work

#

wait maybe i can fix

slender nymph
#

if you are referencing a prefab then you are not calling SetActive on the object that is actually in the scene so naturally it won't disable that one

pastel sleet
#

wait i have to look how i can find script but not put them in from the inspector

slender nymph
#

you have to reference the canvas that is actually in the scene

slender nymph
pastel sleet
slender nymph
#

verify that you are actually referencing the canvas that is in the scene

hasty tundra
#

I have an object, and i need to be able to instantiate another object a certain distance infront of that object (2D Game) to face directly infront of where the object is rotated to face

#

or rather, i dont need to instantiate an object, i just need to get that position

slender nymph
#

you can use transform.TransformPoint to transform a local position to a world position

hasty tundra
#

that might work yeah, ill test it 👍

slender nymph
#

otherwise you can just add the object's transform.up (or transform.right depending on its direction) * distance to its current position

cunning raven
#

Hi! I'd like some advice how to pause the game updates while my tutorial UI is poping up. The idea is similar to StateStack where I push new scene on top of previous scene so I can still see the previous scene but it no longer updates and instead only render. Currently when I add new scene addictive they still get updated

slender nymph
#

use an if statement that just returns early in Update on scripts that should be pausable

cunning raven
#

that's a lot of scripts blobsweats

#

i want the whole scene to pause while new stuff pushed in updates

slender nymph
#

then just disable them or something

rocky canyon
#

take a screenshot of the scene.. display it as a UI element... and remove the scene 😅

cunning raven
#

thats clever, how do i restore them back to its current state after i remove the scene?

slender nymph
#

you'd have to implement some sort of save system. so then you're back to modifying a whole bunch of scripts lmao

cunning raven
#

can I load 2 scenes but inactive 1 scene like GameObjects?

slender nymph
#

you can have two scenes loaded, yes. you can also loop through the relevant objects you want to disable and disable them. which is basically what i suggested here: #💻┃code-beginner message

#

the better option at this point though would be to go and refactor your code to include logic for pausing things that need to be pausable. you'll have something to actually build upon later on should you need it, and you'll have the experience of building the system so you know how you might implement it in future projects

cunning raven
#

thank you, i'll try to figure out a simple system, i am currently trying to create a gameobjects container so i can call if (true) Update() but issue is how do I know when to add and remove those gameobjects from the container as some gameobjects are dynamicly created and destroyed, well all scripts that need monobehaviors i have issue other scripts are fine

gleaming kraken
#

what are the enclosed things called? like [SerializeField]. I'd like to see the documentation and see what all of them are and what they do.

gleaming kraken
cosmic dagger
slender nymph
cunning raven
#

thank you, i'll give it a try🫡

#

have a good day

placid elm
#

hello, I am trying to increase float value on a shader material through the script. I want it to go up over time but the result is that every frame the value changes slightly into different, very low value, like the one on the screenshot.

slender nymph
#

you are just assigning it to the current value of Time.deltaTime. what you've described sounds like you want a float variable that you increase by Time.deltaTime and use that

rich adder
#

float t;
Update(){
t += Time.deltaTime;

cosmic dagger
#

create a variable to increase using deltaTime, not deltaTime itself . . .

placid elm
#

I assumed that the current value would go up over time

rich adder
#

it fluctuates

cosmic dagger
#

you have to assign it a current value, and you entered deltaTime (instead of the value plus deltaTime) . . .

slender nymph
# placid elm I assumed that the current value would go up over time

the "delta" in "deltaTime" refers to it being a change in time, not the current accumulated time. Time.time is the accumulated time since starting the application. or Time.timeSinceLevelLoad if you just want the time since the beginning of the scene. or if you want the time since this object was created then you need to do what i suggested and create a float variable on that object and just increase it by deltaTime each frame

slender nymph
#

no

placid elm
#

ok, I think I get it

rich adder
#

you prob want to reset it after certain amount (if you want to use it again)

placid elm
#

I want to acutally decrease it over time and make it go from 1 to 0, but I should be able to figure out this myself

#

thanks for help

rich adder
#

use a nice lerp

cosmic dagger
# placid elm So this should work?

that will yield the same value every time. you need to add deltaTime to your variable, then use that variable to assign the value . . .

rich adder
fervent abyss
#

i have an array thats a struct with different variables like item name, how can i get an index of a specific one with for example having only item name?

fervent abyss
#

oh

#

i just got the idea 💀

zenith cypress
rich adder
#

with a for loop you would've gotten the actual index anyway but yeah the function nom sent is nice to have too

fervent abyss
#

i use foreach a lil too much 😭 🙏

rich adder
#

I'm the opposite 😅

fervent abyss
#

i probably gotta go to some doctor or smth

#

my memory is so bad lately

fervent abyss
rich adder
fervent abyss
rich adder
fervent abyss
fervent abyss
#

wait so if i have a dictionary

Key1 = Value1

and if I do dictionary.Add("Key1", "Value2")

its going to substitute the "Key1" value right?

#

not create a second "Key1" right

runic lance
#

dictionary keys are unique, so there will never be two "Key1"
but the Add function will throw an exception if try to add a key that already exists

burnt vapor
#

Also, if you think logically you would see that it would be weird if you can add the same key multiple times. So this is not allowed

#

A dictionary contains distinct keys with each a value. The whole point is distinction

cedar prairie
#

Is it possible to ask for collisions from a specific collider thats on the object?

#

Idk how to specify what collider i want to check from within a collision check

fervent abyss
burnt vapor
#

When in doubt, just try it

#

Often asking is easier but the answer will take longer

#

Experiment, see what works. Then ask for the best approach, or if your approach works best

vale geyser
wanton hare
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

bold plover
#

So is one of the uses of a namespace used to prevent code hiding an inherited class? Or is it purely organizational? I'm reading that one shouldn't have scripts named similar things at all.

#

Seems to be primarily geared for team related things on the official documentation.

steep rose
#

from what I know yes, they are mainly used for organizational use cases, but they are useful for normal applications where you have a bunch of items that have their own uses, pseudo code ⬇️

namespace Item {
   
   class sword

   class shield

   class bow

}
wintry quarry
#

Also you might want to read Microsoft's docs on namespaces, as a more authoritative source

bold plover
#

gotcha

#

thanks boss

regal compass
#

does anyone know how to make an unlit color material transparent?

heady torrent
#

can someone tell how to fix this error that says "C:\Users\bbkid\Downloads\com.unity.xr.interaction.toolkit-2.4.3\com.unity.xr.interaction.toolkit-2.4.3\Runtime\XRHelpURLConstants.cs(370,89): error CS0103: The name 'LazyFollow' does not exist in the current context"

steep rose
#

LazyFollow does not exist, you have to make it in the script

sleek flare
#

Quick question, I know Directory.GetDirectories or Directory.EnumerateDirectories returns the full path, is there a version that just returns the folder names alone, or do I have to manipulate the output to get just the folder names?

heady torrent
steep rose
#

also !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

steep rose
#

learn how to make and assign variables and such via link

thorny basalt
sleek flare
thorny basalt
sleek flare
#

I don't think so, basically I have a folder called Games, and a bunch of folders within it. I'm trying to make a list of the folders within the Games directory, so I need to use EnumerateDirectories or GetDirectories, right?

heady torrent
#

!ask

eternal falconBOT
thorny basalt
sleek flare
#

I'll try it, but unless I'm misunderstanding, I'm not looking for files, only directories. If GetFiles returns folders as well, then cool.

sleek flare
#

It doesn't seem to. This is the code I have:

enumerateDirectories = Directory.EnumerateDirectories(Application.persistentDataPath + "/Games");
Debug.Log(enumerateDirectories.Count());
Debug.Log(enumerateDirectories.ToArray()[0]);

getDirectories = Directory.GetDirectories(Application.persistentDataPath + "/Games");
Debug.Log(getDirectories.Count());
Debug.Log(getDirectories.ToArray()[0]);

getFiles = Directory.GetFiles(Application.persistentDataPath + "/Games");
Debug.Log(getFiles.Count());
Debug.Log(getFiles.ToArray()[0]);

And this is the output:

1
C:/Users/moonlit/AppData/LocalLow/SparksOfInsanity/ServerManager-Server/Games\1
1
C:/Users/moonlit/AppData/LocalLow/SparksOfInsanity/ServerManager-Server/Games\1
0
IndexOutOfBounds

Unless I'm using GetFiles wrong, it doesn't seem to return directories.

slender nymph
sleek flare
#

I was looking at it, though I couldn't find anything that would return just the folder name, unless I missed it.

slender nymph
#

you did

sleek flare
slender nymph
#

also, consider using Path.Combine rather than concatenating the strings to create a path

#

there is also a useful method on the Path class

sleek flare
slender nymph
#

what is the point of manually getting all of the directories like this anyway? surely there's a better way to do whatever it is you are actually attempting to accomplish

sleek flare
#

I'm trying to make a application for me to manage game servers. When the application starts, it makes a list of all the server folders, and populates a list on the application with all the server names. Any ideas on how to improve it then, as the only thing I can think of right now, is to cache the servers when they are created, but then I also have to create a import function to add a existing server to the list, instead of it just dynamically updating when the folder is changed.

tender stag
#

better name? GetInventoryItemWeightFitAmount()

slender nymph
sleek flare
#

I mean, your not wrong. I could also have a check where it checks in the folder to see if there's a serverinfo file or something and only adds the directory if it has that file.. but that also kinda defeats the idea of just drag and drop.. hmm.. I mean, if you have a suggestion on how to do it differently, I'm willing to listen. I just don't expect it to be perfect, as I am just doing this for myself, it just needs to work ^^;

north oar
#

i jus downloaded realtime CSG and now my console is bein flooded with "Unable to find style 'WinBtnClose' in skin 'DarkSkin' Layout" i got no idea what this means

#

nvm i used chatgpt and it told me to change a line and it stopped the errors but i still have no idea what caused it

#

nvm the errors are back now

tender stag
#

wonder why

north oar
#

same i just decided to remove csg realtime all together

rancid tinsel
#

i dont think im implementing this correctly

#

if i understand this correctly what this will do is if both the value and the key are in the dictionary, it will continue

#

the issue with that is it could continue even if looking for the name John Smith, but there are two names in the dictionary like Adam Smith and John McDonald

#

is that correct?

deft grail
#

then it should require both the first name and last name to be there

rancid tinsel
#

im so tired how did i not think of that

#

wait no that wont work

#

because i wanted it to check if a specific key contains the value

#

so in the screenshot its implemented wrong

rancid tinsel
#

is it possible to grab one of the strings from a (string, string) tuple?

rich adder
zenith cypress
#
var tuple = ("taco", "bell");
var taco = tuple.Item1;
// or
var (taco, bell) = tuple;
rich adder
#

hmm i like taco better

rancid tinsel
#

i could be wrong but i got it working like this

#

where im using the Item1 Item2 bit for displaying it, but I also have the data for the FirstName and LastName stored

rich adder
#

ofc it does, labels are just syntax sugar / making less confusing when you have multiple values

prime cobalt
#

Is there a way for button presses in webgl to not go through to the browser because sometimes while playing my game the buttons pressed will activate a hotkey shortcut

zenith cypress
#

If you don't want them to work in a build, you can exclude them entirely with defines like:

#if UNITY_EDITOR
if (Input.GetKeyDown(KeyCode.K)) {
  Global.KillAllEnemies();
}
#endif
rich adder
#

I think they mean keyboard shortcuts in webgl game are activating unwanted browser shortcuts

prime cobalt
#

OK for example like if I press the slide then jump button it's ctrl+space which pops up a bookmarks tab. And I want it to not pull up the bookmarks tab if you do that while in the game.

rich adder
#

iirc you might need to be "locked in" the canvas or whatever

#

you tried clicking inside the game again to allow full control of mouse/keys ?

prime cobalt
#

Yeah it does it even while the cursor is invisible and locked to the center of the screen which can only happen if you're locked in I'm pretty sure

zenith cypress
#

Oh I see, mb

rich adder
#

going to have to use a workaround for webgl maybe :\ (use different keys instead of ctrl) could be limitation of browser ? google doesn't reveal much

prime cobalt
#

Ah that's a shams

twin wigeon
ruby python
#

Hi all,

I'm having an issue figuring out why this isn't working.

    void PlayerRotationInput()
    {
        RaycastHit hit;
        if (Physics.Raycast(cameraMain.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, rotationTargetLayerMask))
        {
            playerTargetingObject.position = hit.point;
        }
        RotatePlayer();
    }
    void RotatePlayer()
    {
        //GameManager.Instance.playerTransform.LookAt(playerTargetingObject.position);

        Vector3 desiredLookDirection = playerTargetingObject.position - transform.position;
        transform.rotation = Quaternion.Euler(0, desiredLookDirection.y, 0);

    }

I was using LookAt which works, but I want to add in a 'turning speed' variable so that my player ship 'lags' behind the mouse position input.

The issue I'm having is that the desiredLookDirection Variable is always returning 0 on the Y axis and I'm not entirely sure why.

Would anyone be able to point me in the right direction please?

eternal needle
ruby python
#

New issue. lol.

    IEnumerator Scan()
    {
        canScan = false;
        scannerEffect.SetActive(true);
        scannerObjectScale = 0;

        while(scannerObjectScale <= scannerObjectMaxScale)
        {
            scannerObjectScale = Mathf.MoveTowards(scannerObjectScale, scannerObjectMaxScale, scannerTime * Time.deltaTime);
            scannerEffect.transform.localScale = new Vector3(scannerObjectScale, scannerObjectScale, scannerObjectScale);
            Debug.Log(scannerObjectScale);

            if (scannerObjectScale >= scannerObjectMaxScale)
            {
                canScan = true;
                scannerEffect.SetActive(false);
            }
            yield return null;
        }
    }

I'm using this coroutine to control a scanner pulse, but the 'scannerTime' (how fast the scanner moves), isn't constant, it speeds up every time I use it.

Video for Reference.
https://streamable.com/2lah2h

I'm pretty sure it's something to do with my yield, cause y'know it always is.

Can anyone see the issue please?

Watch "2024-10-15 05-37-47" on Streamable.

▶ Play video
jolly latch
#

!cs

eternal falconBOT
fading vigil
#

Does anyone know how to create an attack delay?

#

like the character freezes in place and does the attack

#

What I want the character to do (in more detail) is stand still, teleport then do an attack before regaining back player control

rich adder
fading vigil
waxen adder
#

!code

eternal falconBOT
waxen adder
waxen adder
#

how can I make it more specific?

burnt vapor
#

C# short circuits so if the first if statement fails, it would end

burnt vapor
#

Though I'm not 100% sure if this applies to editor builds directly

burnt vapor
#

Try debugging scannerObjectScale

#

Alternatively debug scannerTime

#

These two are most relevant

#

One of the two end up changing to the wrong value

ruby python
burnt vapor
#

Try removing Time.deltaTime

rich adder
waxen adder
# rich adder describe what kind of running ? etc.

I want the player to maintain momentum and speed while also having the ability jump and run on a wall. As well as jump from the wall quickly without having to stick on it for very long. Similar to Titanfall 2 but within the context of this character controller.

#

hope that makes some sense

ruby python
# burnt vapor Try removing `Time.deltaTime`

Yeah tried that too. It's such a weird issue. the 'scanner' cicle should expand at a constant rate every time I hit 'F', but it goes faster and faster with each press and I'm absolutely baffled as to why because all the numbers are consistent.

rich adder
burnt vapor
ruby python
burnt vapor
#

But Lerp is linear

ruby python
#

Uuuh, No it isn't it has 'easing' at both ends and I don't want that

burnt vapor
#

Linearly interpolates between two points.

#

It's linear

#

If it's not then you are applying easing

languid spire
burnt vapor
#

I suggest you rewrite it using Lerp and then share the code if it does end up easing in/out

ruby python
#

Small snippet of my log using Lerp.

If you look at the values it's outputting, they're not linear.

languid spire
#

show the code doing that

ruby python
#
IEnumerator Scan()
{
    canScan = false;
    scannerEffect.SetActive(true);


    while(scannerObjectScale <= scannerObjectMaxScale)
    {
        //Debug.Log(scannerTime);
        scannerObjectScale = Mathf.Lerp(scannerObjectScale, scannerObjectMaxScale, scannerTime);
        scannerEffect.transform.localScale = new Vector3(scannerObjectScale, scannerObjectScale, scannerObjectScale);

        Debug.Log(scannerObjectScale);
        
        if (scannerObjectScale == scannerObjectMaxScale)
        {
            canScan = true;
            scannerEffect.SetActive(false);

        }
        yield return null;
    }
}
burnt vapor
#

How is scannerTime set?

#

I don't see it being mutated anywhere

languid spire
#

there you go 'using incorrectly'
Lerp is current = start,end,t
you are doing
current = current,end, constant

night valve
#

this at first glance ig you're using scannerTime simillar to accumulating timeDelta which result in easing at the end being just infinite function

#

so do elapsed/duration instead

#

and raise elapsed by delta

ruby python
#

scannerTime is just a float set in the inspector.

burnt vapor
#

Doesn't matter. Read the documentation on Lerp

ruby python
burnt vapor
#

It requires a float time set from 0 to 1. Not a constant time

rich adder
languid spire
#

it's the Brackeys Lerp, again

ruby python
#

Okay, had a look at that page and the whole target never actually reached thing that Lerp does is what kinda threw me off and why I like to use MoveTowards instead.

burnt vapor
#

So did you debug scannerTime?

#

Please share those results

ruby python
#

Yeah, and it stays constant to what I set it to.

#

1 sec.

night valve
#

scannerTime (duration) should be the constant, but you need elapsed/scannerTime to interpolate over 1sec linearly

#

so Lerp(begin, end, elapsed/duration)

burnt vapor
#

That should not be necessary

#

I'm not familiar with the method but it doesn't require a non-constant value

ruby python
#

Hang on. Lots of stuff being thrown at me, getting confused. lol.

night valve
burnt vapor
#

I still haven't seen the debug results of {scannerObjectScale} - {scannerObjectMaxScale} - {scannerTime} - {Time.DeltaTime}

ruby python
burnt vapor
#

What you are suggesting is what lerping requires

#

MoveTowards takes a delta, or distance

#

If you divide the elapsed distance you are going to get easing, and it will not reach the end

night valve
#

i mean it is really straightforward while having ```float elapsed = 0;
float duration = 1;

then in the coroutine do:

elapsed += timeDelta;
float t = elapsed / duration;
Vector3 currentScale = Vector3.Lerp(fromScale, toScale, t);

rich adder
#

coroutine exmaplecs float original = someProp; float endVal = 23f; float t = 0; while (t < duration) { myThing = Mathf.Lerp(original, endVal, t / duration); t += Time.deltaTime; yield return null; } myThing = endVal;

ruby python
burnt vapor
#

But they mentioned they do not want lerping

#

They want to use MoveTowards

night valve
#

ah ok, sorry, missed that part

ruby python
#

No it's okay, if Lerping works, then I'll use lerping. lol.

burnt vapor
#

Just mutate scannerTime lineary from 0f to 1f and it works

ruby python
#

I just remember something about Lerping never actually reaches its 'target'

burnt vapor
#

If scannerTime is 1f, it reached its target

#

What you are worrying about is easing

#

Since you are gradually moving to the end, it never reaches 1f because it infinitely slows down. In this case you just check if it's close enough

rich adder
night valve
burnt vapor
#

Also a tip, this applies to float comparison in general

#

Do not check for a float value directly, check if it's close enough

ruby python
#
IEnumerator Scan()
{
    canScan = false;
    scannerEffect.SetActive(true);

    float elapsedTime = 0;
    // Wait until the time has reached the target duration.
    while (elapsedTime < scannerTime)
    {
        // Increment our timer.
        elapsedTime += Time.deltaTime;

        scannerObjectScale = Mathf.Lerp(0, scannerObjectMaxScale, elapsedTime / scannerTime);
        scannerEffect.transform.localScale = new Vector3(scannerObjectScale, scannerObjectScale, scannerObjectScale);

        Debug.Log(scannerObjectScale);

        if (scannerObjectScale >= scannerObjectMaxScale-1)
        {
            canScan = true;
            scannerEffect.SetActive(false);
        }
        yield return null;
    }
}

This is what I've currently got re-written. Just about to test.

burnt vapor
#

Lerping by itself is nothing special. It just takes a percentage of the distance based on the time you pass. It does not care about how far it is

#

You can give it 2f and it goes twice the distance

rich adder
#

isn't that the point of development ?

burnt vapor
#

Why check if the scale is reached

night valve
#

by the way... instead of making a new ```Vector3(scannerObjectScale, scannerObjectScale, scannerObjectScale)

you can use ```Vector3.Lerp(Vector3 from, Vector3 to, float t)```
ruby python
#

For every question asked just. Cause I'm an idiot. lol.

burnt vapor
#

There's a lot wrong with this code

#

This while loop will also run way longer than it should

#

Why don't you break out of it when the scale is reached?

night raptor
burnt vapor
#

The initial issue was that their method is gradually increasing in speed with each invoke

ruby python
night raptor
#

ah, I thought they wanted some sort of lerp smoothed output. my bad

ruby python
#

No worries. 🙂 Thank you though.

burnt vapor
rich adder
night raptor
#

That's linear easing though

burnt vapor
#

Also, I should add that elapsedTime / scannerTime is not going to do that you want probably

#

Haven't checked this part thouroughly but if you want to properly ensure that your code has a certain speed then you want to make sure elapsedTime moves to 1f in a way where it accounts for the requested speed

rich adder
#

correct that one is precise time based rather than speed based

#

eg you get different speeds depending on distance from origin to destination with same duration

#

which might be unwanted

ruby python
night raptor
#

calculating the correct time from speed and travel distance isn't hard though (scale is no different)

ruby python
#

Well actually if I include a 'scanning range' modifier as part of the game (upgradeable system) it may become an issue. lol.

#

Okay, got it working. Thank you all for the input. Very much appreciated.

I'm sure there are other ways to improve the code, but it works so I'm happy. lol.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.UI.Image;

public class ScannerController : MonoBehaviour
{
    [SerializeField] GameObject scannerEffect;
    [SerializeField] float scannerObjectMaxScale;
    [SerializeField] float scannerTime;
    [SerializeField] bool canScan;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(GameManager.Instance.controlsManager.scanKey))
        {
            if (canScan)
            {
                StartCoroutine(Scan());
            }
        }
    }

    IEnumerator Scan()
    {
        canScan = false;
        scannerEffect.SetActive(true);

        float elapsedTime = 0;
        // Wait until the time has reached the target duration.
        while (elapsedTime < scannerTime)
        {
            // Increment our timer.
            elapsedTime += Time.deltaTime;
            scannerEffect.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one * scannerObjectMaxScale, elapsedTime / scannerTime);

            if (elapsedTime > scannerTime)
            {
                canScan = true;
                scannerEffect.SetActive(false);
            }
            yield return null;
        }
    }
}
night raptor
#

elapsedTime >= scannerTime should work though I would still not do the if statement there because it's redundant and would run each iteration of the while which is not needed at all

ruby python
#

I've modified it a little bit to introduce a delay before the next scan is available.

IEnumerator Scan()
{
    canScan = false;
    scannerEffect.SetActive(true);

    float elapsedTime = 0;
    // Wait until the time has reached the target duration.
    while (elapsedTime < scannerTime)
    {
        // Increment our timer.
        elapsedTime += Time.deltaTime;
        scannerEffect.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one * scannerObjectMaxScale, elapsedTime / scannerTime);

        if (elapsedTime >= scannerTime)
        {
            StartCoroutine(DelayBeforeNextScan(5f));
        }
        yield return null;
    }
}

IEnumerator DelayBeforeNextScan(float scannerDelay) 
{
    yield return new WaitForSeconds(scannerDelay);
    canScan = true;
    scannerEffect.SetActive(false);
}
languid spire
#

you do not need the if statement at all, once the while breaks it must be true

night raptor
ruby python
#

Okay.

#

Okay, hopefully the last time. lol.

Really do appreciate all the help guys, thank you.

    IEnumerator Scan()
    {
        canScan = false;
        scannerEffect.SetActive(true);

        float elapsedTime = 0;
        while (elapsedTime < scannerTime)
        {
            // Increment our timer.
            elapsedTime += Time.deltaTime;
            scannerEffect.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one * scannerObjectMaxScale, elapsedTime / scannerTime);
            yield return null;
        }
        StartCoroutine(DelayBeforeNextScan(5f));
    }

    IEnumerator DelayBeforeNextScan(float scannerDelay) 
    {
        yield return new WaitForSeconds(scannerDelay);
        canScan = true;
        scannerEffect.SetActive(false);
    }

https://streamable.com/jep47t

Watch "2024-10-15 10-05-05" on Streamable.

▶ Play video
finite patrol
#

how can I hide somthing from a camera but keep its reflections / shadows

night raptor
finite patrol
#

thanks

chrome karma
#

Hi - im working on a project with a friend for my coding class in school and he wants to make a game with similar graphics as the game called lethal company
Ive done a little bit of research and figured out that i need a toon pixely shader or texture but all the youtube guides make absoultely no sense to me who has never touched this app. I am also using unity person thanks

eternal falconBOT
#

:teacher: Unity Learn ↗

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

chrome karma
languid spire
#

no, that is not the way this server works, also you haven't actually asked a code question yet

chrome karma
#

because i dont know anything about this app

languid spire
#

which is why you need to learn, follow the link provided

chrome karma
#

i have 4 days

#

i cannot learn how to code

burnt vapor
#

You don't have 4 days

#

You had longer but you decided to wait

stiff birch
#

Then drop the idea of developping Lethal Company

burnt vapor
#

Either that, or your scope is too big for 4 days

#

Next time dont procrastinate

chrome karma
#

he just wants the graphics

languid spire
#

also learn is not just about learning to code it's about learning to use Unity

ivory bobcat
eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

burnt vapor
#

If you want help with your shader I'm sure people in #archived-shaders can point you in the right direction, but nobody is going to hold your hand

chrome karma
#

thanks

burnt vapor
#

You will still have to learn the idea of shaders

languid spire
#

I'm intrigued by the concept of doing a school coding class but not having time to learn how to code, seems rather self defeating

chrome karma
#

he just said do whatever you want

#

and we thought this was cool

burnt vapor
#

You're not making Lethal Company in four days

#

Doesn't even matter if you have experience

languid spire
#

I very much doubt any real thought went into that decision

burnt vapor
#

Make a simple game, not a partially shitty game

#

Something like pong

#

@chrome karma

chrome karma
burnt vapor
#

Then you still have the issue of needing to make models, a map, the ability to move, physics

ivory bobcat
#

There's a lot more going on than meets the eye

burnt vapor
#

Four days, remember

#

Even if the actual loop isn't added, or monsters, you got a whole lot going on

#

I'd say your shader is one of the last things to add

chrome karma
#

oh

#

well in that case

chrome karma
#

id still wanna know how to do it

burnt vapor
#

If you have a dead line it's often not a good idea to do something else because you want to know how to do it

burnt vapor
#

Unless the whole point is understanding some concepts of Unity in these four days

chrome karma
#

erm]

#

yeah jsust cus we wanna vdo it

#

not really to learn tbh

ivory bobcat
#

You can do it, if you can already do it else you simply can't without first being able to do it - making the game in four days.
If you cannot make the entire game in two years, you'll not be able to make it in four days.

night valve
#

Pretty sure you can't do anything in unity without learning a bit

chrome karma
#

never did i say that i am making lehtal company

#

you guys assumed that earlier for some reason

#

no volumetric smoke or lighting

#

just the pixelation

#

and stuff like that

ivory bobcat
#

This is the beginner coding channel, you're probably in the wrong channel. I do not believe there are any free handout channels.

languid spire
#

small or large is irrelevant. How can you hope to make anything at all withouit first learning to use the app

chrome karma
#

ok

night valve
#

Do you have any exp in coding? Either way, I think while having only 4days deadline of making a game as a begginer, the farthest you can get is using GameMaker or Fortnite creative. In unity, you could at most re-do really simple game from tutorial 1:1 perhaps

chrome karma
night valve
#

Then maybe try GameMaker, and do 2d game using nodes. I bet your teacher would value something like this more than... Well nothing, bc it's basically impossible to make something solid in unity within 4 days without experience

tulip nimbus
#

Why isnt this Collision between Character Controller and the plane with the "ActionMan" Tag debugging "StepOn" in the console? Does Character Controller not work as a collider?

languid spire
#

CharacterController has it's own callback

tulip nimbus
#

Thank you, i was wondering because ive seen people say that it acts as a collider so i thought it works the same like any other

languid spire
#

if in doubt read the docs

slender nymph
thorn imp
#

why is this giant triangle generating

#
IEnumerator CreateMesh()
{
    vertices = new Vector3[(SizeX + 1) * (SizeZ + 1)];

    int i = 0;
    for (int z = 0; z < SizeZ; z++)
    {
        for (int x = 0; x < SizeX; x++)
        {
            float y = Mathf.PerlinNoise(x * .3f, z * .3f) * Amplitude;
            vertices[i] = new Vector3(x, y, z);
            i++;
        }
    }

    triangles = new int[SizeX * SizeX * 6];
    int vert = 0;
    int tris = 0;

    for (int z=0; z < SizeZ; z++)
    {
        for (int x = 0; x < SizeX; x++)
        {
            triangles[tris + 0] = vert + 0;
            triangles[tris + 1] = vert + SizeX + 0;
            triangles[tris + 2] = vert + 1;
            triangles[tris + 3] = vert + SizeX + 0;
            triangles[tris + 4] = vert + SizeX + 1;
            triangles[tris + 5] = vert + 1;

            print(tris);
            print(vert);

            vert++;
            tris += 6;

            yield return new WaitForSeconds(.01f);
        }
    }
}```
eager spindle
#

Hmm there's no draw line code here

#

It could be a gizmo

#

How are you visualising the vertices of the plane?

night valve
#

I'd say it's not a gizmo, more like problem with indices

eager spindle
#

oh I thought you were referring to the blue triangle

night valve
#

Or not? 🤔 apparently there is some extra vertex

eager spindle
#

yea there's an extra vertice

#

Where is 0,0 on this plane?

tame valley
#

my VS2022 intelisense is working normally until i create a new C# file in unity and opened it, the intelisense is gone, can anyone fix it? ToT

#

everytime i want my intelisense to be useable again i have to exit my vs2022 and reopened it in unity and ill work

#

but its too annoying, anyone got a better solution? :(

night valve
#

Maybe the problem comes out of adding +1 or additional 6 triangles, I gtg now so no time to follow the loop precisely but I'm sure the loop needs some refactoring

ruby python
#

Okay, so my brain is now turning to mush, but before I take a break, could someone help me out a little please?

What I'm trying to do is to get my projectiles to 'fire' out of the front of the ship in the direction that the ship is pointing. I usually use the raycasthit that I'm using to rotate the ship/player, but in this case that won't work because I'm 'lagging' the ship behind the raycasthit.

    public void FireWeapon()
    {
        if(canFire)
        {
            canFire = false;
            for (int i = 0; i < firingPoints.Length; i++)
            {
                GameObject newPlayerProjectile = Instantiate(weaponProjectile, firingPoints[i].transform.position, Quaternion.identity);
                playerProjectileController = newPlayerProjectile.GetComponent<PlayerProjectileController>();
                playerProjectileController.projectileSpeed = weaponProjectileSpeed;
            }
            StartCoroutine(DelayBeforeNextFiring());
        }
    }

I've put in Quaternion.Identity just as a placeholder for now. But I've tried matching rotations with various objects in the ship hierarchy, but it all goes to pot (as in, instead of matching the rotation, it sort of adds to rotation (If ship is at 90 degrees, projectiles fire out at 180 degrees.)

wintry quarry
ruby python
# wintry quarry 1. Use the rotation of the firing point. 2. If this is incorrect, double check t...

I've tried using the rotation of the firing points, but it does the whole adding of the rotation if the angle is above/below 0.
The firing points are parented to the ship and are pointing in the correct direction.
Same with the projectile prefab.

Projectile Controller

    public float projectileSpeed;

    private void FixedUpdate()
    {
        transform.Translate(transform.forward * Time.deltaTime * projectileSpeed);
        Destroy(gameObject, 2f);
    }

(The projectiles will be pooled eventually)

wintry quarry
#

That projectile code is incorrect

#

Translate would use Vector3.forward

#

Not transform.forward

#

Translate expects a local space direction

#

transform.forward is a world space direction

#

Also you shouldn't call destroy every FixedUpdate like that. Just call it in Start

ruby python
#

Aah okay. Honestly I thought it was the other away around because if I do Vector3.forward on my ship, it just goes straight 'up' But that's easy fix. lol.

And yeah I just realised that myself tbh. (destroy)

wintry quarry
#

Vector3.forward isn't something you "do" it's a direction vector, so that's vague

#

It depends what you're doing with that vector that matters

#

Translate is the reason it's working this way

ruby python
#

Right okay. Thank you. Yeah I thought Vector3 was always World space and transform..etc was local.

wintry quarry
#

Vector3.xxx isn't inherently in any coordinate space.

If you plug it into Translate, it's local space
If you add it to a world space vector for example, it's in world space

#

Context always matters

ruby python
#

Riiiight. I get you.

wintry quarry
#

transform.forward is absolutely always in world space though 😉

ruby python
#

hehe okay 🙂

#

Right, so I've changed that over to Vector3.forward, and I've moved the destroy into the spawning method (cause that just makes sense to me. lol.)

wintry quarry
#

And is it working better?

ruby python
#

No. lol. The bullets are shooting straight 'up'

wintry quarry
#

Show the new code?

ruby python
#
    public void FireWeapon()
    {
        if(canFire)
        {
            canFire = false;
            for (int i = 0; i < firingPoints.Length; i++)
            {
                GameObject newPlayerProjectile = Instantiate(weaponProjectile, firingPoints[i].transform.position, Quaternion.identity);
                playerProjectileController = newPlayerProjectile.GetComponent<PlayerProjectileController>();
                playerProjectileController.projectileSpeed = weaponProjectileSpeed;
                Destroy(newPlayerProjectile, 2f);
            }
            StartCoroutine(DelayBeforeNextFiring());
        }
    }
    IEnumerator DelayBeforeNextFiring()
    {
        yield return new WaitForSeconds(firingDelay);
        canFire = true;
    }
wintry quarry
#

You're still spawning them with Quaternion.identity

#

You need to use the rotation of the firing point

ruby python
#

Oh poop. lol. Sorry, my bad.

#

Yep all fixed and working. Thank you very much. 🙂

And now a break before my brain dribbles out of my ears. lol.

#

Actually before I go (and this may not be coding question tbh, not sure). Is there a way to detect collisions without having to use a rigidbody? Reason I ask is there is a lot of 'asteroid' objects in the scene and/or potentially lots of bullets/enemies (only a few of the asteroids are activated at anyone time, spawned in a 'chunk' system), but I'm concerned about having rigidbodies on them all or all of the bullets or enemies.

wintry quarry
#

Sure there are lots of ways. but it's not clear they will be more performant than Rigidbodies

ruby python
#

Right okay. I'll do some trial and error with where to put the rigidbodies. 🙂

#

Thank you again 🙂

zenith cypress
burnt vapor
#

It was just the control that didn't work that well

#

Maybe you can combine the two in that case, or Unity could give a proper "is RELEASE build" type directive that .NET has

#

Because I'm pretty sure #RELEASE will just be ignored in Unity

thorn imp
#

where is this one verticies going from?

#
  IEnumerator CreateMesh()
  {
      vertices = new Vector3[(SizeX + 1) * (SizeZ + 1)];

      int i = 0;
      for (int z = 0; z < SizeZ; z++)
      {
          for (int x = 1; x < SizeX; x++)
          {
              float y = Mathf.PerlinNoise(x * .3f, z * .3f) * Amplitude;
              vertices[i] = new Vector3(x, y, z);
              print(new Vector3(x, y, z));
              i++;

              yield return new WaitForSeconds(0.1f);
          }
      }

      triangles = new int[SizeX * SizeX * 6];
      int vert = 0;
      int tris = 0;

      for (int z=0; z < SizeZ; z++)
      {
          for (int x = 0; x < SizeX; x++)
          {
              triangles[tris + 0] = vert + 0;
              triangles[tris + 1] = vert + SizeX + 0;
              triangles[tris + 2] = vert + 1;
              triangles[tris + 3] = vert + SizeX + 0;
              triangles[tris + 4] = vert + SizeX + 1;
              triangles[tris + 5] = vert + 1;

              vert++;
              tris += 6;

              yield return new WaitForSeconds(.01f);
          }
      }
  }```
#

it never gets printed

#

and all the other ones do

#

is tihs a non script related issue

bright siren
#

you need to create an extra vert on each side of mesh (<= SizeX/Z)

#

also view it in wireframe in the scene view

rancid tinsel
#

how do i push my code to a specific branch on a different github repo?

#

im finding it super confusing

#

i made the branch but my project isnt linked to that repo and im not sure how to connect it

slender nymph
#

add the remote host using whatever git gui you prefer then push

rancid tinsel
#

wtf i already screwed something up

burnt vapor
rancid tinsel
#

the new branch i made overwrote part of another branch? the new branch i made has 2 commits from 2 days ago

burnt vapor
#

Sounds like a matter of forking the repo, making your changes in your local repo on a different branch, and then merging the changes to the main repo

#

AFAIK there's no such thing as just pushign changes to a different repo. That makes no sense

burnt vapor
#

It only overwrites changes that do not conflict

rancid tinsel
burnt vapor
#

If you are pushing changes and another commit that was not part of your head also did this, you get a merge conflict

burnt vapor
rancid tinsel
#

IDK

#

theyre not my commits

#

and theyre from 2 days ago

burnt vapor
#

Also, how is this a coding question

burnt vapor
#

Commits don't just magically appear

#

Either you made them, they were merge requests, or somebody else has access to your repo

#

All cases can be checked in your history

slender nymph
#

don't crosspost. if you want to collaborate with someone then go to the discussions site 👇 !collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

slender nymph
#

and if you want actual help then actually !ask a question

eternal falconBOT
faint agate
#

I have a script so when the player does a 180, a screen effect happens as they turn around and hits 100% when the player does a full 180. The problem is its taking not only the y rotation but also the x, I only want to take the Y rotation .
heres the script https://pastecode.io/s/8324yi51

slender nymph
left onyx
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class dragall : MonoBehaviour
{
    [SerializeField] private float objectAcceleration = 10f;
    [SerializeField] private float objectMaxVelocity = 10f;

    private Rigidbody2D objectRigidbody;
    private bool isAccelerating = false;

    private Transform dragging = null;
    private Vector3 offset;
    [SerializeField] private LayerMask movableLayers;

    void start() {
    objectRigidbody = GetComponent<Rigidbody2D>();    
    
    }
    // Update is called once per frame
    void Update()
    {
        HandleobjectAcceleration();
        //HandleobjectVelocity();        

        if (Input.GetMouseButtonDown(0)) {
          
            //castray
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, float.PositiveInfinity, movableLayers);
            if (hit) {
                //record transform of hit object
                dragging = hit.transform;
                offset = dragging.position - Camera.main.ScreenToWorldPoint(Input.mousePosition);
            }
               
            }
        else if (Input.GetMouseButtonUp(0)) {
             dragging = null;         
        }
        if (dragging != null) {
            dragging.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + offset;
        }
    }
    private void update() {
        if (isAccelerating) {
            objectRigidbody.velocity = Vector2.ClampMagnitude(objectRigidbody.velocity, objectMaxVelocity);
        }
    }
    private void HandleobjectAcceleration() {
       // if(Input.GetAxis("Mouse X")<0){
            //Code for action on mouse moving left
         //   print("Mouse moved left");
       // }
      //  if(Input.GetAxis("Mouse X")>0){
            //Code for action on mouse moving right
          //  print("Mouse moved right");
       // } 
    isAccelerating = Input.GetAxis("Mouse X")!=  0;
    }
}
eternal falconBOT
left onyx
#

im trying

slender nymph
#

doesn't look like it

faint agate
left onyx
#

OHHH

slender nymph
#

just use a bin site, it's a large block of code

left onyx
#

i couldnt see the small dots at first

slender nymph
#

apparently you couldn't see the correct instructions either

polar acorn
left onyx
#

i sit far away

polar acorn
#

-# Then I am not sure how you intend to actually read anyone's answers if you can't read text

brave compass
left onyx
slender nymph
left onyx
#

got any ideas? I think im doing it wrong

#

maybe i just need to change the dragging thingy into addforce or something similar?

magic coral
#

I'm new to unity and wanted to create a simple three match mobile game to test it out. Unity uses units for sprites, that makes sense for some games but i have a static game scene that needs to handle a specific aspect ratio on different screens. Is it a good choice to set the unit size to 1 pixel so i can resize everything depending on the screen size or are there some good resources about different aspect ratios?

slender nymph
#

this is a code channel

slender nymph
magic coral
#

I will need letterboxing with a custom background texture of course because if i use a 9:19 aspect ratio and someone opens it on a ipad i need some kind of background. What would be a good start point? I thought about setting a aspect ratio in the game view i want to concentrate and build on top of it and then check out what i need to do for supporting different aspect ratios.

slender nymph
#

a good starting point would be to look at any of the dozens of tutorials for letterboxing or get one of the many assets that handle it

magic coral
#

Makes sense, i will check it out

mossy bay
#

!code

eternal falconBOT
mossy bay
#

Why am I still jumping indefinitely? I can´t see the problem

public void Jump(InputAction.CallbackContext context)
    {
        if (IsGrounded())
        {
            doubleJump = false;
        }
        
        if (context.performed)
        {
            if (IsGrounded()) //First Jump
            {
                rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
            }
            else if (!doubleJump) //DoubleJump
            {
                rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
                doubleJump = true;
            }
        }

        if (context.canceled && rb.velocity.y > 0f) //reduced Jump height if spacebar is only tapped lightly
        {
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
        }
    }

    private bool IsGrounded()
    {
        return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
    }
rich adder
mossy bay
rich adder
#

thats just piece of code, that isn't a verification if its doing what you expect

#

n are you sure you dont have the player inside the groundLayer

faint agate
#

it said I cant use floats

slender nymph
#

what said you can't use floats? and it would be the public yRotation variable you have

mossy bay
rich adder
#

debug the value of IsGrounded

rich adder
rich adder
mossy bay
rich adder
#
OnDrawGizmos(){
Color  col = IsGrounded() ? Color.green : Color.red;
Gizmos.color = col;
Gizmos.DrawSphere(groundCheck.position, 0.2f);
}
slow verge
#

Hey guys, I have a quick question. Recently I have a good idea on a game project that is a sort of board game, which mainly gonna be 2D, I’m not sure if unity is what I’m looking for

#

Can someone give me some suggestions on Unity or any other general tools that would be suitable for a board game. Any language or framework is good

faint agate
slender nymph
#

well you've got the start rotation. so compare that to the current rotation every frame. do you know how to get the difference between two angles?

slow verge
#

I am like unsure what unity can do yet, but ultimately this board game should be able to be the backend of a website.
Is it easy to deploy this to a website?

rich adder
#

there have been countless of board games made in unity

slow verge
#

Last question is that, in the programming part, can it use all the languages? Because there are specific python library that I need to use

#

For the scripting part

rich adder
#

maybe use external libraries for other helper things you can't find native to c# but thats not many things..

#

unity / .net in general can do Interop but its complex (for beginners)

slow verge
#

I mean like can it stuck some other language, I would write the main part in C#

#

Just for the scripting purposes

#

I can do C# for all the logic stuff and connect them

rich adder
#

so what do you need python for

slow verge
#

ex: integrating AI

rich adder
#

by AI. you mean those text prompts?

slow verge
#

Yes

#

Well, I mean there is a new library called sworn

#

And I need to use it

rich adder
#

I mean you can do that with any library, im sure there are interops / .NET wrappers

slow verge
#

Oh ok. I’m not that advanced like advanced advanced

#

I thought the library are only allowed in certain language

rich adder
#

well yeah but there are ways to communicate with other libraries if you write wrappers api for them , usually they have them but mos tof the tme (if its too new no)

#

thats literally what APIs are for lol

#

when you use Unity you're using an API written in C# to talk to the engine / library that is C++

slender nymph
#

what did you try? because it's literally just subtraction

#

there's also the handy dandy Mathf.DeltaAngle if subtraction is too difficult for you

slow verge
#

I would start learning unity lol

slow verge
#

Just released by open AI

rich adder
#

i mean most of the open AI have API calls anyway so language is usually irrelevant

#

I would not be surpised if this did too

#

i see its new enough to be on github, yeah you probably dont have reg API yet

#

you can easily host your own and create API yourself to talk from unity or any other app

faint agate
polar acorn
#

That seems a bit odd

#
  1. Why store the variables if you're just going to modify pl.transform.rotation directly?
  2. Why set it to exactly -180? Aren't you trying to rotate it by 180 degrees and not set it directly to that?
faint agate
#

im using them in a Quaternion.Angle

#

im trying to understand this all myself

slender nymph
#

again, you do not need Quaternion.Angle. you literally just subtract the starting angle and the current angle on the Y axis to find the current angle between them

#

this is like middle school level math at best

gleaming kraken
#

genuine question, what's the point of a CharacterController component if it's really bad with collisions, why would I use it over a RigidBody and making the movement myself?

slender nymph
#

why would you think a CharacterController is bad with collisions? also it's for just straight non-physics based movement but still respects collisions unlike moving via the transform

devout flume
#

I don't know in which channel I should ask editor-inbuilt-features-related questions, so I'm asking it here. Feel free to point out any channel that would be more suitable in this case.

As a new user to unity, I decided to follow the !learn courses, even though I've been using RStudio for years, I am still doing basic tutorials (moving camera, ...) to ensure I learn every useful tips. However there's something that I really dislike : the ROTATE TOOL.

They describe it as follow:

Important: Don't click and drag the ring in a circle as if you were turning a wheel. Instead, click and drag your mouse in one direction, as if you were drawing a straight line with the cursor.

I find this awful. Despite that, I didn't find any way of changing this behavior so that it actually works like a wheel, and rotates the object where I'm putting my cursor. Is there anything I can do? Or am I cooked with this unsuitable solution?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
#

most rotate tools work that way

devout flume
#

I don't understand that ! I mean, the rotation system I'm referring to also have its flaws obviously, but it's way better to click somewhere on the ring, put your mouse cursor wherever you want the part to look at, and that's it, here you have to slide and it's less intuitive in my opinion

#

I guess it's just the time to get the hang of it, but yeah

gleaming kraken
slender nymph
#

unable to collide with triggers
trigger colliders don't collide with anything, they are not solid.
the things are about how you handle the collisions from other objects, it will only collide in the direction it moves because it isn't a physics body like a rigidbody. it's like moving via transform.Translate but with collision checks for the path it will move in. any other collider you move that doesn't have a rigidbody will behave the same way, except without the automatic collision checks for its movement path

gleaming kraken
slender nymph
#

for when they want to move an object with collisions but not have actual physics

zenith cypress
#

Also for when you want 100% control over how the body moves. Rigidbodies can introduce extra forces that can lead to goofy outcomes over time, or mess with some checks.

rocky canyon
# gleaming kraken yes, so why would someone use this over a RigidBody with physics checks? I don't...

character controllers have their own strong-points.. and if u work w/ them long enough it becomes second nature..
whether it be a character controller or a rigidbody if ur doing the bare-minimum they'll act accordingly..
they both take a little TLC for them to work how u want..
CC - tight, responsive movement, simplified collision detection, great for arcade style controls
RB - realistic physic interactions, built-in forces and momentum, ideal for physics-driven gameplay

but yea, a trigger collider isn't supposed to be collided w/ regardless..
i use both a character controller and a rigidbody for two seperate projects..
one is closer to a walking sim and the other is closer to a titanfall controller..

#

for those times when i want stairs isntead of ramps i'll use a CC right off the bat lol

delicate portal
#

Hello! I am currently struggling with movement vectors and animations. I have a moveDir vector which is relative to the camera's current position, as it is circling around the player:

moveDir = (cameraForward * inputVector.y + cameraRight * inputVector.x).normalized;

(The input vector is just a normalized vector getting the input)

However, when I try to set the float on the animator, it works when the player isn't rotated, but when it gets rotated, it completely messes up the animation and plays the left animation when in reality, the player goes right.

pi.animator.SetFloat("xMove", moveDir.x, 0.2f, Time.deltaTime); pi.animator.SetFloat("yMove", moveDir.y, 0.2f, Time.deltaTime);

What should I debug/change?

#

The red line represents the moveDir, the blue line the cameraRight, and the green the cameraForward

#

This point the player already plays the left animation when he is going to the right

wintry quarry
#

"right " and "left" aren't really super useful descriptors here because they depend on a given point of view

#

Should the animation be based on the input direction rather than the transformed direction from the camera?

#

The input direction is always "local" and relative to the camera it seems

delicate portal
delicate portal
delicate portal
cinder gazelle
#

how to take a variable from a script to another one ?

polar acorn
cinder gazelle
#

i have public float movespeed = 5f in a script

#

the seconde script is in the same object

#

how can i take it ?

polar acorn
cinder gazelle
#

ig you don't let me the choice xdd

polar acorn
#

This isn't something you "just solve real quick" and never have to worry about again. Referencing things is like, 90% of all programming in every language and platform ever

quiet ginkgo
rich adder
rocky canyon
quiet ginkgo
rocky canyon
#

make sure u dont have exit time on the idle.. and make sure ur transition makes sense

rocky canyon
quiet ginkgo
delicate portal
delicate portal
rocky canyon
#

before you use the vector anywhere just try passing it thru that function..
worst thing that happens is it doesn't work and you go back to ur original vector and try something else..

#

i do believe it will work tho.. b/c b4 i used it my character would act fine when facing the orientation it spawned in.. but as soon as i turned left or right..
i realized it would still move the same directions.. (after passing it thru the TransformDirection function it worked as expected)... pressing forward moved it forward relative to the way i was facing

delicate portal
#

moveDir = pi.playerTransform.TransformDirection(moveDir);

rocky canyon
#

my camera only rotates up and down (as a child object)

delicate portal
#

For me the camera rotates and the player as well

rocky canyon
#

if ur player rotates u could probably pass in the players transform

delicate portal
rocky canyon
#

it should spit out a new vector takin the players rotation into account

delicate portal
#

This is all you need to know about the moveDir

rocky canyon
#

i'd normalize it first and then run it thru the method

#

not sure it matters but atleast i know it works that way

delicate portal
#

did both

#

Doesnt work

rocky canyon
#

ohhh unfortunate.. i figured i'd chime in b/c i thought taht would work..

#

do u debug ur vector at all to see what its returning? like what u expect

delicate portal
#

maybe it would

#

but in a different way

delicate portal
rocky canyon
#

ohh yea.. i dont think ur camera should be used for that method..

#

it probably makes it do some weird stuff.. because ur camera angling up and down

delicate portal
#

Same idea here

delicate portal
#

But how do I make the movement relative to the camera and make the animation work at the same time?

#

Seems like I'm just not qualified enough

rocky canyon
#

heres a little clip i made showing the results of
regular direction and then direction passed thru that function..
as u can see when its disabled my rotations doesn't really matter
forward is always World Forward

#

but when it is enabled my players rotation affects it.. and then i can go forward Locally..

#

from what little i read from ur comment and post.. i thought the same type of issue was occuring before being passed thru the animator.. but if that method doesnt work i'll have to re-think it thru

#

ill ping or reply if I can find anything.... but thats all i got for now sorry 🍀

delicate portal
#

I tried just that what you show in the video, the problem is that the player always looks at another transform called ai: transform.LookAt(ai);

Thats why the orientation of the player hardly changes, thats why I use the camera to determine the moveDir.

#

So I think I should do something on this line, maybe include the player's forward,right?

rocky canyon
delicate portal
#

it'd be great if I knew where should i even begin

#

maybe debug the hell out of the directions?

rocky canyon
#

my animators only animate in place.. i dont usually use root motion or anything complex..
when i press A or D it strafes.. when i press W or S it walks..
so ive never run into issues such as this.. so thats why i can't really tell u a good starting point

delicate portal
#

Sure thanks man

severe onyx
#

how would I use a List.Sort for a list of generic gameobjects in which I want to sort them by the distance of their transform.position to 0,0,0? Im assuming the latter can be done by just getting the magnitude but Im kinda stumped onhow to properly use the Sort method for this

short hazel
# severe onyx how would I use a List.Sort for a list of generic gameobjects in which I want to...

You have two options:

  1. Use the overload of .Sort() that takes in an Comparison<GameObject> delegate, so you'll make your own method or lambda expression, or
  2. Use the overload that takes in an IComparer<GameObject>, and create a class that implements that interface.
    Both solutions use the same logic, two elements of the array are given to you, and you return either -1, 0, or 1 depending on if the first object is considered "before", "at the same position", or "after" the second one (respectively)
severe onyx
#

mhhhhh

#

I was hoping I could just generically compare two floats since that's all the gameObject.transform.position magnitude is in the end, aye?

short hazel
#

If your list is a List<GameObject>, you need the custom comparer, because you need to tell it to go into .transform.position.magnitude of both objects and compare those

#

It doesn't know otherwise, and will sort using the default comparer (which probably does not do anything, unless GameObject implements IComparable)

severe onyx
#

alright fair enough

#

now I need to figure out what that actually looks like in code and where it goes

night mural
#

you could use linq's orderBy which might be closer to the syntax you're imagining, though it will create a new list (up to you whether you prefer that or not)

severe onyx
#

that might actually be much preferable in this case

night mural
#

it usually is, I'd say

short hazel
#

Yeah if you don't want to sort the list in place, and you're OK with overwriting it again and again, then LINQ is fine

night mural
#

unless you need to save the memory/garbage, immutability is nice

severe onyx
#

it's mostly preferable because I only need the changed order for one specific operation

short hazel
#

It'll look something like list = list.OrderBy(...).ToList()

#

Oh then definitely LINQ then, if you don't need the original list reordered

#

OrderBy is easier, just tell it which property to sort by in the lambda

severe onyx
#

List<Node> temp = NodeList.OrderBy(n => n.transform.position.magnitude).ToList();

#

this would've been my intuitive approach

#

Im a bit rusty on LINQ

short hazel
#

Yep that works

#

OrderByDescending for reversed order, just in case

severe onyx
#

gotcha, time to test

#

thanks for the help

quartz anvil
#

!code

eternal falconBOT
quartz anvil
#

'''cs
void Start()
{

int WTextureAtlasSizeInBlocks = 4;
float WNormalizedBlockTextureSize = (1f / WTextureAtlasSizeInBlocks);

    float y = TextureID / WTextureAtlasSizeInBlocks;
    float x = TextureID - (y * WTextureAtlasSizeInBlocks);

    x *= WNormalizedBlockTextureSize;
    y *= WNormalizedBlockTextureSize;

    y = 1f - y - WNormalizedBlockTextureSize;

    Console.WriteLine(x, y);
    Console.WriteLine(x, y + WNormalizedBlockTextureSize);
    Console.WriteLine(x + WNormalizedBlockTextureSize, y);
    Console.WriteLine(x + WNormalizedBlockTextureSize, y + WNormalizedBlockTextureSize);

}
'''

console is saying cannot convert type float to type string for the x variable? Am confused.

#

ah i did it wrong 😦

#
 void Start()
    {

int WTextureAtlasSizeInBlocks = 4;
        float WNormalizedBlockTextureSize = (1f / WTextureAtlasSizeInBlocks);
        
         




        float y = TextureID / WTextureAtlasSizeInBlocks;
        float x = TextureID - (y * WTextureAtlasSizeInBlocks);

        x *= WNormalizedBlockTextureSize;
        y *= WNormalizedBlockTextureSize;

        y = 1f - y - WNormalizedBlockTextureSize;

        Console.WriteLine(x, y);
        Console.WriteLine(x, y + WNormalizedBlockTextureSize);
        Console.WriteLine(x + WNormalizedBlockTextureSize, y);
        Console.WriteLine(x + WNormalizedBlockTextureSize, y + WNormalizedBlockTextureSize);


  }
#

nvm i figured it out

rocky canyon
rich adder
#

you need Debug.Log

quartz anvil
#

danke

rotund hull
rich adder
#

forgot which

#

bg mode i meant

rotund hull
rotund hull
#

to clear or depth

rich adder
rotund hull
#

which section on the camera

#

i cant find it

rich adder
rotund hull
rich adder
rotund hull
#

if that is what the depth or base is

rotund hull
rich adder
#

I thought depth would clear it but ig not lol

rotund hull
rich adder
#

when its set to uninitialized

rotund hull
#

i will keep on looking

rich adder
rotund hull
#

thanks

ashen niche
#

@steep rose ```void Ship()
{
transform.rotation = Quaternion.Euler(0, 0, rb.velocity.y * 2);

    if (Input.anyKey || Input.touchCount > 0)
        rb.gravityScale = -3.4f; 
    else
        rb.gravityScale = 3.8f; 

    rb.gravityScale = rb.gravityScale * Gravity;
}```not the 10 that i said bc i didnt know the exact value at top of head
steep rose
#

and you mean stutters meaning a movement stutter or a lag spike?

ashen niche
#

seems like a movement stutter

eternal needle
# ashen niche seems like a movement stutter

the only thing that i see could be related to the movement stuttering is if it constantly went between the gravity scale of -3.4 and 3.8. Add some debugs to see if anything weird is happening there, its likely not related to the gravity scale otherwise.
this rotation code is questionable though. the velocity is a direction vector, not a set of angles, so using it in Quaternion.Euler doesnt make much sense.

steep rose
#

it could be rotating the player at an inconsitant "angle" since velocity varies

umbral hull
#

would anyone help me figure out why my models keep starting off the game facing left?

#

like here is my model and camera:

#

and here is the game start

#

facing the left shoulder

steep rose
#

that's just the normal camera rotation of 0,0,0 you can set it on start in your camera script using your X and Y variables, you can rotate your model in the direction of the 0,0,0 rotation

#

im not sure there is a "built in" method

umbral hull
#

yeah. i have it set to (0,90,0) but it keeps starting there

#

its doing that for all my models actually

steep rose
#

you can set it on start in your camera script using your X and Y variables

#

in your camera script

umbral hull
#

to make my cpu's go forwards i have to make them do transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);

steep rose
#

Vector3.right is a global orientation

umbral hull
#

ik

steep rose
#

so why use it

umbral hull
#

but im saying its weird that none of my models are facing 'forward'

steep rose
#

use the local orientation

#

unless you are setting their rotation via script they should not rotate at all on start

#

only the camera

umbral hull
#

im saying its not a camera specific thing. im wondering why none of the things in my scene are actually facing forward. unity seems to think theyre facing left

steep rose
#

are you using global gizmos?

umbral hull
#

idek what that is

steep rose
#

at the top of the unity scene view you should see a sphere with dots on it, click on it and put it to local

#

first picture

#

then select an object on your character and rotate it to whatever

umbral hull
#

its supposed to be blue yeah?

steep rose
#

if you are talking about gizmos color, I dont remember actually 😅

umbral hull
#

srry im a little confused. what does the global gizmos have to do with my stuff facing left?

#

and what should i be doing?

steep rose
#

but yes blue is forward iirc (well its the Z axis)

umbral hull
#

it is highlighted

steep rose
#

what is?

umbral hull
#

this is my scene

steep rose
#

are the gizmos set to local?

umbral hull
#

to my knowlege it looks like hes facing forward but like

steep rose
#

also for a better visualization switch to move mode and you will see which direction its facing

umbral hull
#

move mode?

steep rose
#

yes the move tool

umbral hull
#

ah i got it

#

thank you friend

#

so new question actually lol

#

how do i change the orientation for the camera ig? like

steep rose
#

you change it via code so it may look something like this

void start(){
   Y = 90;
}
#

I believe its X anyway its Y

umbral hull
#

ah thanks

steep rose
#

you can also just set the rotation of the camera on start as well by using
Camera.rotation = Quaternion.Euler(0, 90, 0);

#

but im using Y since most if not all camera controller have X and Y variables for rotation

umbral hull
#

the local orientation has X facing to the left

steep rose
#

on what object

#

the camera?

umbral hull
#

yes

#

just tried this as well transformlocalEulerAngles = new Vector3(0f,90f,0f); but that did nothing

steep rose
#

actually just show your camera script

steep rose
#

is this a FPS camera controller?

umbral hull
#

yea

#

i dont feel its a scripting issue tho

rich adder
steep rose
umbral hull
steep rose
#

Ill just give you mine i'm a bit tired rn, I just gotta fix some issues with my VScode

rich adder
umbral hull
rich adder
umbral hull
rich adder
rich adder
#

also make sure it says its connected

umbral hull
rich adder
#

Assembly

umbral hull
rich adder
rich adder
umbral hull
#

yes

rich adder
#

ok so look at the output

#

or click the red, see what the errors say

#

you also have so many because you got a lot of the the csproj. checked in unity

steep rose
#

but finish what nav is guiding you through

umbral hull
rich adder
#

type dotnet or dotnet --info

umbral hull
rich adder
#

probably because its installed on G:

#

and PATH is usually expected from C: environment variables

#

its usually wise to keep these types of libraries on the main OS drive

umbral hull
#

ugh

#

i need to change my C drive bc its full :/

rich adder
#

You dont need the 6 ones

#

just dotnet 8 sdk + runtime

#

its not that big in size

umbral hull
#

so do i disable the others somehow or??

umbral hull
rich adder
umbral hull
#

ah

subtle sedge
subtle sedge
rich adder
#

bot has mixed feelings

subtle sedge
#

cause i had the same issue

#

i just restart my pc and it worked

umbral hull
#

its saying i have it

#

so like

rich adder
umbral hull
#

oh yeah that

rich adder
#

its trying to read the environment variable from path in c

subtle sedge
steep rose
#

it does work

umbral hull
faint agate
#

Hello, so I have a screen effect and hits 100% as the player does a 180. The problem is that it's also taking in the x axis, I only want the y.
I tried something out but couldn't fix since im not too great. I asked earlier, but was left even more confused.
heres the script https://pastecode.io/s/3gd4c2nb

steep rose
faint agate
umbral hull
steep rose
rich adder
steep rose
faint agate
#

yes sorry

faint agate
#

I only want it to take the y rotation. I see that since im using Camera without declaring it only to the y rotation. I just dont know how to do that

umbral hull
#

not the same script but the coding the change didnt fix it i mean

steep rose
rich adder
faint agate
#

unless im implementing it wrong, it makes it a type float and gives me an error

rich adder
steep rose
# umbral hull no

okay so all you are trying to do is rotate the camera on start 90 deg to the left, correct?

#

or are you trying to rotate your player model to the forward direction of the camera so it matches up

umbral hull
#

their orientation is not aligned with where the model is 'looking'

#

camera does this and all the models on the scene

faint agate
umbral hull
#

like i said before, i had to use vector3.right in my movement script to get them to go 'forward'. it's weird

rich adder
# faint agate okay, so I changed the header too and it doesnt give me an error and works but Q...

try something like this

float startYRotation = startDirection.eulerAngles.y;
float currentYRotation = Camera.main.transform.rotation.eulerAngles.y;
float angleY = Mathf.DeltaAngle(startYRotation, currentYRotation);
//Mathf.Abs(angleY) / 4f / 180f`

or might be better this way

Quaternion startYRotation = Quaternion.Euler(0, startDirection.eulerAngles.y, 0);
Quaternion currentYRotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
float angleY = Quaternion.Angle(startYRotation, currentYRotation);```
#

then use angleY / 4f / 180f

umbral hull
#

im not sure its a scripting issue or something i did with my models?

steep rose
umbral hull
umbral hull
steep rose
#

a normal object is rotated 0,0,0 on creation, you must rotate them 90 deg on the Y axis for them to face in the direction you want, while using local gizmos rotate the objects and where the Z axis is (the blue one) thats the forward direction

#

also use the local direction of the objects instead of global

next moat
#

sorry

#

just reading along

#

but is x forward or right?

rich adder
#

no, x is usually .right

next moat
#

oh

#

sorry

#

i'm r worded

umbral hull
steep rose
#

and are not working properly

umbral hull
#

yes i get hwat youre saying

#

how do i fix the camera issue tho. im kinda rlly focused on that right now bc its kinda late for me

#

oh im dumb

#

lemme reread

steep rose
#

my brain is on the verge of frying, this is not your or anyones fault im just very tired

#

I might be useless soon 🥲

next moat
#

hell yeah

#

same here bruther

#

i've been fried since noon

#

but also, i also have a quick question

#

nothin complicated, but I was just wondering if my unity version might affect the physics import

#

i'm tryna follow along someone else's code and while they're able to move around and look all over, my character is stuck floating only able to look up and down

steep rose
#

wild guess, add a rigidbody to your character and follow along closer

#

I dont have anything to go off of

next moat
#

my player model is a rigid body is the thing

steep rose
#

is it set to kinematic?

next moat
#

it was and then i disselected that and still the same

umbral hull
steep rose
#

Ill help if im available

umbral hull
#

but now this means i gotta remake the other models and reinsert them so uuuggghhhh

next moat
#

technically i haven't handled any "grounding" exceptions but would that screw anything up?

#

my model isn't falling through the terrain and gravity is on'

steep rose
#

and they should be orientated correctly

umbral hull
steep rose
faint agate
fierce geode
#

Is there a way for a spline animator to work in reverse? There's a ping pong mode that makes it go forward and back; but I kind of just want one that goes back.

Basically want to have it so my character can traverse from the start to the end of the spline, but also choose to go from the end to the start.

#

The easiest solution i can think of is having two splines, basically identical just with reverse directions. Just wondered if there was a smarter way

fierce geode
#

okay, found that you can reverse the flow of the spline

#

but can someone hit me in the head; i feel like I'm at -13 IQ. I'm trying to find which knot on the spline is the closest; to determine whether to start at the end or the start. But my program always seems to say I'm at the start, even when I'm dead at the end.

#

Please dont tell me that these are relative positions

fierce geode
#

Okay, dont use Knots.

#

Use the EvaluatePosition(float) with the float being between 0-1(start and end) of the spline

languid spire
queen adder
#

Okay sorry

light wagon
#

ive been trying to make a pinball flipper with a hinge joint 2d, and it seems to work when you turn on the motor, but immediately after becomes irresponsive and kind of spins at a constant rate indefinetly. does anyone know what might be causing this?

#

here is the settings for the rigidbody too. its connected to an anchor object with nothing but a rigidbody 2d with a gravity scale of zero.

#

please lmk if you have any idea how to fix this 🙏 ^^^

eternal needle
light wagon
# eternal needle have you looked at any tutorials for this? im not sure that joints would be the ...

i followed this basically 1:1
https://www.youtube.com/watch?v=X4ib7MKfWAI&t=109s
(skip to 1:15) but seem to be getting different results than the video

Hey everyone! Here's a demo explaining how to utilize the 2D physics engine in Unity to create flippers, bumpers, and a kickout hole for a pinball game. The code is written in C# and uses Microsoft's Visual Studio. Sorry for the long intro, for future demos I will be getting into the information much quicker. This is the first tutorial/demo I ha...

▶ Play video
eternal needle
light wagon
light wagon
#

do i need to lock anything in terms of position or rotation?

eternal needle
slate haven
#

Folks I am making a 2D game, I want the gears to move outside the boundary and immediately enter the screen from the left side, and sit on the new positions accordingly, such that it looks like assembly chain. How do I do it? ( I have a grid system with me)

It shall look like a circular loop
I want to apply it to different rows and columns
So I would want a generalised approach
If its a column, ofc it should move up or down and in a circular loop
https://pastecode.io/s/0wvzkz38

finite patrol
#

what do u guys think about alteruna

sullen rock
slate badge
#

Can anyone tell me why my jump isnt working anym?

slender nymph
#

you should be using ForceMode2D.Impulse for a jump

slate badge
#

The jump works, its just that I can jump infinitely now, the ground check doesnt work fsr

slender nymph
#

that tells me your jump variable is likely way too high since you're using the default forcemode.
but if the ground check doesn't work, then what have you actually done to verify that it is doing what you want it to?

slate badge
wintry quarry
slender nymph
devout flume
# slate badge

if (onGround = true) would always be true, unless I'm mistaken

#

I have C/C++ rules in head lol

languid spire
#

shame they decided to crop out all of the actual useful code

slender nymph
devout flume
devout flume
languid spire
#

yes, there are very few differences between the fundamentals of C and C#

burnt vapor
tawdry quest
#

yeah a = b = c = 1 works, but is a warcrime

burnt vapor
# slate badge

Your comparison is wrong.

- if (onGround = true && ...
+ if (onGround == true && ...
#

Next time, please properly share the !code.

eternal falconBOT
devout flume