Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: derkoi on June 10, 2013, 03:10:38 PM
-
I've used a raycast for a Gun instead of spawning bullets. I'd like to add force to objects that are shot by the raycast but I can think how I could add the correct force Vector from the direction of the raycast? Can anyone help please?
-
Are you only trying to affect one target or make a big pulse effect that hits several objects or multiple objects in a line?
-
Hi,
It depends how you generated the rayCast, but that should not be difficult, you want to add a force at the hit point of contact, but I guess your problem is that you use RayCastFrom GameObject right?
in that case, getting the direction of the ray as a vector3, use the following action: TransformDirection
tell which local axis you are using ( 1,0,0 if you are firing on the positive x axis)
is that what you are after?
bye,
Jean
-
Thanks for the replies.
I'm firing a raycast from a game object using the Raycast action. I then send a 'damage' message to any object I hit, spawn a blood splat or ricochet object at the hit point & add force at the hit point. It's the direction of the raycast I need to put in the add force so it throws the enemy/object backwards.
I'll give the transform direction a try. :)
-
I tried the transform Direction but it doesn't seem to work, it's throwing the objects in all directions. :o
-
Are you using rigidbodies?
I could tinker around and make an example, but I'm not sure if I can squish it in this week.
-
Yeah i'm using rigid bodies & it's working fine. Just the direction in which the rigidbodies are thrown is not away from the gun.
-
Hi,
How do you get the direction to begin with? what action are you using?
bye,
Jean
-
I get the direction from the raycast which fires forward from the player object
-
Hi,
I think you are getting confused with the direction of the ray cast and the direction of the hit normal.
to get the direction of the raycast ( when you use rayCast from gameObject for example), you need to use the "Transform Direction" and in the local Direction put the axis. so if your gameObject fire along its y axis, you need to put (0,1,0) in the local Direction.
Yes?
bye,
Jean