#💻┃code-beginner

1 messages · Page 270 of 1

eternal falconBOT
rich adder
#

no screeshots

quartz mural
#

ok

#
public class BattleUnit : MonoBehaviour
{
    [SerializeField] bool isPlayerUnit;
    [SerializeField] BattleHud hud;

    public bool isPlayerUnit
    {
        get { return isPlayerUnit; }
    }

    public BattleHud Hud
    { get { return hud; } }
    public Pokemon Pokemon { get; set; }

    Image image;
    Vector3 originalPos;
    Color originalColor;

    private void Awake()
    {
        image = GetComponent<Image>();
        originalPos = image.transform.localPosition;
        originalColor = image.color;
    }

    public void Setup(Pokemon pokemon)
    {
        Pokemon = pokemon;
        if (isPlayerUnit)
            image.sprite = Pokemon.Base.BackSprite;
        else
            image.sprite = Pokemon.Base.FrontSprite;

        hud.SetData(pokemon);

        image.color = originalColor;
        PlayerEnterAnimation();
    }

    public void PlayerEnterAnimation()
    {
        if (isPlayerUnit)
            image.transform.localPosition = new Vector3(-500f, originalPos.y);
        else
            image.transform.localPosition = new Vector3(500f, originalPos.y);

        image.transform.DOLocalMoveX(originalPos.x, 1f);

    }

    public void PlayerAttackAnimation()
    {
        var sequence = DOTween.Sequence();
        if (isPlayerUnit)
            sequence.Append(image.transform.DOLocalMoveX(originalPos.x + 50f, 0.25f));
        else
            sequence.Append(image.transform.DOLocalMoveX(originalPos.x - 50f, 0.25f));

        sequence.Append(image.transform.DOLocalMoveX(originalPos.x, 0.25f));

    }
rich adder
#

property is still wrong..

#

I dont understand, you did it correct for the other one..

quartz mural
#

yes ik

#

im lost

rich adder
#

so why are you struggling with a bool

#

its literally the same concept

#

C# is case-sensitive

quartz mural
#

look now i don this

#

but im gettin this

rich adder
#

exactly

quartz mural
#

and if i change this one to a capital i

rich adder
#

the error now tells you why

quartz mural
#

then they arnt linked naymore

rich adder
#

wdym aren't linked ?

quartz mural
#

ill show u the error

rich adder
#

the error tells you the permission issue

#

i know the error, im saying do you ?

quartz mural
#

im talkin abt from the console

rich adder
#

alr

quartz mural
#

ill show u

#

theres no problem 😭

#

i swr there was before

#

omd im such an idiot

#

aplologies

rich adder
#

u good lol

#

suggest maybe refresh on some basic c#

quartz mural
#

👍

honest vault
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
#

setup was just as easy as vs imo, plugin was right there in the marketplace, and the editor package was already installed in my version of unity

rich adder
#

I wonder why your colors are blue for MB

#

which theme are you using ?

rocky canyon
#

idk, i just clicked one of the dark themes..

#

oh w8 it may not be completely setup yet

rocky canyon
#

there we go

#

i didnt have the sdk

rich adder
#

for some reason. it struggles with that

rocky canyon
#

ya i had to manually install it

#

even tho the dev-kit supposedly supposed to handle that for me

#

automatically having to hunt for shortcuts 😄

rich adder
#

they are wildly different than VS

cosmic dagger
rocky canyon
#

just playing with it..

#

really wanted to see how the install process differs from vs so i have context when i see all these guys struggling for days trying to config vscode

#

sooo need a snippet plugin too i imagine

#

sure feels more complicated than VS tho.. with all this debug text everywhere lol

#

I see myself sticking with VS unless Code somehow wins me over..

north kiln
#

Stupid naming conventions really making for a confusing time. Some of these are infinite loops, others aren't, be extra careful the property doesn't refer to itself

cosmic dagger
north kiln
#

It's very easy

cosmic dagger
#

That's good to hear . . .

karmic mulch
#

BulletController

#

oh im dumb

#

in tutorial file name is BulletController

karmic mulch
#

somone can help

karmic mulch
rich adder
ebon robin
#

hey does disabling reloading domain breaks something from packages? Like my code doesn't have much static event handlers or static variables but i wonder if packages have problems

charred spoke
#

Official unity packages ? No.

#

Third party? Who knows….

misty coral
#

Why are there only options for Ontriggerenter 2D

#

why is there no base or 3d option

north kiln
misty coral
#

I want the onTriggerEnter methods but they are not present here for some reason

north kiln
#

No idea, I use Rider

random cave
#

Can someone tell me all the different types of GetComponent

#

Like I know theres one for children and parents

#

but what if its on the same area

summer stump
#

There is plural (GetComponents) which returns an array
Then the parent and children, as well as plurals for those

#

That's it

north kiln
#

They are all listed in !docs

eternal falconBOT
summer stump
#

What do you mean same area though

random cave
random cave
summer stump
north kiln
random cave
north kiln
summer stump
random cave
#

There might not even exist what I am looking for

#

Fine i will read the zzz docs

#

yeah it doesnt exist i think

north kiln
#

Traverse to the parent via the transform and look in it's children with GetComponentInChildren.
Or preferably, just serialize a reference and don't do any of that

random cave
#

No no

#

let me show you

#

If I had a script on B that wanted something from A how would I do that

north kiln
#

Exactly what I said, or explicitly access the specific child from the parent

random cave
#

yeah but wont that conflict if B has the same component

#

or does that go by hierachy order

north kiln
random cave
#

I guess so

#

Thanks

lone comet
#

Can I use relative file paths with AssetDatabase.LoadAssetAtPath?

i.e. AssetDatabase.LoadAssetAtPath("./myFileAtTheSameLocation.txt");

#

From my current testing, no.... no you can not.

carmine turret
#

Alright so Im at the stage where my character can move up slopes (2d) but if you stop moving they slide down, and if they move over a slope from a flat surface, you fly over instead. and recommendations? 🙂

#

Turns out my tilesets just had poor collissions before, hence why I couldnt go up them aha

stoic glen
#

Placement System with Grid doesn't work

foggy crypt
#

I got it 🙂

gleaming kraken
#

junior programmer pathway is so dumbed down it's actually funny

#

a literal 80 year old person could learn from that

acoustic crow
#

!code

eternal falconBOT
delicate portal
#

!collab

eternal falconBOT
analog glen
#

Hello. How I can save x rotation of object as variable?

ivory bobcat
#

Note that rotation uses quaternion and that the euler angle would not always be the same

frank delta
#
    private void GetNeighbor()
    {
        Collider[] ph;
        ph = Physics.OverlapSphere(transform.position, 1f, gameObject.layer);
        foreach(Collider col in ph)
        {
            _neighbors.Add(col.gameObject.TryGetComponent<MapTile>);
        }
    }

why isnt this possible?

gaunt ice
#
_neighbors.Add(col.gameObject.TryGetComponent<MapTile>);
Method(XXX.TryGetComponent<MapTile>);

btw TryGetComponent returns you a bool

olive storm
#

is the a way too make items invisble too the player using it but not invisble too other players im using open xr and pun

fickle plume
#

!mute 1009460584057679943 1d ignoring warnings

eternal falconBOT
#

dynoSuccess foxycrafty1 was muted.

frank delta
frank delta
ivory bobcat
#

Do you want it to be added if it's null?

#

If not, consider using an if statement and placing the addition of neighbor inside

analog glen
scarlet skiff
teal viper
sour ruin
#

Hi, I've been going through a big refactoring and there are a lot read only values in my player controller class such has head rotation range, and a number of scriptable object assets that govern data pertaining to player states. As these are persistent read only values between all players, should they instead be stored in a global singleton reference? My thinking is that on the one hand it doesn't make sense to manually drag and drop scriptable object assets onto players/ rely on prefabs where these values are already set, but it also feels wrong to expose the data to everything in the scene (even though it is private set;). What is correct here?

teal viper
#

If not, perhaps pass these settings to the player when it's instantiated

sour ruin
#

At some point I intend to make it multiplayer but I haven't looked into the details of the implementation. My guess is that its multiple instances on start?

hidden sun
#

hi, i made methods from the cloud code subscription messages anonymous functions, but when i try to unsubscribe it doesn't work.. i think i'm missing something. https://hastebin.com/share/awehasezic.csharp

frank delta
#

I know I have google but I after searching I still have no idea what is wrong

