#💻┃code-beginner

1 messages · Page 274 of 1

idle maple
#

Hi, I'm trying to make an object rotation rotate with a camera
Quaternion target = Quaternion.Euler(transform.rotation.x, 0, transform.rotation.z);
heldObj.transform.rotation = Quaternion.Slerp(heldObj.transform.rotation, transform.rotation, Time.deltaTime * 5.0f);

This is one solution I found but unfortunately it just sets the rotation of the object as exactly the same as the camera and what I was looking for was to take the rotation of when i picked up the object and add to it the changes in rotation of the camera if I move it.
How could I do this?

wintry quarry
#

they are not

#

transform.rotation.x never ever do this

#

(although your code is not actually using this target variable, thankfully)

idle maple
wintry quarry
#

Can you explain this better

#

what exactly do you want

#

you are saying you want the rotation of the camera but not exactly

#

You mean you want it but flat on the x/z plane?

craggy lava
#

My navmesh agent looses its sprite when i press play

wintry quarry
craggy lava
# wintry quarry likely your code setting the reference incorrectly.

This is my script

    [SerializeField]
    private float lookRadius = 10f;

    [SerializeField]
    Transform target;

    NavMeshAgent agent;

    void Start()
    {
        agent = GetComponent<NavMeshAgent>();
    }

    void Update()
    {
        float distance = Vector3.Distance(target.position, transform.position);

        if (distance <= lookRadius)
        {
            agent.SetDestination(target.position);
        }
    }
idle maple
# wintry quarry Can you explain this better

Imagine you have an object in your hand, you can pick it up from all sides, after you pick it up I want it to stay in the same rotation in relation to the camera of how you first picked it up

wintry quarry
#

if you don't want to change the agent, delete that

idle maple
#

Even if you move the camera around

wintry quarry
# idle maple Imagine you have an object in your hand, you can pick it up from all sides, afte...
Transform camTransform = myCamera.transform;

