Jump to content

Stona Persona

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Stona Persona

  1. CamOffset = -5 CamRot = 0 CamHeight = 2 function Script:Start() PlayerCamera = Camera:Create() end function Script:UpdateWorld() PlayerCamera:SetPosition(self.entity:GetPosition().x, self.entity:GetPosition().y + CamHeight, self.entity:GetPosition().z + CamOffset) local window = Window:GetCurrent() local context = Context:GetCurrent() window:SetMousePosition(context:GetWidth()/2, context:GetHeight()/2) mx = context:GetWidth()/2 my = context:GetHeight()/2 CurrMPos = window:GetMousePosition() mxdiff = Math:Clamp(CurrMPos.x - mx,-45,45) PlAngle = Math:CurveAngle(self.entity:GetRotation().y + mxdiff, self.entity:GetRotation().y , Time:GetSpeed()) local move = 0 local strafe = 0 self.entity:SetInput(PlAngle, move, strafe) end Hello guys, so, i have this above code where im trying to get an entity to rotate around its Y-axis when i move the mouse from side to side. It kinda works but the rotation is not smooth and the entity just jumps to rotation values instead of rotating to them smoothly. What am i doing wrong there? Thanks in advance for your time.
  2. Thanks for the quick answer, i think i try it out like this. Im using LUA btw, should ve mentioned in first post. Since i use the player to cast a ray out in the world to detect stuff, so i dont plan to use a crosshair i think i wont need the Camera:UnProject but just get the position of the enemy from the pick. The thing is im trying to figure stuff out for so long now i kinda got tired of trying stuff that doesnt work out in the end, so im very thankful for your information. I think ill try to use the pick i already have when aiming and shooting to make it lock onto the picked enemy.
  3. Greetings fellas, im currently trying to figure out how to build a player system like in the PS1 era survival horror games like Resident Evil for example. So far i got static cameras to switch, tank controls and a very basic shooting mechanic (hold down R mouse and press L mouse to shoot). But now im kinda stuck at how to approach a system that lets my player lock onto an enemy when aiming. Some help with pseudo code would be much appreciated. Would i try to get distances between player and the closest enemy entity or would i use a pick with maybe a bigger radius so you kinda have to roughly aim into the enemies direction and if pick hits the player is locked on? Im still trying to figure the code stuff out, so not a pro coder here.
  4. I have one question tho, sorry if it doesnt fit in here. Will Leadwerks still get some love or being kept alive, since im still fiddling around with it and it wouldnt be money-efficient for me to pay monthly for a tool i wouldnt be using that often. Im still trying to get my head around LW, so i just want to know if its still worth spending the time on it. Thanks in advance. 🙂
  5. Wish you best of luck! Excited to see what you managed to put together after the competition.
  6. Id even be ready to spend 50 bucks for the winner if such contest would happen. Im still a coding noob because i was jumpy af tried this engine, this language and so on but now since i tried em all im stuck with LW and therefore i think its more than worth to push the engine and also the community. So yeah, im ready to cash in to make such contest happen anytime. Cheers.
  7. What i learned from my little experience is that some commands only work inside functions but not outside of them. im getting a lot of these and then i switch some commands around like put them in a function or take something out of it so it isnt in a function and eventually, atleast for now, i ended up getting stuff to work. Maybe it helps you a bit, im a coding noob, so maybe im just talkin BS here, but atleast for me it worked out most of the time, even tho it can be tedious.
  8. Thats a nice thread. I think i can contribute something too. Imo its criminal that this tool is free, but better for the low budget devs. Images to Materials: http://www.boundingboxsoftware.com/materialize/
  9. SetInput instead of Move solved my problems for now, just tried it out. Thanks again.
  10. TYVM, that is actually good to know, since the documentation didnt mention anything like that. Now it all makes sense why stuff is behaving strange af.
  11. Thanks for the reply, but im not at the stage with moving platforms yet, i cant get the "platforms" i already have to stay where they are and still behave like solid objects with collisions for the player. Everything just falls into darkness or stays in place but doesnt collide. I probably could use the terrain and build my levels on that but there must be a way to make the CSG boxes float in air but still be solid with collision and act as a ground themselves.
  12. Hey, thanks for the answer. What i want to achieve are just platforms i could build a level with but with collision for the player and they have to be static, like floating in the "air" so the player could walk on them. I upload a video where i try to show my issue as best as possible. Heres the code for the player Script.CamOffset = Vec3() --vec3 "Camera Offset" Script.PlayerMoveSpeed = 5 --float "Player Movement Speed" --[[Script.isOnFloor = true]] function Script:Start() PlayerPos = self.entity:GetPosition() camera1 = Camera:Create() camera1:SetPosition(PlayerPos.x, PlayerPos.y + self.CamOffset.y ,PlayerPos.z - self.CamOffset.z) end --[[ function Script:UpdateWorld() end ]] --[[ function Script:IsOnFloor() if isOnFloor(true) then self.entity:SetGravityMode(false) elseif isOnFloor(false) then self.entity:SetGravityMode(true) end end ]] function Script:UpdatePhysics() local CamPosUpdate = self.entity:GetPosition() camera1:SetPosition(CamPosUpdate.x, CamPosUpdate.y + self.CamOffset.y, CamPosUpdate.z - self.CamOffset.z) if window:KeyDown(Key.D) then self.entity:Move(self.PlayerMoveSpeed,0,0) elseif window:KeyDown(Key.A) then self.entity:Move(-self.PlayerMoveSpeed,0,0) end --[[if self.entity:GetKeyValue("Collision Type","Prop") then isOnFloor = true else isOnFloor = false end]] end The isOnFloor stuff was just me trying something out. Below is the script i attached to one of the boxes in the video to kinda "keep it in place" every physics update, but that causes more headache tbh. Script.gravitymode = false --bool "Gravity Mode" function Script:Start() if self.gravitymode then self.entity:SetGravityMode(true) else self.entity:SetGravityMode(false) end PosLock = self.entity:GetPosition() RotLock = self.entity:GetRotation() self.entity:SetMass(2) end --[[ function Script:UpdateWorld() end ]] function Script:UpdatePhysics() self.entity:SetPosition(PosLock.x, PosLock.y, PosLock.z) self.entity:SetRotation(RotLock.x, RotLock.y, RotLock.z) end 1609157828_2022-03-3013-31-06.mkv
  13. Hey guys, i just recently started to dig into the Leadwerks coding and so far its getting on with the help of the docs and the forums but now i seem kinda stuck. So, my problem is.. i set up the generic model as the player character and just added a simple CSG block as a platform for testing purposes. My character has a mass of 1, falls from the air and lands on the platform, all cool. But he doesnt fall further down from the platform or collides with any "walls" i placed in for testing. Character is set up as character controller, walls and floors are set up as rigid bodies with collision type scene (tried prop and others also) If i set the mass to every block as lets say 2, then physics start to work, makes sense. But how do i make platforms that are static without falling with the character into the endless abyss. I made a little script to attach to the boxes which disables the gravity for the entity, it stays in place, but the character is still able to "push it" and it starts to jitter and apparently the character slides off the platform and disappears into the shadow realm. Next i told the box to get its initial position at Script:Start and apply it constantly in the Update:Physics function. Ppl more experienced with code will prolly roll on the floor now with cramps in their stomach but yeah. xd Some little help would be very appreciated.
×
×
  • Create New...