#💻┃code-beginner

1 messages · Page 353 of 1

dull saffron
#

ill check it out thanks

eternal falconBOT
rocky canyon
#

oh wait nvm

#

clearly i can't see colored squiggly lines

#

ur formatting threw me for a loop

hollow cosmos
#

hi i need help adding like

#

a basic timer + score counter to a simple platformer

#

im a full noob at unity so bear that in mind

rocky canyon
#

what sort of timer score counter..
give more details..whats ur goal?

hollow cosmos
#

the counter should probably just be time + some collectable

#

when i mean the game can be basic i mean its extremely basic

rocky canyon
#

soo a timer that counts down continously.. and then a collectable that adds a bit of time to it?

hollow cosmos
#

pretty much

#

this is current progress

#

its just a small school project but deadline is pretty soon

rocky canyon
#

you'd need a private float to countdown from, in update you could subtract from it:
timeRemaining -= Time.deltaTime;
then all you'd need is a conditional to end the game

   if (timeRemaining <= 0)
   {
       EndGame(); // call your end game function
       timeRemaining = 0f; // set the timer to 0 in case it overshot it or something
   }
#

and ofc, a function to add ur time back to it..

public void AddTime(int seconds)
{
    timeRemaining += seconds;
}```
then you can call the function and pass in how many ever seconds u want the logic to use: `AddTime(3f);` or `AddTime(yourVariable);`
hollow cosmos
#

also sorry for the bother i just cant miss the deadline

rocky canyon
#

probably.. you'd preferably want it to be a singleton or something so it could be accessed from anywhere.

hollow cosmos
#

whats singleton?

rocky canyon
#

but, it could be on the thing collecting the pickups

hollow cosmos
#

so i would need help with that too if possiable

#

if you could link me to a video i dont want to waste ur time

rocky canyon
#

and u could just use the collision to get the script from the player.. playerTransform.GetComponentInChildren<NameOfScript>();

#

for a pickup system?

#

like a trigger collision type dealio?

short hazel
#

I'd just have the script on the player so it detects the pickups, it's faster and only requires one (already existing?) script

rocky canyon
#

you could find a decent one on the internet just by search those 2 terms

rocky canyon
#

except where he uses tag == you should instead use CompareTag("TagOfObject");

#

if ur only doing 1 type of pickup you could jsut have the detector on the player that when it detects a trigger collider it destroys the collider and just adds points to itself.. that could be done in the same script actually

#
    {
        AddTime();
        Destroy(other.gameObject);
    }```
hollow cosmos
#

or am i doing this completly wrong

rich adder
hollow cosmos
#

how and where would i put that script then

rich adder
#

inside a script ideally

#

which one, thats up to you to figure out

#

if you're doing 2D you need the 2D version

hollow cosmos
#

yea the game is 2d

#

i sent a small clip of the gameplay above 1s

hollow cosmos
#

renderer and transform too i guess

rich adder
#

I kinda just got here, can you give me a TLDR what ur trying to do ?

hollow cosmos
#

just add a collectable + timer + score

rocky canyon
#

it goes in the class, alongside update start etc, same syntax as those

hollow cosmos
rich adder
#

you're gonna have to learn the lingo at some point 😛

swift crag
#

it's a method

hollow cosmos
#

not if i dont stay in this path 🔥

swift crag
#

a function that you declare inside of a class or struct

rich adder
#

class is basically a blueprint to what your object will do

#

functions etc are what it can do

