#show me a picture of what you mean
1 messages · Page 1 of 1 (latest)
basically im trying to input the actual playermovement script into that slot titled "player move script"
along with the ui game objects
the "Pistol Attack" script is on the pistol prefab
which is being instantiated by the weapon pickup
this is what im trying to figure out
been using getcomponent but not really sure how
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
pistol prefab is instantiated as a child of weapon slot
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
okay 👍
what are prop and script referring to?
ah sorry for the late response
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