Jump to content

TemplarAsh

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by TemplarAsh

  1. Hi there, back after a few months break, could someone give me lua advice of how to detect double tap in a character controller script. I am using ActionMap if that's relevant.

     

    Thank you in advance :)

     

    ~Ash

  2. Hi Guys,

     

    I have the auto-save setting disabled, however is there a way to prevent LE from autosaving your scripts inside the script editor when you run the game? This really sucks when you are trying to add things and you have code issues and creates all kinds of headaches when you are a newb.

     

    It would be nice to be able test run inside the script editor without the ninja auto-save.

     

    Perhaps this is not possible as the scrips must be saved before the engine can run them, but I thought I'd ask.

     

    ~Ash

  3. Hi Guys,

     

    I finally got it working, using +/- degrees off of the camerarotation.y. System:Print() was very helpful here finding the correct variable then added the appropriate degrees based on direction.

     

    --Movement

    --Code for detecting key hits for movement and attacks

     

    local targetRotation = self.currentyrotation

     

    if ActionMap:IsDown(ActionMap.block) then self.currentState = self.state.block end

     

    if ActionMap:IsDown(ActionMap.right) then

    movement.x=movement.x+1

    targetRotation = camerarotation.y-90

    changed=true end

     

    if ActionMap:IsDown(ActionMap.left) then

    movement.x=movement.x-1

    targetRotation = camerarotation.y+90

    changed=true end

     

    if ActionMap:IsDown(ActionMap.forward) then

    movement.z=movement.z+1

    --if ActionMap:IsDown(ActionMap.freelook) then return end

    targetRotation = camerarotation.y+180

    changed=true end

     

    if ActionMap:IsDown(ActionMap.back) then

    movement.z=movement.z-1

    targetRotation = camerarotation.y

    changed=true end

     

    if ActionMap:IsDown(ActionMap.right) and ActionMap:IsDown(ActionMap.back) then

    targetRotation = camerarotation.y-45

    changed=true end

     

    if ActionMap:IsDown(ActionMap.left) and ActionMap:IsDown(ActionMap.back) then

    targetRotation = camerarotation.y+45

    changed=true end

     

    if ActionMap:IsDown(ActionMap.forward) and ActionMap:IsDown(ActionMap.right) then

    targetRotation = camerarotation.y-135

    changed=true end

     

    if ActionMap:IsDown(ActionMap.forward) and ActionMap:IsDown(ActionMap.left) then

    targetRotation = camerarotation.y+135

    changed=true end

     

    This is what changes the character direction...

     

    --Rotate model to face correct direction

    if (changed) then

    movement = movement:Normalize()

    self.currentyrotation = Math:IncAngle(targetRotation,self.currentyrotation,self.turnSpeed)--first two parameters were swapped

    end

     

    movement and targetRotation are local variables on the Character controller, camerarotation.y is a global variable at this point, since I moved the camera script off of the controller and attached it to the camera. I am sure there is a better way, even moving this back to the Character controller, but at least this gives you an idea on what to think about and work through. Took me a few days to understand this.

  4. Hi guys,

     

    I need some suggestions on how to get a 3rd person controller's movement that is based on camera direction so the WASD moves the player according to the direction the camera is looking.

     

    I have spent hours with every 3rd person script I can find, local and global space settings and I cannot get this to work correctly. The other thing to mention is I do not want to strafe left and right, but rotate and move the character in that direction. I am using a modified version of the barbarian player controller from Darkness Awaits, but it runs like its always in global space, or just hard coded w&s z+- with a&d x+- which then it does not work correctly when the camera changes rotation.

     

    I have moved the camera rotation off of the 3rd party controller and attached it to a script on the camera then parented back to the controller while leaving the movement controls on the character controller. Not sure if that matters, but it seems to make more sense having them separated with this goal in mind.

     

    Do I need to get the Y rotation of the camera then base the wasd movement off of this, +- 90 degrees and -180, or do I just not understand how to set local space movement either on the controller or the camera, and which would it apply to?

     

    Any guidance is appreciated.

     

    ~Ash

  5. Hi Beo,

     

    I checked and I had the listener on my character controller, but not the camera, so I moved it over to the camera and it does the exact same thing.

     

    Should the listener be on the camera instead of the character controller, does it matter, as both seem to work? We only need 1 listener right?

     

    I am currently working on a new 3rd person character controller and actually moved the camera code off the character controller and instead attached it to the camera which parents back to the controller, which works but is having its own set of challenges of local vs. global space movement with camera rotation, fun times.

     

    I also noticed in testing my autopistol disappears when published but works inside the editor.

     

    This is really weird.

     

    Still digging...

     

    So the autopistol issue was resolved by using the Leadwerks beta version, not the regular 3.3. It appears the sound emitter issue maybe caused by not moving with my character controller. Still working on this but that is what it appears to be doing. More to come smile.png

     

    OK so I did fix this. The beta update seemed to help with my simple test map, however I also changed the listener code to this...

     

    --Create listener

    self.listener = Listener:Create(self.camera)

     

    Thank you for the help.

     

    ~Ash

  6. Hi guys,

     

    I need some help with sound emitters.

     

    I am using this script attached to a pivot next to a wall, with volume tested at 1 and 100. The sound will play inside the editor but when published it will not play. Tried all kinds of things, new map, generic app.lua, stereo vs mono .wav, stock ambient .wavs, I even took the IF statement out of start and I still cannot figure it out.

     

    Thank you for the help.

     

    ~Ash

     

    --require "Scripts/Functions/ReleaseTableObjects.lua"

     

    Script.soundfile=""--path "Ambient Sound"

    Script.range=20.0--float "Range"

    Script.volume=1--float "Volume"

    Script.pitch=1--float "Pitch"

    Script.loop=true--bool "Loop"

     

    function Script:Start()

    if self.sound~="" then

    self.sound = Sound:Load(self.soundfile)

    self.entity:EmitSound(self.sound, self.range, self.volume, self.pitch, self.loop);

    end

    end

     

    function Script:Stop()

    end

     

    function Script:Cleanup()

    end

  7. Sound is very important!

     

    I added some vertical sound triggers and it works ok, for now.

     

    When the player collides into it it changes a flooring variable to a type: stone, grass, etc.

     

    Then used some if statements inside my character controller to check that variable and then play the appropriate material footstep sound, all using the same code (for n=1,4 do) for footstep looping.

     

    So not really attached to the ground but the player won't know.

     

    ~Ash

    • Upvote 2
  8. Hi Guys,

     

    I have the Steam Indie version of Leadwerks, I was reading this tutorial:

     

    http://www.leadwerks.com/werkspace/blog/52/entry-890-lets-make-a-game-procedual-content-creation-part-03/

     

    but right away I noticed Flexman requires some default scripts that I cannot find.

     

    "Scripts/constants/collision_const"

    "Scripts/constants/engine_const"

    "Scripts/constants/keycodes"

     

    The only folders I have inside scripts are...

     

    Functions, Math and Objects, which do not contain them.

     

    I think he said he was using the SDK 2.5, is this the normal version with C+ and are these lua scripts not supposed to be included with the steam indie version?

     

    Can they be downloaded from the werkspace? Or would we have to make these from scratch?

     

    Kind of confusing...

     

    Any help is appreciated smile.png

     

    ~Ash

  9. Hi Josh,

     

    I found out what was causing this issue, let me add some additional info.

     

    I tried to install the latest paint.net, i kept getting an error...NSIS error writing temporary file. Make sure temp folder is valid. I tried all of the recommendations regarding the temp folder, permissions, path, etc., but none of that was an issue.

     

    Some installers have this issue and others do not. This was happening because UAC was turned all the way to the bottom setting in control panel>user accounts>change user account control settings.

     

    I tried the default on setting and the one just underneath that, both worked. I changed it back to the bottom setting and both programs stopped working again with the same write errors.

     

    So it appears to be related to security permissions for certain installers and UAC being set to the bottom option.

     

    I will test this on a 2nd pc and see what happens, unless someone beats me to it smile.png

     

    ~Ash

  10. Hi Josh,

     

    I checked file permissions, ran the .exe as administrator, compatibility mode, never prompt UAC, did several malware scans, a chkdsk on my primary drive, uninstalled my antivirus which was just microsoft security essentials, none of that helped.

     

    I did find something interesting however...

     

    If i move the game folder to my 1Tb data drive which is a SATA drive, it will run. My primary drive is SSD, a Samsung 840 Evo 43.7/250Gb free.

     

    I will keep looking...hope this drive is not having issues.

     

    ***everyone back up your stuff!!!*** biggrin.png

     

    ~Ash

     

    One other thing to mention...

     

    My original project's .exe from a few months ago runs just fine still, but anything new coming out of the publisher is having an issue.

     

    ~Ash

  11. Hi Guys,

     

    I keep getting an fwrite error 13 when trying to run the game.exe after publishing. I was unsure if updating my files messed something up with the map so I completely deleted Leadwerks and reinstalled it. Then I created a new game with just a floor, lights and camera, tried to publish again and getting the same error.

     

    Both the original map and this new basic test map runs inside Leadwerks, I just get this error after publishing and trying to launch the game via it's .exe.

     

    This used to work just fine, not sure what broke. I tried both encryption and without encryption during publishing to no avail.

     

    Thanks for any help!

     

    ~Ash

  12. Hi All,

     

    Loaded up my test map tonight and am experiencing an incredible FPS drop/Lag. Used it last night without issues, I noticed that under the Output tab on the Script Editor that this is spamming constantly...

     

     

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

    Hooking GetOpen/SaveFilename

    Hooking CoCreateInstance[Ex]

     

    Was it always doing this and I just did not notice, or some kind of bad update?

     

    I uninstalled and reinstalled leadwerks and it does it on the stock maps. I created a new project and loaded the Darkness Awaits project and it lags badly now and is spamming these same messages.

     

    Is this normal and something else has happened? Hope my computer is not dying :)

     

    Thanks,

     

    ~Ash

  13. I am a noob but should the collision type be 1 on levelmodel? I would think it should be set to scene so it applies physics to other objects and does not get affected. Using numbers would scene be 2? Also, does it need a mass of 1000, my scene objects have 0 mass?

     

    Just a guess smile.png First thing that came to mind. I tried to test run the code but it was just a black screen for me.

  14. Aggror has a tutorial on youtube for a rotator.lua file that may work for you, here is the code...

     

    angleCounter = 0

     

    function Script:UpdateWorld()

    --increase angle counter

    angleCounter = angleCounter + (1*Time:GetSpeed())

     

    --apply rotation

    self.entity:SetRotation(0,0,angleCounter)

     

    --Check to see if we made a full circle

    if angleCounter > 360 then

    self.component:CallOutputs("Done rotating")

    angleCounter = 0

    end

    end

     

    Save it as rotator.lua then attach it to the object in the script tab.

     

    Hope this is helpful.

     

    ~Ash

  15. Success, I figured it out. I am not certain if this is the best way to do this but it works...

     

    In the barbarian.lua

     

    myVal = 100 --defined at top to keep it from being nil

     

    module("a", package.seeall)

     

    function GetSomeValue()

    return myVal

    end

     

    if self.health>0 then

    self.health = self.health - damage

    myVal = self.health

     

    Inside the Goblin.lua...

     

    require "a"

    if (a.GetSomeValue()) <= 0 then return end

     

    which skips the attack chunk

     

    ***Edit: This worked better

     

    require "a"

    if (a.GetSomeValue()) <= 0 then self.currentState=self.state.idle end

     

    ~Ash

×
×
  • Create New...