#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 410 of 1

swift crag
#

annoyingly, you can't pass Debug.DrawRay a Ray

#
Debug.DrawLine(ray.GetPoint(0), ray.GetPoint(distance), Color.red, 0.5f);
#

This draws a red line that lasts half a second

random cave
#

Ooo new debug thing learnt

random cave
#

Just raycast from the camera

#

I think imma take a break from this its so stupid, its also better because I have to polish how my camera moves around in the map as well

#

Rn you just hold right click i nthe direction you want it to be, Ill work on scrolling

raw token
#

Out of curiosity, why is plane casting the ray? What is it?

swift crag
#

This lets you shoot a ray at a plane defined by a point and a normal

#

It's not physics-based at all -- just seeing if a ray hits a plane

raw token
#

So plane here is roughly where the terrain is?

vernal salmon
#

Hey was doing some basic mathematics functions and the code sends out -infinity first time second time gives out what is supposed to come out

vernal salmon
#

Coming.

swift crag
raw token
vernal salmon
#

The code in question was PlaceX = (player.transform.x / WorldX) ร— MapX - transform.getcomponent<recttransform>().rect.width/2;

#

This again for the z axis then given to the local position of the raw image

#

First time it gives out -infinity

#

Other times not

iron mango
#

is there an easier / better performance way to find an object in a list that is not active than go with foreach through it?

rich adder
#

thats what the other finds methods essentially do, except the list to loop through is bigger

iron mango
#

hm. because i am trying to make a pooling system for projectiles, and searchin for a not active object in the pool every time hurts performance

rich adder
iron mango
#

what else could i do

wintry quarry
iron mango
#

makes sense

wintry quarry
#

You might have 3 collections honestly:

  • A list of all the pooled objects
  • A HashSet of the active objects
  • A HashSet of the inactive objects
#

depending on your needs

raw token
vernal salmon
wintry quarry
#

it's a collection optimized for unordered Contains Add and Remove operations

rich adder
#

interesting, was using a queue at some point, hmm yea hashset makes more sense

fading mountain
#

hey guys. I want to continuously check if a time limit has ran out without the player selecting an answer in my quiz game, and if so play an error message ONE TIME. The way Im trying to do this is by checking in Update() whether or not the time limit has ran out without the player answering a question, and if it has, calling a method which is supposed to play the audio one time and then subtract from a counter which would disable it from being able to play again. The result I'm getting is that the audio clip is being played every single frame without ever stopping until the if condition becomes false. This is the relevant code: https://gdl.space/dorakehige.cs

rich adder
#

!shownFailed or someshit

cosmic dagger
rich adder
cosmic dagger
#

Queue<T> and Stack<T> have their uses, as does List<T>. it really depends how you need to access the elements . . .

#

List<T> is simple and easy because it appears from the inspector . . .

rich adder
#

I was working on a line checkout for a store and queue is perfect but its just a pain to debug

#

I'm trying to ween off using inspector for any debugging though its a bad habit but so eez lol

raw token
#

It does seem a little strange that Unity doesn't provide serialization/editors for some of the other common collections

rich adder
#

always wondered, why aren't things like [,] arrays serialized?

swift crag
#

btw, if you're doing pooling, look at the UnityEngine.Pool namespace

rich adder
#

the unity pooling is great ! it takes care of the heavy work for you

cosmic dagger
swift crag
#

I almost exclusively use it for list and hashset pools

rich adder
rocky canyon
#

what makes it a bad habit?

rich adder
#

I try making everything onscreen now like a UI though. It helps to send a tester/designer just the exe and they can just tune it

cosmic dagger
swift crag
#

It would be nice to have a way to explicitly draw extra fields into the inspector.

rich adder
#

yeah its just a mess

swift crag
#

You'd need a wacky custom editor for that

cosmic dagger
#

let's be fair, all of it is junk, but necessary junk (at least, we think so) . . . ๐Ÿ˜†

rocky canyon
rich adder
#

when I can I do use the Debug mode now, fun fact. You can pop out one component you want and put debug mode only on its inpsector

rocky canyon
#

right click > properties ftw

rich adder
#

game changer!

#

no more locking the inspector to drag items in a list

rocky canyon
#

i do that often to record video's and dock the relevant inspector on top of the game view

swift crag
#

I've written a decently elaborate debug system

#

It draws everything with IMGUI

#

I need to fix the layout again...

#

the IDebug interface requires a DoDebug iterator method that can yield other IDebug objects

rich adder
#

is IMGUI still good to use?
I heard we should not use it anymore

rocky canyon
rich adder
wintry quarry
swift crag
#

It generates a crapload of garbage

rich adder
#

for debugging or sending to designers is ok right?

#

oh ok

swift crag
#

All of my actual UI is UGUI-based

swift crag
#

Still trying to figure out if I can use scroll areas...

#

as far as I can tell, I can't tell IMGUI to make a scroll area that can also shrink if its content is small enough

rich adder
rich adder
#

haha yeah this feels like I'm undoing everything I learned in UIToolkit

full kite
#

Can someone help me? Can I detect when someone leaves the game? Like to detect if a function is the last one that its called?

wintry quarry
#

Is this a multiplayer game? Networked?

full kite
#

A singleplayer thing

raw token
wintry quarry
#

Unplugging a controller? Leaving a physical zone?

cosmic dagger
full kite
#

Its basically, when someone basically leaves the game, like if on a phone, delete it from the apps open, or pc, alt f4 ed

wintry quarry
quick kelp
#

i recently added context menu portion to my inventory and I'm getting errors

with selector and forced selector scripts when entering a new room and trying to open the inventory
the scripts work perfectly when opening the menu in the first initial room but only upon loading a new room does it do this
https://hastebin.skyra.pw/sulotuqumu.csharp selector view

https://hastebin.skyra.pw/ejexeturaj.csharp forced selector

the context menu: https://hastebin.skyra.pw/feluvasita.pgsql

note: the way level streaming works in this project is the player and menus are children in a dontdestroyonload object and are teleported to an exact x,y,z cord

full kite
rich adder
wintry quarry
raw token
full kite
#

Its perfect. Thank you @wintry quarry & @raw token!

quick kelp
#

im gonna be so done if this is the solution

wintry quarry
#

Bsaed on the error I don't see what else it could possibly be

quick kelp
#

omg thats what it was

cosmic dagger
swift crag
#

I have zero experience with UIToolkit outside of creating basic property drawers via code

#

I need to try out the visual editor at some point.

rich adder
#

yeah never tried visual editor
the visual editor does seem appealing though, it just looks limited but idk never touched it lol

rich adder
queen adder
#

yo, I was trying to make a game but I had a issue where I can use WASD to move my little 2d cube but I wanted to make more effects like speed increase over time and slowing down so its not so snappy. anyone know a way I can do this? Also, how could I figure out when the object touches the top of a collidable object (the ground) or when it touches the side of a colliable object and run a function with that??

queen adder
polar acorn
summer stump
queen adder
cosmic dagger
fervent abyss
#

hey guys

i have a configurable joint a collider (not trigger). so basically this joint conflicts with the colliders and makes it buggy (throwing me everywhere)

how could i possibly fix this?

swift crag
#

If your rigidbody is getting pulled in one direction and the joint is trying to do something else, then you're going to get bad behavior

#

could you show us the problem, along with how you've configured the joint and the rigidbody?

fervent abyss
#

as you see on the video, when i grab and stand on the collider, it just throws me everywhere

rocky canyon
#

well thats just an exploit.. i dont think u should be able to stand on the thing ur holding..

fervent abyss
#

what

rocky canyon
#

couldn't u just put a limit on it.. so u couldnt stick it up under ur character?

