Welcome, Guest. Please login or register.
Did you miss your activation email?
September 19, 2024, 11:57:34 PM
Home Help Login Register
News: Zombie Master 2 discussion

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Entity Use
Pages: [1]
Author Topic: Entity Use  (Read 3276 times)
Manmax75
Poster

Posts: 254


Programming Guy


« on: December 11, 2010, 02:00:56 AM »

Hey I am making an ent and I am wondering how can I make it so it doesn't collide with players but players can still trigger the ENT:Use() function.

This code spawns the ent:

local secretent = ents.Create("ttt_secretent")
if ValidEntity(secretent) then

secretent:SetPos(ply:GetPos())
secretent:SetOwner(ply)
secretent:Spawn()

local phys = secretent:GetPhysicsObject()
if ValidEntity(phys) then
phys:EnableMotion(false)
end



And this is my ENT:Initialize function:

self.Entity:SetModel(self.Model)


if SERVER then
self.Entity:PhysicsInit(SOLID_VPHYSICS)
end
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_NONE)

if SERVER then
self.Entity:SetUseType(SIMPLE_USE)
end


So how can I make it non-collideable to players yet still useable?

Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #1 on: December 11, 2010, 09:07:22 AM »

Use COLLISION_GROUP_WEAPON, then it won't collide with players, while still colliding with other things.

Then to make +use work, do the following. This is TTT specific stuff, for the record, won't work in sandbox.
-- In the SENT script, server or shared
ENT.CanUseKey = true

function ENT:UseOverride(ply)
  ply:ChatPrint("You used me!")
end


Of course everything related to Source's standard use stuff, like SetUseType, will not affect this. You should run whatever you want to happen when a player +uses the entity in the UseOverride function.
Manmax75
Poster

Posts: 254


Programming Guy


« Reply #2 on: December 11, 2010, 09:20:20 AM »

Thanks
« Last Edit: December 11, 2010, 09:23:36 AM by Manmax75 »

Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Entity Use « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.009 seconds with 18 queries.