#show me a picture of what you mean

1 messages · Page 1 of 1 (latest)

shy topaz
#

here

past phoenix
#

basically im trying to input the actual playermovement script into that slot titled "player move script"

#

along with the ui game objects

shy topaz
#

this is the picture of the prefab script?

#

or no

past phoenix
#

the "Pistol Attack" script is on the pistol prefab

#

which is being instantiated by the weapon pickup

shy topaz
#

how are you trying to get the script?

#

the playermovement script

past phoenix
#

this is what im trying to figure out

#

been using getcomponent but not really sure how

shy topaz
#

im guessing the pistol script is a child of the player?

#

in a pistol

#

if thats the case then use getparentcomponent

#

i believe thats what is it called

past phoenix
#

pistol prefab is instantiated as a child of weapon slot

shy topaz
#

okay so what you can do is to get the parent of the pistol which is the weapon slot then get the script you want from the player from the weapon slot

#
        PROP = this.gameObject.transform.parent;

        SCRIPT = PROP.GetComponentInParent<somescript>;
#

this should work

past phoenix
#

thank you

#

@bitter hinge is gonna have to try it out cause i’m no longer on pc

shy topaz
#

okay 👍

bitter hinge
shy topaz
#

well you wanted to get the player movement script so

#

the PROP is the pistols parent object. the SCRIPT is the playermovement script which comes from the PROP's parent which is the player

#

all you have to do is make a transform at the top of you script for PROP (you can name it whatever) and the component you are looking for at the top as well, so it would look something like this.

Public Transform PROP; //name prop to whatever
Public somescript SCRIPT; // name this whatever and change somescript to playermovement