#💻┃code-beginner

1 messages · Page 234 of 1

static bay
#

What does it mean?

polar nova
ivory bobcat
#

Make target not null

static bay
#

Why is target null? Did you set it anywhere?

static bay
polar nova
ivory bobcat
#

Put cs if (!target) return;after line 49

polar nova
#

i am so confused

static bay
# polar nova This?

Why on line 20 is it ```cs
if(target != null)
FindTarget();

Wouldnt you try to find a target if target WAS null?
ivory bobcat
polar nova
#

the same but on different line

ivory bobcat
#

Surely if the target is null it would have returned the function.

ivory bobcat
ivory bobcat
#

The real solution would be to simply not call any of these functions if you've not got a valid target

polar nova
#

How do I get that to work

#

sorry If it's annoying but I dont have a lot of experience

queen adder
#

why is this so inconsistent? (varies on framerate)

    public void MoveTowards(Vector2 targ) // called in update, targ is usually mousepos
    {
        rb.MovePosition( Vector2.MoveTowards(rb.position, targ, Time.fixedDeltaTime * speed ) );
```using `fixed` is fast at high fps but slow at low fps,
using `deltatime` is the other way around
lavish gate
#

wait holdon let me look at .MovePosition()

#

Never mind dont remove it

queen adder
#

i cant find which is disturbing the rate, it should work fine when moving via transform

ivory bobcat
queen adder
#

and MovePosition is instant move as well, so they should be similar

ivory bobcat
#

Regular delta time called in the fixed update would use the fixed delta time

queen adder
queen adder
#

delta is slow at high fps, then fast when lagging

lavish gate
#

yes

polar nova
#

I have a Turret which should not Target anything when the target is not in range.

lavish gate
#

show code ihomas 💀

queen adder
#

actually imma try transform.position, it should be really fine if that

static bay
# polar nova This?

The ordering on those functions in Update seems strange.

Wouldn't it make more sense to:

  • Check if the current target is null or not in range. If so, get a new target.
  • Then rotate towards the target if you have one.
polar nova
ivory bobcat
polar nova
sage mirage
# polar nova

Hey! How you are checking a method inside an if statement?

#

Is it possible something like that?

lavish gate
#

you know how you do void methodname()?

sage mirage
#

Yes

lavish gate
#

void is just the return type

sage mirage
#

I know that I mean how he checks the method

static bay
lavish gate
#

so if i put, bool methodname(), i can check if methodname is true or false

static bay
#

Not pretty but meh.

queen adder
#

        // rb.MovePosition( Vector2.MoveTowards(rb.position, targ, Time.deltaTime * speed ) );
        transform.position = ( Vector2.MoveTowards(rb.position, targ, Time.deltaTime * speed ) );
```this is fine, though the `rb` version isnt... hmm..
ivory bobcat
queen adder
#

imma try it in fixedupdate, ig rb isnt instant

#

yea

sage mirage
#

If a method has a return type then you cant check it

lavish gate
#

can or cant?

queen adder
sage mirage
#

Now, I am checking it and it says cannot apply operator to the type void

static bay
#

but you obviously need to return something there

sage mirage
#

Only for bools?

queen adder
#

anything bool can go in ifs

sage mirage
lavish gate
#

any return type that isnt void

sage mirage
#

oh ok

#

Alright I got it! Thanks!

lavish gate
#

You just have to make the correct comparison

queen adder
#

it's only bools (unity objects just secretly turns themselves into bools)

lavish gate
queen adder
#

gameobject is unity object

#

it's being implictly converted

static bay
#

dont worry about what that means

cosmic dagger
sage mirage
cosmic dagger
radiant forge
#

im making flappy bird game. but i made the level generator work on time. like every x seconds it makes a new bc and walls and every x seconds it deletes. but i cant find a equlibrium where i dont eather catch up to the generator or or where the deleter catches up to me. and i tried to generate based on player distance but i just falied miserably any ideas?

keen dew
#

That's usually based on distance, not time

#

There are about a million Flappy Bird tutorials, you could look at how they do it

foggy crypt
#

Hello
I'm having another problem, or more like knowledge issue:

I'm currently trying to make a code for random spawn position and random movement direction
Random position does work - it is in a different code
But when objects spawn - they're moving in both directions at the same time, instead of choosing one of two random directions

void Start()
{
    direction = new Vector3[2];
    direction[0] = Vector3.right;
    direction[1] = -Vector3.right;
}

// Update is called once per frame
void Update()
{
    BubbleFishSwim();
}
private void BubbleFishSwim()
{
    int index = Random.Range(0, direction.Length);
    transform.Translate(direction[index] * speed * Time.deltaTime);
}
static bay
#

So literally every single frame it's deciding "do I go left or right?"

static bay
#

I assume you want them to choose a random direction ONCE, right?

#

And move along that direction?

foggy crypt
#

Each spawn they choose the direction

static bay
# foggy crypt Each spawn they choose the direction

I don't really like how we're choosing that direction but whatever you get the idea.```cs
Vector3 chosenDirection;

void Start()
{
direction = new Vector3[2];
direction[0] = Vector3.right;
direction[1] = -Vector3.right;
int index = Random.Range(0, direction.Length);
chosenDirection = direction[index];
}

// Update is called once per frame
void Update()
{
BubbleFishSwim();
}
private void BubbleFishSwim()
{
transform.Translate(chosenDirection * speed * Time.deltaTime);
}

#

Idk why you're being so secretive of your class/variable names.

#

It doesn't matter.

gaunt ice
#

why dont just

direction.x=Random.value<0.5?-1:1;
```ofc not work if you have multiple direction
static bay
#

And not... a terinary.

#

what does the code that's giving the error look like?

foggy crypt
# static bay I don't really like how we're choosing that direction but whatever you get the i...

That works, but I also want fish to know which direction they should move in, depending on what Xposition they spawned in. Can you help me with that as well?

void Start()
{
    fishX = new float[2];
    fishX[0] = -6; 
    fishX[1] = 5;
}

// Update is called once per frame
void Update()
{
    bubbleFishY = Random.Range(-6, -12);
}
public IEnumerator SpawnBubbleFish()
{

    while (true)
    {
        int index = Random.Range(0, fishX.Length);
        yield return new WaitForSeconds(bubbleFishSpawnRate);
        Instantiate(bubbleFish, new Vector3(fishX[index], bubbleFishY, 0), transform.rotation);
    }
sage mirage
#

Hey, guys! I am currently making a flappy bird game and I have a small issue. So, I want my tree logs to deactivate whenever they touch the other collider. For one reason, it doesn't happen and I wrote some code for that with an OnTriggerEnter2D() method. Check my code:

{
    [SerializeField] private GameObject treeLogs;

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("LeftBound"))
        {
            treeLogs.gameObject.SetActive(false);
        }
    }
}```
#

To note that logs are being instantiated everytime.

#

Also, I have box colliders to both of them like and my other invisible game object and my tree logs as well checked for IsTrigger

gaunt ice
#

treelogs is already a gameobject
if this script is on the log, you dont even need the treelog field
does the left bound have rb?

#

i think your log doesnt need a rb, only the bird and the bound need

sage mirage
#

Tree logs is a prefab yeah. The script is attached to this prefab and I have a field for that. Also, my left bound game object doesn't have an rb.

sage mirage
#

I don't have rb to my logs

gaunt ice
#

read the note

#

also there is a field in monobehaviour called as "gameobject"

sage mirage
#

Yeah I know that

tall basalt
#

is there any tutorial to make spline mesh work in runtime like I want road laying mechanic using splines.

reef patio
#

problem, solve?

