Massive errors with trajectory script added to weapon

Grannyboy

Active member
Im trying to make a throwable weapon but as soon as I add the trajectory script and a line renderer unity craches. I get some allocation errors spamming my console and crashing the editor:

1682790582722.png

I asked chatGPT and got this answer:
The error message suggests that the operation you are trying to perform has caused a stack overflow. In programming, a stack overflow occurs when a function or operation consumes more memory than the stack has available. This can happen when there is a recursive function that calls itself too many times or when there is an infinite loop.

In your case, the error seems to be related to the Ultimate Character Controller from Opsive. Specifically, it seems to be coming from the TrajectoryObject script. The error message indicates that the SimulateTrajectory method is being called repeatedly, and this is causing a stack overflow.

To fix this issue, you may want to review the code in the SimulateTrajectory method and look for any recursive calls or infinite loops. If you are not familiar with the code, you may want to contact the developer or look for support forums related to the Ultimate Character Controller. It's possible that this is a known issue that has already been addressed in a newer version of the software.

Additionally, you may want to check if your Unity version is up to date and if your system meets the minimum hardware requirements. Sometimes, insufficient hardware or outdated software can cause unexpected errors.

If the issue persists after trying these steps, you may want to seek further assistance from Unity support or a community forum.


My weapon is set up similar to the Opsive prebuild Grenade and I can see the line renderer render a trajectory before the editor freezes and chrashes. What could possibly cause this and does anyone else face the same problems?
 
Have you tried the demo grenade to see if it works? You can also use the item template feature to copy an existing item.
 
Yes the demo grenade works fine! But a major difference in my scene is that im also using UIS. One problem is that the grenade dosent seem to parent under the correct object identifier as it does in the demo, even tho i have the exact same set up. Not sure if thats the root cause but:

1682928729458.png
1682928836590.png
 
As soon as the linerenderer gets active the entire log just blows up with allocation errors.

1682929122724.png

StackOverflowException: The requested operation caused a stack overflow.
UnityEngine.PhysicsScene.Internal_RaycastNonAlloc (UnityEngine.PhysicsScene physicsScene, UnityEngine.Ray ray, UnityEngine.RaycastHit[] raycastHits, System.Single maxDistance, System.Int32 mask, UnityEngine.QueryTriggerInteraction queryTriggerInteraction) (at <986bc431530c4e10a9a66db75ccf7a92>:0)
UnityEngine.PhysicsScene.Raycast (UnityEngine.Vector3 origin, UnityEngine.Vector3 direction, UnityEngine.RaycastHit[] raycastHits, System.Single maxDistance, System.Int32 layerMask, UnityEngine.QueryTriggerInteraction queryTriggerInteraction) (at <986bc431530c4e10a9a66db75ccf7a92>:0)
UnityEngine.Physics.RaycastNonAlloc (UnityEngine.Vector3 origin, UnityEngine.Vector3 direction, UnityEngine.RaycastHit[] results, System.Single maxDistance, System.Int32 layerMask, UnityEngine.QueryTriggerInteraction queryTriggerInteraction) (at <986bc431530c4e10a9a66db75ccf7a92>:0)
Opsive.UltimateCharacterController.Objects.TrajectoryObject.Cast (UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Vector3 direction) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/TrajectoryObject.cs:693)
Opsive.UltimateCharacterController.Objects.TrajectoryObject.Move (UnityEngine.Vector3& position, UnityEngine.Quaternion rotation, System.Boolean simulation) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/TrajectoryObject.cs:598)
 
Ahaaa! Silly me... I see now in my own screenshot that my object identifier is not a child under "Item slot 0"... That fixed it!
1682929740021.png
 
That wasnt the whole solution, I also changed this values:
1682932699026.png

Correct the impact layers, o.1 settle threshold isntead of 0 and rotation speed 1 instead of 5.
 
Top