#πŸ’»β”ƒcode-beginner

1 messages Β· Page 446 of 1

twilit iris
#

wait i forget how to change the language

quiet pilot
#

that might help

twilit iris
#

how do u cs for C# again??

quiet pilot
#

I'm not sure you can?

#

actually

#

no you can

wintry quarry
#

you don't need to

#

you set it in the prefab

quiet pilot
#
Debug.Log("test");
rich adder
quiet pilot
#

oh yeah cs

#

i was thinking you'd type just c# 😭

#

Yeah it shows the correct upward force

#

(don't ask about the number that was a random one I was trying)

mystic flower
#

hello i have simple ray intersect to do functions, but if i click on UI button, it also run the function of any object that was behind the button, anyone know how to stop this?

Physics2D.GetRayIntersection(camera.ScreenPointToRay(Input.touches[0].position));
quiet pilot
#

(also it still sends me up like 20 feet)

wintry quarry
#

UI is not physics

#

If you want to handle clicking on things and get UI blocking behavior, you should not be doing your own manual raycasts at all

#

you should use the event system

#

in this case - IPointerDownHandler

quiet pilot
#

physics on text makes me immediately think of like There is No Game or something lol

wintry quarry
#

Physics2D.GetRayIntersection

mystic flower
#

thanks! will look up about event system!

quiet pilot
#

LMAO I THINK I JUST PUT THE VALUE IN THE WRONG SPOT

#

I'VE BEEN WORKING ON THIS FOR DAYS 😭

#

wait

#

no

#

no I didn't

twilit iris
#

Im confused what to do with the anchor... I'm so dumb

quiet pilot
#

wait that's an awesome emoji

quiet pilot
#

see the box

#

the square thing

twilit iris
#

Actually maybe time to change my question, maybe my question was the one that dumb

#

How this code end up spawning my text on -910x, -480y

#

T_T

rocky canyon
#

y are you doing this dynamically?

#

couldnt u just premake the highscore gameobject.. and just enable it (set its text value) when u need to

twilit iris
rocky canyon
#

cool cool.. i'd start w/ gameobjects and stuff.. UI is the hardest thing u coulda started w/ lol

#

w/ all the anchors and noise

twilit iris
#

eh? it is ? T_T

quiet pilot
#

is ui really that hard?

#

maybe mine was just really simple

#

idk

rocky canyon
#

ya, some of it is easy

cosmic quail
rocky canyon
#

positioning stuff on the screen dynamically.. (getting resolutions, setting anchors, and all that stuff) can make it a bit more difficult

#

i like to set up my UI in the editor.. and then just enable them

cosmic quail
twilit iris
#

I'll try

rocky canyon
#

ya ^ u need to be using RectTransforms for Images/UI elements

#

its probably mixxing up worldspace coords w/ screenspace

twilit iris
#

IT WORKSS

#

THANKS T_T

twin bolt
#

Does anyone know why this code isn't working properly? https://i.imgur.com/jLWp1SD.png Releasing the Input enables gravity and removes constraints, but pressing the input only freezes the y rotation and disables gravity.

quiet pilot
#

If I remember correctly there's a bug that prevents this from working properly

#

or maybe it was something similar

#

Idk I'm probably wrong

twin bolt
#

I'm lost, im not sure why this wont work, so it may be a bug.

quiet pilot
#

I'm taking a unity class right now and I think they said something like that a while ago

#

so they might know

raw token
twin bolt
#

How am i overwriting it?

#

Oh wait, is it not setting them one by one?

raw token
#

.constraints is a bit flag - so you need to bitwise OR the subsequent values

twin bolt
raw token
#
.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;

or

.constraints = RigidbodyConstraints.FreezePositionY;
.constraints |= RigidbodyConstraints.FreezeRotationX;
.constraints |= RigidbodyConstraints.FreezeRotationZ;
devout flower
#

let's just say i wanted to disable a sprite, and the gameobject that the sprite is on only has a sprite renderer
if i were worrying about the code optimization, should i disable the gameobject, or use GetComponent and disable the spriterenderer component?

languid spire
quiet pilot
#

Does anyone know why

if (!(Mathf.Abs(transform.rotation.y * 360) < (181) && Mathf.Abs(transform.rotation.y * 360) >= (180)))
        {
            _bumper.transform.Rotate(0f, (-1 * _retRotModifier) * _rotationSpeed, 0f);
        }

makes the object (_bumper) rotate until it's at approximately -60 degrees?

languid spire
#

this
Mathf.Abs(transform.rotation.y * 360) < (181) && Mathf.Abs(transform.rotation.y * 360
is nonsense, rotation is NOT euler angles

rocky canyon
#

float yRotation = transform.eulerAngles.y; convert it to euler first -> then run ur comparison

quiet pilot
#

Oh, ok

#

I saw that it was a decimal

#

and thought that 1 would be like 360 or smth

raw token
#

Quaternion components are something which most of us may never hope or find motivation to understand πŸ˜…. Don't touch the x/y/z/w components of a quaternion.

rocky canyon
#

Quaternions are X,Y,Z,W

languid spire
rocky canyon
#

really? why. i'll look back

#

im pretty sure i corrected myself then too πŸ˜…

languid spire
#

it's simple, when you convert a Quaternion to Euler you have absolutely no guarantee what you will get back

mystic flower
#

i found a solution to my problem on some obscure forum where it is confirmed that it was a bug with unity itself, but some guy remade their function and that worked , god bless forum people

rocky canyon
#

what if we normalize it first? is that possible?

languid spire
#

what? normalize a Quaternion

rocky canyon
#

no the euler

languid spire
#

that makes no sense

quiet pilot
#

(also the reason the 181 and 180 were in parentheses was from an old thing I tried but ended up removing)

raw token
rocky canyon
#

i mean.. what do u mean theres no guarantee what you'll get back? its going to be an equivilent to the starting angle.. either on one side of the extreme or the other

#

couldn't that be made to be a 0 -360 result.. everytime

polar acorn
# rocky canyon no the euler

Euler angles aren't directions. Normalizing them doesn't make sense. You'll just end up at an orientation somewhere near 0,0,0

languid spire
quiet pilot
keen dew
toxic yacht
raw token
toxic yacht
#

For this there are a lot of different options. For example, if you're trying to control the direction the bumper car is facing, it might even be easier to ignore rotation entirely, and use the transform's forward vector instead

#

bumper.transform.forward = directionVec3

quiet pilot
#

Well I'm not trying to move it

#

because it's like a pinball flipper

#

(while writing the script I forgot the name for it lol)

toxic yacht
#

Ah mb. Yeah if you're just rotation in a single axis then eulerAngles will serve you just fine. They start breaking down when you start working with multiple degrees of rotation.

quiet pilot
#

See I'm trying to make it rotate, bounce the player, and return to the original position (slightly slower)

#

I really should move this to a separate scene so I don't have to wait 5 minutes every time I have to test something lol

wintry quarry
#

touching the Transform is a mistake that won't work

quiet pilot
#

Oh

#

Ok

wintry quarry
#

(assuming this is pinball)

quiet pilot
#

Sort of

#

it's a pinball-themed racetrack thing

wintry quarry
#

gotta move via the Rigidbody, yea

quiet pilot
#

a little bit like waluigi pinball from mario kart ds

#

I think it was ds

#

😭

rich adder
#

infinite loop?

quiet pilot
#

actually i should probably close photoshop

#

because that'd probably slow it down anyway

#

(but it still takes this long either way lmao)

willow scroll
#

I think they tell you when it's your code

quiet pilot
#
    float _yRot = transform.eulerAngles.y;
    Debug.Log((Mathf.Abs(_yRot) < 181 && Mathf.Abs(_yRot) >= 180));
    Debug.Log(_yRot);
    if (!(Mathf.Abs(_yRot) < 181 && Mathf.Abs(_yRot) >= 180))
    {
        _bumper.transform.Rotate(0f, (-1 * _retRotModifier) * _rotationSpeed, 0f);
    }

did end up working

#

thanks

#

(although the bouncing is still weird)

toxic yacht
quiet pilot
#

what about it?

#

I thought that was just for it turning

wintry quarry
#

you can't move your object via the Transform if you want physics to work

toxic yacht
#

Changing transform values happens separate from the actual physics simulation

quiet pilot
#

Ohh

#

I did have a different idea that might work

#

so I'll try that

#

because I think I might be trying to do something slightly different

#

but idk

willow scroll
#

Alright, no Approximately required here

errant solar
#

why i can't call this function i made it static what should i do to call it?

willow scroll
#

Try reading the error first

errant solar
quiet pilot
summer stump
#

Why does it need to be static if you are calling it in the same class?

quiet pilot
#

when calling it

#

I think

errant solar
polar acorn
# errant solar

Looks like there is no argument given that corresponds to the required parameter Sprinted of PlayerMovement.SprintingFunction(bool)

errant solar
#

so i made it static

quiet pilot
#

Yeah I'm pretty sure that's your error

summer stump
quiet pilot
#

you need to call it with the parameter

wintry quarry
#

basically you actually want to delete the parameter and remove static

willow scroll
wintry quarry
#

that's not something to call from another script

summer stump
quiet pilot
#

and remove static like they're saying

wintry quarry
#

why add another local variable

#

Seems most likely that should be a member variable

willow scroll
#

Inside of the class

quiet pilot
#

oh yeah that'd work too

#

actually yeah that'd work better

willow scroll
quiet pilot
#

because they'd probably need it in multiple places

quiet pilot
#

oh

#

(can you explain why not?)

willow scroll
#

You can see the warning on the bool Sprited

#

Which tells them the variable is not used inside of the method and is redundant

quiet pilot
#

Ohh

#

I didn't see that sorry

willow scroll
#

They seem to be redundantly updating this variable inside of the method, which does not affect the class at all

#

They either have to make this method non-static and update the global variable, or return this variable, making the method's return type bool

late burrow
#

are jobjects bad for using like array

frosty hound
#

No

#

Given what you've considered bad in the past (including the ridiculous belief that you'll make "the lag" from size of scripts), I'm going to just get ahead of this and say stop over thinking it.

vocal wharf
#

I'm kind of new to coding and I need help.
I'm working on a "test project," just a project made for exploring new things and learning about coding (it's not like a finished game or anything). I want to be able to spawn in a prefab and destroy it when I click with the mouse button. I have the spawning part done and it works great but unity will not let me destroy the prefab. It keeps giving me an error: "Destroying assets is not permitted to avoid data loss." Can you help? Here is my code so far:

sweet sierra
#
            string outputPath = Path.Combine(Application.streamingAssetsPath, "LevelAvailibility.txt"); ;
            System.IO.File.WriteAllText(outputPath, modifiedContent);

Can't seem to write to the file. Reading takes place fine.

#

I need to have a file that stores the data of what levels are accessible

polar acorn
vocal wharf
#

during runtime

polar acorn
sweet sierra
vocal wharf
polar acorn
summer stump
polar acorn
sweet sierra
# polar acorn Does it actually give you an error that it can't write, or is the file just unch...

An error...

DirectoryNotFoundException: Could not find a part of the path "F:\Unity Projects\animal-hoop\Assets\StreamingAssets\LevelAvailibility.txt".
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <51fded79cd284d4d911c5949aff4cb21>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) (at <51fded79cd284d4d911c5949aff4cb21>:0)
(wrapper remoting-invoke-with-check)
polar acorn
#

and it'll store the result in that variable

vocal wharf
polar acorn
sweet sierra
vocal wharf
polar acorn
#

Make a variable, and set that variable to the return value of instantiate

#

Just plug in whatever you decided to name that variable instead of thatVariable

vocal wharf
#

do I put that in the top where I put my references?

vocal wharf
#

I'm so confused

summer stump
#

You MUST call instantiate somewhere if you have your prefab being added to the scene, right?

vocal wharf
#

yes in the if statement in the update method

summer stump
vocal wharf
#

ok

summer stump
#

All you are doing is adding var instance = in front of it

#

Or whatever type it is, and whatever name you want to use

vocal wharf
#

I called it destroyableItem

#

how do I reference it

polar acorn
# summer stump No

Actually, yes. Assuming you want to reference it across multiple frames @vocal wharf

#

Make a field variable, set that variable to the thing when you instantiate it

#

then you destroy that object

summer stump
#

Sorry, I meant that the Instantiate does not go up there.

#

Yeah, the cached variable can be a class member, and does make sense to be one

vocal wharf
#

here is what I have

polar acorn
#

Just like you have made your other three variables

vocal wharf
#

it's probably so simple

queen vapor
#

why do i get these errors can someone help me

summer stump
summer stump
#

As for MoveDirection, is it a Vector? That one may clear after fixing the others

queen vapor
#

using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.EventSystems;

public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 playerVelocity;
public float speed = 5f;
// Start is called before the first frame update
void Start()
{
controller = GetComponent<CharacterController>();
}

// Update is called once per frame
void Update()
{
    
}
//recive the inputs for our InputManager.cs and apply them to our character controller.
public void ProcessMove(Vector2 input)
{
    Vector3 moveDirection = Vector3.Zero;
    moveDirection.x = input.x;
    MoveDirection.y = input.y;
    controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
}

}

#

this is the code

#

i was following a tutorial im a beginner

summer stump
#

Remove using System.Numerics from your class

#

You made a typo. It is supposed to be moveDirection, not MoveDirection

queen vapor
#

okay i did it thank yo so much

queen vapor
#

and these are still here XD

summer stump
#

You need to make it like those. With a type

#

You cannot just write a random word somewhere

vocal wharf
#

like public or something?

summer stump
queen vapor
#

@summer stump thank u so much u a real one fam

summer stump
#

The type

summer stump
vocal wharf
#

ohhh gameobject

summer stump
#

That is a type, yes

vocal wharf
#

I hate myself

summer stump
#

Do not say that

#

Both annoying and unhelpful. Verbal self-harm is still self-harm

vocal wharf
#

well it's the truth lol

#

anyway I'm gonna test this rq

summer stump
# vocal wharf well it's the truth lol

I will not help you again if you don't stop with that
You are learning, it is absolutely wild to "hate yourself" over being in a learning process. Don't

vocal wharf
#

whatever

#

it works

#

however it only destroys the last object that I spawned

stray wraith
#

anyone know how I could mimic unity's scene view camera rotation? I want to make a perfectly accurate camera rotation script so that if I press right click on a small dot in the camera's view and start moving my mouse and rotating my camera the camera would move perfectly with the mouse, and the cursor would always stay above the dot

queen vapor
#

btw aethenosity why my player goes up to the sky when i press w and goes down when i press s but a and d buttons work @summer stump