rocky canyon
#
public class YourScript : Monob..
{

Update(){}

CustomFunctions(){}

OnTriggerEnter(){}

}```
rich adder
#

as you can see OnTriggerEnter is part of many others

#

well unity calls them Messages
cause they're similar to how event works basically hence the naming convention

rocky canyon
#

update runs every frame, thats where the timer would go..
but OnTrigger.. gets called by Unity just like Update.. and Start.. etc.. so the brackets line up inside the Class { } wrapper

hollow cosmos
#

i have no clue about what any of u are saying

#

the closest idea of what i get to do is like

rocky canyon
#

😅

hollow cosmos
#

copy my death script and put it in the same place?

swift crag
#

do you want to learn or are you just going to say "I know nothing" over and over

#

the latter is a great way to continue to know nothing

hollow cosmos
#

if it wasnt deadline restricted i would be down to learn

swift crag
#

then i'm not awfully keen in helping if you're just hoping I write the code for you

rocky canyon
#

they said it was a school proj, and its almost deadline.. you know, the normal MO

swift crag
#

the point of the project is to prove your understanding

rich adder
#

yeah we're not going to help do homework for you

hollow cosmos
#

wish it was just homework atp

rich adder
#

help you fix issues and understand them if you want to learn

rocky canyon
#

ahh i missed

rich adder
#

2D btw **

hollow cosmos
#

ok better question which is probably easier for u guys to answer

#

could i just basically edit this to a destory and remove the transform

swift crag
rocky canyon
#

yae,

rich adder
#

pretty much

hollow cosmos
#

the coin in this case

rich adder
#

yes

rocky canyon
#

other.gam.. = ("ACoin") // a tag <--
Destroy(other.gameObject); <-- the other (which is a coin)

rich adder
#

the answer is always defaulted to yes, you can

rich adder
hollow cosmos
prime cobalt
#

Hey so both the list of player pawns and the multigrid controller are serialize fields so I know that the newPlayer and multigrid aren't null but for some reason the final line of this throws me a null reference exception, what could it not be seeing?

hollow cosmos
#

do i just call it the coin?

rich adder
rocky canyon
#

u can name it w/e as long as u reference it correctly

prime cobalt
rocky canyon
#

the thing above it is null..

rich adder
#

maybe you have a copy of the script with it unassigned?

rocky canyon
#

is that supposed to be?

rich adder
#

can you show the complete error stack btw

prime cobalt
rich adder
#

also freaky we got the same playmode color tint lol

prime cobalt
#

Purple is nice lol

rich adder
#

more than likely you are spawning a copy with it unassigned and the function is running

#

but yeah I'd check how many you got in playmode

hollow cosmos
#

well dont think its a shock to you guys but its not working i guess

#

character is just moving straight through it

rich adder
#

guess what OnTriggerEnter is for 3D

hollow cosmos
#

oh

prime cobalt
rich adder
hollow cosmos
#

whats the 2d varient?

rich adder
#

have you read anything sent to you for the past 15mins?

hollow cosmos
#

more like i understand none of it

rich adder
#

what? you had it correctly before

#

why did you change it

hollow cosmos
#

huh

rich adder
hollow cosmos
#

oh i gotta copy that one

#

my bad

rich adder
#

not exact

#

since Trigger and Collisions are different, but 2D variant

solid pendant
#

quick question, whats that suggestion box that pops up when you start typing in code? It has stopped appearing for me so I have to guess or look up the correct code each time

eternal falconBOT
solid pendant
#

ty friend!

hollow cosmos
#

right

rich adder
#

so you dont want trigger anymore ?

hollow cosmos
#

i thought that was what u were telling me to do

rich adder
#

no I was telling you that there is 2D versions of everything physics related

#

since unity uses two seperate engines for each

#

Box2D vs PhysX (3d)

#

if you're doing 2D stick to the 2D methods

hollow cosmos
#

alright ill check it

solid pendant
#

Yep I think i fixed it ❤️

main anchor
#

i managed to fix it (sort of), but i still sink a very small bit and have to press space multiple times when trying to jump

untold patrol
#

recently switched to a new pc on windows 11 and now when coding in c# doesnt show me syntax errors or auto fill stuff and most code just remains white even tho it used to be blue and stuff to represetned it was an actual thing, assuming theres a setting or update i need to get it to show that stuff but im not sure any help would be appriciated

#

same code before and after

eternal falconBOT
shadow briar
#

Howdy all, so just trying to learn how to use Unity and how to use scripts with classes.
Big forewarning i am fairly new and i think i have made a beginner mistake in using multiple scripts but not too sure, trying to inherit classes and what not.

TLDR in this just trying to make a weapon system with some modularity.

So i made a Wep Data script that holds the weapon data, than a AmmoData script that holds data for ammo and finally a script to just see if in a Example script to just see if it works.
No errors in the data scripts but in the Example script it says the AmmoData is a type but not valid in this context.
This is all in the constructor, nothing being actively used yet.

Now i tried to put the ammo data in the WepData Script to maybe see it was just an reading error of some kind that didnt work. Tried some ammoType._BaseRifleAmmo and that comes with a seperate error.
So hitting the wall just a bit unsure how to approach it.

The pictures in order should be: Wep data, Ammo Data, Example.
Not sure if i used the PasteOfCode right: https://paste.ofcode.org/PDzvsS3vXe7YPuMySN3The

wintry quarry
languid spire
short hazel
#

You cannot have constructors on classes that derive from MonoBehaviour!

shadow briar
wintry quarry
#

You left out the line number

#

full message

#

Compile errors have filenames, line numbers, and column numbers

hollow cosmos
wintry quarry
#

to show you exactly where the error is

hollow cosmos
#

started trying this

#

oh right

#

the coin isnt deleting tiself

#

thats the issue ^

languid spire
hollow cosmos
#

what should i do to find out?

#

rather i just need that to be true and run the delete script

wintry quarry
languid spire
wintry quarry
#

Also, still waiting for those full error messages

hollow cosmos
#

im a full noob sorry

shadow briar
# wintry quarry > No errors in the data scripts but in the Example script it says the AmmoData i...

Right okay, apologies.
So its just in the editor, using Visual Code.
I havent looked in unity since nothing so far is using it, as it says theres an error in editor.

Line 11 on the example
which on Pastebin (The link to that site) is: 90

With the error being

'_ApRifleAmmo' is a type, which is not valid in the given contextCS0119

giving a check in editor it does mention about namespaces but i would prefer to focus on the current error.
But right Monobehaviour can be removed from the example script

languid spire
wintry quarry
wintry quarry
#

Really the short story here is that you are using inheritance incorrectly here

#

this is not what inheritance is for

#

What you actually want is just an AmmoType class and a bunch of instances of that class with different values for its fields

languid spire
hollow cosmos
#

this

wintry quarry
#

e.g.

AmmoType subsonicAmmo = new AmmoType("Subsonic", "Slower than sound ammo", 1, 5, 50);

WeaponStat = new WepData("new weapon", "I am a weapon", 0.2f, WepData.FireMode.SemiAuto, WepData.WeaponType.Pistol, subsonicAmmo);

@shadow briar

languid spire
hollow cosmos
polar acorn
hollow cosmos
#

unless im doing it wrong

wintry quarry
#

Also - again, none of these classes should be MonoBehaviour except the "Example" class.

polar acorn
# hollow cosmos

Okay, so this object has collided with something named Player, not Coin, so it won't be destroying it

hollow cosmos
#

right i need it to be inversed

#

would the script go to the player instead of the object then?

polar acorn
hollow cosmos
#

coin currently

polar acorn
#

So, Coin probably isn't colliding with Coin

hollow cosmos
#

i have very little understanding of what the code is actually doing

polar acorn
#

So, you can check what object collided with this object, by checking that Collision object

#

In this case, the script is on Coin, and it's populating the data about the thing that collided with it in your Collision2D coin variable

hollow cosmos
shadow briar
polar acorn
hollow cosmos
wintry quarry
#

This is actually a great use case for ScriptableObjects

#

ScriptableObjects would let you create different AmmoTypes (and weapon types!) as actual assets in the editor that you can drag and drop, modify in the editor via the inspector, and reference from scripts etc.
It's not a great use case for polymorphism/inheritance though.

polar acorn
hollow cosmos
polar acorn
shadow briar
hasty sleet
# hollow cosmos copy paste 🧌

100% what digiholic said, you need to know the fundamentals of C# and software development before working on code. If you copy-paste, the code will reach a point where you cannot make any changes due to lack of understanding it

hollow cosmos
#

its not me trying to actually learn it right now

hasty sleet
#

That's a tough situation to be in. What's your timeline?

teal viper
hollow cosmos
hollow cosmos
#

i dont mind learning it later but deadline takes priority now

finite hornet
#

I am learning C# will it be everything I need for a VR/ online game?

deft grail
finite hornet
hasty sleet
# hollow cosmos less than 9h

I think you might be falling into a trap of "i'll just complete the project now and learn everything later" but the entire point of the project is to learn

#

If you don't know how to code, you're pretty much asking us to do your project for you

deft grail
hollow cosmos
finite hornet
hasty sleet
hollow cosmos
finite hornet
hasty sleet
#

CS 101, GME 203?

hollow cosmos
#

its a uk course

#

just btec cs

#

180 credit

teal viper
#

Well, you won't find anyone willing to dig through that code for you for free. If you really intend on cheating your way through, maybe hire someone on Upwork or a similar platform

acoustic arch
hollow cosmos
#

this is litearlly all i need help with atm

#

if i can get this working i can do the rest 95%

teal viper
hollow cosmos
#

rn its tryna destroy the player

#

ofc i want it to destroy the coin instead

#

but i literally have 0 clue on how to even after trying to learn on links sent

teal viper
#

Well, you're checking if the object has a "Coin" name. So it shouldn't destroy your player(unless it is named "Coin".

hollow cosmos
#

the coin just remains floating in place

teal viper
#

Well, where is that code then?

#

I'd assume that you're trying to destroy a coin when the player collides with it?

hollow cosmos
#

yep

#

exactly that

hollow cosmos
teal viper
#

I mean, what is that script attached to

hollow cosmos
#

huh

teal viper
hollow cosmos
#

what im trying to do is if anything comes in contact with the coin

#

then delete the coin

teal viper
#

Okay, then how do you reference a gameObject that the script is attached to?

hollow cosmos
#

no clue

teal viper
hollow cosmos
hollow cosmos
teal viper
teal viper
hollow cosmos
#

however new error bit specific to it

#

video in question ^

#

the errors im getting

cosmic dagger
#

that's a warning, not an error . . .

hollow cosmos
hollow cosmos
cosmic dagger
# hollow cosmos

find the script mentioned, go to line and look for a reference variable. if more than one, log and check each one to which is null . . .

wintry quarry
#

so the obviousl conclusion is, coinText is null

nocturne oak
#

why cant my script, score, access the public boolean lostGame, defined in my other script, playerCollision?

cosmic dagger
#

your score has no idea you're trying to access lostGame from playerCollision. you're accessing it like a class variable from score . . .

wintry quarry
#

Note that every instance of playerCollision is going to have its own copy of the lostGame variable

#

so you need to tell it which instance by referencing it

nocturne oak
#

oh ok

#

that is really strange

wintry quarry
#

It's not strange when you understand the concepts

nocturne oak
#

I assumed that a public variable was the exact same for every script

wintry quarry
#

You assumed incorrectly

nocturne oak
#

like how variables work in TI-BASIC

cosmic dagger
wintry quarry
#

this is C#

nocturne oak
#

I know, I am saying this way of doing this is strange, not that it is wrong

#

you misinterpret my statement

wintry quarry
#

You can make a variable that behaves that way in C# if you want, but it's usually not a good idea as a beginner

#

Basically BASIC is not an object-oriented language

nocturne oak
#

how do I make a reference?

wintry quarry
#

references to objects are a concept in object oriented programming

cosmic dagger
wintry quarry
nocturne oak
#

will do

#

literally not a single word of this makes any sense

#

I will go look for something on youtube

cosmic dagger
#

study time!

nocturne oak
#

thanks anyways

acoustic arch
#

for my crop growing game should the crops grow while the player is offline or only online with short times?

#

how could i program in unity to calculate offline time, do i have to subtract off the date and time since last online?

teal viper
misty coral
#

How to check if sphereCast is hitting anything but a specific object tag?

wintry quarry
#

With an if statement.

#

not really sure what "hitting anything but a specific object tag" actually means though

#

Physics Raycasts can only hit one thing and that is Colliders.

misty coral
#

Well Spherecast returns a boolean, Im asking how to make the boolean only true when the thing it collides with is a collider with a certain tag

wintry quarry
#
bool hitSpecialThing = false;

if (Physics.SphereCast(... out RaycastHit hit) {
  if (hit.collider.CompareTag("CertainTag")) {
    hitSpecialThing = true;

    // Or just do whatever you need to do here and omit the bool variable
  }
}```
#

