#Untitled Horror Saga

1 messages · Page 1 of 1 (latest)

plucky venture
#

my bad aha

#

but yeah hang on

flint hollow
#

alr

plucky venture
#

is there anything wrong with this code

flint hollow
#

well first, did you change anything in here?

plucky venture
#

not that i remember

flint hollow
#

and what is exactly wrong

#

breaking how

plucky venture
#

lemme records a vid

flint hollow
plucky venture
#

this has nothing to do ith buttons

flint hollow
#

wdym well how do you reactivate the player

plucky venture
#

it was already enabled when i started recording

plucky venture
#

oh wait

#

ignore me

#

shhhhh

plucky venture
#

its meant to do it by default

#

cause of how my code is

flint hollow
#

because this is not a very good condition

#

if (inventoryCanvas != null && inventoryCanvas.gameObject.activeSelf)

plucky venture
#

i just got rid of the null check

#

but still no reactivation

#

imma save here and come back tomorrow

#

its christmas and its 4.30am lol

flint hollow
#

yeah approach this with fresh mind is probably something simple

plucky venture
#

yeah for sure

plucky venture
flint hollow
#

so you can just @ me

plucky venture
#

bet

#

anyways though

#

youve been a massive help to me so far so ill see you tomorrow broski

#

have an amazing christmas

flint hollow
#

no problem! Thanks. You too 🎅

plucky venture
#

❤️ 🎅

plucky venture
#

yo @flint hollow

#

i need some help disabling a script when a condition is met

plucky venture
#

@flint hollow i need help on teleportation of an object

#

cause ion know how to activate a script when a button is clicked

plucky venture
plucky venture
# flint hollow wdym

but now i need to make it so that it teleports to my hand if it exists but its not a child to ItemLocation

#

@flint hollow this is my psuedocode sort of explaining what im trying to run with the button

flint hollow
plucky venture
#

cause im kinda trying to use the code from when i picked it up originally, to teleport it to my hand

flint hollow
plucky venture
#

it seems to just be a buncha if statements

#

connected to as you said a setparent method

flint hollow
#

you already pretty much wrote it in psuedo

plucky venture
#

but the main issue im having is the activation upon click of the button

flint hollow
#

wdym you already used SetActive before..

plucky venture
#

i never

flint hollow
#

you have it in your code when you activate the panel

plucky venture
#

oh wait apparently i did

#

lemme gather my thoughts real quick

#

okay its kinda working

#

but i have an issue

#

when i use my inventory state script, it disables my "hands" if you wwill, in which when it tries to teleport it it must cause some sort of issues

flint hollow
#

I dont know I haven't seen it

plucky venture
#

ill send a video hang on

plucky venture
# plucky venture

@flint hollow ive reference the right object, i think its just finding out how else i could pause my torch, or just find out how to make this work

plucky venture
flint hollow
plucky venture
flint hollow
#

dont use inspector for this type of stuff

plucky venture
#

and thats my InventoryState script

flint hollow
#

you should call a method you custom made like pickup

#

dont call SetParent from inspector like that

plucky venture
#

ion know how to do that

flint hollow
#

you literally already made it

#

in the Pickup script

#

its all the same stuff

plucky venture
#

hang on then wait a sec

#

transform.SetParent(gunContainer); where do i put this?

flint hollow
#

in a method like the pickup , do you see the pickup?

plucky venture
#

the script?

flint hollow
#

just make another method

plucky venture
#

so all of that is pickup

flint hollow
#

ReturnToHand() or something

plucky venture
#

ohhh i think i know what you mean

#

copy paste the same code?

flint hollow
#

only difference is remove the thing you did the first time

#

or just call pickup again..

#

in the button

#

but you should make this script not be only for torch pickup/dropoff

#

so you can pass Item into it

#

like I was saying yesterday

#

or else you gotta make one for each thing and then light.enabled = true. will be null in other classes that dont have light

plucky venture
#

im gonna be honest im a little confused as to what i need to do?

flint hollow
#

its confusing because your whole system is NOT clean at ALL

#

you're making the hole bigger instead

plucky venture
#

i know i know

flint hollow
#

you need refactor it to make it clean

plucky venture
#

what would you say my next step should be?

flint hollow
#

first do the stuff I was mentioning yesteday with having a generic Item class so it can be used

plucky venture
#

okay bet

#

what is the next step to achieve this

flint hollow
#

then refactor the pickup script to work with Item generic

#

this way button is linked to specific item

#

if the item is already picked it can be dropped without removing it from list

plucky venture
flint hollow
plucky venture
flint hollow
plucky venture
flint hollow
#

why are you naming such shit names

#

literally not what I typed

plucky venture
#

okay okay 😭

#

one sec

flint hollow
#

Naming things properly is just as important as the code itself

plucky venture
flint hollow
#

right

#

change Torch script to inherit Item

plucky venture
#

how would i do that?

flint hollow
plucky venture
flint hollow
#
public class Torch : Item```
plucky venture
#

but the torch hasnt got any behaviour?

flint hollow
#

what aout turning light on and off?

plucky venture
#

it can literally turn a spotlight off and on

flint hollow
#

thats still behavioir

plucky venture
#

ohh okay

#

so you just want me to separate it?

flint hollow
#

where is it now

#

turning light on or of

plucky venture
#

in case later on i wanna add a battery life to it?

flint hollow
#

right exactly

plucky venture
#

lemme grab the code and move it over

flint hollow
#

yeah pickup controller should not be toggling the light

#

not all pickup items will have a light

plucky venture
#

i made this

#

and it attached to my torchobject

#

unless it shouldnt be

flint hollow
#

this supposed to inherit Item

#

Item is already MonoBehavior

#
public class TorchBehavior : Item```
plucky venture
plucky venture
plucky venture
#