Vector3 localForward = camTransform.InverseTransformDirection(theObject.transform.forward);
Vector3 localUp = camTransform.InverseTransformDirection(theObject.transform.up);```
Then whenever you want to _set_ the rotation again:
```cs
Vector3 forward = camTransform.TransformDirection(localForward);
Vector3 up = camTransform.TransformDirection(localUp);
Quaternion targetRotation = Quaternion.LookRotation(forward, up);```
craggy lava
wintry quarry
wintry quarry
#

removed from where

#

agent isn't even serialized

craggy lava
craggy lava
wintry quarry
#

what do you mean by "loses its sprite"?

#

What loses its sprite

craggy lava
# wintry quarry it's not serialized here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class Enemy : MonoBehaviour
{
    [SerializeField]
    private float lookRadius = 10f;

    [SerializeField]
    Transform target;

    [SerializeField]
    NavMeshAgent agent;

    void Update()
    {
        float distance = Vector3.Distance(target.position, transform.position);

        if (distance <= lookRadius)
        {
            agent.SetDestination(target.position);
        }
    }
}
craggy lava
wintry quarry
craggy lava
wintry quarry
#

What am I looking at here?

craggy lava
wintry quarry
#

What does it mean to lose a sprite?

craggy lava
wintry quarry
#

what do sprites have to do with navmesh agents

craggy lava
#

It has a sprite rendere but it gets broke

wintry quarry
#

gets broke how

#

show what happens when it "gets broke"

craggy lava
wintry quarry
#

check z positions

craggy lava
wintry quarry
#

You missed something

wintry quarry
#

and the blue thing

craggy lava
craggy lava
wintry quarry
#

ok and

#

how are they rendered

#

and what positions are they at

craggy lava
#

using sprite rendere

craggy lava
wintry quarry
#

or the enemy

#

or whatever the thing that's going missing is

craggy lava
wintry quarry
#

so the enemy is behind the floor

#

that's why it is hidden

craggy lava
wintry quarry
#

if they're all at the same position and same layer and order in layer it's a crapshoot

wintry quarry
#

what orders are they all

#

show them

craggy lava
#

Enemy is order 3

wintry quarry
#

Also just disable the floor renderer

#

to see if the enemy is behind it

#

disable them just to check

craggy lava
wintry quarry
woven crater
#

just found out you can have multiple scene in the hierachy. its like mixing two scene together or something?

dark mirage
#

hi there

craggy lava
dark mirage
#

is there any beginner guide? or where should I begin? I just downloaded unity 😄

woven crater
wintry quarry
#

looks like the enemy is there

#

Can you change this to "Pivot"?

#

Also disable 3d mode

#

and press F while the enemy is selected

#

Oh wait I see the problem here

#

You have rotated it sideways

#

like paper mario

#

it's infinitely thin

craggy lava
#

thats the navmesh doing so

wintry quarry
#

yes

#

well

#

that's your problem

#

it's probably doing LookAt

craggy lava
wintry quarry
#

Well IDK what code it's using but it's rotating the thing

#

figure out how to make it not do that

idle maple
tawny hedge
#

Player glitching while in a lane

vivid igloo
#

Anyone knows whether I should use regular LODs or HLOD in an open world game!

real perch
#

hey guys, having an issue with mesh/materials. I'm trying to learn a bit how they work. I've managed to generate a big grid of quads pretty simple, I'm trying to add some materials to each quad now, but for some reason the top of the material is appearing like this (only applying to first quad in grid at the moment) and attaching it's self to the triangle above it

I've attached the code I'm using. This is all in 2d btw.

#

the material is just this

wintry quarry
real perch
#

I'm trying to add a material just to that quad in the bottom left

wintry quarry
#

If you want to be able to isolate the UVs per quad you can't do shared vertices.

real perch
#

ah right, so for every quad, it would need 4 vertices that arent used anywhere else

#

and two triangles

gleaming kraken
#

aint no way i spent 10 whole minutes trynna figure out why my translate wasn't working until I realized i put it in void start so it only happened once

#

💀

rocky canyon
#

coding for ya

sage mirage
#

Hey, guys! I don't know how to attach my game object component to that script here. Do you know why? I have it as a prefab but I am not sure why I cant do that.

#

I can't drag and drop the game object to that field here

#

I can do that for my other game objects that are not prefabs

swift crag
#

yes, because you can't reference scene objects from a prefab

polar acorn
sage mirage
polar acorn
#

Prefabs can exist anywhere. Scene objects only exist when that scene is loaded

sage mirage
#

I have to use that main game ui manager

polar acorn
real perch
#

it's for top down terrain with unique materials in a large grid

scarlet skiff
#

Its not really changing the gravity scale :/

#

even if i comment the method that changes the scale back, still the player doesnt float

#

and the dbug shows up like 5 times

swift crag
#

does changing the gravity scale in the inspector have any effect?

hidden sleet
#

Currently for this crafting system I've got two lists, one containing the list of output objects and one holding a scriptable object that points to the object prefab for that item, with a dictionary mapping different crafting methods to these items. However I really don't like how I'm assigning the dictionaries, as changing the list in the inspector in any way, will ruin the whole thing. Is there some better approach to take here so that crafting is consistent and doesn't require as much reopening and editing to change?

using Inventory.Model;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CraftingManager : MonoBehaviour
{
    //Handles turning one object into another and holds the process to perform
    public InventoryManager inventoryManager;
    public RawInventorySO rawInventory;
    public ProcessedInventorySO processedInventory;
    public List<ImmutableItemSO> itemPrefabs = new List<ImmutableItemSO>();
    
    public List<ProcessedItemSO> outputItems = new List<ProcessedItemSO>();
    public Dictionary<CraftMethod, ProcessedItemSO> craftToItem = new Dictionary<CraftMethod, ProcessedItemSO>();
    public List<ImmutableItemSO> itemTemplates = new List<ImmutableItemSO>();
    public Dictionary<CraftMethod, ImmutableItemSO> craftToTemplate = new Dictionary<CraftMethod, ImmutableItemSO>();
    public static CraftMethod craftMethod;


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

        
        craftToItem.Add(CraftMethod.RodCraft, outputItems[1]);
        craftToItem.Add(CraftMethod.CuboidCraft, outputItems[0]);
        craftToItem.Add(CraftMethod.PlateCraft, outputItems[2]);

        craftToTemplate.Add(CraftMethod.RodCraft, itemTemplates[1]);
        craftToTemplate.Add(CraftMethod.CuboidCraft, itemTemplates[0]);
        craftToTemplate.Add(CraftMethod.PlateCraft, itemTemplates[2]);
    }

    public void ProcessInput(GameObject inputObject)
    {
        if (inputObject.CompareTag("RawMaterial"))
        {
            switch (craftMethod)
            {
                case CraftMethod.RodCraft:
                    ProcessedItemSO newRodItem = craftToItem[CraftMethod.RodCraft];
                    newRodItem.itemTemplate = craftToTemplate[CraftMethod.RodCraft];

                    processedInventory.AddItem(craftToItem[CraftMethod.RodCraft], 1);
                    //rawInventory.RemoveItem(inputObject.GetComponent<ItemController>().item);
                    

                    Destroy(inputObject);
                    break;
                case CraftMethod.CuboidCraft:
                    ProcessedItemSO newCuboidItem = craftToItem[CraftMethod.CuboidCraft];
                    newCuboidItem.itemTemplate = craftToTemplate[CraftMethod.CuboidCraft];
                    processedInventory.AddItem(craftToItem[CraftMethod.CuboidCraft], 1);
                    

                    Destroy(inputObject);
                    break;
                case CraftMethod.PlateCraft:
                    ProcessedItemSO newPlateItem = craftToItem[CraftMethod.PlateCraft];
                    newPlateItem.itemTemplate = craftToTemplate[CraftMethod.PlateCraft];
                    processedInventory.AddItem(craftToItem[CraftMethod.PlateCraft], 1);
                    

                    Destroy(inputObject);
                    break;
                default:

                    Destroy(inputObject);
                    break;
            }
        }

    }
}

scarlet skiff
swift crag
#

It will either be one of your scripts or an Animator.

polar acorn
scarlet skiff
#

its the animator component again... idk what to do with it..

polar acorn
#

Don't animate values you don't want to drive by animation

scarlet skiff
#

i didnt think i changed the gravity scale from an animation

swift crag
#

well, the animator certainly thinks you did!

hushed spire
#

Hey guys, I have a first person player with a camera. I want to make a script that draws the camera to a certain direction, but that the player can still resist and have some control over. Any ideas on how I’d do this?

swift crag
#

oh yeah, I've done this before

#

you can do something as simple as

hushed spire
#

Everything I’ve found online is just about taking the camera control completely away and focusing on one object

hushed spire
swift crag
#
camera.transform.rotation = Quaternion.RotateTowards(camera.transform.rotation, targetRotation, Time.deltaTime * 45);
#

this will drag the camera towards targetRotation at 45 degrees per second

#

You can also cap the player's look input (it'll depend on how exactly you read input) to limit how quickly you can try to look away

hushed spire
#

But the camera is locked onto the cursor

#

If I don’t disable that it’ll just override

swift crag
#

show me how you rotate the camera.

hushed spire
#

Alright give me a minute

scarlet skiff
swift crag
#

It doesn't matter if the animation clip is in a state that is not currently active.

hushed spire
#

I can’t tell because I’m using a first person controller package called Opsive and the script is mad confusing

scarlet skiff
swift crag
scarlet skiff
#

oh my goodnes...

swift crag
hushed spire
scarlet skiff
#

i have 12 animations

swift crag
#

I would suggest making a component with two fields:

  • a bool for "control gravity"
  • a float for the gravity value
polar acorn
swift crag
#

Animate these properties.

#

The component will overwrite the rigidbody's gravity scale if the bool is true.

scarlet skiff
swift crag
#

unity doesn't care what you intended to do

polar acorn
swift crag
scarlet skiff
#

so its a game of hide and seek now, to find the animation that is resposible

swift crag
#

i'd just go over to my shell and do a grep -R gravityScale Assets/Animations/ and see if anything pops up

#

dunno if there's a nice way to do that in-editor

karmic lichen
#

Fen you have officially motivated me to learn how to use terminal more effectively.

swift crag
#

i often just grep for a GUID to figure out if an asset is totally unused before I delete it

karmic lichen
#

that's a really good idea

polar acorn
karmic lichen
#

also a protective plating that grows on the backs of some reptiles

swift crag
#

see "graphical shell"

#

i guess that "shell" alone implies that you're talking about a command-line interface

stark berry
#

I have this unity game that is being programmed in C#. The basis of the game is that there is a worm that is made up of 3 points that moves across the screen. I am having an issue where when the input data is being read (its just a smooth sin wave) the constraints lock and unlock where I do not expect them to. I have tried a few things but can not get it to work. If a video would help explain my issue I can provide one.

swift crag
#

you'll need to provide much more information

wintry quarry
scarlet skiff
#

where do i find my shell

hexed terrace
#

on your back?

stark berry
#

am i allowed to upload pictures and videos in here

hexed terrace
#

shell in windows is cmd prompt

swift crag
swift crag
hushed spire
#

Ok Fen, let’s say I find a way to just disable the camera being locked by the mouse in the first person controller. Could you please help me with the separate script that would give the control back to the player but still have the attraction force of the camera to the object?

fickle plume
stark berry
wintry quarry
eternal falconBOT
wintry quarry
#

and explain how you expect this to work

stark berry
hushed spire
#

Fen did not give me permission to ping them… so I guess I’ll just wait for my hero lol

wintry quarry
scarlet skiff
#

i mean ig i gotta learn it at some time so, got any good tutorials?

stark berry
# wintry quarry and explain how you expect this to work

the game takes in hip angle data, calculates the speed, and if the speed is positive the front one locks so that as the center body rises the back body moves forward because the front body is locked. then as the speed goes negative the center body moves down while the back body is locked which pushes the front body forward. for testing I am using a smooth sin wave

#

the center point moves up and down correctly without the other bodies but when i add them in it starts to mess up

#

if any more info is needed pls lmk i've been stuck on this for a while

swift crag
#

If it's updating pitch and yaw values that it uses to compute a rotation, then you need to modify those values

limpid wren
#

I’m making my first sound manager and had some questions regarding the systems design stuff. My first instinct is to make like a dictionary of string/audioclips and then have a "playsound(string soundID)" function to interface with it, is this a reasonable approach or is there some other common way to do this?

#

I'm expecting to play quite a lot of sound effects at once, so I'm concerned about the AudioSource management too, if anyone has any stories from their own sound managers they'd like to share I would appreciate it a lot

hushed spire
#

Basically like I’m disabling one script, taking away the camera movement, and enabling another script that gives that movement back but now it can rotate towards another object

#

Or does that not make sense to do?

#

No clue if this solution is smart or dumb

swift crag
#

I would just make it so that the original camera movement script continues to run

#

i don't know what you're doing, so i can't say anything more specific than that

hushed spire
#

I can’t move the camera during runtime in positional or rotational values if that helps

#

Only with the mouse, not with the inspector

wintry quarry
empty dagger
#

Hello, I'm trying to implement a wall slide/jump mechanic into my game- I'm trying to use Debug.DrawRay to start with (I was following a tutorial) but it's just not doing anything, even tho the same code worked on the tutorial (code here: https://gdl.space/eduricokiy.cs (In the PlayerMovement script)), does anyone know what the issue could be?

wintry quarry
vocal marlin
#
private IEnumerator AttackCo()
    {
        Vector2 facingDirection = new Vector2(animator.GetFloat("Horizontal"), animator.GetFloat("Vertical"));
        animator.SetBool("Attacking", true);
        player.rb.MovePosition(player.rb.position + facingDirection * lungeDistance * 5);    
        Debug.Log(player.rb.position);
        Debug.Log(player.rb.position + facingDirection * lungeDistance);
        player.currentState = PlayerState.attack;
        yield return null;
        animator.SetBool("Attacking", false);
        yield return new WaitForSeconds (attackAnim.length);
        if (player.currentState != PlayerState.interact)
        {
            player.currentState = PlayerState.idle;
        }
    } 

for some reason this line: player.rb.MovePosition(player.rb.position + facingDirection * lungeDistance * 5); isn't moving the player. Can anyone tell me why? I debugged it and the numbers were all right

wintry quarry
empty dagger
wintry quarry
vocal marlin
wintry quarry
empty dagger
vocal marlin
vocal marlin
#

ok ty

west sonnet
#

I've got an issue with my enemies throwing animation. If I move to the other side of my enemy, my enemy throws downwards instead of upwards. I'm using DOTween to do the enemies throwing movement. I believe the issue is happening because in my code, I'm telling the enemies hand to move forward and up, so when the hand is rotated to the left side of the enemy, the hand moves downwards instead of upwards

#

Here's the DOTween code I'm using for the hand movement

wintry quarry
#

so if you've rotated 180 degrees, that 1.5 up will be 1.5 down

#

Or if you've given your enemy a negative scale

rocky canyon
#

ur rotating around like this

west sonnet
#

Yeah, I get it, but how can I resolve this?

#

I'm not sure how to fix it

rocky canyon
#

not sure off-hand

west sonnet
#

Could I change the enemies X scale when it turns around?

rocky canyon
#

u could... do a - scale to just flip the character

#

see if it works out w/ just that single change

west sonnet
#

Can't figure out how to change the scale. I'm trying to do gameobject.transform.localscale.x = -1, but it's not letting me

rocky canyon
#

could also probably but the shooting thing on a gameobject that doesnt rotate

buoyant knot
#

don’t change local scale unless you actually want to change scale.

rocky canyon
#

so its axis' are always the same.. and u can do ur math off of those

wintry quarry
vocal marlin
#

for some reason i'm getting this error

#

Cannot reparent window to suggested parent. Window will not automatically close.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

rocky canyon
#

since its a sprite u should probably use FlipX

#

instead

vocal marlin
wintry quarry
#

Eh i prefer
transform.localRotation *= Quaternion.Euler(0, 180, 0); 😜

west sonnet
rocky canyon
#

ohh true

rocky canyon
vocal marlin
rocky canyon
#

restart ur editor..

wintry quarry
cosmic dew
#

i have uplaod a game to internal testing to get IAP key. i have also created purchasing script. i have a question regarding this did i have to publish the game on playstore to test its working or not. because when i build apk and tested on mobile its showing the item that you were attempting to purchase could not be found.

rocky canyon
#

set layouts to default

buoyant knot
#

every time i flip sprite, it bites me in the ass because asymmetric hitboxes don’t get moved too

rocky canyon
#

facts

vocal marlin
rocky canyon
#

reset ur layouts to default then

#

and then restart

buoyant knot
#

flipped scale has its own issues, but it is better than flipped sprite

rocky canyon
#

as long as u remember ur scale is flipped

vocal marlin
rocky canyon
#

top right

#

reset all layouts

vocal marlin
#

ok ty

rocky canyon
#

layout is just the way ur windows are arranged

#

and since its an issue with the editor and it's windows.. it might solve it

vocal marlin
#

yeah I've seen it now hopefully it fixes it

rocky canyon
#

ive had certain assets ive installed be the reason for continuous errors like that

fading rapids
#

does changing a ascript in one scene that is also used in other scenes(like movement scripts for levels) chgange the script for every scene or change it only for that scene

rocky canyon
#

if u change the actuall code (the script) then yes..

summer stump
rocky canyon
#

if ur only modifying values then those values will be back to default on a new scene load

summer stump
#

You create INSTANCES of those scripts in scenes
If you change the code, it changes the file
If you change the inspector, it changes the instance of the scene object, or could change a prefab file

rocky canyon
#

unless u carry that instance of the object across into the new scene with DDOL or something

vocal marlin
rocky canyon
#

no..

rocky canyon
#

i tried and then stopped

#

why did someone rob my name? 😅

fading rapids
#

"If you have multiple scenes that use the same script and you want to update the script across all scenes, you'll need to manually make those changes in each scene or use some form of automation or scripting to apply changes across scenes programmatically." chatgpt capping these days

wintry quarry
rocky canyon
#

or if its plausible could DontDestroy it

summer stump
summer stump
rocky canyon
#

Obviously

fading rapids
summer stump
fading rapids
#

oh no i meant it obvious to not take schatgpt as a reliable source

summer stump
#

Spam machine writes spam

rocky canyon
#

should be changed to will

cosmic dew
#

i have uplaod a game to internal testing to get IAP key. i have also created purchasing script. i have a question regarding this did i have to publish the game on playstore to test its working or not. because when i build apk and tested on mobile its showing the item that you were attempting to purchase could not be found.

cosmic dew
summer stump
cosmic dew
gleaming kraken
#

so in the junior programmer pathway's comments, I've been seeing a lot of people say the instructor is teaching bad code practices. How do I identify these and learn the better method of them?

summer stump
#

Avoid Find, avoid Invoke (except with events of course), try to limit scope of classes, try to cache things when possible

#

Tons of things to keep in mind. Looking up cs principles can help

#

SOLID is a big one

gleaming kraken
# summer stump Do the comments say what practices exactly?

some of them do, for instance, an example could be:

  • On one of the scripts, it checks if gameOver is a false variable in a different script, and if it is, then it runs the code, otherwise, it doesn't. What the comments say is that it could instead use a "CancelInvoke" to stop the "InvokeRepeating()" that would occur
gleaming kraken
# swift crag link to an example please
Unity Learn

Overview: We’ve got the core mechanics of this game figured out: The player can tap the spacebar to jump over incoming obstacles. However, the player appears to be running for the first few seconds, but then the background just disappears! In order to fix this, we need to repeat the background seamlessly to make it look like the world is rushin...

#

lots of comments about bad practice on this one

woven crater
#

why these button component look so different?

gleaming kraken
#

i mean i'm learning a lot from this, but I'm just trying to avoid bad practice so that's why

swift crag
woven crater
#

dam im dumb

swift crag
#

It would be ideal to just directly reference the player.

gleaming kraken
#

rather than look for a specific object with the name player

#

just look for an object with the tag player

#

that way even when renaming it won't break

west sonnet
#

I've got an explosion I've made using a Particle system. What would be the best way to create a force that pushes back all nearby object when the explosion happens?

swift crag
#

jinx

wintry quarry
#

Damn 🐢

swift crag
#

note that this won't involve the particle system at all

#

it'll be a separate thing

wintry quarry
#

Generally preceded by a Physics.OverlapSphere to find the objects to all that with

#

(as in the example code in the docs)

west sonnet
#

Oooh, interesting. Thank you!

compact crescent
#

Literally none of my scripts are working when I try to import them

polar acorn
compact crescent
#

Yes, but they are all because of the files?

#

Even though other people use them.

polar acorn
#

You'll need to fix those errors before your code will compile

compact crescent
#

Could it be the version I'm on?

polar acorn
#

start at the top and move down the list

wintry quarry
polar acorn
#

fixing one often fixes future ones

compact crescent
wintry quarry
compact crescent
wintry quarry
#

is Pun installed in this project?

compact crescent
polar acorn
# compact crescent

Do you have anything named MonoBehaviourPunCallbacks in your project or packages?

wintry quarry
#

you'll need it in the project to use it of course

compact crescent
#

Ok, I'll download it 1 second.

wintry quarry
#

Also that filename is not going to work

#

Did you copy the scripts multiple times or something

#

fix the filenames

wintry quarry
#

JoinRoom (2).cs ain't gonna work

compact crescent
#

Alright.

polar acorn
# compact crescent No.

So that would be why you have the error. The code references that class, which you don't have

compact crescent
#

Yeah, because I'm just trying to add a code computer.

polar acorn
#

...a code computer?

compact crescent
#

Yeah, I'm making a VR game thing

wintry quarry
#

What does code computer mean and what does it have to do with VR

polar acorn
#

I have no idea what you're talking about

compact crescent
polar acorn
wintry quarry
#

Why are you manually copying scripts around?

#

Wouldn't you just clone the whole project (ideally through version control)?

compact crescent
polar acorn
#

What?

wintry quarry
#

or rather, if you just want to run a server, you make a build of the game and run that

compact crescent
#

They're scripts.

wintry quarry
#

you don't need to do anything with the project

#

yes those are scripts

#

why are you copying them around manually?

compact crescent
polar acorn
#

Maybe we just stop for a second and back up

#

what are you even trying to do

wintry quarry
polar acorn
#

There are several fundamental miscommunications and I think we need to just throw out the entirety of the last minute or so of conversation

compact crescent
summer stump
#

Sounds wild....

compact crescent
#

No...

polar acorn
compact crescent
polar acorn
compact crescent
#

Pictures

polar acorn
#

no

#

Right now just tell me what you're importing and from where

#

Are you just trying to drop in the code from a tutorial without doing the actual tutorial?

compact crescent
#

I'll jsut quit, it's fine, I don't want to give you more trouble

polar acorn
#

The tutorial probably mentions installing Photon so you can actually use this code

compact crescent
polar acorn
#

No

compact crescent
#

ok

#

It's fine, I'll just quit

#

Thanks for trying though

flint falcon
#

Is it a bad idea to try and code basic ideas things like movement with chatgpt to try and learn? I've already gotten a few issues but when I relay them back to get it can fix them. Starting to think it's showing me not great ways to do things

polar acorn
flint falcon
#

Yeah I did that originally and it was going well but the style of movement I was looking for I must have been an idiot cause I couldn't find it or where to start

hoary locust
#

hello there. i ran into a pretty weird problem with the unity engine. I have 6 layermaks and instead of their values being 1 to 6, its instead 1, 2, 4, 8, 16, 32, and 64. does anyone have any idea whats the problem with that?

languid saffron
#

I'm still having the issue where I can't hear the music, It's set to 3D, I have Audio Listener on my camera. I do have a Radius that isnt too big

hoary locust
polar acorn
languid saffron
swift elbow
polar acorn
languid saffron
#

(i am very new to coding lol)

#

Audio Source isn't muted if that's what you ment

swift crag
#

No. Look in the Game View for a mute button in the top right corner.

#

it looks like this when muted.

languid saffron
#

Still doesn't work

swift elbow
#

check your audio mixer settings

flint falcon
swift crag
languid saffron
swift crag
#

you said it was set to 3D

languid saffron
#

The Audio Source

swift crag
#

I'm not talking about the "2D" button in the scene view

languid saffron
#

oh

swift crag
#

that just locks the scene view camera to the XY plane

#

I'm talking about the spatial blend on the audio source.

languid saffron
#

Yes I can hear it on 2D, but it still plays even when I'm across the map

swift elbow
swift crag
#

The default volume curve is very aggressive.

timber tide
#

OnTriggerEnter and OnTriggerStay dont have a discreet executing order right

languid saffron
swift crag
#

The max distance is 5

#

if you're more than 5 meters away the audio source is completely silent

#

and if you're more than 1.5 meters away, the audio source is already at 30% volume

languid saffron
#

yea but when i go right next to it, it still doesn't play

swift crag
#

Reset it to a linear rolloff and give it a reasonable max distance.

#

say, 30 meters

steel geyser
#

what is worng

languid saffron
#

it worksss tysm

swift crag
#

PostProcessProfile is in UnityEngine.Rendering.PostProcessing

#

you haven't added a using directive for that namespace, so the name can't be found

steel geyser
swift crag
#

sounds like you don't have a package installed, then

#

I presume you're using the built-in render pipeline. Have you installed the Post Processing V2 package?

swift crag
#

well, you'd better figure out what you're actually doing first

#

did you copy this script from somewhere?

steel geyser
#

chatgpt

swift elbow
# steel geyser chatgpt

if you asked it why you got these errors, i think it wouldve told you that you dont have the package installed

swift crag
#

I am not interested in helping you with machine-generated spam.

swift elbow
#

its not like the code is bad, it just omitted a few steps before implementation

languid spire
swift crag
#

it's bogus

swift elbow
swift elbow
languid spire
#

IT DOES NOT WRITE CODE

swift crag
#

It produces sequences of text that can happen to match the syntax of code.

#

It also does not think.

languid spire
#

it writes text that looks like code, there is a huge difference

swift elbow
#

if it works it works. whats so wrong with that?

#

i feel like yall are being too harsh with specifics

swift crag
summer stump
#

That we then get asked to fix

swift crag
#

normalizing it means i'm forced to look at more weird sludge

swift elbow
swift crag
languid spire
swift crag
#

and thus producing exponentially more sludge

#

i'm already dealing with enough AI-generated spam

summer stump
#

If it happens to produce something right, it is because it copied it directly. And that could have been found and support the writer instead of gpt

#

But it rarely gets stuff right ime

hidden sleet
swift elbow
swift crag
#

fantastic. never use it.

swift elbow
#

its much easier to ask it than to go read the docs yourself, and it explains it a lot more comprehensively

swift crag
#

it also confidently tells you things that are wrong

#

because it is a very large pile of text smashed into a gigantic statistical model

#

it is not documentation.

gleaming kraken
#

bit confused on why this doesn't work, wouldn't it get the transform of the part the player collides with and then set it's y to 0?

swift crag
swift crag
#

Always start with the error message.

#

you can't just see a red squiggle and stop there

languid spire
gleaming kraken
gleaming kraken
#

looking at the console it says that

swift crag
#

Indeed.

#

Vector3 is a struct, so it's a value type

#

Value types are never shared. They're copied around.

summer stump
# gleaming kraken

Copy the position, modify y of the copy, write the modified vector back

swift crag
#

Transform.position is a property, so it's actually a function that returns a Vector3

#

The Vector3 you get is much like a float or an int

#

You can't have several variables that reference the same Vector3. It's just a value.

#

So modifying the returned Vector3 would do nothing.

gleaming kraken
swift crag
#

The access modifier is invalid here.

languid spire
#

.y is not a Vector3

swift crag
#

An access modifier can only be used when declaring a member (field, method, property, nested type, etc.). Local variables are not a kind of member.

gleaming kraken
#

wait right

#

its just the position

summer stump
gleaming kraken
#

ohh

steel geyser
#

good job gpt , very nice 👍

short hazel
#

F*ck around and find out

gleaming kraken
#

hypothetically this SHOULD work

gleaming kraken
scarlet skiff
#

if anything you can use it to do stuff you already know, not new stuff

languid spire
scarlet skiff
#

many times it can miss minute detaljs or not ask for important stuff you forget to mention, and when it doesnt work and you ask it to fix it, it will take a total different approach and still not think of those basics

craggy lava
#

Error:

NullReferenceException: Object reference not set to an instance of an object
PickUpObject.Update () (at Assets/Scripts/PickUpObject.cs:21)

Line:

if (hit.transform.tag == "Pickup")

Full code:

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

public class PickUpObject : MonoBehaviour
{
    [SerializeField]
    Transform pickupPoint;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Debug.Log("Shooting ray!");
            if (Physics.Raycast(ray, out hit))

                Debug.Log(hit.transform.name);
            if (hit.transform.tag == "Pickup")
            {
                hit.transform.parent = pickupPoint;
            }
        }
    }
}
gleaming kraken
summer stump
#

It is a vector3 variable

summer stump
#

That isn't used anywhere

gleaming kraken
steel geyser
gleaming kraken
#

or would that not work unless I declared it initially

swift crag
summer stump
swift crag
#

I talked about the meaning of a value type

#

It is not shared.

#

It is always copied.

short hazel
gleaming kraken
polar acorn
craggy lava
craggy lava
scarlet skiff
# steel geyser i can read codes but i cant write

keep writing code and some things will come naturally, tbh even if you 100% know something and it would just be easier to write a prompt to chatgpt, i think you yourself should still write that code, let it become engraved in your mind, soon you will become your own chatgpt

short hazel
craggy lava
# short hazel Do you get the log? What does the new code look like?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PickUpObject : MonoBehaviour
{
    [SerializeField]
    Transform pickupPoint;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Debug.Log("Shooting ray from your cursor!!!");

            if (Physics.Raycast(ray, out hit))
            {
                Debug.Log(hit.transform.name);

                if (hit.transform.tag == "Pickup")
                {
                    hit.transform.parent = pickupPoint;
                }
            }
        }
    }
}
polar acorn
#

The name of the object?

craggy lava
short hazel
#

First log?

polar acorn
craggy lava
short hazel
#

Your ray isn't hitting anything then

craggy lava
polar acorn
craggy lava
polar acorn
craggy lava
polar acorn
steel geyser
#

is there code editor in unity , i can open it from windows ?

#

msv is slow

empty dagger
#

How do I use "(Input.GetButton("Jump"))" in a way where it only activates once and not the whole duration i hold the button? Is there a different version of GetButton I can use?

empty dagger
#

Ohh okay, thanks

summer stump
summer stump
craggy lava
steel geyser
languid spire
summer stump
trail folio
#

Hey,
I downloaded an asset and I would to reference it my code but I can't find it in Rider.
What should I do?

polar acorn
trail folio
#

Yeah it is

polar acorn
#

if you type the class name, your IDE can probably auto-complete the import

summer stump
#

Why would you not be able to?

trail folio
polar acorn
trail folio
polar acorn
zinc warren
#
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("TOUCH");
        if (collision.gameObject == enemyCreature)
        {
            Debug.Log("Collision Detected!"); 
            TakeDamage(10); 
        }
    }

why won't it output TOUCH when there's a collision? i have attached a rigidbody 2d and a capsule collider 2d to a 3d capsule as i want to achieve some an isometric effect

rocky canyon
#

if its on a 3d capsule are u sure the two colliders are on the same plane of existence?

#

or will that even work that way? im not sure

swift crag
#

i don't think 2D colliders care about depth

summer stump
#

Oooo, one is 3d? Intereeesting
No idea how that works out

swift crag
#

depth can be used when doing queries

rocky canyon
#

yea he said he put those components on a 3d capsule

swift crag
#

Although the Z axis is not relevant for rendering or collisions in 2D, you can use the minDepth and maxDepth parameters to filter objects based on their Z coordinate.

rocky canyon
#

ahh okay

craggy lava
#

Error:

My error is that it does not set the position of the hit obj to 0,0,0

Line:

hit.transform.position = Vector3.zero;

Full code:

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

public class PickUpObject : MonoBehaviour
{
    [SerializeField]
    Transform pickupPoint;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {

            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (hit)
            {
                if (hit.transform.tag == "Pickup")
                {
                    hit.transform.parent = pickupPoint;

                                   hit.transform.position = Vector3.zero;

                }
            }
        }
    }
}
rocky canyon
#

soo it just sort of smashes it into a single plane of existence

zinc warren
summer stump
polar acorn
summer stump
#

Show that one

swift crag
#

2D and 3D colliders will not interact.

polar acorn
# craggy lava ye

Okay, and after the raycast, what are the positions of the object you've clicked on and its parent?

zinc warren
rocky canyon
#

but with 2d colliders

#

both having 2d colliders?

craggy lava
zinc warren
polar acorn
polar acorn
#

It's entirely possible that the object is at 0,0,0, but you don't see that in the inspector

craggy lava
polar acorn
zinc warren
polar acorn
craggy lava
polar acorn
polar acorn
summer stump
craggy lava
summer stump
craggy lava
polar acorn
# craggy lava idk

Log this after you set the position:

Debug.Log($"{hit.transform.name} is at world {hit.transform.position}, local {hit.transform.localPosition}");
summer stump
craggy lava
polar acorn
#

Okay, looks like it's definitely being set to 0,0,0

#

If it doesn't stay there, something else is moving it

craggy lava
#

But its not at the HoldPosition

polar acorn
craggy lava
polar acorn
# craggy lava

Okay and what does this have to do with the code provided

#

What object is this

#

is this HoldPosition?

craggy lava
craggy lava
polar acorn
#

According to your log

polar acorn
craggy lava
# polar acorn

My Player is teleporting when i move away and click on the key

summer stump
#

What object is PickupObject attached to?

craggy lava
little seal
#

why does the highlight child disable when it spawns? its enabled in my prefab

summer stump
# craggy lava The player

Ok good. Well, it is hitting the player for some reason.
Two things

  1. use Debug.DrawRay to make sure it is going where needed
  2. use a layermask to prevent the player from being hit
summer stump
little seal
summer stump
little seal
#

oh hold on

#

i forgot to remove setactive

#

ur right

#

ty

summer stump
#

This doesn't make sense

#

Are you setting the transform.position?

#

Try to reexplain because it wasn't clear what the issue is

empty dagger
#

I'm trying to make it so if the player is colliding with a wall and not grounded, they can press the jump button to do another jump, but atm it barely ever works, I think it's only activating during the peak of the jump, meaning it doesnt work if the player is already moving up/down, I think? What do I change here to make it so it works at any point jump is pressed? https://gdl.space/tehekavini.cs

covert crown
#

Can anyone help me? Usually what I want to type, it wont color that word. Is it supposed to be a problem?

indigo wagon
#

I've came from a different engine so can someone point me as to why this is wrong

slender nymph
#

start by reading what the error said

#

then i recommend also looking into using Input.GetAxisRaw instead of manually polling the keys and adding/subtracting manually from the Vector2

indigo wagon
slender nymph
#

better than GetKeyDown or better than just regular GetAxis? because for the former, it actually returns the value of the axis rather than requiring you to add/subtract manually. the latter because it only returns -1,0,1 for digital input which is clearly what you want

indigo wagon
slender nymph
#

correct because you do not assign to it. local variables do not get their default values assigned, they are unassigned until you actually assign to it

rocky canyon
#

this is the axis input he spoke of

#

2 lines vs (howmany ever u have)

#

does the exact same thing

polar acorn
indigo wagon
#

so is there no way to just make it assigned to do nothing until something is pressed

polar acorn
gleaming kraken
#

so on one of the junior programmer challenges, I needed to make a balloon bounce off of the ground. I noticed in the comments most people actually used a tag to get if the balloon collided with the ground, while I just checked if the y is lower than 0. Which one of these two methods is considered a better practice than the other just to know for future reference?

polar acorn
#

you want to instead assign it to something until you press a button and assign it to a different thing

slender nymph
slender nymph
rocky canyon
#

or if the balloon has a script on it could check that

indigo wagon
slender nymph
#

just assign Vector2.zero instead of each axis manually

polar acorn
#

or just use GetAxis

rocky canyon
#
            inputDirection.x = Input.GetAxisRaw("Horizontal");
            inputDirection.y = Input.GetAxisRaw("Vertical");```