Just... you know.. check for it

acoustic arch
wintry quarry
#

You'll want to also look into layermasks

rustic dagger
#

Does anyone know how to change a string from an input field into a float for a static variable?

wintry quarry
#

float.Parse or float.TryParse

#

Look them up in the C# docs

rustic dagger
#

I tried to fix it and looked through the docs but it says that Parse is not in context and can not convert float to string

slender nymph
#

show what you tried

rustic dagger
#

public static float timeAmount;
public InputField insertTime;

public void ChangeTime()
{
    timeAmount = Parse(insertTime.text);
}
#

all my code

#

but i fooled around with it

slender nymph
#

so you didn't look at the docs then

hollow cosmos
#

i have no clue whats causing this^

#

any ideas?

#

i can take any ss u might need but i dont get this shit

hollow cosmos
#

how do i link the script properly

slender nymph
#

wdym by "link the script properly"

hollow cosmos
#

for both of the scripts above its just simple counters and timer

slender nymph
#

you do realize i don't know what the contents of your code is so i cannot know what is null to tell you how to fix it, right?

hollow cosmos
slender nymph
#

and have you even figured out what variables are null using the steps in the link?

#

so you just didn't bother dragging the reference in there

hollow cosmos
#

huh

slender nymph
#

wdym "huh"? you did not bother assigning the variable

hollow cosmos
#

where do i assign it

#

i have litearlly no clue

slender nymph
#

literally look at your screenshot?

hollow cosmos
#

not following

slender nymph
#

hope that helps

hollow cosmos
#

does alot honestlyt

#

thanks

slender nymph
#

you sure it doesn't need some flashing lights or anything to help draw your attention to your screen?

hollow cosmos
#

did assign it

#

not working still

slender nymph
#

show the code

hollow cosmos
#

but one fiex

#

1s

slender nymph
#

does this object have a TMP_Text component on it

hollow cosmos
#

yeah

#

well

#

ui one

#

i can switch but it didnt change anything earlier

slender nymph
#

then you've got another of these components in the scene without one

#

look at your logs, you'll likely see that log from Awake printed more than once

hollow cosmos
#

only prints once

slender nymph
#

your console is set to Collapse

hollow cosmos
#

ah

slender nymph
#

make sure there isn't a (2) at the end of the line

hollow cosmos
slender nymph
#

screenshot your entire console window

#

with collapse mode on still

hollow cosmos
#

yeah i just saw the 2 ur on about

slender nymph
#

yes and that proves my point exactly. you have 2 of those components in the scene

#

one of which does not have a TMP_Text component attached and should be removed since you should only have one ever since it is a singleton that doesn't bother doing any checks to see if one already exists

rustic dagger
#

how do i fix this?

slender nymph
#

your string contained characters that were not able to be parsed as a float

rustic dagger
#

all i inputed was 4 in the input field

slender nymph
#

put this on the line before the float.Parse call: Debug.Log($"'{insertTime.text}' is {insertTime.text.Length} characters long and can be parsed into a float: {float.TryParse(insertTime.text, out var f)}"); then show what it prints

#

oh wait i just went back and saw insertTime was the input field, you'll need to access the .text property for it in that log

#

but i suspect this is u200b making its appearance again

rustic dagger
#