    private void GetNeighbor()
    {
        Collider[] ph = Physics.OverlapSphere(transform.position, 1.5f, this.gameObject.layer);
        foreach(Collider col in ph)
        {
            if(col.gameObject != this.gameObject)
            {
                col.gameObject.TryGetComponent<MapTile>(out MapTile neighbor);
                Debug.Log(neighbor);
                _neighbors.Add(neighbor);
            }
        }
    }

My overlapSphere is not returning anything

#

they share the same layer

#

this is what suppose to be happening

burnt vapor
#

Other than that perhaps try a really big radius and see if it works. perhaps it's too small.

frank delta
#

no no the code works, the only screwed part is the layer

#

without the layer checking part everything works

#

but it will lead to assigning other things that it shouldnt later down the line

#

problem is the overlapping sphere is not registering the layer correctly

zenith cypress
#

Because raycasts take a bitmask, not a layer index. 1 << gameObject.layer, or if you know what it is already LayerMask.GetMask("LayerName")

swift crag
frank delta
#

huh neat

hidden sun
#

i need colider for OnMouse functions?Solved: yes

exotic hazel
#

could someone tell me the meaning of instance here

#

i dont know what instance is

wraith valley
#

I can`t use Texts text for changing value

swift crag
exotic hazel
#

it is from a tutorial but he didnt explain instane

languid spire
#

It means that the AddToInventory method must be called on an instance variable of the InventorySystem class
this is why you should post code properly so I don't have to type so much

swift crag
swift crag
exotic hazel
#

there are 44 tutorials and im alr not understanding anything at 5th

swift crag
#

this is a common way to implement a singleton

wraith valley
exotic hazel
#

ublic static InventorySystem Instance { get; set; }

public GameObject inventoryScreenUI;
public bool isOpen;


private void Awake()
{
    if (Instance != null && Instance != this)
    {
        Destroy(gameObject);
    }
    else
    {
        Instance = this;
    }
}


void Start()
{
    isOpen = false;
}


void Update()
{

    if (Input.GetKeyDown(KeyCode.I) && !isOpen)
    {

        Debug.Log("i is pressed);
        inventoryScreenUI.SetActive(true);
        isOpen = true;

    }
    else if (Input.GetKeyDown(KeyCode.I) && isOpen)
    {
        inventoryScreenUI.SetActive(false);
        isOpen = false;
    }
}

}

swift crag
swift crag
#

That will let you reference a TextMeshPro (for non-UI text) or TextMeshProUGUI (for UI text)

swift crag
#

if nothing exists, it stores itself into that static property

#

otherwise, it destroys itself

wraith valley
# swift crag If you want to use a TextMeshPro component, then use `TMP_Text` instead of `Text...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class addScore : MonoBehaviour
{
    public TMP_Text scoreText;
    // Start is called before the first frame update
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Score.score++;
        scoreText.text = Score.score.ToString();
    }

    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
}
#

Help please

#

That`s have to add score

#

Triggered but doesn`t work

burnt vapor
# exotic hazel could someone tell me the meaning of instance here

In your case Instance would be a property or field. If InventorySystem corresponds to a class type, then Instance is a static property or field because you are not calling it from an instance. Do not be confused by the name because the point is getting to a valid instance in this case, which is the idea of a singleton pattern. That's why the property or field itself was named Instance here. If InventorySystem were a property or field, then Instance would not be static.

swift crag
wraith valley
#

Yes

scarlet skiff
#

Why did my Flip method stop working? i believe the only change i have made was changing the name of the object which has this script from "player" to "body" and then parenting it under a newly made empty object.

Full script: https://gdl.space/uqeguzuzag.cs

languid spire
#

scoreText is null

swift crag
wraith valley
swift crag
#

Okay, that's one instance of Add Score

#

Perhaps you have another one.

#

Click on the error once in the console and unity should highlight the object that produced the error in the hierarchy

swift crag
#

