[SOLVED ]If i did a collision to pick up a weapon

a graph node? New parent to attach graph node too.

Good. Now consider how you are using the function:

Are you passing a pc.GraphNode to the function?

Wait so i did it backwards? or should it be more of missing something? from what i can see with the function i am using ¨Player¨ to reassign as a parent to the weapon or am i reasignning weapon as the parent or neither?
EDIT: ok well the error has gone away now but showing a new one error coding this:

      this.root.reparent("Player");

I tried this first but when i reparent i want to make the player the parent right?
So if i mixxed Player with weapon…

More pointed question: Why are you passing a string to a function that is expecting a pc.GraphNode?

Because i thought it would pull the entity instead of the node and it cant do that? what should i put there then? numbers?

OK @yaustar i think i have an idea i was looking at some unity tutorials on this (Yes i know unity is different from playcanvas but helped) This is the question i have now:
link to video
first off GameObject is its own call in CSHARP right?
07%20PM%20-%20Edited
So if i change this to fit playcanvas how would i fir this?
this.myWeapon;
or
this.weaponOnGround?
also is collide and _collide its own thing in playcanvas? even if its in its own terms?
Please let me know what you think i should/could do :slight_smile:

Just one thing, I’ve tried this, but Unity tutorials never work for PlayCanvas . Look at the documentation carefully. The function requires two arguments, the parent, and the index. You are not passing the index argument. Also, the parent argument cannot be a string, but a node.

this.Player.reparent(“AK47”);
Are you passing a pc.GraphNode to the function?
More pointed question: Why are you passing a string to a function that is expecting a pc.GraphNode?
Because i thought it would pull the entity instead of the node and it cant do that? what should i put there then? numbers?

@Nathan_Hawkins1, yaustar was getting you to look closer at what you’re doing.

Instead of passing a graph node, you’re passing a string to the function.

What you need to do is get the graph node, using the string.

Something like…

var node = this.app.root.findByName(“AK47”);
// Now you have something valid to pass to the reparent function, ie a graph node rather than a string
this.Player.reparent(node);

Oh ok i was so unfocused ya wow im stupid um thanks you guys for the help i will try this out asap thanks @yaustar & @Mal_Duffin & @DevilZ appreciate your patience and help. But i now have another problem @yaustar when i do the collision it does not continue with the player it just changes positions :slight_smile: let me know if im missing something
EDIT: calling error on if(result.other.getName() === "AK47" && this.weaponEntity.enabled !== true)
yet it isnt incorrect… (FIXED)
EDIT2: Ok Another Problem Now When It Collides the weapon just changes position instead of attaching to the player like it should be :slight_smile: this is where i will leave this post @yaustar if you have any suggetion please tell me ive looked all over for the problem but just cant find it

Try setting the coordinates and rotation of the entity

@DevilZ Im taking a break go ahead and take a look at it : https://playcanvas.com/editor/scene/732925