Skip to main content
removed unityscript tag (doesn't apply), moved images directly into question, transcribed code from screenshot
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to Instantiate the weapon. I created a parameter in the script for the hand: [SerializeField] GameObject weaponSocket; and I tried to Instantiate the weapon like this like this: Instantiate(weaponPrefab, weaponSocket.Transform);, but I just cant drag the hand to the parameter.

Anyone knows how to do this correctly?

Thank you!

Images: Player script:  

public class Player : MonoBehaviour, IDamageable {

[SerializeField] Weapon weaponInuse;
[SerializeField] GameObject weaponSocket;

GameObject currentTarget;
CameraRaycaster cameraRaycaster;

// Use this for initialization
void start ()
{
   PutWeaponInHand();
}

private void PutWeaponInHand()
{
   var weaponPrefab = weaponInUse.GetWeaponPrefab();
   var weapon = Instantiate(weaponPrefab, weaponsocket. transform);
   weapon.transform.localPosition = weaponInUse.gripTransform.localPosition;
|  weapon.transform.localRotation = weaponInUse.gripTransform.localRotation;

https://i.sstatic.net/fIuaG.jpgenter image description here Trying

Trying to drag the left hand to the parameter (indicated by red arrows):    https://i.sstatic.net/0EwlW.jpgenter image description here

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to Instantiate the weapon. I created a parameter in the script for the hand: [SerializeField] GameObject weaponSocket; and I tried to Instantiate the weapon like this like this: Instantiate(weaponPrefab, weaponSocket.Transform);, but I just cant drag the hand to the parameter.

Anyone knows how to do this correctly?

Thank you!

Images: Player script:  https://i.sstatic.net/fIuaG.jpg Trying to drag the left hand to the parameter (indicated by red arrows):  https://i.sstatic.net/0EwlW.jpg

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to Instantiate the weapon. I created a parameter in the script for the hand: [SerializeField] GameObject weaponSocket; and I tried to Instantiate the weapon like this like this: Instantiate(weaponPrefab, weaponSocket.Transform);, but I just cant drag the hand to the parameter.

Anyone knows how to do this correctly?

Thank you!

Images: Player script:

public class Player : MonoBehaviour, IDamageable {

[SerializeField] Weapon weaponInuse;
[SerializeField] GameObject weaponSocket;

GameObject currentTarget;
CameraRaycaster cameraRaycaster;

// Use this for initialization
void start ()
{
   PutWeaponInHand();
}

private void PutWeaponInHand()
{
   var weaponPrefab = weaponInUse.GetWeaponPrefab();
   var weapon = Instantiate(weaponPrefab, weaponsocket. transform);
   weapon.transform.localPosition = weaponInUse.gripTransform.localPosition;
|  weapon.transform.localRotation = weaponInUse.gripTransform.localRotation;

enter image description here

Trying to drag the left hand to the parameter (indicated by red arrows):  enter image description here

Source Link
roni
  • 3
  • 1

Using Part of prefab as script parameter

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to Instantiate the weapon. I created a parameter in the script for the hand: [SerializeField] GameObject weaponSocket; and I tried to Instantiate the weapon like this like this: Instantiate(weaponPrefab, weaponSocket.Transform);, but I just cant drag the hand to the parameter.

Anyone knows how to do this correctly?

Thank you!

Images: Player script: https://i.sstatic.net/fIuaG.jpg Trying to drag the left hand to the parameter (indicated by red arrows): https://i.sstatic.net/0EwlW.jpg