It is starting to shape up but I'm still having a problem:
If Not LinePick(EntityX(c\Pivot,1),EntityY(c\Pivot,1),EntityZ(c\Pivot,1),EntityX(c\Cam,1)-EntityX(c\Pivot,1),EntityY(c\Cam,1)-EntityY(c\Pivot,1),EntityZ(c\Cam,1)-EntityZ(c\Pivot,1)) = 0
PositionEntity c\Cam, PickedX(),PickedY(),PickedZ(),1
PointEntity c\Cam,c\Pivot
MoveEntity c\Cam, 0,0,0.5
Else
If EntityZ(c\Cam) > EntityZ(c\tzPivot) Then MoveEntity c\Cam, 0,0,-0.5
EndIf
And c\Pivot is the parent pivot that is moved to the player's location every frame (before this code), c\Cam is the camera of course, and c\tzPivot is the target pivot (the preset location to move the camera back to.)
The above works well except when the camera is positioned at the picked xyz, the screen starts shaking intensly. And when i comment out the else block which moves the camera back, there is no longer any shaking. Thus, its like the else is being executed
with the if.
...While typing this post I just realized hey why not try and run two linepicks one for false and one for true:
If Not LinePick(EntityX(c\Pivot,1),EntityY(c\Pivot,1),EntityZ(c\Pivot,1),EntityX(c\Cam,1)-EntityX(c\Pivot,1),EntityY(c\Cam,1)-EntityY(c\Pivot,1),EntityZ(c\Cam,1)-EntityZ(c\Pivot,1)) = 0
PositionEntity c\Cam, PickedX(),PickedY(),PickedZ(),1
PointEntity c\Cam,c\Pivot
MoveEntity c\Cam, 0,0,0.5
EndIf
If LinePick(EntityX(c\Pivot,1),EntityY(c\Pivot,1),EntityZ(c\Pivot,1),EntityX(c\Cam,1)-EntityX(c\Pivot,1),EntityY(c\Cam,1)-EntityY(c\Pivot,1),EntityZ(c\Cam,1)-EntityZ(c\Pivot,1)) = 0
If EntityZ(c\Cam) > EntityZ(c\tzPivot) Then MoveEntity c\Cam, 0,0,-0.5
EndIf
Works flawlessly...
Any idea why the first doesn't work and the latter does?
Edit: After more testing I noticed the camera would still shake if it got close to the player (like against a wall) and so out of pure luck and just messing around I came up with this:
If EntityZ(c\Cam) < -1.5
If Not LinePick(EntityX(c\Pivot,1),EntityY(c\Pivot,1),EntityZ(c\Pivot,1),EntityX(c\Cam,1)-EntityX(c\Pivot,1),EntityY(c\Cam,1)-EntityY(c\Pivot,1),EntityZ(c\Cam,1)-EntityZ(c\Pivot,1)) = 0
PositionEntity c\Cam, PickedX(),PickedY(),PickedZ(),1
PointEntity c\Cam,c\Pivot
MoveEntity c\Cam, 0,0,0.5
EndIf
EndIf
If LinePick(EntityX(c\Pivot,1),EntityY(c\Pivot,1),EntityZ(c\Pivot,1),EntityX(c\Cam,1)-EntityX(c\Pivot,1),EntityY(c\Cam,1)-EntityY(c\Pivot,1),EntityZ(c\Cam,1)-EntityZ(c\Pivot,1)) = 0
If EntityZ(c\Cam) > EntityZ(c\tzPivot) Then MoveEntity c\Cam, 0,0,(EntityZ(c\tzPivot)-EntityZ(c\Cam))*0.1
EndIf