vocal wharf
summer stump
queen vapor
#

and it works

queen vapor
#

no its 3d

#

but in the tutorial it works

summer stump
#

Then are you sure he is not using Z ?

#

Or has other code?

queen vapor
#

let me check again

#

ohhh he changed the code and didnt mention in the video

vocal wharf
#

@summer stump when I spawn 2 crates and aim at the first one it deletes the second one because it only destroys the one that I last instantiated. I have a sphere in front of my character that follows the camera movement and has a trigger collider. I want to delete a crate when it is inside that sphere and when I press the mouse button. Is there a way to do that?

sweet sierra
#

I feel kinda dum dum but I'm new to unity so ig it's fine 🌝

sweet sierra
#

To store the instances that you created

vocal wharf
#

I've done it before but for some reason my project that had that code got deleted

sweet sierra
short hazel
vocal wharf
#

I want to delete the crate when it's inside that sphere and when the mouse button is clicked

polar acorn
sweet sierra
#

How do I write the same file I've read from

#
 string filePath = "Data\\LevelAvailibility"; 
 string fileContents = Resources.Load<TextAsset>(filePath).text;

 int currentLevel = int.Parse(SceneManager.GetActiveScene().name[5..]);

 string modifiedContent = fileContents + "\nLevel" + currentLevel++;

 string outputPath = Path.Combine(Application.streamingAssetsPath, "LevelAvailibility.txt"); ;
 System.IO.File.WriteAllText(outputPath, modifiedContent);
short hazel
#

Your path shows StreamingAssets, which means you've probably piped Application.StreamingAssetsPath to it

#

Yep

#

The StreamingAssets folder might just not exist under your project directory

#

