#💻┃code-beginner

1 messages · Page 836 of 1

naive pawn
#

it'll help a lot

fervent yew
#

i dont wanna be a programmer but i have to do this pathway to enroll on to an artist scholarship(mindblowing)

livid socket
#

then read ur errors correctly ?

fervent yew
#

i came here to find out how...

next yarrow
livid socket
next yarrow
#

so why not start with basic c#

rich adder
#

learning the basics doesn't need to make you a programmer.. at least you can then read code

fervent yew
#

agreed

#

okay fresh start lmao... apologies for coming in hot

#

by configure my ide i assume like using extensions and that right?

rich adder
#

you only need Unity extension, its all outlined in the link sent

acoustic maple
#

This

naive pawn
#

i don't really have more info, i'm not familiar enough to prescribe anything

fervent yew
#

okay so the error is line 2 but thats not something iv written, that existed from the moment i created the script

#

also i did the configuration guide ty

keen dew
#

If only there was some way to remove it

fervent yew
#

will it not break anything? since it was there from creation

slender nymph
#

it wasn't there when you created the script

naive pawn
fervent yew
#

i did the guide so ill remove it and hoipefully that'll sort it

naive pawn
#

you should configure your ide.

rich adder
#

funny how VSC underlines Behaviour as a spelling error 😆

naive pawn
fervent yew
naive pawn
#

it hasn't been configured

naive pawn
#

you should see MonoBehaviour, UnityEngine, GameObject, and Collider in green, and Destroy, Instantiate, and Rotate in yellow

#

they aren't highlighted properly, a sign that it hasn't been configured

#

have you installed the .net sdk via the .net install tool in vscode? (in vscode, command palette (ctrl+shift+p) > install .net sdk)

#

