Portal-style item pickup

Hi, I have no idea on how to pickup a game object when I am looking on it and make it rotate like the player object, like in portal when you pickup a cube or other item. How can I do this?

using UnityEngine;
using System.Collections;

public class FunnyCubeRotation : MonoBehaviour {
	public GameObject player;
	public float speed = 5.0f;
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		transform.Rotate((player.transform.position - transform.position).normalized * Time.deltaTime * speed);

To rotate the cube.

To pick it up, cast a ray from the camera position and direction (Physics.RaycastAll) and if hit on pickable object, set transform.parent to camera’s transform and reset the localPosition to where you’d like the object in relation to the camera.

That should keep you busy :slight_smile: