Spawn entity and attach to player?

Please post any questions about developing your plugin here. Please use the search function before posting!
you171717
Junior Member
Posts: 2
Joined: Fri Jan 20, 2017 6:49 am

Spawn entity and attach to player?

Postby you171717 » Fri Jan 20, 2017 6:54 am

Hello,

I want attach prop(hat) to player in tf2.

But code doesn't work properly (even spawning prop).

Syntax: Select all

target = Player(1)
entity = Entity.create('prop_physics')
entity.model = Model('props_junk/wood_crate001a.mdl')
entity.spawn()
entity.teleport(target.origin)
Last edited by L'In20Cible on Fri Jan 20, 2017 7:42 am, edited 1 time in total.
Reason: [code] → [python]
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Spawn entity and attach to player?

Postby L'In20Cible » Fri Jan 20, 2017 7:18 am

The function you are looking for is Entity.set_parent.
you171717
Junior Member
Posts: 2
Joined: Fri Jan 20, 2017 6:49 am

Re: Spawn entity and attach to player?

Postby you171717 » Fri Jan 20, 2017 7:41 am

L'In20Cible wrote:The function you are looking for is Entity.set_parent.


'set_parent' function make prop invisible

is this trick of tf2? :p
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Spawn entity and attach to player?

Postby L'In20Cible » Fri Jan 20, 2017 7:43 am

What is your complete code?

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 21 guests