Jump to content

Phodex Games

Members
  • Posts

    275
  • Joined

  • Last visited

Posts posted by Phodex Games

  1. Yes all this is possible. 

    For blending use the blend value in the PlayAnimation function. To play animations only on particular bones, you need to call the animation function on the specific bones you want to play the animation.

     

    Here an example. Say you want the character to speak while running. I will simplify the structure for better unterstanding:

    --play running
    self.entity:PlayAnimation("running", 1, 500)
    --play talk animation only on the face
    self.entity:GetChild("FaceBones"):PlayAnimation("talking", 1, 500)

    Obviously the "FaceBones" entity most likey is called something like "Head" containing all other bones, like lip, eyebrown etc bones.

    Imporant to know is that if you play a new animation on parts of your model the old animation gets overwritten (so the head bones dont play the run animation obviously) and it is not nessecary to play the animation on all sub bones. Check your bone hierarchy in the editor and just play the animations on the parent. Hope you understood everything.

  2. 12 hours ago, randomdude said:

    I made a character for that purpose which has a big load of MoCap-animations

    MoCap? How did you do that? You dont have a professional mocap studio I guess. You used that kinect thing did'nt you?

    12 hours ago, randomdude said:

    Yes if you do it not this way or lets say you are not making all unseen sides invisible you get fps problems

    Of course, but I am talking about you have an entity in the editor for every csg brush, so for larger structures you will generate many entites. A single modle just counts as one entity. And the number of entites also affects performance know what I mean?

    12 hours ago, randomdude said:

    In LW itself you cant make specific sides of models invisible as far as I know. The point is you loose all of LW beauty if you use too much models.

    True, but thats what I meant, you can also hide faces inside a model editing software. Actually thats a fundamental thing to even DELETE sides which are not needed, or you cannot see. So you can actually do this even better within a model. But IF you want to work with csg brushes that thing you showed about faces is very important. I dont really know what you mean, that models make the game look worse, because you can create any model you want and its up to YOU how it looks like. You can actually create models looking like the csg brushes ^^, know what I mean. But I guess what you actually mean is to not overload your scene with details dont you?

  3. Hey,

    to explain the blending. As I dont use this function very often dont blame me if I am wrong ^^. This is an example code to show the function:

    function Script:Update()
      if window:KeyHit(Key.D1) then
    	self.entity:PlayAnimation("Idle", 5, 500)
      elseif window:KeyHit(Key.D2) then
    	self.entity:PlayAnimation("Walking", 5, 500)
       end
     end

    So what happens now is that if you press "1" on the Keyboard, the entity starts playing the idle animation. Because the entity had no animation before, blending does not matter. Hope thats clear so far. So if you now press "2" then the walking animation gets played, BUT its blends from the idle animation to the new one. More precise: The idle animation needs 500 miliseconds to blend into the walking animation. So the blending always happens you just decide how long it takes, if it is nil or 0 then no blending happens. I hope this was understandable. Of course this works the other way as well if you go from walking to idle. Try experimenting with it.

    On 23.8.2017 at 3:19 PM, randomdude said:

    Yeah its fun for me as well, but I want to get it done, it takes just too much time and then it doesnt work. My plan is to finish the maps and do this at the end.

    Its funny because I could say the exactly same thing about art :D. I have that problem with good working animations and models, but I really want to learn it. Currently getting into ZBrush. My Animation skills are at least good enough to create some basic motions.

    That tip on performance is very interesting indeed, thank you. Did not knew that yet, but some time ago I created an whole house with CSG Brushes and it lead to heavy performance issues, because its creates a LOT of entites. My performance where ways better when using an optimised single model. But your tip also works with models I guess. However be careful to not create more entites than you need.

    I dont know how good I am in level design and yes its a fun part ineed, but have not gathered much experience yet. I am working on all of my systems, you know all that coding stuff. This is where most of the beginner gamedevs fail, thats why I decided to start with that. 

    On 23.8.2017 at 3:19 PM, randomdude said:

    If you ever have a performance problem or no idea how to give your maps a special touch just let me know

    Will definitely come back to you :)

    On 23.8.2017 at 3:19 PM, randomdude said:

    I have not seen something from you

    Well working hard, I guess cant take too long till I will show some stuff. I have huge plans :D working for about an year on my current project, but not much model/animation work is done yet, but as mentioned before its just an framework no real game or something but whatsoever ^^

     

    Edit: This could be interesting if it comes to raycasting, actually its the command to perfrom an raycast:

    https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_Pick

  4. Hi,

    About that animationmanager thing:

     Well there are a few things to say about it. First, yes Leadwerks has/had an own animationmanager script build in, which was used back in the days, when the "PlayAnimation" function was not available, but I was talking about my own animation manager script I created myself. You cannot download this anywhere as I have not released it :D. However never mind it, as the PlayAnimation function works well and its much easier for beginners.

    About Blending:

    PlayAnimation(string sequence,number speed=1.0f, number blendtime=500, number mode=0, string endhook="")

    This is what you find in the documentation. See that "number blendtime", this is for blending. More precise this is the time in miliseconds to blend form one animation to another as far as I understand it. 

    About your interaction function:

    Puh, would take a lot of time to indeep explain, how to do interaction, what options you have etc. However as far as I understand you want your player to interact with stuff in the world right? I have no idea how the code, I could see in the video should get this done. Where does this function even get called from? The only thing this lines of code does is to search for entities which have an "Use" function inside their script.

    The most common way to handle interaction is to use a raycast. I hope you are familiar in any way with that, so I dont have to explain this more detailed :D. Another way I could think of especially in those 3rd person "topdown" like style is a cylinder or sphere around the player which scans if objects around can be ineracted with, but this method may pick more than one Item at once so this could be a problem. However it would be a little bit too complicated to explain this in detail.

    I think you are doing pretty well so far and your stuff looks interesting. I think one of the fun parts making games is to come up with own ideas and to solve problems like that. I see you dont feel the same way :D, but maybe try it out. I know you want to focus on the art stuff, but give coding a try :). Sit down, enjoy a cup of coffee, take pen and paper and think on how to solve your problem, try it out and see what you can do.

    Good Luck :)

  5. Actually to be honest I dont use the built in PlayAnimation command, so I dont have much experience with it. I use my self made animation manager. Maybe I will put this on the workshop any time soon, because it provides more features then the build in animation function.

    I cant tell you for sure why its ignoring your speed value, because you did not provide the code where your char is playing the running animation.

    What I mentioned is that you need some blending when your character stands up its a little bit direct. To make your character go idle when you dont move, as this is what I understood you want to realise, you need to check if your character has speed in any direction, or if the play is pressing any kind of key. So you have to come up with something like this:

    local speed = self.entity:GetVelocity(true)
    local newMode = nil
    
    if speed.x == 0 and speed.y == 0 and newMode ~= "Idle" then
      	newMode = "Idle"
    	self.entity:PlayAnimation("Idle", 0.035)
    elseif newMode ~= "Walking" then
      	newMode = "Walking"
      	self.entity:PlayAnimation("Walking", 0.035)
    end

    Notice that you need to check if your mode is "Idle" or "Walking" already that your entity does not call "PlayAnimation" all the time this is very important. It can be pretty complicated if you have many diffrent modes, because you need to notice any circumstance there is and how it affects your mode.

    I would recommend you creating a seperate function for your modes this can look like this:

    function Script:SetIdle()
    	newMode = "Idle"
    	self.entity:PlayAnimation("Idle", 0.035)
    end
    
    function Script:SetWalking()
    	newMode = "Walking"
    	self.entity:PlayAnimation("Walking", 0.035)
    end

    Or like this:

    function Script:SetMode(mode)
    	newMode = mode 
    	if mode == "Idle" then 
    		self.entity:PlayAnimation("Idle", 0.035)
    	end
    	if mode == "Walking" then 
    		self.entity:PlayAnimation("Walking", 0.035)
    	end
    end

    This makes it easier for you and you have your code more organized. You also most likley need to set the modes more than just one time where this helps you as well.

    Its a little off topic, but because I am currently creating a framework, including many systems, like the animation manager, an easy UI system, AI and so on, I mentioned this would be very helpful for you as you dont want to code that much, and thats exactly the reason I am creating it. Unfortunately there is a lot of work to be done and a release can't be expected any time soon, but maybe I will provide some smaller parts in the workshop in the future.

  6. I have a question and an answer to this topic. Is there any reason you call you stuff in the UpdatePhysics function, because I see no reason for that. Correctly me if I am wrong as I am no expert.

    If I can give you an advice, built in a system allowing you to perform keychecks multiple times per Update. I use this method as well, I would implement it as fast as possible into your project. Works like the following:

    --Put this into your main.lua:
    
    --main.lua code here
    
    keyHit = {} --just declare this variable, outside the main loop
    
    --some more main.lua code
    
    --Put this inside the main loop in the main.lua file:
    
    	--------------------Hit
    	--Mouse
    	keyHit.RMouse = window:MouseHit(2)
    	keyHit.LMouse = window:MouseHit(1)
    	
    	--Alphabetic
    	keyHit.A = window:KeyHit(Key.A)
    	keyHit.B = window:KeyHit(Key.B)
    	keyHit.C = window:KeyHit(Key.C)
    	keyHit.D = window:KeyHit(Key.D)
    	keyHit.E = window:KeyHit(Key.E)
    	keyHit.F = window:KeyHit(Key.F)
    	keyHit.G = window:KeyHit(Key.G)
    	keyHit.H = window:KeyHit(Key.H)
    	keyHit.I = window:KeyHit(Key.I)
    	keyHit.J = window:KeyHit(Key.J)
    	keyHit.K = window:KeyHit(Key.K)
    	keyHit.L = window:KeyHit(Key.L)
    	keyHit.M = window:KeyHit(Key.M)
    	keyHit.N = window:KeyHit(Key.N)
    	keyHit.O = window:KeyHit(Key.O)
    	keyHit.P = window:KeyHit(Key.P)
    	keyHit.Q = window:KeyHit(Key.Q)
    	keyHit.R = window:KeyHit(Key.R)
    	keyHit.S = window:KeyHit(Key.S)
    	keyHit.T = window:KeyHit(Key.T)
    	keyHit.U = window:KeyHit(Key.U)
    	keyHit.V = window:KeyHit(Key.V)
    	keyHit.W = window:KeyHit(Key.W)
    	keyHit.X = window:KeyHit(Key.X)
    	keyHit.Y = window:KeyHit(Key.Y)
    	keyHit.Z = window:KeyHit(Key.Z)
    	
    	--Numeric
    	keyHit.D0 = window:KeyHit(Key.D0)
    	keyHit.D1 = window:KeyHit(Key.D1)
    	keyHit.D2 = window:KeyHit(Key.D2)
    	keyHit.D3 = window:KeyHit(Key.D3)
    	keyHit.D4 = window:KeyHit(Key.D4)
    	keyHit.D5 = window:KeyHit(Key.D5)
    	keyHit.D6 = window:KeyHit(Key.D6)
    	keyHit.D7 = window:KeyHit(Key.D6)
    	keyHit.D8 = window:KeyHit(Key.D7)
    	keyHit.D9 = window:KeyHit(Key.D8)
    	
    	--Special
    	keyHit.BackSpace = window:KeyHit(Key.BackSpace)
    	keyHit.CapsLock = window:KeyHit(Key.CapsLock)
    	keyHit.Space = window:KeyHit(Key.Space)
    	keyHit.Escape = window:KeyHit(Key.Escape)
    	-----------------------------------------------

    You can do the same for KeyDown of course. Now instead of "if window:keyHit(Key.E) then" you can use "if keyHit.E then". This is not only shorter, but also can be used as often as you want. Note that you need to add some characters to my keyHit list, because mine is not complete. I hope this is understandable if not I could provide a modified main.lua including my code so you can take a look at it.

     

    About your actual problem, as far as I understood you just want the person to stand up if you press E. The problem is that it just plays the animation as long as keyHit is true and that is just the case for one millisec maybe. So here is the fix:

    if self.entity:GetAirborne()==false then 
    		if window:KeyHit(Key.E) and newmode ~= "Idle" then
    		   newmode = "Idle"
    		   self.entity:PlayAnimation("Idle",0.035)
    		end
    	end

    Now the entity plays the idle animation if you hit E. The question under which circumstances you want the entity to sit? You have to code this externally, not within the KeyHit command!

  7. Hi,

    pretty simple question. Is there a way to get the files/filenames of all files within an folder. Could not find something like that in the API. I used the lua io.popen function and it works ok, but seems to open up an cmd window for a second, which does not look good. However any ideas?

  8. The easiest and best way for you would be to go for E-Books, but in advice I doubt this would be a success ^^. I mean Leadwerks is cool but its definetly not a mainstream Engine, even further I guess the percentage of people using Leadwerks and are spanish is very low. However a general book about the Leadwerks Game Engine and how to make games with it, I would actually buy I guess :)

    Anyways good luck with it and 

    Best Regards from Phodex :)

    Edit:

    Because you most likely will insert this into google translator I did this for you here is the google translated spanish translation xD

    Quote

    La manera más fácil y mejor para usted sería ir para E-Books, pero en el consejo dudo que esto sería un éxito ^^. Me refiero a Leadwerks es cool, pero definitivamente no es un motor mainstream, incluso más, supongo que el porcentaje de personas que utilizan Leadwerks y son español es muy bajo. Sin embargo un libro general sobre el motor del juego de Leadwerks y cómo hacer juegos con él, yo compraría realmente adivino

    De todos modos buena suerte con ella y

    Saludos cordiales de Phodex

    Editar:

    Porque lo más probable es insertar esto en google traductor hice esto para usted aquí es el google traducido español traducción xD

     

  9. Maybe this helps? debug.sethook should work, but in the offical API you just find this and that. Just tried that, debug.sethook, what you find in the offical LUA API also works in Leadwerks. But I dont know how to use the "AddHook" function. You seem to need any kind of keyword in addition. However Leadwerks does not seem to recognice "AddHook" as a keyword. But I think debug.sethook should do the job.

    • Upvote 1
  10. Hi :)

    Simple question, I cannot find a GetAnimation and GetAnimationFrame function in the API. I realised those functions in my own AnimationManager script manually, but since there is the "new" entity:PlayAnimation function how to get access to this functions? Any ideas or suggestion?

    EDIT: Would also be good to know how to get animation index by name and the other way around. Something like: self.entity:GetAnimationName(0) or self.entity:GetAnimationIndex("Idle"))

    • Upvote 1
  11. Okey after playing around a bit and deleting all animations & armature it worked. Could you tell me how you deleted those animations? I always struggle a bit when deleting animations in blender I dont really know how to do it ^^. Still I dont really know what the animations have to do with that distorted rotation, isnt this a thing which should not be? Well what ever, thank you a lit for you help and time. At least I know now where the mistake was :)

  12. 1 hour ago, Genebris said:

    Use Leadwerks exporter.

    If it just would be that easy... I tried the exporter of course, but with it, I cannot export the models seperatly somehow. If I select the sword and export with "Export only selected objects" ticked, Blender says "Couln't find any exportable objects." :(

    Just tried again. The exporter works even worse. Look what happens after export inside blender

     

    BEFORE:

    :5972637bd5ccf_BeforeExporter.PNG.2d6e346b106ed126f89be1e31eb23d59.PNG:

    AFTER USE OF EXPORTER:

    59726389ea556_AfterExporter.PNG.bbb92a52ba66037a6b00c162ec770f6b.PNG

    And no the model doesn't appear like in the first picture, nor does it like in the second picture, after I imported it into Leadwerks.

    Really annoying if you try to make some precise first person animations!

     

  13. Hi,

    I have this annoying problem for pretty a while. I currently was trying to figure out the error, but I am no master at Blender so maybe its my mistake, maybe you have to take care on something in Leadwerks?

    Look thats the problem:

    1.  That is how I set it up in Blender:

    Blender.PNG.3de43af8d4318128c0509029a0ede15f.PNG

    2. Now I export the hands model and the sword model (in the fbx model format) seperatly and import them into Leadwerks. After I put them into the engine, adjust their scale and zero their position and rotation it looks like this:

    Leadwerks.PNG.38e566e26b7155d3171a05d483b4200a.PNG

    And yes I did apply the rotation, location and scale in blender. Why the heck doen't this work? I get some trouble with my animations with that, because I put the sword to an bone handling the weapon position within the animation. There is this "Forward" and "Up" setting when exporting the fbx, maybe you need to take care on that? I dont know, I would be very very glad if you could help me because that makes me freak out :o

    NOTE: I adjusted the scale of the sword, because it had completely diffrent dimensions, like 100 times bigger, thats why it looks diffrent scale wise. However the biggest problem is that its rotation is wrong.

  14. 59 minutes ago, macklebee said:

    Hard to tell exactly if the same issue since no code was provided but it may be an antialiasing issue - if so, not quite sure why Josh has not reverted this back yet. Just set your font's style to Font.Smooth when loading.

    https://www.leadwerks.com/learn?page=API-Reference_Object_Asset_Font_Load

    Okey just did this and it kind of is part of the fix, it also seems to be important, if you render the text to keep the following order:

    1. Set context blend mode

    2. Set context font

    3. Set color

    4. Draw text

     

    EDIT: Ok still found an issue :( it seems to depend on the font size:

    Font size 12:

    Issue1.PNG.8429b4387c5c088368971fb58ad21347.PNG

    Font size 20:

    Issue3.PNG.27885a8797840b5eded5951e4212c510.PNG

    Font size 50:

    Issue2.PNG.94d4fde608fe0dafc8b01ac4e2a28dc9.PNG

    The code where it gets drawn is:

    --I use an renderer class, which renderes all my objects in on script, to handle render priority:
    --current stands for the current rendering object
    context:SetBlendMode(current.blend)
    if current.font ~= nil then context:SetFont(current.font) end
    context:SetColor(current.color)
    context:DrawText(current.text, current.pos.x, current.pos.y)

     

     

  15. Hi I have a small problem. I think the pictures should explain it pretty good :)

    With font size of 12 see the terrible cut on the top?:

    RenderIssue.PNG.4061fccb40bc4574ec78e1991b9091f8.PNG

    With font size 20 it is a little bit better but somehow not as sharp as it should be;

    RenderIssue2.PNG.e254ca9fc470377c0ecf8246e7a2d0d0.PNG

    This is how I would expect it to look like:

    HowItShouldBE.thumb.PNG.cbdcc17adefb864a1540b14bd76626c8.PNG

    I am rendering the text with the default arial.ttf font, I render the following color Vec4(0, 0, 0, 255) and with blendmode Blend.Alpha. So whats the problem? I remember the text rendered sharper another time, but I dont know what I am doing wrong atm? Any suggestions?

     

     

  16. Hi Jorn, how to check if the entity is initiated?

    In my case the player gets spawned and then the player "spawns" another entity which then gets loaded by the players loadfunction. By the way the object the player spawns is an prefab. However I worked around the problem by changing the whole spawning process. However the problem still remains. I often have trouble with prefabs the Start function and script variables. Just wanted to gather some experiences etc.

  17. Hi,

    I pretty often encounter the followning problem: I need something to be called before, or after the Start function of an script.

    My actual problem is that I have an NPC and his "Load" function (I wrote by myself) is called before the script actually is initiated. The problem is, in the load function some values are set (like npc health) but then the script gets initiated and the script uses the default script value of 100% health and the loading does not work. A workaround I found is to use the first step of the update function but I find this not very smart. Here an example:

    function Script:UpdateWorld()
    	if self.doOnce ~= true then 
        	--do something here
        	self.doOnce = true
        end
    end

    Any ideas how to solve this more elegant? Would be really glad if we could gather some ideas :)

    Markus

  18. I did some debugging etc and kind of fixed the Problem better said worked around it like the following:

    --DOES NOT WORK:
    self.firstSlotOffset.x = self.firstSlotOffset.x * context:GetWidth()
    self.firstSlotOffset.y = self.firstSlotOffset.y * context:GetHeight()
    
    --WORKS:
    self.test = nil
    self.test = self.firstSlotOffset.x * context:GetWidth()
    self.test = self.firstSlotOffset.y * context:GetHeight()

    So I think you see the problem. Still I dont understand what the problem actually is. I encountered the same kind of problem for some other scripts as well. Would be glad if somebody could explain this.

    P.S.: Currently have no working internet at home so it can take a while until I reply

×
×
  • Create New...