Hence the needed usage of Directory.CreateDirectory(Application.StreamingAssetsPath) beforehand, which will ensure it exists (and do nothing if it's already the case)

sweet sierra
#

I sound so dumb but your help is much appreciated! πŸ™Œ

short hazel
#

No, that will make the outputPath actually exist on your computer, so File.WriteAllText() can actually locate it

#

The reading from Resources works fine, it's the writing to StreamingAssets that fails

sweet sierra
#

Ohh. Okie I'll try that

vocal wharf
sweet sierra
sweet sierra
short hazel
#

From the one in StreamingAssets? With the File.ReadAllText() method

summer stump
eternal falconBOT
#

:teacher: Unity Learn β†—

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

summer stump
#

Using a trigger area is covered in the pathways

vocal wharf
#

wdym pathways

short hazel
#

It's read-only

summer stump
vocal wharf
#

ok

vocal wharf
languid spire
#

Damn silly to check for input in a trigger or collision method

vocal wharf
#

what why?

languid spire
#

you would need to hit the key on the exact same frame as the trigger goes off

vocal wharf
#

πŸ’€

#

no freakin wonder

#

Is there a way in the update method to reference the object that entered the trigger?

languid spire
#

only if you make it so, why not the other way round?

summer stump
#

I really recommend you stop and do the guide I sent

vocal wharf
vocal wharf
languid spire
# vocal wharf wdym

hmm, save the fact the the input was triggered and check for that in the trigger method

sweet sierra
summer stump
sweet sierra
short hazel
vocal wharf
#

I have googled many things and searched many forums already and I'm so done with this mess

sweet sierra
#

Like see here

#

I'm checking If I can access a level

thick dove
#

I'm trying to have two different trigger colliders on this gameobject. I tried using .Istouching but that didn't seem to work, is there a simpler way to detect which trigger collided with the object?

short hazel
sweet sierra
tulip cipher
#

@thick dove where is the other collider?

thick dove
#

in a child

sweet sierra
#

So, to sum it up:

  • Resources for reading
  • Streaming for writing
  • Persistent for both

Or I hope πŸ˜‚. I'll search on this

thick dove
#

Oh, do I have to do this in the child and then send that to this main script?

tulip cipher
#

@thick dove can you explain me what are you trying to do?

summer stump
thick dove
#

Alright, thanks

tulip cipher
#

Another thing you could do is to set the Ontrigger on the parent's script and then call childs

#

but the answer above is better

wide raven
wide raven
wintry quarry
#

what's the issue?

sweet sierra
#

@short hazel This is insult πŸ˜‚

#

It works fine for dataPath though

vast vessel
#

yo guys!
any ideas on how i can automatically correct the location of these portals after placing them via code, so they dont get placed on weird places, like half outside of the world, or being half placed on non portal-ableworld geometry?(black metal walls are non portal-able) (also already have code for detecting if the material that a Raycast hit is portal-ableor not)

#

here is my current code.
pretty simple

#

just checks if the raycast hit a portallable surface then rotates and moves the portal

wintry quarry
vast vessel
#

i also want to PREVENT placing portals on surfaces too small

wintry quarry
#

like, the "is this a valid spot" check should also be doing the "can I fudge this slightly to be in a valid spot thing

#

And it's probably doing something like a capsule cast

vast vessel
#

how do i know where to move the portal do so it dosnt overlap anything, or dosnt have any overhangs?

wintry quarry
#

probably something like:

  • capsule cast
  • if capsule hits on top or bottom (instead of on its side), try another capsulecast from the hit location along the tangent of the surface with a limited distance until finding a spot where the side of the capsule hits
#

definitely not a one-liner

#

there's probably a lot of edge cases as well

#

you probaly also will want to sample the wall at at least a few points within the projected oval area to make sure the material is correct everywhere

crisp token
#

what is the c# naming convention for abstract classes

wintry quarry
wide raven
wintry quarry
#

but, it doesn't look to "fit" in either video

wide raven
wide raven
#

you can see it is resizing

#

In the original one

wintry quarry
wide raven
#

like have a seperate camera that renders it

#

so It fits like that

#

or

#

Idk

#

Resize sprites?

wintry quarry
#

so then you shouldn't need to do any resizing etc

#

just only zoom the game camera

#

leave the separate camera alone

wide raven
#

Currently I use solo camera

#

So you say that I should use seperate cameras to achieve that?

wintry quarry
#

that's certainly an option

wide raven
#

But as far as you can see they kinda get closer like squish a little to fit but I feel like it is a seperate camera that squishes on the x axis to give the illusion i guess

eternal flame
#

I can't get my unity app to receive data over udp

#
using UnityEngine;
using System.Net;
using System.Net.Sockets;

public class UDPListener : MonoBehaviour
{
    private UdpClient clientData;
    private int portData = 50505;
    private IPEndPoint ipEndPointData;
    private System.AsyncCallback AC;
    private byte[] receivedBytes;

    void Start()
    {
        InitializeUDPListener();
    }

    public void InitializeUDPListener()
    {
        ipEndPointData = new IPEndPoint(IPAddress.Any, portData);
        clientData = new UdpClient(portData);
        
        Debug.Log($"UDP client listening on port {portData}");
        
        AC = new System.AsyncCallback(ReceivedUDPPacket);
        clientData.BeginReceive(AC, null);
    }

    void ReceivedUDPPacket(System.IAsyncResult result)
    {
        receivedBytes = clientData.EndReceive(result, ref ipEndPointData);
        ParsePacket();
        clientData.BeginReceive(AC, null);
    }

    void ParsePacket()
    {
        Debug.Log($"Received packet from {ipEndPointData}. Length: {receivedBytes.Length} bytes");
        // Here you can add code to process the receivedBytes as needed
        // For example, converting to a string:
        string message = System.Text.Encoding.UTF8.GetString(receivedBytes);
        Debug.Log($"Message: {message}");
    }

    void OnDestroy()
    {
        if (clientData != null)
        {
            clientData.Close();
        }
    }
}```
#

i can receive the data with a similar script if i don't run it in unity, but as soon as i try to use it in unity it won't receive the data

#

so unity must be blocking it somehow i just can't figure it out

queen vapor
#

hello guys

#

how do i fix these errors

polar acorn
queen vapor
#

this is my code

languid spire
#

!code

eternal falconBOT
polar acorn
#

Start at the top

queen vapor
#

but i dont know how to im a beginner and i was following a tutorial

polar acorn
#

The first error says there's nothing called lerpCrouch and your code confirms

queen vapor
#

he didnt show me how to

wintry quarry
polar acorn
queen vapor
#

can i send links here?

polar acorn
#

yes

queen vapor
#

The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.

I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!

Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...

β–Ά Play video
#

and im at 21.18

polar acorn
#

Did you actually watch the future videos?

queen vapor
#

no he said try to do this by yourself

#

and i tried (failed)

polar acorn
queen vapor
#

i did and it doesnt work

#

it gives me these errors

polar acorn
#

You're supposed to actually attempt to write the code yourself not just copy verbatim small snippets of someone else's code

queen vapor
#

but bro im new at this ;((

#

wdym write the code yourself

polar acorn
#

Well, you're 20 minutes into the tutorial, have you actually been attempting to learn what the code is doing or just copy-pasting what they've done without taking any attempt at understanding what it means

polar acorn
# queen vapor wdym write the code yourself

Whenever you open Visual Studio, keystrokes on your keyboard get translated into letters in the code. Letters can combine to form things called "Words" which can be used to convey meaning

queen vapor
polar acorn
#

You should be learning the language first

#

There are guids linked in the pins, or on !learn

eternal falconBOT
#

:teacher: Unity Learn β†—

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

polar acorn
#

Code isn't magic. Those words all mean things. Learn what they say and you can combine them in literally infinite ways

queen vapor
#

k thanks so do i just close this project...

polar acorn
#

You should at the very least remove the code you were never supposed to copy-paste

#

Examples are meant to be instructive, not to do it for you

languid spire
queen vapor
queen vapor
eternal flame
#

@polar acorn I can't get my unity app to receive data over udp
using UnityEngine;
using System.Net;
using System.Net.Sockets;

public class UDPListener : MonoBehaviour
{
private UdpClient clientData;
private int portData = 50505;
private IPEndPoint ipEndPointData;
private System.AsyncCallback AC;
private byte[] receivedBytes;

void Start()
{
    InitializeUDPListener();
}

public void InitializeUDPListener()
{
    ipEndPointData = new IPEndPoint(IPAddress.Any, portData);
    clientData = new UdpClient(portData);
    
    Debug.Log($"UDP client listening on port {portData}");
    
    AC = new System.AsyncCallback(ReceivedUDPPacket);
    clientData.BeginReceive(AC, null);
}

void ReceivedUDPPacket(System.IAsyncResult result)
{
    receivedBytes = clientData.EndReceive(result, ref ipEndPointData);
    ParsePacket();
    clientData.BeginReceive(AC, null);
}

void ParsePacket()
{
    Debug.Log($"Received packet from {ipEndPointData}. Length: {receivedBytes.Length} bytes");
    // Here you can add code to process the receivedBytes as needed
    // For example, converting to a string:
    string message = System.Text.Encoding.UTF8.GetString(receivedBytes);
    Debug.Log($"Message: {message}");
}

void OnDestroy()
{
    if (clientData != null)
    {
        clientData.Close();
    }
}

}
i can receive the data with a similar script if i don't run it in unity, but as soon as i try to use it in unity it won't receive the data
so unity must be blocking it somehow i just can't figure it out

eternal falconBOT
eternal flame
#

that is on me

#

i had it in a code block

#

but i copy pasted it wrong

summer stump
#

Use a paste site

eternal flame
#

I can't get my unity app to receive data over udp

using UnityEngine;
using System.Net;
using System.Net.Sockets;

public class UDPListener : MonoBehaviour
{
    private UdpClient clientData;
    private int portData = 50505;
    private IPEndPoint ipEndPointData;
    private System.AsyncCallback AC;
    private byte[] receivedBytes;

    void Start()
    {
        InitializeUDPListener();
    }

    public void InitializeUDPListener()
    {
        ipEndPointData = new IPEndPoint(IPAddress.Any, portData);
        clientData = new UdpClient(portData);
        
        Debug.Log($"UDP client listening on port {portData}");
        
        AC = new System.AsyncCallback(ReceivedUDPPacket);
        clientData.BeginReceive(AC, null);
    }

    void ReceivedUDPPacket(System.IAsyncResult result)
    {
        receivedBytes = clientData.EndReceive(result, ref ipEndPointData);
        ParsePacket();
        clientData.BeginReceive(AC, null);
    }

    void ParsePacket()
    {
        Debug.Log($"Received packet from {ipEndPointData}. Length: {receivedBytes.Length} bytes");
        // Here you can add code to process the receivedBytes as needed
        // For example, converting to a string:
        string message = System.Text.Encoding.UTF8.GetString(receivedBytes);
        Debug.Log($"Message: {message}");
    }

    void OnDestroy()
    {
        if (clientData != null)
        {
            clientData.Close();
        }
    }
}```
i can receive the data with a similar script if i don't run it in unity, but as soon as i try to use it in unity it won't receive the data
so unity must be blocking it somehow i just can't figure it out
summer stump
eternal flame
#

there you go

#

oh

#

i thought this was code

summer stump
#

Basically no networking stuff EVER belongs in the beginner section though haha

#

Also, be sure to use a paste site. That is way too long for just a code block

eternal flame
#

fair

ember gate
#

if Im creating a small pick up system like coins I have to create a script for the coin itself and when its touched it deletes itself and adds to some ui at the top but like how can I make it so the ui text is raised when coin is picked?

#

I don't want an indepth explanation just where to write that code the one that adds 1 everytime coin is touched so I can figure out myself from there

deft grail
ember gate
#

the ui?

deft grail
ember gate
#

im pretty new so I won't go into tweening just yet tbh

#

other way? cause like I know what to write for the coin but idk how to add a score when its picked

#

idk if it should be done in the same script or a different one

deft grail
#

on the coin or player

ember gate
#

that for destroying it or for adding it to the score?

deft grail
#

if you trigger it, means you collected it, means you should add score > animate it > destroy it

ember gate
#

ok lemme try and i'll say if I managed to do that

deft grail
ember gate
deft grail
ember gate
#

i get this now

#

idk why I cant acces totalcoins value from the coins script into the counter script

deft grail
#

you can see in the Unity console

ember gate
#

an object reference is required for the non static field

deft grail
ember gate
#

what does that mean?

deft grail
# ember gate

first of ill say the idea of this line seems weird and pointless anyway

deft grail
ember gate
#

im checking if the coin amount is different than the one that is on the text and if it is it should change it

#

oooh

deft grail
#

because checking that line in Update isnt the most efficient

#

probably would still run perfectly fine in your game, but its still not the best practice

ember gate
#

its still just so I can learn so its alright atm ig

deft grail
#

it also just doesnt really make sense to check "if the text and coin is different > update text"
when you can just do "on collect coin > update text and coin"

ember gate
#

ye but idk how to update the text through the same coin script

#

so i have a script for the text ui

deft grail
#

the scripts are no different between eachother

ember gate
#

so in the same coin script I can manipulate the ui text?

ember gate
#

for some reason it seems so complicated for me

#

how can you do that

#

wait

#

I think i know how

#

one sec

#

what library I need for TMP text?

deft grail
ember gate
#

in code

slender nymph
#

if your IDE is properly configured you can just use the quick actions to import the correct namespace

deft grail
deft grail
eternal falconBOT
late burrow
#

i kinda want use everything in json now

#

its nice to not need define every new variable i want to use

ember gate
#

for some reason I cannot drag my text to the coin inspector

#

like it does not want to go in the box

slender nymph
#

either you've used the wrong variable type or you're trying to drag a scene object into a prefab

ember gate
#

its not a prefab

#

I did this

slender nymph
#

TextMeshPro is not the UI one, it is the world space text object. you want to use either the parent class TMP_Text which is the parent of both of them or use the correct derived class TextMeshProUGUI

ember gate
#

oh

#

ok ye

#

thanks

#

good the counter works as well

#

thanks guys

#

oh btw would you guys know why the text is a bit blurry?

deft grail
# ember gate thanks guys

np, also to say if you WERE to access your coins in another script
its private and wouldnt even BE able to access in another script

ember gate
#

but thanks

deft grail
ember gate
#

no problem its not a big deal atm

#

i wanna make a small puzzle game sort of

#

idk don't got any ideas atm but ill come up with sum tomorrow

#

thanks for the help ❀️

crisp token
#

is this the correct way to use base class constructor in c#?

short hazel
crisp token
short hazel
#

Yes

#

Do note that since you use custom constructors, any of these cannot inherit from MonoBehaviour. Unity doesn't like the constructors, since it can't know what to pass when you attach the component onto an object. For other uses, it's fine

crisp token
short hazel
#

Huh?

crisp token
#

idk on my screen my text is red, nvm

short hazel
#

In Discord, means the message failed to send

crisp token
#

"I should just be able to apply any monobehavior stuff from there right?"

primal trench
#

how would i check if a mouse is hovering over a button?

short hazel
#

A lot of features will not work if your class doesn't inherit from MonoBehaviour. You won't get Unity messages like Start and Update

crisp token
short hazel
#

Yes that's not tied to specific MonoBehaviour features, so it will work

crisp token
#

well it could be as long as I access the monobehavior features through the monobehavior class I thought

crisp token
short hazel
#

Yes they're only available there, unless you pass them around. If your abilities need to access the script that queues them, you can inject it: someAbilityVariable.DoStuff(this)

#

In ability: public abstract void DoStuff(YourScript context); and override in children

rich adder
#

for the inspector only without script, you can use an Event Trigger

crisp token
vast vessel
#

to guys.
i have no idea how these bitwise operations work. can someone tell me what exactly this piece of code is doing?

crisp token
#

and equals would be my guess idk

rich adder
#

its bitwise AND

vast vessel
rich adder
gusty scaffold
#

a variable like an int or a char is ultimately stored in binary

rich adder
#

usually when dealing with bitmasks

gusty scaffold
#

so it's something like 1101

#

if you do bitwise "and" with 1101 and 0111

#

the first digit is 1&0 = 0

vast vessel
gusty scaffold
#

second digit is 1 & 1 = 1

#

third digit is 0 & 1 = 0

#

fourth is 1&1=1

#

so the result is 0101

gusty scaffold
#

it's easier to see if you line them up vertically

1101
0111
----
0101
vast vessel
gusty scaffold
#

it depends how a bool is stored in bits

#

which i'm not sure of

#

theoretically, you only need one bit to represent a bool

polar acorn
gusty scaffold
#

but computers aren't designed to handle single bits

#

so a bool is probably stored in 8 bits or something

gusty scaffold
#

my guess is it would be the same as a regular "and" operation

#

but to know for sure...

gusty scaffold
#

first of all, does Linecast return bool?

#

yes

vast vessel
#

yea

rich adder
vast vessel
#

can someone just tell me if this is what that line is doing pleaseee
IsOverlapping = IsOverlapping & RandomBool

gusty scaffold
#

i would assume so

#

you'd have to check docs to be sure

#

i'm taking a look

gusty scaffold
rich adder
#

its not that complex

#

true & true = true

vast vessel
#

wow thanks

vast vessel
rich adder
vast vessel
#

whatever dude

rich adder
#

the first one was also correct

gusty scaffold
orchid zinc
#

does it matter what version of visual code studio i use with unity? for example can i use vcs 2019 with the latest lts unity

gusty scaffold
#

and someone said & is equivalent to && when the operands are bools, which makes sense to me

rich adder
#

vsc and vs are not the same program

orchid zinc
#

ohhhh

#

this one

rich adder
#

yes thats Visual Studio

#

its old, you should use the 2022 one

eternal needle
#

It doesnt matter what IDE you use at all, as long as you can configure it. Though you might as well use the latest

rich adder
#

a bit faster since its 64 bit app, and you have nice addition like intellicode

orchid zinc
#

alr thanks

gusty scaffold
orchid zinc
#

when installing what happens if u dont select game development with unity? does it not work properly?

#

just curious

rich adder
#

those two features you see .Underline red and showing the classes / and functions etc.

timid quartz
#

say I've got a Vector3 representing the offset I'd like the camera to be at in regards to the player - something like (0, 10, 10) or something to keep it simple. and I want the camera to follow the back of the player. if the player were literally always facing forwards, I could just add the offset to the player position, but what am I missing to make it so that the camera is offset in the direction of the player's transform?

orchid zinc
teal viper
timid quartz
#

sorry - how would I go about doing that?

teal viper
timid quartz
#

oops you're totally right

#

you totally nailed it, that was exactly what I needed. thanks other lich!!

thick swift
#

If I want to use the Tunnelling Vignette prefab from the samples folder, how do I make my own version of it? When I copy the folder into my Assets/Prefabs folder, then drag the prefab over my camera, it creates Tunnelling Vignette_1 in the scene.

copper orbit
#

when enemy is hit, it moves the enemy 2 meters back based on shot direction. That's what i am trying to do with this code anyway. Not sure why the enemy is not moving on hit. No errors or null references

rich adder
orchid zinc
#

ok so i got vs 2022 and i checked the unity box while downloading but it doesnt see any of the unity functions

#

no MonoBehaviour, no start, no update

rich adder
orchid zinc
#

wheres external tools

rich adder
#

its there one of the steps

orchid zinc
#

well i just installed vs and unity just opened it on its own

rich adder
#

well go back n do the steps

ivory bobcat
#

!vs

eternal falconBOT
#
Visual Studio guide

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

β€’ Visual Studio (Installed via Unity Hub)
β€’ Visual Studio (Installed manually)

orchid zinc
#

yes i selected the unity workload

ivory bobcat
#

Make sure the external tools are setup correctly and regenerate the project

sleek marten
#

I'm using this code to prevent my player from moving to a UI element when it's clicked on

            if (EventSystem.current.IsPointerOverGameObject())
            {
                // Do nothing
                return;
            }```
and that's working fine when I'm in Game display. When I switch to Simulator and I click on a button I move to its location. If I keep clicking on a UI element I won't move to those areas anymore. Why is this happening?
teal viper
sleek marten
#

huh

#

didn't know that could happen

#

what do I do?

teal viper
#

On mobile you'll need to handle it differently. For example, each time you click, make a check if the click is over the UI before executing whatever logic you want.

sleek marten
#

so something like(?)

       {
           // Do nothing
           return;
       }
 else{}```
teal viper
#

You'd probably need to implement some method to check if a point is within the bounds of any of your ui.

sleek marten
#

I was thinking of throwing in an else statement but that didn't work

sleek marten
#

I really don't understand what the problem is with how I've set it up

        {
            // Check if the click is over a UI element
            if (EventSystem.current.IsPointerOverGameObject())
            {
                // Do nothing
                Debug.Log("Clicked on the UI");
                return;
            }```
I check for mouse input and then it checks for any UI right after. Works perfectly fine in Game mode and the manual says it should work in Sim too
keen sonnet
#

Is there a chart of all of the main codes

#

Like "if"

#

And that stuff to make coding easier

keen sonnet
#

Thanks

misty remnant
#

i have a question how can i rotate an object around another object to a certain degree so if i put transform.RotateAround(Vector3.zero, Vector3.up, 20) in void update it would not just keep spinning it would just stay at that angle around that object

fathom timber
raw token
#

Not a bad idea for an extension method... RotateAroundTowards()

gusty scaffold
#

if you put that line in Update(), it will keep getting executed

misty remnant
fathom timber
ancient rampart
#

what would you guys recommend for importing and exporting yaml data? looking to read a yaml file and then assign gameobjects based on the info in there

#

I saw yamldotnet was an option, but not sure if that's the standard

graceful crystal
#

can someone explain how to fix this

deft grail
summer stump
graceful crystal
#

ahhh thanks it fixed that error

#

but got a new one which is so fun

warm surge
#

Im trying to simulate audio waves, but I'm not sure of how to go about it. I've thought about raycasting, but im not sure if it would be the most performant. I need to be able to detect when sounds collide with walls in particular.

warm surge
#

But in large quantities with maybe 1,000+ rays each frame will it still be performant?

#

up to 1,000*

rich adder
#

why do you need 1000 rays

#

it would probably make more sense using a bigger query like overlap that grows then do raycast on hit items you're interested to check walls

warm surge
#

what do you mean by "bigger query like overlap"

rich adder
#

like overlap sphere / circle for example

warm surge
#

thats what i was thinking about, but then how would that work? The sphere grows and hits something end keep expanding, but where do I cast the rays from? The sphere has a continuous surface so how would i cast rays several times on one surface from a sphere

rich adder
warm surge
#

oh wait i had an idea

rich adder
#

like real sound

#

yea

warm surge
#

wait no i didnt

#

so what happens when the sphere collides with a wall or something. how does the wave bounce off

rich adder
#

or spherecasts

warm surge
#

whats a spherecast?

rich adder
#

throw a ball of certain radius, whatever it hits, thats a spherecast

#

just a fancy raycast that is thicc

warm surge
#

that makes sense

#

im thinking that maybe a plain raycast might be the best option

rich adder
#

what are you trying to accomplish with these waves?

warm surge
#

i want to highlight the areas the waves are hitting. so if theres a wall next to a speaker or something, the wall is highlighted red because its close, while a wall across the room is highlighted blue because its far

#

and waves can bounce off walls and add onto eachother if they land on spots that are already highlighted

teal viper
#

This kind of a simulation would require a lot of computation

warm surge
#

thats what im worried about

teal viper
#

Might need to write a compute shader for that.

warm surge
#

i was thinking about shaders, and have known i'll probably need to write one, but my only problem is idk how to highlight walls and stuff.

#

The more i think about it the more complicated it gets

cedar bone
#

Is it a good idea to have every feature for the player in one giant script, or split it up to different scripts?

#

i mean features that directly address the player, not every feature for the game

raw token
# cedar bone Is it a good idea to have every feature for the player in one giant script, or s...

It's really a personal preference, buuuut...

The sort of prevailing wisdom is that "monolithic scripts" are unwieldy and difficult to work with... The more atomic a script is, then all of the code related to that part/feature are in a nice condensed package such that you're less likely to overlook a necessary change or get lost in the implementation. Plus, you can easily leverage the strengths of OOP and inheritence such can easily create subclasses for unique variants.

In a monolith you often end up hunting around for all of the places which touch and implement that functionality, and it's easier to miss something if you make a change or decide to revamp or replace the implementation... let alone creating some variant of it.

This is some small portion of the reasoning behind the "Single Responsibility Principle" facet of SOLID, which asserts that a class should only have a single reason to be changed. More or less, a class should only be responsible for one thing only.

Personally, I'm not great at adhering to that principle out of the gate. But I often find I'll prototype in larger chunks of code and refactor into separate classes when the discrete behaviors become more defined.

tiny plaza
cedar bone
#

is it a good idea to make variables in one script

#

and then make everyother script on the palyer change that variable from that script?

#

because main thing im worried about when using different scripts is having to getComponent 3 times to get a couple variables

warm surge
raw token
# tiny plaza why does my chracter keep moving left when i jump?

Hard to say based on that video alone. If you suspect your code could be responsible, you should share that code. It might also be an input issue - if you're using a controller or have one attached, that could easily be like a joystick hanging out outside of the deadzone

cedar bone
#

is it those things in the particle system component?

#

where u can see different settings?

warm surge
# cedar bone wdym by module?

module is an arbitrary name for each script. you have your movement module, your inventory module, your interactions module. you dont need to call them module, but the fact that each idea is broken up into different scripts makes the parts of the player modular, which is why its called a module

cedar bone
warm surge
#

and also the fact theyre easily changable

cedar bone
#

This was really helpful πŸ‘

warm surge
#

youre welcome

cedar bone
#

thank you!

#

anything else I should know?

warm surge
#

maybe, i'll think and let you know if theres anything i can think of

raw token
# tiny plaza here's my code

Okay, cool. That all looks fine - that code shouldn't be responsible, unless the cube isn't sitting directly aligned with the world axes... You could test that real quick - temporarily swap out transform.up with Vector2.up

cedar bone
#

also what are scriptable objects?

#

it seems important for keeping code clean

tiny plaza
warm surge
# cedar bone it seems important for keeping code clean

theyre a special class that lets you create assets that can hold data. Unlike MonoBehaviours, they dont need to be attacthed to game objects and dont exist in the scene. theyre saved as assets in your project and can resued on different scenes and prefabs

warm surge
#

not necessarily, but you can use it like one

raw token
cedar bone
warm surge
#

one example i can think of would be a dialogue system

tiny plaza
cedar bone
tiny plaza
#

wait

tiny plaza
cedar bone
#

where settings can be changed

raw token
warm surge
cedar bone
#

so a scriptable object is just a script that stores data?

tiny plaza
cedar bone
#

and scripts can access it to do logic?

cedar bone
raw token
warm surge
cedar bone
#

and it doesn't do any logic?

#

and it can store functions im assuming?

tiny plaza
cedar bone
#

sorry for the ton of questions

warm surge
#

and its fine ur asking lots of questions

#

i dont mind

cedar bone
raw token
toxic yacht
#

The way I've thought about scriptable objects is as unity's all-in-one do to data driven. Its common to want to serialize data, like say the possible moves for a pokemon, in something like a json file. But in order to make that work, you need to do file parsing, and if you want type safety feed the dict that comes out of parsing to builder for your own class. Scriptable objects wrap all of that in a single feature for you.

cedar bone
raw token
# tiny plaza

Have you written any code for horizontal movement?

cedar bone
tiny plaza
warm surge
cedar bone
#

rigidbodies are weird

#

OOOH

#

ok

#

that makes sense

toxic yacht
cedar bone
warm surge
#

yea that reddit comment didnt make much sense to me

#

didnt quite understand what they were getting at

mint remnant
tiny plaza
#

i tried going back to default gravity scale and it does nothing

raw token
#

My mind is boggled πŸ˜•

mint remnant
#

Angular drag defaults to 0.05, curious why or if that was changed if would impact it

cedar bone
#

are materials scriptable objects?

tiny plaza
#

i did this and it solved it

cedar bone
warm surge
mint remnant
tiny plaza
warm surge
#

materials are not derived from the scriptable object class

toxic yacht
toxic yacht
#

A lot of frameworks/pipelines/libraries use scriptable objects for their settings

tiny plaza
#

btw do i need to use Time.deltaTime on addforce?

raw token
tiny plaza
mint remnant
raw token
# tiny plaza perfect!

(For completeness' sake, it depends on your ForceMode... ForceMode.Force is default. But you usually don't want it at all if you're using one of the modes which doesn't already include it)

toxic yacht
#

I'm catching up on the jump doing a slight shift bug. One alternative is instead of using addforce, set the rigidbody's velocity. This isn't a one to one since add force takes into account the rb's mass tho.

tiny plaza
raw token
warm surge
tiny plaza
toxic yacht
#

Yeah I a fighting game id guess the jump is balanced based on height, and speed. Also can point out that the jump there has a higher gravity scale when falling.

raw token
# tiny plaza thanks i'll save this message for when i get to animating!

Looking back at your code, the force mode is why you're having to use such a large force to achieve your current jump - the force is only applied for one frame, but since ForceMode.Force is scaled by time, you're having to use that large multiplier. If you switch to Impulse it'll just dump the entire force at once.

In short, when using a time-dependent force mode, the force value you give it represents "force per second." When you use a time-independent mode, it just represents direct force

toxic yacht
# tiny plaza i feel like 10 is giving me the best result

Wishlist Isadora's Edge on Steam: https://store.steampowered.com/app/3125320/Isadoras_Edge/

(My actual fast fall value is about 47.5% but that felt too wordy to use in the video)

The game that I'm developing an an indie game dev is called Isadora's Edge! A 2D Pixel Art platformer game, that I'm developing in the Godot Game Engine! If you're ne...

β–Ά Play video
#

And in general this channel is goated

tiny plaza
tiny plaza
#

what does the "!" do? it came when i tabed

mint remnant
#

negator for booleans

tiny plaza
mint remnant
#

depends on what you want it to do, that code says return the result of isGrounded() then make it opposite of that value before it goes into the && check

tiny plaza
mint remnant
#

the fact that hitting tab auto added it is beyond me though

tiny plaza
#

also should i use fixedupdates or updates?

mint remnant
#

in general you want anything physics in fixed update

#

though adding a force I don't think matters as much

tiny plaza
#

is there a way to do something when not in collision with something?

#

because this doesn't work

formal sable
#

I have a problem. Yesterday I faced the problem that the pause is removed from the space bar, that is, I click on the button to press "continue the game", then pause, press the space bar and the game is removed from the pause. After deleting the EventSystem, it is no longer removed, but the buttons stop clicking

raw token
mint remnant
formal sable
raw token
topaz mortar
#

I'm currently using FixedUpdate to send a raycast to find my target.
Is it ok to call my attack logic from FixedUpdate as well? Or should I use Update for that?

raw token
formal sable
#

There is no such problem on version 2021 πŸ™‚

#

I choose the 2022

raw token
formal sable
raw robin
#

Hi all, I have a fairly generic question on pros and cons of prefabs vs scenes

Currently Im using prefabs for different levels, and I destroy and instantiate the levels. Now Im aware scene is something usually to handle level changes, but if prefabs does most things I currently want to, is there a reason I should change to using Scenes?

Thansk

raw token
formal sable
raw token
eternal falconBOT
teal viper
# raw robin Hi all, I have a fairly generic question on pros and cons of prefabs vs scenes ...

You might want to use scenes instead if memory is an issue, as using one scene with many prefabs is gonna keep all the prefabs loaded into the memory. On the other hand, when you unload a scene it releases all the memory it references.

It's a bit more complicated than that and there are ways to tackle the issue, but that's the gist of that. Also, it's just a different development workflow.

formal sable
raw token
formal sable
raw token
#

Woot woot!!

formal sable
#

Thank you very much

limpid plinth
#

Hey,
I wrote a script for my prefab.
Created 500 game object with different positions. (Clones)

How to link them back to blue link prefab? I have to more modifications and don't want to make.them manually for each

raw token
copper orbit
#

has anyone ever tried utilizing navmesh with spriterenderer in 3d?

limpid plinth
topaz mortar
#

Does Physics2D.Raycast always return just a single target? The first one hit?
The docs are a bit confusing

raw token
north kiln
tiny plaza
#

i'm trying to make my character jump without it's original horizontal velocity but it doesn't work

limpid plinth
#

@raw token No,
I just created them to position by script logically 500 objeects.
Now they exist in editor mode too.
But i want to LINK them BACK with prefab. Now they are grey. In editor. In editor i want blue link

#

i want this

#

blue hex, not gray hex

mint remnant
# topaz mortar Does `Physics2D.Raycast` always return just a single target? The first one hit? ...

Many of us kind of jumped into gamedev without a solid understanding of these Physics APIs such as Raycast and Spherecast. In this video I aim to make it really clear how each of the Ray, Sphere, Box, and Capsule casts work, look, behave, and how you can use each one of them to achieve your "casting" goals!

In this tutorial video you can see t...

β–Ά Play video
limpid plinth
#

how to link gray Hex to be blue hax @solemn loom

#

but i have 500 of them

#

all same, just different pos

raw token
# limpid plinth but i have 500 of them

I don't think unity has a built-in faculty for restoring a relationship between a game object and a prefab asset...

If you need to instantiate a prefab within the editor, you should be using PrefabUtility.InstantiatePrefab(); which maintains the relationship.

There might be some hack to restore the relationship by editing the scene file by hand... but that seems sketchy, to me. If you decide to try that, definitely make backups πŸ‘€

Maybe use another editor script to iterate through all of the clones you've instantiated, instantiate new copies with InstantiatePrefab(), copy their values over, then delete the unlinked clones, I guess? 😦

limpid plinth
#

that helps alot @raw token

#

but can i execute it on playtime?

raw token
#

In editor playmode, I think? But not in a build

limpid plinth
#

letme try

#

OMG

#

it works

#

jesus christ

#

thank you

#

god bless you +1 life

#

i spend 4 h on this

raw token
#

hahaha πŸ™‡β€β™‚οΈ

#

That's... not a fun situation

limpid plinth
#

thanks buddy!

#

can i reach out to you dm?

raw token
#

Momentarily - but I'll be headed to bed shortly

limpid plinth
#

sent dm

raw token
tiny plaza
languid spire
tiny plaza
#

what i want to do is to have a set jump for each direction that isn't controlled by the initial speed

tiny plaza
languid spire
#

still, change you test to 0.01f

pulsar shuttle
#

Trying to implement pinch gesture zooming, but having trouble. I need to limit the zooming, just call the function when the fitting gesture is made, instead of directly passing the difference to camera's size. currentMagnitude and prevMagnitude almost feel random, i can literally hold two fingers in place and it will tell me the difference is 100 pixels sometimes.

#
        {
            Touch touch1 = Input.GetTouch(0);
            Touch touch2 = Input.GetTouch(1);

            if (touch1.phase == TouchPhase.Moved || touch2.phase == TouchPhase.Moved)
            {
                Vector2 touchOnePrev = touch1.position - touch1.deltaPosition;
                Vector2 touchTwoPrev = touch2.position - touch2.deltaPosition;

                float prevMagnitude = (touchOnePrev -  touchTwoPrev).magnitude;
                float currentMagnitude = (touch1.position - touch2.position).magnitude;

                float difference = currentMagnitude - prevMagnitude;

                if (Mathf.Abs(difference) < 50f) return;

                bool zoomOut = currentMagnitude > prevMagnitude;
                textMesh.text = $"{zoomOut} {difference}\n {prevMagnitude} {currentMagnitude}";

                if (zoomOut)
                {
                    //zooming out
                }
                else
                {
                    //zooming in
                }
            }
        }```
astral falcon
#

And for sure you need more logs than just a result of multiple calculations to figure out, whats going on or going wrong

#

I would also store those toucheoneprev and stuff in a persistent value so you can log that values all the time and also can 0 them out when cancelled, just to make things clean and controllable

pulsar shuttle
languid spire
#

touch can be extremely sensitive, even a slight roll of a finger can be seen as a move. You might want to put a minimum on your touch delta

pulsar shuttle
pulsar shuttle
astral falcon
astral falcon
astral falcon
pulsar shuttle
#

still pretty frustrating it acts so odd, wonder if my understanding of how it works is wrong

astral falcon
# pulsar shuttle still pretty frustrating it acts so odd, wonder if my understanding of how it wo...
pulsar shuttle
ruby python
#

Mornin' all,

In the attached image I have a bunch of 'connection points' that I'm using for a simple building system and I'm trying to figure out how to make it so that only the point facing the camera is visible (the player uses A and D currently to rotate the camera around the 'core' of the station) and clickable. I've gotten the clickable/building 'extra' bits all working, I just need to hide/deactivate any points that aren't facing the camera.

Anybody have any ideas? (the 'cross' is just for 'center screen' reference.)

topaz mortar
#

Alright, so my bunnies were perfectly walking from right to left, I changed something (dunno what) and now they won't move
They still have their RigidBody, the velocity is set to Vector2(-3, 0),
rb.constraints only returns that the z axis is locked, which is intentional
when I unlock it, my bunnies start rolling forward instead of walking
Are they somehow stuck in my ground? Or is something else going on? Even if I manually move them out of the ground, they won't move forward, they do fall back down

languid spire
#

if you don't know what you changed (not sure I can understand how that is even possible) roll back to a previous commit when things did work

topaz mortar
#

I changed a lot of things, but nothing that seemed relevant

#

and I don't want to roll back, it would probably just cause the same issue again

#

just not sure what I'm looking for

teal viper
#

Additionally, confirm that your code executes at all and is applying velocity to the correct objects.

#

Additionally, when debugging issues like that, make sure you have gizmos enabled.

topaz mortar
#

ah, found it thx πŸ™‚
I changed it so the velocity is set in Awake, but the drag cancels it out within a few frames

pulsar shuttle
topaz mortar
#

So I set both linear and angular drag to 0, but my velocity is still being cancelled out

sick cloud
#

Hello everyone, is this the right channel to ask for help?

pulsar shuttle
topaz mortar
teal viper
sick cloud
#

so should I just post everything about my problem in?

teal viper
topaz mortar
#

I guess that's why ppl set the velocity in fixedupdate and not awake πŸ˜›

languid spire
eternal falconBOT
sick cloud
#

So I'm working on this application, in which you can choose a folder with DICOM files and the program makes a 3D model with it. I have already achieved to load a folder using a button and then removing the volume again with another button.
However, if I want to choose another folder or the same one again with the first button then no model will be created, which is not good and I don't know how to solve this :(

Here are the 2 scripts that include the folder dilemma.

"DataStore" Code 1:
https://paste.ofcode.org/hDK5Tjg82ZCH2HdjHtDVuD

"Vtk Volume render Load Control Script" Code2:
https://paste.ofcode.org/3PwawxqdNgjYNU64Y88Bbu

#

Here is a Picture of how the Program looks rn:

pulsar shuttle
sick cloud
#

should be OnSelectFolderButtonClick()

#

second one is OnClearFolderButtonClick()

#

anyone who can help please just ping me, so I won't miss anything

pulsar shuttle
languid spire
sick cloud
#

but it's not really a problem rn

#

if any of the //comments are in german and you need them translated I'm ready to help

languid spire
#

why is ImageDataFolders even an array?

sick cloud
#

I work with the VtkToUnity Plugin and some of the code was already existing, so idk but it propably has to do with how the DICOM files are listed I guess

round mirage
#

how can i get a child GameObject by his name in a script ?

sick cloud
#

Also to be completely honest I'm a C# noob and actually wanted to make this in Python but the necessary libraries didn't like each other so I had to switch to Unity

pulsar shuttle
pulsar shuttle
sick cloud
pulsar shuttle
#

Im not sure then, try rechecking everything in the clear method, you might be resetting some conditions or destroying some needed object

#

but if it doesn't give any errors it should be something to do with the conditions

round mirage
#
Bouchon = child.gameObject.Find("Bouchon");```
why it dont work ?
pulsar shuttle
round mirage
#

but why i can use it without "child."

pulsar shuttle
languid spire
sick cloud
pulsar shuttle
languid spire
round mirage
sick cloud
languid spire
#

no add StartCoroutine to the call

sick cloud
#

theres a startCoroutine right above yield return base.StartImpl();
or should I add another?

languid spire
#

ffs
yield return StartCoroutine(base.StartImpl());

sick cloud
#

oh that's what you meant sorry

#

didn't fix it sadly :/
but I'll leave it like that for now

pulsar shuttle
languid spire
cedar bone
cedar bone
sick cloud
celest jay
#

What's the closest we can get to run method like Update() in the edit mode?

late burrow
#

why jtoken.toobject uses constructor? it already has all data in text

celest jay
#

like always running a method without relying on any editor changes/window open

celest jay
errant solar
#

why erorr?

sick cloud
# languid spire I don't see where this protected override IEnumerator StartImpl() { is ever invo...

Hey man I have a quick question,
what if I write it like that:

     private void OnDataFolderChanged()
    {
        if (DataStore.Instance == null || string.IsNullOrEmpty(DataStore.Instance.ImageDataFolder))
        {
            Debug.LogError("DataStore or ImageDataFolder is invalid.");
            return;
        }

        StartCoroutine(base.StartImpl());
    }
  • in DataStore OnSelectFolderButtonClick() has VtkVolumeRenderLoadControl.Instance.OnDataFolderChanged();

Then I need to remove the "protected" from protected override IEnumerator StartImpl()

Will that even work?

languid spire
sick cloud
#

anyways thx for the help until now

languid spire
#

The only thing I can say is your code seems horrendously overcomplicated for what it appears to be doing

sick cloud
languid spire