YouGroove Posted February 19, 2014 Share Posted February 19, 2014 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 ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 19, 2014 Share Posted February 19, 2014 After you scale it, you could position the laser at your gun's barrel position (which will be the center point of your laser right?), and then Move() it forward (z value only in Move()) by 1/2 of it's z scale value. So scale it Position it Move it forward Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 19, 2014 Author Share Posted February 19, 2014 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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
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.