frosty hound
#

The error tells you the script and line number. Otherwise show your !code.

eternal falconBOT
reef patio
tall basalt
frosty hound
frosty hound
reef patio
tall basalt
reef patio
#

It cleared, now it has 3 errors left.

frosty hound
reef patio
#

No.

#

"Attach" is there and leads to a form, to run it.

#

I've been having problems with it, but still manage to script.

frosty hound
#

Then you need to configure your !ide

eternal falconBOT
reef patio
#

VS2019.

frosty hound
#

It's a requirement to ask questions here, regardless if you manage without it.

reef patio
#

Ok.

#

Fixed.

#

It has the same 3 errors, im puzzled by.

frosty hound
#

It's not going to fix your errors. It's going to highlight them, and your IDE will auto complete things for you.

#

So what is it highlighting when you double click those errors?

lavish gate
#

whoopsie memory leak?

reef patio
#

FixedUpdate

#

Move

frosty hound
#

Show a screenshot, let's see if it's actually configured.

lavish gate
#

Screenshot of what exactly?

#

Code?

#

or not me

reef patio
frosty hound
#

That wasn't to you

lavish gate
#

Okay, sorry

frosty hound
#

You were missing a closing brace. I don't know how you interpreted that as deleting the opening one.

pallid nymph
frosty hound
#

Anyway I can see this going to be a lot of hand holding, so I'm going to move on. Good luck.

lavish gate
queen adder
#

how can I import these into my project?

lavish gate
exotic hazel
pallid nymph
reef patio
#

does anybody know how to solve this?

#

I have a teacher lesson I can show you all.

lavish gate
reef patio
#

I'm seeing differently now.

queen adder
#

there is

lavish gate
#

Seeing the answer?\

queen adder
#

🤔 ;

reef patio
#

Wait, i'm going to edit it.

queen adder
#

why have ; when finishing method

reef patio
#

Yes!

#

I did it.

#

Thanks for the support.

north kiln
static cedar
#

Gotten too used to python or js or smth. UnityChanThink

exotic hazel
north kiln
#

That area is still underlined in yellow

exotic hazel
#

oh wait

#

it was fixed asec ago

#

let me check

queen adder
#

It was underlined by IDE

#

and you didn not have {}

exotic hazel
#

it says it is unused

queen adder
#

I hate to usem them too tbh but you can not use them if you have an if staement for exampl

#

and its single line

exotic hazel
#

oh my god

#

i just forgot to capitalise the 'd' in OnTriggerEnter2d

#

lemme see if it works

#

its working now

#

but i still wanna cry

brazen canyon
#

Hey guys, I have a class with

private bool Available;

public bool getAvailable {get; set;}
#

Now I have another class that has an OnCollisionEnter to detect if this game object is colliding with the other game object with that class above

#
private void OnTriggerEnter(Collider other)
{
    if(other.gameObject.CompareTag("Bricks"))
    {
        
    }
}

I mean I wanna access and change the value of Available in the other class after the collision was detected.
But how do I know what game object I collided with to call the method, I mean other.gameObject is not guaranteed to be the class above

#

So how do I get to the getAvailable method ?

low path
#

You get the component with GetComponent . You can do that in your if.

north kiln
#

Just use TryGetComponent to check whether you hit an object with that component, while getting it

low path
#

I’d also reconsider your naming for properties and variable. Capital letters are by convention used for properties. Get available suggests it’s only used to get but it has a setter.

north kiln
#

also if your Available/getAvailable is written exactly as above they are two unrelated variables

low path
#

Oh yeah that too. You need to specify the backing field in your case.

hot wave
#

when I crouch, I adjust the height of the controller but It pushes the ground checker down also and it loses the ground check, how do I avoid doing that?

low path
#

you have to assign that value to something (which would access the getter) or assign something to that (which would access the setter) but yeah basically. you still have to account for the possibility that the component doesn't exist and thus would be null, which you can do with an if (e.g., if the component != null, do that)

#

also, i'd avoid that kind of plain public setter, since it basically converts your property to a public variable

#

also if you're going to get the component and check if it's null i'm guessing you don't need to check the tag

#

since i'm guess only items tagged "bricks" have a "brickitem" component

low path
#

um... no if you want to assign you'd do getCanPick = false;

brazen canyon
#

Oh ...

low path
#

properties are methods that act like variables syntactically

brazen canyon
#

Thank you

brazen canyon
queen adder
#

Can someone check my detection system and tell me where my logic is wrong please? Sometimes it will work and sometimes it won't, it will either give me one result all the time or work randomly
https://hastebin.com/share/bomubezapi.csharp

long jacinth
#

whats wrong with this

teal viper
long jacinth
#

OnTriggerEnter2D works

#

i really dont know or im either stupid

teal viper
teal viper
languid spire
queen adder
long jacinth
teal viper
long jacinth
#

god

#

im stupid

teal viper
#

Exit would be called when a collider exits it. If you expect the Pad to exit the collision, you should check if it's the tag.

long jacinth
#

it works now im just stupid

languid spire
#

so on enter if it's Pad yo set to true and on exit if it's not Pad you set to false? Seems very strange

hot wave
#

setting controller height lower when crouching moves everything downward including groundcheck, which fails and gravity starts going up very fast, how do I prevent it?

#

if okUnityChanSalute

frosty hound
#

You have to also reposition the collider. Scaling happens from the center, so you naturally need to move it down to compensate.

rocky canyon
#

gotta manipulate the center

#

possibly the camera if its parented. but somtimes not

hot wave
#

ah, what is the center?

#

it is like this

#

everything is connected to the controller, it is difficult UnityChanThink

pallid nymph
#

it's just a few things that you need to "move around"/adjust together

hot wave
#

this is the first person play thingy, I think it is the collider, then the ground check

#

how would changing or moving the center help? I cant seem to grasp it yet UnityChanThink
wouldnt that mean the ground check would still move regardless or I am missing something

rigid pilot
#

Hello, I need some help rotating a projectile towards the direction of movement. Here's my code:
void Update()
{
transform.Translate(direction * speed * Time.deltaTime);

    transform.rotation = Quaternion.LookRotation(direction);

    if (transform.position.z > 2)
    {
        Destroy(gameObject);
    }
}

}
However, when modifying the rotation, the position is also changing for some reason and it's not longer following the expected trajectory

hot wave
#

from the way I visualize it, does it work like this? or I could be wrong

reef patio
#

some problem again with the animator

#

it seems to be going the same way and not connecting right

hot wave
queen adder
#

Hello guys. I wanted to ask this question its somehow code related. So let's say you want to learn a coding concept for unity. Is it better to learn it from documentations first then watch tutorials about it or watch tutorials first?

reef patio
#

sometimes I get jammed, and need help here, but you could start with guides that are good, but some are ill and are not so precise

frosty hound
gaunt nymph
#

Heyyy

#

Is there someone who can teach me how to make third person controller real quick

#

I am stuck at that problem since two weeks

#

🥺🥺

rigid pilot
hot wave
#

is like this? UnityChanDown

rigid pilot
frosty hound
#

Posting random drawings here isn't going to be useful for anyone.

hot wave
#

the green one is groundcheck, red is the playerbody, i cant figure out what is the center since everytime i simulate it in drawing, the groundcheck falls down

rocky canyon
#

lmao fr..

#

liek are u just pretending these are happening?

#

or are they actually happening

hot wave
#

I dont know how it works UnityChanDown no one told me how the center is relevant

gaunt nymph
#

So that in future I can use my own animations and logic

rocky canyon
#

theres a center parameter

#

u'll need to tweak that to fit ur smaller size

rigid pilot
#

