-
Posts
688 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Chris Vossen
-
-
If the details lower the FPS drop them
-
I'm a little confused as to the exact nature of the prefab factory. Are you trying to input a prefab name and destination and then have a function that when called will load a prefab at that destination?
-
I'm currently planning out a multiple week "Let's build a FPS" tutorial.
It will be a series of tutorials wherein each week I will cover a new subject (movement, lighting, dealing with assets... etc) resulting in the final outcome of fully playable FPS.
More to come on this!
- 2
-
Thanks for the tip on prefab.
the fisrt would be some 360 direction input by mouse for the character or for some space ship :
On Android instead of mouse it would be some full 360 Android circle pad.
***********************
The second idea was but for later would be some RTS style unit movement :
You click on terrain or any model level with mouse and your unit or character goes to that position.
I'm just going to quickly post these 2 bits of code:
Top Down Camera:
Script.target = nil--Entity "Target"
Script.distance = 10--float
Script.debugphysics = false--bool
Script.debugnavigation = false--bool
Script.pitch = 20--float
Script.height = 10--float
function Script:Start()
if self.target==nil then return end
--debug functions for viewing physics or navigation in game
self.entity:SetDebugPhysicsMode(self.debugphysics)
self.entity:SetDebugNavigationMode(self.debugnavigation)
--Set the camera's rotation
self.entity:SetRotation(self.pitch,0,0)
end
function Script:UpdatePhysics()
--Exit the function if the target entity doesn't exist
if self.target==nil then return end
--Get the target entity's position, in global coordinates
local p0 = self.target:GetPosition(true)
--Calculate the new camera offset
local offset = Vec3(p0.x,p0.y+self.height,p0.z-self.distance)
--Add our original offset vector to the target entity position
p0 = offset
self.entity:SetPosition(p0,true)
end
Character movements: (on a goblin model)
Script.camera = nil --Entity "camera"
--Define animation sequences
Script.sequence={}
Script.sequence.walk=5
Script.sequence.idle=6
function Script:Start()
self.currentyrotation = self.entity:GetRotation().y
self.modelrotation = -90
App.window:ShowMouse()
end
function Script:UpdatePhysics()
local window = Window:GetCurrent()
local move = (window:MouseDown(Key.LButton) and 1 or 0)
local playerscreenpos = self.camera:Project(self.entity:GetPosition(true))
local mousescreenpos = window:GetMousePosition()
local vectorbetween = mousescreenpos - playerscreenpos
self.currentyrotation = Math:ATan2(vectorbetween.y, vectorbetween.x) + self.modelrotation
self.entity:SetInput(self.currentyrotation,move,0)
if move ~= 0 then
self.entity.animationmanager:SetAnimationSequence(self.sequence.walk,0.04,200)
else
self.entity.animationmanager:SetAnimationSequence(self.sequence.idle,0.05,200)
end
end
To understand the code basically
Math::ATan2 finds the angle between the mouse and the player
Camera::Project takes the character position in global space and converts it to screen space.
-
To do: Add in a Lua tag and create a documentation page.
-
So the proper way to do it is a call to World:Clear(), unfortunately we forgot to tag it for lua (and document it). I'm posting a bug report for this right now and hopefully the lua tag (and documentation) will be available with the next build.
-
This is a slippery bug (it is really hard to recreate), that we thought we had pinned down. Make sure your current LE3 copy is up to date (Click on the update button on the installer) and we will check it out.
-
@Chris : thanks we have the free camera system now.
For rocket launcher code,, what would you use ? a rocket we put below ground and just place after weapon when player fires ?
For collision Axis box collision between rocket and mob ?
In the editor I'd create a rocket model, set it's physics shape and collision type, attach a particle effect, and then save it as a prefab. Then in code I'd use the prefab load function:Prefab
@Chris :
When you'll have time, if you could post some lines about Mouse to manage direction of the character ?
If I can find the time, maybe. What sort of mouse movement are you thinking of?
-
Sorry to bump but anyone know how to set custom collision types in Leadwerks 3? I know how to set a collision type.
Cheers!
-
The Time class contains many handy functions.
I'd use Time::GetCurrent
local nextoccurrence = Time:GetCurrent() + 6000 (6000 milliseconds aka 6 seconds)
if Time:GetCurrent() > nextoccurrence then
nextoccurrence = Time:GetCurrent() + 6000
Do the function that you want every 6 seconds here
end
-
Thanks, it's a start.
I notice that when attached to a camera, it makes the camera slowly but 'continuously' move (when the keys are not pressed).. I tried adding mass to the camera to stop it without success. Any ideas how it can be stabilised?
Weird, I can't seem to recreate this. For me the camera just floats in mid air. If you zip a copy of your project and msg me with it I'll open it and take a look.
-
Okay I posted some 3rd person movements code :
http://www.leadwerks.com/werkspace/files/file/407-3rd-person-controls/
As well as a blog on how to set up a 3rd person scene:
And a step by step code walkthrough of the 3rd person camera:
http://www.leadwerks.com/werkspace/blog/110/entry-1058-third-person-camera-code-walk-through/
-
Here is the start of a 3rd person camera. I'll write up a blog explaining the code tomorrow:
http://www.leadwerks.com/werkspace/files/file/406-3rd-person-camera/
For those who don't want to click download you can copy and paste this:
Script.target = nil--Entity "Target"
Script.distance = 5--float
Script.debugphysics = false--bool
Script.debugnavigation = false--bool
Script.pitch = 35--float
Script.angle = 180--float
Script.pickradius = 0.5--float
Script.verticaloffset = 1.8--float
Script.smoothness = 30--int
function Script:Start()
if self.target==nil then return end
--debug functions for viewing physics or navigation in game
self.entity:SetDebugPhysicsMode(self.debugphysics)
self.entity:SetDebugNavigationMode(self.debugnavigation)
end
function Script:UpdatePhysics()
--Exit the function if the target entity doesn't exist
if self.target==nil then return end
local originalcamerapos = self.entity:GetPosition(true)
local targetpos = self.target:GetPosition(true)
local newcamerapos = self.target:GetPosition(true)
targetpos.y = targetpos.y+self.verticaloffset
self.entity:SetPosition(targetpos)
self.entity:SetRotation(self.target:GetRotation(true))
self.entity:Turn(self.pitch,self.angle,0)
self.entity:Move(0,0,-self.distance)
local targetpickmode = self.target:GetPickMode()
self.target:SetPickMode(0) --so that the pick doesn't hit the target
newcamerapos = self.entity:GetPosition()
local pickinfo = PickInfo()
if (App.world:Pick(targetpos,self.entity:GetPosition(),pickinfo,self.pickradius,true)) then
newcamerapos = pickinfo.position
end
newcamerapos.x = Math:Curve(originalcamerapos.x,newcamerapos.x,self.smoothness/Time:GetSpeed())
newcamerapos.y = Math:Curve(originalcamerapos.y,newcamerapos.y,self.smoothness/Time:GetSpeed())
newcamerapos.z = Math:Curve(originalcamerapos.z,newcamerapos.z,self.smoothness/Time:GetSpeed())
self.entity:SetPosition(newcamerapos)
self.target:SetPickMode(targetpickmode)--return pick mode to original value
end
-
This isn't a tutorial but I uploaded a FreeLook (which I basically stole from Josh) camera that uses the WASD keys and mouse movements.
http://www.leadwerks.com/werkspace/files/file/405-freelooklua/
While it's not a true FPS camera, you hopefully could augment it to fit your project.
-
I was watching Andy's : http://www.leadwerks.../videos/_/-r192
And immediately thought of portal somehow.
Is it possible to render a camera to a texture?
Josh says that buffers similar to LE2 are in the code, but not officially supported at this time.
-
If I was going to make 1 tutorial, what subject would you want it to be on?
-
Straneg ? Golbins don't attack each other in the game ?
The Goblin should attack player only ?
They will only attack players:
function EnemyAttackForEachEntityInAABBDoCallback(entity,extra)
if extra~=entity then
if entity.player~=nil then
extra.goblinai:AttackEnemy(entity.player)
end
end
end
-
-
Thank you!
Josh just fixed it and will include the fix in the next update.
-
I created a new LUA Project.
The script i've overwritten was the default one of the mini game.
How to do when we create a new project to not overwritte the main Lua script ?
It seems it's the same main Lua file called each time could we create a new project ?
OR should we duplicate script , ressources etc ... to the new project location ?
I'm a bit confused about that main script launched bu default
So when you make a new project it includes all the default scripts.
If you changed the script in the Darkness Awaits folder and want to use that script in your new project you can copy just copy and past it into the new project's script folder.
Also this post might help:
http://www.leadwerks.com/werkspace/topic/6081-le3-question-about-starting-a-project/
-
So the function don't work correctly and we should avoid use it ?
As far as I know the function is working properly. If it's not let me know!
-
Quick steps to making a new project:
1. Make sure your current LE3 build is up to date (just click on the installer and click update)
2. Open the project manager File->Project Manager
3. Click "New"
4. Select your project type (I chose Lua for this example), enter a project name, and click okay.
5. Select your project from the list and click okay
6. Create a map, throw in a camera
7. Save your map.
8. Click run.
-
Finally exploring Leadwerks 3. I've discovered how to create a project but but when I run the map it always seems to start with the 'Darkness Waits' title and music then shows the scene I have created. I'm not in the Darkness Waits project so where do I either delete or change the title and music? I've looked through lua.start but there's nothing there about loading media.
Hmm when you use the project manager to make a new project it should create a new App.Lua script that shouldn't have anything to do with Darkness Awaits.
If you open up the App.Lua script it should look something like this: (except instead of "test2" it should say your project name)
--This function will be called once when the program starts
function App:Start()
--Set the application title
self.title="test2"
--Create a window
self.window=Window:Create(self.title)
self.window:HideMouse()
--Create the graphics context
self.context=Context:Create(self.window,0)
if self.context==nil then return false end
--Create a world
self.world=World:Create()
--Load a map
local mapfile = System:GetProperty("map","Maps/start.map")
if Map:Load(mapfile)==false then return false end
return true
end
--This is our main program loop and will be called continuously until the program ends
function App:Loop()
--If window has been closed, end the program
if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end
--Update the app timing
Time:Update()
--Update the world
self.world:Update()
--Render the world
self.world:Render()
--Refresh the screen
self.context:Sync()
--Returning true tells the main program to keep looping
return true
end
-
how to fade texture
in Programming
Posted
Check out GetTexture:
http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/material/materialgettexture-r125
then change of the texture.