(unless it's already been destroyed)

wraith valley
#

Nothing

swift crag
#

This is your code editor.

#

you will not see any errors in the code editor; this is a runtime error

#

look in the unity console and click on the error.

ivory bobcat
# exotic hazel could someone tell me the meaning of instance here

I'm not certain if it's been mentioned yet but that would be the variable you'd use to access the single instance of said object - Singleton pattern. It's one of the few reasons why most opt to use Singletons - for ease of access by having a static member associate with an instance but accessible via class.

wraith valley
#

I did it

swift crag
#

Do this while the game is running. It may show you which object caused the error.

#

Click once. Double-clicking opens your code editor.

wraith valley
#

That`s all what showing me

#

Similar issues

scarlet skiff
swift crag
burnt vapor
swift crag
wraith valley
#

I can move to Visual Studio

#

It`s all

scarlet skiff
swift crag
wraith valley
swift crag
#

Clicking once will not open Visual Studio.

wraith valley
#

Is it?

burnt vapor
swift crag
#

Click on the error message. Do not double click on the error message. Do not click on the blue link.

If this does not highlight something in the hierarchy, then turn on Error Pause so that the game pause after an error. When the error happens, search for this in the hierarchy:

t:addscore

wraith valley
swift crag
swift crag
ivory bobcat
swift crag
#

one is attached to the GameManager

swift crag
#

I bet the animator is controlling it.

#

unless your code is already constantly setting the rotation

scarlet skiff
ivory bobcat
#

Likely something has constrain it then

scarlet skiff
swift crag
#

The animator will always write to every single property that any of its animation states controls

#

(and no, disabling Write Defaults doesn't stop this)

ivory bobcat
#

Assuming the changing of it's name isn't the issue, what object did you child/parent this to?

scarlet skiff
#

bro... idk what i did but it started working...

wraith valley
#

That`s one

swift crag
wraith valley
#

That`s object of text

swift crag
#

you checked that one of them is set up correctly

#

but what about GameManager?

wraith valley
#

I mean TMP

wraith valley
# swift crag but what about GameManager?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{

    public GameObject gameOverCanva;
    public AudioClip audioClip;
    private AudioSource audioSource;

    // Start is called before the first frame update
    void Start()
    {
        audioSource = gameObject.AddComponent<AudioSource>();
        audioSource.clip = audioClip;
        audioSource.loop = true;
        audioSource.Play();
       
       
    }

    public void gameOver()
    {

        SceneManager.LoadScene(0);
       
    }

    
    // Update is called once per frame

  
    void Update()
    {

    }
}
swift crag
#

You need to look at the game object.

languid spire
#

that is the gamemanager script not the gamemanager object

#

show the inspector

swift crag
# wraith valley That`s object of text

I don't care what else is attached to those objects. Those two objects have AddScore components on them. You need to make sure that the AddScore components are set up correctly.

wraith valley
languid spire
#

there you go

swift crag
#

every object in the hierarchy must have an AddScore on it

#

I think I forgot to explain what that search meant!

ivory bobcat
#

You've got some "None"s here that you might want to consider evaluating.

swift crag
wraith valley
swift crag
wraith valley
#

There`s

swift crag
#

There it is.

#

That's what's actually causing the error.

#

The AddScore components on your GameManager and on your scoreText objects weren't doing anything.

#

since those objects did not have colliders on them at all

#

The object with between the two pipes is the problem.

#

You're going to need to assign a reference to scoreText after you spawn the pipe prefab.

#

because the prefab has no way to get that reference otherwise

#

it's not part of the scene when the game starts

ivory bobcat
#

It could be though (hidden/moved after the scene loads)

wraith valley
#

But that`s prefab

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

public class Pipe_Spawner : MonoBehaviour
{
    public GameObject pipe;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
            GameObject newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
            Destroy(newPipe, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
#

Random generation

ivory bobcat
#

Right, so set the field after you've created the pipe

#

newPipe.whatever = ...

#

Meaning you'll have to reference it by the specific component type

#

public AddScore pipe

scarlet skiff
#

Sometimes the bombs dont "split", they technically do but i assume they immedietly touch the ground or something? which i have code for, if htey touch the gorund they explode, the problem is, as you can see in the screenshot, i tried to solve this by making them spawn a little above the ground, yet they still explode many times, before having hte chance to move, do i then simply increase the elevation of the point they spawn at? or is there some clever way to go about this, cuz im worried if i elevate them too much it will looks weird, since the point is that it looks like the bomb is splitting

wraith valley
#

Don`t undestand

ivory bobcat
#

If the pipe doesn't have the score and it's on a child object, you'll need to either have a script on the pipe that gives access to the trigger or call get component on child to acquire the necessary component - assuming it's on a child object.

swift crag
#

You can reference a prefab as a GameObject or as any component on the object.

wraith valley
#

Pipe doesn`t have

#

Just movement

swift crag
#

well, then add it!

#

Put an AddScore field on it.

#

Reference the AddScore component.

#

Then, instead of referencing the prefab as a GameObject, reference it as a Pipe.

wraith valley
#

And add AddScore script in inspector?

swift crag
#

You’d reference it in the prefab, yes

#

Then, whoever instantiated the pipe can give it a reference to the score text

wraith valley
#

That`s for trigger field have behaviour OnTrigger from that script?

#

In every pipes

swift crag
wraith valley
swift crag
#

OnTriggerEnter2D uses the scoreText field to change the text that is shown

wraith valley
#

That`s for adding behaviour of OnTriggerEnter2D in addScore script?

ivory bobcat
wraith valley
#

But that`s have trigger field already

swift crag
#

You need a way to set up the scoreText field.

#

You only have a Pipe.

#

You don’t have the AddScore component.

wraith valley
swift crag
#

There is no “trigger field”. I don’t know what you’re referring to here.

#

Do you mean that there are trigger colliders?

wraith valley
ivory bobcat
#

It'd eventually look something like cs Pipe newPipe = Instantiate(...); ... newPipe.addScore.scoreText = myRefToTheScoreTextKnownByTheSpawnerThatsAlreadyInTheScene;

wraith valley
#

I clicked isTriger

swift crag
wraith valley
#

That`s should be easier?

#

Type mismatch

swift crag
#

Yes. You can't reference scene objects from a prefab.

#

That's why we're doing this.

young wren
#

Hi i added some code like this

using UnityEngine;
using UnityEngine.EventSystems;

public class StopPropagation : MonoBehaviour, IPointerDownHandler, IDragHandler
{
    public void OnDrag(PointerEventData eventData)
    {
        eventData.Use();
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        eventData.Use();
    }
}

To prevent propagation of touch / drag / click etc... from my UI panel into game but this seems not working at all any idea how it should be done correctly?

ivory bobcat
#

Did you make sure to change the stuff in the spawner from Game Object to the appropriate type Pipe?

swift crag
#

type mismatch in the inspector

#

not a compile error

wintry quarry
#

normally this shouldn't be needed at all

young wren
#

I have camera script to move / zoom depends on inputs and i want it to dont get signals when someone press something at UI that's above my camera

swift crag
#

if those inputs aren't based on UI events, then this will do nothing whatsoever

wraith valley
swift crag
summer stump
#

!code

eternal falconBOT
swift crag
#

yeah this has nothing to do with UI events

#

If you want to test if your mouse is over a UI element, you can do that

#

EventSystem.current.IsPointerOverGameObject();

young wren
#

I see thanks

swift crag
#

also, I'm not sure even Unity UI events even "propagate"

wintry quarry
#

they don't normally unless you tell them to

wraith valley
#

Hard

swift crag
#

UIToolkit events definitely bubble up

wintry quarry
#

My recommendation is to rewrite your camera controls stuff using the UI events then you get all the nice behavior for free!

ivory bobcat
# scarlet skiff any suggestions?

I wasn't sure what your question initially was but I'm now assuming you meant that the object being below the ground might be causing your secondary explosions to trigger prematurely. If so, maybe have the secondary explosives disable their colliders for a few milliseconds after spawning? (somewhat like an invulnerability frame/time etc)

wraith valley
#

I should create public GameObject triggerField for pipe in pipe script?

swift crag
#

We didn't suggest doing anything like this at all.

#

And you don't need to do anything with the trigger colliders.

#

You need to be able to do this:

var pipe = Instantiate(pipePrefab);
pipe.addScore.scoreText = theScoreText;
#

That's it.

wraith valley
#

Var?

#

Why is not GameObject?

swift crag
#
Pipe pipe = Instnatiate(pipePrefab);
rocky canyon
#

it is in this case

#

well Pipe actually

swift crag
rocky canyon
#

no need to spawn it as a GO just to have to call a getComp on it

swift crag
rocky canyon
#

work smarter not harder

swift crag
#

You can use any component that is on the prefab's root object -- the one that's at the top of the hierarchy.

rocky canyon
#

say a friend of mine gunked up his drop down with unnecessary IDE's and what-not.. if he uninstalls them will they disappear from this drop-down.. im thinking it'll repopulate and remove them if the file path is missing

swift crag
#
[SerializeField] Enemy enemyPrefab;

public void SpawnEnemy() {
  Enemy enemy = Instantiate(enemyPrefab);
  enemy.health = 100;
  enemy.damage = 25;
}
wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public GameObject pipe;
    public TMP_Text tmpText;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
            GameObject newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
          newPipe.tmpText = Score.score;
            Destroy(newPipe, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
ivory bobcat
# wraith valley Why is not GameObject?

You can have a field referenced as the specific component type on the game object rather than simply a game object. You'll still be able to instantiate the pipe object using the component reference.

#

Replace GameObject with Pipe - assuming that's what your pipe script is named.

#

You may have to drag and drop the pipe into the inspector field for your manager again.

swift crag
#

Yes, you will.

wraith valley
#

Pipes are working

swift crag
#

The old reference will be to the GameObject, not to the Pipe.

wraith valley
#

But without points

ivory bobcat
#

Your pipe prefab should have an add score field.

wraith valley
#

Yes

ivory bobcat
wraith valley
summer stump
ivory bobcat
wraith valley
swift crag
#

Yes.

#

Pipe is the type of the variable. It's the kind of thing the variable holds.

summer stump
summer stump
swift crag
# wraith valley

Dalphat meant that your Pipe class should have a field on it that holds an AddScore. You need to add a field to Pipe and assign a reference to the AddScore component in the prefab.

summer stump
#

Can you show the update

scarlet skiff
#

i suppose i should just try

wraith valley
# summer stump It wasn't in the recent code you showed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public Pipe pipe;
    public TMP_Text tmpText;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
       Pipe   newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
          newPipe.tmpText = Score.score;
            Destroy(newPipe, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
scarlet skiff
summer stump
#

Destroy should now be newPipe.gameObject
Otherwise you will just destroy the component

wraith valley
summer stump
rocky canyon
#

just here

#

newPipe now references the script

#

u want to destroy the scripts gameobject

#

(the entire pipe)

#

pipe now seems like a silly word

wraith valley
#

Now nothing

rocky canyon
#

anyone present use vscode?

ivory bobcat
rocky canyon
#

"it wont drag, its not a TMP element.."

wraith valley
#

Doesn`t work

swift crag
#

And, again, you cannot reference a scene object from a prefab

#

That's the entire point of the changes we're making.

swift crag
rocky canyon
#

ya, they're guiding u the right way. just gotta change bit by bit

wraith valley
#

I tried

wraith valley
summer stump
ivory bobcat
wraith valley
summer stump
#

Like which object, and to which object

#

Show a screenshot maybe, circling the two objects involved

wraith valley
#

In trigger field addscore script

swift crag
#

there is no "trigger field". you keep talking about a "trigger field".

summer stump
rocky canyon
#

he's hung up on this

scarlet skiff
#

can someone simply this for me? what does it mean exactly

rocky canyon
#

it means u shouldnt use keywords that are already in use by unity

summer stump
wraith valley
swift crag
summer stump
#

Although it is deprecated

scarlet skiff
#

so its suggesting that i simply use component.collider?

wraith valley
#

I`m noob

rocky canyon
ivory bobcat
# wraith valley In trigger field addscore script

Spawner needs a reference to the Pipe component. Pipe needs a reference to the AddScore component. If you've got it all, you'll be able to drag the pipe into the spawner's field (scene). Drag the score into the pipe's field (prefab).

swift crag
rocky canyon
#

if the script is called Pizza call it pizzaCollider instead

summer stump
swift crag
#

However, the properties remain for backwards compatibility's sake. You get a warning here because you're declaring a member with a name that collides with one of these obsolete properties.

rocky canyon
#

no need to complicate ur scripts already

summer stump
swift crag
eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
# scarlet skiff can someone simply this for me? what does it mean exactly

A long time ago, Unity had built in methods for common components. They have since been deprecated, but for compatibility, the variables have not been removed.

You should either name the variable something different, or add new before the type to let the compiler know you are intentionally overwriting that I used field

real falcon
#

I have an issue where I have a turret and I need the base to rotate towards the player. this works for the hinge part, but the base has an issue. it works, until I put it on the ceiling. since the base is inverted, I believe that something here is causing it to ignore that aspect of the rotation, and just set itself to the vector assuming that "up is world up" if that makes sense

swift crag
#

We've been going in circles for a long time and it sounds like you simply do not understand anything that is going on here

rocky canyon
swift crag
#

That's fine, but it also means that it's very hard for us to help you.

burnt vapor
eternal falconBOT
wraith valley
wintry quarry
scarlet skiff
summer stump
rocky canyon
#

just use a different name

#

myCollider

polar acorn
frigid sequoia
#

Also, I can't quite see this in my head. What does he mean by "the base is inverted on the ceilinf?"

summer stump
#

@wraith valley

Show a screenshot maybe, circling the two objects involved

I don't know where you are dragging it

scarlet skiff
# rocky canyon just use a different name

hold on im trying figure things out, if there was a way to access the collider i dont want to make a variable for it, but that name for it is no longer a thing is what i understood

rocky canyon
#

this also.. you can just call yourComponent.collider to give it the specific collider (if theres multiples)

rocky canyon
#

ya they're their own thing now.. BoxCollider BoxCollider2D MeshCollider etc

summer stump
real falcon
rocky canyon
#

transfrom.localRotation modifications/calculations could work too

swift crag
summer stump
rocky canyon
#

gross

ivory bobcat
# summer stump This is vague, not exact like I keep asking for

Currently the individual has got a Pipe Spawner in the scene, a Pipe prefab and a Trigger Zone child object on the Pipe prefab. The trigger zone needs to acquire a reference to a scene text object. The solution suggested was to reference the Pipe explicitly (not as Game Object), have the script on the Pipe reference the child Zone object (I believe the component name was AddScore). So far, we've established the correct referencing between spawner and pipe. Pipe doesn't seem to have the correct reference to the score yet though (seems to be referencing TMP).

rocky canyon
#

thats what i gathered too but got lost at the Score reference.. does he have a script in the scene that manages the score?

#

seperately from the pipespawner?

summer stump
#

Ok, understood.
So in this ss #💻┃code-beginner message
The bottom thing in the hierarchy needs to be dragged to the inspector of the top thing
It's gotta go to the parent @wraith valley
The same prefab

swift crag
rocky canyon
#

nice.. statics

summer stump
swift crag
#

don't move any components around. you've completely gotten rid of AddScore.

rocky canyon
#

he meant drag the box collider 2d Component

#

onto the root Pipes

wraith valley
#

The bottom thing in the hierarchy needs to be dragged to the inspector of the top thing

rocky canyon
#

but fen says different

summer stump
#

I meant, select pipe

swift crag
wraith valley
#

I`m read, and another contex

rocky canyon
#

hold up.. fen's setup doesn't require that

summer stump
#

In the inspector, drag the score trigger into the inspector

rocky canyon
#

his score trigger field is a TMP object from when i seen it

swift crag
#

can you screenshot the inspector for the "Pipes" object before we go any further, please?

summer stump
summer stump
#

Phone help sucks sometimes

rocky canyon
#

doesn't matter.. send ur inspector for Pipes

wraith valley
#

That`s empty object with 2d collider

rocky canyon
#

i know what the object was.. i meant the variable

#

but ignore that

ivory bobcat
# wraith valley

Your hierarchy should look like this still for the prefab where the third item had an add score component.

rocky canyon
#

this ..

swift crag
#

We're throwing a massive pile of contradictory and confusing words at Brian and it's really not helping.

rocky canyon
#

im following ur lead Fen.. just waiting and watching

swift crag
summer stump
#

I will stop, I tried to make it simpler, but I see it's being translated which makes things harder. Apologies Brian

ivory bobcat
rocky canyon
swift crag
#

Okay. Here are the things you need to do, in order:

  1. Remove the "Add Score" component from the "Pipes" object. It does not belong there.
#
  1. Add the "Add Score" component to the "ScoreTrigger" object. That's where it was supposed to be.
rocky canyon
#

ohh, i see what ur doin now

#

then a reference to AddScore has the logic and the collider

swift crag
#
  1. Add this line of code to the Pipe script. It belongs with the other lines that declare variables:
public AddScore addScore;
#

This will make a new field appear in the inspector for the "Pipe" component.

#

It will appear next to the "Speed" property in the inspector.

#

It wil be called "Add Score".

rocky canyon
#
  1. drag the trigger object (now sporting the AddScore script) to that slot
swift crag
#

When you drag a hierarchy object into a field in the inspector, Unity will look for a component that matches the field's type.

#

It will find the "Add Score" component you attached to the "ScoreTrigger" object and store it in the field.

#

You must do these steps exactly in order. Do not do anything else.

rocky canyon
#

this lol.. report back when finished

swift crag
#

If you don't understand any of these steps, then please ask me about them.

wraith valley
#

Ok, I process information

#

Omg

rocky canyon
#

👍 no worries.. take ur time

swift crag
wraith valley
#

Why not GameObject?

swift crag
rocky canyon
#

because we want to access the AddScore script

swift crag
#

The game object is not useful.

#

If I want to cook food, I can't just go into a house.

#

I need to go into a kitchen.

rocky canyon
#

if you were to reference the gameobject we'd need to use a GetComponent function on it to get teh AddScore script anyway..

#

extra logic.. extra performance

swift crag
#

If all I know is that I'm in a house, I cannot cook anything.

wraith valley
#

I don`t have AddScript file

#

Only addScript

rocky canyon
#

u add the AddScore script to it

swift crag
#

You can write addScore, then.

#

It will still work.

#
public addScore addScore;

It's just going to be confusing to look at.

wraith valley
#

But AddScore addScore are working too

swift crag
#

You should try to capitalize class names JustLikeThis.

#

You could name the variable something else if that makes it easier to understand

public addScore scoreAdder;

for example.

#

After you add this, you should see a new field in the inspector.

wraith valley
#

But don`t my class name

#

I used only GameObject, MTP_Text

ivory bobcat
swift crag
swift crag
rocky canyon
#

same.. but neither here nor there..

swift crag
#

the name of the component in the inspector is created from the name of the class

#

MyCoolClass becomes "My Cool Class"

sullen trench
#

Hello, I'm trying to Set up a Javascript plug-in, and then Call Javascript Functions from C# script. I've had a few errors to help illustrate my lack of success. (I dont know how to do tha cool highlight thing anymore, ive completely forgotten)
EntryPointNotFoundException: GetUserAgent assembly:<unknown assembly> type:<unknown type> member:(null)
DeviceInfo.Start () (at Assets/DeviceInfo.cs:20)

#

Ive since started a new project

#

And am trying the same task

wraith valley
swift crag
wraith valley
swift crag
swift crag
#

You could have also dragged the "ScoreTrigger" object into the field.

rocky canyon
#

like dis

wraith valley
#

🗿

rocky canyon
#

now ur prefab has access to the AddScore script.. as well as the trigger collider thats attached to it

wraith valley
swift crag
# wraith valley

Did you just delete the "Add Score" component from the "ScoreTrigger" object?

rocky canyon
#

lol, how did it go from working to broken in 5 seconds?

sullen trench
swift crag
wraith valley
#

There`s was mistaking

swift crag
#

Was that anywhere in the instructions we gave you?

#

ctrl-z to undo

#

or put it back and re-assign the reference

wraith valley
rocky canyon
#

the highlighting is an unconfigured IDE problem make sure its !ide configured @sullen trench

eternal falconBOT
swift crag
# wraith valley

As we have said multiple times: You cannot reference a scene object from a prefab.

#

You will never be able to assign anything to the scoreText field in the prefab.

swift crag
#

ScoreTrigger.

#

Pick it.

rocky canyon
#

just finish this step.. and they'll show u the next step

wraith valley
#

It`s

swift crag
#

Stop trying to post gifs.

rocky canyon
#

no gifs

sullen trench
frank delta
#

hello Fen

ivory bobcat
# wraith valley

Alright, looks good. You won't be dragging/assigning anything into this field from the inspector. You'll be doing so through code after you instantiate an instance of the prefab.

wraith valley
rich adder
wraith valley
#

If i delete in ScoreTrigger

rocky canyon
#

unity's setup doesn't autocomplete js

ivory bobcat
wraith valley
#

Will evaporate

swift crag
#

Stop deleting random components.

wraith valley
#

If delete from there

ivory bobcat
#

Now for your spawn code..

wraith valley
#

Pipes will lost addScore

rocky canyon
#

the tmp field is a different situation.. they'll sort it for u

frank delta
#

man I think it is best if you understand how unity works

wraith valley
#

That there

frank delta
#

how references works

rocky canyon
#

addscore can't access the TMP field b/c its in the scene

wraith valley
#

I looked at the guide on how to make a territory trigger, everything worked there, and then I wrote here because the text did not change, and I was thrown all kinds of information, most of which I did not understand and got even more confused

sullen trench
rocky canyon
wraith valley
#

All working except text

ivory bobcat
#

newPipe.addScore.scoreText = yourText;
You'll need to reference the tmpro text object in the scene with your spawner to pass a reference (all the way) to your add score component that's a child of the new Pipe.

rocky canyon
#

this read this.. and understand this. b4 u go changing anything else

sullen trench
#

Gotcha

rocky canyon
#

i was talkn to Brian

wraith valley
rocky canyon
#

but yea intellisense should work. but autocomplete is a different thing.. it can autocomplete little bits and keywords.. but not full functions like unity can..

#

you'd need some sort of plug-in for snippets to autocomplete entire methods

wraith valley
rocky canyon
#

noo.. i just told you to read this newPipe.addScore.scoreText = yourText; You'll need to reference the tmpro text object in the scene with your spawner to pass a reference (all the way) to your add score component that's a child of the new Pipe.

sullen trench
rocky canyon
#

not familiar with jslib.. is that just a big javascript library?

swift crag
sullen trench
#

no, .jslib files are JavaScript plug-in files used to create native plug-ins for Unity using JavaScript

wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class addScore : MonoBehaviour
{
    public TMP_Text scoreText;
    // Start is called before the first frame update
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Score.score++;
        scoreText.text = Score.score.ToString();
        
    }

    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
}
rocky canyon
rocky canyon
#

i found a couple different unity snippet autocomplete plugins for vscode

#

do you use any?

rich adder
#

for vsc ? yeah I have to use one unfortunately for basic MB methods

ivory bobcat
rocky canyon
#

not sure which one to use

rich adder
rocky canyon
#

not in the stock stuff i downloaded

#

this is all i have atm

wraith valley
#

🗿

rich adder
rocky canyon
#

thanks man... if its good enough for you

wraith valley
rocky canyon
#

thats the one i found too.. 5 star ratings but wasn't sure since its a third party

#

and im sure we can add to it

rich adder
#

yeah its pretty good makes it seamless, the only difference I had to go into the options for the plugin and change the code style of brackets

rocky canyon
#

thanks fam @rich adder

rich adder
blissful bloom
#

I need a small suggestion. In my game, I have a multiple GameObjects "door", in which each there's a script "doorBehaviour". I am giving an AnimatorController "doorController" to each script. Inside the doorController, I have AnimatorStates "opening" and "closing", for each which I have scripts for behaviour "DoorOpening" and "DoorClosing". Now my question is, how do I access the original GameObject "door" inside the "DoorOpening" and "DoorClosing" scripts?

viral hemlock
swift crag
swift crag
#

You can find what you need from there.

rocky canyon
# rich adder I chnged this because I don't use K&R

w/o the 100s of errors i was getting yesterday VSCode isn't too bad..
only complaints soo far..

  • sometimes it takes it a min for the syntax to become colored / regestered as valid methods/types
  • sometimes it takes it a minute for unity to recompile after a save in vscode
viral hemlock
# rich adder show movement code
    void FixedUpdate()
    {
        Move();
    }
    private void Move() // this method handles the movemnts physics
    {
        _moveDir = TakeMoveInput();
        if (Input.GetKey(KeyCode.LeftShift)) // sprint input
        {
            _moveSpeed = _sprintSpeed;
            _isSprinting = true;
            _isCrouching = false;
            _isWalking = false;
        }
        else if (Input.GetKey(KeyCode.C) || Input.GetKey(KeyCode.LeftControl)) // crouch input
        {
            _moveSpeed = _crouchSpeed;
            _isCrouching = true;
            _isSprinting = false;
            _isWalking = false;
        }
        else // walking
        {
            _moveSpeed = _walkSpeed;
            _isWalking = true;
            _isSprinting = false;
            _isCrouching = false;
        }
        _playerRb2d.velocity = _moveDir * _moveSpeed;
    }
    private Vector2 TakeMoveInput() //this method handles the movements input
    {
        float horizontal = 0;
        float vertical = 0;

        //keybord input 
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) vertical += 1; 
        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) horizontal -= 1;
        if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) vertical -= 1;
        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) horizontal += 1;

        return new Vector2(horizontal, vertical).normalized; //returns the vector2 input and normalizes it
    }```
ivory bobcat
swift crag
rich adder
ivory bobcat
rocky canyon
#

do you have it assigned correctly in teh script? since u changed other stuff u might need to redrag the prefab

rocky canyon
rich adder
rocky canyon
viral hemlock
rocky canyon
#

you drag the prefab that HAS the pipe script on it

rich adder
blissful bloom
ivory bobcat
rich adder
#

that gives u extra laggy feel

rocky canyon
blissful bloom
#

nevermind

ivory bobcat
#

Hopefully you didn't just try to reference the script.

wraith valley
#

Working already

viral hemlock
wraith valley
#

But text doesn`t work

