Jump to content

tipforeveryone

Members
  • Posts

    382
  • Joined

  • Last visited

Posts posted by tipforeveryone

  1. @Aggror: Yes this will solve the problem of window:KeyHit but affect window:KeyDown too, I use ASWD for character movement and they are flushed too, make my character unmovable. So that I think it is not good to put window:Keyflush() anywhere.

    Is there any way to flush only one key ?

     

    @Rick

    I avoid the Hit functions generally and use the Down functions with my own Boolean for that specific case instead. The Hit functions have a few "quarks" that I don't like and often burn me.

    I have a same thinking now sad.png I may combine window:KeyDown with some bool variable

     

    @SGB: I want a key to execute an unique function only in specified condition(this case is player is inside a room), when player is outside the room, that key will do another task when hit.

     

    Ex:

    Press H in room 1 ~> display "Rick"

    Press H in room 2 ~> display "Josh"

    Press H in room 3 ~> display "SGB"

    etc...

     

    one key can execute diffirent tasks in a specified condition, so that I need to put window:KeyHit under an if statement

    If I put if statement inside if window:KeyHit(). It does not work

     

    this code does not work

    if window:KeyHit(Key.H) then
    if self.room == "Room1" then ... end
    if self.room == "Room2" then ... end
    if self.room == "Room3" then ... end
    end

     

    this does but if I use this, I will have problem which I describe in the first entry of this topic

    if self.room == "Room1" then
    if window:KeyHit(Key.H) then *dosomething* end
    end
    if self.room == "Room2" then
    if window:KeyHit(Key.H) then *dosomething* end
    end
    if self.room == "Room3" then
    if window:KeyHit(Key.H) then *dosomething* end
    end

  2. I would put it in the main.lua loop and not in an entity script. Somewhere at the end of the loop so you know that all updateworld and updatephysics already have taken place.

     

    Same resuit :D I put window:FlushKeys() at the bottom of loop and still can't move. You should give it a try, please

  3. Sound like your keys are stored untill usage. You probably just have to use flush keys:

    http://www.leadwerks.com/werkspace/page/api-reference/_/window/windowflushkeys-r903

     

    I thought about this function once, but I wonder will it flush every keyboard interaction, include KeyDown if I put this in UpdateWorld ?

     

    ....

    Oh I have tried FlushKeys(), put it in UpdateWorld() then I can not use my AWSD key anymore :"D

     

    can you suggest me how to use this to solve my KeyHit problem ?

  4. Today I found a strange problem with window:KeyHit

    I put this code inside an if statement

     

    if self.player_Inside_Room == true then
    if window:KeyHit(Key.H) then
    System:Print("Yay!")
    end
    end

     

    I create a CSG box with collision type = Trigger, it will set self.player_Inside_Room = true when player collides, after that, I can press H to display "Yay!"

     

    Strange thing is: I press and release H before entering the trigger but when I enter that box, the debug console displays "Yay!". It doesn't matter how long I have pressed H key before

     

    How can I solve this? I just want to execute something only when I get inside the trigger and hit a key

  5. Features

     

    - Record camera path movement by controlling camera itself, what you see is what you get
    wink.png

    - Path information can be saved to sperated file for later use

    - Attach saved path file to any entity to playback recorded path

    - Camera movement can be adjusted for smooth and better path record

    - Great for cut scene or object with motion.

     

    Demo

     

    What I did in this demo:

    - Record the first path and save it to path1.lua

    - Record the second path and save it to path2.lua

    - Create a small box then attach each of saved path files

    - Attach path1.lua to Pivot, attach path2.lua to box, watch their combination

     

    How to use

    - Download and extract 2 lua files to anywhere in your project folder, example: Scripts/Recorder

    - Create a Pivot in your map then attach
    PlayerControl-PrototypeB.lua
    to it

    - Create a lua file then choose it as" Record File" in Script tab of the pivot (
    This is required!
    )

    - Run the game

    - Press
    R
    to start/stop record

    - Press
    P
    to playback recorded path

    - Press
    Esc
    to exit

    - Create an entity, ex: a box. Attach
    ObjectPathMovement.lua
    to it

    - Choose saved record file (
    This is required!
    )

    - Run the game

    - Press
    J
    to start playback recorded path for the entity

     

    Other attributes explaination

    PlayerControl-PrototypeB.lua

     

    -
    Playback Start:
    Execute playback process right after the game start, using data from choosen record file

    -
    Clean Screen:
    Hide all HUD elements while playback

    -
    Both Playback Start and Clean Screen are good for cutscene camera

    -
    Focus Object:
    Drag any entity which you want camera to point at while moving, this will ignore recorded rotation of camera.

     

    ObjectPathMovement.lua

     

    -
    Play Rotation
    : if this is false, entity will ignore recorded rotation

    ObjectPathMovement.lua

    PlayerControl-PrototypeB.lua

    • Upvote 9
  6. This does not work smile.png

     

    I try

    function Script:Collision(entity,position,normal,speed)
    if entity:GetKeyValue("name") == "PlayerControl" then
    System:Print("hit")
    else
    System:Print("no hit")
    end
    end

     

    Then there is no "no hit" in output when player is outside of trigger box, of course it will display "hit" when player step inside the box. I want to do something when player step out or out side triggerbox.

  7. I can use a box with Collision Type = Trigger to detect player

     

    function Script:Collision(entity,position,normal,speed)
    self.playerInside = true
    end

     

    But I can't figure out how to execute when player NOT collides this box

     

    something likes

     

    function Script:Collision(entity,position,normal,speed)
    if entity == player then
    self.playerInside = true
    else
    self.playerInside = false --how can I do this :"D
    end
    end

  8. 1. Write cutscene script (all stuff like: How all entities are placed, which shoud be moved first etc..)

    2. Create the scene (using leadwerks brush or 3d program like blender)

    3. Prepare character animation

    4. Write code for camera movement / position / time

    5. Combine all of them

    • Upvote 1
  9. Another script for flicker light

     

    Script.flicker = true --bool "Flicker enabled"
    Script.flickerRate = 0.5 --float "Flicker Rate"
    -- Value range should be from 0 to 1
    -- near 0 ~> light is off most of time
    -- near 1 ~> light is on most of time
    
    function Script:FlickerControl()
       if self.flicker then
           local rand = Math:Random(0,1)
           if rand < self.flickerRate then
               self:entity:Show()
           else
               self.entity:Hide()
           end
       end
    end

  10. You could put a tall rectangle or cylinder around it with the invisible material and make it a prefab.

     

    Thanks for your reply.

    I thought about this solution before but it does not fit my need biggrin.png

    I need to keep physic mesh of my object for specified purpose, this is my example, it is silly but can demontrate what I need hehe

     

    I have a toilet, I want bulletshells which were ejected from my gun can physical interact to it,

    I dont want to step on the toilet each time I get too close, decrease climbstep of character controler is the best solution (it is sad to know that it can not be changed)

     

    If I use an invisible box to block my movement, bulletshells can not interact to toilet

    post-16833-0-38428100-1474618222_thumb.png

×
×
  • Create New...