indigo wagon
#

gonna sound really petty but I like powering through my coding mistakes even if they are stupid lol

rocky canyon
#

sure thing 👍

indigo wagon
#

so it's obviously not as efficient

#

but fun

polar acorn
#

Switching to GetAxis is powering through it

#

The same way fixing your compile error is

rocky canyon
#

i get what ur saying about using ur own code.. but ur gonna learn real quick to refactor what u have

#

nothing wrong with changin something to make it work

indigo wagon
#

I know for a fact you're both obviously right

#

I guess I'm just stubborn

slender nymph
#

yeah fix the issue, don't just leave bad code there just because you want to "power through it". you wouldn't try and cook a steak but leave it on the grill until it's done even though you forgot to turn the grill on

rocky canyon
#

ur gonna spend 2x time as long when u could be having fun doing ur next thing

rocky canyon
indigo wagon
#

Only thing is I've gone through both godot and monogame so I tried to stick to what I "knew" but I'll give it a shot

polar acorn
rocky canyon
#

i mean, hes not wrong

polar acorn
#

If you switched engines it was surely for a reason, right? Use the stuff the engine gives you

rocky canyon
#

ur gonna need to adapt to what works for Unity

indigo wagon
slender nymph
#

also the original issue would have happened in both godot and monogame since it was a compile error with how c# works and not specific to unity