`Debug.Log($"'{insertTime.text.Length}' you want before the call for parse. then what do i do with this {float.TryParse(insertTime, out var f)}");

slender nymph
#

obviously at each point in that log where i used insertTime you just have to add .text to it

#

then show what it prints

rustic dagger
slender nymph
#

well you clearly didn't follow my instructions. but i updated the message so you can just copy/paste it

#

you'll also need to use a different variable name since you apparently use terrible names and called something f already

rustic dagger
#

no errors

slender nymph
#

okay if there are no errors then run it and show what the log prints

rustic dagger
#

i entered 4 into the input field

slender nymph
#

i told you to put the log on the line before your existing float.Parse call

rustic dagger
#

thats what the code looks like

slender nymph
#

then save the code so it recompiles and try it again

#

also get your !IDE configured 👇

eternal falconBOT
rustic dagger
slender nymph
#

the log will print before the error

#

and the log cannot throw that error

rustic dagger
#

sooo what should I do??

slender nymph
#

screenshot the entire console window

rustic dagger
#

im stupid

#

the log was clicked to show

#

now i see the log

hollow cosmos
#

@slender nymph highly apperciate the help thanks

#

finally time to get sleep

slender nymph
# rustic dagger

congrats, you have been cursed by the TMP_InputField hidden character! when you parse it (and ideally you should be using tryparse if a player can input anything into the input field), you need to trim the \u200b character from it

rustic dagger
#

where should i put the code

#

public string Trim (char trimChar);

slender nymph
#

have you just never read any documentation before?

#

you don't copy/paste that line into your code, that is the method's signature. the method you need to call

rustic dagger
#

honestly

#

no

rustic dagger
slender nymph
#

not even close

rustic dagger
#

oh gosh

slender nymph
#

please go through the beginner c# courses pinned in this channel

rustic dagger
#

good idea

grizzled fulcrum
#

Having a small difficulty, multiple boxes are getting grabbed at once when I interact with "E" on the hitbox of the first one. How could I fix it to separate them?

using UnityEngine;

public class BoxPushPull : MonoBehaviour
{
    public float pushPullSpeed = 4f;
    public float playerNormalSpeed = 7.0f;
    public float playerGrabSpeed = 4.0f;

    private bool isPulling = false;
    private Rigidbody2D rb;
    private PlayerBase PlayerBase;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        PlayerBase = FindObjectOfType<PlayerBase>();
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (!isPulling)
            {
                isPulling = true;
                rb.bodyType = RigidbodyType2D.Dynamic;
                PlayerBase.SetSpeed(4.0f);
            }
            else
            {
                isPulling = false;
                rb.bodyType = RigidbodyType2D.Static;
                PlayerBase.SetSpeed(7.0f);
            }
        }

        if (isPulling)
        {
            Vector2 movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
            rb.velocity = movement * pushPullSpeed;
        }
        else
        {
            rb.velocity = Vector2.zero;
        }
    }
}
slender nymph
#

instead of checking for input on every individual box, you should instead check for input on a component on the player, then you can use a physics query like a raycast, overlapcircle, etc to find nearby interactable objects and interact with those specifically

#

because right now, all you do on every single box is just listen for input and start reacting as soon as there is any input regardless of whether the player is even anywhere near them or not

onyx tusk
#

where 2 save data & sort it if folders in game directory can't be written, folders in Application.persistentDataPath r also can't be written?

eternal needle
grizzled fulcrum
slender nymph
#

yes

grizzled fulcrum
#

I'll try and figure out what to do in regards to that then

north kiln
# onyx tusk

Do you intend to have double backslashes in your path? Also if you use Path.Combine you don't need to specify any slashes and it is generally much safer due to that

next bolt
#

I'm currently trying to make two objects(guns) attached to my camera always visible but the models always clip through the floor. How do i make them always visible

onyx tusk
next bolt
#

nevermind i did it

unkempt carbon
#

hello coding gods GuraPray2 im trying to make a script that checks to see if the other player is ready, is this a question to ask in the unity multiplayer networking server? or can I ask this here?

summer stump
unkempt carbon
atomic bison
#

good morning guys. i have a question, if i want to add part of an scene as addressables is better to use Addressables.LoadSceneAsync or Addressables.InstantiateAsync?

topaz mortar
#

what happens to a reference to a destroyed gameobject? is it set to null?

slender nymph
#

no, the reference is still there. it will just throw a MissingReferenceException if you try to do unity things to it, and it will be equal to null when comparing with the == operator

topaz mortar
#
TownController.Instance.Scroll = null;```
the DeleteItem function calls Destroy(gameobject)
just wondering if I still need to set it to null after?
slender nymph
#

if you want it to be actually null and not just reference the now-destroyed object, then yes you should

topaz mortar
#

yeah it needs to be null, I'm checking it in other places

slender nymph
#

destroyed objects do still equate to null using the == operator

topaz mortar
#

ah

slender nymph
#

unity has overridden the == operator to check for destroyed objects so a destroyed object will return true when compared to the null literal with that operator. this is why it is always recommended to use that operator to null check a UnityEngine.Object variable rather than things like the null conditional operator, is operator, or null coalescence. none of those use the overridden == operator and unity cannot override the behavior of those other operators so using any of those other operators with something that may be destroyed but not immediately explicitly assigned to null will end up potentially throwing exceptions

queen adder
#

rectTransform.position or .localPosition?

#

ah just saw this

languid spire
gilded elm
#

oh srry

dry spruce
#

Facing problem with the word random plz help me

deft grail
dry spruce
#

how that can be done

deft grail
slender nymph
dry spruce
languid spire
stuck palm
#

is there a way to immediately end a coroutine from an outside source

#

instead of stopping it

#

like if im using a coroutine to tween two values

#

is there any way to add some sort of interrupt that would instantly make it go to its end result

cosmic dagger
#

to end a coroutine, you have to stop it from running . . .

cosmic dagger
stuck palm
#

how can i add breakpoints to code in unity that would pause the editor?

elder raptor
#

How do I make sure that all the Input Field only accepts integers?

wintry quarry
#

Especially if you are using TMP

elder raptor
#

Ah got it, thank you

deft grail
burnt vapor
#

So whatever the issue is now is different. Considering sharing your !code

eternal falconBOT
dry spruce
#

yess its all done n working properly

#

tysm everyone for ur time n help

frail laurel
deft grail
#

instead of 0.05

willow scroll
#

Either decrease the timer by Time.deltatime, as was mentioned above, or manage this behavior with the Coroutine

delicate portal
deft grail
#

put a debug.log

#

at the top before mouseposition =

delicate portal
deft grail
delicate portal
digital temple
#

Guys for Unity I only need to know C# right

delicate portal
#

Yes

deft grail
digital temple
#

Is it easy to switch between it and C++

delicate portal
#

Nope

languid spire
delicate portal
#

I mean depends on ya

deft grail
digital temple
#

And be able to use them correctly

#

I guess it depends too 😭

delicate portal
#

depends on you, id say 6 months to a year

deft grail
languid spire
digital temple
#

So as someone with zero experience can I be able to make my first game in 3 months

#

Just a simple mobile game

deft grail
digital temple
languid spire
#

then 3 months is unrealisric

deft grail
#

depends what your making "simple mobile game" can be many things

languid spire
#

without programming experience you need to learn programming not just coding, that is no easy task

digital temple
#

Not my goal

deft grail
digital temple
#

What about a game like soul knight but without online servers

deft grail
#

a basic prototype you can make in probably 1-2 weeks depends how you use your skills

digital temple
#

Ok thanks and do you recommend any material to go and learn from

deft grail
#

if you are trying to literally just make the game

#

follow tutorials on each thing your implementing

#

otherwise theres some pinned in this channel or !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

digital temple
deft grail
digital temple
languid spire
digital temple
frank zodiac
#

hey guys what are the ways to make a parallax effect? for instance, hollow knight layered their backgrounds in 3D but some do it using programming. whats the best method?

deft grail
cosmic quail
#

doesnt hollow knight use an isometric camera? so layering it in 3d does nothing

frank zodiac
deft grail
#

thats just them looking around the scene in 3D view

#

to showcase each part of the background

frank zodiac
#

yeah thats what i meant

cosmic quail
deft grail
frank zodiac
#

that seems simple

#

im not sure why they did it manually like that

real rock
#

Well outside of a “normal” camera there’s no other way to do parallax

cosmic quail
real rock
#

Either you let the physics of perspective do it or you move things at different speeds sooo

cosmic quail
#

and making your camera non-isometric screws up your entire view and the game no longer looks the same so you cant do that either

real rock
#

Yeah you’d have to design the game around that

hallow totem
#

Actually I checked and it also happens in preview it's just less noticable so these logs are relevant to the character swerving to the right while going backwards.

magic jungle
#

Hi, I'm a beginner in Unity.
I usually use Godot, but for a game, I need to use Unity.
So, I wanted to know how to load all the videos of a project (FMV) before the game starts. This project will be hosted on a website, and I'm not sure what the best way to play those videos is.

buoyant knot
#

idk about videos, but this doesn’t sound like something where you’d want to use unity

#

