#Untitled Horror Saga
1 messages · Page 1 of 1 (latest)
alr
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
is there anything wrong with this code
well first, did you change anything in here?
not that i remember
which method u call with button
this has nothing to do ith buttons
wdym well how do you reactivate the player
it was already enabled when i started recording
wat
thats what im saying
its meant to do it by default
cause of how my code is
because this is not a very good condition
if (inventoryCanvas != null && inventoryCanvas.gameObject.activeSelf)
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
yeah approach this with fresh mind is probably something simple
yeah for sure
what time are you normally on so i know when to catch you?
I'm usually on my phone
so you can just @ me
bet
anyways though
youve been a massive help to me so far so ill see you tomorrow broski
have an amazing christmas
no problem! Thanks. You too 🎅
❤️ 🎅
i fixed it noww
@flint hollow i need help on teleportation of an object
cause ion know how to activate a script when a button is clicked
so i got the button stuff i was talking about done
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
which part dont you know how to use
i dont know how to 1 code it, 2 activate it
cause im kinda trying to use the code from when i picked it up originally, to teleport it to my hand
you only need SetParent method and reset position to that
i was thinking that
it seems to just be a buncha if statements
connected to as you said a setparent method
you already pretty much wrote it in psuedo
but the main issue im having is the activation upon click of the button
wdym you already used SetActive before..
i never
you have it in your code when you activate the panel
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
so you refernced the wrong object probably
I dont know I haven't seen it
@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
show currect code
for what? my pickup script?
the one that just made what happen in video
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
and thats my InventoryState script
you should call a method you custom made like pickup
dont call SetParent from inspector like that
ion know how to do that
in a method like the pickup , do you see the pickup?
the script?
so all of that is pickup
ReturnToHand() or something
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
im gonna be honest im a little confused as to what i need to do?
its confusing because your whole system is NOT clean at ALL
you're making the hole bigger instead
i know i know
you need refactor it to make it clean
what would you say my next step should be?
first do the stuff I was mentioning yesteday with having a generic Item class so it can be used
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
i meant how would i make an item class
make a new file
public class Item : MonoBehaviour
am i making it anywwhere specific?
it needs to be in its own file doesnt matter where
Naming things properly is just as important as the code itself
how would i do that?
show torch script
Ok so make new script for torch behavior
public class Torch : Item```
but the torch hasnt got any behaviour?
what aout turning light on and off?
it can literally turn a spotlight off and on
thats still behavioir
in case later on i wanna add a battery life to it?
right exactly
attached to the pick up controller
lemme grab the code and move it over
yeah pickup controller should not be toggling the light
not all pickup items will have a light
this supposed to inherit Item
Item is already MonoBehavior
public class TorchBehavior : Item```
i also detatched it from TorchObject so this is just a file
cause the script was having naming issues
ill show you
i cant even add it back on
yu have clones of two scripts
what did you did you do
did you create Item in some other class
hang on a sec
jfc
why did you write it like this
just delete and remake them
dont Put CLASS inside of names of classes
they're not class , they're objects. class can be ommited
ok
those are the 2 files i have
this one is item.cs
now the ITEM class needs to have anything that Items will have
so all the stuff other than the script from my pickup script?
not all the stuff, stuff to not just torch but any item will have
like Rigidbody field
etc
everything EXCEPT lighton
and player
okay bet
gun container and fps cam should also stay on pickup script
basically only Rigidbody and Collider
why so?
and then additional fields you want
like Item name, Item decription
maybe quantity etc
nah ion need quantity
just making a point
okay okay
Item will be the template for anything that Inherits it
so what code would i put where?
wdym what code? you literally answered yur own question b4
i think i understand
just those 2?
for now
unless u added other stuff later or something
public string ItemName ?
depends what fields u need
i dont need the name just yet
so just leave those two for now..
i just wanna get some functionality and clean up
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
what is the filename of TorchBehavior
that fixed it
yeah
ok so fill them in from the torch obj
done
what do you have so far then
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
what
i actually dont think i know
if (!equipped && distanceToPlayer.magnitude <= pickUpRange && Input.GetKeyDown(KeyCode.E) && !slotFull) PickUp();
yeah
then it has a pickup function which then moves the parent, and makes sure its facing the right way, right size etc i think
the important part is having a physics query
a what
Physics.OverlapSphere
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
well thats regular inventory
you keep saying " i just need to do thi"
mine is sorta button unlocking based off of triggers
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...
see.. no anyways
you have to learn this stuff
im not trying to do a 1 on 1 tutoring
yeah i know what you mean
https://docs.unity3d.com/ScriptReference/Physics.OverlapSphere.html
this is one of the methods you should learn to pickup stuff
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
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?
ideally you dont want constant (since you only need to check on Pickup key pressed)
put it inside E button press
but yeah
it looks for colliders not collision point but yeah the gist is that
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
i know what you mean now
i just had a little dinner break and now i have no clue hat im supposed to be doing 😭