reef oyster
#

hi i need some help w/ my vs 2022, Its not detecting the documentation and I cant really know if it's working or not. Any possible fixes? I already tried downloadnig any missing asset.

slender nymph
#

!ide

eternal falconBOT
rocky canyon
#

but yes, just set the input to 0 at the top of the first frame.. then ur chain of if statements will change it to what it needs to be..

#

if no input is given it will stay 0 for ya

#

hacky but will work

reef oyster
slender nymph
#

if you have completed all of the steps there then regenerate project files and restart visual studio

rocky canyon
#

if its working Monobehaviour will be colored.. and hovering it will tell u its from Unity

reef oyster
#

thats the problem.. it isnt

rocky canyon
#

yea, just letting u know what to look for since u said u didnt know how to tell if it was or not

#

u gotta follow the steps again..

#

theres no other way to get it working

pine umbra
#

Hi! I have problem with my enemy's knockback - There is a func which is responsible for tracking player and its based on .MoveTowards func which is using enemy's positon from transform component. In diffrent script there is func .AddForce which is using (or at least should) enemy's rigidbody2D component to push it from my player when it's beeing hit. Problem is that my knockback simply doesn't work and I just wonder if that is a bug or it should be like that and manipulating this could cause other problems.

slender nymph
rich egret
#

