playMaker

Author Topic: Create Object update to allow for easy bullet impacts and holes.  (Read 2237 times)

Roger Lee

  • Playmaker Newbie
  • *
  • Posts: 31
Create Object update to allow for easy bullet impacts and holes.
« on: December 12, 2019, 11:21:00 AM »
I've been working on a firearm system and have been pulling my hair out trying to get a bullet impact particle system to orient properly using the Create Object action.  You would think that the spawn rotation could be accomplished by just simply providing the hit normal in this action.  I doesn't work.  I've read old posts on here about these long drawn out processes using many actions just to simply align the created object.

I found the solution to make it work as I think it was intended.

Make this simple edit in the Create Object script and your particle systems and bullet hole sprites will align perfectly to the surface they hit.  (assuming you supply it with the hit normal from your raycast.)

Approx location is line 95 in the script.  Replace the RED with the GREEN and all is good.


(old)  var newObject = (GameObject)Object.Instantiate(go, spawnPosition, Quaternion.Euler(spawnRotation));
            
(new) var newObject = (GameObject)Object.Instantiate(go, spawnPosition, Quaternion.LookRotation(spawnRotation));

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Create Object update to allow for easy bullet impacts and holes.
« Reply #1 on: December 12, 2019, 01:07:11 PM »
For bullet impacts and holes, you might want to look into a pooling system that has its own spawn, rather than create object. Since create object and destroy will start to create lots of garbage quick.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Create Object update to allow for easy bullet impacts and holes.
« Reply #2 on: December 13, 2019, 12:58:15 AM »
Hi.
Maybe this video can help. it does not use particles but it does set the decal in the right rotation so you could also use this for the particle :


Roger Lee

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Create Object update to allow for easy bullet impacts and holes.
« Reply #3 on: December 13, 2019, 02:30:45 PM »
Hi.
Maybe this video can help. it does not use particles but it does set the decal in the right rotation so you could also use this for the particle :


Editing the Create Object action works flawlessly so no need for any other solutions, but thanks for the info.

Also each particle and hole spawned has it's own clean up script, so no problems there.  Ammo is limited in this project, so garbage won't be an issue.

Thanks for the responses, but I'm just offering this solution to others, my issue was solved in the original post.  I'm assuming this is the way the action was suppose to work in the first place.  Why else would they put a rotation field that doesn't do anything?
« Last Edit: December 13, 2019, 02:34:57 PM by Roger Lee »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Create Object update to allow for easy bullet impacts and holes.
« Reply #4 on: December 14, 2019, 04:21:08 AM »
Hi.
Even when limited its recommended to pool.
As Create and Destroy are 'heavy', leaves garbage and can cause lag when creating.

With pooling you can pre create objects @ the start of the game and reuse them.

Also if you edited the action i also recommend to rename the action and the .cs file  else if you update Playmaker, the code will be reset.