#💻┃code-beginner

1 messages · Page 383 of 1

dense root
#

Woah how did you find that so fast?

slender nymph
#

i used the discord search feature. just using mentions:Justin Chou with the keyword "entrance"

dense root
#

Ahh, thank you that's super useful

rocky canyon
#

yea, the search options are pretty good on discord

#

if u can vaguely remember something and who u were talking with, its pretty easy to find stuf

stuck palm
#
 foreach (var asset in allAssets)
                    {
                        if (asset is AnimationClip clip)
                        {
                            Debug.Log("Found clip: " + clip.name);
                            if (clip.name.Contains("preview"))
                            {
                                break;
                            }

will break exit the foreach loop or go to the next loop?

polar acorn
zealous hatch
#

im trying to store a vector 3 in a variable so i can then change the transform.position of a game object in a if statment

#

how would i store the vector 3?

#

using what type

polar acorn
#

...Vector3

#

What else would it be?

zealous hatch
#

oml

#

so is vector 3 a type

polar acorn
#

I don't know how you could know the term "Vector3" and not know that it is a Type

dense root
#

What's the most elegant way to add a door here? The tilemap already has applied a collider, would I simply add another collider for use as a door?

#

My proposed solution seems clunky

zealous hatch
polar acorn
steep rose
#

!help

#

!code

eternal falconBOT
steep rose
#

how would i make it so when i run jump it keeps my momentum? this is the first time im using a character controller instead of a rigidbody one so.
https://hatebin.com/sedhirluyr

swift crag
#

one side comment: you should only call Move once per frame

#

If you call it several times per frame, you get two problems:

  • Your movement is split into several pieces, which could let you clip through a wall when you should've hit it (because you moved horizontally, then vertically
  • The grounded state of the CharacterController might be wrong, because it's based on the result of the most recent Move. Not really relevant here, since you do your own ground check
#

also, I'm getting deja vu here -- are you following a tutorial for this?

#

someone else posted very similar looking code earlier today

steep rose
#

yes i followed a tutorial, as i said this is my first time using this 😅

#

i know i can do this using if statements but i would like to learn another way to do this better

eager bear
#

Whats the reference for the left click?

steep rose
eager bear
#

I'm gonna try

#

It works

#

Thanks for help

steep rose
#

np

swift crag
steep rose
swift crag
#

What you can do is record your horizontal velocity from before the jump, and then keep using that until you hit the ground again

#

Or you could take the character controller's velocity, remove the vertical part, and then re-use that until you hit the ground

#

But you'd need to combine those two Move calls into one for that to work

rocky canyon
steep rose
#

i always used that, i mean they do the same thing

polar acorn
rocky canyon
#

ahh even better reason

steep rose
#

oh

#

i did not know that

polar acorn
#

There's reasons you might want to do either one, so it's not that either is "wrong", and 90% of the time you're going to know which one you want and being able to do both isn't very important

zealous hatch
#

i have a gun that inialise a bullet on the guns spawnPoint. How would i make it so 3 bullet spawn spreading

#

maybe i could initialise 3 bullets and change there dirrection slightly

slender nymph
#

yes, do exactly that

zealous hatch
#

how would i go about Instantiating 3 things

#

a for loop?

slender nymph
#

by calling Instantiate 3 times such as within a loop

ivory bobcat
zealous hatch
#

how would i change the angle? at the moment they fire facing the guns rotation. I know i would add like 3 to the z value but how would i make the first bullet - 3 then the second mnormal and the third plus 3

ivory bobcat
zealous hatch
#

im making a upgradde where instead of shooting 1 bullet they can shoot extra not different accuracy but instead a extra bullet shooting of into a different direction

#

i suppose i could track if the last upgraded bullet was either positive or negative angle and then switch

urban escarp
#

What does green plus mean?

zealous hatch
#

so if last bullet was-3 then next will be + 6 then next would be -6

slender nymph
slender nymph
slender nymph
#

so yes, like a fan

zealous hatch
#

are yeah, when you said fan i tohugh you were thinking top down three in each direction type thing

#

so how would i go about doing this

slender nymph
zealous hatch
slender nymph
zealous hatch
#

yeah i get that

slender nymph
#

the angle between those

zealous hatch
#

but the problem lies in changing the degree of the bullets

slender nymph
#

in what way

zealous hatch
slender nymph
zealous hatch
#

how do i calculate the angle difference

slender nymph
#

you determine the angle you want them to fire at

#

then from there it's literally just simple division to determine the amount of rotation needed for each individual bullet

zealous hatch
#

okay

#

at the moment my bulelts are decided by the angle my gun is facing. How would i add a angle onto transoform.rotation

#

BulletInst = Instantiate(bullet, bulletSpawnPoint.transform.position, Gun.transform.rotation);

slender nymph
#

multiply the current rotation by the desired rotation offset

zealous hatch
#

how do i do that? can you multiply a Quaternion

slender nymph
#

yes

steep rose
#

does he want a randomized angle?

scenic burrow
#

How can I stop player from spazzing out when it collided with another object?

ivory bobcat
slender nymph
#

the answer is likely to constrain the rotation on the rigidbody. but yes, more context is needed

scenic burrow
#

Well I got a plane which is supposed to fly through rings. When I fly the plane through the ring, it will like rotate and move when it is supposed to stop.

ashen ridge
#

Im having trouble imaging tgat can you send a video of it

scenic burrow
#

Like in this photo it was supposed to be going straight but when I hit the ring it started flipping itself

slender nymph
#

constrain the rotation on the rigidbody

scenic burrow
#

The plane is meant to tilt when I move left and right, so wouldn’t that stop it from doing it?

ivory bobcat
scenic burrow
#

My script checks if the player collided with the ring in which they stop moving and the game ends.

slender nymph
scenic burrow
#

I locked the position and rotation of the rigidbody and it kind of works but I am still bouncing off the ring when I hit it

#

It hits the ring and doesn’t move around like before just moves backwards

#

Wait nvm fixed it

#

Tysm 👍

rustic timber
#

I’m not sure I understand the question, but I like to assign as much as possible in the inspector on the prefab so I don’t have to grab things using GetComponent during runtime. In your script it seems like enemy is the current object, so might as well prepare what you can as early as possible!

queen adder
#

my character keeps falling throught the floor and i have tried rigid body and it doesnt work any advice

rich adder
#

there is nothing here that would make this fall through floor

#

you have a misunderstanding what rigidbody is

#

thats what gives it Physics

#

without it nothing falls

queen adder
#

oh mb

#

it is just what i saw to do if it keeps happening

rich adder
queen adder
#

👍

#

wait 1 sec

#

ill convert i

rich adder
queen adder
rich adder
#

oh wait

#

ur mixing character controller too

#

pick on or the other

queen adder
#

wait between what

rich adder
#

rigidbody is physics n needs collider.
Character controller works with physics already has collider

queen adder
#

oh

#

do i get rid of rigid bodies then

rich adder
#

depends what ur trying to make

#

both have their pros and cons

queen adder
#

i was trying to do a shooter for my friend

#

but only simple

#

im just trying to test it out for now

rich adder
#

just use character controller so you don't have to deal fighting the physics to learn how movement works

#

the only difference you have to code your own forces such as gravity

queen adder
#

do i still keep the colliders

rich adder
#

character controller needs no other colliders

queen adder
#

but does the ground

rich adder
#

is it solid?

#

ofc

queen adder
#

im still falling

rich adder
eternal falconBOT
queen adder
rich adder
#

!screenshots

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

queen adder
rich adder
#

make sure you can see the collider green gizmos lines

queen adder
rich adder
queen adder
#

how do i do that?

rich adder
#

Hold Ctrl and select both objects in hierarchy

queen adder
rich adder
#

I have a feeling your Mesh is higher than your main player

#

you probably only moved the child mesh

queen adder
rich adder
#

yea..

#

ur character is in like 5th circle of hell rn

queen adder
#

thank you how do i fix

rich adder
rocky canyon
#

how in the world did u drag all those in different places? 😄

queen adder
#

i think i undertsand but he is in he floor

rich adder
rocky canyon
#

well raise the gameobject up above the floor..

rich adder
#

also keep this in Pivot/Local as to avoid confusions later on

queen adder
#

it works thank you so much

#

one more question sorry

#

it works but the actual player is still below me slightly is there a way to fuse them

rich adder
#

fuse what exactly

queen adder
#

so the capsule and the bit where i store them

rich adder
queen adder
#

is there a way to bring this inside of the capsule

rich adder
#

well you're doing it backwards, you should probably do the !learn essentials path before doing anything further

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

i told you before, the capusule is the Child/Visuals its position needs to be 0,0,0 relative to the parent

#

you don't move parent into a child object

#

the pathways will at least show you how to do basic hierarchy navigation and whatnot, this stuff is important

queen adder
#

sorry man i thought this was the some of the first stuff you should learn ill look more into it

rich adder
#

at very least knowing the interface and what everything is yeah

#

the parent / child relationship is also very important as it plays large parts with each object

karmic kindle
# rustic timber I’m not sure I understand the question, but I like to assign as much as possible...

Yeah that makes sense. I'm trying to do that as much as I can. With my setup, I'm importing assets that have materials with the color in them so I can't set it up like that. I'd be interested in your thoughts of what I have and if there's a different way of doing it - https://pastebin.com/0UqAtnPJ

I think Unity is doing something weird in the background so this is what I've done to set it up; I don't want to duplicate every material and swap them (too many assets). If I don't set the material to "transparent" in the inspector then it doesn't work. My code gets the settings for all meshes on a gameobject, changes the mode to opaque so that the mesh renders correctly when playing (it will look like you can see through them gameobjects), then when I need to hide the enemy I set everything accordingly.

rustic timber
# karmic kindle Yeah that makes sense. I'm trying to do that as much as I can. With my setup, ...

I’d be happy to take a look if you named the methods and properties to something more verbose and descriptive, it’s hard to understand what you’re trying to achieve from looking at the code right now. For example, you’re not getting meshes, you’re getting mesh renderers. The mesh is a separate concept, the renderer just renders it. And HideMe doesn’t hide anything as such, it just sets a property block on a mesh renderer. The code should read like a short story in a way, so that someone new can go through it and be like ah, this is what the intent is.

#

Also you don’t need a separate alpha value, Color has r, g, b and a

karmic kindle
#

Cool, thanks very much. I'm still getting used to all the actual differences between the names and things so hopefully it'll stick lol. That's good advice, I will have to think a bit more when I'm writing it 🖖

olive galleon
#

When I'm trying to make a prefab should I finish all the logic completely for 1 instance before trying to create copies of it using a prefab. My example is making an enemy prefab, should I first finish all the script for the enemy OR if I change the Enemy script, the prefab will change as well? Sorry for the rough explanation

scenic burrow
#

Im making a script to end the game when the player is touching only one of two objects they must pass through. Both objects are placed in the same position so the player will hit both. The player is required to hit one of these objects to continue playing, but if they hit only the other object, the game should end. When I test out my script, the game ends when I hit the objects because they are placed together. How would I only end the game if the player misses the main object they are supposed to hit?

rich adder
#

also you should configure your IDE

swift crag
#

All that Unity cares about is:

  • which script asset each component uses
  • what values you've stored in the serialized fields of each component
#

So no, you don't have to finish writing your code first

scenic burrow
#

For clearer picture here is what I am looking for

#

When I hit the two objects it ends it, of course because I hit the purple ring as well.

rich adder
#

ohh I see what you mean, you want to hit both but not just purple ?

#

if hit only purple, end game

scenic burrow
#

Essentially I am always going to hit the purple ring, which is why I added the hidden green ring. So long as the player hits the green ring and stays within it, they are allowed to continue

#

Hitting only purple should end the game yes

rich adder
#

is it spheres or something?

scenic burrow
#

The box collider is the visible ring, the circular ring is the hidden one

#

I am basically trying to make a "hole" in the box collider to allow the player to pass through

swift crag
#

You can't. The box collider is a box.

scenic burrow
#

I know I cant actually make a hole

rich adder
#

I see, basically you want that bool to make you "safe" if you hit the inner collider

scenic burrow
#

Yea

swift crag
#

that sounds reasonable, assuming the player doesn't turn around and try to crash into the ring

#

(which they probably will not)

scenic burrow
#

Player is forced to fly forwards with only a certain area to move around so that should not be a problem

swift crag
#

You'll have a smaller collider that sticks out ahead of the game-over collider

rich adder
#

indeed offset it a little forward

#

hits first, bool goes safe, now on the second tag check if already safe return

scenic burrow
#

Hmm alright I will try that

#

Ty!

rich adder
#

You just need a way to reset the bool back to false once you passed the checkpoint

#

maybe OnTriggerExit or something

swift crag
#

or do it per-ring

ember tangle
#

do classes inheriting from a abstract class need to use the same namespace as the abstract class?

teal viper
ember tangle
#

hmm, im not understanding why my state system causes null reference exception errors when a certain line is not commented out

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

public class UnitDrawState : UnitBaseState
{
    float stateTimer = 0f;
    float drawTime = 1.5f; // temporary, will be based on attack type eventually.
    //float randomDelay = Random.Range(0f, 0.5f); // PROBLEM

    public override void EnterState(Unit unit)
    {
        unit.material.color = unit.drawColor;
        stateTimer = Time.time; //Start the timer
    }

    public override void UpdateState(Unit unit)
    {
        if(stateTimer + drawTime /* + randomDelay */ <= Time.time) // also commented out
        {
            unit.ChangeState(unit.rangedAttackState);
        }
    }
    public override void OnCollisionEnter(Unit unit)
    {

    }
}

abstract class:

using UnityEngine;

public abstract class UnitBaseState
{
    public abstract void EnterState(Unit unit);
    public abstract void UpdateState(Unit unit);
    public abstract void OnCollisionEnter(Unit unit);

}
teal viper
#

And the !code in such way that we can see the line numbers

eternal falconBOT
ember tangle
teal viper
#

Yes

neat bay
#

Hello, so I have a function that's suppossed to be running every 300ms, but for some reason its ever so slightly off each time. does anyone know what could be causing this? https://hastebin.com/share/jexeviyaha.markdown

scenic burrow
#

Would OnTriggerEnter work the same as OnCollisionEnter?

ember tangle
# teal viper Yes

it gives me a Null Reference exception error where the UpdateState() is called ;

#

works perfectly when random number is not generated

teal viper
rich adder
teal viper
ember tangle
#

sometimes brain no work good lol

teal viper
scenic burrow
ember tangle
scenic burrow
#

Searched up online but not very helpful imo

neat bay
#

or would it just always be slightly off no matter what i do?

teal viper
#

It should be off no more than a frame's worth time.

scenic burrow
# rich adder in what way its not correct?

Well I wanted to test if it was actually registering that I am no longer touching the hidden ring with a debug.log, but it does not log it meaning it is not checking if I left it

teal viper
rich adder
scenic burrow
#

Yes

rich adder
#

and how are you moving the plane in code

scenic burrow
rich adder
#

does plane have a collider? and are both "rings" collider set to trigger

rich adder
# scenic burrow

yeah that wont give you accurate collision manipulating the position directly

scenic burrow
#

Didnt remember to set triggers to on

rich adder
#

well both the rings colliders need trigger set on collider, the plane can be solid collider

scenic burrow
#

Ok it is regestering that I left it

rich adder
#

but you should not move position directly

#

set Rigidbody velocity. it appears to work ok but its gonna be jank and inconsistent.

scenic burrow
#

I added in the code to set the bool to false upon exit, but it seems that the inital code that sets it to true isnt working anymore

rich adder
scenic burrow
#

Oh no I didnt

#

Ooo it works

#

Hopefully now it should end game when it set to false

rich adder
scenic burrow
#

Yes it is forward by 3, but it does not log the code where I am going to end the game. Maybe because I have set it too close?

#

The first log works

#

Just not the second one

rich adder
# scenic burrow

put a Debug.Log(other.name) before the Safe tag comparison if statement

#

also your IDE doesn't look like its configured

scenic burrow
#

Not sure how to configure it. Will try to get that handled soon

#

I just noticed something

rich adder
eternal falconBOT
scenic burrow
#

My plane is set to move within a certain distance. I increased how far I could go, which then logged the second code

rich adder
#

you should not be moving rigidbody transforms directly, that also contributes to jank trigger messages

scenic burrow
#

Wouldnt technically shrinking the hiddenRing make it more accurate when colliding witht he actual ring. Since it is nearly the same size as the visible one, it will look that you did hit it but the game didnt end.

#

Think it actually looks correct. I think it should work how I like. Thank you so much!

sonic kite
#

!code

eternal falconBOT
sonic kite
#

Hey there.
I picked up development on a game that I didn't build. I'm an animator by trade wanting to branch out into designing/coding as well. One of the things I want to do is to take the ultimate move and extend the invulnerability it gives player by a few seconds. Here's the code in question, with a few sections of it removed to avoid discomfort of others.


    protected override void OnDisable() {
        base.OnDisable();
        
        input.actions["Ultimate"].performed -= OnUltimateButton;
        waiting = 0;
        attackCount = 0;
        doneAttacking = false;
        //player.SetFreeze(false);
        player.invulnerable = false;
        
    }

From what I know or looked up, I know I need to add a coroutine using yield WaitForSeconds(); But I don't know if it should be written as:


    protected override void OnDisable() {
        base.OnDisable();
        
        input.actions["Ultimate"].performed -= OnUltimateButton;
        waiting = 0;
        attackCount = 0;
        doneAttacking = false;
        //player.SetFreeze(false);yield WaitForSeconds(1);
        {player.invulnerable = false;}
        
    }

Or something else...

eternal needle
#

this is probably something that should be running on the player anyways

sonic kite
# eternal needle you'll need to make a separate method and theres examples on the docs below. but...

Yeah, I was reading through that page, and that's where I got the yield WaitforSeconds();, but... sorry if I'm not describing or hell, even understaning it well, but this specific section is what happens at the end of the ultimate. It runs the OnDisable thing, which turns off several of the main things it's using. The player.invulnerable state is one I want to turn off as well but just a little later. The problem is that it's lumped into everything else, so I'm not sure how to handle it.

There are several chunks there that I cut out of that section just to help avoid making people uncomfortable. But if need be, I can paste the entire script and you can look through it to see what I mean. I have it in a paste.ofcode already.

scenic burrow
#

Where would I find audio files for say a plane engine or background music?

eternal needle
# sonic kite Yeah, I was reading through that page, and that's where I got the yield WaitforS...

i understood what you were trying to do, but maybe you should start by just copying one of the examples and running this on a test script. You are missing the actual coroutine part, a method returning IEnumerator and something calling StartCoroutine on it. And my message was to tell you if the game object is being disabled, the coroutine will stop running. This is something you'd want to run on the player, like by having the player start the coroutine.

eternal needle
sonic kite
# eternal needle i understood what you were trying to do, but maybe you should start by just copy...

(In case I haven't made this abundantly clear, I know quite literally next to nothing about C# coding. I'm literally only like 5-6 lessons in on codecademy. Sorry for the inconvenience.)
So, to make sure I understand that correctly you're saying I need to create an IEnumerator that will run when the player activates the Ultimate ability, (on.Enable() in this case,) that will then end on disable?

For reference, this is what the two of those look like.

eternal needle
sonic kite
#

That is correct

#

Oh wait a minute, yeah, I just realized that OnEnable isn't where it starts. Would that be part of the problem?

eternal needle
#

🤷‍♂️ that depends on your game design. Do you want it to be invulnerable when OnEnable runs?

#

i dont think theres a better way I can word it than i already have above, if you arent familiar with how to call methods then you'll really want to do some c# basics first. Or at least test how coroutines work on a completely separate test object and just have it print out values from 0 to 1 for example.

sonic kite
#

Ok, so it doesn't particularly make a difference in terms of the game design, as basically they seem to run at the same time. Also, I do apologize, as it seems OnEnable is actually not even particularly relevant to the parts we're talking about. In this case, it's the section just above it.


    void OnStateTriggered(string name) {
        if (name == "TypeAttacked") {
            if (attackCount < stats.projectileCount.GetValue()) {
                Character target = AquireTarget();
                attackCount++;
                if (target == null) {
                    OnPostSlam();
                    return;
                }
                // Hack, just keep things from ending too early-- let them stack up.
                animator.SetTrigger("Chomp");
                animator.SetBool("ultAttack", true);
                waiting++;
                Score.AddDamage(weaponCard, target.stats.health.GetHealth());
                attackTarget.Vaccum(target);
                //player.SetFreeze(true);
                player.invulnerable = true;
                //float progress= (float)i/(projectileCount.GetValue());
                //yield return new WaitForSeconds((1f-progress)+0.8f);
            }
            OnPostSlam();
        }

This is the section in question. I've replaced certain names that would be sensitive.

#

Wait a Minute! I just noticed there's a WaitForSeconds in there already commented out for something else!

eternal needle
#

that commented out part wouldnt run regardless, this isnt a method that returns IEnumerator

sonic kite
#

Would you like me to just send a paste.ofcode so you could look a bit more at it?

#

Also, I am still trying to learn on codecademy, But I'm going between doing that and trying to fix/work on this game simultaneously to try and keep both motivation and attention up for both.

eternal needle
# sonic kite Would you like me to just send a paste.ofcode so you could look a bit more at it...

honestly this code is pretty bad, im surprised anyone would really require you to block out parts of this. I assume this is a friends project rather than a company NDA.
You can post more of the code if you want but there really isnt anything more that i need to see. It doesnt change what I said about how to run a coroutine. I strongly recommend re-reading what i said above and step away from this code for now. Make a new script, a new scene if you have to, attach the script to an empty game object and just have a coroutine print out values from 0 to 1 over time. Experiment around with it and what you can do. Then once you understand how to actually run a coroutine, come back to this script and apply the exact same logic. Theres nothing special about these methods that changes anything.
The only thing that would affect a coroutines logic is if the object is actually disabled or destroyed. Don't worry about this yet.

#

You could even start by literally copying the docs in your test code. The example with IEnumerator Fade()

sonic kite
#

The reason I'm blocking out content is for viewer safety/comfort, rather than any kind of secret. It has more to do with the content and the fact that it is ||A pornographic adult game|| and while I didn't see anything in the Code of Conduct for the discord server here saying that wasn't permitted, I don't want to take any chances currently.

eternal needle
# sonic kite The reason I'm blocking out content is for viewer safety/comfort, rather than an...

understandable, not really sure either if any words get flagged. I can only imagine what seemingly 3 letter word prefixes "Attack" in that snippet above 😂
Anyways i assume that commented out //yield return new WaitForSeconds((1f-progress)+0.8f); was probably left in there because this method used to be a coroutine. Really dont worry about the current code right now, it is confusing you too much where to put the coroutine when you arent sure how to write one yet.

sonic kite
# eternal needle understandable, not really sure either if any words get flagged. I can only imag...

Four letters actually. xD

And I want to do that, but like I said, I'm going between learning and working on this game to help retain my attention for both. I've been able to successfully fix a number of bugs in the game already, but this ultimate weapon is one of those problems that needs to be fixed ASAP. It has a lot of problems, including that it's not even entirely clear what it's supposed to DO. But this is the most identifiable thing that needs to be fixed.

If you're curious or willing to look through it to see if you can figure that out, here's the full script: https://paste.ofcode.org/vgDzRX6BJPZcw4VMEP4x6e

eternal needle
sonic kite
eternal needle
# sonic kite Outside of that specifically, it's not really obvious in game what this weapon a...

it is kinda hard to help if you arent truly sure what the issue is, or if you cant point to a section and say definitively "this value isnt what its supposed to be" or "this code isnt running". Add debugs in your coroutine if you think its an issue with the invulnerability like at the start and the end of the coroutine.
Also yea theres a lot of logic here that i just dont really have the time to go through to point out if i see flaws

#

There is also the part i mentioned above, where coroutines will stop running on disabled game objects

sonic kite
raw ledge
#

Hey is Photon 2 PUN in maintenance or it is working to create some multiplayers for a game ?

raw ledge
ruby python
#

Hi all, so once again I'm trying to get my head around Scriptable Objects. I'm looking to use SO's for my enemies so just a question if you would indulge me.

Can you assign values to variables in the SO at runtime? In my use case, each enemy 'targets' the player as they spawn, so 'finding' the player on spawn would be necessary.

eternal needle
# ruby python Hi all, so once again I'm trying to get my head around Scriptable Objects. I'm ...

You can, but you shouldnt really. SO's are mainly just immutable data containers.
Consider what you are doing here, as an enemy spawns you want them to reference the player. Instead of using an SO, the same can be achieved in ways that doesnt involve creating an asset to hold this "middleman" of data. Like when you instantiate an enemy, you are directly given a reference to any component you want. You could easily create a method that accepts a transform (or whatever you wish) and plug in the player data.

#

I want to also make it clear, what you asked will work but its just like a weird alternative to using a singleton or directly plugging in the data you need. Then every single enemy needs to reference this in inspector when really its always gonna be the same asset

quick pollen
#

how can I make it so only a single class has access to a variable from an other class?

simple sun
verbal dome
simple sun
#

^ is probably better

quick pollen
#

or maybe something like this?

#

I meant like over scripts

verbal dome
quick pollen
#

not just over classes

#

basically

#

I want to have a class called Ability which other scripts can inherit from

simple sun
#

make them protected

#

inherit from ability to gain access

quick pollen
#

if I do it like this then yeah it can just be protected

#

but like

#

god this is so fucking hard to phrase

#

if Ability had a function called void StartAbility() as an example

#

and I had a script which is inherited from Ability

#

or like

#

omg

#

im struggling so hard

eternal needle
#

well here, ability would just have access to every single thing inside ActionHandler

verbal dome
#

You can try to give a code example of how you would like to use it

eternal needle
#

inheritance like this doesnt really make sense, or its just something ive not seen done.

quick pollen
#

but I want to have different Ability scripts

quick pollen
eternal needle
#

I think this just falls into "if you dont want something accessing your variables, just dont give it your class"

#

although unity does kinda make it easy for anything to grab components, it could just be something you document like "dont GetComponent this and destroy it!!" Likewise how you cant prevent yourself from just randomly destroying every game object in your scene, something which is publicly available to do but you know better

quick pollen
#

as an example this doesn't work

eternal needle
#

well yea what instance are you trying to call it on?

quick pollen
#

wdym

#

im not calling it yet

#

its literally in the same script

#

do I need to make StartAction static

eternal needle
#

that is what your code is trying to do, call it.

quick pollen
eternal needle
#

then pass the instance into Ability from ActionHandler, an instance of Ability does not magically get created because you create one of ActionHandler

quick pollen
#

how do I do that then

eternal needle
#

look at the same thing you do for enums, you have an enum declared at the top there PlayerState. But you also have a
public PlayerState playerState

#

though really, i dont see why this needs to be a class within a class

#

StartAction is already public

quick pollen
#

basically

#

I don't want to have the scripts for stamina handling and the abilities to be separate

#

cuz whats the point

#

at that point the stamina handling script's only reason to exist would be just to store the stamina value and thats it

eternal needle
#

putting them in 1 file does not change anything here

quick pollen
#

i wont have to make all my variables public

wintry quarry
quick pollen
eternal needle
#

nested classes can access private variables but you also said you want inheritance, im not sure how you plan to handle that

wintry quarry
eternal needle
#

I think you could really just be fine with this mindset #💻┃code-beginner message
Dont pass around instances if you dont want something accessing that instance's data

wintry quarry
#

Internal allows access in the assembly. Two different files in the same assembly works just as well as two classes in the same file with internal

#

Now if you put the two different files in different assemblies that's a different story

#

But that would only happen with assembly definition files or with special folders like Editor

quick pollen
#

basically

eternal needle
#

then pass around the instance to whatever needs it

quick pollen
#

I want to have a class called Ability
other scripts can inherit from it, and be able to set things such as stamina cost, ability key, cooldown, etc
the other scripts can then write their own behaviour for what happens when that ability gets executed

#

im guessing ill need override to get the last part going

wintry quarry
#

None of that requires putting the classes in the same file or nesting them

#

That's just a standard abstract class/derived class setup

quick pollen
#

i dont know what you're saying.

#

i have no clue what derived or abstract means

wintry quarry
#

A derived class is just a class that derives from another class

#

Like Example : MonoBehaviour

#

Or MyClass : MyOtherClass

#

A child class if you will

eternal needle
#

You would also use protected so derived classes can access values from the base class

quick pollen
#

I want something like this

#

but it says i cant because its contained in a non-abstract type

wintry quarry
#

Yeah because you didn't mark the parent class abstract

quick pollen
#

and Ability is also abstract then?

wintry quarry
#

Which you need to do

#

Yes

eternal needle
#

you should read up on abstract classes first before guessing at to write though. And hopefully this isnt a nested class anymore

wintry quarry
#

Look at the examples in the link I sent

quick pollen
#

man this is complicated

quick pollen
#

its exactly what I want

#

basically have a class that has different uses depending on what it's called by

#

I just don't get why here it wasn't abstract yet still works

wintry quarry
#

Not by what it's called by.
By what it is

quick pollen
#

this is from the override part

wintry quarry
quick pollen
#

whats the difference

wintry quarry
#

Virtual is the same as abstract except you provide a default implementation in the parent class

quick pollen
#

aaahhh I see

#

I mean

eternal needle
#

Classes also dont have to be abstract at all, although you likely want it in your case

quick pollen
#

I could use that too for debugging reasons

#

but I think I get an error anyway if its not implemented

wintry quarry
#

A class has to be abstract of it contains at least one abstract member

wintry quarry
astral falcon
#

good day everyone. I am wondering, if there is a workaround to call interactable = true and false including the button being changed visually? Right now, if you select the toggle in inspector, its working, but by setting interactable to false and back to true does not turn it back on full color for example.

quick pollen
#

also why doesnt my intellicode realise that I want to use the Input type?

#

or whats going on here

eternal needle
#

Yea theres a lot of extra details to type here, like what can be done and when. so I think it's just best if you just experiment with this on test classes to understand it.

quick pollen
#

like I could write all this code in a much simpler way

#

which is what i had until now

#

but I guess this is good practice to learn these keywords

#

plus if I get asked in the future to show code that I've written before, like at a job interview, I can look just that much smarter

#

here comes another issue though

#

what if I want to make it so you cant use other abilities when you are in the middle of using one?

#

but I do want to be able to use the same ability

wintry quarry
#

I don't see how that is related to the question of polymorphism

quick pollen
#

well its less related

#

but basically if I have 2 abilities, a parry and an attack

#

I want to be able to continue attacking if I'm attacking

#

but I don't want to be able to parry

wintry quarry
#

Keep a reference to the ability you're currently using. Don't allow a new one to be used while using one

#

Just a few if statements and variables

eternal needle
quick pollen
#

how can I keep a reference?

#

i dont want to use integers or strings

astral falcon
wintry quarry
#

Ability currentAbility

quick pollen
#

because I could have a [SerializeField] internal string actionName

quick pollen
wintry quarry
#

Why not?

quick pollen
#

because I am inside of Ability?

wintry quarry
#

That's the whole point of defining types

#

You get to use them

quick pollen
#

oh wait im not

wintry quarry
#

This would be some other class

eternal needle
#

Its public

astral falcon
quick pollen
#

oh wait

#

yeah okay so like this

#

i dont really understand

#

is this null?

verbal dome
#

No, and if it was, it wouldn't throw that error

#

Doing something = null is valid

wheat wave
#

ability?

verbal dome
#

Looks like ability is null

quick pollen
#

oh

#

how could I make it not null....

verbal dome
#

Assign a value to it?

quick pollen
#

yeah but what value

#

do i need to serialize Ability

verbal dome
#

What is the point of the ability reference?

#

Oh this is in ActionHandler, not in Ability

astral falcon
quick pollen
teal viper
verbal dome
wheat wave
#

what's the point of abilityRef? If this class is supposed to be a singleton, it should be a static member

quick pollen
#

its not a singleton

#

i mean

#

youre going to have multiple abilities

#

and i dont want to be able to use multiple abilities at once

wintry quarry
#

The fact that Ability is a MonoBehaviour is pretty sketchy to me

#

Not sure what the instance management will look like

#

Also why a separate variable for this?

quick pollen
#

if i dont have a reference to handler I get an error inside of the classes that derive from ability

teal viper
#

What's handler even?

quick pollen
#

the class that contains Ability

teal viper
#

Why does the ability need to know about it?

wintry quarry
#

I mean abilityRef that variable seems really pointless

quick pollen
#

appareantly it isnt

wintry quarry
#

It definitely is

quick pollen
#

because the compiler shits itself if i remove it

wintry quarry
#

Define "the compiler shits itself"

quick pollen
teal viper
#

It only "shits itself" because you're doing something wrong

#

Like using that variable

wintry quarry
#

But the logic where you're using this variable seems like something that shouldn't be living in the Ability class in the first place anyway

#

Seems like something that should be in ActionHandler

eternal needle
#

You already are using this as well where you assign abilityRef

quick pollen
#

so something like this?

wintry quarry
#

Yeah but again I feel like all that code belongs elsewhere anyway

eternal needle
#

Most of that logic should be in the ability itself imo

quick pollen
#

dude yall just told me that having Ability be a monobehaviour is sketchy

wintry quarry
#

Yes

#

It is

quick pollen
#

how else am i meant to detect input

wintry quarry
#

In a MonoBehaviour attached to the player

#

That you only have one of

quick pollen
#

thats literally what im doing??

wintry quarry
#

Which is what I'm guessing ActionHandler is?

quick pollen
#

yes

wintry quarry
quick pollen
#

ActionHandler only has a single instance existing at all times

wintry quarry
#

Isn't this in the Ability class?

quick pollen
quick pollen
#

void ActionHandler.Update()

wintry quarry
teal viper
#

Maybe start sharing the !code correctly, so that we don't get confused

eternal falconBOT
quick pollen
quick pollen
eternal needle
#

The suggestion wasnt even related to input, I was saying that you shouldnt need to check an abilities stamina and cooldown from outside the ability

wintry quarry
#

Misread then sorry

quick pollen
#

oh, all good then

quick pollen
#

oh wait

#

i get what you mean

#

how else am i meant to check if I can cast an ability

wintry quarry
#

I mean I think that's debatable

#

If they All are always stamina based, this can work.

eternal needle
#

If this is literally the only place thatll call abilities then sure it's fine. The stamina part I misread I guess, but the cooldown part can just go directly inside the ability class since it's being compared to 0

wintry quarry
#

If you need polymorphic behavior on whether it can be cast that's a different story

quick pollen
teal viper
eternal needle
#

Though I dont see the point of that if ability[0] != this because that should basically always be not equal

quick pollen
wheat wave
#

you can have instances of abstract classes?

#

oh

wintry quarry
#

Sure, they just have to be an instance of a derived class in reality

quick pollen
wheat wave
#

I'm assuming you're assigning derived objects to that Ability[]

quick pollen
wheat wave
#
if(ability[0].handler == null) ability[0].handler = this;
quick pollen
wheat wave
#

I don't like this

quick pollen
#

Resonance derives from Ability but it isn't Ability

teal viper
quick pollen
#

idk how to serialize it

wheat wave
#

if you want abilities to be able to reference the event handler, you can have a static reference to the ability handler in itself

#

without ever needing to assign the reference to the handler in each ability

wintry quarry
#

Software design by committee let's go.

Alright I'm gonna go about my day.

wheat wave
#

too many cooks. Ironically, I showed up last

teal viper
#

Maybe we should give them some time to figure out how they want to design it first.

wheat wave
#
if(ability[0] != this){
``` what is this line doing?
eternal needle
wheat wave
#

when will an ability ever be of type eventHandler?

wheat wave
#

in theory

teal viper
quick pollen
eternal needle
quick pollen
quick pollen
#

I guess a better name would be AbilityHandler

#

okay I updated the code, ill send it again to keep things fresh

eternal needle
quick pollen
bitter sequoia
#

Guys, the inspector doesn't show anything to know if a default property changed?

quick pollen
#

ActionHandler is a script that exists on the Player and is responsible for handling all the abilities

wheat wave
#

like I said, singleton in theory

quick pollen
#

there can only be one of it at a time

#

am i missing a keyword

#

objects deriving from Ability, however, are not singletons

#

you can have multiple Ability scripts

eternal needle
#

Literally nothing you've linked has a singleton in ActionHandler. Although I truly dont feel like trying to correct another person's questionable suggestions as it just feels like working backwards. Really assigning the reference directly is better but I too will step out now.

quick pollen
#

i dont understand

wheat wave
#

having a static instance of a class, and an assignment to it in Awake, and a check to prevent multiple instances from existing at once is enough to fulfil the design pattern, right?

late burrow
#

if im making big log file does it matter if i gather info in string[] or string

quick pollen
eternal needle
# quick pollen i dont understand

You can google what a singleton is, yours simply isnt one and does NOT need to be. You are already directly telling the ability what the handler is, so the suggestion to randomly throw in static there achieves nothing. Singletons shouldnt be used purely because you dont want to assign a reference properly.

#

Keep the handler part as is if the ability even needs it. That doesnt need to change

short hazel
wheat wave
#

shouldnt be used purely because you dont want to assign a reference properly.
it's not?

late burrow
#

ok other question whats better writealllines or writealltext

short hazel
#

You're evading the problem

late burrow
#

im evading code i cant use

quick pollen
short hazel
quick pollen
#

ill remove the static part

#

also i still dont know how to get a reference to the scripts that are derived from Ability

eternal needle
# quick pollen to be fair I only really need it for one line

That's definitely not where you would even want it to be static. Theres more pressing issues to worry about though like actually implementing your abilities. One thing I'll reiterate before I gotta go is that this likely shouldnt be a nested class. This will just be more annoying in the future if you want like AI to use abilities too since you wouldnt be checking if via Input

quick pollen
#

AI wont be using abilities like this

#

like actually implementing your abilities
that's why I have the Action()

#

I can tell the ActionHandler what to do like that whenever I want to use an ability

#

but yeah how can I get a reference to Resonance?

wheat wave
#

ugh, I was worried about this

#

Resonance derives from ability, right?

quick pollen
#

yep

wheat wave
#

are you able to click and drag the monobehavior to the array slot

quick pollen
#

damn im stupid

#

yeah ty

#

also, do I even need to have Resonance as a monobehaviour?

wheat wave
quick pollen
#

couldnt I just have a script that I put there from assets?

wheat wave
#

I personally use scriptableobjects for this exact case

quick pollen
#

yeah thats a scriptableobject moment

eternal needle
#

That error is likely because you changed it from a monobehaviour

quick pollen
#

well i cant drag it in anymore

quick pollen
#

but it fixed after I made Ability be a ScriptableObject

#

yeah idk i think its better to keep it a monobehaviour

#

yeah using MonoBehaviour it works

#

yeah ive no clue

#

still @eternal needle tysm for the help

#

also @teal viper @wintry quarry @wheat wave @verbal dome thank u all very much

ruby python
neat bay
#

does anybody know my I'm getting thousands of these errors in my console? I haven't even ran my code

vital tangle
#

hey

ivory bobcat
vital tangle
#

i need some serious help

#

consider there is a children assigned to the transform of every gameobject

#

now i get the transform of a gameobject

#

and loop through its childrens and display their names

#

but it would only show the childrens of that transform

#

not the childrens of the transforms which i got from their parent transforms

#

i want to create a loop that will show me the names of all childrens in the transform and then their childrens as well until there are no children left

#

how can i achieve something like that?

willow scroll
vital tangle
#

any examples

willow scroll
willow scroll
#
Level 1
  - Level 2
    - Level 3
      - Level 4
        - Level 5
          - Level 6
      - Level 4
Level 1
  - Level 2
  - Level 2
    _ Level 3
  -
#

In this case, Level 1 is the original transform

#

You enumerate through its children, which are Level 2s

vital tangle
#

it only gives you level 2

#

you cant run a loop

#

such that it goes on and finishes on level 6

willow scroll
#
private static void EnumerateThru(this Transform value)
{
    foreach (Transform child in value)
    {
        child.EnumerateThru();

        print($"child: {child};");
    }
}
willow scroll
#

This is already the whole method to print all the names of the children

vital tangle
#

to run the same void inside a void

willow scroll
vital tangle
#

waaaaah

#

never thought of this

#

haha

#

thanks

#

you put me out of my misery

#

its not really transform

#

its a pretty complex thing which i am trying

willow scroll
vital tangle
#

but it pretty much looks like unity transforms so i gave example of transform

willow scroll
vital tangle
#
                            AssetTypeValueField GameObject = manager.GetBaseField(afileInst, Info);
                            // #Transform
                            {
                                AssetTypeValueField data = BaseField["m_Component.Array"][0];
                                AssetPPtr pptr = AssetPPtr.FromField(data["component"]);

                                if(pptr.FileId == 0)
                                {
                                    AssetTypeValueField transform = manager.GetBaseField(afileInst, pptr.PathId);

                                }
                            }```
#

this thing pretty much works like unity transforms

#

so yea

#

anyways thanks for the help

#

its really appreciating

pliant oyster
#

Hi, does anyone know why my code does not work?

void OnMouseOver()
{
    Debug.Log("Mouse Over");

    if (currentScale.x >= originalScale.x * (1 + scaleModifier) && !invertCheck)
    {
        bounceSpeed = -bounceSpeed;
        invertCheck = true;
    }
    else if (currentScale.x <= originalScale.x && invertCheck)
    {
        bounceSpeed = -bounceSpeed;
        invertCheck = false;
    }

    currentScale = new Vector2(currentScale.x + (bounceSpeed * Time.deltaTime), currentScale.y + (bounceSpeed * Time.deltaTime));
    transform.localScale = currentScale;
}
```It doesn't even print the "Mouse Over".
#

I have it on a Button on a Canvas. I made sure to also add a BoxCollider after it didn't work the first time.

pliant oyster
#

Yes

willow scroll
#

The method OnMouseOver only works when you have a Collider and a suitable layer

languid spire
ivory bobcat
pliant oyster
willow scroll
pliant oyster
#

Okay so it only checks when the mouse enters, not when the mouse is over the GameObject. How do I do that?

languid spire
ivory bobcat
#

Pretty good idea. I would have suggested a bool to be set true on entry and false on exit with some code evaluating said bool in Update.

languid spire
#

works just as well, i find Coroutines cleaner for this kind of thing

pliant oyster
#

I don't know coroutines and never worked with them so I will use Dalphat's solution. Thank you!

languid spire
pliant oyster
pliant oyster
#

Ah okay! Thanks, I will try that!

abstract finch
#

How complex of a problem is it to be able to get the two zombies behind to go towards those spots?

pliant oyster
languid spire
#

and, sorry, that was my bad, I forgot it first too

#

although IEnumerators should not compile without a yield statement

queen adder
#

can anyone tell me why the points system doesn't work


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

public class Objectbehavior : MonoBehaviour
{
[SerializeField] GameObject prefab;
bool _gameOver = false;
int _points = 0;

public void spawnObject()
{
    Instantiate(prefab, new Vector3(Random.Range(-8f, 8f), 6f, 0f), Quaternion.identity);
}

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.tag == "Player" && !_gameOver)
    {
        spawnObject();
        Destroy(gameObject);
        _points += 1;
        Debug.Log(_points);
    }
    else if (collision.gameObject.tag == "ground")
    {
        _gameOver = true;
        Debug.Log("GAME OVER! YOU LOOSE!");
    }



}

}

ivory bobcat
queen adder
#

point system

ivory bobcat
#

If you're wanting points to persist between instances, you ought to have something that isn't destroyed hold the point variable.

#

The dirty solution would be to have points be static and assigned in Start - bandaid solution.

fair temple
#
        bool canMove = !Physics.Raycast(transform.position, moveDir, playerSize);

        if (canMove)
        {
            transform.position += moveDir * moveSpeed * Time.deltaTime;
        }

im trying to prohibit to passing into the wall but i cant see any problem but still can pass through to wall

timber tide
#

raycast may be originating inside of the wall

fair temple
#

any advice ?

timber tide
#

well, are you sure it's detecting the wall at all first

fair temple
#

idk what should i do

#

wall isnt detecting

timber tide
#

what I would do is make a larger raycast and make sure it's pointing in the direction you're moving

#

and debug that it's hitting something first off

fair temple
#

i fixed with decreasing value of movedirection * movespeed and delta time

#
 if (canMove)
 {
     transform.position += moveDir * moveSpeed * Time.deltaTime;
 }
 else
 {
     transform.position -= moveDir * moveSpeed * Time.deltaTime;  
 }
lime pewter
#
Debug.Log(liquidType.maxFill / liquidType.viscosity + " this is min fill");

"maxFill" = 1f", and "viscosity = 9" why does Unity somehow output 0.133333?
I understand there is a float point error but where does Unity pull the 0.133333 when the true answer should be 0.1111111, even if it's not fully accurate an entire 0.02+ off seems excessive.

swift crag
#

oops, wrong reply

swift crag
swift crag
lime pewter
swift crag
lime pewter
# swift crag log the values **immediately** before you use them

Yeah no you were 100% correct, I am realizing the reason my prior checks weren't working is since I was checking in a class declaration even though the actual "maxFill" was altered in a scriptable object which was actually being evaluated as "1.2" even though the class declares "1.0" initially.

#

Appreciate the help!

swift crag
#

that'll do it (:

#

Log early and often when you're getting weird behavior like that

#

(or attach a debugger)

lime pewter
swift crag
#

GPUs can emit a lot of very creative text.

lime pewter
#

AI can be extremely insightful and give some pretty good direction on where to go a lot of the time, and other times it assumes my code is Chinese and will respond in Chinese, there is a lot of variability lol.

dim hawk
#

Hello, Is making an idle game easy? I have a slight programming knowledge but on game development im still a begginer.

lime pewter
swift crag
#

idle games have the advantage of not involving movement, physics, etc.

lime pewter
#

However, if you're using Unity a lot of people struggle with UI which is 90% of an idle game.

swift crag
#

at least, they don't have to

#

UI is actually pretty easy if you take a bit of time to read the manual thinksmart

#

Unity doesn't help with its bad defaults, though

#

layout groups should absolutely not default to force-expanding children

lime pewter
swift crag
#

all you need to know is:

  • RectTransform anchors and pivots
  • LayoutGroups and LayoutElements all the way down for auto-layout
#

The problem is that these bad defaults make broken UIs kind of work

#

until you do something that makes them fall apart and explode

#

and then you have to fix all the bad defaults to get something that actually behaves

lime pewter
#

Haha, yeah.

rotund egret
#

whats the most beginner way to make objects look at other objects in unity 2D?

#

:/

swift crag
#

setting transform.right or transform.up to a direction will rotate the transform

rotund egret
#

Hm how do i set them up tho?

swift crag
#

set what up?

next ravine
#

to make 1 object face the other mathematically id assume youd do this
?

#

as the simplest way

polar seal
#

hey guys, i have a little question

how i create a simple script for instantiate any props like a Tetris in 2D game ?
i'm begginer 😅

wintry quarry
swift crag
wintry quarry
#

oh

#

then

#
theObj.transform.right = (otherObj.position - theObj.transform.position);```
next ravine
#

positioon

ashen ridge
next ravine
#

wouldnt the trig method work too?

swift crag
#

sure, but I prefer to let Unity do the math for me

#

I do very little trig

wintry quarry
#

sure but - then what do you do with AngleToRotate?

#

feed it into more stuff

#

I like to keep it simple

next ravine
#

yeah i didnt know unity could do it for you

#

thats nice

swift crag
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rotund egret
#

how do i get theobj do i just do gameobject? or give it its own self?

swift crag
#

So surely you know what object you want to look at, right?

#

theObj is the thing you're rotating. If it's the object your component is attached to, you can just use your own transform

rotund egret
#

i want the object i have rn to look at other object

#

the object its self

wintry quarry
#

If you want "itself" then that will just be transform in a script attached to it

rotund egret
#

Mhm let me try

#

transform.right = (Player_Object.position - transform.position);
like this?

wintry quarry
rotund egret
#

but im getting an error with that

wintry quarry
rotund egret
void raptor
#

ive added these buttons, resume should disactive the menu and quit should make you go back to the main menu but the buttons when i click them it doesnt work. i did the same thing in another scene and the buttons worked.

wintry quarry
rotund egret
#

the error is gone wait

wintry quarry
rotund egret
#

it works tysmmm i learned smth new lets go

void raptor
stiff briar
#

Uhh hi
as someone who's not familiar with Unity's Syntax at all
Where should i start?
Should i memorize every basic command or there's a place where i can find the syntax that i need to do what i want?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

stiff briar
#

ok thx!

obtuse axle
#

Hello I have a problem with a collision script : I have an invisible box and a player. I want the box to teleport the player somewhere upon contact. In solo mode, everything works because the player is already on the scene. However, in multiplayer mode, since i use Photon 2 and my player is a prefab, it doesn't work since the players aren't on the scene yet since i have to spawn a player each time someone logs in the room. Here's my code for the collision script and if someone could help me i'd be grateful.

atomic yew
#

The person who prepared the video has three places in the on value changed section. The object with a piece of code is the name of the second function, but I also have a place where it says 0. I guess that's why I can't print the slider value on the screen properly.

#

Why do I have 4 parts and the guy has 3?

abstract finch
raw ledge
#

Hey im trying to make interract two prefab together, so I put them as siblings of a prefab "ball+ui", but when I do .Transform.GetChild(0) and .Transform.GetChild(1) to interract with them it uses the two prefab that are outside my "ball+ui" so I can't make them interract together, anyone got any ideas ? peepohappy

ruby python
#

Hey all, I'm having a really weird issue and I'm not sure what the problem is, as this was working perfectly as of this morning.

I have a turret controller that points at the player. The problem is, the whole turret (base and turret) rotate to face the player, and I'm really at a loss as to why.

Turret Controller Code
https://hastebin.com/share/uwiluxadux.csharp

Turret setup image attached.

raw ledge
tepid steeple
#

Assets/Scripts/CustomNetworkManager.cs(6,26): error CS0115: 'CustomNetworkManager.OnServerAddPlayer(NetworkConnection)': no suitable method found to override

using UnityEngine;
using Mirror;

public class CustomNetworkManager : NetworkManager
{
public override void OnServerAddPlayer(NetworkConnection conn)
{
base.OnServerAddPlayer(conn);

    if (numPlayers >= 2) // 2 veya daha fazla oyuncu olduğunda sahneye geç
    {
        ServerChangeScene("SetGame");
    }
}

public override void OnServerSceneChanged(string sceneName)
{
    if (sceneName == "SetGame")
    {
        // SetGame sahnesine geçildiğinde, burada oyunu başlatma veya ayarlama işlemleri yapılabilir
        // Örneğin, SetGameController'dan seçim UI'sını etkinleştirmesini isteyebiliriz.
        GameObject setGameControllerObj = GameObject.FindWithTag("SetGameController");
        if (setGameControllerObj != null)
        {
            SetGameController setGameController = setGameControllerObj.GetComponent<SetGameController>();
            setGameController.EnableSelection();
        }
    }
}

}

can someone help me i cant figure out my fault

wintry quarry
languid spire
#

ok, a method signature is the method declaration in the code.
the base is NetworkManager.
so post the NetworkManager.OnServerAddPlayer declaration

golden blade
#

hello

#

does unity

#

support having multiple windows for a game

#

Like this

tepid steeple
#
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using System.Diagnostics;

public class NetworkManager : MonoBehaviourPunCallbacks
{
    void Start()
    {
        // Connect to Photon servers
        PhotonNetwork.ConnectUsingSettings();
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("Connected to Photon servers");
    }

    public void CreateRoom()
    {
        PhotonNetwork.CreateRoom(null); // Create a room with default room options
    }

    public void JoinRoom()
    {
        PhotonNetwork.JoinRandomRoom(); // Join a random available room
    }

    public override void OnJoinedRoom()
    {
        Debug.Log("Joined room");
        // Load your game scene or lobby scene here
    }
}
ruby python
#

!code

eternal falconBOT
wintry quarry
golden blade
#

damn

wintry quarry
#

It supports multi monitor but not multi window

languid spire
golden blade
#

idk how to go about changing this then ty for the info

tepid steeple
#

I am using Mirror but this code import photon?

languid spire
#

Do you understand even basic C# ?

tepid steeple
#

Yes i got the error there is no OnServerAddPlayer there

languid spire
#

the NetworkManager code you posted is Photon but it is not in a namespace, why do you have Photon scripts in your project if you are using Mirror?

frank zodiac
#

why does my Vector3.Lerp stop at 5.9998 instead of 6?

rich adder
tepid steeple
rich adder
frank zodiac
#

okay thank you

languid spire
tepid steeple
#

this is for my final project

#

i dont even make games

#

Im just working on Java Spring boot

#

Im not fan of C# and Unity

summer stump
#

We can tell

languid spire
#

Then I suggest you go and do something else because you will get nowhere like this

tepid steeple
#

Submit deadline is tomorrow sadok

summer stump
#

Well, you are not likely to make that deadline. Sorry

#

Seems rude of them to give you a project like this with no teaching about unity or c#

tepid steeple
#

yes our lecturer did not use Unity even once in class only made us watch videos.

rich adder
#

another quack then?

tepid steeple
#

thats why i dont understand anything

languid spire
#

there is no way you were given a Networking project without a great deal of tuition

tepid steeple
#

he did

#

he gave us

#

im saying he even didnt open the unity .

languid spire
#

Listen, even very experienced game devs quake in their boots at the mere mention of networked games

#

on a scale of 1 to 10 in difficulty they rate about 1,000

tepid steeple
#
using Mirror;
using System.Diagnostics;

public class NetworkManager : NetworkManager
{
    void Start()
    {
        // Start the network client
        StartClient();
    }

    public override void OnStartClient()
    {
        Debug.Log("Connected to Mirror server");
    }

    public void StartGame()
    {
        // This method could be called to start the game once all players are connected
        ServerChangeScene("GameScene"); // Change to your actual game scene name
    }

    public override void OnServerAddPlayer(NetworkConnection conn)
    {
        // Override this method to handle player spawning
        GameObject player = Instantiate(playerPrefab);
        NetworkServer.AddPlayerForConnection(conn, player);
    }

    public override void OnServerSceneChanged(string sceneName)
    {
        // Override this method to handle scene changes on the server
        if (sceneName == "GameScene")
        {
            // Perform game setup logic here
        }
    }
}

eternal needle
tepid steeple
#

No, i didnt choose anything

#

all im saying is true he gave us multiplayer project

frank zodiac
#
private void Update()
{
    Vector3 target = pointB;
    Vector3 currentVelocity = Vector3.zero;

    transform.position = Vector3.SmoothDamp(transform.position, target, ref currentVelocity, Time.deltaTime, maximumSpeed);

    if (transform.position == pointB)
    {
        target = pointA;
    }
}

it goes to pointB successfully but then it wont go back to pointA for some reason

tepid steeple
#

He DID!

languid spire
#

I don't want to be rude, but you literally cannot get to where you need to be from where you are in 24 hours. So just stop

eternal needle
#

And you chose unity? Theres absolutely no way they said use unity and the whole class doesnt revolt against this and go to the dean.

slender nymph
tepid steeple
#

there is no pdf

#

just whatsapp messages

rich adder
#

lmao what

eternal needle
tepid steeple
frank zodiac
languid spire
#

At this point you are just being a troll

quick pollen
#

Can I use the Animator to call functions using UnityEvents somehow?

rich adder
quick pollen
#

I've seen this but im not sure how to use it

rich adder
tepid steeple
# tepid steeple

Multiplayer phone game for four and a half year old girl
Only the network communication technology will be mirror and will work in the local network. In the network, the client will be able to find the server. There are codes for this in the mirror
Those who use libraries other than Mirror or those who do not use any network remain the same.
On a smartphone, the game should fit well on the screen and the interface should not be overwhelming. There must be at least 4 levels and each level must be one level harder. If the game is time-based, the time should be optimized, neither too fast nor too slow. Two people must be in the same game. There may be other styles of play, such as against each other or both against a common enemy.

However, in order to unite the players online, an intermediary server that uses a technique called network punchthrough is required. For this, you can use a unity service called relay server.
You can search for unity relay server and see the details.
We want a local network in the final assignment. The other player must be able to find the server on the local network. Mirro has the necessary sample and source codes for this.
So they will not communicate by entering the IP number.

ashen ridge
#

Check the first line in the update method

quick pollen
frank zodiac
#

didnt notice that

rich adder
ashen ridge
#

Xd

eternal needle
quick pollen
rich adder
#

drag that one, not the script from project folder

quick pollen
#

im not sure what you mean

rich adder
#

Oh wait this is a Animator state

#

just realized

quick pollen
#

yes

ashen ridge
quick pollen
tepid steeple
#

do it

rich adder
#

I thought you first wanted Animation Events to call a function lol

quick pollen
#

oh yeah no that would be simple I think

#

let me check....

ashen ridge
quick pollen
#

nope

tepid steeple
#

😸

#

There is why im asking here

quick pollen
rich adder
quick pollen
rich adder
#

You cant drag scene event because the Animationstate is isolated from scene

quick pollen
#

yeah I know

#

still tried tho lol

#

what do you mean then by AnimationEvents

#

or like

rich adder
quick pollen
#

how can I make it so at a specific point in an animation, a function from a script gets called

rich adder
#

thats what I'm telling you lol

#

Animation Event

quick pollen
rich adder
#

yes the Instance thats playing the controller

#

aka the gameobject that has the animator

#

when you do so it will give you a dropdown of all the methods that are on a script on the same object

quick pollen
#

greyed out

#

cant click

rich adder
#

its part of the FBX

#

clone animation clip to modify them

quick pollen
#

that sounds really bad

rich adder
#

or just make the FBX read/write

#

this is a specific unity thing that has nothing to do with animator, its how FBX are packaged

quick pollen
#

how can I do that

tepid steeple
#

Please help me about NetworkManager 😿

rich adder
summer stump
# tepid steeple There is why im asking here

Tell him that this is beyond the scope of what you can do and will not be completing it. It is inappropriate to assign an assignment based on something that has not been taught and without being explicit about prerequisit knowledge before the class starts.
Tell him you will be taking this to the dean if he doesn't remove this assignment from your grade

quick pollen
#

would this mess anything up when updating the fbx?

rich adder
tepid steeple
summer stump
quick pollen
#

the animations are still readonly

rich adder
ruby python
# tepid steeple He didnt know

Hang on, how can he assign a project, and then expect to grade it if even he doesn't know how to do it? I smell bullshit tbh.

rich adder
#

wasting time and flooding chat

tepid steeple
#

NO WAY

#

IM NOT LYING

quick pollen
ruby python
tepid steeple
#

BECAUSE U HAVENT TAKE LECTURE IN TURKEY

summer stump
#

Go to the dean. You WILL NOT receive the help you need here. It is beyond what we can do

ruby python
#

Any game in 24 hours is virtually impossible (I stress virtually).

rich adder
#

let me see if I missed something on how to make animation not-read only directly in FBX

quick pollen
# rich adder yes

yeahh fuck that I'll just use an animatorhandler like I did before and just use import events

ruby python
rich adder
#

apparently duplication is the only way

#

bummer

rich adder
swift crag
#

I would avoid this at all costs.

#

It means that if you modify the animation, you have to completely replace the existing animation clip asset

#

Now all of your references to it are broken, since you deleted the existing asset

#

I guess you could manually copy all of the new data into the existing asset

swift crag
#

specifically, the Animation section

#

You can attach animation events to the importer animation clips there.

#

You can also configure stuff like Loop Time, add custom curves, etc.

#

I never pull animation clip sub-assets out of imported models.

quick pollen
#

i have a different method for it

#

I already had events working

#

I was just hoping i could do it easier

swift crag
#

what could be easier than this?

quick pollen
#

yeah thats what im doing

#

I just need to have this animator thing which actually calls the function

swift crag
#

yes, that's a given

#

the animation event has to be received by something

quick pollen
#

i cant directly call any function sadly

quick pollen
swift crag
#

You never "directly call a function".

#

If you get a dropdown to pick a function name from (I believe that appears when you're editing an animation clip with a specific animator selected?), that's still just filling in the Function field

quick pollen
rich adder
#

its the same thing, one gives you a dropdown and one doesn't
dropdown shows up when you selected the animation when you have object with said Animator selected

quick pollen
#

how

#

what

swift crag
# quick pollen whuh

Either you haven't applied your changes in the importer or you're using the wrong animation clip

#

Or you have multiple animation events

quick pollen
#

i forgot to apply appareantly

#

i didnt even know it allows you to enter playmode without applying import settings???????

swift crag
#

It only complains if you try to leave the importer settings.

#

(and you have to manually apply them because that triggers a re-import of the asset)

#

You aren't directly editing the animation clip. You're editing settings on the importer.

quick pollen
#

i entered my gameobject thing multiple times to check other stuff

rich adder
#

normally it prompts you

swift crag
#

actually, I also got a warning when I tried to enter play mode with unsaved changes

quick pollen