I'm making a combine ball lua script, but I'm having trouble with making it bounce. Any Ideas?
Have a look at how Garry does it in the bouncy ball entity
[QUOTE=highvoltage;45119725]Have a look at how Garry does it in the bouncy ball entity[/QUOTE]
Valve*
[QUOTE=highvoltage;45119725]Have a look at how Garry does it in the bouncy ball entity[/QUOTE]
tried that already, and it failed.
Could you post your code please? So we can take a look at what's wrong.
[QUOTE=Jvs;45119831]Could you post your code please? So we can take a look at what's wrong.[/QUOTE]
Alright. It's a little messy, and might there be unnecessary lines in it.
[code]
AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
ENT.PrintName = "Combine Ball (Unfinished)"
ENT.Author = "Minigun2142"
ENT.Information = "Easy Way to spawn combine balls!"
ENT.Category = "Mini Entities"
ENT.Editable = false
ENT.Spawnable = true
ENT.AdminOnly = false
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
--
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local size = math.random( 12, 12 )
local SpawnPos = tr.HitPos + tr.HitNormal * size
local ent = ents.Create( "prop_combine_ball" )
if (ent:IsValid()) then
ent:SetPos( SpawnPos )
ent:Spawn()
ent:SetModel( "models/Effects/combineball.mdl" )
ent:GetPhysicsObject():AddGameFlag( FVPHYSICS_WAS_THROWN )
ent:GetPhysicsObject():AddGameFlag( FVPHYSICS_DMG_DISSOLVE )
ent:SetOwner( self.owner )
ent:Activate()
ent:SetSaveValue('m_flRadius',12)
ent:SetSaveValue('m_nMaxBounces',10)
end
return ent
end
function ENT:Initialize()
if ( SERVER ) then
local size = 12
-- Wake the physics object up. It's time to have fun!
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
-- Set collision bounds exactly
self:PhysicsInitSphere( size, "metal_bouncy" )
self:SetCollisionBounds( -self:GetSize(), self:GetSize() )
end
end
function ENT:Draw()
self:DrawModel()
end
[/code]
bits of it was from sent_ball.lua
Unless your entity classname is actually prop_combine_ball that code only spawns the hardcoded Combine Ball, and not your custom entity, but since I see you haven't said anything about it erroring from the method self:GetSize() not existing, it's spawning the hardcoded one.
In which case the question is, are you trying to use the actual combine ball or remaking your own? Because that code is a bit confusing and I can see you just started learning GLua.
-snip-
Haven't read that you already did that
Yeah I'm trying to use Prop_combine_ball, and Yes I just started GLua a few days back.
[url]http://pastebin.com/fxUHHUSW[/url]
Here's is the prop_combine_ball.cpp
Take a look on the line 2075 and 884, i hope that you can understand it
Try replacing your ENT:SpawnFunction with this.
[code]
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local size = 12
local SpawnPos = tr.HitPos + tr.HitNormal * size
local ent = ents.Create( "prop_combine_ball" )
if (IsValid( ent ) ) then
ent:SetPos( SpawnPos )
ent:SetSaveValue("m_flRadius", size )
ent:SetSaveValue("m_nMaxBounces", 10 )
ent:Spawn()
ent:SetOwner( ply )
ent:Activate()
end
return ent
end
[/code]
I can't test it right now but it should work.
[editline]16th June 2014[/editline]
You can also remove ent:SetOwner( ply ) if you want the ball to collide with the player that spawned it.
[QUOTE=Jvs;45120103]Try replacing your ENT:SpawnFunction with this.
[code]
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local size = 12
local SpawnPos = tr.HitPos + tr.HitNormal * size
local ent = ents.Create( "prop_combine_ball" )
if (IsValid( ent ) ) then
ent:SetPos( SpawnPos )
ent:SetSaveValue("m_flRadius", size )
ent:SetSaveValue("m_nMaxBounces", 10 )
ent:Spawn()
ent:SetOwner( ply )
ent:Activate()
end
return ent
end
[/code]
I can't test it right now but it should work.
[editline]16th June 2014[/editline]
You can also remove ent:SetOwner( ply ) if you want the ball to collide with the player that spawned it.[/QUOTE]
That's what I started with.
[editline]16th June 2014[/editline]
[QUOTE=gonzalolog;45120065][url]http://pastebin.com/fxUHHUSW[/url]
Here's is the prop_combine_ball.cpp
Take a look on the line 2075 and 884, i hope that you can understand it[/QUOTE]
yeah, not helping XD
still nothing.
When I was trying to spawn combine balls that bounce and did damage I ended up using [URL="https://developer.valvesoftware.com/wiki/Point_combine_ball_launcher"]point_combine_ball_launcher[/URL], I hope that's of some help
Sorry, you need to Log In to post a reply to this thread.