-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
I don't know if you mean it this way or not but sometimes your posts come off as you being very rude. I was not aware you didn't upgrade to the new system. I see now from a different post you made that you haven't. If I find time away from my 3rd person entity I'll see if I can't see what's wrong.
-
??, I would first say you are using the old way with multiple lua states. Look at the template.lua in the Scripts dir to see how the new way is structured with the new single lua state.
-
lol, yeah that's what the LinePick should do. Ah, nevermind. My player pivot was "inside" the terrain so it never was really not visible. I had to move the player pivot up slightly. My bad.
-
It did work at one point on the terrain, but after manipulating the terrain it seemed to stop working.
-
My camera is able to rotate below the terrain.
-
I think there is still a bug with this. It was working fine, but then I manipulated the terrain and it stopped working. Mackle, could you test out your code with manipulating the terrain? What I did exactly was create a small mount, then run the game a few times. That works. Then flatten the terrain and try it again to see if the terrain still collides with LinePick.
-
The first way you were doing it was actually creating a global variable named cube. I'm guessing you don't want the cube to be global so making it apart of object would be what you want.
-
nvm, because my SetKey()/GetKey() wasn't correct it screwed other things up.
-
Well here is something interesting. If I remove the SetKey() and GetKey() it works. So what am I doing wrong with those 2 functions that's causing issues? Bah, nevermind I copied from the template and it's working. Man that's a pain that because those 2 methods didn't return a value it totally hosed everything up. ><
-
I place this object into my scene via drop and drag, then run the game script from the editor. I put Notify's inside other entities like lights and when I exit game mode they all call Free() then CreateObject(). So not sure why my entity here isn't. If I go into the script of my entity and save it, it does call Free() then CreateObject(), but not after the game mode is ran then exited back to the editor.
-
The model to this object has the material.abstract::invisible.bmp applied to it. Would that have any effect on it? I wouldn't think so. The lights have the same thing. I'm very confused as to why this barebone object isn't having it's CreateObject() and Free() being called correctly.
-
My custom object doesn't seem to be calling object:Free() and object:CreateObject() correctly and I can't figure out why. I have Notify() inside both CreateObject() and Free(). When I originally add it to the scene I get a "Inside create" message but when I run the game then exit the game you normally would get Free() called followed by CreateObject(), but for this object below neither get called. I must be doing something wrong. require("scripts/class") require("scripts/loop") --- create the class local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) Notify("Inside create") function object:Round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function object:Free(model) Notify("Inside free") end function object:SetKey(key, value) end function object:GetKey(key, value) end function object:Update() end end
-
I agree that they will, but here we were thinking of a generic main loop program, and it's not needed for us to do anything with hooks. We can include the loops file so coders could use them though.
-
I have a target that is disappearing and I can't figure out why. Here is the code to my 3rd person object. The idea behind this is that you place this object where you want the camera to start. You make another object the target of the camera object. When you run the game it then gives mouse controls to rotate around the object you made the target? It would also move along with the target. That all works. The issues I'm having is more in the editor. I'm using 2 pivots. One at the base of the target object and one where the camera entity in the editor should be. This also works at first. When I run the game the first time it all works fine. When I exit the game it then removes the target link for some reason. This is problem number 1. Problem number 2 is after I exit the game mode, the cube I have for debugging reasons for some reason moves slightly away from the camera object. I can't figure out why. Any help would be great. Thanks! require("scripts/class") require("scripts/loop") --- create the class local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Position") group:AddProperty("PosOffset",PROPERTY_VEC3,"","Position Offset" ) end function class:CreateObject(model) local object=self.super:CreateObject(model) object.model = model object.msgOnce = false object.initOnce = false object.leftMouseDown = false object.camRotationX = 0 object.camRotationY = 0 object.mouseX = 0 object.mouseY = 0 object.cameraPivot = CreatePivot() object.playerPivot = CreatePivot() object.cameraPivot:SetParent(object.playerPivot, 1) object.PlayerPositionOffsetX = 0 object.PlayerPositionOffsetY = 0 object.PlayerPositionOffsetZ = 0 -- debugging code object.cameraCube = CreateCube(object.cameraPivot) object.cameraCube:SetScale(Vec3(.25, .25, .25)) object.playerCube = CreateCube(object.playerPivot) object.playerCube:SetScale(Vec3(.25, .25, .25)) function object:Round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function object:Free() object.cameraPivot:Free() object.playerPivot:Free() -- debugging code object.cameraCube:Free() object.playerCube:Free() end function object:SetKey(key, value) --if key == "PosOffset" then -- Notify("Hello") -- local offset=string.Explode(value,",") -- object.PlayerPositionOffsetX = tonumber(offset[1]) -- object.PlayerPositionOffsetY = tonumber(offset[2]) -- object.PlayerPositionOffsetZ = tonumber(offset[3]) --end end function object:GetKey(key, value) end function object:Update() local t = object.model:GetTarget(0) if t ~= nil then if object.initOnce == false then object.initOnce = true --pos.x = pos.x + object.PlayerPositionOffsetX --pos.y = pos.y + object.PlayerPositionOffsetY --pos.z = pos.z + object.PlayerPositionOffsetZ --object.playerPivot:SetPosition(Vec3(pos.x, pos.y, pos.z)) object.playerPivot:SetPosition(EntityPosition(t)) object.cameraPivot:SetPosition(EntityPosition(object.model), 1) end end if GetGlobalString("mode") == "GAME_MODE" then if t == nil then if object.msgOnce == false then msgOnce = true Notify("You must assign a target for the 3rd person camera!") end else if MouseHit(1) == 1 then object.mouseX = MouseX() object.mouseY = MouseY() MoveMouse(GraphicsWidth() / 2, GraphicsHeight() / 2) HideMouse() end if MouseDown(1) == 1 then local mx local my mx = MouseX() - object:Round(GraphicsWidth()/2, 0) my = MouseY() - object:Round(GraphicsHeight()/2, 0) MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2) object.camRotationY = object.camRotationY + mx / 4.0 -- this is left and right object.camRotationX = object.camRotationX - my / 4.0 -- this is up and down if object.camRotationX > 25 then object.camRotationX = 25 end if object.camRotationX < -55 then object.camRotationX = -55 end object.leftMouseDown = true object.playerPivot:SetRotation(Vec3(object.camRotationX, -object.camRotationY, 0), 1) elseif MouseDown(1) ~= 1 and object.leftMouseDown == true then MoveMouse(object.mouseX, object.mouseY) ShowMouse() object.leftMouseDown = false end t:Hide() object.cameraCube:Hide() -- debug object.playerCube:Hide() -- debug if EntityVisible(object.playerPivot, object.cameraPivot) == 0 then local p = LinePick(EntityPosition(object.playerPivot, 1), EntityPosition(object.cameraPivot, 1), 0, 0) if p ~= nil then PositionEntity(object.cameraPivot, Vec3(p.position.x, p.position.y, p.position.z), 1) PointEntity(object.cameraPivot, object.playerPivot, 3, 1, 0) MoveEntity(object.cameraPivot, Vec3(0, 0, .25)) end end object.cameraCube:Show() -- debug object.playerCube:Show() -- debug t:Show() -- the pivot to follow the player around object.playerPivot:SetPosition(t:GetPosition()) object.cameraPivot:Point(object.playerPivot, 3, 1, 0) fw.main.camera:SetMatrix(object.cameraPivot.mat) end end end end
-
Can't find any difference between the 2. This doesn't make any sense, but I guess I'll assume going forward it's all good. *sigh*
-
hmm, I recreated a new scene and now it works. I was using an existing scene the entire time and I wonder if something got corrupt. Maybe I'll compare the 2 sbx files to see if I can see anything wrong.
-
The main difference I can tell is that I'm doing this in an object where you are doing your code inside the main loop lua file. I wouldn't think this would cause any issues but who knows.
-
Because linepick returns a point that is slightly still inside the model. If I just parent the camera itself you see slightly inside the model that came between the 2 points. Because of this I do a MoveEntity() of the pivot slightly forward and then position the camera at the pivot. If I did this directly on the camera you would see it happening and create a strange jerking movement. The reason I need the player pivot is because when you hold the left mouse down it rotates around the player. To do this the pivot does the rotation and not the player character. The pivots are needed to create a smooth professional looking 3rd person camera. They are very necessary. I'll try your code above to see what it's doing and if it's a test.
-
I'm wondering if there is a way to do this. I would need the position of the object I place in the editor. The issue is it takes the 2nd time after I move the object around for it to get inside the create method for me to get it. Would there be a way for me to get the location after the first move of the object in the editor?
-
I just don't think it is (it should). The barrel works just fine. I set the position of the camera to the cameraPivot location. The cameraPivot location is parented to the playerPivot. When I rotate the playerPivot with the mouse the cameraPivot follows, which means the camera follows. I would agree with you if the barrel didn't cause a collision with the ray from playerPivot to cameraPivot but it does.
-
I'm confused to why I would want to do that with the design idea we are talking about? The idea is that the users wouldn't need to do any coding at all. Objects would control everything. These hooks would be more for the coders making the objects for non coders, or even coders who don't want to reinvent something, to use. For example if I was to create a 2D HUD object I would hook into the Flip hook when in game mode and unhook it when in editor mode. The user drags the object onto the scene and it just works.
-
Oh so your using CameraPick to pick the terrain and not LinePick to see if the terrain comes between 2 points. I assume that's different. This did work in older versions of LE because I'm copying the code I used in a C++ program I made. So can anyone verify that the terrain is considered in LinePick?
-
Well the thing is above it never hit the notify. So I did this: local p = LinePick(EntityPosition(object.playerPivot, 1), EntityPosition(object.cameraPivot, 1), 0, 0) if p ~= nil then Notify(p.entity:GetClass()) end This returns 1 for the barrel and it never hits the Notify() at all for the terrain. So LinePick is return a nil for picking the terrain. Do I need to do something with the terrain? It's not painted or anything.
-
Exactly, which is why I'm confused. I have a terrain and made a little mound. I place my character on it and a barrel next to him. The camera is a 3rd person view where I can rotate around my character. When I rotate it down where the terrain covers the player up nothing happens. When I rotate it so the barrel covers the player the camera moves where it should in front of the barrel. The whole idea is that if anything comes between the player and the camera, the camera would move to a spot where it can always see the player. This works for objects, just not the terrain.
-
This is what I'm using for the main loop lua file. Ideally we would have a better way to exit game mode than having it hardcoded inside here. Could probably make setting in the Configuration Options for how to exit game mode from the editor. Now ideally this script would also be setup so it can run from the engine.exe as well and it would know where it's being ran from. The editor or the engine. I'm open to ideas. require("Scripts/constants/collision_const") require("Scripts/constants/engine_const") require("Scripts/LinkedList") require("Scripts/filesystem") require("Scripts/math/math") require("scripts/classes/bullet") SetGlobalString("mode", "GAME_MODE") FlushKeys() FlushMouse() --main function while KeyHit(KEY_ESCAPE)==0 do fw:Update() fw:Render() Flip(0) end SetGlobalString("mode", "DESIGN_MODE")