fervent abyss
#

thats not going to feel well

#

thats why i need the collider..

swift crag
#

You're getting into a "troll physics" situation (:

#

the physics system isn't fully accurate; it can't understand that you're pulling on yourself

rocky canyon
#

Barrel flying

fervent abyss
#

no throwing here

rocky canyon
#

my own version of barrel flying ๐Ÿ˜…

rich adder
#

we called that "prop surfing " in gmod

rocky canyon
#

ohh yea thats a good name for it

#

FYI, i gave up and scrapped the mechanic

rich adder
#

its pretty easy to check with a physics query or even just a dot product if you're above a prop while holding

rocky canyon
#

ya, i was young and dumb.. now i could probably fix it

rich adder
#

never too late!

fervent abyss
#

erm

rocky canyon
#

lol, its been deleted.. all i have is memories

#

SOT clone anyway.. wasn't anything special

rich adder
#

you never know, it can turn into something of its own. not a lot of good SOT-like games out there

rocky canyon
#

i mean.. the physics pickup was cool.. but it was more trouble than it was worth

#

also had to contend w/ walls and stuff

#

u could rubber band the prop a long distance from ur hands

#

if i were to do it again id come up with some kinematic solution

rich adder
#

kinematic is good too, with dynamic you just have to have more checks in place cause it has a mind of its own lool

rocky canyon
#

perhaps locking the object to a container

#

and using regular rotation methods to rotate it manually

#

instead of letting it get hung up on things

rocky canyon
#

hmm todo:

#

to physics or not to physics.. that is the question.. ๐Ÿชถ

#

love this mechanic.

#

i wish i could help the guy above but i don't/can't do VR but it should be pretty similar

rocky canyon
#

gotta click it.. reddit sucks

#

its just a more refined version of the lever..

rich adder
#

damm thats fire

rocky canyon
#

not really sure how he does it.. i've asked him before and he told me it was proprietary ๐Ÿ˜„

rocky canyon
#

his lighting/colors pop like a mfr

rich adder
rocky canyon
#

the magnets cool, but i know how tha tworks

#

im not sure if he's using a hinge joint on the cursor..

#

or if hes just using lateral mouse movement and rotation

rich adder
#

yeah hinge is what I would use and get the "pull" direction

rocky canyon
#

you mean a hinge on the lever or the crosshair?

rich adder
#

the lever

rocky canyon
#

oh yea ofc.. but im thinking he might connect it to a dummy object in front of hte cursor

#

to do the actual pulling and pushing..

#

that i can't say for sure tho.. i need to experiment ๐Ÿฅผ

#

i'll report back w/ my findings

rich adder
#

Would make an interesting mechanic within itself

full kite
#

Hello guys! I found this script that you can use in order to get a gameobject in 2d to follow your mouse but it seems it doesnt work. I know that I used it several times in the past and now it seems like I made a typo or something. Can anybody help?

using System.Collections.Generic;
using UnityEngine;

public class Drag : MonoBehaviour
{
    private Vector2 mousePosition;

    private float offsetX, offsetY;

    public static bool mouseButtonReleased;

    private void OnMouseDown()
    {
        mouseButtonReleased = false;
        offsetX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x;
        offsetY = Camera.main.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y;
    }

    private void OnMouseDrag()
    {
        mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector2(mousePosition.x - offsetX, mousePosition.y - offsetY);
    }

    private void OnMouseUp()
    {
        mouseButtonReleased = true; 
    }
}```
#

I assigned this script to the gameobject, putted rigitbody 2d, gravity scale to 0, sleeping mode = neversleep ; box collider 2d, isTrigger = on, and still 0 result

rich adder
#

@full kite were they helping you earlier ?

#

you shouldn't tag people into your questions if they weren't actively helping you

full kite
#

yes, it was working earlier but now it seems like I made a typo or smth

#

oh

#

yes he did

#

earlier

rich adder
#

ok but still they might be busy or might not want to be pinged for every issue, just post the question and someone can chime to help

full kite
#

oke

rich adder
#

can you show the setup where you put this script

full kite
#

what do you mean?

#

And the drag script is the script

hybrid tapir
#

i dont know whats going on here (the error about VCS client not the UI being wrong)

rich adder
# full kite

so drag is on a gameobject that has a collider?. You should not drag a gameobject with a rigidbody like this btw

full kite
#

and you tell me that I should delete rigitbody 2d from the gameobject?

rich adder
full kite
#

2 gameobjects

#

more like 2 images

#

that are gameobjects

rich adder
#

I don't understand what about them and what does rigidbody have to do with it

full kite
# rich adder I don't understand what about them and what does rigidbody have to do with it

this is the link to the script https://www.youtube.com/watch?v=9-ok9Cn3d90

How to merge two objects to get a new one? That is what this video is about.

TO BLAST! - My New Fun Relaxing Puzzle Game Available On Google Play Store
https://play.google.com/store/apps/details?id=com.ZoGames.ToBlast

Not only your hands are responsible for aiming ability :-)
Logitech G305 LIGHTSPEED Wireless Gaming Mouse
https://amzn.to/2VxEO...

โ–ถ Play video
hybrid tapir
full kite
#

Without the last function is my entire script

hybrid tapir
#

it was working perfectly when i left it

rich adder
rich adder
full kite
rich adder
full kite
#

0 errors

rich adder
#

show me in playmode

raw token
full kite
#

one sec

raw token
rich adder
#

yes its Verison Control

#

comes preinstalled UnityChanPanicWork

full kite
#
    using System.Collections.Generic;
    using UnityEngine;

    public class Drag : MonoBehaviour
    {
        private Vector2 mousePosition;

        private float offsetX, offsetY;

        public static bool mouseButtonReleased;

        private void OnMouseDown()
        {
            mouseButtonReleased = false;
            offsetX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x;
            offsetY = Camera.main.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y;
        }

        private void OnMouseDrag()
        {
            mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            transform.position = new Vector2(mousePosition.x - offsetX, mousePosition.y - offsetY);
        }

        private void OnMouseUp()
        {
            mouseButtonReleased = true; 
        }
    }
``` and entire script
rich adder
#

seems you accidentally made it a UI object

#

its supposed to be a regular Sprite Renderer object

#

also no clue why your Image component is scuffed.

#

first of all you're forcing transform on a rigidbody thats a big no

#

use torque at minimum

fervent abyss
full kite
#

But why sprite renderer instead of Image?

#

If I can know

#

Ofc

rich adder
# full kite If I can know

Image renders on a completely different space than world.
Sprite Render is inside the world, you dont want to add physics/colliders on a UI object since it lives on a screen space

heavy kite
#

i have a probleme with my code that manage my inventory, when i click on the button to go to the next or previous item, after that, when i jump it pass to other item and use some, only when i jump, and when i click a it does not use my current item
invetory script : https://gdl.space/gebidareso.cs
item script : https://gdl.space/akapizocil.cs

fervent abyss
rich adder
full kite
fervent abyss
rich adder
#

use for example a FixedJoint

#

so fixed for the parent of the hinge, then you can keep the hinge for rotation purpose

rich adder
fervent abyss
rich adder
#

just parent it

fervent abyss
#

i had another kind of hinge joint and it worked completely fine ๐Ÿ’€

fervent abyss
rich adder
#

so it has a rigidbody

#

is it set to kinematic

#

show the setup / inspectors

#

oh and we're in a code channel this isn't really a code issue

west sonnet
#

I don't understand why I'm being told this bool can be removed because it's not used? It is being used in the NPCFacePlayer Method. If I remove the bool, I get an error in that method. I keep getting an error message in Unity saying that it can be removed and it's annoying. Is this a bug or am I missing something?

