Position Camera move Entity Mouse.

Blitz3D Forums/Blitz3D Programming/Position Camera move Entity Mouse.

Yue(Posted 2016) [#1]




depending on where you look selecionar cubes and motion vectors cube moves correctly.

the problem is that if I'm watching it ahead of the cube, and try to move the cube from its vector x, moves backward.

Any suggestions?




Flanker(Posted 2016) [#2]
Hide all meshes just before camerapick, then show them back after it's done. Something like that :
For c.cube = Each cube
	HideEntity c\mesh
Next

CameraPick camera,MouseX(),MouseY()

For c.cube = Each cube
	ShowEntity c\mesh
Next



Yue(Posted 2016) [#3]
No work.

If I'm behind the cube, moving the mouse to the right with the vector x selecionado moves correctly, if the camera is in front of the cube to move forward is moving backward.






Flanker(Posted 2016) [#4]
Oh! sorry I didn't understood well what you meant. The hideentity/showentity code above allows you to pick the axis even if the cube is in the way.

For you actual problem, I solved it in my previous code, you need to invert the move direction depending of you position from the cube :

		If PickedEntity() = Xaxis
			If EntityZ(camera) < EntityZ(entity)
				MoveEntity pivot,Float(MouseXSpeed())*distance,0,0
			Else
				MoveEntity pivot,Float(-MouseXSpeed())*distance,0,0
			EndIf
			PositionEntity entity,EntityX(pivot),EntityY(pivot),EntityZ(pivot)
		ElseIf PickedEntity() = Yaxis
			distance# = EntityDistance(camera,entity)/450
			MoveEntity pivot,0,Float(-MouseYSpeed())*distance,0
			PositionEntity entity,EntityX(pivot),EntityY(pivot),EntityZ(pivot)
		ElseIf PickedEntity() = Zaxis
			distance# = EntityDistance(camera,entity)/450
			If EntityX(camera) < EntityX(entity)
				MoveEntity pivot,0,0,Float(-MouseXSpeed())*distance
			Else
				MoveEntity pivot,0,0,Float(MouseXSpeed())*distance
			EndIf
			PositionEntity entity,EntityX(pivot),EntityY(pivot),EntityZ(pivot)
		EndIf



Yue(Posted 2016) [#5]
Thanks You. :)