So I’m making portal-like game. Basic idea is this: Player can shoot orange and blue portal bullets. When bullet hits something, it teleports portal-gameobject to hit location. This works fine. But portal-object is always in the same rotation (horizontal). And I want it to rotate like in Portal 2 (or 1) (Valve game), ‘facing’ hit surface.
This is my BlueBullet script:
using UnityEngine;
using System.Collections;
public class CreatePortalBlue : MonoBehaviour {
public GameObject PortalB;
public void OnTriggerEnter( Collider col)
{
Vector3 impactPos = this.transform.position + new Vector3(0, 0.3f, 0);
PortalB.transform.position = impactPos;
//this works fine (move the portal)
PortalB.transform.rotation = Quaternion.identity;
//bad try to rotating portal. I have tried lot's of things.
Destroy(gameObject);
//destroy bullet
}
}