The projectile is deviating itself from the trajectory towards the mouse pointer (white circle)

hot wave
#

I thought scaled from center

frosty hound
rigid pilot
gaunt nymph
frosty hound
#

No

gaunt nymph
#

I will be happy to connect with you guys on vc

hot wave
#

I am still learning, I hope it is ok sadokI am a bit slow

rocky canyon
#

for me my collider is 2 tall.. and my center is 0..
when i crouch its 1 tall.. so i reset my center to .5

rigid pilot
hot wave
#

sorry spawn, steel, I get it now

rocky canyon
#

dont apologize..

#

learning is trial and error.. and learning new things

hot wave
#

okok, I will do my best UnityChanSalute

rocky canyon
#

ur changing it ^

final glade
#

Okay so basically I want to make a simple 2D race game between 2 cars 1 car moves at constant speed and isn’t playable, the other moves when I press the space key. Now I am stuck with collision I want the game to freeze and display a message “the winner is:” when the one of the cars reach the end line but the cars keep going.
I made colliders and made them trigger but doesn’t work, I have 2 scripts which I will send down here 👇

#

using UnityEngine;
using UnityEngine.SceneManagement;
struct CarInputState
{

 bool isAccelerating;

public CarInputState(bool i_isAccelerating)
{
    isAccelerating = i_isAccelerating;
}

public bool IsAccelerating => isAccelerating;

}

public class CarController : MonoBehaviour
{
Collider2D colliderr;
CarInputState inputState;
float speed = 1f;
float acceleratingspeed = 2f;
bool isAccelerating;
void Start()
{
// initialize whatever needs initialization
if (gameObject.CompareTag("Player"))
{
isAccelerating = true;
}
else if (gameObject.CompareTag("ConstantSpeedCar"))
{
isAccelerating = false;
}
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.R))
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
    if (isAccelerating)
    {
        Vector3 position = transform.position;
        if (Input.GetKey(KeyCode.Space))
        {
            move(position);
        }
        // implement game logic
    }
}
 void FixedUpdate()
{
    if (!isAccelerating) {
    Vector3 position= transform.position;
    position.x += speed*Time.fixedDeltaTime;
    transform.position = position;
    }
}
  CarInputState getInputState()
  { 
    //capture inputs here
    if (colliderr.gameObject.CompareTag("Flag"))
    {
    StopGame();
    }
    return new CarInputState(isAccelerating);
   }

void move(Vector3 i_deltaPosition)
{
    // implement the move code for you car
        float deltaTime = Time.deltaTime;
        i_deltaPosition.x += deltaTime * acceleratingspeed;
        transform.position = i_deltaPosition;
}

public void StopGame()
{
    Time.timeScale = 0.0f;
}

}

rigid pilot
# rocky canyon ur changing it ^

Yeah that line is translating it towards the desired direction, it isn't until I rotate it in the following line that the position gets changed in an undesirable way

#

Anyway I fixed it by changing only the graphics rotation instead of the entire object

final glade
#

using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class RaceCountdown : MonoBehaviour
{
[SerializeField] Text countdownTextUI = null;
[SerializeField] Text WinnerTextUI = null;
Coroutine countdownRoutine = null;

void OnEnable()
{
    countdownRoutine = StartCoroutine(playCountdown());
}

void OnDisable()
{
    if(countdownRoutine != null)
    {
        StopCoroutine(countdownRoutine);
    }

    countdownRoutine = null;
}

public bool IsCountdownRunning => countdownRoutine != null;

IEnumerator playCountdown()
{
    // Bonus : Implement this coroutine

    countdownTextUI.text = "3";
    yield return new WaitForSeconds(1);
    countdownTextUI.text = "2";
    yield return new WaitForSeconds(1);
    countdownTextUI.text = "1";
    yield return new WaitForSeconds(1);
    countdownTextUI.text = "Start";
    yield return new WaitForSeconds(1);
    countdownTextUI.gameObject.SetActive(false);
}

void applyCountdownText(string i_text)
{
    if(countdownTextUI == null) return;
    countdownTextUI.text = i_text;
}

void onCountdownEnded()
{
    enabled = false;
}

}

#

If anyone can help it would be appreciated. 👍

near wadi
#

!code

eternal falconBOT
final glade
#

I am sorry.

near wadi
#

well, it should be basically what i suggested.. When crossing the finish line, you can lerp timescale to 0. or instant if you want

polar badge
#

Hi team. Colliders: I have an awkwardly shaped game object. Is the best practices just to make a whole bunch of simple colliders, one convex, or is there a good asset to support auto creation of a bunch of colliders? Do I merge colliders after, is that a thing?

#

Thanks in advance!!

timber tide
#

mesh collider?

rocky canyon
#

multiple primative colliders yes

#

is it a rigidbody?

#

if a convex collider works for u use it

timber tide
#

use primitives if it makes sense

rocky canyon
iron mango
#

Sooo if i have an ability that my character can equip, and i want to use it, and it's for example a throw grenade ability, and the character moves the hand as an animation, how do i connect that? I mean the animation is not on the character but on the ability that i equip (other example would be how do i place the hands where they are supposed to when i spawn a gun on the player)

rocky canyon
#

i think ur doing it bass ackwards

#

u should spawn the gun onto the hands

#

you can instead use Unity's Animation Rigging package.. that will allow u to assign bones from ur character to be attached to the gun..

#

and then when u move the gun.. the bones you chose will work along with it.. sooo ur character animation would still play.. except his arm for example would just be tracking the gun

iron mango
rocky canyon
#

thats what that animation riggging package would do..

#

u would assign the arm/ and hand bones to track the gun.. the rest of the body would animate like the character normally would.. the hands would follow along with the gun..

iron mango
#

Yeah i know but ._.

rocky canyon
#

doesnt matter if ur animating the gun

#

the arms would just follow

#

the gun would still need to be attached to the player somehow.. maybe not the hand bones.. but maybe the main root so it follows along with the position of ur character

iron mango
#

Yeah but if i want to have a reloading animation where the hand doesn't follow the gun but ... Is included in the animation, so it does something

#

If i spawn any gun, there must be a reference to all the bones in the hand for the animation to play

#

Is that automatically or-

rocky canyon
#

not sure about the setup.. u'd just have to work with it

iron mango
#

🫠

rocky canyon
#

look up some resources on it Unity Animation Rigging Package

#

see if it makes sense for u to use.. thats all i can suggest

timber tide
#

I've been just sticking all weapon animations on the character itself. Not too sure how having it on the weapon would work.

#

I'd probably just stick local animations on the weapon like firing animation

rocky canyon
#

ya thats what i do too

#

the gun is animating within a parent gameobject.. and i then add that to the character

neon ivy
#

I'm learning more about interfaces and I have a question.
an interface can have methods that you must implement in the class using the interface. is this also possible with variables?
for instance, if I have a class that implements IInteractable which has an enum EInteractionTypes. how do I make it so the class implementing the interface has to implement a variable of type EInteractionTypes?

short hazel
#

Interfaces can force properties to be implemented, but not fields. So make your member of type InteractionType a property

neon ivy
#

can't say I understand that

short hazel
#
interface ISample
{
    InteractionType Type { get; set; } // read, write
}
neon ivy
#

ooooh

short hazel
#

"variables" as you call them, are in reality fields

#

A property is designed to access a field, and to optionally do logic on the value when the property is get/set from other code

#

Properties can be made read-only by omitting the set accessor

neon ivy
#

yea I've used them before, didn't know they were called properties though xD

#

thanks, I think I can figure something out now UnityChanThumbsUp

polar badge
timber tide
neon ivy
#