!code

eternal falconBOT
rich egret
polar acorn
slender nymph
#

also obligatory: use cinemachine

pine umbra
slender nymph
#

yes, you choose one way to move the object and use that to do both

polar acorn
rich egret
#

Yes, but without this script the camera moves really slowly @polar acorn @slender nymph

pine umbra
#

Yup, thank u guys

rocky canyon
#

cinemachine

frigid sequoia
#

Can I instantitate an object in relative coordinates? Like... adding an offset vector to the position of instantiate but taking into account that the item might be rotated....

#

Kinda hard to explain like this....

rocky canyon
#

just add the offset to its localPosition

hexed terrace
#

you can instantiate an object wherever you want to

rocky canyon
#

^ this too

pine umbra
frigid sequoia
#

Like the cone instantiates proyectiles, but it does so in its possition, so its origin; that cone rotates in the green axis, seeking for targets, I want the offset to add a bit of "foward" depending on which direction the cone is rotated at the moment, so I can swap the current red trayectory to the yellow one

hexed terrace
#

easiest way is to have an empty game object in the location you want to spawn things, and pass that in as the position when instantiating

#

you can then easily move that empty transform around to reposition without going in/out of code

frigid sequoia
#

Yeah, that would be the most precise, but I am already having this thing kinda like... really nested in a good chunk of parents, doesn't this cause performance issue? Can I not just add the offset by code?