it sounds like youtube

errant pilot
#

Guys im spawning an object in the Worldspace and assigning its position to the mouse position but they are located differently, how can I fix it?

real rock
#

You’re gonna need to send a pic or vid of what’s happening

polar acorn
#

Add Component -> Box Collider

slender nymph
#

does the ball also have a non-trigger collider on it?

#

so that's a no

#

a rigidbody is not a collider, it just simulates physics

polar acorn
#

Looks like it's working exactly as it's supposed to

hallow totem
slender nymph
#

yes, that is as expected if the ball has no collision

real rock
polar acorn
#

Right, because colliders collide with colliders, which your ball does not. Since your ball has no collider, it's supposed to do that. Meaning it's working as intended

slender nymph
#

remember how i specifically asked if the ball had a collider, then you showed that it did not so i pointed out that it does not

errant pilot
real rock
errant pilot
strong mica
#

Guys I need you helppppp, I'm making a roguelike game that has multiple scenes and DontDestoryOnLoad function working between each scene. Any suggestion for restart function? I need to make the player go back to the first scene when dies and all the data needs to be reset (Everything back to the default setting).

real rock
errant pilot
slender nymph
waxen cypress
#

So im making a VR game but when Im making my code it comes up with these errors talking about needing to convery to a new SFK style for it work in C# Dev kit. Any clue on how to fix?

slender nymph
#

configure your !IDE so that it will underline your syntax errors for you

eternal falconBOT
strong mica
slender nymph
#

does it have that tag?

strong mica
#

yea its same as its name

slender nymph
#

and have you tried this?

strong mica
#

I tried and it looks like the saved object in DDOL did not get destroyed

slender nymph
#

so you see two of those objects in the DDOL scene?

strong mica
#

yes

slender nymph
#

are you sure that it has the PersistenceManager tag applied to it?

real rock
#

Honestly, singleton time? Might be easier than tag searching and maybe duplicating

slender nymph
#

show the full inspector for the object

#

holy hell you have so many DDOL objects. but it's clearly working, there's only a single PersistenceManager in there after the restart. now you need to do the same for all of the other DDOL objects that aren't getting destroyed on restart

strong mica
#

yea lol, im making a roguelike game tho

slender nymph
slender nymph
swift crag
#

roguelikes generally don't persist many things from run to run 😉

strong mica
slender nymph
#

i don't really see how that is relevant

strong mica
slender nymph
#

my dude, you only destroyed the PersistenceManager. now destroy the rest like i just told you

strong wren
#

yo

strong mica
#

oh i see

#

thx mate

strong wren
#
    {
        if (collision.gameObject.CompareTag("PlayerSlap"))
        {
            ChildHealth--;
            Debug.Log("Child Killed");
        }
    }``` is there a reason why my code isnt rlly working? im making an attack system bassically if i click the mesh renderer and the collider turns on, that works as needed this doesnt work and idk why
strong wren
#

thats why i added it

#

this is the gameobject thing

polar acorn
strong wren
#

as u can see the Tag is PlayerSlap

strong wren
slender nymph
polar acorn
real rock
#

I may be wrong but I wanna say you don’t get a collision if the collider is turned on while already inside the other collider

slender nymph
strong wren
#

I tagged it as EnemySlap Cause if they touch you then u lose HP thats works fine

polar acorn
# strong wren

Okay, so since this one has the rigidbody, is this object the one moving? How is it moving?

polar acorn
slender nymph
#

am i really the only one that saw it?

real rock
#

Oh yeah also collision vs trigger is what box is trying to subtly say

strong wren
real rock
polar acorn
strong wren
#

i have the rigidbody for physiscs

real rock
polar acorn
#

I saw that it was disabled but they said it enabled I didn't even check the rest of the collider

strong wren
#

which works

#

i checked

polar acorn
real rock
#

Yeah

strong wren
#

heres proof that if i click they turn on

polar acorn
strong wren
#

oh is it cause i have the isTrigger Enabled?

real rock
#

Yee

#

You either need to change that or make it OnTriggerEnter

strong wren
#

kk

#

what does this mean?

slender nymph
polar acorn
strong wren
#

but the thing is the script that has the OnTrigger is the AI following me, and the Box Collider of the Child Isnt a trigger

#

wont that affect something?

slender nymph
#

you know this can be answered by reading the information in this guide, right?

strong wren
#

oh ok

#

eyy

#

it works now

real rock
#

Nice

strong wren
#

and the death thing works too

#

lets goo

#

quick question again
this is the code i have paired to the slap thing right

using System.Diagnostics;
using UnityEngine;
using UnityEngine.UI;
public class Stats : MonoBehaviour
{
    public ChildFollow CF;
    public float Health = 5;
    public Slider HealthBar;
    public GameObject Slap;
    public void Update()
    {
        HealthBar.value = Health;

        if (Input.GetKeyUp("mouse 0"))
        {
            Slap.GetComponent<Collider>().enabled = true;
            Slap.GetComponent <MeshRenderer>().enabled = true;
        }
    }
}

yeah well how can i turn off the Collider and meshrender again? i was thinking of making a float variable and a bool to check if the ColliderIson and if it is the float to go down by Time.DeltaTime and once it reaches 0 to reset the float variable and set the Colliders and meshrenderer to false and also set the bool to false

#

is there like a better way to do it?

real rock
#

No real need to subtract deltatime, just track the time it started and then subtract that from either Time.time or Time.realtimeSinceStart(?)

chrome echo
#

why dose the destroy function destroy my script instead of the gameobject the script is attached to? the val here is ref through a interface

slender nymph
#

what you have there will destroy the gameobject, provided you actually save the code

strong wren
# real rock No real need to subtract deltatime, just track the time it started and then subt...

how can i impliment that into my code cause i only worked with DeltaTime so idk anything about Time.time

using System.Collections;

public class Example : MonoBehaviour
{
    public GameObject projectile;
    public float fireRate = 0.5f;
    private float nextFire = 0.0f;

    void Update()
    {
        if (Input.GetButton("Fire1") && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            Instantiate(projectile, transform.position, transform.rotation);
        }
    }
}``` this is what i found in the unity docs but this is only a delay beetween shots whilst i need my slap to be on for like 0.5 seconds then turned off again
real rock
#

(I’m on my phone so a (?) means I’m not 100% sure about the type/name, IDE and docs should catch it)
Assign Time.time to a double(?) when the slap starts, then on each update check whether the time between that assigned time and the current time is .5s and if so disable the slapper

chrome echo
waxen cypress
#

Why doesnt unity want to recognise [serializedfield]?

polar acorn
waxen cypress
#

I had no issues using it before tho. And the video I watched also uses it.

slender nymph
#

make sure your !IDE is configured so you don't make silly spelling mistakes

eternal falconBOT
strong wren
polar acorn
strong wren
waxen cypress
# polar acorn Show the video that uses it

Its for VR but goto https://www.youtube.com/watch?v=TJ8yk5vVwI0 (13:40)

🎮 This is a wrap up of my How to make a VR game series cut to a single video for easier follow 🕹️

🔹Asset Links🔹
1️⃣ Unity Asset Store Free Asset: I will be using this great free asset from the Unity Asset Store in this tutorial: https://goo.by/f2w1f
or
https://assetstore.unity.com/packages/3d/props/polygon-starter-pack-low-poly-3d-art-by-synty-...

