Help Grenade trajectory velocity

novi

New member
Hi so I'm trying to rotate or face the velocity of throwing the grenade but its not relative to the character facing angle. How do I this? I already tried something on the script but its not accurate. I want the grenade trajectory endpoint to go through the target area. Thanks!

1618971007495.png
 
The line drawn is based on which version of TrajectoryObject.SimulateTrajectory is called. ThrowableItem.LateUpdate passes the item's initial position, velocity, etc. and allows TrajectoryObject to calculate its trajectory from that. If you want to specify an end point, you can call TrajectoryObject.SimulateTrajectory(GameObject originator, Vector3 startPosition, Vector3 endPosition).

Since ThrowableItem.LateUpdate is not an overridable method, you may want to create your own subclass (e.g. of GrenadeItem) which calls SimulateTrajectory itself, in a similar way to ThrowableItem.LateUpdate.
 
The line drawn is based on which version of TrajectoryObject.SimulateTrajectory is called. ThrowableItem.LateUpdate passes the item's initial position, velocity, etc. and allows TrajectoryObject to calculate its trajectory from that. If you want to specify an end point, you can call TrajectoryObject.SimulateTrajectory(GameObject originator, Vector3 startPosition, Vector3 endPosition).

Since ThrowableItem.LateUpdate is not an overridable method, you may want to create your own subclass (e.g. of GrenadeItem) which calls SimulateTrajectory itself, in a similar way to ThrowableItem.LateUpdate.
Thank you for answering. I'm doing a custom throwable with my own aiming system will this be able to traject the velocity of the grenade using TrajectoryObject.SimulateTrajectory ? Or this is just for the line renderer. Somehow the direction of ThrowableItem.Velocity is relative on the camera whilst I wanted to do the direction from the character position to endpoint (target ground) .
 
Last edited:
SimulateTrajectory is just used for the LineRenderer.

For the actual thrown object's motion, that's controlled by TrajectoryObject, specifically Move. Again this isn't an overrideable method, so you may want to create a custom script to handle movement between pre-defined points A and B.
 
SimulateTrajectory is just used for the LineRenderer.

For the actual thrown object's motion, that's controlled by TrajectoryObject, specifically Move. Again this isn't an overrideable method, so you may want to create a custom script to handle movement between pre-defined points A and B.

Okay I get it but is it possible to activate the trajectory without using the aim ability ?
 
Last edited:
Ah sorry I see what you mean now. The trajectory begins simulating in ThrowableItem.LateUpdate - you can see it requires aiming to be active. So you'd need to either modify ThrowableItem (e.g. by removing m_Aiming && m_ShowTrajectoryOnAim from the if statement) or do something similar in your own custom class, similar to what we talked about before.
 
Top