Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Everything posted by havenphillip

  1. Something that might be cool is a button somewhere that allows me to toggle the navmesh on and off.
  2. Include a crawler.pfb in your game? Can't you just drag and drop the prefab into the screen? Not sure what you mean. But here's a basic ammo pickup script. Just add one of your ammo models to your scene and attach this script to it. Also you might need to add a collision shape to your ammo model. ammo_pickup.lua
  3. I don't know, man. I added very little to the crawler.
  4. Thanks. What is it missing, in your opinion? Seems like there should be more to it.
  5. It's great, man. It works. The rules are correct for the quadrants. The rotation sets the correct directions when walking towards or away, etc. But the dot is a bit jumpy. I have four equal quadrants and when I stand on or near the Z line (for instance) relative to the crawler and spin in a circle, the dot doesn't rotate. It just goes up and down. Same when I stand on or near the X line. I think it's because the number for the X coordinate is basically zero when I'm on the Z line so it's completely flattened. And if I walk to one of the four corners of my map I get a nice circle on rotation because the X and Z are equidistant. So as I'm walking around and rotating and stuff the dot kind of jumps around. So what I need to figure out is how to keep that circular shape from collapsing into a line when I cross between quadrants. No video. Sorry. I don't know how to do that. I don't really have a game or anything. Just a crawler standing in the middle of a big square lol. By all means copy/paste the code if you want. You can see for yourself.
  6. Ok. I think I see that. You created the Vec2 drawCoords variable but left it empty, basically. That allowed you to make x and y flexible depending on whatever you might want to do. And then with the "or" statements (which I was unaware of) you can reduce it down to this since some of the lines are similar: Script.target = nil -- entity "Target" Script.dotSize = 5 -- int "Dot Size" function Script:Start() self.player = self.entity:GetParent() self.mapPos = Vec2(200, 200) end function Script:PostRender(context) local x = self.mapPos.x / 2 local y = self.mapPos.y / 2 local playerPos = self.player:GetPosition(true) local enemyPos = self.target:GetPosition(true) local playerYRotation = self.player:GetRotation(true).y local drawCoords = Vec2(0,0) --We will use this variable to store the calculated draw position context:SetBlendMode(1) context:SetColor(1, 1, 1, 1) context:DrawRect(x, y, self.dotSize, self.dotSize) context:SetColor(1, 0, 0, 1) if (playerYRotation <= 30 and playerYRotation >= -30) or (playerYRotation >= 150 and playerYRotation <= 180) or (playerYRotation <= -150 and playerYRotation >= -180 ) then -- facing forward or backward if (playerPos.x < enemyPos.x and playerPos.z < enemyPos.z) or (playerPos.x > enemyPos.x and playerPos.z > enemyPos.z) then drawCoords.x = x + (-Math:Cos(playerYRotation) * (playerPos.x - enemyPos.x) - Math:Sin(playerYRotation) * (enemyPos.x - playerPos.x)) drawCoords.y = y + (-Math:Sin(playerYRotation) * (enemyPos.z - playerPos.z) + Math:Cos(playerYRotation) * (playerPos.z - enemyPos.z)) elseif (playerPos.x > enemyPos.x and playerPos.z < enemyPos.z) or (playerPos.x < enemyPos.x and playerPos.z > enemyPos.z) then drawCoords.x = x + (-Math:Cos(-playerYRotation) * (playerPos.x - enemyPos.x) - Math:Sin(-playerYRotation) * (enemyPos.x - playerPos.x)) drawCoords.y = y + (Math:Sin(playerYRotation) * (enemyPos.z - playerPos.z) + Math:Cos(playerYRotation) * (playerPos.z - enemyPos.z)) end elseif (playerYRotation >= 30 and playerYRotation <= 149) or (playerYRotation <= -30 and playerYRotation >= -149) then -- facing right/left if (playerPos.x < enemyPos.x and playerPos.z < enemyPos.z) or (playerPos.x > enemyPos.x and playerPos.z > enemyPos.z) then drawCoords.y = x + (Math:Cos(playerYRotation) * (playerPos.x - enemyPos.x) - Math:Sin(playerYRotation) * (enemyPos.x - playerPos.x)) drawCoords.x = y + (-Math:Sin(playerYRotation) * (enemyPos.z - playerPos.z) - Math:Cos(playerYRotation) * (playerPos.z - enemyPos.z)) elseif (playerPos.x > enemyPos.x and playerPos.z < enemyPos.z) or (playerPos.x < enemyPos.x and playerPos.z > enemyPos.z) then drawCoords.y = x + (-Math:Cos(playerYRotation) * (playerPos.x - enemyPos.x) - Math:Sin(playerYRotation) * (enemyPos.x - playerPos.x)) drawCoords.x = y + (-Math:Sin(playerYRotation) * (enemyPos.z - playerPos.z) - Math:Cos(playerYRotation) * (enemyPos.z - playerPos.z)) end end context:DrawRect(drawCoords.x, drawCoords.y, self.dotSize, self.dotSize) context:SetBlendMode(0) context:SetColor(1, 1, 1, 1) context:DrawText( Math:Round(playerPos.x) .. "," .. Math:Round(playerPos.z) .. "/" .. Math:Round(enemyPos.x) .. "," .. Math:Round(enemyPos.z), 20, 20 ) context:DrawText(playerYRotation, 20, 50) context:SetBlendMode(1) end
  7. Cool. Thanks. I kind of get it. It boggles my mind a bit how you can just say something like "isNegative" and go about using it without defining it anywhere. My brain will slowly absorb this. This code works so far. I'm getting a slope on rotation rather than a circular motion, and for some reason if I add an "if" statement I get that error again. It's a lua error or something so it doesn't highlight a line or anything. I'm totally in the dark about it. What I think I need is to adjust these for right 90 and left -90 degree turns, which requires an "if." Not sure if I should try to get the rotation working or fiddle with the turn problem first, or if solving one of those will also solve the other. Ideally, without having to add a ton of coordinate statements the enemy dot would move down from top to center as I walk facing towards it and continue down as I walk away from it, regardless of my player position and rotation relative to the enemy position. As it is, when I turn right and walk away from the target, the dot moves left, rather than down. Where should I focus my efforts from here? Script.target = nil -- entity "Target" Script.dotSize = 5 -- int "Dot Size" function Script:Start() self.player = self.entity:GetParent() self.mapPos = Vec2(300,300) end function GetDrawCoordinate(mapPos, playerpos, enemypos, isNegative, yRotation) local dir = 1; if isNegative then dir = -1 end local X = mapx+(dir * Math:Cos(dir * rot)*(player.x-enemy.x) - Math:Sin(dir * rot)*(enemy.x-player.x)) local Y = mapy+(-Math:Sin(rot)*(enemy.z-player.z) + Math:Cos(rot)*(player.z-enemy.z)) return Vec2(X,Y) end function Script:PostRender(context) mapx = self.mapPos.x/2 mapy = self.mapPos.y/2 player = self.player:GetPosition(true) enemy = self.target:GetPosition(true) rot = self.player:GetRotation(true).y s = self.dotSize context:SetBlendMode(1) context:SetColor(1,1,1,1) context:DrawRect(mapx,mapy,s,s) context:SetColor(1,0,0,1) local drawCoord = GetDrawCoordinate(Vec2(mapx,mapy), player, enemy, true, rot) context:DrawRect(drawCoord.x, drawCoord.y, s, s) context:SetColor(1,1,1,1) context:DrawText(Math:Round(rot),20,50) end
  8. Ok I'm getting an error "...error in function 'new' [argument #2 is nil...no object expected" adding variables inside a created function is still kind of a new concept to me. You don't have a video on specifically this, do you? Here's how I have it set up. Where is 'new' argument 2? --Helper function that retrieves the right DrawCoords function GetDrawCoordinate(mapPos, playerPos, enemyPos, isNegative, yRotation) local dir = 1; if isNegative then dir = -1 end local x = mapPos.x+(dir * Math:Cos(dir * yRotation)*(playerPos.x-enemyPos.x) - Math:Sin(dir * yRotation)*(enemyPos.x-playerPos.x)) local y = mapPos.y+(-Math:Sin(yRotation)*(enemyPos.z-playerPos.z) + Math:Cos(yRotation)*(playerPos.z-enemyPos.z)) return Vec2(x,y) end function Script:PostRender(context) x = self.mapPos.x/2 y = self.mapPos.y/2 playerPos = self.player:GetPosition(true) enemyPos = self.target:GetPosition(true) a = self.player:GetRotation(false).y s = self.dotSize context:SetBlendMode(1) context:SetColor(1,1,1,1) context:DrawRect(x,y,s,s) context:SetColor(1,0,0,1) --Format to: if a <= 30 and a >= - 30 then -- facing forward local drawCoord = GetDrawCoordinate(Vec2(X, Y), playerPos, enemyPos, true, yRotation) context:DrawRect(drawCoord.x, drawCoord.y, s, s) end
  9. I'm trying to make this rotating radar thing. I have this script but I get the feeling I'm doing way more than necessary and it's really jumpy. I'm not that good with shaders and still pretty limited in my understanding of coding in general. You can kind of see what I'm trying to do but what's the best way to go about this? Current script: Script.target = nil -- entity "Target" Script.dotSize = 5 -- int "Dot Size" function Script:Start() self.player = self.entity:GetParent() self.mapPos = Vec2(200,200) end function Script:PostRender(context) x = self.mapPos.x/2 y = self.mapPos.y/2 pos = self.player:GetPosition(true) enemy = self.target:GetPosition(true) a = self.player:GetRotation(true).y s = self.dotSize context:SetBlendMode(1) context:SetColor(1,1,1,1) context:DrawRect(x,y,s,s) context:SetColor(1,0,0,1) if a <= 30 and a >= - 30 then -- facing forward if pos.x < enemy.x and pos.z < enemy.z then -- lower left local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z < enemy.z then -- lower right local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x < enemy.x and pos.z > enemy.z then -- upper left local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z > enemy.z then -- upper right local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) end elseif a >= 150 and a <= 180 then -- facing backward if pos.x < enemy.x and pos.z < enemy.z then -- lower left local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z < enemy.z then -- lower right local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x < enemy.x and pos.z > enemy.z then -- upper left local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z > enemy.z then -- upper right local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) end elseif a >= -180 and a <= -150 then -- facing backward if pos.x < enemy.x and pos.z < enemy.z then -- lower left local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z < enemy.z then -- lower right local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x < enemy.x and pos.z > enemy.z then -- upper left local X = x+(-Math:Cos(-a)*(pos.x-enemy.x) - Math:Sin(-a)*(enemy.x-pos.x)) local Y = y+(Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z > enemy.z then -- upper right local X = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local Y = y+(-Math:Sin(a)*(enemy.z-pos.z) + Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) end elseif a >= 30 and a <= 149 then -- facing right if pos.x < enemy.x and pos.z < enemy.z then -- lower left local Y = x+(Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z < enemy.z then -- lower right local Y = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(enemy.z-pos.z)) context:DrawRect(X,Y,s,s) elseif pos.x < enemy.x and pos.z > enemy.z then -- upper left local Y = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(enemy.z-pos.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z > enemy.z then -- upper right local Y = x+(Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) end elseif a <= -30 and a >= -149 then -- facing left if pos.x < enemy.x and pos.z < enemy.z then -- lower left local Y = x+(Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z < enemy.z then -- lower right local Y = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(enemy.z-pos.z)) context:DrawRect(X,Y,s,s) elseif pos.x < enemy.x and pos.z > enemy.z then -- upper left local Y = x+(-Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(enemy.z-pos.z)) context:DrawRect(X,Y,s,s) elseif pos.x > enemy.x and pos.z > enemy.z then -- upper right local Y = x+(Math:Cos(a)*(pos.x-enemy.x) - Math:Sin(a)*(enemy.x-pos.x)) local X = y+(-Math:Sin(a)*(enemy.z-pos.z) - Math:Cos(a)*(pos.z-enemy.z)) context:DrawRect(X,Y,s,s) end end context:SetBlendMode(0) context:SetBlendMode(1) context:SetColor(1,1,1,1) context:DrawText(Math:Round(pos.x)..","..Math:Round(pos.z).."/"..Math:Round(enemy.x)..","..Math:Round(enemy.z), 20, 20) context:DrawText(a,20,50) end
  10. You just have to put this under the UpdateWorld() function: if window:KeyHit(Key.U) then self:Hurt(100) end
  11. Maybe the lowercase "h" to a capital? if window:KeyHit(Key.U) then self:Hurt(100) <----- end
  12. Ok. It's confusing. I have this at the bottom of my AI script. Do I need/can I make use of any returns anywhere? function Script:UpdateWorld() if self.enabled == true then self.despawnTimer = self.despawnTimer + Time:GetSpeed()/100 if self.despawnTimer > self.despawnTime then self.mode = "dead" self:DespawnItem() end end if self.mode == "dead" then self.removeBodyTimer = self.removeBodyTimer + (Time:GetSpeed()/100) if (self.removeBodyTimer > self.removeBodyTime) then self:DespawnItem() end end end function Script:DespawnItem() self.entity:Hide() self.entity:Release() end
  13. What are the appropriate uses of it? I've never fully understood when and where it should be used.
  14. Appears to have resolved itself so I don't know.
  15. Even while standing still my bullets are causing me damage for some reason. Everything was fine yesterday. Anyone else experiencing this?
  16. Some hud elements I was able to make with help around the community. HUD Elements.zip
  17. I have this enter/exit trigger from Aggror set up to hide my weapons when I walk on the trigger and show weapons when I walk off the trigger. My problem is when I stand perfectly still on the trigger the weapons show. I don't want that so how do I stop that from happening? I tried the player script's speed, moveSpeed, and playerMovement. You can see what I'm trying to do here: Script.enabled = true Script.entered = false Script.exited = false Script.collided = false function Script:Collision(entity, position, normal, speed) self.player = entity if self.enabled then self.collided = true if self.entered == false then self.entered = true self.exited = false entity.script.weapons[entity.script.currentweaponindex].entity:Hide() if entity:Stop() then -- right here what? entity.script.weapons[entity.script.currentweaponindex].entity:Hide() end end end end function Script:UpdatePhysics() if self.enabled then if self.entered then if self.collided == false then self.exited = true self.entered = false self.player.script.weapons[self.player.script.currentweaponindex].entity:Show() end end self.collided = false end end
  18. I think the line self.entity:SetMass(0) was causing crash problems. Maybe uncomment that.
  19. Ah yes that worked perfectly, Ma-Shell. Thank you so much! GorzenDev that's the post I started from. The only thing was I needed to rotate the texture without rotating the quad/mask texture itself. Here's the script I'm using with the vertex and fragment of the shader for those wandering by: Script: Script.pos = Vec2(49,60) -- Vec2 "Position" Script.size = Vec2(210,215) -- Vec2 "Size" function Script:Start() self.shader = Shader:Load("HUD Elements/rotate attempt/weird.shader") self.intex = Texture:Load("Materials/Developer/bluegrid.tex") self.mask= Texture:Load("Materials/Developer/Flat Black.tex") self.angle=0 end function Script:UpdateWorld() self.angle = Time:GetCurrent()/1000 end function Script:PostRender(context) local a = self.a local x = self.pos.x local y = self.pos.y local w = self.size.x local h = self.size.y shd = context:GetShader() self.intex:Bind(1) self.shader:SetFloat("t", -1.0) self.shader:SetFloat("angle", self.angle) context:SetBlendMode(1) context:SetColor(1,1,1,1) context:SetShader(self.shader) context:DrawImage(self.mask, x, y , w, h) context:SetShader(shd) end ------------------------------------------------------------------------------ Fragment of shader: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; in vec2 vTexCoords0; in vec2 vTexCoords1; out vec4 fragData0; void main(void) { vec4 mask=texture(texture0,vTexCoords0); if (mask.r < 0.1 && mask.a > 0.0) { vec4 t0 = texture(texture0, vTexCoords0); vec4 t1 = texture(texture1, vTexCoords1); mask = mix(t0, t1, vec4(vTexCoords1.x >= t)); } else { discard; } fragData0 = mask; } ------------------------------------------------------------------------------ Vertex of shader: #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 position[5]; uniform vec2 texcoords[4]; uniform float angle = 0.0; out vec2 vTexCoords0; out vec2 vTexCoords1; void main(void) { float s = sin(angle); float c = cos(angle); mat2 RotationMatrix = mat2(c,-s,s,c); vec2 pos = position[gl_VertexID]; gl_Position = projectionmatrix * (drawmatrix * vec4(pos, 0.0, 1.0)); vTexCoords0 = texcoords[gl_VertexID]; vTexCoords1 = (texcoords[gl_VertexID] - vec2(0.5, 0.5)) * RotationMatrix + vec2(0.5, 0.5);; }
  20. Since the time I asked this question I made a little progress. I have it rotating now using the vertex, but I can't get it to rotate from the center. It centers at the top-left. Here it is: Fragment: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; // e.g. 0.4 in vec2 vTexCoords0; in vec2 vTexCoords1; out vec4 fragData0; void main(void) { vec4 mask=texture(texture0,vTexCoords1); if (mask.r < 0.1 && mask.a > 0.0) { vec4 t0 = texture(texture0, vTexCoords1); vec4 t1 = texture(texture1, vTexCoords0); mask = mix(t0, t1, vec4(vTexCoords1.x >= t)); } else { discard; } fragData0 = mask; } Vertex: #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 position[4]; uniform vec2 texcoords[4]; uniform float turn = 0.0; in vec3 vertex_position; in vec2 vertex_texcoords0; out vec2 vTexCoords0; out vec2 vTexCoords1; void main(void) { vec2 pos = position[gl_VertexID]; mat2 rot = mat2( cos( radians(turn)), -sin( radians(turn)), sin( radians(turn)), cos(radians(turn))); gl_Position = projectionmatrix * (drawmatrix * vec4(pos, 0.0, 1.0)); vTexCoords1 = texcoords[gl_VertexID]; vTexCoords0 = texcoords[gl_VertexID] * rot; }
  21. I have a shader that allows me to move a texture1 within the masked space of a texture0 but I'm only able to move it in a line. I need it to rotate. How can I do that? Here's the fragment shader: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; // e.g. 0.4 uniform vec2 bar = vec2(1.0,1.0); uniform bool isbackbuffer; in vec2 vTexCoords0; out vec4 fragData0; void main(void) { vec2 UV = (bar); if (isbackbuffer) UV.xy = 1.0 - UV.xy; vec4 mask=texture(texture0,vTexCoords0); if (mask.r < 0.1 && mask.a >0) { vec4 t0 = texture(texture0, vTexCoords0); vec4 t1 = texture(texture1, vTexCoords0+UV); mask = mix(t0, t1, vec4(vTexCoords0.x >= t)); } else { discard; } fragData0 = mask; } //vec2 turn = vec2(-(cos(2)*(UV.x/2) - sin(2)*(UV.y/2)),(-sin(2)*(UV.x/2) - cos(2)*(UV.y/2)));
  22. I have this rotating thing I want to make a health half-circle but I need to mask half of it. How can I do it? Anyone come across a shader for that? Or can it be done in lua? I looked around but I haven't been able to find one that works for this. Here's my code, if that's useful: Script.player = nil -- entity "Player" Script.pos = Vec2(242,234) -- Vec2 "Position" Script.offset = Vec2(4,3) -- Vec2 "Offset" Script.csize = Vec2(200,200) -- Vec2 "Size" function Script:Start() self.player = self.entity:GetParent() self.tex = Texture:Load("Materials/Developer/bluegrid.tex") end function Script:PostRender(context) local a = Time:GetCurrent() /10 local w = self.csize.x local h = self.csize.y local x = self.pos.x-(Math:Cos(a)*(w/2) - Math:Sin(a)*(h/2)) local y = self.pos.y+(-Math:Sin(a)*(w/2) - Math:Cos(a)*(h/2)) local scale = 1 context:SetRotation(a) context:SetScale(1,1) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawImage(self.tex, x, y, self.csize.x, self.csize.y) context:SetRotation(0) end
  23. I see. You have to reset context:SetRotation(0) at the bottom.
×
×
  • Create New...