▶ Play video
polar acorn
waxen cypress
#

Its used as a float

slender nymph
strong wren
#

you know its bad when even i know how to fix it

polar acorn
strong wren
waxen cypress
#

... no comment. Listen guys. I promise I'm not special. Blame time 🙂

#

Please 🙂

slender nymph
#

again, get your !IDE configured so you don't make these silly spelling mistakes

eternal falconBOT
strong wren
#

whats the diff beetwen time.time and time.Deltatime?

slender nymph
#

what do the docs say about each of those

strong wren
#

havent rlly read the docs about them someone just said if im working with time to use time.DeltaTime

summer stump
#

There are significant differences

slender nymph
#

your first thought when you don't know what something does should be "i should check the documentation" rather than "i should ask what these do in discord"

strong wren
#

oh

#

i just checked

#

wait then shouldnt i be using time.Deltatime instead of time.time?

real rock
#

Deltatime is the time it took since the last frame

polar acorn
real rock
#

time is just the time since the first frame

strong wren
real rock
#

Both would work, it’s just more conventional to make a timer by comparing the time to the runtime rather than adding up the Deltatime

polar acorn
summer stump
strong wren
real rock
strong wren
#

dayum ur like the first person to stand up for me lol

real rock
#

Meh just correcting a misunderstanding. Some people hop in and don’t realise it’s been a slightly long convo

#

Done it myself before

summer stump
real rock
#

Yeah

strong wren
#

i did smth and it works

summer stump
strong wren
#
using System.Diagnostics;
using UnityEngine;
using UnityEngine.UI;
public class Stats : MonoBehaviour
{
    public ChildFollow CF;
    public float Health = 5;
    public Slider HealthBar;
    public GameObject Slap;
    public float SlapTime = 0.5f;
    public bool isSlapOn = false;
    public void Update()
    {
        HealthBar.value = Health;
        if (Input.GetKeyUp("mouse 0"))
        {
            Slap.GetComponent<Collider>().enabled = true;
            Slap.GetComponent<MeshRenderer>().enabled = true;
            isSlapOn = true;
        }
        if (isSlapOn == true)
        {
            SlapTime -= Time.deltaTime;
        }
        if (SlapTime <= 0)
        {
            Slap.GetComponent<Collider>().enabled = false;
            Slap.GetComponent<MeshRenderer>().enabled = false;
            isSlapOn = false;
            SlapTime = 0.5f;
        }
    }
}
#

prob not the best way to do it but it works

real rock
#

God reading this on a phone is painful lol

strong wren
#

lol sorry

real rock
#

Yeah that’s one way of doing it

strong wren
#

i mean it works

real rock
strong wren
#

lo

real rock
#

But yeah if it works that’s the main thing

#

I think there’s a way of doing it that’s considered “better” but I think it’s just because it’s become a standard rather than any other reason

tranquil scarab
#

https://gdl.space/alalabivoh.cpp i made this function for a script in my game that should handle the grip of a tyre on the x axis. it works on normal cornering but when it drives straight the forces overshoot and it begins to wobble really heavily. how can i solve this best?

strong wren
#

this was prob the first time where i didnt get bullied when i needed help

polar acorn
real rock
#

Sometimes programmers can be harsh but usually it comes from a point of wanting people to learn for and by themselves rather than constantly outsourcing

summer stump
real rock
#

I guess you have the gizmos but I can’t see those

#

Actually wait no

#

I had this issue too

#

I would do the Vector3.Dot with tyre velocity.normalized

tranquil scarab
tranquil scarab
golden blade
#

Took me 2 days for this beauty

#

☝️sadok

summer stump
golden blade
#

Nope

#

Just wanted to show

summer stump
golden blade
#

Ok ty

tranquil scarab
#

works now tnx

#

logical if you think about it but never crossed my mind

median roost
#

hello, new to the coding side of unity and wondered if anyone could help - I have a character moving and idling in 8 directions, however, i cant seem to make the character idle in the 3/4 positions, it defaults to either up/down/side. tried looking elsewhere for a solution and cant find anything. thanks in advance:)

real rock
tranquil scarab
languid spire
eternal falconBOT
median roost
worthy merlin
#

https://gdl.space/lusezuvoje.cs
Getting very confused. Its declared as a monobehavior class yet its saying it isn't. Can't see any syntax wrong on it? Was working moments ago, closed my computer and no its doing this?

worthy merlin
#

Very vague

deft grail
worthy merlin
#

yeah but thats all I am getting

deft grail
#

delete the script from your game object and then add it back

worthy merlin
deft grail
worthy merlin
#

Filename, class name, all match

deft grail
#

the whole window

austere hedge
#

I have a class containing properties:

public class MovementModifier
{
    public float SpeedModifier { get; set; } = 1f;
    public float DurationModifier { get; set; } = 1f;
    public enum IgnoreModifier { None = 0, PopUp, WaitDuration, PopDown }
}

I want my method to accept the MovementModifier object as an optional parameter. So if a MovementModifier is not provided, it'll use the default values I've set into the properties.

I know how to make simple data types like int or string optional, but how do I make MovementModifier optional?

public void Foo(MovementModifier movementModifier ????????)
{
//Do something
}
worthy merlin
deft grail
worthy merlin
#

yeah, very confused. Even tried restarting unity but its still doing this?

deft grail
worthy merlin
deft grail
worthy merlin
#

Looks like removing PlayerInput library fixed it?

#

cause now its working. No idea why its doin that though

short hazel
# austere hedge I have a class containing properties: ```cs public class MovementModifier { ...

The optional value must be a compile-time constant. The only thing you can use here is null, and afterwards check if it's null, and assign a new instance of that class with the default values you need.
eg.

void Foo(MovementModifier movementModifier = null)
{
    // Note: '??=' does not work reliably with anything deriving from 'UnityEngine.Object'
    movementModifier ??= new MovementModifier();
}
#

An alternative would be to make an overload that doesn't take the parameter, and call the other method that has the parameter with the value you want.

void Foo() { Foo(new MovementModifier()); }
void Foo(MovementModifier movementModifier) { /* ... */ }
austere hedge
willow breach
#