UnityChanClever that makes sense

supple citrus
#

Is there a way that this can be done without the Out?

#

I only want the bool value but it seems the out parameter is required

short hazel
#

You can discard it by passing out _

#

In some cases the underscore has a special meaning, it's treated as a discard

supple citrus
#

Oh nice

#

ty

paper star
#

alr so i need help with this code. i have that code on a capsule model with a block hitbox and the Rigidbody physics

#

my whole player model rotates and fucks the physics so my player moves without anything pressing

#

and i dont know how i can do that the player moves just on X axis and not the Y axis

#

public class MouseMovement : MonoBehaviour
{

    public float mouseSensitivity = 500f;

    float xRotation = 0f;
    float yRotation = 0f;
    

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

    }

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

        xRotation -= mouseY;

        xRotation = Mathf.Clamp(xRotation, -89f, 89f);

        yRotation += mouseX;

        transform.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);
    }
}
timber tide
#

getaxis

#

what tutorial you following

languid spire
#

Firstly you should not be using deltaTime there
secondly do not rotate using transform use the rigidbody

frigid sequoia
#

But what is he rotating? Is this an fps?

paper star
# timber tide what tutorial you following

#unity #fps #tutorial
In this series, we are going to create a first-person shooter game in unity.
We will learn how to develop all the different features that are common in FPS games.
From basic movement to shooting modes, impact effects, animating the weapon models, ammo management, enemy ai, and more.

Full FPS Playlist:
https://www.youtube...

▶ Play video
#

and chat gpt

#

and some own

timber tide
#

well, they also multiply GetAxis by deltaTime

#

I'd look for another tutorial

rocky canyon
#

i agree

rocky canyon
vital crow
#

Someone knows how to fix this error?
Saving has no effect. Your class 'UnityEditor.WebGL.HttpServerEditorWrapper' is missing the FilePathAttribute. Use this attribute to specify where to save your ScriptableSingleton. Only call Save() and use this attribute if you want your state to survive between sessions of Unity. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
I've created my class HttpServerEditorWrapper but idk what to do with it

languid spire
#

tbh the message is very self explanatory, either add the FilePath Attribute or don't use Save

median steppe
#

anyone know how to fix this photon vr issue also this is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.VR;
public class ChangeHeadCosmetic : MonoBehaviour
{
public string Head;

private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("HandTag"))
    {
        PhotonVRManager.SetCosmetic("Head", Head);
    }
}

}

languid spire
#

No fix, Not Implemented means Not Implemented

pallid nymph
#

probably means you need to implement it

languid spire
#

you think it requires an override?

pallid nymph
#

yep, otherwise it would be very weird to exist

#

(and btw, it's probably explained in the documentation @median steppe 🙂 )

languid spire
#

@median steppe is SetCosmetic marked as virtual?

median steppe
#

im using tutorials for a gtag fan game so

languid spire
#

and that is relevant to the problem how?

median steppe
#

idk

#

they could be on an older version

languid spire
#

that is a possibility, but check if the method is virtual anyway

autumn tusk
#

how do i replace a child of an object with a prefab

pallid nymph
median steppe
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.VR;
public class ChangeHeadCosmetic : MonoBehaviour
{
public string Head;

private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("HandTag"))
    {
        PhotonVRManager.SetCosmetic("Head", Head);
    }
}

} this is the script

pallid nymph
#

sure, sure, but what about that PhotonVRManager class and its SetCosmetics method? Can you show that?

median steppe
median steppe
twin ibex
#

every time i must use ( UnityEngine )
1 week ago i didint use it

languid spire
#

wtf is UnityEngine.windows?

short hazel
twin ibex
#

i dont know

twin ibex
short hazel
#

If you need to always fully qualify that Input as UnityEngine.Input, then you have your own class Input in the project

twin ibex
#

i dont no i opened the script like that

short hazel
#

What even is the question here

twin ibex
#

i deleted UnityEngine.windows?

languid spire
#

that looks correct

short hazel
#

What happens if you remove all the UnityEngine on line 19? I guess nothing, it's grayed out so it means it can be removed

twin ibex
languid spire
#

where did UnityEngine.windows come from, it's your code after all

twin ibex
#

i know

#

but y the UnityEngine.windows

short hazel
#

You added it yourself at some point

#

By accident

twin ibex
short hazel
#

Yes

twin ibex
#

Bro am not joking

#

i will open a new 1 and i will show u

languid spire
#

code does not write itself, perhaps pay more attention when your IDE offers you solutions

twin ibex
twin ibex
short hazel
#

In VS 2022 when you type the completion list appears. In that version the list is more complete, and for some elements, when you complete it, it'll automatically add the missing using directives at the top

#

That's 100% what happened and you didn't notice it

twin ibex
#

ok thx
i dont know what happend but ok hh

#

sorry

queen adder
#

I just wanted to say I know what my problem is but i wanted to ask whats the best way to deal with it. Attack is running constantly with no down time so should I add down time to each if statement in Attack or should I add it to Update() after i call Attack? I'll send an image of what the code does for now
https://hastebin.com/share/ilajucunoc.csharp

real falcon
#

this seems like it should be simple but I need this part to rotate its X axis so that the barrel points at the sphere

rocky canyon
#

i have zero idea about how to do this... except possibly requiring a <List> vs the Arrays im using now

rocky canyon
#

bullets be wrappin around walls n shit

real falcon
#

lol

rocky canyon
#

it is simple tho..

#

u need a gameobject parent thats holding the barrel.. making sure that the barrel is lined up with the Z axis

#

then you can use multiple different Look methods to look towards that sphere

real falcon
#

I can't just use the look method because it aims with two seperate game objects

#

I need the selected one to only rotate its x axis

rocky canyon
rocky canyon
#

and use the X of the thing u wanna look at

#

(target.x, cannon.y, cannon.z)

real falcon
#

what do I use this vector for? the euler angles?

rocky canyon
#

its the position

#

ur looking towards a vector3 position..

#

theres a LookAt() method that does the rotations for u

#
        // look towards the target on the x and z but straight ahead on the y
        // Get the target position with the same y-coordinate as this object
        desiredLookTarget = new Vector3(lookTarget.position.x,transform.position.y,lookTarget.position.z);

        // Calculate the rotation needed to look at the target position
        Quaternion targetRotation = Quaternion.LookRotation(targetPosition - transform.position);
        transform.rotation = Quaternion.Lerp(transform.rotation,targetRotation,rotationSpeed * Time.deltaTime);``` heres a snippet from the script controlling the cannon in the video
#

in this one i don't allow it to look up and down (so i use the transform.position.y) of the cannon

#

or u can just use transform.LookAt(desiredLookTarget);

#

i use a Lerp to get some smoothing

#

( the wrong way to use a lerp btw ) and it should be a slerp since im using it for rotations.. ) but it gives u the idea of how to look towards something

timber tide
#

could probably use that over lerp

real falcon
#

hm ok I am getting somewhere

timber tide
#

I dont think I really use any lerp methods for rotations

#

or slerp, so I guess I've been just using methods that probably do a lot of that already

real falcon
#

though the method of aiming with the gun's own y and z seems to make it just freeze up

#

ugh I got something working and then it stopped

rocky canyon
#

lol 😄

real falcon
#

            upDownPart.transform.LookAt(new Vector3(aiTarget.lastSeenTargetLoc.x, upDownPart.transform.position.y, upDownPart.transform.position.z));```
rocky canyon
real falcon
#

yeah the commented line works but ignores the contraints

#

the second line just makes it freeze in place

rocky canyon
#

check out this video.. it sounds exactly what u need

#