rich adder
#

you're only assigning it, that's not using

raw token
fervent abyss
#

it work

west sonnet
#

I'm not sure I understand what you mean

rich adder
west sonnet
west sonnet
rich adder
#

hiding warning is just a band-aid

#

why are you assigning value to it if you're not using it in a if statement or something

west sonnet
#

Ooooh shit, I see what you mean lool

#

I've come back to this project after like 2 months of not doing anything, I must've written that for debugging and forgot to delete it

#

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

rich adder
#

oh haha

#

maybe you were trying to use it as a field for a get property ๐Ÿ˜›

#

can come in handy I suppose

#

public bool IsFacingLeft => isNPCFacingLeft

swift crag
#

You'll get warned (or even get an error) when you do something that the compiler knows is pointless

#
3; // unacceptable kind of expression -> error
bool x = true; // never used -> warning
transform.position.x = 3; // transform.position is not a variable -- it's a property, so it's really a function call that returns a Vector3
swift crag
#

it just gets grayed out

eager spindle
#

very dumb beginner c# question but if I inherit from another object do the usings from that object's file get carried over

swift crag
#

Nope.

eager spindle
#

ah I see im trying to find out why my debug.log has ambiguity

swift crag
#

using strictly affects the file that it appears in.

#

You probably have a using System.Diagnostics;

eager spindle
#

oh right I do

#

I didn't even see it get added

swift crag
#

System.Numerics is another nuisance with Vector3

eager spindle
#

is there a way to change the default file unity creates when you make a new script?

#

oh i googled

#

theres a unity article on it but no docs

raw token
# eager spindle oh i googled

I'd like to know what you find. Last time I looked, the docs I found were outdated... I vaguely remember there being a more recent solution, but I don't remember what it was

languid spire
eager spindle
#

this is big news for me

#

i wonder if it takes effect immediately

raw token
#

Awesome!

eager spindle
#

3 years into unity i can finally stop removing the comments that come with the script every time

#

im not sure what #NOTRIM does though

languid spire
#

problem is you have to do it for every installed version there is no central repository

rocky canyon
#

so ur methods aren'[t on top of each other

cosmic dagger
# rich adder something like this ? maybe I misunderstood https://docs.unity3d.com/ScriptRefer...

sorry, missed this. that's part of it. i'm using a value changed callback

TypeObjectField = Root.Q<ObjectField>("type");
TypeObjectField.RegisterValueChangedCallback((e) => UpdateStat(e));
```for the object field to check the new value. i try to assign the property (referenced from `PropertyStat = Property.FindPropertyRelative("_stat");` based on the `Type` of the new value of the `_type` field. at least, that's what i can remember. i haven't check in a long time . . .
rich adder
# cosmic dagger sorry, missed this. that's part of it. i'm using a value changed callback ```cs...

Oh I see yeah, I still haven't gone that deep into UIToolkit esp with editor or dealing with more complex classes. Most I did with object field, though similar with what you did here but without the Q since I'm building the tree in c# directly