I had some issues to debug my code on windows so i checked on my mac and was able to debug it but then i notices there are differences in the project even though it's the same repo.

  1. on the mac the min for scale is X2 and on the windows is X1 does it matter?
  2. the canvas size on the mac is smaller (320X568, and on windows it's 400X711) and it seem like only 4 buttons out of 5 are showing (in horizontal layout), does it mean i have a problem or is it just because there are some differences with the project settings and I shouldn't be developing on 2 OSs
short hazel
polar acorn
# worthy merlin Looks like removing PlayerInput library fixed it?

It needed to force recompile. Chances are you changed a name of something and the codebase didn't get the message to recompile. Another thing that can force a recompile is to intentionally introduce a syntax error to a script and save it, then let it fail and go fix it

willow breach
short hazel
# willow breach

The Game View might just be too big for it to render at that 9:16 resolution, if you resize it down, can you scale the display down?

short hazel
willow breach
plain dagger
normal juniper
#

problem solved

plain dagger
# short hazel Here is probably fine

Thank you 🍪

Alright, so I'm developing an RPG and I want to have an On-Contact battle encounter system. I was wondering if I should store encounter information in the enemy, give that to a scriptable object, and then transfer that information to a "Battle" Scene, or if that's improper usage.

I know SOs don't store data permanently, but they should store for while the game is still open, right?

short hazel
#

You can do that with a class that doesn't derive from anything
It's usually best to keep ScriptableObjects immutable (when created they should not be modified)

plain dagger
short hazel
#

If you already have a script on an object that you persist through scenes with DontDestroyOnLoad(), then you can use that to transfer your data

plain dagger
#

I see, thank you for the help

frail laurel
#

Need help with this script i got 3 scenes like Level 1, Level 2 , Level 3 how do i make that in diffrent level diffrent time seconds would be like level 1 would be 30 in level 2 would be 20 in level 3 would be 10 https://hastebin.com/share/eqovohavan.csharp

austere hedge
#

I can't access my enum property. What am I doing wrong?

public class MovementModifier
{
    public float SpeedModifier { get; set; } = 1f;
    public float DurationModifier { get; set; } = 1f;
    public enum IgnoreModifier { None = 0, PopUp, WaitDuration, PopDown }
}
MovementModifier movementModifier = new();
movementModifier.?????
polar acorn
short hazel
polar acorn
#

You've made the type but you aren't using it anywhere

short hazel
#

If you're going to use it outside the MovementModifier class, consider moving it outside to its own file.

austere hedge
#
public class MovementModifier
{
    public float SpeedModifier { get; set; } = 1f;
    public float DurationModifier { get; set; } = 1f;
    public enum IgnoreModifier { None = 0, PopUp, WaitDuration, PopDown }
    public IgnoreModifier MovementType { get; set; }
}

I think I have it now. I didn't know that it behaved as its own data type.

wintry quarry
#

yep, exactly, it's its own data type

austere hedge
#

Thanks guys.

valid roost
#

Basically, I want my player sprite to pass through enemies but I still want him to take damage from said enemy is there anyway that i can achieve this?

willow scroll
wintry quarry
#

BTW that sounds like you would need either the enemy or the player to have two separate colliders:

  • One for general interaction with the game world (ground, floors, etc)
  • A separate trigger collider for the enemy/player damage interaction
valid roost
#

oh right

#

yeah

#

thank you both

frail laurel
#

how to fix this error i only have one LevelManager Assets\Scripts\LevelManager.cs(4,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'LevelManager'

https://hastebin.com/share/hawedamusa.csharp

willow scroll
wintry quarry
#

(unless you put them in different namespaces)

frail laurel
wintry quarry
willow scroll
rocky canyon
#

Great thing about computers is they do exactly what they're told and they tell no lies.

robust pecan
#

Maybe I'm stupid, but shouldn't this code place an object at all the corners of a rectangle? (the red dots in the image)

position is the green dot on the image

for(int j = 0; j < 4; j++)
{
    GameObject obj = MonoBehaviour.Instantiate(gameObject);

    obj.transform.position = position + new Vector3((j % 2 == 0 ? halfSizeX : -halfSizeX), 0f, ((j - 1) % 2 == 0 ? halfSizeZ : -halfSizeZ));
}

The second image is what I get from this

short hazel
icy junco
#

i have quick question so i have an empty object with arms and gun under it but so there are two different animators how do i make them work at the same time i have made my gun and my arms a different animation but they work togheter

gaunt ice
#

when j%2=0 ,(j-1)%2=1 you must get halfSizeX, -halfSizeZ, when j%2=1, you must get -halfSizeX, halfSizeZ

robust pecan
gaunt ice
#

btw there are only two states generated when you do j%2 , but you want -1,-1 -1,1 1,-1 1,1 = four states, technically impossible to produce -1,-1 -1,1 1,-1 1,1 from only a single j%2 operation

brave compass
valid roost
#

I figured i could use OnTriggerEnter but

wintry quarry
#

Why would you make a separate serialized reference to the player?

#

What's the point of that

willow scroll
valid roost
#

i see

wintry quarry
#

CompareTag should be used yes but that's just an optimization

#

it won't change the behavior

#

This code doesn't make sense as is.

willow scroll
#

That was a simple suggestion

valid roost
#

yeah i figured

valid roost
honest haven
wintry quarry
# valid roost I have no idea then

Hint - don't have a separate serialized reference. There's no need for it. OnTriggerEnter2D gives you a reference to the object you intersected with.

wintry quarry
honest haven
#

Failed to load player data: End of Stream encountered before parsing was completed.

wintry quarry
#

well there ya go

#

Sounds like the file didn't contain valid JSON

honest haven
#

so do i call close steam at the end

summer stump
# valid roost I have no idea then

Look into TryGetComponent. You won't even need to use tags if you do that
Although you can. In the case of the object being wrong, validating the tag is slightly faster than a failed trygetcomponent call.
Not a big difference though

umbral mist
#

Hello, is there a way to do something like this

boolean = expression

to check if a boolean is true, I don't want to do If (expression) then (boolean is true or false)

wintry quarry
honest haven
wintry quarry
wintry quarry
umbral mist
#
    {

        below = footY < platformY;
}
#

I get an error

wintry quarry
#

Maybe share what the error is?
That will work as long as the datatypes are correct

umbral mist
#

below is a bool, the other 2 are floats

wintry quarry
#

Then there's no problem

umbral mist
#

it says can't convert bool to floats

wintry quarry
#

if you have an error, please share it with the class

umbral mist
#

do i do ==

wintry quarry
#

sounds like below is actually a float

#

not a bool

wintry quarry
umbral mist
#

I want below to be true if one float is less than another

#

is there shorthand

wintry quarry
#

Are you reading what I'm writing?

#

You used the wrong datatype for below

#

you wrote float

#

it should be a bool

umbral mist
#

I'm asking if you can make a bool true or false based on an expression without using an if statement

wintry quarry
#

I said yes already

#

You are not reading what I'm writing

willow scroll
wintry quarry
#

you just did it wrong

#

you did this:

float result;
float x = 5;
float y = 6;
result = x < y;```
umbral mist
#

no, i result in my case is a bool

wintry quarry
#

provce it

umbral mist
#

and it says can't convert bool to float

wintry quarry
#

prove it

#

Show the full script

#

I think you made a mistake

#

because your error message implies you made it a float

umbral mist
#
{
    Overseer global;
    Player player;

    float footY;

    float platformY;

    BoxCollider2D bc2d;

    PlayerControl playerControl;

    public bool below;
    public bool down;
    public bool jump;

    // Update is called once per frame
    void Update()
    {
        footY = player.transform.position.y - 0.5f;

        platformY = 

        below == footY < platformY;

        if (down && jump && below)
        {
            bc2d.enabled = false;
        }
        else
        {
            bc2d.enabled = true;
        }
    }```
restive ember
#

you put ==

wintry quarry
#

what the heck is this

#

delete the platformY = broken thing

umbral mist
#

i changed it to == after I asked

restive ember
#

yes the platformY = is why you are getting an error

#

its just an empty line

wintry quarry
#

it needs to be = and you need to delete this nonsense

umbral mist
#

oh oops wow

#

yea

#

that's why I put it in beginner

languid spire
restive ember
#

right now what you have is float = (bool = expression);

umbral mist
#

I thought I was better than this

#

I have bool = (float > float)

restive ember
wintry quarry
restive ember
umbral mist
#

yea I fixed it

restive ember
#

nice 👍

umbral mist
#

thank you all, I should have finished that first

restive ember
#

it happens :D

languid spire
cosmic flicker
#

Hello,

I am currently facing a problem. I've attached recordings of my actual game progress. The problem is that on the top half of the grid (that is isometric) you can see that the placeholder isn't appearing unless I kinda put it next to an already placed bloc, in that case only the face against an already placed bloc is kinda appearing. It started to appear after I imported and used an asset pack called low poly water. I did some debugging but I feel like it's not a code problem or anything like that, just in case here is a pastebin of the PreviewSystem. I've tested to place cubes with just a normal blue plane and it works just nicely (as you can see on one of the 2 attached videos), so it seems to be the low poly water plane from the asset pack, maybe a shader problem but I'm not quite sure, if anyone has a clue I would be happy to hear it.

Disclaimer : I'm currently learning unity, and especially integrating graphics, for a long time I made games for fun without using any assets so I kinda understand the coding part but not the visual things.

frail laurel
#

is there anyone who willing to help?

wintry quarry
#

Are you aver calling AddTime? Is it ever running? Use Debug.Log to check

polar acorn
frail laurel
rocky canyon
# valid roost

Sorry, I started to answer and got a phone call..
But. what you have looks like it will work..

  • Make sure the OnTriggerEnter2D is on an object with a BoxCollider2D or some other 2D collider
  • Make sure there's a Rigidbody2D somewhere on the setup.. (mine is on the Player in this example)
  • Make sure that isTrigger is ticked on the Collider on the GameObject the script is attached..
  • Make sure that your Player Tag is applied to Other GameObject.. and that its spelling and capitalization match exactly
using UnityEngine;
public class Monster : MonoBehaviour
{
    public float damageAmount =10f;
    public float health = 100f;

    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log($"Something collided with our Trigger.. {other.name}");

        if(other.CompareTag("Player"))
        {
            Debug.Log($"That 'something' matches our tag..");
            
            // Take Damage to Monster
            health -= damageAmount;
        }
    }
}```
brisk kindle
#

Hi everyone, I'm trying to get an object to follow my mouse in a room (like first video). What I want is for the object's position to change to where the mouse is moved. I am doing this by casting a ray from the mouse. When the ray hits a collider the object's position should change to where it hit. But when i hit play and click on the object, it move along the ray that is being cast, starting at the collision (hit.point) and traveling towards the camera. Once it reaches the camera it starts over at hit.point and repeats. When I move the mouse the object's position changes to the new hit.point and moves toward the camera (second video). Anyone know how to fix that, or is there any other way to move the object like the first video? Thanks!

rocky canyon
#

ur code must be doing that.. can u show the code where u position the object to the hit location

brisk kindle
#

My code:


public class Trash : MonoBehaviour
{
    private bool _dragging;
    
    private Vector3 _originPos;

    private void Start()
    {
        _originPos = transform.position;
    }

    private void Update()
    {
        if (!_dragging) return;
        
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        
        if (Physics.Raycast(ray, out hit))
        {
            var mousePos = hit.point;
            transform.position = mousePos;
        }
    }

    private void OnMouseDown()
    {
        _dragging = true;
    }

    private void OnMouseUp()
    {
        _dragging = false;
        transform.position = _originPos;
    }
}```
valid roost
wintry quarry
#

Use a layermask to exclude it

untold bear
#

hey, i'm missing the correct android jdk, sdk, ndk and gradle for my new unity version which I downloaded through the unity archive, online it sais to download in through the hub but there it won't let me add modules, where else can I find the right versions for this?A

untold bear
#

idk just not an option

deft grail
#

then topr ight should be add modules

untold bear
#

yeah I know but it's not there

deft grail
#

screenshot it

languid spire
#

you cannot add modules to a Editor that was not installed via the Hub

deft grail
#

i see, it only works with LTS i think

untold bear
#

it is an lts version but I had problems downloading it through the hub as the install would just stay stuck in an endless loop, then I decided to download through the archive which worked fine but now I can't add the modules

#

I mean I could just download them manually and put them in the right folders but i'm not sure where or how to find the right versions for this unity version

brisk kindle
brisk kindle
languid spire
untold bear
untold bear
languid spire
#

Did you just download the editor again, not the Unity Installer like I said?

untold bear
#

also downloaded the android build support component installer

brisk kindle
#

Dont do that

languid spire
brisk kindle
#

Go here and select ur version, click Unity Hub and Install in Unity Hub

wintry quarry
untold bear
#

alright gonna restart pc and try again and run unity hub as admin now as I read that could be the reason the install in hub never finishes

brisk kindle
wintry quarry
#

This video seems to use an isometric view with an orthographic camera

#

So the depth doesn't really matter

#

Whereas your game is using a perspective camera

#

So that's going to change things a bit

valid roost
brisk kindle
frail laurel
polar acorn
cosmic flicker
high marsh
#

hi im working on the 2d beginner unity course and i have an issue

#

ive just updated my character moving script to now have the move left as an input action

#

but its saying that InputAction doesnt have a definition for isPressed

rocky canyon
#

u have to regenerate ur c# class

high marsh
#

how do i do that?

#

oh wait i found it

#

the guide was just wrong

rocky canyon
#

each time you add to ur input actions u need to regenerate the class (make a new version of it)

high marsh
#

its IsPressed not isPressed but the guide had it wrong so when i copy pasted it in it didnt work

rocky canyon
#

so the references exist

high marsh
#

like make a new save?

rich adder
velvet solstice
#

i am having a problem where the boxcolliders collide without touching eachother, this is the bug and the code

rocky canyon
#

i can't say for sure.. I've had other people do it to solve their issue.. and the last time i used the c# class I would have to regenerate.. The action map could be updated automatically.. but not the c# script.. I would think that'd be something they'd add or something that should be the default functionality but idk tbh

untold bear
tulip plover
#

hi, i have a problem, can someone help me?
i have a shooter test, so when i shoot to some place, the bullet go to the bullet hole and if after that i shoot to another place without an obstacle, the bullet go to the last bullet hole, i have an video of that error if someone needs it

#

And if apart from that you could help me fix that when I start the game, the camera doesn't look down, it would also help me a lot

rocky canyon
eager wolf
#

this gives me object reference error on line 67, not sure why (it's the last line)

rocky canyon
eager wolf
ivory bobcat
#

I'm assuming your error was a null reference exception error? @eager wolf

ivory bobcat
eager wolf
radiant frigate
#

does someone know why that error pops up?

summer stump
eternal falconBOT
tulip plover
summer stump
#

All good. Just can't read it without downloading as it is

tulip plover
#

is that good?

rocky canyon
#

are u trying to get the Rigidbody off the MeteorExposion script?

#

because GetComponent is trying to get a rigidbody off of the gameobject this script is attached to..

#

also.. you sent WeaponController via Hatebin..

#

the error is on MeteorFireMovementScript