my method may be overly complicated for what u need to do

median steppe
#

I have tried everything

real falcon
#

maybe I can just make it look and then clamp the axes in the next line, will that visually display?

slender nymph
median steppe
rocky canyon
slender nymph
rocky canyon
#

not sure that would work.. clamping it after rotating it.. but it might.. give it a try and see

median steppe
languid spire
median steppe
#

I have no set cosmetic

#

But i do have a photon manager

languid spire
#

but the PhotonVRManager script does\

median steppe
languid spire
#

tbh If you have so little understanding of what you are doing I question the wisdom of your doing it at all

languid spire
median steppe
#

I have never asked on any discord that is why im confused

languid spire
#

!code

eternal falconBOT
median steppe
#

there is no error in photon manager

#

only in change head cosmetic

languid spire
#

do you not understand what the words Not Implemented mean?

median steppe
#

nah ive never experinced this before

languid spire
#

well post the code correctly and I shall show you

slender nymph
#

the exception isn't even happening in their own code, it's happening in some photon asset

languid spire
#

indeed, which is where I'm trying to get to

median steppe
#

this is where a error is happening

#

line 13

languid spire
#

ffs post the damn PhotonVRManager code

median steppe
#

no error in photonvrmanager tho

languid spire
#

just do it

median steppe
languid spire
#

ffs correctly, that does not even show the correct method

slender nymph
#

that's not even the correct class or file

short hazel
#

The right class, in a paste website

#

!code

eternal falconBOT
short hazel
#

Read the instructions

median steppe
#

i read the GODDARN instructions im not very good at understanding most stuff

short hazel
#

This is a large code block, use the Large Code Blocks instructions

rich adder
#

Large Code Blocks use Link services

#

its like plain english lol

short hazel
#

And that's still the wrong class

slender nymph
slender nymph
grizzled zealot
#

What is better: To build generic shaders (e.g., one shader that can change color, grayscale, alpha through parameters) or specific shaders for each individual task?

slender nymph
real falcon
#

well, I got it working kind of, but now I can't constrain the angle

#

to prevent it from looking too far up or down

autumn tusk
#

ok im geniunely wondering how i do this

#

im currently trying to make a weapon swap system with pickups

rocky canyon
median steppe
slender nymph
#

what is so hard to understand about posting your code using a paste site

median steppe
#

i dont know how to use a paste site

rocky canyon
#

u paste it and hit the save button (it generates a new url)

slender nymph
#

paste code on site. click save. copy link and send link here

frosty hound
#

Click link, paste code, post link here

rocky canyon
#

copy and paste that url

autumn tusk
#

send the link

rocky canyon
#

ez sauce 🫙

median steppe
#

i clicked save

#

oh wait

rich adder
#

sent the wrong script again 👏

median steppe
#

wrong one

#

lemme just

lusty flax
#

For some reason, even though the code inside of this if statement runs each time it's supposed to (tested with Debug.Log), the particles are sometimes simply not shown, even if the code in the if statement is running. Why does this happen?

This code is running in FixedUpdate, if that helps.

if (Mathf.Abs(rb.velocity.x) > 0 && timeSinceGrounded == 0)
{
    dustParticles.Play();
}
buoyant knot
#

it is possible to make a “scriptable obejct variant” like with prefab variants?

languid spire
#

you want a job done, do it yourself

        /// <summary>
        /// Sets a specefic cosmetic
        /// </summary>
        /// <param name="Type">The type of cosmetic you want to set</param>
        public static void SetCosmetic(CosmeticType Type, string CosmeticId)
        {
            PhotonVRCosmeticsData Cosmetics = Manager.Cosmetics;
            switch (Type)
            {
                case CosmeticType.Head:
                    Cosmetics.Head = CosmeticId;
                    break;
                case CosmeticType.Face:
                    Cosmetics.Face = CosmeticId;
                    break;
                case CosmeticType.Body:
                    Cosmetics.Body = CosmeticId;
                    break;
                case CosmeticType.BothHands:
                    Cosmetics.LeftHand = CosmeticId;
                    Cosmetics.RightHand = CosmeticId;
                    break;
                case CosmeticType.LeftHand:
                    Cosmetics.LeftHand = CosmeticId;
                    break;
                case CosmeticType.RightHand:
                    Cosmetics.RightHand = CosmeticId;
                    break;
            }
            Manager.Cosmetics = Cosmetics;
            ExitGames.Client.Photon.Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
            hash["Cosmetics"] = JsonUtility.ToJson(Cosmetics);
            PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
            PlayerPrefs.SetString("Cosmetics", JsonUtility.ToJson(Cosmetics));

            if (PhotonNetwork.InRoom)
                if (Manager.LocalPlayer != null)
                    Manager.LocalPlayer.RefreshPlayerValues();
        }

this is the method you are calling, your parameters are not right

median steppe
#

oh

rich adder
pallid nymph
rich adder
#

its supposed to be PhotonVRManager not PhotonVRManagerGUI

median steppe
#

oh

slender nymph
median steppe
#

Ruh roh raggy

slender nymph
#

you are actually making it impossible to help you. and at this point i definitely won't be attempting to help you further

median steppe
#

i did it

languid spire
#

he's had his answer anyway in spite of his incompetence

median steppe
#

right thing

rich adder
#

It's like, you want to make a game you should at least be aware how to send the proper script

#

As pointed out already, yeah You are passing a string string where the method does not take string, string

#