ill show you

#

i cant even add it back on

flint hollow
#

fix it

#

expand console window

plucky venture
flint hollow
#

yu have clones of two scripts

#

what did you did you do

#

did you create Item in some other class

plucky venture
#

hang on a sec

plucky venture
#

okay i fixed it

flint hollow
#

so now do yu have the proper

#

classes

plucky venture
#

only the files you told me to make

flint hollow
#

why did you write it like this

plucky venture
#

wait wrong file

#

imma delete that

flint hollow
#

just delete and remake them

#

dont Put CLASS inside of names of classes

#

they're not class , they're objects. class can be ommited

plucky venture
flint hollow
#

ok

plucky venture
#

those are the 2 files i have

plucky venture
flint hollow
#

now the ITEM class needs to have anything that Items will have

plucky venture
#

so all the stuff other than the script from my pickup script?

flint hollow
#

not all the stuff, stuff to not just torch but any item will have

#

like Rigidbody field

#

etc

plucky venture
#

everything EXCEPT lighton

flint hollow
#

and player

plucky venture
#

okay bet

flint hollow
#

gun container and fps cam should also stay on pickup script

#

basically only Rigidbody and Collider

plucky venture
#

why so?

flint hollow
#

and then additional fields you want

#

like Item name, Item decription

#

maybe quantity etc

plucky venture
#

nah ion need quantity

flint hollow
#

just making a point

plucky venture
#

okay okay

flint hollow
#

Item will be the template for anything that Inherits it

plucky venture
#

so what code would i put where?

flint hollow
plucky venture
#

i think i understand

flint hollow
#

public Rigidbody rb

#

public Collider col

plucky venture
#

just those 2?

flint hollow
#

for now

#

unless u added other stuff later or something

#

public string ItemName ?

#

depends what fields u need

plucky venture
#

i dont need the name just yet

flint hollow
#

so just leave those two for now..

plucky venture
#

i just wanna get some functionality and clean up

flint hollow
#

put those fields there and hit save on Item class

#

put the TorchBehavior on the torch

#

you will now see those fields on that class

plucky venture
flint hollow
plucky venture
flint hollow
#

in the project window

plucky venture
flint hollow
#

misspelled

#

filename and class name dont match

#

look the spelling

plucky venture
#

that fixed it

flint hollow
#

ok

#

so put it on torch and u should see the fields

plucky venture
#

yeah

flint hollow
#

ok so fill them in from the torch obj

plucky venture
flint hollow
#

you have to just cleanup the pickup script to work with that

#

how do you currently pickup script

#

also reference the inventory class from this pickup script

plucky venture
#

what

flint hollow
#

nvm i see the script

#

how do you physically pickup the torch

#

detect it

plucky venture
#

i actually dont think i know

flint hollow
#

if (!equipped && distanceToPlayer.magnitude <= pickUpRange && Input.GetKeyDown(KeyCode.E) && !slotFull) PickUp();

plucky venture
#

yeah

flint hollow
#

this only looks for torch

#

you have to change it up

#

to only find Item

plucky venture
#

then it has a pickup function which then moves the parent, and makes sure its facing the right way, right size etc i think

flint hollow
#

the important part is having a physics query

plucky venture
#

a what

flint hollow
#

Physics.OverlapSphere

plucky venture
#

imma be honest, so far has been quite weird for me because ive been using a mixture of tutorials, chatgpt, and my own initiative, so do apologise if i ask a shit ton of questions that should be simple, im slowly getting the grasp of everything

#

its just retaining the info and learning new stuff

flint hollow
#

I told you inventory is not easy

#

you started too complex before learning basics

plucky venture
#

well thats regular inventory

flint hollow
#

you keep saying " i just need to do thi"

plucky venture
#

mine is sorta button unlocking based off of triggers

flint hollow
#

it doesn't matter what the design is

#

you have to learn basics

#

like how to detect pbjects

#

how to store object in a list

#

you're trying to run before knowing how to walk...

plucky venture
#

i know what you mean

#

anyways though, whats next?

flint hollow
#

see.. no anyways

#

you have to learn this stuff

#

im not trying to do a 1 on 1 tutoring

plucky venture
#

yeah i know what you mean

flint hollow
#

maybe a Raycast too

#

lookup tutorials on how they work

#

almost all pickup systems use some sort of physics queries

#

you see the example

Collider[] hitColliders = Physics.OverlapSphere(center, radius);
        foreach (var hitCollider in hitColliders)
        {
            hitCollider.SendMessage("AddDamage");
        }```
all you do is replace it with checking Item
#
Collider[] hitColliders = Physics.OverlapSphere(center, radius);
        foreach (var hitCollider in hitColliders)
        {
            if(hitColliders.TryGetComponent(out Item item))
            {
              inventoryController.PickUp(item);
                break;}

        }```
#

just an example

plucky venture
#

okay i think i know how it wworks

#

it has a "sphere" that is constantly checking and intaking new collision points, it then sort of looks at all these collision points and looks at their classes, it finds the torch for example and it looks at it and says "hey thats an item!" and then after that is when it can think about using the pick up script / code

#

i think?

flint hollow
#

put it inside E button press

#

but yeah

flint hollow
#

now you see why Item class is important

#

it doesnt care which item it is, just that it is an Item

#

so you dont need 20 differen checks for 20 diff items

plucky venture
#

i know what you mean now

plucky venture