Jump to content

AggrorJorn

Members
  • Posts

    4,816
  • Joined

  • Last visited

Posts posted by AggrorJorn

  1. If your coins don't need to interact with physics once they are moving towards you and you don't want them to rotate towards the player you can move them like this:

    --UpdateWorld
    local velocity = (playerPos - coinPos):Normalize() * self.coinMoveSpeed * Time:GetSpeed()
    local newCoinPos = coinPos + velocity;
    coin:SetPosition(newCoinPos)

     

    • Thanks 1
  2. I have a similar situation with camera min/max angles where this works fine. For camera rotation the max angle is actually negative (although the name would suggest otherwise). Based on your if statements and the inversed use of max/min zoom, I figured that for the zooming something similar would be happening. 

  3. Nice script GorzenDev. That would be a nice addition to the documentation samples.

    Little side note:

    if self.curZoom < self.maxZoom then
        self.curZoom = self.maxZoom
    elseif self.curZoom > self.minZoom then
        self.curZoom = self.minZoom
    end


    could be shortened to

    self.curZoom = Math:Clamp(self.curZoom, self.maxZoom, self.minZoom)

     

    • Like 1
  4. You would have to write your settings/save data to a file. This could be any kind of file. For instance like savegame.json or .xml.

    --Load the save game file
    local path = "mysavegame.data" 
    local stream = FileSystem:WriteFile(path) 
    if (stream==nil) then Debug:Error("Failed to write save game.") end
    
    --Write save game data
    stream:WriteLine("LevelFinished:1") 
    stream:Release() 
    
    --Load the save game
    stream = FileSystem:ReadFile(path) 
    if (stream==nil)then Debug:Error("Failed to read file.") end
    
    --Loop over save game lines
    while (not stream:EOF()) do
    	System:Print(stream:ReadLine()) 
    end
    
    stream:Release()

     

  5. It is really great to see that people are still making use of these tutorials, even though they are a bit outdated.

    The problem lies in the Collision function. Th 4th parameter is speed. When you print out the value to the screen you will see that it is 0 and therefor not afflicting damage to the player.

    function Script:Collision(entity,position,normal,speed)
        System:Print("speed:" ..speed)
        if speed>20 and entity:GetKeyValue("name") ~= "DeathTrigger" then
            self:Hurt(100)
        end
    end
    

    Obiously the speed value should not be 0. This does seem like a bug imo. Maybe something that slipped in with 4.5. I tried the same map with the beta version and the problem persists. This can be a good bug report.

  6. You could make an EnterExit trigger. Not sure if you are using Lua, but you could be doing something similar in C++.

    Script.enabled = true
    Script.entered = false
    Script.exited = false
    Script.collided = false
    
    function Script:UpdatePhysics()
    	if self.enabled then
    		if self.entered then
    			if self.collided == false then
    				System:Print("Exiting the trigger")
    				self.exited = true
    				self.entered = false
    			end
    		end	
    			
    		self.collided = false
    	end	
    end
    
    function Script:Collision(entity, position, normal, speed)
    	if self.enabled then
    		self.collided = true
    		
    		if self.entered == false then
    			System:Print("Entered the trigger")
    			self.entered = true
    			self.exited = false
    		end
    	end	
    end

     

    • Upvote 1
  7. Wow there are some really old and deprecated engines up there. Some of them aren't even actual engines but mods on games.

    Additionally you might want to add Leadwerks to that wikipedia entry that is in the first result. At the bottom there is a list of proprietary game engines and leadwerks is not on there, although it is mentioned in the article itself.

    • Like 1
  8. Flush the keys to get the desired effect: https://www.leadwerks.com/learn?page=API-Reference_Object_Window_FlushKeys. Also be aware of Keyhit for the same key being stored in a single frame. That means of 2 frames us KeyHit for the Spacebar, only one script will have the spacebar set to true(pressed).

    *edit: just read the topic you were refering to. So this solution might not work for you. https://www.leadwerks.com/community/topic/15185-windowkeyhit-strange-problem/?tab=comments#comment-102329

    • Thanks 1
  9. Just now, therickmandkok said:

    If other users don't report the problem , it's problably to do with my pc / graphics drivers etc...  I have a radeon hd 6900 card and I can no longer update the drivers , so that could be it.

    To be honest I have had this problem too, but that was years ago when I did a lot of CSG brush creation. These days I just create a brush without looking to the actual measurements.  Still, if you are able to record it (OBS) we can see if there is something wrong.

  10. Ah I see what you mean. The option to check out files works regardless of software you are using btw. Subversion and TeamFoundationService do the same thing. 

    Leadwerks .map files are binary files which makes them impossible files to merge with text editors/mergers. If you use Git you can not exclusively checkout files, but work with local copies and having to to merge with an existing branch.

  11. Your item script is fine, although I would set the enabled/pickedup boolean to false. Because now, everytime you spawn the entity, it is emmidiatly 'picked up'. I would also rename this boolean to 'pickedUp' or something similar. Calling it 'enabled' could mean anything.

    I might have forgot the starting possibility. You want to spawn an item when:

    A: there is no entity spawned yet.

    B: an entity is spawned but not yet picked up.

     

    Try this line instead of the previous one:

        if self.spawn == nil  or self.spawn.script.pickedUp then

     

  12. I remember a blog post when this option was introduced. I asked the question what would happen with entities loaded by code. The answer was something like "These are not included". But that blog was more than 1 or 2 years ago so things might have changed.

×
×
  • Create New...