rocky canyon
#

ya, your text isn't set up yet

rich adder
wraith valley
wraith valley
rocky canyon
ivory bobcat
rocky canyon
#

and u can get ur score from the addscore script

frigid sequoia
#

I asked this in another thread but I am gonna ask here too cause is remotely related. Can you like ovewrite an imported asset? Like replace a placeholder image or model by a new one without having to reassign all the references of it

rich adder
ivory bobcat
#

Since your spawn manager is in the scene, it'll be able to reference the text object in the scene.

wraith valley
rocky canyon
#

yea, you dont need to access the text thru the trigger anymore

#

you want ur pipespawner to do that..

ivory bobcat
#

You can drag the text object in the scene into the spawn object

rocky canyon
#

🙏 give me strength

wraith valley
#

I got confused

sullen trench
#

@rocky canyon I just read through that link you sent me, and I'm familiar with the content, but I'm not convinced the error is derived from setup i have with Unity -> Visual Studios. I am actually not sure that .jslib makes use of IntelliSense. but i do appreciate the acknowledgement of my question

swift crag
ivory bobcat
swift crag
#

This may create or destroy sub-assets (e.g. if you removed a mesh from a model file)

wraith valley
#

Where`s bird

rocky canyon
ivory bobcat
rocky canyon
wraith valley
rocky canyon
#

you keep posting screenshots as a delay to what you've actually done..

frigid sequoia
rocky canyon
#

its moderately confusing

ivory bobcat
swift crag
#

Overwrite the file directly.

swift crag
#

e.g. by exporting over it from Blender.

rocky canyon
ivory bobcat
rocky canyon
#

yes, on the pipespawner script.. you need a reference slot to drop in ur textmeshpro element

#

when you spawn the pipe you'll pass that reference to the addscore script for it to use

rich adder
polar acorn
wraith valley
rocky canyon
#

digi's here! 👋

wraith valley
#

Where`s is bird is not question

