playMaker

Author Topic: How to 'addforce' only to rigidbodies in camera view?  (Read 707 times)

TonyCooper

  • Playmaker Newbie
  • *
  • Posts: 6
How to 'addforce' only to rigidbodies in camera view?
« on: May 26, 2020, 03:44:46 PM »
Hi there,

As per the title, I'm trying to create a "push" spell (think fus-roh-dah) that will use an addforce on all rigidbodies in the camera view to move them away like a sudden blast of wind.

'Add Explosion Force' only works as a 360 degree radius, and 'Add Force' only works on individual rigidbodies.

Unless there is a way to create some kind of 'Add Explosion Force' but just within a given arc, the only way I can think of to do this is to do a 'Raycast All' from the camera position, from this array find all rigidbody actors in the camera frustrum/view, and then 'Add Force' to each of them based on distance.

This sounds like a lot of work (which I don't mind doing!) but if there is an easier way to do this I would love to know.

Thanks! Tony.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to 'addforce' only to rigidbodies in camera view?
« Reply #1 on: June 04, 2020, 02:30:36 AM »
Hi,

You can use a spherecast ( on the ecosystem browser), to list all objects from within a certain distance from a point, and call them, each would then check their individual distance and apply a counter forced based on the source of the explosion and the distance.

Bye,

 Jean