playMaker

Author Topic: Shooting with raycasts  (Read 1781 times)

haratman

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Shooting with raycasts
« on: January 05, 2018, 08:43:35 AM »
Hello.

I wanto t mgun shoake a ts with ps hits and  I fo aty3d.com/learn/tutorials/lets-try/shooting-with-ra370
« Last Edit: October 19, 2018, 11:25:06 AM by haratman »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 756
    • View Profile
Re: Shooting with raycasts
« Reply #1 on: January 05, 2018, 11:22:45 AM »
Hi, first it is important to learn how raycasts work. This short tutorial video shows raycasts in playmaker:
Next, once you have the object you have hit with the raycast, you can use the playmaker action "add force".

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 756
    • View Profile
Re: Shooting with raycasts
« Reply #2 on: January 14, 2018, 07:41:08 PM »
Hi, I was hoping someone else would answer your question.  ;D Sometimes big questions or big requests are hard to answer. It is important to learn the fundamentals of playmaker.

Did you have a chance to learn how to use the raycast action from the video? Use the raycast to "shoot". Find out what gameobject it hits. Then send an event to that gameobject (enemy) with a custom global event. On this enemy, use the the action "knock back". The raycast will give you the position of the hit normal. Use this position for the knock back action.

Action: https://hutonggames.com/playmakerforum/index.php?topic=14171.0

Or you can apply force if you want to use rigidbody physics.

Here is alternative way to do knockback as well. This one instead of using a normal, calculates the direction between two game objects.  https://hutonggames.com/playmakerforum/index.php?topic=16400.0

Let me know if this helps.  8)

« Last Edit: January 14, 2018, 07:42:57 PM by tcmeric »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15330
  • Official Playmaker Support
    • View Profile
Re: Shooting with raycasts
« Reply #3 on: January 23, 2018, 12:12:00 AM »
Hi

 Did you checked out the ecosystem sample "RaycastHitNormal" and "GetNextRaycastAllHit" it features all the code to work with raycasts and fire. "GetNextRaycastAllHit" also shows how to check for obstacles.

 Bye,

 Jean