Jump to content

Rotate entity on collision


gennadiy
 Share

Recommended Posts

Hello, friends! I'm new in Leadwerks Game Engine and I need help. Previously, I have programmed in Unity3D. So what's the problem - I need to create the object after the collision object to the scene and turn it as well as the collision surface (normal). On the Unity I wrote:

void OnCollisionEnter (Collision col)
{
 if (col.gameObject.CompareTag("Scene"))
 {
   ContactPoint contact = col.contacts[0];
   Transform Obj = Instantiate(Object, contact.point, Quaternion.FromToRotation(Vector3.up, contact.normal)) as Transform;
 }
}

and how i can do this on Leadwerks?

function Script:Collision(entity, position, normal, speed)
 local collisiontype = entity:GetCollisionType()

 if collisiontype==Collision.Scene then
   local obj = Prefab:Load("Prefabs/Object.pfb")
   obj :SetPosition(position + normal * 0.1)
 end
end

But how i can rotate object? Sorry for my bad English and noob question (((

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...