Camera Switch

Blitz3D Forums/Blitz3D Programming/Camera Switch

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have two modes in my game: walk mode, and drive mode. They are represented by the variable "cam_mode." If "cam_mode" equals 1, then it is walk mode, where the player can walk around the level. If "cam_mode" equals 2, then it is drive mode, where the player can drive around in a vehicle. I can't really figure out how to switch both of these.

This is the code for "drive mode:"
	If cam_mode = 2
	EntityParent camera, car\entity
	PositionEntity camera, EntityX(car\entity), EntityY(car\entity)+30, EntityZ(car\entity)-10
	RotateEntity camera, EntityPitch(car\entity)+45, EntityYaw(car\entity), EntityPitch(car\entity)
	If KeyDown(17)
		MoveEntity car\entity, 0, 0, 3
	EndIf
	
	If KeyDown(31)
		MoveEntity car\entity, 0, 0, -3
	EndIf
	
	If KeyDown(30)
		TurnEntity car\entity, 0, 1, 0
	EndIf
	
	If KeyDown(32)
		TurnEntity car\entity, 0, -1, 0
	EndIf
	If KeyHit(57)
		cam_mode = 1
	EndIf
	EndIf


You can see that W, S, A, and D, control the car, and the camera is parented to the car. First of all, how would I make it so I wouldn't have to make the EntityParent, PositionEntity, and RotateEntity functions? While the game is running in walk mode, the camera is not parented to the car. In drive mode, it is. I just haven't got it figured out.

All I want to do is make it so if the camera is a certain distance from the car (car\entity), and the spacebar is pressed. And if the spacebar is pressed while in drive mode, then the player is transported right next to the car.

How would I achieve this?