ojField = new()
{
    name = "A",
    label = "SpriteSheet",
    allowSceneObjects = false,
    objectType = typeof(Texture2D),
};
ojField.style.paddingTop = 16;
ojField.Bind(new SerializedObject(this));
ojField.RegisterValueChangedCallback(TextureObjectChanged);
root.Add(ojField);```
#

the whole binding process is still a bit confusing without using uxml

cosmic dagger
remote osprey
#

Is there a way to disable all user inputs without using a global boolean?

#

Just curious

raw token
polar acorn
remote osprey
raw token
remote osprey
#

I just added a global boolean to my game and called it a day

#

it only had 1 input point, so no worries

hasty blade
#

hey I have a question about animator override controllers if anyone has a minute

hasty blade
#

my bad

#

having trouble making my animator override controller be active when i transfer to different scenes. it works when i equip it in the customization screen but doesnโ€™t save when i transfer to a different scene

acoustic echo
swift crag
#

it works when i equip it in the customization screen but doesnโ€™t save when i transfer to a different scene

Nothing you do in the old scene will affect anything in the new scene.

#

I'm unclear what you're doing here, exactly -- are you expecting a player prefab in Scene B to reflect the changes you made to the instance of the player in Scene A?

cyan vortex
#

I've got a Question which Image Format can I use for my screenshots so I'm able to send them into the group as I've got told earlier you lot don't Approve jgrx

swift crag
#

it destroys everything in the old scene

#

the new scene is loaded, and all of the stuff in it gets created

hasty blade
#

ohhhh

swift crag
#

You could use DontDestroyOnLoad to move the player into a special scene that is never unloaded

#

Alternatively, you'll need to remember the changes you made (probably in a "game manager" object that lives in DontDestroyOnLoad!) and apply them every time the player is created

hasty blade
#

hmm okay i think i got that

#

actually that will work perfectly because every scene iโ€™ve just been copy and pasting the background and player

#

thank u thank u ๐Ÿ™

swift crag
#

You'll just need to make sure to create the player once when the game starts

#

You can check if a player exists and instantiate a prefab if you need to

hasty blade
#

yes thank u that will also work great. I appreciate it iโ€™ve asked this question on so many different platforms and havenโ€™t gotten an answer. ur a life saver ๐Ÿ™

light arrow
#

Is this the right spot for animation help?

wanton kraken
light arrow
#

Thx

lime pewter
#

Hey, quick question! Just wondering if anyone knows what the most performant solution would be to dynamically creating a sprite which would be used in a tile-based pool system, each "pool" would be split into tiles and each tile would be 16x16 pixels, I am currently trying to find a solution to creating a sprite that based on a "fill" amount of each tile would determine how many pixels tall that tile would be dynamically, the only issue I have currently is finding the most performant solution to creating 16 possible "liquid fill" sprites, ideally this solution is dynamic and would be able to be reused by changing the color for different possible liquids. Any thoughts or ideas would be amazing! Thanks.

lime pewter
trail heart
#

The liquid simulation sounds like the real challenge here

lime pewter
# trail heart Why would you need to create the sprites dynamically when they can be premade an...

I don't necessarily "have to" create them dynamically however, if I wanted a system that could have different colors of water based on the biome they're in and mix the colors of two merging pools of different colors dynamically I think it could be cool/useful to have it be dynamic, plus the memory overhead of swapping a lot of sprites might be a lot especially if I have many pools of different times besides water.

lime pewter
# trail heart The liquid simulation sounds like the real challenge here

I created a cellular automata type system which works well, and is quite efficient with pooling, draining, etc. Controlled by a parent "pool" object, a lot of documentation on it so it wasn't too bad. Obviously it's not perfect yet but I am at the stage where I am confortable starting to integrate a proper visual implementation ahah.

lime pewter
trail heart
#

16 16x16 sprites in memory sounds negligible
Tilemaps can handle hundreds of tiles and let you read and assign any color per tile

#

As well as any sprite

lime pewter
# trail heart 16 16x16 sprites in memory sounds negligible Tilemaps can handle hundreds of til...

Yes, true however I determined that using a tilemap wouldn't be the best option for my liquid so they're just perfectly aligned gameobjects that are stored in the same layer which I'll pass as a render texture to the shader, I've been using separate "fill amount" sprites, but I was looking for a more clean solution if possible, especially if I wanted to change liquid based on whatever other factors I have in the project down the line.

#

I know I want more than just water, so having a universal dynamic 16/16px "liquid" could be useful to have in the liquid script, but if that wouldn't be performant I understand if that isn't worthwhile.

trail heart
#

How did you determine that gameobjects would be better than a tilemap?

lime pewter
lavish jolt
#

Hello. How can I change cursor on cursor pointer from script?

lime pewter
#

Also, storing a "fill-amount" or any data in the tilemap is significantly harder and requires a lookup table which again isn't good for performance.

#

So I just have a gameobject system that are able to be enabled and disabled based on when they're "falling" or "pooled".

trail heart
lime pewter
#

So I guess technically yes, it is a physics collision but it is only a single one which is negligible performance-wise.

#

I assume that is much faster than having a dictionary for each pool, and having to lookup in that dict every update.

trail heart
#

You seem to find very creative ways to work these problems
I would be more inclined to look for existing examples

#

Fluid and light pixel/tile simulations have been a thing in games for thirty years, there should be something

lime pewter
lime pewter
# trail heart Fluid and light pixel/tile simulations have been a thing in games for thirty yea...

I would also argue that both starbound/terraria are both heavily lacking in terms of how liquid physics is handled, on top of just being plain inaccurate it's also extremely laggy since each tile is updated separately, where-as my solution would only be updating the "pool", both cutting a lot of the overhead and the frame of empty space when taking water from the center of a pool as an example.

lime pewter
trail heart
#

Doing something per-tile is not inherently unperformant in any way
Even if it intuitively might feel that way

#

Not implementing proper optimizations when doing so is the issue

lime pewter
# trail heart Doing something per-tile is not inherently unperformant in any way Even if it in...

That's true, however I've found cellular automata to be quite unflattering especially when draining even in the biggest games out there since they all seem to follow pretty much the same solution. I'm trying to improve on that concept by using references from cellular automata and creating my own rules which will allow it to be pretty much unnoticeable performance-wise but also look quite a bit better hopefully.

#

Also, allow for me to create "pseudo physics" such as pressure.

digital warren
#

how can i solve it?

trail heart
lime pewter
digital warren
lime pewter
trail heart
trail heart
#

If the error is not recognizable to us, you would have to give more details about what seemed to cause it

lime pewter
#

It looks to me like you're using a gui package that's outdated.

#

Generally if something is "obsolete" it means there is a newer solution and that support has stopped for the prior function.

#

Unity is very good at telling you when something has been updated and will often recommend the exact replacement for it in the error message.

acoustic echo
lime pewter
# digital warren hmmm ok then wait

If that doesn't work and you want a really easy solution, I'd recommend looking to see if the package has been updated to the same unity version you're using, and if not maybe search for alternatives.

acoustic echo
#

```put code inside```
Also use this to post code ^

digital warren
digital warren
#

Or U mean the line that has the problem?

acoustic echo
#

only the lines causing it

lime pewter
digital warren
digital warren
lime pewter
#

Just send line 53, and line 58.

acoustic echo
#

how outdated

digital warren
#

This 10th time that I install unity again lol

lime pewter
#

Just the specific package you're using if it's been updated.

digital warren
lime pewter
#

I assume you're trying to make a UI?

stiff bane
#

ok so im following a youtube tutorial for a 2d game and i was doing the animations. one of the things was to flip it when you go in the other direction shown in the image bellow. however, my character sprite stretches out horizontally whenever i move. i'm pretty sure its because the code is actually making the size of the sprite 1 or negative 1 for the switch, but if i change it to the transform scale that i have my sprite at (so -0.7 and 0.7) it gives me an error?? so im not sure how exactly to fix this...

lime pewter
stiff bane
#

this is the error

acoustic echo
lime pewter
#

if you have a single decimal point that is called a "double" and will be recognized differently to a float.

#

placing an "f" directly after a number will always format it to a float.

stiff bane
#

like so?

slender nymph
# stiff bane this is the error

start by making sure that your !IDE is configured so that it will underline errors in the code so you see them and can correct them more easily

eternal falconBOT
lime pewter
lime pewter
# stiff bane like so?

also a simple "else" instead of an "else if" will do the same thing and be marginally faster.

acoustic echo
acoustic echo
#

It should still work

lime pewter
polar acorn
#

Technically they are not the same. Currently, with else if, neither condition runs if xAxis is exactly 0 which might be what they want

slender nymph
lime pewter
inner pike
#

Hi all, what Unity version do you suggest to use today for development purpose for a game that probably will be released in 2025-2026 (probably 2026 or more, it will be hard for 2025): It will be a mobile multiplayer based on Photon Quantum. I spen the today stream but I'm still unsure about what to use. Is the v6 a lot bugged now or it is ok to start with it yet? I want to avoid migrations if te 6 LTS will be available this year for sure, and I like something in v6 more than v2022. On the other ends, probably I'll find more exmaples, tutorials, and less bugs, in 2022.. Any suggestion will be appreciated, thank you!

lime pewter
stiff bane
#

the adding the f after the numbers worked thank you.

digital warren
# lime pewter try changing "TextEditor.content" to "TextEditor.text" as the error message says
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using UnityEngine;

public static class NGUITools
{
    private static AudioListener mListener;

    private static bool mLoaded = false;

    private static float mGlobalVolume = 1f;

    private static Vector3[] mSides = new Vector3[4];

    public static float soundVolume
    {
        get
        {
            if (!mLoaded)
            {
                mLoaded = true;
                mGlobalVolume = PlayerPrefs.GetFloat("Sound", 1f);
            }
            return mGlobalVolume;
        }
        set
        {
            if (mGlobalVolume != value)
            {
                mLoaded = true;
                mGlobalVolume = value;
                PlayerPrefs.SetFloat("Sound", value);
            }
        }
    }

    public static bool fileAccess
    {
        get
        {
            return true;
        }
    }

    public static string clipboard
    {
        get
        {
            TextEditor textEditor = new TextEditor();
            textEditor.Paste();
            return textEditor.content.text;
        }
        set
        {
            TextEditor textEditor = new TextEditor();
            textEditor.content = new GUIContent(value);
            textEditor.OnFocus();
            textEditor.Copy();
        }
    }
eternal falconBOT
acoustic echo
lime pewter
digital warren
#

sorry wait

stiff bane
lime pewter
#

it's okay, haha.

polar acorn
slender nymph
digital warren
trail heart
#

@digital warren This NGUITools is not an official package, we can't really advice how to fix it and there's no guarantee it has any way to keep up with your unity version

slender nymph
polar acorn
lime pewter
#

But the package might have documentation relating to how to properly use the "TextEditor"

acoustic echo
digital warren
#

An app

polar acorn
#

There's basically no reason to use NGUI any more, it's practically built in

acoustic echo
#

I'm sure that package is not for Unity 6, just look at date of last commit to that file

lime pewter
swift crag
#

so you're trying to decompile an application (presumably ancient) and then smash the resulting code into modern Unity

digital warren
#

This why then

#

Wait let me change the version

lime pewter
digital warren
trail heart
#

Decompiling is against the rules, in any case

lime pewter
#

I would find a recent guide on basic UI. And avoid third-party-packages almost always.

digital warren
polar acorn
digital warren
#

._.

slender nymph
lime pewter
#

Unity has recently updated the UI system, so natively it's a lot more malleable than versions prior.

lime pewter
# digital warren This why then

https://www.youtube.com/watch?v=DX7HyN7oJjE Try this, and see if it suits what you're going for!

In this Unity tutorial we'll make a Main Menu.
How to make a PLAY button , OPTIONS button and QUIT button in Unity ?

Enjoy the video โ˜•

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”
๐Ÿ– Hi Game developer
Welcome to Rehope Games I'm Murat

I share unity tutorial videos on my channel. if you want to make a game with unity (especially 2d platformer game), the ...

โ–ถ Play video
lime pewter
#

I assume this teaches basic buttons and ui elements which you could apply to more than just a main menu.

lime pewter
#

It's in my opinion not very helpful to rip packages from online whenever you need something and instead try to find guides that can help teach the concepts of what you need going forward, learning isn't using already finished products.

#

So even if you think it'll slow down progress, in the long term it's way more worthwhile to just learn how to create whatever you'd like yourself, in all elements of game design, (barring maybe design assets if that's not your thing).

digital warren
#

Alright man ._.

lime pewter
digital warren
#

Wait I run the game Before in unity 6 lol idk why it's get this error again @lime pewter I face it before

#

And chat GPT helped me lol but idk why it getting back

#

Ok I asked him

#

Now I got 80 errors

lime pewter
digital warren
#

GG

digital warren
#

I liked unity 6 because it's has the ability to remove splash screen

#

This why I using it lol

lime pewter
digital warren
#

I heard it from YouTube dude say unity 6 has ability to remove it without paying

#

Or anything

lime pewter
# digital warren Really?

Yeah, I think you may need a license. Which you'd have if you were going to release your game anyway.

digital warren
#

Hmm I see now

lime pewter
slender nymph
#

you need unity pro to remove the splash screen in versions prior to unity 6. unity pro is not required to release on all platforms, just consoles, and also there's a revenue threshold that once you pass you must purchase pro

lime pewter
#

I personally don't use new versions until they've been out for a significant amount of time so documentation is less scarce. But there's a lot of reasons I avoid Unity 6 personally which I won't get into.

#

I believe it has a lot of native features which are very good for realism from what I've heard.

digital warren
#

._.

feral shuttle
slender nymph
#

I think that's an error with the docs. those methods shouldn't be static since they access instance members

feral shuttle
#

I guess the idea is that the buttons are only meant to be created once, or that there should only be one instance of network manager?

#

"network manager" referring to the entire class

slender nymph
#

ah yeah, looks like they've changed at some point and either should be using the networkmanager singleton or previously did. the snippet with those methods further down the page uses the singleton instead of the direct reference

feral shuttle
#

Ohhh I missed that, thanks

eternal needle
final totem
#

should i just put var everywhere as rider suggests?

cosmic dagger
summer stump
cosmic dagger
#

if you have to stop and think what type it is, then no, i wouldn't use it . . .

swift crag
#

i noticed that Rider rewrote all of my explicit types into var

#

i wonder if I can make its cleanup process leave simple types untouched

#

ah, you can!

#

much better -- it wanted to make everything into a var. I made built-in types explicit and used var when evident in other cases

final totem
#

But should i have var everywhere? Sometimes is good but not everything.

swift crag
#

I found it very awkward in situations like this

#
var x = 1;
#

Maybe that's just because I'm used to using the explicit type for these "simple" types

#

you can read about how to configure things here

final totem
#

How do i forget the habit of asking wveryhting to copilot and copy pasting. I want to stop but it does everything I say perfectly I can't stop to think and understand wtf is he writing but it works to perfection I need tips

#

Every thing I ask he writes it perfectly. He's not longer copilot he's capitan I'm the copilot

swift crag
#

by not using it, pretty much

#

use material on !learn to get a handle on the basics

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

weak talon
#

hello, i am making fps shooter and my camera is jittery

the player is a parent to the camera and when i move the camera (like rotation) it is fine but only when i start moving and rotating the camera the camera movement is very jittery

the rigidbody is interpolate, movement is in fixedUpdate as it is rigidbody movement, and cameramovement is in lateupdate
please help (tell me if you need to see any code)

swift crag
#

What about rotation? Where does that happen?

serene briar
#

I need help with my code. I want to apply a force to the 0,0 point to simulate a gravitational body at that location. The problem is that the force just doesn't do anything. The rigidbody just sits there. I've tried with Vector2.up and it works so I'm not sure what the problem is.

public class Gravity : MonoBehaviour
{
    public Rigidbody2D Rocket;
    public float GravityStrength = 1;
    
    void Start()
    {
        
    }
    void Update()
    {
        Rocket.AddForce(new Vector2(0,0) * GravityStrength);
    }
}
frosty hound
#

When you add force, it's a direction you're pointing it. You're giving it a direction of nothing.

serene briar
#

If I added another rigidbody to simulate a planet, could I get that planet's transform and use it in my vector

ember tangle
#

!code

eternal falconBOT
serene briar
#

that's the hard part really, I see so many methods and none seem as simple as it should be

ember tangle
#

https://hatebin.com/qrdpnrgiyv I don't understand why this code works. The values being put into Vector3.Lerp through curve.Evaluate(sampleTime);at line 22 are crazy and are never between 0 and 1. This line if (sampleTime >= 1f) somehow works when sampleTime is in the 20s.

slender nymph
#

you should note that you are printing Time.time and not your actual sampleTime variable. so what you are printing has pretty much nothing at all to do with the value you are actually using

eternal needle
finite lark
#

if im doing a top down game and i have a doorway how do i make it so the player goes under the door way but renders over the wall

#

i also have props that need to render over the wall

slender nymph
honest trench
#

https://pastebin.com/c6DGanrs So i have this code here, and in my SetGrapplePoint void im tryna make it so if the player clicks close enough to a grappleable object it will auto lock to the surface of the object, it it works fine, the issue is that when a player clicks on a object to grapple it grapples where ever the player clicked, including the middle of the object, instead of the surface. example attached. how do i fix this?

rocky canyon
honest trench
#

okay got it

rocky canyon
#

cool system so far ๐Ÿ‘

honest trench
#

thanks

#

first time doing raycasting so im mad confused but im figuring it out

rocky canyon
honest trench
#

lmao i used to play worms on my 360

#

im tryna make a getting over it rage game thing

rocky canyon
#

best game ever imo

honest trench
#

ik i did it wrong i just have no clue like how this works

rocky canyon
#

why would that happen? the only thing u would change is hte location ur grapple targets

honest trench
#

idk

#

wait i think i got it

#

i did it backwards mb

rocky canyon
#

!code

eternal falconBOT
vast moat
#

o my bad

rocky canyon
vast moat
#
//Face mouse
        Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
        float rayLength;
        if (groundPlane.Raycast(cameraRay, out rayLength))
        {
            Vector3 pointToLook = cameraRay.GetPoint(rayLength);
            Debug.DrawLine(cameraRay.origin, pointToLook, Color.yellow);

            transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
        }

could someone explain to me why this code works to make my character face my mouse? im not really familiar with anything "Ray" related so i'd like to know how it works

rocky canyon
#

Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); ur shooting a ray from the camera thru the screen, thru the mouse position, and hitting the level

#

thats ur point.. then LookAt just looks at that point

summer stump
rocky canyon
#

LookAt() is just a magic unity function..

#

normally ud need to write out ur rotation logic as well

#

ur passing in transform.position.y soo that it doesn't look up and down. (basically looking at a point on the same height as the transform(player)

#

just left and right (x and z)

wintry quarry
rocky canyon
#

instructions unclear -> swat sitting down the road

#

but in seriousness, you get all that Taf?

vast moat
#

yeah i think i got it mostly

#

thank you for the help everyone

#

i just realized that im pretty sure the debug line isnt necessary at all and just to visualize the ray in the scene

rocky canyon
#
        Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); // you make the ray
        Plane groundPlane = new Plane(Vector3.up, Vector3.zero); // you create a invisible plane oriented same as ur ground i imagine
        float rayLength; // the length of the ray
        if (groundPlane.Raycast(cameraRay, out rayLength)) // shoot the ray and if the ray hits the plane
        {
            Vector3 pointToLook = cameraRay.GetPoint(rayLength); // get the point where the ray hits the plane
            Debug.DrawLine(cameraRay.origin, pointToLook, Color.yellow); // ur fancy debug

            transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z)); // look at the point
        }```
