Jump to content

Haydenmango

Members
  • Posts

    434
  • Joined

  • Last visited

Posts posted by Haydenmango

  1. That sounds extremely convenient/useful Josh. I may wait for that before making a LoD system.

     

    For now what do you think would be the best way to do a more specific View Range system? By specific I mean I could set the view range for each object to a set number instead of Near,Medium,Far,Max, or Infinite.

  2. Sadly all of my entites view ranges are already set to near (in the editor). Does setting view range for entites in the editor also set it in game or would I have to use the function in a script?

     

    I can still see all of my entites with a near view range from 300 units away. My Cameras View Range is set to 300 (instead of 1000) and I can see my trees all the way up to where the camera range cuts off.

    I would probably like the range to be about 100-150 if I could figure it out.

  3. Thanks for your thoughts guys.

    @Charrua I hadn't thought of gathering my entities info at the inital map load I may give it a try although I am using Lua.

    @Rick I am trying to do a slightly different LoD system; it's actually more like a view range system. I don't have different LoD models for everything in my map (I may eventually) but for now I was just trying to make entities a certain distance from me Hidden and then the entities within the distance Shown.

    I guess I could give all my entites scripts but my worry is they all would be constantly calculating their distance from me instead of me just calculating my distance to them.

     

    Am I going about this in the wrong direction? Should I use a collision box or something similar for my "View Area" or would calculating distance to/from each entity better? I will give that thread another read through, there are some helpful tips in there.

  4. Hey everyone I have been trying to make a LoD (Level of Detail) system lately but I am running into one big issue.

    Using world:ForEachEntityInAABB() or world:ForEachVisibleEntityDo() works to hide the entity but then I run into my issue. These functions will not return a Hidden entity. So how would I go about 'finding' a Hidden entity?

     

    I know I could give each entity a script and make them check for my player when they are hidden but that doesn't seem like the best way to go about doing this.

     

    Any other ideas are welcome.

  5. Just started getting this error after closing and reopening my project I am working on. Now every time I open the editor this error shows up. Video--

     

    https://www.youtube.com/watch?v=7IPqD4OchVE&feature=youtu.be

     

    Microsoft Windows 7 Home Premium

    Intel® Core™ i5-3230M CPU @ 2.60GHz

    GeForce GT 630M

     

    --edit After deleting the mdl of the last object I was working with everything has gone back to normal and I no longer get this error. I think this is connected to changing an entites script parameters (like Script.MyEntity = nil --entity "MyEntity") because that was the last thing I was doing before this error occurred.

  6. My larger concern is if a dozen or more character controllers drastically slows down the game as that's what I'll be trying to implement soon.

    Hm well I am not completely sure if this is related but my game I'm working on using has like 20-30 character controllers that travel on terrain and it lags pretty hard. The only thing I have found that increases my fps is deleting/hiding some of my character controllers.

  7. Hi there.

    Recently I have been working a lot on one map and it hasn't come to my attention until now that I am unable to create or open another project. I have recently joined the workshop beta and I am running Steam Indie Edition. I attached a video that shows the behavior.

    I am not sure what to send to you as none of my projects except for one work but let me know if you need anything and I will send it your way.

     

    --video

     

    https://www.youtube.com/watch?v=iBw2hCEQ0iM

  8. Using Instance() I respawn my animals and weapons so far. It works great for my open world survival game!

    Simply hiding objects when they die and then switching their location and showing them when they respawn seems to work in most cases but I instance my animals because they go through a complex script that would be hard to reset by Hiding and repositioning them.

  9. I think it carries over the init variables at the top as well! Almost all of my entities load through Instance() after my game initially starts and I noticed that you do have to call spawn.script:Start() when the entity is instanced because that will not run otherwise but other than that everything (in the entities script) seems to carry over.

     

    A cool trick for respawn time is to Hide() the dieing entity and then wait a set amount of "respawntime" then call a custom Death() function that Instances your dieing entity, reset the script values(for the instanced entity), Show() the instanced entity, and release the dieing entity.

    • Upvote 1
  10. Yes it works as it should when instanced. I believe instance seems to copy the entites script as well as the changes made to it.

    If you have a script like-

    Script.health=80

    then your entity dies because its health reaches 0 and you want to respawn it-

    self.entity:Instance()

    self.entity:Release()

    this would create another dead entity because its Script.health is still equal to 0 which would then loop this death code and probably crash the game. you would need to do this-

    local spawn=self.entity:Instance()

    spawn.script.health=80

    self.entity:Release()

    now your instance will spawn with 80 health. You also need to set the instances position I believe.

    That is how I have been releasing and respawning entities so far.

  11. Well that ties into the actual issue I posted about. The code above was my workaround to get rid of the physics shape my "dropped weapon" inherited from its parent. Creating an Instance of the "dropped weapon" got rid of the unwanted physics shape. I then release the "dropped weapon" so that the instance of it I created pretty much replaces it.

     

    So in this case I do not want the entity back into the world because it has its parents physics shape which I do not want it to have. I had to create a instance of the entity (which magically gets rid of the unwanted physics shape) to fix my issue.

  12. Will do. Just making sure I wasn't missing anything obvious before I post a bug report.

     

    --edit for now I found a fix. still posting a bug report as it doesn't solve the actual issue.

    function Script:Drop()
    self.entity:SetParent(nil)
    self.entity:SetMass(self.mass)
    self.entity:SetCollisionType(Collision.Prop)
    self.entity:SetShadowMode(1)
    local spawn=self.entity:Instance()
    spawn:SetPosition(Transform:Point(0,0,1,self.entity,nil))
    self.entity:Release()
    end
    

  13. Very true. I just came to that solution a few minutes ago as well. I still don't like this though(moving my weapons manually doesn't work well with my animations and it looks really choppy). dry.png I wish someone could confirm whether this is just how the engine works or if I am missing a function to correct my mistakes.

    When you have a parented entity and set its parent to nil it shouldn't keep the characteristics of its previous parent.... or should it?

     

    edit- When I search around for more information about SetParent() it only says

    This function can be used to parent one entity to another. A child entity will maintain the same local orientation when its parent moves.
    so SetParent() should only change the orientation of the entity. It seems SetParent() isn't well documented or bugged because my child entity is also inheriting its parents Physics Shape.
  14. That would work but I have lots of weapons all over my map. If I don't use SetParent() then each one of those weapons is going to need an UpdateWorld() function which means all of those weapons will be constantly looping through that function to check if they are "active" rather than just being turned on and off when they are being used. I think that is where I will lose performance.

     

    Oh well though... for now I may have to do it manually instead of using SetParent(). It is just such a bummer because it seems like it wouldn't be impossible to set an objects shape back to normal after its parent is cleared. Thanks for the help/suggestions by the way Yougroove.

  15. I was really hoping I wouldn't have to do this--

    - Instead of suing SetParent, try each update frame to position and rotate thane stick by code to self.palm.

    but it is the only thing I have tried that fixes the problem.

     

    Is there really no way to get rid of the shape my weapon inherits from its parent?? Is this intended behaviour or am I missing something? Things would be much more simple if I could just use SetParent() instead of constantly checking if my weapon is being held then constantly moving it if it is.

  16. I don't think you understand. I just said it doesn't even work when I don't mess with my weapons shape.

    My issue still occurs whether I change my weapons shape or not.

     

    And in my video the problem occurs once the weapon is dropped. Once my weapon is dropped it has some sort of extended collision shape as you can see in the video. So no it did not work for the first stick in my video.

     

    In case you still don't get the shape part this is what my original code was(this was the code used in the video)--

    --pickup code

    if window:KeyHit(Key.G) then
    if (App.world:Pick(self.camera:GetPosition(),Transform:Point(0,0,self.useDistance,self.camera,nil),pickInfo,0,true)) then
    if pickInfo.entity.script then
    if pickInfo.entity.script.weapon then
    	 if self.carryingEntity==nil and self.weapon~="torch" then
    	 if self.weaponentity~=nil then
    	 self.weaponentity.script:Drop()
    	 end
    	 self.weaponentity=pickInfo.entity
    	 self.weapon=self.weaponentity.script.name
    	 self.weaponentity:SetMass(0)
    	 self.weaponentity:SetCollisionType(Collision.None)
    	 self.weaponentity:SetPosition(self.palm:GetPosition(true))
    	 self.weaponentity:SetRotation(self.palm:GetRotation(true)+self.weaponentity.script.rotation)
    	 self.weaponentity:SetParent(self.palm)
    	 self.weaponentity:SetShadowMode(0)
    	 end
    	 end
    end
    end
    end
    

    --drop code

    function Script:Drop()
    self.entity:SetParent(nil)
    self.entity:SetMass(self.mass)
    self.entity:SetCollisionType(Collision.Prop)
    self.entity:SetShadowMode(1)
    end
    

     

    This results in the same issue shown in my video.

  17. Changing my weapons shape was what I thought would fix this problem but it doesn't.

     

    My issue still occurs whether I change my weapons shape or not.

     

    Here is my code so you may understand what is happening--

    --pickup code

    if window:KeyHit(Key.G) then
    if (App.world:Pick(self.camera:GetPosition(),Transform:Point(0,0,self.useDistance,self.camera,nil),pickInfo,0,true)) then
    if pickInfo.entity.script then
    if pickInfo.entity.script.weapon then
     if self.carryingEntity==nil and self.weapon~="torch" then
     if self.weaponentity~=nil then
     self.weaponentity.script:Drop()
     end
     self.weaponentity=pickInfo.entity
     self.weapon=self.weaponentity.script.name
     self.weaponentity:SetShape(nil) --you can comment this out and the problem still occurs
     self.weaponentity:SetMass(0)
     self.weaponentity:SetCollisionType(Collision.None)
     self.weaponentity:SetPosition(self.palm:GetPosition(true))
     self.weaponentity:SetRotation(self.palm:GetRotation(true)+self.weaponentity.script.rotation)
     self.weaponentity:SetParent(self.palm)
     self.weaponentity:SetShadowMode(0)
     end
     end
    end
    end
    end
    

    --drop code

    function Script:Start()
    self.shape=self.entity:GetShape()
    self.shape:AddRef()
    end
    
    function Script:Drop()
    self.entity:SetParent(nil)
    self.entity:SetShape(self.shape) --you can comment this out and the problem still occurs
    self.entity:SetMass(self.mass)
    self.entity:SetCollisionType(Collision.Prop)
    self.entity:SetShadowMode(1)
    end
    

×
×
  • Create New...