there is this

   internal static void SetCosmetic(string v, string left)
        {
            throw new NotImplementedException();
        }```
languid spire
#

it is odd thouse that it throws an Not Implemented exception

rich adder
#

but seems generated from IDE / OP

short hazel
#

Plus it's internal, idk how you can even use it from outside the library

slender nymph
#

it's the very last method in the class

rich adder
short hazel
#

Ohh I see what's happening

#

They used the Quick Actions to generate it

rich adder
#

bingo

languid spire
#

that is what I expected to see

polar acorn
rich adder
#

yeah this def makes the original error make more sense

languid spire
short hazel
#

Correction: not knowing what they're doing

autumn tusk
#

why cant i use transform.position on this instanciate function

languid spire
#

I was trying to be polite, not like me I know but I have my moments

slender nymph
#

gotta specify a rotation too if you want to provide a position

autumn tusk
#

ah

#

always forget that

slender nymph
#

always check the docs if you are unsure, or look at the overloads in your IDE

autumn tusk
#

why did this game object go missing

#

i have it set to swap out heldweaponprefab to the gun the player just picked up

wintry quarry
short hazel
# autumn tusk why did this game object go missing

It shows that when the object has been deleted (in your project files) or destroyed (in the scene)
The variable has "prefab" in its name, so unless it's badly named and holds an object in your scene, you just deleted your prefab from your files, and forgot to drag-drop a new one

wooden hare
#

hello guys
I create a new project and get the following error:
Library\PackageCache\com.unity.test-framework@1.1.33\UnityEditor.TestRunner\TestLaunchers\PlatformSetup\PlatformSpecificSetup.cs(19,17): error CS0246: The type or namespace name 'AndroidPlatformSetup' could not be found (are you missing a using directive or an assembly reference?)
can someone help me?

lusty flax
#

I'm trying to make dust particles that go underneath the player while they run in my platformer game, except that the particles don't always appear when they're supposed to. I use this if statement to tell when the player is running, and this if statement does run when it needs to (tested with the Debug.Log command below). Also, the dust particles do appear to play as dustParticles.isPlaying always returns true while the player is running. However, the particles do not seem to be visible at times even though the code runs when necessary. How can I fix this?

if (Mathf.Abs(rb.velocity.x) > 0.1f && timeSinceGrounded == 0)
{
    dustParticles.Play();
    Debug.Log(dustParticles.isPlaying);
}

Below is a video example of my problem.
https://gyazo.com/4d10243b06bb4460a33c5c9aff0e0e65

autumn tusk
rich adder
#

how you just said it

#

destroy the instance not the object in the field

short hazel
#

Instantiate() returns the newly created object, store it in a variable for later use

#

GameObject instance = Instantiate(prefab)

rich adder
#

var instance = Instantaiet(etc.
Destroy(instance.gameObject)

#

aw 🦥

ivory bobcat
short hazel
#

Maybe some code calls Stop() on it right away or too soon so the particles don't have time to spawn.

graceful dust
#

not code, BUT i have a button that uses an object on DontDestroyOnLoad to get the script from. whenever i reload the scene, the button doesnt have that object attatched. how do I fix that? if u need other context just ask

lusty flax
#

rn the log is printing that they're playing even though i can't see them

ivory bobcat
#

There isn't much to work with..

#

I can only assume it's not running

rich adder
ivory bobcat
#

Likely your issue lies elsewhere

lusty flax
#

if it helps in any way, my code is running in FixedUpdate()

short hazel
#

Well if there's no stop, the particle system is always emitting!

final glade
lusty flax
#

its one of those particles that doesn't loop

rich adder
lusty flax
#

it lasts like 0.1 seconds

short hazel
#

Well it should be set to loop, then Play and Pause/Stop when needed

final glade
#

One second

vale karma
#

is there a reason why i still have to click on the screen to get the mouse cursor to listen to CursorLockMode.Locked after escaping the settings menu?

ivory bobcat
#

Escape button has an extra behavior in the editor

rich adder
short hazel
#

It's so you don't lose control of the mouse. It doesn't happen in builds

vale karma
#

okay, i wrote some code to change whether the mouse shows up in the menu and locks back when it snot in the menu

#

i hope that translates well to the build

final glade
vale karma
#

i dont want to run a build rn loll

ivory bobcat
#

Use a different button temporarily in the editor

rich adder
vale karma
#

😮 good idea

final glade
rich adder
#

otherwise Trigger wont be accurate at all

final glade
#

How do I move them using the RigidBody? Sorry I am still a beginner.

rich adder
final glade
#

The rigidbody should be static too right?

rich adder
#

no

final glade
final glade
rich adder
final glade
#

And I should freeze the Y and Z then right?

rich adder
reef patio
#

im stuck, I edited it so many times now, and it continues to read errors, this health script

south fjord
#

I've marked a GameObject with DontDestroyOnLoad(), however when I load a different scene and then later on reload the scene with the original DontDestroyOnLoad()-object then both are shown at the same time. Any tips on how to fix it?

reef patio
rich adder
reef patio
#

Yes.

rich adder
short hazel
#

The issue is at the end of line 19

rich adder
#

ah shit yeah im blind

short hazel
#

There shouldn't be a semicolon at the end of the line

reef patio
#

Yes.

rich adder
short hazel
#

It's throwing the compiler way off, that's why you get a ton of errors

reef patio
#

im still getting a list of errors

rich adder
#

; means end of a statement

rich adder
reef patio
#

"Assets\Scripts\Player\PlayerHealth.cs(20,7): error CS1519: Invalid token '{' in class, record, struct, or interface member declaration

Assets\Scripts\Player\PlayerHealth.cs(21,22): error CS1519: Invalid token '-=' in class, record, struct, or interface member declaration

Assets\Scripts\Player\PlayerHealth.cs(21,31): error CS1519: Invalid token ';' in class, record, struct, or interface member declaration

Assets\Scripts\Player\PlayerHealth.cs(22,26): error CS8124: Tuple must contain at least two elements.

Assets\Scripts\Player\PlayerHealth.cs(22,26): error CS1026: ) expected

Assets\Scripts\Player\PlayerHealth.cs(22,26): error CS1519: Invalid token '<=' in class, record, struct, or interface member declaration

Assets\Scripts\Player\PlayerHealth.cs(26,5): error CS1022: Type or namespace definition, or end-of-file expected

Assets\Scripts\Player\PlayerHealth.cs(28,5): error CS8803: Top-level statements must precede namespace and type declarations.

Assets\Scripts\Player\PlayerHealth.cs(28,5): error CS0106: The modifier 'private' is not valid for this item

"

rich adder
#

seems you still have syntax issue then, are you using a configured iDE ?

#

and did you save changes

short hazel
#

Remove the semicolon at the end of line 19 and make sure you saved

reef patio
#

I have a modified iDE VS 2019, and did save.

rich adder
#

wdym a "modified ide"

#

it should be highlighting this issue for you

reef patio
#

wow only 1 error left now

#

the unity stock development modification

rich adder
reef patio
#

from the installer

rich adder
#

with code showing

reef patio
pallid nymph
final glade
rich adder
short hazel
#

It is configured (see Solution Explorer), it just hasn't loaded the file

rich adder
#

this should say assembly like it does on solution explorer

reef patio
#

another scripts there but I don't understand how to remove its past to a current script check

rich adder
#

try regen project files

short hazel
#

Close the script and open it by double-clicking it from Unity

rich adder
#

the original issue was fixed

rich adder
vale karma
#

if i am making an open world concept first person game, and i have completed movement, and got a mock settings screen up, what should I start to work on next? inventory system? Health or stats? i have no idea, it seems all of them depend on eachother

reef patio
#

oh

vale karma
#

tanku

final glade
rich adder
#

you don't move rigidbodies with transform

final glade
#

Bruh I don’t even know why they’re not colliding

reef gale
#

Hey, could I have some help creating a delay in my script?

vale karma
#

you move Character controllers with transform. transform does not really work with colliders

rich adder
reef patio
#

Ok, I fixed it.

#

It has 0 Errors now.

reef patio
#

Thank you.

final glade
vale karma
#

your professor probably talked about a character controller, they have built in controller functions for colliders

rich adder
south fjord
vale karma
#

oh wait what do you move it by?

reef gale
#

Sry lol

rich adder
final glade
#

If I listen to you guys I will get a 0💀

rich adder
#

all the collisions will be wonky

vale karma
#

lol you probably need velocity or force

pallid nymph
#

talk to your professor and make sure you understand things 🙂

final glade
#

Okay.

rich adder
#

the best thing You can do is ask clarification to why they are compelled to use transform and not the proper Rigidbody methods

timber comet
pallid nymph
#

some physics will work even if you move them with transform, I think... it'll just be buggy as frog

rich adder
#

it wont be accurate iirc, but it might still trigger a message

timber comet
reef gale
#

Basically, I have a problem where I want to have a delay after the player dies. I have made an animation where the player (A Cube) shatters into a bunch of pieces. I want the player to see that animation for 1/2 second, before restarting the scene. Unity tutorials and even ChatGPT are not getting me what I want, since they are telling me to run a coroutine, but since my script deactivates the player cube, a coroutine is out of the question. Is there anything like a delay function in Unity? I'll send my script.

#

!code
using UnityEngine;
using UnityEngine.SceneManagement;

public class CubeExplosion : MonoBehaviour
{
public GameObject explosionPiecePrefab; // Prefab for the smaller pieces
public float explosionForce = 10f; // Force applied to each piece
public float explosionRadius = 2f; // Radius of the explosion

public float delayInSeconds = 0.5f; // Initialize the delay
private bool hasExploded = false; // Track whether the explosion has occurred

// Call this method to trigger the explosion
public void Explode()
{
    if (hasExploded)
        return; // Prevent multiple explosions

    // Disable the original cube
    gameObject.SetActive(false);

    // Create smaller pieces    
    for (int i = 0; i < 27; i++) // 3x3x3 grid of pieces
    {
        Vector3 randomOffset = Random.insideUnitSphere * explosionRadius;
        GameObject piece = Instantiate(explosionPiecePrefab, transform.position + randomOffset, Quaternion.identity);
        Rigidbody rb = piece.GetComponent<Rigidbody>();
        if (rb != null)
        {
            rb.AddExplosionForce(explosionForce, transform.position, explosionRadius);
        }
    }

    // Set the explosion flag
    hasExploded = true;
}

void Update()
{
    if (hasExploded)
    {
        // Wait here for the specified delay
        delayInSeconds -= Time.deltaTime;
        if (delayInSeconds <= 0f)
        {
            // Execute your desired action after the delay
            Debug.Log("Half a second has passed!");
            // Reload the scene (you can replace this with your actual action)
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }
}

}

timber comet
rich adder
#

well yeah, it just wont be accurate at all

#

you're literally teleporting and letting the physics part "catchup"

reef gale
#

My time.Deltatime method does not work for some reason.

pallid nymph
rich adder
#

!code

reef gale
#

how do i do that sry?

timber comet
#

!code

rich adder
#

bot is alseep.

short hazel
#

Morale of the story, always have a backup

reef gale
#

!code

rich adder
#

its not working right now, read the messages above you

timber comet
#

Can’t really tell without proper code tho

rich adder
#

Coroutine should work fine, async maybe overkill

reef gale
pallid nymph
#

run the coroutine on another object/script

reef gale
#

OHH.

#

Thanks. Give me one second.

timber comet
#

But as navarone said it would be overkill

short hazel
#

And probably too complex. I mean when you ask ChatGPT to code for you, you're not ready yet

tender stag
#

the yRotation should just lerp to the opposite y rotation of the climbingWall

timber comet
timber comet
south fjord
# pallid nymph No worries. What is that object doing? Singletons are about having a single inst...

Alright, yeah it seems like they could be useful in my case.

Basically it's a scroll view in which I instantiate texts to create a sorta scoreboard/highscore board on the main menu. But every time I load a scene the texts just get destroyed. I know there is probably a better way to do it by doing sum like usin binary n serialisation, but the teach wants us to use PlayerPref to save the data. I could dumb the idea down in concept by not displaying it on the main screen, but I think it'd be way cooler if I did.

timber comet
south fjord
#

They're under the content of the viewport of the scroll view, which itself is under a panel which is under the canvas

buoyant knot
#

if I have an existing git repository, can I just go to VS > git > clone repository to link to it?

ivory bobcat
#

It might be appropriate if you were to know how to design it but were too occupied to write the lines of code. However, if you don't know what you're doing and hope chatgpt had done it correctly.. pray that someone else bothers to try to understand chatgpt's logical thinking process.

timber comet
noble yew
#

idk where to ask this question but. Im trynna make a 2d fighting game and I kinda want my physical colliders not to collide (So 2 bodies can go through each other) but keep the trigger so hp will go down. I was advised with layer collision matrix and my triggers turn off too :/

timber comet
#

That’s why I ask chat gpt sometimes

south fjord
buoyant knot
noble yew
buoyant knot
#

colliders set to Trigger do not exert force, and solely detect via OnTrigger… Callbacks

timber comet
buoyant knot
#

you can also use the separate layer overrides to change force vs callback

timber comet
buoyant knot
#

“force send layers”, “force receive layers” are override options to affect which layers actually send/recieve force via this collider, which is separate from collision callbacks

#

which allows two non-trigger colliders to 1) exert force with other colliders, 2) not exert force between each other, and 3) get OnCollision… messages

#

understand?

noble yew
#

are these the "layer overrides" options?

buoyant knot
#

yes

noble yew
#

it seems working now but now i have double interaction between layers 😭

buoyant knot
#

wdym double interaction

#

every collision can only make one callback

noble yew
buoyant knot
#

you did not explain the problem to fix

noble yew
buoyant knot
#

layer overrides override the normal settings in the collision matrix

#

good luck then lol

hollow gate
#

How do you guys manage your "Main menu" screen in Unity, settings page et.c., is it by simply hiding and showing entire panels, or how do you do it? 🙂

real falcon
#

this doesn't seem right

Assets\Scripts\Entity\AI\CompoundTarget.cs(11,18): error CS1540: Cannot access protected member 'Target.Die()' via a qualifier of type 'Target'; the qualifier must be of type 'CompoundTarget' (or derived from it)

hollow gate
#

@real falcon how does your Target look like?

real falcon
#

it just extends MonoBehavior

#

@hollow gate

hollow gate
#

PRotected means that only a type and types that derive from that type can access that member.
Make it public, make it internal or derive from another class.

real falcon
#

but I'm calling that from a child class, so shouldnt I be able to see it?

#

I feel like Dog should be able to call Animal methods, at least thats how I Remember it in java

hollow gate
real falcon
#

huh ok

#

is that different in java or am I crazy

hollow gate
#

Haven't programmed in Java in like 13 years, so I don't remember 😄

timber tide
#

You got a list of Targets that you're calling the method on, not the class itself is accessing the method.

#

base.Die(); should work though

tender stag
#

is there anyway i can do this without making ySmoothRot a global variable?

quaint flicker
#

Added the splines package through package manager, I have spline components available, but when I try to reference splines in my scripts (just using UnityEngine.Splines;) I get: The type or namespace name 'Splines' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp]
If I open a script from the splines package it uses that namespace and vscode doesn't complain about it. Is there some extra step when importing the splines package (or any package) to be able to extend/interact with it's code?

ivory bobcat
quaint flicker
hollow gate
#

float ySmoothRot = 0f;
ySmoothRot = Mathf.lerp(.....)

tender stag
#

oh wait it works

#

yeah thanks

tender stag
#

would that also work?

hollow gate
#

you could just initialize it above

polar acorn
hollow gate
#

it's not "guaranteed" that it will be set @tender stag you could come around the problem by just initializing the float ySmoothRot and checking with if(ySmoothRot) {code}

cosmic dagger
quaint flicker
digital topaz
#

Im having a purple asset issue ONLY when I build my project. I converted the materials to URP originally to make them work in the editor, but I’m not sure how to fix it in the build…

short hazel
#

Unused shaders will be stripped off builds to save disk space. If it's not used anywhere except being loaded by code at runtime, it may have been wrongly stripped off. You can add it to the always included shaders list in the project settings

cosmic dagger
brazen canyon
#

I already made a property to get set this variable from a script that's not in a same Game Object with another class
But it still log this error, this means these classes must be in a Game Object to be able to share variable
But I already made a property
WTF is happening

autumn tusk
#

ugh

icy grotto
#

is there a way to auto populate a return switch? like pressing double tab on a regular switch (enum)?

autumn tusk
#

i dont understand why my destroy script is destroying the entire script instead of an individual gameobject

#

is there a way to turn my gameobject into an instance within its own script

rich adder
rich adder
#

what are you trying to do exactly (mechanic)
what is happening instead?

autumn tusk
#

a weapon pickup system

#

each weapon is a prefab, and when the player picks up a gun it replaces all stats and info of the ground gun with that of the players

rich adder
#

ok . can yu show what you're destroying in the code

autumn tusk
#

the player is carrying a prefab version of the gun theyre holding, and that gets spawned in the exact same position as the pickup

#

issues are at line 50

rich adder
#

well u need to cache the instance you spawn if thats what u want to destroy

#

pretty sure we told you earlier how to do that

autumn tusk
#

can you link to an instruction or something

#

its kinda unclear

#

or like docs

rich adder
#

yeah sure

autumn tusk
#

would this work for my script tho

brazen canyon
rich adder
#

cause what you're doing doesn't make much sense rn

autumn tusk
brazen canyon
# rich adder cause what you're doing doesn't make much sense rn

I already made a property to get set this variable from a script that's not in a same Game Object with another class
But it still log this error, this means these classes must be in a Game Object to be able to share variable
That line

enemyHealth.Health -= damage;

Is line 32

rich adder
rich adder
lapis quest
#

Hello guys. How come that when I upload to WebGL, the object does not react to the space key?

brazen canyon
eternal falconBOT
rich adder
#

and since its private its not assigned anywhere else

autumn tusk
rich adder
#

it should make no functional difference unless you done wrong logic

short hazel
#

Whoa discord wtf, everything loaded at once

rich adder
#

also == true is redudant

short hazel
#

Like the message I replied to was the latest one lol

brazen canyon
rich adder
# brazen canyon Huh ?

I asked you where you assigned it and you showed me the script, no where did i see its assigned.

#

Should you by now know the difference between assigment and declaring ?

#

pretty sure you've done it before lol

short hazel
#

They will only appear when there are missing cases. Why did you switch to a regular switch though?

#

The expression was nice and shorter

#

You can also trigger the quick actions manually by right-clicking the switch and selecting "Quick actions and Refactorings"

icy grotto
#

yeah but I don't know how to auto populate the shorter one

#

okay let me try

brazen canyon
rich adder
#

unity has another way too

short hazel
icy grotto
rich adder
#

missin out on intellicode

short hazel
#

I'm still on that one too at work but I can't remember on which one it appears. Again maybe it's just my config

icy grotto
#

will update once i'm done with this game. I'm just afraid it might mess things up.

rich adder
#

vs2019 doesn't have intellicode, just intellisense

short hazel
#

One thing that's really nice with VS22 is that when you type the completion list is blazing fast, idk what they did but it loads sooo quickly it's unreal, even on my potato laptop

#

And no, it won't mess anything with your project, you'll just have to tell Unity to use 2022 instead of 2019

rich adder
#

its also a true 64bit app 2019 is not

#

explains the speeds too

short hazel
#

Yeah it's the first version that's 64bit

brazen canyon
# rich adder sure thats how you assign things so where in the code you sent you did that btw?
rich adder
#

this line throws null
enemyHealth.Health -= damage;

#

because enemyHealth i null

#

its not assigned anywhere, you cannot use a component that isn't assigned

brazen canyon
#

What do I have to do ?
I put this script in a Target object

rich adder
#

what?

#

just assign enemyHealth to a component

#

do you know what [SerializeField] does?

brazen canyon
#

Like this ?

rich adder
#

drag n drop n ur done

#

putting the script there wont do anything..

#

you need to assign it from wherever you are trying to use it

#

method or field, you have to assign it somehow

brazen canyon
#

Okay thanks
I'll give it a shot

#

Like this ?

rich adder
#

just use the inspector when possible

brazen canyon
short hazel
# brazen canyon Like this ?

Also, make sure you apply the newly added Enemy Health script to your prefab! Otherwise other enemies spawned by code won't have it!

rich adder
brazen canyon
#

No I mean these scripts has to be in a same GameObject ?

rich adder
#

GetComponent assumes its this GameObject

#

unless you specify which component you want to GetComponent from.
eg
someOtherObject.GetComponent<T>();

brazen canyon
#

Today I was working on another game.
And I did the same thing but no error shows up ?

short hazel
#

When you put nothing before GetComponent, you can think of it as expanding it to this.gameObject.GetComponent<T>()

#

Which effectively searches the object this script is on

rich adder
tender stag
#

why is this smooth damp fps dependent?

#

like when im in the editor minimized window it runs faster

outer thunder
#

my ui elements (buttons) seem to have a fixed position on the screen so...

tender stag
brazen canyon
short hazel
#

If you want to get a component on that object, sure thing

silent locust
#

I am a begginer, how do i fix this?

rich adder
silent locust
#

I tried doing the Edit-settings-input and i couldnt get it

silent locust
rich adder
#

show the line of code you're using those two

silent locust
rich adder
#

or you didnt save

#

you should probably configure your IDE first if its not already though

silent locust
#

idk what that means

rich adder
#

also Time.deltaTime is wrong on Inputs mouse

silent locust
#

i started today

slender nymph
# silent locust

don't multiply mouse input by deltaTime. mouse input is already frame rate independent so multiplying by deltaTime just makes it dependent on the framerate again causing stuttery camera controls

#

also obligatory: use cinemachine

rich adder
#

Dyno died

outer thunder
#

!learn

#

damn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silent locust
#

what do i multiply it by

slender nymph
#

just the sensitivity

silent locust
#

better?

outer thunder
#

can anyone help fix the problem with my script? (i think its the script) I posted a thread

rich adder
#

what is the question?

#

unclear to me what you're asking about

outer thunder
#

why are my ui elements changing position?

#

did you see the gif?

#

did you open the thread? 👀

lost anvil
#

How would i track if i have a certain GameObject (a hammer), currently equipped in this script? ive had a good search and found nothing on the subject.

https://gdl.space/ivapizotiy.cs

also are scriptable objects easier to work with for making inventories?

rich adder
#

yeah def ur script

silent locust
#

is this something to do with it?

rich adder
#

why did you code position in ? @outer thunder

rich adder
outer thunder
#

I followed a tutorial but then this happened

rich adder
#

that should not say 0 @silent locust

outer thunder
#

Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - https://www.patreon.com/sasquatchbgames
Join our Discord Community! - https://discord.com/invite/aHjTSBz3jH

In this Unity tutorial, you'll learn about Unity's handy Selectable interfaces (like ISelectHandler, IPointerEnterHandler, et...

▶ Play video
silent locust
#

what should it say?

rich adder
silent locust
#

now what

rich adder
#

I just use DOTween for all my UI animations

#

ez pz

outer thunder
#

good point

noble yew
#

guys im trying to make a fighting 2d game and i have 2 scripts rn Actions and Physics. In Physics i have speed ([SerializeField]) and in actions I need to somehow modify that physics speed. how can I do that?

outer thunder
#

you make a very fine point there thanks

rich adder
silent locust
#

aw man

rich adder
#

it should've already had the default

#

what did you do earlier

silent locust
#

crap

#

idk

rich adder
#

brand new projects don't come like this

silent locust
#

i think when i downloaded an asset

#

it chyanged it i think

rich adder
#

possible you replaced your project settings

silent locust
#

is there anyway to fix it

#

ive been working on this all day

rich adder
#

google says to copy the InputManager.asset file

#

and replace that

silent locust
#

i have no clue what that means

silent locust
#

ima try and watch a tutorial

rich adder
#

dont think there is a tutorial for such a specific thing but goodluck ig

#

all you need to do is replace on file

silent locust
#

idk how to do that

timber comet
rich adder
tender stag
#

why when i debug it prints 0.7071068 Debug.Log(climbingWall.transform.rotation.y);

timber comet
rich adder
#

did you loook at the answer from the thread, from a unity empployee ? @silent locust

silent locust
#

no

#

i didnt iknow that was a thong

#

thing

rich adder
#

or mod

rich adder
silent locust
#

like the treads

rich adder
#

well the forum has most of the answers/ issues

#

since tons of people have done exactly what we all are going to do etc.

silent locust
#

tysm

#

now i have another problem

#

i pressed that and cant get back to what i had

#

nvm

#

fixed it