vast moat
#

okok i got it now

#

can you just use LookAt whenever you want anything to look at anything basically? itll do all the rotation for you?

rocky canyon
#

yup

vast moat
#

that makes life easy

#

okay, thank you so much

rocky canyon
#

sometimes u want more complex rotations.. but LookAt() is pretty good when getting started

#

and if u dont want it to look up and down or left or right (a certain axis) you pass in its own transform for that property

#

like u code does for the y part of the vector you use

vast moat
ashen wind
#

I'm really new to unity's Mirror networking, can anyone explain what this does

NetworkServer.Destroy(gameObject);

#

I had an idea of what I thought it did, but the behavior I'm seeing is not following that

rocky canyon
#

destroy a game object on all clients connected to the server.

ashen wind
#

but when you say gameObject, that only refers to the gameobject that the script your in is attached to, right?

rocky canyon
#

well w/e is in the ( )

#

gameObject is the gameobject the script is on correct (its the same as this.gameObject

#

but u could put any gameobject/ any reference in there

ashen wind
#

because I have this attached to a missile and when I shoot the missile with a bullet, it's supposed to destroy the missile on both clients

rocky canyon
#

does it not?

ashen wind
#

but what it actually does is destroy the missile on one of the clients and destroy the player on both clients

rocky canyon
#

that doesn't make sense

ashen wind
#

the player that shot the missile that is

rocky canyon
#

this means it shouldn't be on ur player..

#

and shouldn't therefor destroy the player for no reason

ashen wind
#
 void OnTriggerEnter2D(Collider2D collision)
    {
        if (isServer == true)
        {
            if (collision.CompareTag("Player") || collision.CompareTag("bullet"))
            {
                Debug.Log("network missile hit player or bullet");
                NetworkServer.Destroy(gameObject);
            }           
        }
    }
#

this is in my network missile script

rocky canyon
#

yea, unless that was yourPlayerReference.gameObject it wouldnt destroy the player.. just the gameobject that script/trigger is attached to

zenith cypress
#

Don't you have to destroy via a [Command] function

rocky canyon
#

yea โ˜๏ธ

ashen wind
#

ok lemme try that

#

wait

#

the example has the function with [Client] above it

#

do I need that?

#

or can I do this

rocky canyon
#

i have no clue.. i make singleplayer games.. sorry

ashen wind
#
    
void OnTriggerEnter2D(Collider2D collision)
    {
        if (isServer == true)
        {
            if (collision.CompareTag("Player") || collision.CompareTag("bullet"))
            {
                Debug.Log("network missile hit player or bullet");
                CmdDestroyObject(gameObject);
            }
            

        }
    }

    [Command]
    private void CmdDestroyObject(GameObject obj)
    {
        if (!obj) return;

        NetworkServer.Destroy(obj);
    }
rocky canyon
#

put a line break after cs

#

not sure what [Command] does.. but its some sort of attribute

#

The [Command] attribute in Unity's UNet (Unity Networking) API designates a method to be called on the server, even though it might be invoked from a client. When a client calls a method marked with [Command], the request is sent to the server, which then executes the method.

eternal needle
#

Unet is old

eternal needle
zenith cypress
#

Yeah I haven't used it, but I use NGO so its "ideas" are similar

rocky canyon
#

yea, i figured the [Command] part was still relevant..

#

yea networking would know more about this stuff

native hill
#

i am trying to make a mouse movement script, it works kinda the only thing rotating is the camera ```using UnityEngine;

public class MouseMovement : MonoBehaviour
{
public float sense;
public Transform Player;

void Start()
{
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
}

void Update()
{
    float mouseX = Input.GetAxis("Mouse X") * sense;
    float mouseY = Input.GetAxis("Mouse Y") * sense;
    float PlayerX = Input.GetAxis("Horizontal") * sense;
    float PlayerY = Input.GetAxis("Vertical") * sense;

    transform.Rotate(Vector3.up, mouseX);    
    transform.Rotate(Vector3.left, mouseY);  
    Player.Rotate(Vector3.up, PlayerX);  
    Player.Rotate(Vector3.forward, -PlayerY); 


}

}```

native hill
#

tutorials and stuff, i just gathered what i saw and tried making it

#

i tried my best to understand everything

rocky canyon
#

never in my life i seen anything like that.. lol

native hill
#

i didnt know it was that bad ๐Ÿ’”

#

how do i fix it!

rocky canyon
#

this is how i do it.. you should only need (1) rotation method for each object

#

the fact u have 2 for each object is extremely odd to me

native hill
#

augh so much mathhh, ill look at the docs and stuff to try and understand what is going on

native hill
rocky canyon
#

i could send you my version if ur using 3D

native hill
#

I am using 3D

rocky canyon
rocky canyon
#

for controller slot in ur player object

#

ur camera should be a child of ur player

native hill
#

it is

rocky canyon
#

ur camera rotates up and down... and the player left and right

native hill
#

i could show u a screenshot

rocky canyon
#

it should work out of hte box

#

nah i believe you

native hill
#

the player isnt doing anything

rocky canyon
native hill
#

yeah, im not sure what im doing wrong

native hill
rocky canyon
#

whats different?

native hill
#

wait nevermind

#

its just the icon

rocky canyon
#

i changed my limits to 80

native hill
#

ill show u mine once snipping tool opens

serene briar
#

I've tried everything but my rocket still doesn't move.

#

Oops

native hill
#

what do u suggest i start learning

#

or should i just rack up experience

rocky canyon
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

native hill
#

thanks

rocky canyon
wanton kraken
#

hey fellas, i'm working on a top down game and struggling to implement bullets that travel in a straight line from where they're shot. any ideas on how to do this? do i need raycasts? i'm also planning to make them bounce llater, so there's that

queen adder
#

So this is how I want to handle triggering a ragdoll on a bot's death:

The main bot object, like the parent of the rig and everything etc has a script called Human. and when the health is 0 out of 100, it calls a function called KillBot, This loops through all the body part rigidbodies and turn them on etc.

Each collider body part has a script called BodyPart. When lets say a bullet hits it, it does GetComponent<BodyPart>().DamageBot(100f), Each BodyPart script can access the Human script.

Im wondering if this is the best method, other than having one overall collider to register bullet hits, and then it would get disabled and the body part colliders/rbs enabled

rocky canyon
#

scroll down to the where/how and theres some good resources i recommend @native hill

native hill
#

alright i will

rocky canyon
#

should travel in a str8 line as is.. unless ur doing something weird to it

hybrid tapir
#

why do i get this error 4 times

wanton kraken
#

also, youโ€™re always here to help people. youโ€™re a real one man!

queen adder
rocky canyon
rocky canyon
hybrid tapir
#

wish it would tell me what object

#

and in what scene

rocky canyon
#

click it

#

it should highlight the object

#

(or maybe not, ive never had that exact error before)

hybrid tapir
#

its not highlighting anything for me like i can normally do with errors

rocky canyon
#

hmm do you have any object that you know of that may have a really big scale..

#

or way off the screen?

wanton kraken
#

that's why i'm so confused

rocky canyon
#

then why would gravity still be affecting it?

wanton kraken
#

i have zero idea, i can send a video if you'd like

rocky canyon
#

is it colliding w/ any part of ur player

#

thats sending it the wrong way?

wanton kraken
#

oh nevermind, i figured it out. just had something set up wrong lmao

rocky canyon
#

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

wanton kraken
#

i know right

#

but now that i look at it, the issue is actually persisting

#

when the bullets fly for a bit, they start falling off

hybrid tapir
# rocky canyon or way off the screen?

i mean, maybe it thinks the UI is a sprite? i can cintinue doing whatever i want without resolving these errors, but there are 4 of them and 4 coins so it has to be something in the coin counter scene

rocky canyon
#

its a weird error..

#

b/c underneath it says UnityEditor..

#

those are usually Unity Bugs that disappear w/ restarts

#

BUT if its a UI element.. it may be something of urs.. u can restart and test maybe

hybrid tapir
#

every time i start the unity project i get the errors but once i clear the console they dont come back

rocky canyon
#

hmm interesting.. i wonder if it would affect the build any?

wanton kraken
rocky canyon
#

it may be a non-issue but a broken editor..

#

@hybrid tapir hey, try resetting ur layout

hybrid tapir
#

did that

rocky canyon
hybrid tapir
#

imma restart the editor and see if i get the errors again

hybrid tapir
wanton kraken
queen adder
hybrid tapir
wanton kraken
rocky canyon
wanton kraken
#

ironically, the movement doesn't happen in that script. here's the code for the bullet's movement though

#

\
GameObject bullet = Instantiate(BulletPrefab, Spawner.position, Spawner.rotation);
bullet.GetComponent<Rigidbody2D>().AddForce(Spawner.up * BulletSpeed, ForceMode2D.Impulse);
\\

#

well that ain't right. oh well

rocky canyon
#

i got the gist of it

#

is that in update?

hybrid tapir
queen adder
rocky canyon
#

i see everyone using 33

wanton kraken
native hill
#

so im looking at a question on stack overflow and theres different answers, should i just try understanding one of the easier ones or complex ones so i could learn more

wanton kraken
rocky canyon
#

the drag on ur RB2D is slowing it down

#

soo it appears to be falling

#

i think

wanton kraken
#

there's zero drag on it, though

rocky canyon
#

i ohh ur right.. nvm

rocky canyon
#

in update

#

and see what velocities its using

#

something weird is going on

wanton kraken
#

i would be lying if i said i knew how to do that

#

i thought the issue is that force isn't being applied throughout?

rocky canyon
#

rb2dReference.velocity

#

Debug.Log(rb2dReference.velocity);

rocky canyon
wanton kraken
#

yeah, exactly

rocky canyon
#

it'd be like pushing a satellite in space.. it'd just keep going the way u pushed it

wanton kraken
#

that's why i'm confused

rocky canyon
wanton kraken
#

alright, let me see to that

rocky canyon
#

(0,0,AValue)

#

wait.. its 2d..

#

so it'd be (your value, 0)

wanton kraken
#

huh?

rocky canyon
#

Spawner.up is probably Vector2(0, 1);

#

sooo ur value should read (0, a number)

rocky canyon
wanton kraken
#

let me check that out

rocky canyon
wanton kraken
#

you mean relative force?

rocky canyon
#

yea that

wanton kraken
#

don't be dude, i can use the help

vast moat
#

would this be the channel to ask about colliders? or is there a different channel better suited for that

rocky canyon
wanton kraken
#

no beans on that, it's actually far worse

rocky canyon
#

rb2d.velocity = forward * speed;

rocky canyon
#

if its just about the collider and inspector u can ask in physics or unity-talk

vast moat
#

okay thanks

rocky canyon
wanton kraken
#

mkay, let me try that

#
bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(BulletSpeed, BulletSpeed);
#

how's that?

summer stump
#

is that.. what you want?

wanton kraken
#

i'd like it to travel in a straight line from where it's shot

#

not sure how exactly that translates into (x,y) consider that changes on the fly

summer stump
#

instead of making a new Vector

#

often for 2d that means either transform.up or transform.right depending on how it is set up
The transform would either be the player or a gun or some firePoint object

wanton kraken
#

i had that before, spawncamp suggested that i add velocity directly

summer stump
#

Well, what I'm describing would be used to set the velocity directly

#

I am only talking about directions

#

rb.velocity = transform.right * bulletSpeed

wanton kraken
summer stump
#

Nope

#

before you used AddForce

wanton kraken
#

ah, you're talking about transforming the object directly

summer stump
#

I am talking about setting the velocity

wanton kraken
#

oh. my mistake

rocky canyon
summer stump
#

transform.up and transform.right are just directions. they dont' actually DO anything to the transform

rocky canyon
#

i set velocity directly in the Start() function of the projectile

wanton kraken
#

right, well now when i shoot it, it curves hard right lol

summer stump
#

nice video

wanton kraken
#

agreed, thank you for the demonstration

native hill
#

whats the difference with getaxis and getaxisraw?

summer stump
#

it goes from 0 to 1 with all values in between

#

the latter just jumps immediately to 1 or 0

summer stump
wanton kraken
rocky canyon
hybrid tapir
rocky canyon
native hill
hybrid tapir
#

im bummed out i literally got an android phone FOR DEV STUFF and i still cant do anything after enabling dev mode

rocky canyon
#

mobile can be tricky..

hybrid tapir
#

i thought not being able to build to your device was just apples self imposed problem

wanton kraken
rocky canyon
#

just run in the simulator until u figure it out

summer stump
wanton kraken
#

nothing really, just some basic code to destroy the bullet on collision

summer stump
rocky canyon
summer stump
#

Ah, thx

wanton kraken
rocky canyon
#

put ur bullet prefab in the scene and press play

#

see if it still happens (w/o instantiating it)

wanton kraken
#

well, nothing happens. this is probably because the movement script isn't inside the prefab itself

summer stump
#

Wait, when you say hard right, do you mean it comes out at the wrong angle, or it CURVES to the right.

summer stump
#

BulletMover is not on the prefab?

rocky canyon
#

interesting..

wanton kraken
#

on the cannon, pressing the fire button calls to the method fire. that's what both instantiates the bullet as well as adds force to it

summer stump
#

Oh, you set the velocity in the code that instantiated it

wanton kraken
#

BulletMover is on the prefab

rocky canyon
wanton kraken
#

it doesn't actually move the bullet because i'm a sick man

rocky canyon
#

hes got phantom code

wanton kraken
#

i'm just cursed i guess? i don't know, why the heck is it doin that

vast moat
#

hey do you guys know how to get suggestions like the ones this guy has

#

that tell you what types of things go in the brackets

wanton kraken
#

you need intellisense. make sure that unity has visual studio editor installed and active

wanton kraken
rocky canyon
#

delete it and re-do it

wanton kraken
#

i mean, i'm just going to redo what I have here and reach the same result

rocky canyon
#

first thing u need to do is get a 2d projectile to fly str8

#

worry about that first..

#

and then spawn it and rotate it or w/e

wanton kraken
#

mkay

rocky canyon
#
using UnityEngine;

public class ProjectileMover : MonoBehaviour
{
    public float speed = 10f; // Speed variable

    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>(); // Grab the Rigidbody2D component

        // Set the velocity to be its forward direction multiplied by speed
        rb.velocity = transform.right * speed;
    }
}
#

