Jump to content

Genebris

Members
  • Posts

    517
  • Joined

  • Last visited

Posts posted by Genebris

  1. But hidden entities won't cast shadows, will they?

     

    Why don't you just render the first-person model with a material that has shadows but discards the fragments of the model in the normal shader? Then, you get the best of both worlds.

     

    Personally, I would do what Josh suggested though. If you decide to use environmental probes, you're going to be in trouble.

    How do you get your shadows from the first world render on top of the render from the second world?

     

    I just don't like the idea of forcing player not to shoot simply because he is near the wall. It can be that he is still able to shoot someone but his controls are taken away.

     

    Actually, while I was playing Fallout 4 I noticed that my weapon didn't seem to receive true shadows, most of the time it was completely dark or completely bright and I was wondering why. Maybe they simply check if the player is inside the light cone (they anyway need no to do this for the stealth system) and make the weapon darker if not. Have you noticed anything like this in other games?

  2. SetInput already moves player in his local axis. First parameter is rotation angle, don't set it to 0, set it to angle you want player to look at. And second parameter will move player forward in that direction.

    Check out default FPSPlayer script, it sends camera rotation as first parameter, z input as second and x input is third.

  3. false means the frame rate game can exceed the refresh rate of your monitor(typically 60hz, so 60fps). In my opinion the only significant value of disabling vertical sync is for benchmarking.

    Or if you don't want to have terrible input lag.

    • Upvote 1
  4.  

    Script.startPivot="" --entity
    Script.dungeon={}
    Script.names={"d1", "d2l", "d2r", "d3l", "d3r"} --Names of all possible dungeon segments to check AABB intersection
    Script.d1="Prefabs/Dungeon/d1.pfb"
    Script.d2l="Prefabs/Dungeon/d2l.pfb"
    Script.d2r="Prefabs/Dungeon/d2r.pfb"
    Script.d3l="Prefabs/Dungeon/d3l.pfb"
    Script.d3r="Prefabs/Dungeon/d3r.pfb"
    Script.currentR=0
    Script.nextR=0
    Script.j=0
    Script.i=0
    Script.s=0
    Script.allDungeonSegments={}
    --Debug
    function Script:Start()
    --math.randomseed(10)
    end
    function Script:UpdateWorld()
    if App.window:KeyHit(Key.G) then self:Use() end
    end
    function Script:Use()
    self:GenerateDungeon()
    end
    function Script:GenerateDungeon() --main generation function
    self.currentR=0
    self.nextR=0
    self.i=0
    self.j=0
    player:ConsoleLog("Generation started. Countentities = "..App.world:CountEntities())
    self:DeleteAllDungeonSegments()
    player:ConsoleLog("All segments deleted. Countentities = "..App.world:CountEntities())
    self.dungeon={}
    self.dungeon[0]=self:CreateSegment(self:GetRandomPart()) --Create first dungeon element
    self.dungeon[0]:SetRotation(0,self.currentR,0,true)
    local pos = self.dungeon[0]:FindChild("Enter"):GetPosition(true)
    local previousPos = self.startPivot:GetPosition(true)
    local dPos = pos-previousPos
    self.dungeon[0]:SetPosition(pos-dPos, true)
    local result = true --Create main path
    self.dungeon, result=self:GeneratePath(100, self.dungeon) --If this function failed to generate dungeon we still need to save it, but we sholdn't proceed further
    if not result then
    self:GenerateDungeon() --Failed to generate dungeon, starting again
    return
    end
    --Generate forks
    self:GenerateForks()
    end
    function Script:GeneratePath(amount, startingTable, emergencyLimit)
    if not emergencyLimit then emergencyLimit=200 end
    local dungeon={}
    dungeon=startingTable
    local emergencyCounter=0
    local i=#dungeon+1
    self.intersectionFound=false
    while i<=amount do
    emergencyCounter=emergencyCounter+1
    --System:Print(emergencyCounter.." i="..i)
    if emergencyCounter>emergencyLimit then --reached limit of retries, generate again
    return dungeon, false --still need to return current dungeon to be able to clear it
    end
    dungeon[i]=self:CreateSegment(self:GetRandomPart())
    local yRotation=dungeon[i-1]:GetRotation(true).y+self:GetExtraRotation(dungeon[i-1])
    dungeon[i]:SetRotation(0,yRotation,0,true)
    pos = dungeon[i]:FindChild("Enter"):GetPosition(true)
    previousPos = dungeon[i-1]:FindChild("Exit"):GetPosition(true)
    dPos = pos-previousPos
    dungeon[i]:SetPosition(dungeon[i]:GetPosition(true)-dPos, true)
    --Check AABB
    local aabb=dungeon[i]:GetAABB(Entity.GlobalAABB)
    local j=1
    local maximum=#self.allDungeonSegments
    while j<=maximum do
    --System:Print(j)
    if self.allDungeonSegments[j]~=dungeon[i] and self.allDungeonSegments[j]~=dungeon[i-1] and self.allDungeonSegments[j]~=dungeon[i-2] then
    if aabb:IntersectsAABB(self.allDungeonSegments[j]:GetAABB(Entity.GlobalAABB)) then
    System:Print(dungeon[i]:GetKeyValue("name").." intersects with "..self.allDungeonSegments[j]:GetKeyValue("name"))
    if i<4 then
    return dungeon, false
    else
    System:Print("Three steps back")
    self:DeleteSegment(dungeon[i])
    System:Print("Deleted last segment")
    dungeon[i]=nil
    self:DeleteSegment(dungeon[i-1])
    System:Print("Deleted i-1")
    dungeon[i]=nil
    self:DeleteSegment(dungeon[i-2])
    System:Print("Deleted i-2")
    dungeon[i]=nil
    i=i-3
    j=1000--maximum+1
    end
    end
    end
    j=j+1
    end
    i=i+1
    --System:Print("End of I loop. i="..i)
    end
    return dungeon, true --returning true if managed to generate dungeon properly
    end
    function Script:GenerateForks()
    local i=1
    while i <= #self.dungeon do
    if self.dungeon[i]:GetKeyValue("name")=="d1" and math.random(0, 20)==0 then
    local matrix=self.dungeon[i]:GetMatrix(true)
    self:DeleteSegment(self.dungeon[i])
    self.dungeon[i]={}
    self.dungeon[i][0]=self:CreateSegment(self:GetRandomPart(4,5))
    self.dungeon[i][0]:SetMatrix(matrix, true)
    self.dungeon[i][1]=self:CreateSegment(self:GetRandomPart())
    local yRotation=self.dungeon[i][0]:GetRotation(true).y+self:GetExtraRotation(self.dungeon[i][0]) --second element
    self.dungeon[i][1]:SetRotation(0,yRotation,0,true)
    pos = self.dungeon[i][1]:FindChild("Enter"):GetPosition(true)
    previousPos = self.dungeon[i][0]:FindChild("Exit2"):GetPosition(true)
    dPos = pos-previousPos
    self.dungeon[i][1]:SetPosition(self.dungeon[i][1]:GetPosition(true)-dPos, true)
    --local dungeon
    --local result
    local dungeon, result = self:GeneratePath(15, self.dungeon[i], 30)
    if not result then
    self:DeleteSegment(dungeon[#dungeon])
    self.dungeon[i]=dungeon
    else
    self.dungeon[i]=dungeon
    end
    end
    i=i+1
    end
    end
    --other function
    function Script:GetRandomPart(minimum, maximum) --Choose random element
    if not minimum then minimum=0; maximum=3 end
    local r=math.random(minimum, maximum)
    if r==1 or r==0 then
    return self.d1
    elseif r==2 then
    return self.d2r
    elseif r==3 then
    return self.d2l
    elseif r==4 then
    return self.d3r
    elseif r==5 then
    return self.d3l
    end
    end
    function Script:GetExtraRotation(name)
    name=name:GetKeyValue("name")
    if name=="d2r" or name=="d3r" then
    return (90)
    elseif name=="d2l" or name=="d3l" then
    return (-90)
    end
    return 0 --all other segments return 0
    end
    function Script:CreateSegment(name)
    local entity=Prefab:Load(name)
    table.insert (self.allDungeonSegments, entity)
    return entity
    end
    function Script:DeleteSegment(entity)
    local i=1
    local maximum=#self.allDungeonSegments
    while i<=maximum do
    if self.allDungeonSegments[i]==entity then
    local temp = self.allDungeonSegments[i]
    table.remove (self.allDungeonSegments, i)
    --self.allDungeonSegments[i]=0
    temp:Release()
    i=maximum
    end
    i=i+1
    end
    end
    function Script:DeleteAllDungeonSegments()
    for i=1, #self.allDungeonSegments do
    self.allDungeonSegments[i]:Release()
    end
    self.allDungeonSegments={}
    end
    function Script:IsDungeonSegment(name) --not needed
    name=name:GetKeyValue("name")
    for i=1, #self.names do
    if self.names[i]==name then return true end
    end
    return false
    end
    

     

     

    That's my script. You are supposed to have 5 prefabs with specified entry and exit pivots. And a start pivot as a beginning of a dungeon.

    But I don't know what have you changed.

     

    Edit: Have you just typed a string value in startPivot variable? You should drag a pivot entity in the scene on this variable in the inspector.

    • Upvote 1
  5. Not really at this time. All AI uses the same navmesh, and the agent radius is used in the navmesh calculation.

     

    I wouldn't really worry about this, I see this problem in AAA games all the time.

    But still not being able to change character collider is a big problem. As you can see his scorpion is three times lower than collider so he should be able to crawl through small holes, but he won't with this collider.

    • Upvote 2
  6. Window:FlushKeys() will set all key states to 0. Call this before you switch to a menu or something.

    Seems like another very importand method that isn't documented. It really should be listed at least somehow.

    • Upvote 2
  7. I only made a small class once when I wanted to have the same RPG functions such as TakeDamage and IncreaseSkill the same for NPCs and player. So I created object of this class inside NPC script and Player script. But other than that it's just like Josh said, script is a class and each model on the scene with this script is an object of this class.

    • Upvote 1
  8. App.world:SetGravity(x,y,x)
    

     

    When you create a variable in App script like this:

    self.myVar=1
    

    You can access it from any other script like this:

    App.myVar=2
    

     

    Or you can use global vars that can be accessed through any script including App.lua like this

    myGlobalVar=1
    
×
×
  • Create New...