Jump to content

Laser length


YouGroove
 Share

Recommended Posts

Well i have a model laser of lenght = 1

But when scaling it it is scaled on the center , not from the gun, so it is scaled front and behind player.

Would it be some other way to create a variable laser length ?

 

(Create a cube or cylinder at runtime could create lag like i seen with debug spheres i created at runtime)

 

As it is a cone , some way to not change begin vertexes and just change vertex ending position ?

Perhaps with that ?

 

Surface::SetVertexPosition

 

This function sets a vertex position.

Syntax

  • void SetVertexPosition(int v, float x, float y, float z)
  • void SetVertexPosition(int v, const Vec3& position)

Parameters

  • index: the index of the vertex to set.
  • x: the X component of the position to set.
  • y: the Y component of the position to set.
  • z: the Z component of the position to set.
  • position: the position to set.

GetModel of entity, and get Surface, and try to find the good vertex number , and when found i will in code just set it's position so ?

It is fast method ? i mean not too slow to manipulate the vertex in real time by code ?

Stop toying and make games

Link to comment
Share on other sites

Yes, i guess i have to recenter my laser at 0,0,0 before export.

The move forward will be a proportionnal value , the problem is that laser scales on begin and end points.

 

I wanted to use the Vertex method, but well seems GetSurface not working ? I got nil value.

 

 laser = self.entity:FindChild("laser")
if laser ~= nil then
position = Vec3(10,10,10)
laser:GetSurface(1)
for v=0, surface:CountVertices()-1 do
local position = surface:GetVertexPosition(v)
if v==1 then
surface:SetVertexPosition(v,position)
end
end

end

 

So i think i will go with the scale method and move forward.

Stop toying and make games

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...