#

My textScore where is white bird

rocky canyon
ivory bobcat
#

Did you create a new field for your text object? It should be written in your spawn manager class @wraith valley

thorn iron
#

Hello, I'm wondering how I can add a method to a UnityAction<T0> with an argument ?
For instance, a zero argument UnityAction<> can be assign a method like this:

public class Test
{
  public UnityAction Action1
}
public class Test2 : MonoBehaviour
{
  public Test test
  
  public void Start()
  {
    test += Method; 
  }

  public void Method()
  {
    ...
  }

}
polar acorn
rocky canyon
wraith valley
swift crag
#

Note that, to serialize a generic UnityEvent, you'll need to derive a specific class

ivory bobcat
swift crag
#

you can't just serialize a UnityEvent<bool>

rich adder
thorn iron
swift crag
rocky canyon
thorn iron
rocky canyon
#

he's doing the part now where he should be adding the tmp reference to his pipespawner

rocky canyon
#

and 7.0 says its broken?? lol so i used 6.0 for now

wraith valley
# ivory bobcat Yes.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public Pipe pipe;
    public TMP_Text text;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
       Pipe   newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);

            Destroy(newPipe.gameObject, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
rocky canyon
#

no i got 6, imma upgrade to 8.0 today if all goes well

#

... you are almost finished @wraith valley

#

you'll have to make 1 more change to this script.. and 1 more change to the AddScore script

wraith valley
rocky canyon
#

its not supposed to yet

ivory bobcat
rocky canyon
#

you are not finished

#

but you are close

ivory bobcat
#

If you only click once, it'll show the inspector for the text object. You must drag the object without releasing.

rich adder
#

9.0 is already in the works 😛

#

M$ moves fast. Unity better catchup already..

wraith valley
#

Doesn`t work

#

Again is null

ivory bobcat
#

Did you drag the text object into that field?

swift crag
wraith valley
#

Yes

swift crag
#

there's also yet another random "Add Score" component attached to the Pipe_Spawner object

ivory bobcat
#

Remove the add score component on your manager script

rocky canyon
#

he's unknowingly trolling 😄

ivory bobcat
wraith valley
# ivory bobcat Remove the add score component on your manager script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class addScore : MonoBehaviour
{
    public TMP_Text scoreText;
    // Start is called before the first frame update
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Score.score++;
        scoreText.text = Score.score.ToString();
        
    }

    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
}
#

For this

rocky canyon
#

lol.. addScore is on ur bird prefab..

#

take it off ur pipespawner

ivory bobcat
rich adder
swift crag
rocky canyon
#

remove it off ur pipespawner ^

wraith valley
#

In bird nothing

rocky canyon
#

it should be you showed us it was

ivory bobcat
wraith valley
swift crag
#

It was shown attached to many other things...

ivory bobcat
rocky canyon
#

ohh thats right it was on his Trigger object

wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public Pipe pipe;
    public TMP_Text text;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
       Pipe   newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);

            Destroy(newPipe.gameObject, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
ivory bobcat
#

You can place it before the Destroy statement

rocky canyon
#

and when i said Bird earlier i meant pipe 🤦‍♂️ hella misspelling

rocky canyon
wraith valley
#

Hard

#

I got confused

#

Omg

scarlet skiff
swift crag
#

Disable the animator component and see if you can start flipping the character.

scarlet skiff
#

yup, i can flip now

#

when i disabled

#

animator

swift crag
#

I would just flip the parent empty object.

#

You want to flip the entire character around, right?

#

That means you're flipping not only the player's visuals (the sprite renderer) but also anything else attached to the player

wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public Pipe pipe;
    public TMP_Text text;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    }

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
            Pipe newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
            newPipe.addScore.scoreText = addScore.Score.score++.ToString();


            Destroy(newPipe.gameObject, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
#

🗿

scarlet skiff
swift crag
#

Do that. Do not make up your own code.

rocky canyon
#

i even explained what it did afterwards 😩

wraith valley
#
newPipe.addScore.scoreText = text;
rocky canyon
#

yes, ur setting the text element in the addscore script to this text element

#

ur not setting the text's "Contents" yet

swift crag
wraith valley
#

Will assign but what?

rocky canyon
swift crag
#

You should write exactly what Delphat told you to write

ivory bobcat
wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Pipe_Spawner : MonoBehaviour
{
    public Pipe pipe;
    public TMP_Text text;
    public float maxTime = 1;
    private float timer = 0;
    public float height = 1;

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

    }

    // Update is called once per frame
    void Update()
    {
        if (timer > maxTime)
        {
            Pipe newPipe = Instantiate(pipe);
            newPipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
            newPipe.addScore.scoreText = text;


            Destroy(newPipe.gameObject, 20);
            timer = 0;
        }
        timer = timer + Time.deltaTime;
    }
}
swift crag
#

Okay, good.

rocky canyon
#

👍 good stuff

#

now ur addscore script will use that reference to set the text

ivory bobcat
#

If not, you may be referencing the wrong text (assuming you've got an asset and an in scene object that's got the component tmpro text)

rocky canyon
#

was his addscore setup already to modify the text?

wraith valley
#

Work

#

Thanks

ivory bobcat
wraith valley
#

But i got confused

rocky canyon
wraith valley
#

It is not a fact that I will be able to repeat it

rocky canyon
#

thats the reason it was set up the way it was.. every pipe you spawn should function the exact same

#

oh you mean repeat the coding yourself?

#

well it takes practice and exposure.. gotta do it more than once or twice

wraith valley
#

All the same, there will already be some idea, but it will be necessary to repeat this. As far as I understand. I create a refab, there is a zone in the refab, I create it as a trigger, I create a script, for example, a finish, I create an ontrigerenter2d method, for example, I output the text to the logs and does it work?

rocky canyon
#
  • you spawn a bird
  • that bird has a script on it
    • that script has a reference to addscore
  • after you spawn the bird you use the bird script's reference to addscore to give it the text element
  • the addscore uses the text element you assigned when you spawned it to set the score
wraith valley
rocky canyon
#

it is public yes.. so you can access it from ur pipe spawner script...
pipe.addScore =

#

if it wasn't public you couldn't access it..
it would only show pipe. and then you wouldn't see the addScore

#

building flappy bird is a great starting point.. but also you need basic information to know what ur doing.. or else ur copying and not learning anything..
at this point in time.. i say finish ur project or w/e and immediately start backing up and learning basic information !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
wraith valley
#

All working early

rocky canyon
#

.. are you saying now its not working?

wraith valley
#

Ok, thanks

wraith valley
rocky canyon
#

ok phew

wraith valley
#

But need remind

#

I forgot

#

🗿

#

+- i know

#

When will be practice

#

I will remind

#

Whatever thanks

vast vessel
#

Learn english first

#

Personal opinion

stark trail
#

logic question:
Any ideas on how to cycle a number to the next one in a series, while looping? Best demonstrated through the case:

There are 7 days of the week: 1-7
If I wanted to add x days to currentWeekday for example, would the best solution be to use a remainder operation? Or is there something else?

twilit ocean
#

My hammer glitchdes through everything. The blue plataform is 3 plataforms over one another and that reduced the colision problems, but it's all a mess.

wraith valley
swift crag
rich adder
swift crag
#

You'll need to subtract 1 before applying it, then add 1 afterwards.

#

Note that -1 % 7 is -1, not 6 -- it's not the modulo operator

#

in case you want to go backwards

rocky canyon
vast vessel
stark trail
rocky canyon
#

the ball and chains and the rope bridge look like common unity physics issues

lilac olive
#
            switch (previousScreen)
            {
                case "Spotify":
                    spotifyUI.gameObject.SetActive(true);
                    break;
                case "R6Tracker":
                    r6TrackerUI.gameObject.SetActive(true);
                    break;
                case "Netflix":
                    netflixScreen.SetActive(true);
                    break;
            }```

ive got this system for changing tabs on the players Tablet but SetActive False makes some things break like the spotify page
is there a differant way to just make them invisible and not there 🙂
rocky canyon
#

id rotate my rigidbody using AddTorque or something..

#

it'd be less likely to rip the balls off the chains

twilit ocean
rich adder
rocky canyon
#

^ it looks to me like its being rotated manually

twilit ocean
#

What website do I use to dump the code?

rich adder
#

also why is the gravity still checked on

rocky canyon
eternal falconBOT
rocky canyon
#

i use hatebin

stark trail
twilit ocean
swift crag
#

otherwise (0 - 1) % 7 == -1

stark trail
#

yeah okay

#

thanks

rich adder
rich adder
rocky canyon
#

lol.. got the itch eh

rich adder
#

physics are too damn funn not to play around

twilit ocean
twilit ocean
rich adder
#

why

#

1 means its putting gravity

rocky canyon
rich adder
#

I wish we had Havok..out the box..

rocky canyon
#

trying to do a tow truck.. but the offsets mess with each other.. like the fact that one boom faces downwards and the next boom faces upwards..

twilit ocean
rocky canyon
#

they dont play well together.. in my excavator example i have the peaks of the booms tied together with hydraulics if u will 2 hinge joints on a pole

rocky canyon
#

may have to do the same thing here

rich adder
#

here mine

 private void FixedUpdate()
 {
     if (!canRotate) return;
     arm.MoveRotation(Mathf.LerpAngle(arm.rotation, zRot, speed * 100 * Time.fixedDeltaTime));
 }

and yes my lerp is wrong rn but just testing

rocky canyon
#

gonna need 3 or more per piece

#

one at the actual pivot.. and then 2 more holding the top of the arm to the truck

twilit ocean
rocky canyon
scarlet skiff
exotic hazel
#

im beginner someone can tell what the words here mean?

rocky canyon
rich adder
swift crag
#

(just rotating the parent empty object)

#

I prefer to keep my movements and rotations separately from whatever the animator is doing.

rich adder
twilit ocean
exotic hazel
scarlet skiff
swift crag
scarlet skiff
#

wait let me show

wraith valley
rocky canyon
wraith valley
#

I did it too

swift crag
rich adder
#

but you can prob use torque too

#

You are meant to use the methods on the rigidbody
also turn gravity scale to 0 for any extra objects on player besides player body

exotic hazel
scarlet skiff
#

this is the whole player, but "body" is what has all the scripts, its like the main thing, the "player parent" is just for grouping, as parryhitbox is related to the player but shouldnt hsare the hitboxes of the player and such.

It is the body that has the flip method

swift crag
sullen trench
#

I'm updating my Visual Studios 2022 to 1794. i didn't realise there was an update, i hope that fixes my problem, but I've got doubts notlikethis

rocky canyon
#

instance is a version of the thing that exists

swift crag
#

A property looks a lot like a field, but when you access it, you're actually calling a method.

exotic hazel
swift crag
#

C# can auto-generate them if you just need something that works like a field.

scarlet skiff
swift crag
#

In this case, it will create a backing field to hold the InventorySystem.

swift crag
#

This way, other classes could read, but not write the property

#

As-is, it's basically identical to just making a static field.

exotic hazel
#

ohhh

swift crag
#

The property is called "instance" because it's the instance of the InventorySystem

#

if "Dog" is a class, then an actual dog is an instance of "Dog"

exotic hazel
exotic hazel
#

got it thx

rocky canyon
#

what do properties default to? say i just have a set; get; ?

#

is it w/e the type's protection level is?

swift crag
#
private Foo propBacker;

public Foo Prop
{
  get => propBacker;
  set => propBacker = value;
}
swift crag
#

You can make the accessors more narrow.

rocky canyon
#

okay. that what i was thinking

exotic hazel
swift crag
#
public Foo Prop { protected get; private set; }
sullen trench
# rich adder which problem

I'm Trying to Call Javascript Functions using C# Scripts. I reset my project to do it in a simpler manner, but i am receiving similar results. I have clear confusion points here now. Heres my error EntryPointNotFoundException: Hello assembly:<unknown assembly> type:<unknown type> member:(null) UnityPrinting.Start () (at Assets/Script/UnityPrinting.cs:16)

swift crag
#

it won't let you put a modifier on both

#

which is reasonable: the public modifier is totally pointless in this example

#
    protected Foo Prop { get; private set; }
#

corrected

rocky canyon
#

soo private Foo {get; set;} are both private getter and setter
and pubilic Foo {get; set;} being both public unless specified

rich adder
wraith valley
# wraith valley How?

4 урок видеокурса, на котором мы создадим 2D игру flappy bird на движке Unity. В ходе курса мы научимся работать с Unity, изучим написание скриптов, разберемся с анимацией. В конце видеокурса у нас получится готовая игра Flappy Bird, которую можно будет загрузить в App Store или в Google Play!

---------------------------------------------------...

▶ Play video