heres what u seen in the video if u want

eternal falconBOT
wanton kraken
#

as expected, i got the same exact results

rocky canyon
#

impossible

#

you only have 1 rigidbody on that thing right?

wanton kraken
#

just the one.

rocky canyon
#

doesn't make any sense..

#

did u create a new object for the prefab?

wanton kraken
#

yes, i did. the bullets are falling straight out of the cannon like water droplets

rocky canyon
#

ur mass is huge..

#

crank up the velocity

wanton kraken
#

it's .5 lmao

rocky canyon
#

my mass was 1

rocky canyon
wanton kraken
#

me too dude

#

me too

#

i must be doing something seriously fucking stupid, that or the engine doesn't like me

#

i seriously don't know

rocky canyon
#

create a new scene.. drop the prefab in it by itself and test it..

wanton kraken
#

the prefab itself doesn't do anything. the cannon has the movement script.

rocky canyon
#

if it doesn't go straight.. send a screenshot of the prefab selected in the heirarchy and the mode set the pivot local

rocky canyon
#

just make it move by itself.. in a str8 line.. w/o falling first

#

we're trying to isolate whatever is causing it to fall

wanton kraken
#

mkay

rocky canyon
#

u can spawn the bullet.. and rotate it.. and then let the bullets movement code set its own velocity