hexed terrace
#

no? why would you get performance issues with an empty transform?

#

you can add the offset by code if you want to do it that way..

frigid sequoia
hexed terrace
#

nope

polar acorn
pine umbra
ionic zephyr
#

If I want each of my characters to have different habilities or attacks should I make a Script for every character like "Character Name"Attacks???

polar acorn
ionic zephyr
muted wadi
#

my camera will not rotate towards the new vector

{
    float step = speed * Time.deltaTime;
    Vector3 camTargetQ = camTarget - cam.transform.forward;

    Vector3 newDir = Vector3.RotateTowards(cam.transform.forward, camTargetQ, step, 0.0f);
    cam.transform.rotation = Quaternion.LookRotation(newDir);
    cam.transform.position = Vector3.MoveTowards(cam.transform.position, targetPos, step);
    yield return null;
}```
#

i dont get what im doing wrong

brazen canyon
#

Hey guys

#

I'm trying to detect when I start using the joystick and when I stop

reef oyster
#

yea im clueless to why it isnt detecting monobheaviour

#

i followed all the god damn steps already

#

aight i figured it out

#

how i feel now:

rich adder
#

stop with the useless meme crap

reef oyster
brazen canyon
muted wadi
#

blud does NOT wanna keep image perms

muted wadi
rich adder
reef oyster
polar acorn
reef oyster
#

you mean a single png

rich adder
reef oyster
#

its the end of the world

#

its over

languid spire
#

you let one idiot get away with posting crap, all of a sudden all the idiots want to do the same

reef oyster
#

yea guys dont express how you feel when you fix something here

#

go post your crap elsewhere

rich egret
#

Does anyone know how to change rotation speed in CinemachineVirtualCamera?

languid spire
reef oyster
#

because you have probably never touched grass

polar acorn
#

This has gone on long enough

muted wadi
polar acorn
languid spire
rich adder
muted wadi
#

im not really sure what to debug here, i tried to debug the position of the target rotation but it came up with numbers that weren't correct at all

languid spire
#

everything, so far you know nothing, your just guessing

rocky canyon
pastel pollen
#

When scheduling an IJobParallelFor job, the documentation says that unity automatically splits the work into chunks of no less than the provided batchSize, does that mean that unity performs some check behind the scenes if a larger batch size is better? I'm not sure how to reason about choosing batch size, and it seems like a time sink manually benchmarking for different batch sizes, any tips?

north kiln
ionic zephyr
#

If I want each of my characters to have different habilities or attacks should I make a Script for every character like "Character Name"Attacks???
or is it better to have one for every character and then check which gameobject is the one handling that script???

eternal needle
frigid sequoia
#

Do I need an animator controller to add a single simple animation? Cause pretty sure I did that before but now it isn't working for some reason

ionic zephyr
#

for example

eternal needle
ionic zephyr
ionic zephyr
modest dust
#

Depends on the kind of attack

#

If each attack has similar properties, it can be one script, then just make several instances of the same script for each attack and set up its fields accordingly

rugged plover
#

Nevermind

ionic zephyr
modest dust
#

That would require two different scripts.

ionic zephyr
modest dust
#

Could be one parent class, say Ability with an Invoke(ICaller caller) method, and several effect scripts, let's say deriving from an IEffect interface

#

IEffect could have an Apply(ICaller caller) method, each effect would define it's own apply behaviour and manipulate ICaller's properties / call some methods

#

Effects can be stored in an [SerializeReference] IEffect[] array within the Ability class

eternal needle
# ionic zephyr Oh isnt that less efficient, just asking because Im really noob

Efficiency shouldnt be your concern here. No it is not less efficient, you simply just attach the needed scripts to an object. If it doesnt have the script, it doesnt have the ability. If your abilities were all grouped in 1 script, itd be worse actually because this would be a major hassle to make 2 enemies with the same abilities excluding one

ionic zephyr
modest dust
#

This array can be hidden in the inspector and instead the visible thing would be an [SerializeField] EffectWrapper[] array, which basically contains two fields, enum EffectType and IEffect, the first one used purely to know which class deriving from IEffect to instantiate (idk if there's a prettier way). EffectWrapper would exist purely to instantiate the correct effect and unwrap it back into the IEffect[] array in the Ability class

#

That's a bit of work, but will hopefully result in a somewhat flexible ability system

eternal needle
#

Similarly, cant make an ability which boosts your players stats if your stats doesnt accept boosts yet

nocturne parcel
ionic zephyr
nocturne parcel
#

Take a look at League of Legends. Any champion ability that spawns something in the map shares the minion code.

next reef
#

quick question do i need to name something doorAnim from line 7?

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

public class NewBehaviourScript : MonoBehaviour
{
public Animator doorAnim

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        doorAnim.SetTrigger("open");
    }
}
void OnTriggerEnter(Collider other)
{
    if(other.CompareTag("Player"))
    {
        doorAnim.SetTrigger("close");
    }
}

}

nocturne parcel
#

!code

eternal falconBOT
ionic zephyr
ionic zephyr
# nocturne parcel !code

sory, just curious, are you spanish? because maybe my questions would be better in my native language

eternal needle
nocturne parcel
#

I dunno, better than suggesting a bunch of redundant code they must be.

ionic zephyr
nocturne parcel
ionic zephyr
magic condor
#

I have an issue with my VR game mod, I'm trying to apply a custom material from an asset bundle onto the player model's SkinnedMeshRenderer, but the material isn't getting applied to the player.

eternal needle
nocturne parcel
#

Caesar gave a suggestion. For me, it's hard to tell what I would definitelly use. My first try would be an ability script that either inherits from interfaces or uses scriptable objects.

#

Again, you need to test it out and have a definitive goal in mind.

ionic zephyr
ionic zephyr
magic condor
eternal falconBOT
magic condor
#

Sorry

carmine sierra
#

any logic wrong with this

#

i want it to move to the mouse position when the if condition is met

fierce geode
#

This is more of a subjective question, but when do you choose to split off code into different scripts? Is it just when the script gets too long, or if the elements of the script stray too far from the core execution idea of the script?

carmine sierra
north kiln
#

Presumably due to the issue mentioned in the link

carmine sierra
#

fair ill check it

nocturne parcel
carmine sierra
#

the same code works when another object follows the mouse

#

just in this script im doing something wrong

north kiln
#

So your camera is orthographic?

carmine sierra
#

not sure

north kiln
#

Select it and look at the projection type

rocky canyon
#

check

carmine sierra
#

orthographic

north kiln
#

Okay, then my only assumptions would be that either the code isn't running, or something else is driving the transform and overriding it

carmine sierra
#

here is the script if someone is able to check 🙏

rocky canyon
#

shouldnt it be OnMouseUp? where spawned goes false?

#

idk im just guessing

#

id put a debug in ur if(spawned) block to see if its running

carmine sierra
#

I found the issue i think

#

I was trying to transform the prefab

#

not the instance of the prefab which is spawned in

rocky canyon
#

oh, yup thats what u were doing

ionic zephyr
#

Is it better to have all my habilities classes in one script or in separate ones?

summer stump
#

How similar are they?

ionic zephyr
#

I mean like pokemon attacks

#

for example

summer stump
#

And when you say "in the same class" do you mean like a list of them, or implemented in the same class

#

If a list, then the same is fine.
If implementation, then CERTAINLY separate classes

ionic zephyr
summer stump
#

One class per file

ionic zephyr
#

Okay, makes sense

ionic zephyr
ionic zephyr
#

I am doing an Habilities Class from which every habilities class will inherit

summer stump
#

Is hability something specific, or just a way of saying ability?

ionic zephyr
#

oh sorry, spanish error

#

ability

summer stump
#

No worries. Just curious

#

All good

ionic zephyr
summer stump
ionic zephyr
#

thanks for all!

rocky canyon
frigid sequoia
#

I need the first if clause to execute in normal Update and the rest in Fixed, but I need all the logic to happen in the same Update, how do I... fix this mess? XD

summer stump
rocky canyon
#

no clue what that is 😄

#

yea mean just a reg enum?

#

the purpose being to flag certain groups?

summer stump
#

[Flags] attribute over it

rocky canyon
#

ahh yea yea . ok gotcha.. u know how to help daleo_dorito up there ^ 😅

#

id be interested in a solution.. just cuz lol

summer stump
#

The null check?

rocky canyon
#

i was thinking extra bools.. but thats always my solution

carmine sierra
#

does onmousedown only trigger when the script parent object's collider is pressed on

summer stump
#

All of it will happen in the same physics frame (that is for Daleo)

empty dagger
#

I'm trying to implement a walljump but it only works randomly and I can't figure out what's causing it.
https://gdl.space/tehekavini.cs
it works consistently if I change GetButtonDown to GetButton but then it keeps jumping if I hold the button in. atm if I stand against a wall and spam the jump button, instead of continuously jumping up it will ignore most my inputs and just jump at random intervals. Does anyone know how I can fix this?

rocky canyon
#

collisions can occur on child colliders if the parent has a rigidbody.. (all colliders get grouped like 1 big collider)

#

not sure if that applies to the OnMouse events tho

summer stump
#

Set a bool true or false, and then handle input in update based on that bool

rocky canyon
#

^ thats like trying to snatch a fly out of mid-air

#

the odds that u hit the key the exact same frame that the OnCollision fires off is very low

carmine sierra
#

i might be an idiot but what is wrong with this

frigid sequoia
empty dagger
summer stump
quartz mural
#

how do i make it so that the background goes

#

i thought by getting a transparent one it would already be ogne

#

seems not though

rich adder
carmine sierra
#

from the function?

quartz mural
#

u dont know how?

rich adder
carmine sierra
rich adder
carmine sierra
#

idk what can means

#

i thought itd just enter on the if conditions

#

but i see that i am assuming it works like other functions

#

i should just put it in update then?

rich adder
#

wdym other functions?

carmine sierra
#

like onmousedown and update

#

cause that's what ive been using for the most part

rich adder
#

why would it be called by itself

carmine sierra
#

wym

#

but yeah i see what i might be doing wrong

summer stump
#

Are you asking what an early return is?

rich adder
summer stump
#

if (isInstantFollow) return;

frigid sequoia
#

Can u dod that?

ionic zephyr
summer stump
carmine sierra
#

i just forgot that every function needs to be called

#

since starting c# i only coded within functions when I am not initialising variables

rich adder
#

unity Monobehaviours is special case with built in Events like Update

carmine sierra
#

yeah

summer stump
carmine sierra
#

OHH nvm

ionic zephyr
#

but if I want to assign the different habilities how can I do that in the editor?

summer stump
empty dagger
#

What do I add to this code to make it so the player is pushed away from the wall theyre currently colliding with? atm it's just a jump but I want it to push them in the opposite direction too to prevent jumping up the same wall continuously, I couldn't find a tutorial for this, probably because I don't really know how to word it specifically
https://gdl.space/lecokonuve.cs

modest dust
summer stump
modest dust
#

Yeah, so there's no issue with that

#

Idk about a List tho, didn't try it out

#

But a [SerializeReference] IEffect[] array should do the job if set up correctly

summer stump
#

Maybe the issue was list vs array?

#

And we're talking about drag and dropping via the inspector, right? Because that's what they wanted

modest dust
#

I'm talking about setting it in the inspector, not drag and dropping
In that case it's a different scenario

summer stump
#

Ah, I could have misunderstood them too. I dunno

modest dust
#

But it still could be done via drag and drop I guess..
By drag and drop I assume using ScriptableObjects? Then just move what I just wrote into that and drop a singular-type SO into the field

summer stump
#

I had been assuming they meant MonoBehaviours

modest dust
#

I mean, they were talking something about an Ability System

#

So these abilities would either be set up directly on the MonoBehaviour in the inspector or on the SO and dropped into a field on said MonoBehaviour

empty dagger
#

How do I specify the direction of a contact point? Like, so far I'm trying a "rb.AddForce(something * jumpForce)", I can't find out how to specify that the direction should be opposite to the contact point currently being touched (assuming I'm going about this the right way)

north kiln
#

would it not be the normal?

abstract sparrow
#

so void start is where the script is called into a scene. whats the void for when you first boot up the game

summer stump
eternal needle
north kiln
summer stump
abstract sparrow
#

i have basically 3 types of score. score/highscore/wr

#

once a high score is hit, it saves into disk along with the wr

#

but then when i reboot the game, the highscore gets filled and i want it to basically reset to 0, now i tried to do awake but now it didnt pick up my all time highscore when teh games first booting up

summer stump