Jump to content

AggrorJorn

Members
  • Posts

    4,816
  • Joined

  • Last visited

Everything posted by AggrorJorn

  1. Don't worry, that is all part of becoming a developer. But you can't give up. Slowly you will get better and better. Ans asking questions is no problem as long as you try things out yourself as well. As for your error: I made a mistake with cleaning the table. This line is incorrect: self.enemyEntities = nil After its first update the table is currently set to nil. And the loop no longer functions because the table is nil. That is also what the error is saying So instead of setting it to nil we have to empty every enemy reference that is in there. Try something like this: for k,v in pairs (self.enemyEntities) do self.enemyEntities[k] = nil end
  2. Had a look at your script. It looks like you want to fill in the enemy characters by hand? Script.enemyEntities ={} Script.enemyEntities[0] = "Prefabs/Characters/German Zombie 1.pfb" --path Script.enemyEntities[1] = "Prefabs/Characters/Gasmask Zombie.pfb" --path Script.enemyEntities[2] = "Prefabs/Characters/Helmet Zombie.pfb" --path Script.enemyEntities[3] = "Prefabs/Characters/Officer Zombie.pfb" --path Script.enemyEntities[4] = "Prefabs/Characters/Drag Zombie.pfb" --path Script.enemyEntities[5] = "Prefabs/Characters/German Zombie 10.pfb" --path Script.enemyEntities[6] = "Prefabs/Characters/Officer Zombie 9.pfb" --path Script.enemyEntities[7] = "Prefabs/Characters/Pilot Zombie.pfb" --path There is no need to do that since the callback function will fill up the table. Every seconds or so, it will refresh this table with the enemies that are in vicinity. The enemies tables is part of the script and can be accesses using 'self.enemyEntities' when in the PostRender function At the bottom of your post render you can start drawing a rectangle per enemy entity. Give it a shot. If you are really stuck I can help out. for key, value in pairs(self.enemyEntities) do --calculate the position to drawcolor context:DrawRect() end
  3. Go to the physics tab of your object in the scene and adjust the character angle.
  4. In the mean time I would recommend reading up on lua basics or watch this tutorial seres on Leadwerks Lua basics. It teaches all the Lua you need for your scenario. Or at least watch the tutorial about tables. The 'GetAABB' parameter is described in the documentation. You might need to switch 1 with 2. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_GetAABB
  5. Well done, you are making progress. Some feedback on your code and a few suggestions: Have an array which holds enemy positions. You are currently creating a new AABB from scratch, which is fine. The sphere however already has an AABB and you can simply retrieve it by using GetAABB(). Saves you from making an AABB from scratch. But that is up to you. A Callback function no longer has acces to the 'self' variable. That is why you can simply provide an extra variable which either holds the script's entity. You can try it out. When that works, we have a look at the drawing part. **EDIT: added a simple timer in the update, so that you can control how often the enemy table is updated. --An array which holds the enemies. This array is empties every update before being filled again. Script.enemyEntities = {} Script.timer = 0 Script.timeUntilMinimapUpdates = 0.2 function Script:Start() self.miniMapSphere = Model:Sphere(8,self.player) self.miniMapSphere:SetScale(50,50,50) self.miniMapSphere:SetPosition(self.player:GetPosition(true)) --Parenting the sphere to the player, means we don't have to update the position ourselves again. self.miniMapSphere:SetParent(self.player) self.miniMapSphere:Hide() end function Script:UpdateWorld() self.timer = self.timer + Time:GetSpeed() if self.timer > self.timeUntilMinimapUpdates then self.timer = 0 self.enemyEntities = nil local AABB = self.miniMapSphere:GetAABB(1) --We pass along the entity that our current script is attached to world:ForEachEntityInAABBDo(AABB, "Callback", self.entity) end end --A callback function has lost the reference to 'self', that is why pass in the 'self.entity' at ForEachEntityInAABBDo function Callback(entity, extra) if entity:GetKeyValue("type") == "enemy" then table.insert(extra.script.enemyEntities, entity) end end
  6. Try something like this. You are currently using a certain area around you to show as a map. Place a sphere as a child of your player and make it invisible (or partially transparent for debugging) The sphere needs to be roughly the size of the minimap you want to display. For example 4 meters wide. In your minimap script, reference the sphere and perform ForEachEntityInAABBDo every second (or as often you would like to update the minimap). The entities returned by the above function can now be looped over Check if it is an enemy (GetKeyValue could be used) Since AABB is a box and not a sphere, do a distance check to the enemy. If it is within the radius of the sphere, it should be shown on the minimap. The method above is just a way to get a list of entities that are near you. The distance check is to further finetune the result. See if you can get this working first before worrying about drawing the positions of the enemies.
  7. You want your character controller to collide with the door in order to open it? Your code suggest that you use a pick function to interact with objects. Can you clarify what is working and what is not working. Do see anything that shouldn't happen. Error log? Perhaps a video recording?
  8. How about window key + up arrow key?
  9. The first thing you need to is gather information about which enemies are near you and should be projected on the minimap. one way is to gather enemies is using https://www.leadwerks.com/learn?page=API-Reference_Object_World_ForEachEntityInAABBDo Or you can loop over all enemies in an array, and check the distance to the player. second step is adding this information to the shader. I have never added an array of positions to a shader (I recon something like this should be possible: uniform vec2 enemyPositions[2];) but as an alternative you can add several enemy positions.
  10. Control enter to switch between fullscreen and minimizes Control + Enter and then control + enter to reset size.
  11. I mean even before that. Is the 3dsxmax scene referencing the renamed textures?
  12. So you are exporting the model and than rename the textures? If so, how would the model know that you renamed your textures. The texture need to have that name before you export the model.
  13. I am not entirely understanding this question. Your diffuse texture is visible in the screenshot your provided but you are sayin it is not using it? As for the bump and specular not automatically added to the material. I think Leadwerks uses a postfix to map bump and specular textures in a material. Try giving your textures the following names with a postfix: myTexture_diff myTexture_dot3 myTexture_spec
  14. In that case, I would file a bug report because that should be happening automatically. Are you using Linux btw? Because the automatic mapping only works in windows. As for not seeing any shadows. Open the material for your model. Is the Cast shadow option enabled? Open the properties tab for your entity, under the appearance tab set cast shadows to Dynamic.
  15. According to the documentation it should do this automatically, but there are some conditions: https://www.leadwerks.com/learn?page=Tutorials_Editor_Models-and-Animation Can you check if you have the following: The fbx model references your texture. That texture is in the same folder as you model.
  16. There is a materials folder by default. What you describe already happens. However you need to make a material first. If you import a model with textures, material files are even created automatically.
  17. Are you using Git in combination with LFS to store larger assets?
  18. You are correct. The sample lacks the actual demonstration of the function. Something like this would be needed. (haven't tested it) --Create a window window = Window:Create() context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:Move(0,0,-3) local light = DirectionalLight:Create() light:SetRotation(35,35,0) model = Model:Box() model:SetColor(0.0,0.0,1.0) while true do if window:Closed() or window:KeyHit(Key.Escape) then return false end if model ~= nil then model:Turn(0,Time:GetSpeed(),0) end --Clears the current world if window:KeyHit(Key.Space) then world:Clear() end Time:Update() world:Update() world:Render() context:Sync(false) end
  19. We need more information to help you What is your exact error? Lua or C++ Screenshots? Log file (in /Documents/leadwerks) What is disabled?
  20. I would still go for the Vive because of room tracking. Even with little space, I can see far more potential in simulations.
  21. You need to clear the current world first. https://www.leadwerks.com/learn?page=API-Reference_Object_World_Clear
  22. Wouldn't this be useful for the documentation somewhere here: https://www.leadwerks.com/learn?page=API-Reference_Object_VR
  23. As I said, Leadwerks rewrote all documentation for the new system. It is perfectly possible small details are forgotten. In the old documentation you see how the Entities member is listed: http://web.archive.org/web/20150502074238/http://www.leadwerks.com:80/werkspace/page/documentation/_/command-reference/world
  24. No. All the documentation found here: https://www.leadwerks.com/learn?page= is part of Leadwerks 4.x . It is just a new documentation system which was filled from scratch. So some information in the old documentation website might not be written in the new documentation system. Adding comments to pages would be nice, but for now we would have to file a bug report. Things get fixed very quickly if described properly. Example.
×
×
  • Create New...