#

that way the cannon isn't telling the bullet what to do..

#

SOLID

Single Responsibility

wanton kraken
#

why the fuck won't it let me add the bulletspawner into the script

#

i'm losing it

#

when i add it to the hirearchy i can, when i put it back into prefabs it dissapears

#

forget it, i'll go without that part

#

i'm done, i have no idea what the problem is and it absolutely refuses to work. i give up, goodnight

rocky canyon
wanton kraken
#

here's to hoping, i appreciate the help

native hill
#

i do not understand Quaternion.Euler at all

#

the docs r confusing

slender nymph
#

it creates a quaternion from euler angles. what is confusing about that?

native hill
#

i dont even know what any of that means ๐Ÿ’”

#

i saw it in a camera movement tutorial video and im trying to understand it

rocky canyon
#

Unity uses Quaternions.. transform.rotation is a quaternion.. (we humans usually visualize angles as 0 - 360*) the method converts what we associate w/ angles and rotations to a Quaternion you can use for functions that require it

slender nymph
#

a quaternion is a 4 axis structure used to represent a rotation. that's really all you need to know about that part. euler angles are the X Y Z angles in degrees you are likely already familiar with

rocky canyon
#

Quaternions are 4 Dimensional ๐Ÿคฏ

native hill
#

that makes more sense