(once you've installed that you would restart vscode)

rich adder
frigid barn
#

guyz the square is not coming upto the background i checked order in layer but still not showing...

rich adder
#

they are not compatible

#

also not a coding question

sage mirage
#

Hey, guys! I didn't know the DDOL can be used to save actually values and preferences like we do with PlayerPrefs, JSON etc

#

Is it an efficient way to actually save values this way with DDOL?

rich adder
#

DDOL has nothing to do with saving values..

sage mirage
#

Or it works only when changing scenes

#

So I think it wont actually store values in memory

#

they will gone after restarting the game

slender nymph
#

DDOL does not save values. DDOL is only to prevent an object from being destroyed when the scene is unloaded

rich adder
sage mirage
#

so it will save values only across scenes its not effective on anything else

rich adder
#

you can save a JSON formatted text into PlayerPrefs 🤯

rich adder
sour fulcrum
#

as i mentioned

sage mirage
#

So two options JSON and PlayerPRefs

#

Right?

rich adder
#

again json is just format.. is not a save method

sage mirage
#

There isn't anything else

rich adder
#

you mean a File on your PC ?

sage mirage
#

I mean I have mever used this method

#

With JSON Utility I think

#

its a class right

sour fulcrum
#

theres many ways, those are two common ones though

rich adder
#

JsonUtility just de/serializes text

#

you can literally use it in PlayerPrefs as well

sage mirage
#

I want to try and save values using this method but right now I have to go off so probably tomorrow I will be around.

rich adder
#

the common way is
Json format into a file saved in Application.persistentDataPath

#

playerprefs for more "temporary" options (maybe muting a session when it starts, video settings etc.)

slender nymph
#

playerprefs should ideally never be used for gameplay save data and should just be used for preferences for the player application hence the name PlayerPrefs

#

it should especially never be used for gameplay on Windows because they get saved to the windows registry

rich adder
#

I use it for session cookies when user logs in and stores their tooken

slender nymph
#

DontDestroyOnLoad

lilac goblet
#

Guys where do I show my games

lilac goblet
#

Ty

tender vapor
#

Hello <@&502884371011731486> where can I report a scammer?

frosty hound
nocturne parcel
#

How to attach text to a gameobject?
A floating text in front of it

night raptor
undone birch
#

Hello yall, is this where I can ask for some help?

radiant voidBOT
# fickle plume !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

undone birch
#

I'm having a bit of an issue here in Unity where I'm experincing quite a bit of frame skips. I don't really know what I'm doing since I'm a turbo beginner, so if anybody has any idea what I could do to fix this, I'd appreciate any help.

solar hill
#

Share the code here

#

!code

radiant voidBOT
undone birch
solar hill
#

Yes

undone birch
#
//using UnityEngine;

public class CameraLook : MonoBehaviour
{
    public float mouseSensitivity = 100f;
    private float xRotation = 0f;
    private Transform playerBody;

    void Start()
    {
        playerBody = transform.parent;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

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

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
}
unborn trellis
#

Can someone help me take a look at my code and help me figure out why my SoundControl() method (the one at the very bottom) isn't fully working?

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
#

just post code and describe the issue - how exactly isn't it working?

#

!code

radiant voidBOT
unborn trellis
#

sorry more used to mobile so accidentally hit enter and sent early

#

wasnt done typing

#

https://paste.ofcode.org/wvd8SyGyvtEEUxcGj7Ntb3 Can someone help me take a look at my code and help me figure out why my SoundControl() method (the one at the very bottom) isn't fully working? The jump sound effect is working but the walk run and crouch audio doesnt activate. for the record. For the record the debug output is coming out 1 if not moving, 7 if crouching and moving, and 8 when walking and sprinting

naive pawn
#

like why is it a separate boolean instead of a separate state

unborn trellis
naive pawn
#

right but how do you want your game to behave now

unborn trellis
#

Yes crouching is supposed to be allowed to happen when walking/running/in air

naive pawn
#

you'll probably want to separate what happens when doing those on their own vs doing those whilst crouching then

#

or do you want it to play both the crouching sound at the same time as walking/sprinting

#

also seems like you'd be restarting the audiosource every frame?

unborn trellis
#

I'll try separating some things then

unborn trellis
#

https://paste.ofcode.org/9kyL5M8XdWSvwmrqKmXEYi Updated the code a bit but not sure if this is the right direction or not, the walking and crouching audio will actually play now but for some reason it will only play if you sprint first and it will immediately stop if you do any other movement

ruby python
unborn trellis
frigid barn
#

Guyz can anyone help me related the Github,
if we pushed the assets project settings already and we want to push more small files then should we require to send whle asset file again...?

naive pawn
#

when you upload stuff to github, it's the changes

#

this should be kinda obvious when you're staging the new changes

frigid barn
#

or we have to push the changes separeatly?

teal viper
alpine birch
#

Hello everyone this might be a stupid question but how do i learn code and then how to use code in games? (c#)

frigid barn
#

and for using/applying code you will need external coder like visual studio code is good at all...

naive pawn
alpine birch
#

Everyone is saying that starting practically is the best way but i dont know how to start and with what

naive pawn
#

most important is just to start tbh

frigid barn
#

try making small games

alpine birch
#

alright

frigid barn
#

dont ry big projects early u can make flappy bird clone

#

also if u stuck at any place u can take help of AI or this server anytime

alpine birch
#

sounds good

naive pawn
#

don't use AI while learning, you don't have the necessary experience to actually utilize it properly and you will end up shooting yourself in the foot

muted grove
alpine birch
#

Guys im getting this error: Can't add script behaviour 'FliegeAnimation'. The script needs to derive from MonoBehaviour!

#

FliegeAnimation means flying animation its german

#

@frigid barn idk why but i cant awnser your Dm

radiant voidBOT
naive pawn
naive pawn
alpine birch
alpine birch
naive pawn
#

right

#

are there any compile errors?

naive pawn
alpine birch
#

ill try

#

im using visual studio and there was some mistakes and copilot fixed it for me i think and now its saying no problems found but the same issue pops up

#

never mind i fixed it

naive pawn
fickle plume
#

Looks like paste site expired

muted grove
fickle plume
#

oh actually quite a few do not load for me, might be an outage

#

works now...

shy tapir
#

Hello everyone

real thunder
#

can I somehow break out of if statement?

sour fulcrum
#

by avoiding needing to 😄

whats the usecase

real thunder
#
if (Physics.Raycast(start_trans.position, start_trans.forward, out RaycastHit hit, Mathf.Infinity, check_mask))
            {
                assumed_target = hit.transform.GetComponentInParent<AggressionTarget>();
                if(cached.Contains(assumed_target))... ugh skip no next condition?
            }
            else if (Physics.SphereCast(start_trans.position, spherecast_radius, start_trans.forward, out hit, Mathf.Infinity, check_mask))
            {
                assumed_target = hit.transform.GetComponentInParent<AggressionTarget>();
            }
            else
            {
                assumed_target = Accountant.instance.RequestTargetHomingClosestBlacklist(PlayerAsTarget.instance, start_trans.position, start_trans.forward, coeff, cut_coeff, cached);
            }
#

I figured I need to exclude repeats

#

...I guess I need a small method

#

bool one

naive pawn
#

... ugh skip no next condition?
where do you want control flow to go exactly?

wintry quarry
naive pawn
#

it already skips the "next" condition because you're already in the if

real thunder
#

it's almost like a language is designed to prevent me from building huge ugly chunks of poorly readable code

wintry quarry
#

save the raycast results to variable(s), do all the processing you need, then start the branches

real thunder
naive pawn
#

so you want it to check the next condition, not skip?

real thunder
#

I want to skip this one and check next one

#

not sure if this wording makes sense on second thought

#

but you got it

naive pawn
#

and you have more stuff after that if (cached...?

real thunder
#

no

naive pawn
#

then what's the point of this being a separate condition

#

this is just a chain of or's and and's

real thunder
#

there really is none

#

no wait

#

no abort waiting there is no point of not putting it at check

#

but like

#

seems like I either have to make a small method

#

or I dunno

#

need to transform hit into target

naive pawn
#

im so confused what this is supposed to do

#

you want to go into the else if? which has the same logic?

real thunder
#

yes!

#

but it's a spherecast now

#

the whole idea is to scan for several targets

#

this piece executed several times

naive pawn
#

so if it's cached, discard the raycast result?

real thunder
#

yeah

#

latest method also discards copies

naive pawn
#

you could have these be separate ifs that check assumed_target == null (and you'd do assumed_target = null in the cached check)

but it'd probably be more readable to just have this be its own method that does returns

real thunder
#

not sure I understood first one but this surely works and look bit suboptimal

private bool IsDuplicate(RaycastHit hit)
    {
        AggressionTarget assumed_target = hit.transform.GetComponentInParent<AggressionTarget>();
        if (cached.Contains(assumed_target))return true;
        else return false;
    }
naive pawn
#

this would duplicate the GetComponentInParent call wouldn't it

real thunder
#

🤔 wait this also does nullcheck

real thunder
naive pawn
real thunder
#

right

#

well I can put one assumed_target there as an out parameter

#

and it will be godawful design to look at

naive pawn
#

you're overcomplicating it

#

just pull this if tree out into its own method and put in returns in place of the assumed_target

polar acorn
sharp bloom
#

On some random article about UnityEvents vs. .NET Actions. I don't think I quite agree that using Lambda method is "cleaner", it just obscures stuff.

#

I think it's way more "consise" to do subscribe on Enable and unsubscribe on Disable

polar acorn
#

Lambdas are disposable and anonymous, so, they could make the code cleaner for things that are meant to be disposable.

sharp bloom
#

I see, any examples where I'd want something like that to be disposable?

naive pawn
#

callbacks rather than event listeners, perhaps

polar acorn
sharp bloom
#

Ah that kind of syntax exists in C# as well huh

#

I'm familiar with this kind of thing in JS

naive pawn
#

many languages use this term for what js calls arrow functions/anonymous functions

#

(what did you think it was...?)

sharp bloom
#

Yes it's an arrow function in JS, but IIRC there is no syntax like
foreach (var item in items) {dosomethingwith item}.

It's always an arrow function in JS

sharp bloom
#

Okay forget my message then

naive pawn
#

most modern imperative-ish languages have both functional patterns and imperative patterns for this kind of thing

sharp bloom
#

Crazy how I didn't learn about the existence of "for of" in a JS course...the teacher only told us to use foreach =>

naive pawn
#

kinda yikes

#

(the course i mean)

grand snow
naive pawn
grand snow
#

and as pointed out, lambdas are also related and can be used by both

#

I feel like the comparison to JS is dangerous because in JS arrow functions capture this when function(){} does not. Same for the difference of what for of and for in does.

#

basically js fucky dont look at it

mint imp
#

Ive never done a shop menu before
Where do i even begin with that?
Can someone give me a beginner level idea of how a shop would work
code wise

naive pawn
#

Where do i even begin with that?
drawing board - design out what it needs to do, what it needs to interact with, what it'll look like, what parts it's composed from

solar hill
mint imp
solar hill
#

if youre planning to build UI for your game you have to start off by researching how UI works in unity to begin with

swift crag
#

UGUI is unity's older UI system. It's GameObject based, so you create a hierarchy in your scene to represent each part of the UI.

UIToolkit is a newer system that's used a fair bit for the editor's UI. It's not GameObject based; you create documents (either with the interactive editor or via code) and then render them.

solar hill
#

UIToolkit is very similliar to Razor if you have some experience with it

#

basically imagine it as html and css for your UI

swift crag
#

I am mostly familiar with UGUI

#

yeah, UITK closely mimics the flexbox layout system used in browsers

#

UGUI has its own auto-layout system (which is in the same ballpark as flexbox layouts)

acoustic maple
#

What does this error mean? NullReferenceException: Object reference not set to an instance of an object
Ball_hit_bumper.OnCollisionEnter (UnityEngine.Collision collision) (at Assets/Script/Ball_hit_bumper.cs:42)
UnityEngine.Physics:OnSceneContact(PhysicsScene, IntPtr, Int32) (at /Users/bokken/build/output/unity/unity/Modules/Physics/ScriptBindings/PhysicsContact.bindings.cs:45)

naive pawn
polar acorn
naive pawn
#

check for stuff before . or [] on the line mentioned

acoustic maple
polar acorn
#

Try using logs to find out what

naive pawn
#

it's Score_Manager

acoustic maple
#

!code

radiant voidBOT
acoustic maple
polar acorn
#

Into the inspector on your object

acoustic maple
polar acorn
#

I said drag it in to the inspector

#

The public field

#

You have to tell it which Points_Manager you want the variable Score_Manager to hold

acoustic maple
polar acorn
#

On the object that has the variable

#

Drag in the object that has the script you want to reference

acoustic maple
#

like this?

polar acorn
acoustic maple
#

yes

polar acorn
#

You have to drag this into the object you want to reference it

acoustic maple
#

oh

#

it should look like this?

polar acorn
#

No

#

Literally just look at the inspector for your script

#

it will become obvious what you need to do

acoustic maple
#

it worked

polar acorn
#

!learn you should consider going through the basic courses so you know what words like "inspector" mean to save yourself a lot of time in the future

radiant voidBOT
acoustic maple
naive pawn
#

you don't have the time to learn a basic core concept? that'll just waste more time

polar acorn
maiden totem
#

should i be using IEnumerator coroutines or Awaitable (or Task?) methods

#

any guidelines on when which one should be used?

#

it feels like both are very similar but i find enumerator coroutines to be a bit clunky and unintuitive

rich adder
#

there is no exact way to answer this, there are only pros and cons in each

#

Coroutines just make it easier to work with specific unity apis cause only work on main thread since they are mostly not-thread safe

acoustic maple
rich adder
#

now the Awaitable is a better solution to Tasks for Unity API , cause at least you can temporarily switch it to Main thread if a unity API is needed to be called in the thread

#

there is also UniTask which is a bit more mature than awaitable that some people still swear by it.
But it is third party

maiden totem
#

basically what i wanna do is just have an ability i can call with a single method and that one method to contain all the stuff like starting the cooldown, playing the animations, spawning projectiles, and ending the casts etc

rich adder
#

not sure how that relates to async

maiden totem
#

well im gonna need to wait for some seconds and whatnot, since the casts take time

rich adder
#

async is better for thread blocking operations such as IO and Network / performance boggling big operations

maiden totem
#

so should i use ienumerator coroutines instead?

rich adder
#

You can do timers with all three, but I think Task.Delay doesn't seem solid for unity frame loop

maiden totem
#

there's Awaitable.WaitForSecondsAsync and EndOfFrameAsync

rich adder
#

I'd use Update or just a while loop with a coroutine

#

true though personally I do not like those Wait method because you cannot mess with progress

#

personally I think deltaTime way is better if you're showing progress bars n such for the timing
so Update or Corouotine with a while loop (time.deltaTime)
but you can probably use Awaitable too with while loop but calling Unity api methods is still a pain inside of it

acoustic maple
maiden totem
rich adder
#

yes thats part of the unity api on main thread

naive pawn
#

!learn

rich adder
radiant voidBOT
maiden totem
#

im gonna try awaitable, if something seems very off ill switch to a while loop or whatnot

verbal dome
#

Havent tested tho

rich adder
#

yeah true. I havent used it myself so you may be right 100 here

maiden totem
#

maybe fiddling around with threads isnt the best idea then

rich adder
verbal dome
#

On the main thread I think coroutine vs. Awaitable would be very similiar

rich adder
#

I like the Time.deltaTime approach to sub/adding number timer cause like I said its easier to do progressbars

acoustic maple
verbal dome
maiden totem
#

are ienumerator coroutines background threads as well?

verbal dome
#

No

maiden totem
#

okay then i think im safe to use those for this

rich adder
#

they run in main thread, very cleverly..

#

"fake async"

maiden totem
#

also this is probably a stupid question but i've seen many different opinions and im not sure about it, but is encapsulation worth it? I've been doing stuff like [field: SerializeField] public int variableName { get; private set; } for a while now and is that... too much?

naive pawn
#

definitely not "too much", that's not rare

swift crag
#

it's appropriate for something that anyone should be able to read, but not change

#

I don't like serializing the auto-generated field though

#

(i guess because it makes renaming the property a bit more annoying)

#

obviously, you can use [FormerlySerializedAs] so that existing data doesn't break

#

but now you're stuck with that forever unless you ensure that all uses of the data are updated

#

this would be particularly bad for a package that other people depend on (it's easy to make sure your own data is uploaded, but other people's? oof)

#

using an explicit private field separates the name of the serialized property from the name of the...property

#

(name collision!)

grim goblet
#

Is it necessary to complete the entire pathway course to get started or can I learn on my own project?

#

(How did you guys learn to implement movement and customize it to make it your game

#

@swift crag @naive pawn

solar hill
solar hill
grim goblet
scenic raven
#

hey I'm new to coding I tried using the C# tutorial for the driving (since I'm trying to make a driving game) but I'm using my own blender model and for some reason when I use the script on the blender model it doesn't seem to work but it works on the car I got from the package. but when i go into play mode (with my blender car) it doesn't go forward when I press W and S instead it goes side to side and acts as there is a barrier Infront of it I have searched countless of times for the what the issue could be and I don't get the answer (no the car does not have wheel colliders it has Ridgidbody and a box collider but could someone please help me out on this?

solar hill
#

is it just a model?

#

or is it a prefab

#

if so the car might have some other things set up on it that yours doesnt

scenic raven
#

the car from the package is a prefab. the car i made is also a prefab

scenic raven
solar hill
#

well it almost certainly points to that being the issue

#

take a look at their prefab

#

open the prefab up and check out the object hiearchy

#

see how its set up

#

mimic that with yours

scenic raven
#

okay

#

to be honest i think i tried this but i was kind of stressing so it just flew over my head

#

the only difference is that it has a front angle at the front of the car

#

other from that everything seems to be the same

solar hill
#

so the object hiearchy is indentical?

#

the only difference is the mesh for the car?

#

are you 100% positive?

scenic raven
solar hill
#

thats not really telling us much

scenic raven
solar hill
#

thats why i specifically mentioned the object hiearchy

#

can you screenshot both prefabs opened up

scenic raven
solar hill
#

the hierarchy and the inspector

scenic raven
solar hill
#

no im telling you to open both prefabs up in the prefab view

#

expand the hiearchy fully and screenshot the root objects inspector

#

for both prefabs

scenic raven
#

im sorry but im kind of confused 😭

#

wait ill take a screen shot of what im seeing right now

mint imp
# solar hill if youre planning to build UI for your game you have to start off by researching...

I can handle the GUI part , i know what i want my layout to look like.
My issue is how to handle the shop,
okay sure i have a button for "buying" an item but what does that... mean?
Im not sure where to start.
Id have a prefab for the ui object , referencing a scriptable object?
Then i guess i add that to a list of "owned" objects.

As for UGUI vs UItoolkit i just never called it that so not sure what you meant, ive always used UGUI. Wasnt aware there was a new system.

UI toolkit sounds really cool imma have to look into that

scenic raven
#

this is what im currently seeing

rich adder
solar hill
#

the prefab

scenic raven
scenic raven
solar hill
#

what about your prefab?

scenic raven
#

hold on a second

rich adder
solar hill
#

in the slightest

#

even after i asked you twice if you were sure

scenic raven
#

bro.. i could of sworn i added colliders and stuff

rich adder
#

the collider is the least if the problems if its not moving..

scenic raven
#

i forgot to save thats why it didnt have colliders

#

hold on let me just fix this real quick

#

alr i inported my new go kart

#

ive made it look a bit more identical

#

the wheels fell off

scenic raven
solar hill
#

it doesnt move forward?

#

Did you add the Front_Angle collider from the original prefab to yours?

#

perhaps its related

scenic raven
scenic raven
# rich adder what is the code that moves it

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

public class PlayerController : MonoBehaviour
{
public float speed = 10.0f;
public float turnSpeed = 25.0f;
public float horizontalInput;
public float forwardInput;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    // This is where we get player input 
    horizontalInput = Input.GetAxis("Horizontal");
    forwardInput = Input.GetAxis("Vertical");

    // We move the vehicle forward 
    transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);
    transform.Rotate(Vector3.up, Time.deltaTime * turnSpeed * horizontalInput);
}

}

rich adder
#

this is overriding physics, it shouldnt even be affected by colliders

onyx ridge
#

// This is where we get player input
horizontalInput = Input.GetAxis("Horizontal");
forwardInput = Input.GetAxis("Vertical");
This is cursed

solar hill
#

the only thing cursed about it are the variable names, other than that nothing is wrong with it

onyx ridge
#

I tried code like this before and it messes with collisions

#

Input.GetAxis

rich adder
scenic raven
#

i mean i pressed play and the wheels just fell of lol

solar hill
#

can you clarify litterally anything you say please

rich adder
rich adder
scenic raven
rich adder
#

yeah thats wrong

solar hill
onyx ridge
scenic raven
solar hill
rich adder
#

not directly input related

scenic raven
solar hill
#

can you actually check

#

instead of assuming things

#

youre about 0:2 on that front

scenic raven
#

so the red car i showed you guys?

solar hill
#

whatever prefab came with the package

#

yes

#

the car that works

scenic raven
#

okay i will check

#

fr this time

rich adder
#

if you have rigidbody on wheels and colliders on them too, they will act as seperate objects from the main rigidbody causing to feel as obstacles

scenic raven
#

they do not have rigidbody on the wheels

rich adder
#

but again , Translate should in practice override obstacles anyway

solar hill
#

right so what does that tell you

#

also true UnityChanThink

scenic raven
rich adder
#

we're not getting the full picture here.. its kinda confusing

solar hill
#

doesnt have rigidbodies on the wheels

#

what does that tell you about your car that has rigidbodies on the wheels

scenic raven
#

holy shit im a idiot

solar hill
#

please use logic, reasoning and deduction

scenic raven
proven atlas
solar hill
#

plus as nav said we are still missing some context here

solar hill
#

if you want us to help you, you kinda need to actually try

scenic raven
#

the wheels still fall off

scenic raven
solar hill
#

what does this mean

rich adder
#

unless you have rigidbody with gravity on them, wheel shouldnt just fall off lol

proven atlas
scenic raven
#

wait i forgot to turn them off in prefab

scenic raven
#

i turnt off the rigidbody on everything and it stays in one piece now

onyx ridge
rich adder
scenic raven
#

okay so now the car only goes side to side

#

we are back to square one

#

do you guys want me to send a video on what i mean with the car going side to side?

onyx ridge
#

can't you just remove the rigidbody from the wheels and attach them to the car as a child?

scenic raven
#

dude imma be so real here im new to unity so that sentence as a whole just dont make sense

onyx ridge
#

im new too

scenic raven
#

which is kinda why ive been taking long and being dumb (not because i want to be dumb buy because idk what im doing)

scenic raven
onyx ridge
scenic raven
rich adder
#

understand the workflow and components a bit better

#

if I'm learning the last thing im gonna worry about is assets and how they look

onyx ridge
scenic raven
scenic raven
onyx ridge
#

@scenic raven

scenic raven
#

yooo

onyx ridge
#

you see the player rocket in the hiearachy, it has a "spot light" attached to it

#

so wherever the rocket moves, the light will be attached to it so it's always lit up

scenic raven
#

that is so cool

#

and smart asw

onyx ridge
#

when you make a new thing in the hieararchy you can drag and drop it onto another thing and it becomes the child of the thing you dropped it onto

scenic raven
#

ohhhhhhhhhhh

#

okay okay

proven atlas
onyx ridge
#

and when you adjust it's position you can adjust it relative to where the parent is, so it will remain relative to where the parent is

scenic raven
onyx ridge
#

so if you attach wheels to a go cart you can prefab the wheels then attached 4 of them and called them "FL wheel" "FR wheel" (front left, front right)

#

rename them then adjust their position relative to the parent

#

so if you want to attach something to another thing, the thing you're attaching to is the parent

#

and the thing that you are attaching is the child

#

you're dragging something to the parent, it then becomes the child

scenic raven
#

ooh okay okay

#

it makes a bit of sense

onyx ridge
#

Here is an example

#

Left Laser and Right Laser is a child of Player Ship

scenic raven
#

yes i had something like this in mind but didnt wanna say

rich adder
onyx ridge
#

so when I adjust the position of the lasers, they shoot from the same point of the ship all the time

scenic raven
#

alr i understand it now

onyx ridge
#

it doesn't go to the crosshair yet but you can see the lasers are always on the same point of the ship, it's like you're literally attaching it to the ship

scenic raven
#

yeah i see

#

want me to send a video on my issue

#

because i feel like once i fix this

#

then i can do a lot more stuff

onyx ridge
#

when you adjust their transform make sure these settings are "Pivot" and "Local"

scenic raven
#

yeah ik about the pivot thing

#

and then center

#

not the local tho

rich adder
#

yours was set to Center when u screenshotted it

scenic raven
#

i prefer center

rich adder
#

its not good to use center positioning things especially in code, its misleading

rich adder
#

the pivot could be 20 miles away but show you have it close. then if you do something from transform.position you wonder why its not even doing it from there

scenic raven
#

i didnt know that but thank you

#

i will use pivot from now

rich adder
#

center is only good for mass rotating a bunch of objects so they dont individually rotate

#

and a few other specific reasons, in most cases should always be on pivot so you know where origin is

scenic raven
#

yeah alr then

#

thank you for that

#

now the car dont even move

onyx ridge
#

send a video of it or screenshot

scenic raven
#

hold on

#

wait should i add the script to it in the prefab

#

no

#

i shouldnt

#

thats a dumb question

onyx ridge
#

I want to see what's going on lol

rich adder
#

if the car is meerly visual the script only goes on the main object

scenic raven
rich adder
#

that error is unrelated to anything in the play code

scenic raven
#

i dont think so

rich adder
#

its the editor bugging out / layout

scenic raven
#

i really dont know

rich adder
#

thats why im telling you

scenic raven
#

oh shit

#

i read that wrong

#

sorry

rich adder
#

the script should be on New Prefab 1

scenic raven
#

no the editor is fine

scenic raven
rich adder
#

so whats the issue cause the video doesnt show any

onyx ridge
#

Did you check to see if all your scripts and [SerializeFields] are still attached / have things attached?

#

do you have a [SerializeField] somewhere which you need to attach an object to in the inspector?

scenic raven
#

nope

scenic raven
hollow dome
#

does anybody know how to code a gorilla tag fan game computer?

rich adder
hollow dome
rich adder
#

gtfg is brain rot

onyx ridge
scenic raven
scenic raven
rich adder
#

can you make up your mind

scenic raven
#

sorry man im super tired

onyx ridge
scenic raven
#

the script is only on prefab one and thats it

rich adder
scenic raven
# onyx ridge can you show the movement script

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

public class PlayerController : MonoBehaviour
{
public float speed = 10.0f;
public float turnSpeed = 25.0f;
public float horizontalInput;
public float forwardInput;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    // This is where we get player input 
    horizontalInput = Input.GetAxis("Horizontal");
    forwardInput = Input.GetAxis("Vertical");

    // We move the vehicle forward 
    transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);
    transform.Rotate(Vector3.up, Time.deltaTime * turnSpeed * horizontalInput);
}

}

rich adder
#

ok so when you press buttons WASD, do you use Horizontal / Vertical input go to > 0

#

You marked this as Environment static, of course is not gonna move...

scenic raven
#

im a idot i swear down

solar hill
#

Pekal i think you need to actually start learning some editor basics

scenic raven
#

i lowkey got to go bed man 😭

scenic raven
rich adder
#

if you're tired go to sleep, its never good to learn / do highly mental processing tired

scenic raven
#

i agree bro

#

i think tomorrow i will text here with a better mind set yk

onyx ridge
scenic raven
#

yeah i will

#

but guys

onyx ridge
#

going straight into making a game is kind of like just doing things randomly

scenic raven
#

thank you so much for all the help ik ive been a pain in the a$$ but i really didnt want to be i haven't made this easiest thing and i apologise for that

onyx ridge
#

I like talking about it tbh xD

#

helps me learn too

scenic raven
#

u sure man

scenic raven
onyx ridge
scenic raven
#

anyways im going to go bed now since im half asleep

onyx ridge
#

gn

scenic raven
#

again thank you guys for the help and goodnight

muted sand
#

I have an inventory system & need assistance with it
I have a public abstract void OnEquip and OnUnequip with the same keywords on an Item class
They have different parameters for each of the subclasses (Consumable, etc)
How would I have a script to call those methods and have it know which parameter to pass in without having:
if (class == "foo") {} etc

I tried searching it up and i didn't find anything
I considered having a big table to be passed in every single time but that would pile up on every special "custom" item and waste a ton of memory

rich adder
#

or maybe try doing this with interfaces

muted sand
#

i don't want my project to be a triple A computer part requirement slop game

rich adder
#

depends how much in it...a few references maybe? probably would be what like 50 bytes per instance?

#

at least in the context of an inventory it doesnt sounds like you will hit extreme case

#

even at 1000 contexts per frame thats what? 50 kbs ?

#

if allocations are a worry at worst you can pool it / reuse the same obj

#

keeps it simple enough imo.. if behaviors are truly unrelated, interfaces are the option too

#

I'd only worry if profiling shows heavy GC pressure

muted sand
verbal dome
#

ref = read/write, in = read-only

muted sand
verbal dome
#

So all possible things (references, values) that might be needed to pass into the method, like nav said

muted sand
#

Okay thanks so much

naive pawn
acoustic sequoia
#

hey everyone, I'm having an issue with data being loaded.. everything seems to work except for one file and it's the statistics script.
when i start up the game all the data is reading with "0":

savefile before loading is:

 "StatisticData": {
    "ActiveTiles": 0,
    "InactiveTiles": 81,
    "TickCount": 75,
    "AllEnergy": 215,
    "AllCurrency": 0,
    "AllPlates": 0
  },```
savefile after loading is:

"StatisticData": {
"ActiveTiles": 0,
"InactiveTiles": 81,
"TickCount": 0,
"AllEnergy": 0,
"AllCurrency": 0,
"AllPlates": 0
},```

this is where it's being called:

private void Awake(){
      #region Instance
      if(instance == null) instance = this;
      else{
        Destroy(gameObject);
        return;
      }
      #endregion
      
      #region Save/load test
        _cells = gridManagerObjects.InstantiateCellGrid(startMatrixSize);
        SaveData loadData = SaveManager.LoadGame(SaveManager.saveName); 
        if(loadData == null) {
        }
        else {
          LoadCellData(loadData); <<----- LOADING PREVIOUS SAVE WITH ADITIONAL DATA WORKS GREAT
          
          SaveManager.SaveGame(SaveManager.saveName); <<------ THIS IS FAILING TO SAVE THE NEWLY UPDATED LOADDATA
        }
      #endregion
      
    }```
keen dew
#

You'll have to show the code for LoadCellData and SaveGame

hollow cradle
#

why doesnt this work?

teal viper
#

Because unity projects don't use main as an entry point. It's not a console app.

#

Might want to learn the unity basics in addition to C#.

#

!learn

radiant voidBOT
hollow cradle
#

I alr enabled the script on my game object

keen dew
#

void start() or void Start()?

naive pawn
#

also what nitku said

hollow cradle
naive pawn
#

if you're following a plain c# tutorial, run it in a plain c# environment (eg, not unity)

keen dew
#

Show the script you have now

#

!code no screenshots

radiant voidBOT
naive pawn
#

Console.Log doesn't exist anywhere i can find either, did you follow a js tutorial or something

#

or are you just winging it

#

anyways, configure your ide as well

#

!vscode

radiant voidBOT
stark oracle
#

!ask

radiant voidBOT
# stark oracle !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

real thunder
#

so I made a simple class
(AggressionTarget is an interface btw, is this the issue?)

    [System.Serializable]
    public class AssignedRocket
    {
        public AggressionTarget aggression_target;
        public Vector3 last_known_target_position;
        public GameObject pointer;
    }
    public List<AssignedRocket> rocket_setups;

and I try to do this

public int amount_of_rockets = 8;
void Awake()
    {
        rocket_setups = new(amount_of_rockets);
    }

and it just does not work, list is the same empty thingie in the inspector
despite I can see and populate this list in the inspector in the editor
what's going on?

#

Let me assume, if it was a struct that won't cause issues, but if I just try to make classes out of nowhere it doesn't work like that?

naive pawn
#

(AggressionTarget is an interface btw, is this the issue?)
yes

#

but if I just try to make classes out of nowhere it doesn't work like that?
no

#

the built-in inspector doesn't draw interface fields

#

technically it can serialize references (if you mark it serializereference) but you'll need other ways to set the reference, iirc you could make a custom inspector for example

real thunder
#

the odd issue is

#

as you can see from the screenshot

#

I can populate list from editor

#

but... can't through code?

#

is this so? is it's right, I don't understand why

#

like....
rocket_setups = new(amount_of_rockets);
that does not even do what setting 8 in the field of the list in inspector would do

#

that I can't see it in the inspector is not an issue for me

naive pawn
#

hm? i mightve misread your question

#

i'm confused what you're asking

naive pawn
#

the int parameter is capacity
the number you see in the inspector is length
those are different things

real thunder
#

I suspected that

#

if it was a struct instead of a class I would instantly see it populated in the inspector tho?

naive pawn
#

no

#

if it were a struct, nothing in what i just explained would change

#

length and capacity would still be different things

real thunder
#

so.. is there a shortcut to create a list having some default elements?

naive pawn
#

no

#

create them

real thunder
#

alright

dense basin
naive pawn
#

certainly not a code issue

dense basin
naive pawn
dense basin
naive pawn
#

you didn't even say what the issue was

#

go provide context where you asked originally

#

this is a code channel

polar acorn
hasty tundra
#

is there any doccumentation/method to have loops only go to the next iteration when the user clicks the mouse?

polar acorn
#

Don't use a loop, take the body of that loop and put it in a function, then call that function when you detect a click

naive pawn
#

you could theoretically use a coroutine for that, but it could just make the overall code flow harder to read

hasty tundra
#

tyty 🙏

hollow cradle
#

Why do some peple use should for example shouldContinue variable?

frosty hound
#

It's just a way to keep a consistent naming convention for a bool flag

#

isSomething and canSomething and shouldSomething, they just imply what the variable represents.

shell sorrel
#

if it was just Continue it sounds like a verb and should be a function not a bool

frosty hound
#

You can do whatever you want, as long as you're consistent with your naming conventions so you're not trying to read through randomly named variables trying to remember what they do.

shell sorrel
#

where canContinue clearly shows its some condition blocking something else

polar acorn
scenic raven
#

and it only drives forward when i turn the car

hollow flare
#

Anyone building with Xcode and finding your .app is signed but not notarized bc its not happy with Unity frameworks? seems like its beefing with GameAssembly.dylib and UnityPlayer.dylib

#

my apple dev account is good but im wondering if anyone has ran into a similar issue. seems like the recent PLA might've broken something

solar hill
solar hill
#

that means the cars rotation isnt correct

scenic raven
#

when i press A and D it turns

solar hill
#

check the mesh in the prefab

#

and check its transform rotate

scenic raven
#

also kuzmo i read back last night and i was being a pain in the ass which im sorry for i was super tired

solar hill
#

i told you you dont have to apologize to me

scenic raven
scenic raven
solar hill
#

see if that makes it behave correcty

#

also check the original prefab

#

compare how the 2 cars are oriented

#

see if it really is the orientation

scenic raven
scenic raven
scenic raven
scenic raven
solar hill
#

yes

scenic raven
#

its 0, 0, 0,

solar hill
#

how is it oriented compared to your car

scenic raven
#

if thats what u mean

solar hill
#

forward is entirely arbitrary

#

relative to your prefab

#

are they facing the same direction?

scenic raven
#

let me check

solar hill
#

just add it to the scene next to yours...

scenic raven
#

okay okay

#

so add them next to each other?

#

and they are both facing forwards

solar hill
#

the same direction?

scenic raven
#

wait no

#

when i put the go kart prefab in it faces left

solar hill
#

the original prefab is facing the correct way

#

yours isnt

scenic raven
#

yes pretty much

solar hill
#

offset the rotation of the mesh on your prefab

#

by rotating it -90 on the y axis

#

or +90

scenic raven
#

when i do it 90+ it faces right

solar hill
#

i feel as if ive given you all the steps here to fix your issue, and you can extrapolate from here.

scenic raven
#

yea maybe

#

but im WAY to dumb to fix this

real thunder
#

become smarter 🥹

scenic raven
#

that is the current plan

#

i cant rely on people to help me fix it tho ibr

swift crag
#

when you select an object, the handles will show you its X/Y/Z axes (as long as you've got your scene view set to Local, not Global

#

the blue arrow is its forward vector

#

the model, which is parented to the prefab, must be rotated to align with that arrow

real thunder
#

I might be getting it wrong, but hear me out

so I am instantiating a MonoBehaviour which is inheriting from an interface
then I instantiate an interface variable
then I assign that MonoBehaviour there
then I Destroy MonoBehaviour's GameObject
then interface variable is... not null, somehow?
I am confused

naive pawn
slender nymph
#

you're not using the overridden == operator at that point, you're using the default == from System.Object. cast to UnityEngine.Object if you want to check for unity's fake null

real thunder
#

I am using ==

naive pawn
#

but what are you using it on?

real thunder
#

interface, yeah

slender nymph
#

right, but as i explained because you are using an interface type you are just using System.Object's == operator, not the one from UnityEngine.Object

naive pawn
#

if it's on a variable that isn't UnityEngine.Object then it isn't using UnityEngine.Object's definition of ==

real thunder
#

this looks like poor design on Unity's side isn't it?

#

anyway how do I solve that

naive pawn
#

i mean... kinda

real thunder
#

alr that works but it's extremely confusing

alpine birch
#

can Console.Writeline only show the text or can it be used for other stuff?

slender nymph
#

you wouldn't be using Console.WriteLine in unity since that doesn't print to the unity console

alpine birch
#

alr ty

patent kelp
#

hi, i have a problem with deciding what order in layer an object should have. I have like 2.5D style walls, right now i tried to set the order in layer based on the center point/lowest point in the GO - the idea was the lower the point the higher the order, but it doesnt work and i have no ideas as to how to render it right

grand snow
patent kelp
grand snow
#

sorting order?

patent kelp
#

sorry the order in layer

grand snow
#

that should work too, lower Y should be bigger though to draw in front

patent kelp
#

yea but if the wall is really wide then it creates something like on the right in the picture i sent

verbal dome
#

That kinda breaks with diagonal objects as can be seen in the screenshot

#

The rightmost object's Y is a bit below the one next to it

patent kelp
#

exactly

verbal dome
#

I think often people split objects into a couple of sprites in these cases?

grand snow
#

May be best. Its not really something you can solve well without 3 dimensions

verbal dome
#

This kinda split would probably work well enough

#

(The split sides would have different pivots ofc)

patent kelp
#

so then it would be 2 GO and each would have its order based on the Y cord like it is now?

verbal dome
#

Yeah

patent kelp
#

or like 2 sprite renderers

verbal dome
#

I can't think of a better way atm, but you can research online

patent kelp
#

im really not experienced with this

#

thanks tho

verbal dome
#

Can't stack them

patent kelp
#

ohh

#

alr

verbal dome
#

1 sprite on the parent, another on the child, should do it

patent kelp
#

ok thanks

real thunder
#

ofttop but I ve been here asking questions related to steps how to make this for quite a long time now and making homing rockets finally concluded

real thunder
#

thanks people who help other people here

#

would take way way longer without you

night cedar
#

Hey guys I want to make a cardboard cutout of a sprite for vr anyone have a tutorial or can help?

slim meteor
#

hi can anyone help am new

swift crag
sullen arrow
#

Hey guys, I ran into a problem with UI elements. I made a timer and score meter, but every time I close unity, they move? Is there a way to glue them in place?

broken nest
#

Hey, it's been a long timesince i used scriptable objects, how do I reference them? I was thinking making a script which acts as a database for all the scriptable objects I create

grand snow
#

Serialised ref or resources or addressables

broken nest
grand snow
broken nest
#

Yeah ok that's what I meant to do

#
{
    public List<ScriptableObjectEnemy> scriptableEnemyList = new List<ScriptableObjectEnemy>();
    public List<ScriptableObjectSpell> scriptableSpellList = new List<ScriptableObjectSpell>();
}```
grand snow
#

Using resources would let you load many assets in code like this a bit easier but a top level object to ref them all isnt bad

broken nest
#

ok ty I'll stick to the basics

open crater
#

Guys im trying to build a game in which you survive in different castle rooms. Your goal is to survive 1 minute in each room but every 20 second something makes the environment harder to fight such as turrets or falling parts, and the player (a cube that can be controlled by imput) must avoid these. Now about the hturrets, if I want the bullets to reduce the player health (10, -1 for each bullet) on collision (and the reduction of health bar that is a default 2d square sprite, where should I put the script that manage the health and the bar size? Should i create a gameobject and insert the script here (as a logic script) or in a specific place such as in the bullet prefab? Considering that the bullet is a prefab cloned by the turret

grand snow
#

your player can tell the UI to refresh

broken nest
#

I'm instantiating a prefab like this :

Animator playerMonAnim;
    playerMonAnim = Instantiate(scriptableObjectPlayerMon.monsterAnimVerso);

How do i make sure I destroy the previous prefab before instantiating another one?

onyx ridge
#

Can't you just make some basic 3D objects, uncheck their mesh and tick the 'on trigger' collider

#

then write the code in there what happens when the player colldies with the box colldier, triggers an event

grand snow
#

if(thingy != null) Destroy(thingy.gameObject);

keen veldt
#

I want to make a skill tree system but making a scriptableObject class and an instance for each upgrade feels like blowing the project window.

#

Is it ok or there exists a smarter approach?

#

Feel free to ping me.

teal viper
#

It's fine if you do it smart. It's normal to have classes and instances of them. Think of custom MonoBehaviour scripts.

ivory bobcat
keen veldt
#

Yup! they are gonna be accesible from the inspector. And what you mean by unity objects here?

ivory bobcat
#

You could just simply use plain c# objects..

keen veldt
#

OK, thanks bro. will be back if ther ewas a bproblem

tight schooner
#

hey guys i’m sorry i don’t know where to ask this, but I made a custom shader for a wiggle effect, not too complex. issue is that when I use it on an image, it ignores masks. I’ve been looking on google but everything’s a bit confusing. does anybody know a clear/easy fix?

slender nymph
#

#1390346776804069396 for shader issues, you'll also want to provide details about the shader in your post

gaunt cipher
#

I want to preserve the values of a TextMeshProUGUI for later use.. I'm doing stuff in code where I save off some values like fontSize into variables but I'm just thinking.. surely it would be far easier if I could just save the entire TextMeshProUGUI component off.. as far as I'm aware, the TextMeshProUGUI class is a reference, does anyone have any ideas? something like Clone() or EditorUtility.CopySerialized? Like what does Unity do when you copy a component / paste as new? I feel like surely I'm missing something easy instead of doing font = tmp.font; fontSize = tmp.fontSize; color = tmp.color etc... for every field

cosmic dagger
gaunt cipher
glass summit
#

What's the difference between both of these functions

{
    if (Input.GetButtonDown("Jump"))
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
    }
}```


```private void Update()
{
  if (Keyboard.current.spaceKey.wasPressedThisFrame)
  {
    rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
  }
}```
ivory bobcat
#

First is the old input system. Second is the new input system. Both are polling in Update for input.

glass summit
#

and they both were telling me to write it differently

#

I think one is outdated

cosmic dagger
dense burrow
#

So im tryna use visual coding and i CANNOT get a player controller to do anything besides look around, please help me im going insane

#

Also im using visual coding because i refuse to learn c#

sour fulcrum
dense burrow
#

Thank you i did not see that oml

ionic zealot
keen dew
#

The position of a RectTransform (reticle.position) is not the same as screen position. Converting it to screen position isn't that simple. In general you shouldn't have UI elements interacting with world objects in this way. It would be better and easier to just make it a normal object

#

If the element is anchored top left and it's not scaled, then anchoredPosition probably matches the screen position

sage mirage
#

Hey, guys! A class that derives from scriptable object class is by default a static class?

#

Because I dont have to create a field of this class in order to get a referencec and I was wondering

#

What I am doing is just do PlayerData.PlayerID.P1 in my case

#

instead of

#

yes then how I am able to get a reference through a class without even creating any fields of the class

#

I haven't created a static class myself so not sure

ivory bobcat
#

I'm assuming you're referring to an "instance" rather than "field".

sage mirage
undone rampart
sage mirage
#

yes I cant understand

undone rampart
#

You are getting a type inside another type

#

not a member of that class

sage mirage
#

I dont have to create a field in order to get a reference to player id I am doing it with the instance of a class

undone rampart
#

because the player ID is an enum not a member

#

it's just nested type

sage mirage
#

So enum is not a member thats why right

undone rampart
#

yes

#

this goes for structs and classes as well

sage mirage
ivory bobcat
#

The type isn't. You can have a enum member.

undone rampart
# sage mirage what exactly?

you can declare any type inside another type, that's just nested types and they can be accessed trough the type directly

#

So yeah is similar to static members since static members belong to the type not the instance

ebon sapphire
#

Im restarting my journey on learning how to code in Unity, and ive got a working player movement script, but i can't figure out how to make it to where the player's jump doesn't get stopped when they move... im not wording it right, but here's a screenshot of the relevant code.

ivory bobcat
vague comet
#

ard there any resources about the relative computational costs of putting things in Update? Or maybe some common "don't do this" type stuff for update()?

ivory bobcat
ebon sapphire
#

what would i put instead?

undone rampart
cosmic dagger
ivory bobcat
#

Cache the previous y component and assign that to it or modify only the x and z component of the velocity vector.

sage mirage
#

I want to understand

cosmic dagger
# ebon sapphire what would i put instead?

you're assigning the y component of the velocity to 0. that overrides the force you apply in your jump. instead, assign the current value of y from the velocity . . .

ivory bobcat
ebon sapphire
#

ok, so something like this?

sage mirage
#

I think those are good examples of that we were talking about or not?

undone rampart
# sage mirage I want to understand

when you declare a field, function or property without static or const, by default it will belong to the instance of that type, meaning you need to create a new instance or get a reference to an instance of that type to access those members

sage mirage
undone rampart
sage mirage
#

ok

#

The problem was that I got a reference before

#

I have created a PlayerData playerData;

ivory bobcat
sage mirage
#

inside my player data class I had an enum

undone rampart
#

don't confuse reference types with getting a reference

ivory bobcat
slow roost
#

Hi everyone! I faced a problem with behavior tree. I'm trying to make simple enemy AI, which see target, than move to it, that attack, but if target not in a enemy view, than return to patrolling.

I created 1 condition and patrol behavior action. And it work on way, that in start of tree enemy patrol, than when enemy see target abort is called and enemy start moving to target, but when player disappear from the target, enemy continue to chase enemy and never return to patroling state. Could anybody tell me it's expected behavior with my tree, and if it is, than how I can handle this?

pure meteor
#

mabye the enemy rotates towards the player and moves at a pace where the player is always visiblee?

slow roost
pure meteor
#

Oh, i wonder if the self must touch the target for it to be marked as complete?

dense burrow
#

am i allowed to put visual coding stuff here cause i can not figure out why my code isnt working and no one is responding to me post in #1390346878394040320 T~T

pure meteor
#

nah just wait until someone does ig

dense burrow
#

danm ight

#

does normal scripting have an issue with player controllers where it moves diagonally backwards?

#

cause thats the issue im having and i have zero idea why

pure meteor
#

no

pure meteor
#

many ppl cant even see visual coding tab thats why ig

dense burrow
#

ooooh

#

i see

cosmic dagger
#

!code

radiant voidBOT
slow roost
cosmic dagger
#

it's not my way, just the general way everyone shares code. most people cannot see embedded code in their discord, and no one will download random files to their computer . . .

pure meteor
#

yo i dont see a max chaseedistance var but mabyee it would work like this:
if (distance > context.MaxChaseDistance)
{
context.State = EnemyState.Idle;
return Status.Failure; // This lets the tree switch back to Patrol
}

slow roost
#

Maybe I can't using running actions with abort operations, I don't know..

#

but self or both abort types must check condition while child node is running if believe docs....

midnight tree
#

!collab

radiant voidBOT
# midnight tree !collab

:loudspeaker: Collaborating and Job Posting

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

naive pawn
#

<@&502884371011731486> seems like a scam to me?

frosty hound
#

?ban 548715125339586561 Scam bot

eternal falconBOT
#

dynoSuccess pcsotfsmedvescak8074 was banned.

frosty hound
#

It is

slow roost
#

Does unity behaviour tree usable at all? I see abort node didn't works as I expected at all

slow roost
#

Why behavior tree always running abort operation and never fail it? it restart tree and try this node again and again and again.

ionic zealot
keen dew
#

Well you can google for how to get the actual screen position of recttransforms (and specifically its center point) and try to get it working that way

grand snow
ionic zealot
#

Thank you!

real thunder
#

or what did you mean saying "in this way"

keen dew
#

I mean comparing the positions of gameobjects and screen space UI elements is awkward at best

#

Usually you wouldn't use UI elements at all or use world space UI elements for that. A reticle might be a special case but usually you'd just check the mouse position directly

real thunder
#

I don't believe in most games UI markers on things are somehow unique

#

I ve severly upgraded someone's github solution to be able to attach UI objects to transforms and clamp it to edges and I don't understand why it's not supported by default

#

everything on one canvas I mean

#

world space UI would create canvases, right?

#

that's like considerably bad for performance

keen dew
real thunder
#

well... yeah it's kinda pointless since one axis is missing

keen dew
#

Screen position always has two axes

naive pawn
#

screen coords technically do have a meaningful third axis, idk if it'd make sense to apply that claim to screen pos though 😓

real thunder
#

right

ebon sapphire
#

for some reason this doesn't work for me and i don't understand why

polar acorn
#

And why are you multiplying a fixed value by deltaTime

ebon sapphire
polar acorn
ebon sapphire
#

This is what i have now, but it still doesn't work. I know that the Look() method is still being called on properly thanks to using Debug.Log(), but i don't have any camera movement.

rich adder
ebon sapphire
#

wait no i didn't i forgot to do that

slender nymph
#

+=

ebon sapphire
#

i just checked

naive pawn
#

!code btw

radiant voidBOT
ebon sapphire
naive pawn
#

in the inspector

ebon sapphire
#

100

naive pawn
#

it's lookX and lookY that are currently logging 0 no matter what you input, right?

#

if that's the case, how is that input action set up?

ebon sapphire
#

okay im an idiot, i forgot to add the mouse controls after trying to troubleshoot it earlier

#

but now its doing the teleporting thing again

naive pawn
#

which teleporting thing

slender nymph
#

also reduce the sensitivity, 100 is way too high

ebon sapphire
#

yeah, i did after i got it to work, its currently set to 16 in the inspector

naive pawn
slender nymph
#

should be close to 1

#

lookX = look.y

naive pawn
#

oh this is still camera stuff 💀

#

i was thinking "teleporting" meant position lmao

slender nymph
#

yeah they probably worded it weirdly, but assigning to the input*100 rather than adding the input to the current rotation would make it seem like the camera is snapping to randomish positions, which is probably why they described it as teleporting

naive pawn
#

that makes sense

ebon sapphire
#

New problem: no matter which way the camera faces, my player doesn't move in that direction.

slender nymph
#

how are you rotating the player

ebon sapphire
#
 private void Rotate()
    {
        Player.transform.rotation = Quaternion.Euler(CameraHolder.transform.rotation.x, 0, 0);
    }```
slender nymph
#

so, you know rotating around the X axis is pitch, not yaw, right?

red ivy
#

Hello. I've set my scrollbar value of steps in unity default packages

#

how do I import it to my current project

wintry quarry
red ivy
#

Which is 11 by default

wintry quarry
#

export the prefab

#

import in the new project

broken nest
#

Is there a way to get the index of an enum?

wintry quarry
broken nest
#

That's simpler than I thought thanks

wintry quarry
#

or whatever your base numeric type is for the enum (int is the default)

wintry quarry
broken nest
#

Alright ^^

grand snow
spring badge
#

As a beginner, would it be easier for me to use visual scripting, or should I just dive into coding?

wintry quarry
mint imp
#

First time using a switch in a method with a return thats not void, what am i missing here?

rocky wyvern
#

default: return null;

#

wondering why you are not using an array for the abilities though

#

would avoid this kind of verbose switch statement where you have to hard code every case

mint imp
#

Thank you
+
Yeah great point.
I figured it wasnt need its just the 3 "slots" that i can drag and drop scriptable object abilities in to
so just checking what slot is what ability

rocky wyvern
#

yeah but what if u want to make 7 in the future then you have to go back and change a shitton

#

besides, if anything it's simpler and easier to code so there really isnt much benefit that I can see

mint imp
#

Ohhh like if i add more slots you mean
Youre totally right ill just do that

wicked stratus
#

Realizing that onMouseOver() is not going to work for my circumstances (if there is a collider in front of the collider I'm calling the method on, it just doesn't go through) so I'm wondering about alternatives or ways around this, without turning off layer interactions and such? It's quite annoying, it'd be nice if it like, returned a list of the colliders it's over or something rather than not logging it at all

rich adder
wicked stratus
sour fulcrum
#

cheap

wicked stratus
#

ah ok

#

I will try that, thank you

rich adder
keen dew
#

OnMouseOver is just a raycast you have no control over

wicked stratus