Yue Posted August 21, 2018 Share Posted August 21, 2018 Apparently it's a delay in the camera that follows the vehicle, but I don't know for sure. Quote Link to comment Share on other sites More sharing options...
Yue Posted August 22, 2018 Author Share Posted August 22, 2018 Explorer On Mars 22_08_2018 11_09_26 a. m..mp4 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted August 22, 2018 Share Posted August 22, 2018 No one can tell if you don't show your code. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Yue Posted August 22, 2018 Author Share Posted August 22, 2018 Quote Script.rueda1 = nil --entity "Rueda 1" Script.rueda2 = nil --entity "Rueda 2" Script.rueda3 = nil --entity "Rueda 3" Script.rueda4 = nil --entity "Rueda 4" Script.camara = nil --entity "Camara" Script.pivoteCamara = nil --entity "Pivote Camara" Script.context = Context:GetCurrent() function Script:Start() self.motor1 = self:InitRueda ( self, self.rueda1 ) self.motor2 = self:InitRueda ( self, self.rueda2 ) self.motor3 = self:InitRueda ( self, self.rueda3 ) self.motor4 = self:InitRueda ( self, self.rueda4 ) self.camara:SetParent( self.pivoteCamara ) end function Script:InitRueda( self, rueda ) self.posRueda = rueda:GetPosition() self.motorRueda = Joint:Hinge( self.posRueda.x, self.posRueda.y, self.posRueda.z, 0, 0, 1, rueda, self.entity ) self.motorRueda:DisableLimits() return self.motorRueda end local pivote = Vec3() function Script:GiroCamara(self) --Get the mouse movement local sx = Math:Round(self.context:GetWidth()/2) local sy = Math:Round(self.context:GetHeight()/2) local mouseposition = ventana:GetMousePosition() local dx = mouseposition.x - sx local dy = mouseposition.y - sy --Adjust and set the camera rotation pivote.x = pivote.x + dy / 10.0 pivote.y = pivote.y + dx / 10.0 self.pivoteCamara:SetRotation(pivote) --Move the mouse to the center of the screen ventana:SetMousePosition(sx,sy) end function Script:UpdateWorld() self.posChassis = self.entity:GetPosition(false) self.pivoteCamara:SetPosition( self.posChassis ) if ventana:KeyHit(Key.S) then self.entity:AddForce(0, 1500*10, 0 ) end self:GiroCamara ( self ) end function Script:UpdatePhysics() self:SetMotor( self.motor1 ) self:SetMotor( self.motor2 ) self:SetMotor( self.motor3 ) self:SetMotor( self.motor4 ) end Script.velocidad = 0 function Script:SetMotor( motor ) motor:DisableMotor() if ventana:KeyDown(Key.W) then motor:EnableMotor() motor:SetTargetAngle( self.motorRueda:GetAngle() -100 ) if self.velocidad < 2000 then self.velocidad = self.velocidad + 1 end else self.velocidad = 0 end motor:SetMotorSpeed( self.velocidad) end Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 22, 2018 Share Posted August 22, 2018 You need to interpolate the camera's position to the next position over time or you will get quick jumps like that in movement. Use the Math:Curve() to smoothly transition between positions. Now if some of the jerkiness is due to the pivot bouncing with the stuttering vehicle joints, that might be another problem. EDIT--Also - it appears you have implemented some sort of camera collision/pick which is not a part of the code you posted above that is moving the camera as well. If this is the case, then you need to show that code as well or even better post an example that shows the problem. If you have the code above and some sort of camera collision code setting the position of the camera as well, I can see the two causing a jittery effect as they work against each other. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Marcousik Posted August 24, 2018 Share Posted August 24, 2018 @macklebee Strange... I can't find this quoted script part in the Spectator.lua ? Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 24, 2018 Share Posted August 24, 2018 There's been a lot of iterations apparently. I was going to use the 3rdPersonFollow script as an example that has similar code but that's no longer supplied with the software. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
havenphillip Posted August 25, 2018 Share Posted August 25, 2018 Here's spectator.lua if you need it: Script.movespeed=5.0--float "Move speed" Script.movementsmoothing = 0.3--float "Move smoothness" Script.radius = 0.5--float "Radius" Script.lookspeed = 0.1--float "Look speed" Script.looksmoothing = 0.5--float "Look smoothness" function Script:Start() local window = Window:GetCurrent() self.mousepos = window:GetMousePosition() self.camerarotation = self.entity:GetRotation() if (self.entity:GetMass()==0) then self.entity:SetMass(10) end self.entity:SetGravityMode(false) self.entity:SetBuoyancyMode(false) self.entity:SetCollisionType(Collision.Projectile) if self.entity:GetShape()==nil then local shape = Shape:Sphere(0,0,0, 0,0,0, self.radius*2,self.radius*2,self.radius*2) self.entity:SetShape(shape) shape:Release() end self.entity:SetFriction(0,0) self.entity:SetElasticity(0) self.entity:SetSweptCollisionMode(true) self.listener = Listener:Create(self.entity) self.entity:SetBuoyancyMode(false) end --Collision filter so the spectator doesn't knock things over function Script:Overlap(entity) if entity:GetMass()==0 then return Collision.Collide else return Collision.None end end function Script:UpdateWorld() local window = Window:GetCurrent() local cx = Math:Round(context:GetWidth()/2) local cy = Math:Round(context:GetHeight()/2) local mpos = window:GetMousePosition() window:SetMousePosition(cx,cy) local centerpos = window:GetMousePosition() if self.started then mpos = mpos * self.looksmoothing + self.mousepos * (1-self.looksmoothing) local dx = (mpos.x - centerpos.x) * self.lookspeed local dy = (mpos.y - centerpos.y) * self.lookspeed self.camerarotation.x = self.camerarotation.x + dy self.camerarotation.y = self.camerarotation.y + dx self.mousepos = mpos else self.mousepos = Vec3(centerpos.x,centerpos.y,0) self.started=true end end function Script:UpdatePhysics() local move=0 local strafe=0 local ascension=0 local window = Window:GetCurrent() if window:KeyDown(Key.W) or window:KeyDown(Key.Up) then move = move + self.movespeed end if window:KeyDown(Key.S) or window:KeyDown(Key.Down) then move = move - self.movespeed end if window:KeyDown(Key.D) or window:KeyDown(Key.Right) then strafe = strafe + self.movespeed end if window:KeyDown(Key.A) or window:KeyDown(Key.Left) then strafe = strafe - self.movespeed end if window:KeyDown(Key.Q) or window:KeyDown(Key.PageDown) then ascension = ascension - self.movespeed end if window:KeyDown(Key.E) or window:KeyDown(Key.PageUp) then ascension = ascension + self.movespeed end local currentvelocity = self.entity:GetVelocity(false) local desiredvelocity = Vec3(strafe,0,move) + Transform:Vector(0,ascension,0,nil,self.entity) local velocity = currentvelocity * self.movementsmoothing + desiredvelocity * (1.0-self.movementsmoothing) self.entity:AddForce((desiredvelocity - currentvelocity) * self.entity:GetMass() / self.movementsmoothing,false) self.entity:PhysicsSetRotation(self.camerarotation.x,self.camerarotation.y,self.camerarotation.z) end Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 25, 2018 Share Posted August 25, 2018 Thanks - but I think Marcousik has that file. I am looking for the script and now i cannot find it either. Oh well, I think the bigger issue above is that it appears the OP has two sets of code setting the camera position and possibly fighting each other. Or at least the collision code and however the pick properties are set is causing it to bounce position. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Yue Posted August 25, 2018 Author Share Posted August 25, 2018 Hi, I just have that file code, where the camera is implemented. Only file Script. Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 25, 2018 Share Posted August 25, 2018 6 hours ago, Yue said: Hi, I just have that file code, where the camera is implemented. Only file Script. Impossible. In your videos, the camera is changing positions if behind walls and is allowing you to move the camera close and away from the vehicle. The code you posted only allows the user to change the rotation of the camera and not the position. EDIT - you can make as many videos as you want, but without an example we cannot troubleshoot your issue. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Yue Posted August 26, 2018 Author Share Posted August 26, 2018 Quote Link to comment Share on other sites More sharing options...
Yue Posted August 26, 2018 Author Share Posted August 26, 2018 Quote Link to comment Share on other sites More sharing options...
Solution Marcousik Posted August 26, 2018 Solution Share Posted August 26, 2018 Well maybe it makes sense to study the mouse look in the FPSPlayer.lua (there are examples of how using Math:Curve() ) This is the mouse look in the UpdateWorld(): (I would not change this) Quote --Mouse look self.currentMousePos = window:GetMousePosition() window:SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2)) local centerpos = window:GetMousePosition() self.currentMousePos.x = Math:Round(self.currentMousePos.x) self.currentMousePos.y = Math:Round(self.currentMousePos.y) -- Here is code for weapons cycle that I removed to simplify self.mouseDifference.x = Math:Curve(self.currentMousePos.x - centerpos.x,self.mouseDifference.x,2/Time:GetSpeed()) self.mouseDifference.y = Math:Curve(self.currentMousePos.y - centerpos.y,self.mouseDifference.y,2/Time:GetSpeed()) self.camRotation.x = Math:Clamp(self.camRotation.x + self.mouseDifference.y / self.mouseSensitivity,-90,90) self.camRotation.y = self.camRotation.y + (self.mouseDifference.x / self.mouseSensitivity) --Adjust the view shake self.hurtoffset.x = Math:Inc(0,self.hurtoffset.x,2*Time:GetSpeed()) self.hurtoffset.y = Math:Inc(0,self.hurtoffset.y,2*Time:GetSpeed()) self.smoothedhurtoffset.x = Math:Curve(self.hurtoffset.x,self.smoothedhurtoffset.x,3) self.smoothedhurtoffset.y = Math:Curve(self.hurtoffset.y,self.smoothedhurtoffset.y,3) --Set the camera angle self.camera:SetRotation(self.camRotation+self.smoothedhurtoffset) And this is in the UpdatePhysics(): Quote self.entity:SetInput(self.camRotation.y, playerMovement.z, playerMovement.x, jump , false, 1.0, 0.5, true) local playerPos = self.entity:GetPosition() local newCameraPos = self.camera:GetPosition() --local playerTempHeight = ((self:IsCrouched() == 1) and crouchHeight or playerHeight) newCameraPos = Vec3(playerPos.x, newCameraPos.y ,playerPos.z) if newCameraPos.y<playerPos.y + self.eyeheight then newCameraPos.y = Math:Curve(playerPos.y + self.eyeheight, newCameraPos.y, self.camSmoothing) else newCameraPos.y = playerPos.y + self.eyeheight end self.camera:SetPosition(newCameraPos) And somewhere I would add something like this for the third person view: self.camera:Move(0,0,-10) 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 26, 2018 Share Posted August 26, 2018 At this point, I think its the code the OP isn't showing us that is the problem or at least maybe how the pick is working for camera collision. The code he posted doesn't do anything but set the camera at the 'chassis' position and allows the user to rotate the camera.That code does not point the camera at the car, it does not automatically move the camera if behind a wall, and it doesn't allow the user to move the camera closer or farther away from the 'chassis' like what is shown in his videos. The jitter, since he is making us guess, is probably due to the pick hitting the wheels briefly instead of the chassis causing the camera to move slightly. So it's probably more of collision type setup issue more than anything where the camera pick needs to ignore the wheels. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Yue Posted August 26, 2018 Author Share Posted August 26, 2018 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.