Jump to content

Megalocerous

Developers
  • Posts

    23
  • Joined

  • Last visited

Posts posted by Megalocerous

  1. I think I fixed this by re-writing my player script differently and then using 2 different triggers. One that triggers the wind, one that disables it. Now when the player enters the "wind zone" they will be fighting against the force constantly and if they get pushed out of the zone they will stop having the force applied.

     

    Script.playerSpeed = 10.0 --float "Player Speed"
    Script.windForce = 20.0 --float "Wind Force"
    Script.windVector = Vec3(0,0,-1) --vec3 "Wind Vector"
    
    local isWindActivated = false
    
    function Script:Start()
    	
    	self.world = World:GetCurrent()
    	self.isAlive = true
    	-- Create camera
    	self.camera = Camera:Create()
    --	self.camera:SetFOV(90)
    	self.camera:SetProjectionMode(Camera.Orthographic)
    	self.camera:SetZoom(50)
    	--load the font
    	self.font = Font:Load("Fonts/Ranchers-Regular.ttf",48)
    	--update the camera
    	self:UpdateCamera()
    end
    
    
    
    function Script:UpdateWorld()
    	
    	self:UpdateCamera()
    	
    end
    
    
    
    function Script:UpdatePhysics()
    	
    	self:MovementInput()
    end
    
    
    
    function Script:UpdateCamera()
    	self.camera:SetRotation(45, -35, 0)
    	self.camera:SetPosition(self.entity:GetPosition().x, self.entity:GetPosition().y, self.entity:GetPosition().z)
    	self.camera:Move(0, 0, -30)
    	
    end
    
    function Script:MovementInput()
    	local moveVector = Vec3()
    	local window = Window:GetCurrent()
    	
    	if window:KeyDown(Key.W) then moveVector.z = 1 end
    	if window:KeyDown(Key.S) then moveVector.z = -1 end
    	if window:KeyDown(Key.A) then moveVector.x = -1 end
    	if window:KeyDown(Key.D) then moveVector.x = 1 end
    	
    	local normalizedVector = moveVector:Normalize() * self.playerSpeed
    	local vectorWithWind = (moveVector:Normalize() * self.playerSpeed) + (self.windVector * self.windForce)
    	
    	if isWindActivated then
    		self.entity:AddForce(vectorWithWind)
    	else
    		self.entity:AddForce(normalizedVector)
    	end
    end
    
    
    function Script:EnableWind()--in
    
    	isWindActivated = true
    end
    
    
    function Script:Disable()--in
    
    	isWindActivated = false
    end

     

    • Like 1
  2. On 6/23/2020 at 4:40 PM, JMK said:

    I was curious and took a look at the flowgraph. That is some pretty complex logic at first glance. If I was designing this I would probably just do something like this in the windzone script:

    
    function Script:Collision(entity, position, normal, speed)
    	entity:AddForce(self.force)
    end

     

    Just to follow up on this -

    This seems to work better in 4.5 then in 4.6.

    4.6 seems to keep calling entity:AddForce() even after exiting the trigger zone, which I am guessing is not supposed to happen?

  3. Yeah I apologize I was working on it late last night and its possible that I over complicated it.

    That is similar to how the bounce block or bounce zone works, which is good on the initial collision. But for this I am thinking design wise that it will be a constant force added while you are inside the zone, but removing the force when you are outside of it.

    Just adding the force on collision like this doesn't check on exit and keeps applying it no? At least that is what seems to happen when I write it like that. 

  4. First off - hello! It has been a while since I've used Leadwerks, but I have decided to install it again and actively use it.

    I figured the best way to remember how to use the engine would be to re-create my Beach Roll entry submitted for one of the summer jams a few years back, but make it less bad and add a lot of fun level design obstacles/features, updated camera view, actual game menu etc.

    So for most of this I have been creating scripts in lua and making them usable in flowgraph. This way I can just script what the object should do, then I can just wire it up in the level as its needed.

    The current issue I have is with creating a "Wind Zone" trigger script. Basically when the player rolls into the trigger, it should add force in a given direction based on the scripts force vector property. Then when the player leaves the trigger it should stop applying the force. I used the collision-enter-exit script from the wikidot to achieve this. The only problem is that when I move into the first zone, it applies the correct force, the second zone works properly, the third zone does...but then if I move back into any of the previous zones it will still apply the last zones force. Upon re-entering the same zone (after it applied the incorrect force the first time) it applies the right force.

    I'm sure it is either a logic issue or the way I am handling the variable for it, but I've attached a test project with a map and everything wired up in case anyone wanted to take a look.

     

    Thanks!

     

     

    WindZoneTest.zip

  5. Hey guys,

     

    Not sure if anyone can help me out. I have a weird issue right now where the running animation for the character I am using does not play when I am running to the right. However the idle animation seems to run no matter which direction I am facing.

     

     

    Script.movespeed = 5 --float
    Script.cameradistance = 40 --float
    Script.camerazoom = 8 --float
    Script.orthographicseffect = 1 --float "Flatness"
    Script.camerarange = 10 --float
    Script.jump = 15 --int
    Script.ismoving = false --bool
    Script.isjumping = false --bool
    
    --Animation variables
    Script.animationspeed = 1.0 --float
    Script.idlesequence = 0 --int
    Script.runsequence = 0 --int
    Script.jumpsequence = 0 --int
    function Script:Start()
    self.playerangle = -90.0
    self.camera = Camera:Create()
    self.entity:SetPhysicsMode(Entity.CharacterPhysics)
    self.camera:SetRotation(0,0,0)
    self.camera:SetZoom(self.camerazoom*self.orthographicseffect)
    self.camera:SetRange(self.cameradistance*self.orthographicseffect-self.camerarange, self.cameradistance*self.orthographicseffect+self.camerarange)
    
    
    if self.entity:GetMass() == 0 then self.entity:SetMass(10) end
    
    end
    
    function Script:UpdateWorld()
    --Update the camera
    self.camera:SetPosition(self.entity:GetPosition())
    self.camera:Move(0,1.8/2,-self.cameradistance*self.orthographicseffect)
    
    
    end
    
    function Script:UpdatePhysics()
    
    local window = Window:GetCurrent()
    local move = 0
    local jump = 0
    
    --Set the players direction if they move left or right
    if window:KeyDown(Key.D) then
    
    self.playerangle = -90.0
    self.ismoving = true
    move = move - self.movespeed
    
    else
    self.ismoving = false
    end
    
    if window:KeyDown(Key.A) then
    
    self.playerangle = 90.0
    self.ismoving = true
    move = move - self.movespeed
    
    
    else
    self.ismoving = false
    end
    
    
    --Set the players jump if space is hit
    if window:KeyHit(Key.Space) then
    
    jump = self.jump
    
    end
    self.entity:SetInput(self.playerangle,move,0,jump,false,1.0,1.0,true)
    end
    
    function Script:Draw()
    local t = Time:GetCurrent()
    if self.ismoving == true then
    self.entity:SetAnimationFrame(t/100.0*self.animationspeed,1,self.runsequence)
    elseif self.ismoving == false then
    self.entity:SetAnimationFrame(t/100.0*self.animationspeed,1,self.idlesequence)
    end
    
    end
    

  6. Easiest thing to do after finishing one of the Leadwerks tutorials (in my opinion anyway) is to take the template that you have just completed, and try to make small additions. This is part of what I am working on for the Summer Games Tournament, it is simple but it is helping me really get my feet wet with the engine.

     

    Now that you have the marble game template, what other small gameplay elements could you create that would enhance the game? (Moving platform, jump etc...) Then design new levels around the new mechanic.

  7. I was not using the FPS prefab Thirsty, but for the time being I think I figured it out. I am using Window:SetLayout to change the window that is created from the editor to what I want. I am still not sure if this is the correct solution but I will try it again with Window:Create later.

     

    Whenever I use Window:Create it doesn't seem to render the world that I have created in the editor. So I believe somewhere I am missing something really dumb on my end (wouldn't be the first or the last time biggrin.png )

  8. Initially I just had the camera added in my scene, then used Window:Create but I don't believe that worked. Then I deleted the camera from the scene and used Window:Create and created a camera via code, but now I had two completely black windows. I am assuming I need to also create a light in my code now since it is not using the light that I added through the editor itself?

     

    Sorry if I am not making any sense, but I really appreciate all your help thus far cassius!

  9. Yeah I have something similar in lua, it just shows a black screen. If I am calling Window:Create I am guessing I need to create the light through code as well right? Right now I have one in the editor but it does not seem like it is applying that to the Window:Create scene.

     

    Unfortunately I can't test right now. I'm at my soul destroying full time job biggrin.png

  10. Thanks cassius! I will mess with it more later tonight. Last night I had the window drawn through Window:Create but it wasn't showing anything other than a black screen. I'm obviously doing something wrong so I will keep plugging away until it's fixed.

     

    Thanks again!

  11. Hello everyone! I am new here and come from using Unity and UDK previously. I purchased this engine quite some time ago but never got far with it. However I have returned to give it another shot over the last few weeks and have really been enjoying it. I am hoping to have a simple game submitted for the Summer Games tournament and then roll into my next project from there.

     

    Now that my brief introduction is over...

     

    I just had a quick question in regards to creating a window. It seems that if I am not using windows create and I test my level I only have one window created. Using Window:Create will create two windows, one in the background and the one that I have created. Is there anyway to have just one window created? Is this just something that happens when using the editor? If I compile it to an exe will it just be the one window?

     

    Sorry if this was answered somewhere already, I've been messing around with it for the last couple of days and figured it was time to log on and ask.

     

    Thanks in advance!

×
×
  • Create New...