#

thank u

bright grail
#

can anyone help me with a animation problem here?

rocky canyon
#

we can help w/ coding issues related to animation

bright grail
#

i think its a coding error but idk

rocky canyon
rocky canyon
bright grail
#

the animation is freezing at the frist frame and idk if its bc of the code or the Transition times

rocky canyon
#

transition shouldnt matter until the end of the clip

bright grail
rocky canyon
#

if its freezing at the first frame i doubt its transition issues.. Unless its looping to an animation over and over and over

#

and then the animation might not get a chance to play

bright grail
#

oh ok let me see

rocky canyon
#

open up the Animator window while u play test..

#

and click on the object w/ the animator in the hierarchy

#

u can visualize whats happening

#

they'll be a white progress bar growing under the clip thats playing.. and then transitions will light up when it goes from one clip to another

bright grail
#

it doesnt look like the Idle anim is looping it just goes to the walking anim and just kind stops at the first frame

#

like littary the bar just stops

rocky canyon
#

sounds like a clue ๐Ÿ”Ž

slender nymph
#

i'm gonna guess that's it is constantly reentering that state, perhaps due to a transition from Any State

bright grail
#

what does that mean

rocky canyon
#

โ˜๏ธ yay, validation

bright grail
#

ohh

slender nymph
bright grail
#

okok

rocky canyon
#

means this

bright grail
#

wait let me Test something

#

ok yea ig its because i put coming from any state

#

my bad i was stupid

#

thank you guys

slender nymph
#

remember, Any State includes every state, including the one you are transitioning to. so you gotta be careful when using that and pay extra close attention to your transition conditions

eternal magnet
#

whare i can i get help about tiles in unity 2d?

bright grail
#

ok yea thank you ill rember that

hasty sleet
hasty sleet
languid spire
hasty sleet
languid spire
#

Nice in theory, pointless in practice

hasty sleet
#

Empathy and kindness is free.

eternal needle
languid spire
summer stump
#

Honestly, most people don't know about #๐Ÿ”Žโ”ƒfind-a-channel
I think it is a good response
It shows all the categories of channels with descriptions, and is very helpful

random dove
#

can anyone hlep me

hasty sleet
#

It can cut both ways. Treating newcomers with apathy / low empathy makes it more likely to occur again in the future.

summer stump
random dove
#

how to get first person template its not showing in templates

summer stump
random dove
summer stump
#

You can also find them on the asset store from what I understand. You'd have to search though, I don't have a link handy

random dove
#

well i can't download bcz my wifi is trash

summer stump
#

You do not need templates

random dove
#

there is no 3rd person game also?

rocky canyon
summer stump
rocky canyon
#

2021.3 has First Person and Third Person Core

summer stump
random dove
rocky canyon
random dove
#

wait what so what is 3d core

rocky canyon
#

its ur basic 3d project..

hasty sleet
summer stump
# random dove i can't download

Well, like I said, you don't need to use any template. It just preinstalls some packages. You can use any template and achieve the same things

rocky canyon
#

3d core is 3d project w/ camera and light

hasty sleet
rocky canyon
#

they're really not that much different from each other.. (maybe some unity assets included in each)

random dove
random dove
#

i have some questions so what is your prob?

summer stump
random dove
#

can i make 3rd person game on 3D

hasty sleet
#

I misunderstood. I thought he was implying his main problem was his inability to download the template.

summer stump
hasty sleet
summer stump
random dove
#

bruh then what are templates for

summer stump
rocky canyon
#

pro-tip.. unity is a 3d engine.. even 2D is basically 3d while ignoring an axis

random dove
#

;=;

hasty sleet
# summer stump Yes

I don't see how it would be. "I cannot help you" is not a lack of empathy.

summer stump
random dove
#

cya

hasty sleet
summer stump
#

I am clearly not. Sorry if I upset you. Gonna just leave it to you. Goodbye

topaz mortar
#

I'm using UGS C# Cloud Code Module as a server, it's non-persistent.
The server handles all my combat logic, to prevent cheating.
Now I'm trying to add different spells to my game, with randomized stats.
The server will need to know these spells, again to avoid cheating.
But how would I get them on my client?

I'm thinking to save them in code on my server, since that will be the easiest to edit for me.
Then when a client loads the game, it sends a request to the server to get all the spell data? Not sure if this is a good idea?
There won't be a crazy amount of spells, maybe like 50-100 max?

hasty sleet
#

Let's leave it at that, then.

eager spindle
#

when making UI how do y'all embed 3d renders in? load another scene in parallel or just put the character somewhere in the world

hasty sleet
#

For example, if the player is holding a sword, and you want to render the 3d sword object onto the UI rather than in real worldspace, such as in most FPS games. Like this?

eager spindle
#

on what is best practice

hasty sleet
#

I am not sure if it is best practice, but I followed some docs in one of my previous projects.

The primary steps were:

  1. Create a camera elsewhere in the scene, and only capture the prop objects you want to render onto the UI
  2. Output the camera capture onto a UI Canvas element
eager spindle
#

when rendering dialogue like this do you use 3 cameras? because it feels kinda inefficient

#

the characters on the left and right are in the same scene

hasty sleet
#

I think you might have to if you have three different perspectives you want to capture. Alternatively, you could genuinely take a picture of these characters, edit the image, and store it as a single image file, but I imagine you might be trying to capture animated characters

eager spindle
#

this is a live scene where they have expressions and stuff

#

like mouth movements, some particle effects

hasty sleet
#

The others can chime in to suggest alternate approaches, but the only one I am aware of involves a camera outputting to a canvas element, since capturing an image/video from a scene necessarily involves a camera, I believe, though there could be other approaches.

hasty sleet
eager spindle
#

yep I understand how to do that

#

im thinking more about how to efficiently render multiple perspectives