Jump to content

macklebee

Members
  • Posts

    3,946
  • Joined

  • Last visited

Posts posted by macklebee

  1. Need more information. Are you saying that when your character's physics mode is changed to Character and you have the physics debug mode on, your character is halfway into the ground? Where is your player model's origin located? If its at the center instead of its feet, the base of the controller will be at the waist. Or are you saying that the character model is sinking into the ground while the controller stays above ground? Would be useful if you provided enough information to see exactly what you are doing wrong - example map, code, the character's physics property settings, or even the model itself (if its not proprietary)...

    • Upvote 1
  2. 2 hours ago, gamecreator said:

    Ah yes.  So an enemy told to go from one side to another would try to go down the middle.  And I guess in C you'd have to set his character controller to crouch mode with SetInput once he gets to the area.

    Exactly. Use triggers to toggle crouch. Could do the same for the player as well so the user doesn't even have to do it.

    • Like 1
    • Upvote 1
  3. 1 hour ago, gamecreator said:

    That's good to know.  Do you know if it also works with GoToPoint and Follow, taking holes like the ones in Defranco's video into consideration?

    Are you talking about whether or not the navigation system will create a navmesh in an area for crouching? Not inherently due to the restriction built into the navmesh creation. But you can always get around that by being creative on what entities have their navigation mode set to true when you are building your scene. In my example above with the 3 boxes, I would set the ground and the two vertical boxes' navigation mode to true and not the horizontal. This would allow for a navmesh to be built under the box.

    crouchnavmesh.jpg

    • Like 1
    • Upvote 1
  4. Defranco is correct and I am not sure why this keeps getting stated that crouching is not available?? For some flarking reason it is not officially supported and you have to take care of the animation, the movement/position of the camera, and understand the crouch height limit (1.2m), but it works. I think people are assuming since the visual representation of the physics body does not change shape when crouched that the actual physics body did not change shape. In LE2 days, the visual also changed when crouched.

     

    • Upvote 1
  5. Try this with the understanding that it doesn't play well with sprites or particles:

    --insert before main loop
    mybuffer = Buffer:Create(window:GetWidth(),window:GetHeight(),1,1) --custom buffer
    image = Texture:Load("Materials/Developer/bluegrid.tex") --load the background image
    
    --in the main loop
    currentbuffer = Buffer:GetCurrent() --add this
    mybuffer:Enable()					--add this
    
    --Render the world
    world:Render() 						--this should already be there
    	
    currentbuffer:Enable()				--add this
    
    context:SetColor(1,1,1,1) 			--add this if using std fpsplayer cuz Josh doesn't clean up his context SetColors!
    context:DrawImage(image,0,0,window:GetWidth(),window:GetHeight()) --add this
    context:DrawImage(mybuffer:GetColorTexture(0),0,0,window:GetWidth(),window:GetHeight()) --add this
    
    --draw text and images etc after if required

    background.thumb.jpg.61b1391d7d441ab31264b5c043d35b7e.jpg

     

    • Like 1
  6. 9 hours ago, Rick said:

    I'd like to see some automatic configuration around this (if it doesn't already exist) based on a naming convention. Perhaps open the model and click one button that brings them all in with the same name and an underscore or perhaps the @ which is popular format for this kind of thing. Perhaps a dialog that shows all them and you can multi-select which ones you want to add.

    So what you are asking for is what you can currently do within the Model Editor with the File>Load Animation dialog except you want it to be able to multi-select instead of one at a time.

  7. SetResponse is not officially documented for some reason but if you search the forum you will find plenty of examples of it. What you are showing should work assuming the endpoints of the World Pick are where you think they are. You may need to place a sphere at the pick position to confirm. Another way to do this would be just pick everything by setting the Pick's collisiontype to '0' then filtering the results by checking the collisiontype/name/etc of the picked entity.

    Example:

    window = Window:Create()
    context = Context:Create(window)
    world = World:Create() 
    camera = Camera:Create() 
    camera:Move(0,1,-5) 
    light = DirectionalLight:Create() 
    light:SetRotation(35,35,0) 
    
    enemy = Model:Load("Models/Characters/generic/generic.mdl")
    enemy:SetPosition(-4,0,0)
    enemy:SetRotation(0,90,0)
    enemy:SetColor(1,.5,0,1) 
    enemy:SetCollisionType(Collision.Character)
    
    player = Model:Load("Models/Characters/generic/generic.mdl")
    player:SetPosition(4,0,0)
    player:SetColor(0,1,0,1)
    player:SetCollisionType(Collision.Character)
    player.health = 1000
    
    wall = Model:Box()
    wall:SetScale(0.2,1,1)
    wall:SetColor(0,0,1,1)
    wall:SetCollisionType(Collision.Prop)
    
    toggle1 = 1 
    toggle2 = -1
    
    while window:KeyDown(Key.Escape)==false do
    	if window:Closed() then break end
    	
    	if wall:GetPosition().y > 3 then
    		toggle1 = -1
    	elseif wall:GetPosition().y < -1 then
    		toggle1 = 1
    	end
    	wall:Translate(0,0.01*Time:GetSpeed()*toggle1,0)
    	
    	if player:GetPosition().y > 3 then
    		toggle2 = -1
    	elseif player:GetPosition().y < -1 then
    		toggle2 = 1
    	end
    	player:Translate(0,0.02*Time:GetSpeed()*toggle2,0)
    	
    	Time:Update() 
    	world:Update() 
    	world:Render() 
    
    	pickinfo = PickInfo() 
    	p0 = enemy:GetPosition() -- enemy position
    	p1 = p0 + Vec3(0,1.7,0) -- adding height so ray comes from enemy eyes
    	p2 = player:GetPosition() 
    	p3 = p1 + Vec3(10,0,0) -- 10m ray out from enemy eyes
    	pick = world:Pick(p1,p3,pickinfo,0,true,0) -- pick between two defined points
    	if pick then
    		if pickinfo.entity==player then player.health = player.health - 0.1 end --do damage to player
    		d1 = camera:Project(pickinfo.position) -- just to show raycast hitpoint
    	end
    	d0 = camera:Project(p1) -- just to show raycast startpoint
    
    	context:SetBlendMode(Blend.Alpha)
    	context:SetColor(1,0,0,1)
    	context:DrawText(string.format("Player Health: %.1f",player.health), 2, 2)
    	context:DrawText("Pick: "..string.format("%s", pick),0,20)
    	n0 = camera:Project(p0)
    	n1 = camera:Project(p2)
    	context:DrawText("ENEMY",n0.x,n0.y)
    	context:DrawText("PLAYER",n1.x,n1.y)
    	if pick then context:DrawLine(d0.x,d0.y,d1.x,d1.y) end
    	context:SetColor(1,1,1,1)
    	context:SetBlendMode(Blend.Solid)
    	context:Sync(true) 
    end

     

    worldpick.jpg

    • Thanks 1
    • Upvote 1
  8. Here is the table that for some reason has been removed from the documentation:

    If you are trying to only have a collision with the character then you will need to make a new collision type that only interacts with a character using SetResponse(). Then use that new collsiontype with your Pick. See this post for more info:

     

  9. It would be a lot easier if we had code to review and try for ourselves. The video is nice as it shows what the effects of the issue but doesn't help us see what you are doing wrong. Show us your pick code. Or better yet, make a small example map and available code that we can easily try. 

     

  10. Nothing special required for sandbox mode being turned off - just know that it has loaded lua modules or LE sandbox-disabled specific commands that someone could attempt to do nefarious things with.., which is why lua sandbox enabled was the only option for games uploaded to the game launcher.

    In any case, don't use dofile due to the path issue with an exported game- use Interpreter:Executefile() or import depending on how you are using the loaded file. Both will work with sandbox mode enabled or disabled and will work with data.zip.

    EDIT - updated to point out that dofile works with sandbox enabled. The problem is due to the file path changing once everything is exported to a data.zip folder.

    • Like 1
  11. On 4/28/2018 at 10:54 AM, reepblue said:

    With LE4, dofile isn't exposed. To call the lua script, you need to use "import" instead. This will run the lua script and put all the functions and variables in memory. 

    The lua function dofile is exposed in LE4. It works in editing mode with lua sandbox turned ON or OFF. The reason dofile is failing is due to how the file path is changed when everything is placed inside data.zip within the game directory. For example, prior to publishing myscript.lua is in the "MyGame/Scripts" folder, and after exporting myscript.lua is now in the "Scripts" folder inside the data.zip file located in the "MyGame" folder. Dofile will work if the path from the executable's root folder to the file in question has not changed. So this means you can create a folder called "Scripts" within the root folder and put myscript.lua in there. But this means your files are exposed....

    On 4/28/2018 at 11:37 AM, Phodex Games said:

    @reepblue Thanks thats the information I needed :), but the problem now is that for some reason import does only work with pure string not put into a variable. But within my system I often used "dofile" to load self made data files, like sound profiles for various objects, which paths are stored in variables to be flexible. Is there any way you could do this? Otherwise I have some trouble :rolleyes:

    While import does work - it will only load the file once. So if you are using import to set variables by loading multiple scripts, it will only let you set it once with that file. So the LE sandbox version of dofile is 'Interpreter:Executefile("luascript.lua")'. Also, since it is an inherent command in LE, it works when published from the data.zip without having to worry about paths being changed.

    Example: Files, myfile1 & myfile2, contain the variables A, B, & C set to various values.

    window = Window:Create("example",0,0,400,300,Window.Titlebar+Window.Center)
    context = Context:Create(window)
    world = World:Create()
    camera = Camera:Create()
    
    gui = GUI:Create(context)
    base = gui:GetBase()
    x=140
    y=110
    local sep=30
    button1 = Widget:Button("Dofile 1",x,y,100,25,base)
    y=y+sep
    button2 = Widget:Button("Dofile 2",x,y,100,25,base)
    A = 0
    B = 0
    C = 0
    D = 0
    while not window:KeyHit(Key.Escape) do
    	if window:Closed() then return false end
            
    	while EventQueue:Peek() do
    		local event = EventQueue:Wait()
    		if event.source == button1 then
    			filetodo = "Scripts/myfile1.lua"
    		elseif event.source == button2 then
    			filetodo = "Scripts/myfile2.lua"
    		end
    		Interpreter:ExecuteFile(filetodo)
    	end
    	D = A + B - C	
    		
    	Time:Update()
    	world:Update()
    	world:Render()
    	context:SetBlendMode(Blend.Alpha)
    	context:DrawText("D = "..D,2,2)
    	context:SetBlendMode(Blend.Solid)
    	context:Sync()
    end

     

    • Like 2
  12. os.time works but it requires that lua sandbox be disabled. If you are trying to get a number to use with randomseed() and random(), try using Time:Millisecs() as it doesn't require lua sandbox to be disabled.

    On a side note: os.date seems to be more user friendly if anyone is trying to obtain time in hours/minutes/seconds... https://www.lua.org/pil/22.1.html

    window = Window:Create("CLOCK",0,0,500,500,Window.Titlebar+Window.Center)
    context = Context:Create(window)
    world = World:Create()
    camera = Camera:Create()
    light = DirectionalLight:Create()
    light:SetRotation(30,35,0)
    
    box1 = Model:Box()
    box1:SetPosition(0,0,1.5)
    box1:SetColor(1,0.5,0,1)
    
    while not window:KeyHit(Key.Escape) do
    	if window:Closed() then return false end
    	
    	box1:Turn(0,Time:GetSpeed()*0.5,0)
    
     	Time:Update()
    	world:Update()
    	world:Render()
    	
    	local temp = os.time()
    	context:SetBlendMode(Blend.Alpha)
    	context:DrawText(os.date("%I:%M:%S"),2,2)
    	context:DrawText(temp,2,22)
    	context:DrawText(os.date("%X", temp),2,42)
    	context:SetBlendMode(Blend.Solid)
    	context:Sync(true)
    end

     

    clock.jpg

    • Like 1
    • Thanks 1
  13. You need to post an example of your problem because what you are describing is exactly what my code does. If you notice from the post pic the text is being drawn onto the buffer and then the color texture is being set to the material. If there was no transparency on that "text buffer" then you would not see the concrete texture on the box.

  14. You are setting the buffer color to white when you clear it which results in a white background. Same would happen if you set the color to red and you cleared it would result in a red background. Try setting the color to (0,0,0,0). Also, you are using 5 parameters in your setcolor() - not sure the mode parameter is a part of the buffer's SetColor()? 

    But it looks like you are also missing setting the blendmode to alpha prior to clearing? Maybe have to set the alpha to 1 prior to clearing for your needs... hard to say since you don't give us enough information to understand what you are trying to draw. Look at my example post from the post you linked to:

        Buffer:SetCurrent(mybuffer)
    	context:SetBlendMode(Blend.Alpha)
    	context:SetColor(0,0,0,0)
    	mybuffer:Clear()
    	context:SetColor(1,0,0,1)
    	context:DrawText(os.date("%I:%M:%S"),25,45)
    	tex4 = mybuffer:GetColorTexture(0)
    	mat1:SetTexture(tex4,4)
    	Buffer:SetCurrent(buffer)
    	context:Sync(true)

     

  15. Are you assuming the collision is only happening once? More than likely when a collision occurs, its triggered multiple times. A box falling on the ground is not just a single collision. If you are not performing a check to prevent it, the second reported collision will try to release an entity that has been already released by the first reported collision. Without example code, we can only guess what you are doing wrong.

  16. There have been several shaders that use masks (in various capacities) - found within 5 minutes of searching for the keyword "mask".

    I also remember shadmar having several posts in the past where he was using masks for 2D effects as well.

    • Haha 1
  17. OOP, please. Mostly for the selfish reason that it allows me for the most part to use old code without having to completely rewrite it and procedural will pretty much guarantee that majority of your current users will be frustratingly be typing in the wrong code because they keep forgetting that you just decided to randomly change your API syntax.

    • Like 3
  18. What "model settings" are you referring to? Are you referring to the model's material settings? Are you talking about physics shape? Or are you talking about the appearance/physics settings that can be saved for a model once placed in the scene or saved as a prefab? Need more information or we are just guessing.

  19. Open up the material in the Material Editor and change the diffuse color. Save and exit.  Sorry I see you said flat diffuse. Thats what that shader does. It sets the diffuse color to (0.5,0.5,1.0) and the normal to 0. Maybe picking the regular diffuse shader with no normals will give you what you are looking for.

×
×
  • Create New...