Search Unity

BGCurve (free Bezier Spline Editor) support thread [OFFICIAL]

Discussion in 'Assets and Asset Store' started by BansheeGz, Feb 18, 2017.

  1. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    32
    Ok, thanks for the reply, even if its not the answer i was hoping for ;)
     
  2. Vanilla-Plus

    Vanilla-Plus

    Joined:
    Jul 2, 2014
    Posts:
    41
    I forgot to respond, sorry! I managed to fix the problem, but thank you very much for replying so comprehensively. I'll be sure to apply your fix script if it happens again.

    I have another question, although this is more to do with functionality. I'm still loving this asset pack! :D

    On the BGCcCursorObjectTranslate and BGCcCursorObjectRotate components, is it possible to change which cursor they are controlled by through code? It says that BGCcCursorObjectRotate.Cursor is read-only, but because it's being added outside of the editor, I'm not sure if I get a choice for which cursor they will use. They seem to automatically pick the first cursor component available.
     
  3. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    ChiefBreakeverything, thank you for your support!
    You could use SetParent method to change the cursor.
    The cursor should be attached to the same GameObject.
     
  4. Vanilla-Plus

    Vanilla-Plus

    Joined:
    Jul 2, 2014
    Posts:
    41
    Perfect, that worked very well, thank you!

    Is it possible to use the same function to move a Cursor between different BGCcMath components? For example...

    Code (CSharp):
    1. differentMathComponent = someOtherGameObject.GetComponent<BGCcMath>();
    2.  
    3. myCursor = GetComponent<BGCcCursor>();
    4.  
    5. myCursor.SetParent(differentMathComponent);
    I've tried doing that, but it doesn't seem to be present on the 'differentMathComponent' when I check. Although the objects are in different scenes (loaded additively), so I'm wondering if that's part of the problem. Or I could just be doing it wrong...

    Another small question is about the BGCcCursorObjectRotate component. I noticed that if the cursor its attached to is moved to a point that is 'upside down', the object being driven by the BGCcCursorObjectRotate component will be automatically flipped 180 degrees. In other words, without manually changing the offset rotation when this happens, it's impossible for the controlled object to be rotated to face downwards via BGCcCursorObjectRotate. This could be changed if it were possible to know when the cursors position is considered 'upside down', but I'm currently unsure how to do that. Hopefully that all makes sense, it's a strange thing to describe! I've attached an image demonstrating; it shows two sprites which are being controlled by the BGCcCursorObjectRotate component. The top sprite is displayed correctly, but the bottom sprite flips because the angle of the cursor its attached to is facing downwards.

    Capture.PNG

    Edit:
    I've sort of solved the rotation problem, but I'll leave the message this way just in case there's a misunderstanding in my thinking or other people get stuck the same way. It's definitely not elegant, especially since the sprites need a -90 offset on the Y axis in BGCcCursorObjectRotate's 'offset' Vector3 to begin with, but I've added a small script that can fix the rotation as follows:

    Code (CSharp):
    1.  
    2. if (Mathf.RoundToInt(sprite.transform.eulerAngles.y) == 180) {
    3.     sprite.transform.localEulerAngles = new Vector3(180.0f, 180.0f, -sprite.transform.localEulerAngles.z);
    4. }
    5.  
     
    Last edited: Mar 6, 2018
  5. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    ChiefBreakeverything, assigning Math component from another Curve is an unintended function, we did not test it.It may work or may not. I've added Math setter for BGCcWithMath (instead of using SetParent), you could try it like this (cursor.Math=MathFromAnotherSpline; ). It looks like SetParent works only if you use it while creating a new component.

    Normally, you would want to delete 3 components from old spline (BGCcCursorObjectTranslate, BGCcCursorChangeLinear,BGCcCursor) and add these 3 components to the new spline.
    I attached an example of how to do this (see Assets\BansheeGzSupport\support.unity scene)

    Regarding rotation- we use plain Quaternion.LookRotation without any adjustments.
    I may be wrong, but I do not think it's possible to adjust it somehow so it would fit any possible scenario.
    So adjusting it for your particular use case - is the right thing to do.
     

    Attached Files:

  6. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    22
    Hi BansheeGz,

    I've been playing around with the Spline Editor during the last days and it is really awesome!

    I'm having a few troubles with a feature that I need to implement inside my project, though.
    I would like to instantiate a prefab in the same position as the spline's nodes. I've read in the documentation that it is possible thanks to the BGCurveBaseMath component (through the GetPosition() function) but I can't find a way to access that component.
    If I write something like:

    Code (csharp):
    1. gameObject.GetComponent<BGCurveBaseMath> ().GetPosition(0);
    I get the following error:
    ArgumentException: GetComponent requires that the requested component 'BGCurveBaseMath' derives from MonoBehaviour or Component or is an interface.

    What should I do exactly to access that information?

    Thanks a lot in advance! :)
     
  7. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Tiollo, thank you for your support!

    You can find point's position without math component.

    Code (CSharp):
    1. var curve = GetComponent<BGCurve>();
    2. var pointsCount = curve.PointsCount;
    3. for (var i = 0; i < pointsCount; i++)
    4. {
    5.    var point = curve[i];
    6.    print("Point #" + i +" position=" + point.PositionWorld);
    7. }
    GetPosition is just a faster alternative.

    BGCurveBaseMath is not extended from MonoBehaviour, that's why ArgumentException is thrown.
    The right class is BGCcMath (Note it starts with BGCc..- Cc stands for Curve's component)
    BGCcMath uses BGCurveBaseMath internally, so you can access it like this:
    Code (CSharp):
    1.         BGCcMath mathComponent = GetComponent<BGCcMath>();
    2.         BGCurveBaseMath internalImplementationMath = mathComponent.Math;
    3.  
     
    Tiollo likes this.
  8. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    22
    Awesome, it was way easier than expected :)
    Thanks a lot!
     
  9. stanleylkm

    stanleylkm

    Joined:
    Jan 24, 2013
    Posts:
    3
    Hello BansheeGz, awesome free plugin !

    I have been using your plugin for a while and it's really good. In my project, I realized I need a specific mechanic and I am not sure whether there are existing API for that.

    In the following image , I have a spline containing points 0 ~ 5. Is there a way to temporarily "Disable" a specific point (for example point 3), and the end result will be a Cursor that starts at point 0 and ends at point 2 (because point 3 has been disabled and "blocking" the line)
    upload_2018-3-23_14-7-59.png

    Once again, thanks for the awesome plugin !
    Hope to hear back from you soon , cheers !
     
  10. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hello stanleylkm, thank you for your support!

    For the disabled value, you could use a point's field.
    Chose "Fields" tab and add a field called "disabled" with type bool.
    After that, you can change its value in the Editor or from a script like this
    Code (CSharp):
    1.         var curve = GetComponent<BGCurve>();
    2.         var firstPoint = curve[0];
    3.         firstPoint.SetBool("disabled", true);
    4.         print("disabled=" + firstPoint.GetBool("disabled"));
    As for the component, you will need to write a component, which will change cursor position.It also has to be aware of this "disabled" field and acts accordingly.
    Since existing component (BGCcCursorChangeLinear) is very complex, I would not use it and would start from scratch.
    If you could provide more details about how it should act, we could try to provide you with this component prototype.
    By more details I mean things like:
    1) Can cursor move from the end of the curve to the start or only from the start to the end?
    2) Does it have to monitor "disabled" value and start moving if it's set to false?
    3)What would happen if cursor already between points, should it monitor "disabled" field?
    etc.
     
  11. stanleylkm

    stanleylkm

    Joined:
    Jan 24, 2013
    Posts:
    3
    Basically, I am using the curve as a "moving path" for a player object. the curve contains a BGCcCursorObjectTranslate component , which is controlling the player object. When a movement input is registered , it will update the Distance value of the BGCcCursor component by distance moved. The player object can only move from the start to end of the curve. This works well so far.

    My idea now is to have a more dynamic path , for example , there is a Rock in between point 2 and point 3 now (refer to my image in the previous post), so the player can only move from 0 ~ 2 . the rock will be removed through designed event such as "use item", etc. That will opened up point 3 again, player will now be able to move from 0 ~ 5. No constant monitoring is needed.
     
  12. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    I think, you could try to use existing components.
    There is PointReached event at CursorChangeLinear component, you could make use of.
    I've attached an example scene (BansheeGzSupport/support)
    Here is what I did:
    1) Set "Use Fixed Update" to true (at CursorChangeLinear )
    2) Added Test.cs component to the curve
    3) Added Test.PointReached method as PointReached event listener (at CursorChangeLinear ). Take a look at how Test.cs is implemented
    If this was not helpful, please, let me know.
     

    Attached Files:

  13. stanleylkm

    stanleylkm

    Joined:
    Jan 24, 2013
    Posts:
    3
    I found my own solution :D
    Although your method it isn't a direct solution to my need, I still appreciate your help as it helps me to further understand your plugin!

    Thanks for the help :D
     
  14. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    277
    Hello,
    I have a cursor object attached using the Cursor and TranslateObjectByCursor. I can then move the cursor by changing the distance ratio. What I want to know though is how can I move the cursor through other means, such as physics impulses and still have it follow the spline?
     
  15. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
  16. luvjungle

    luvjungle

    Joined:
    Dec 18, 2017
    Posts:
    47
    Hi BansheeGz, thx for your awesome asset pack.
    Can you help me with problem, please.
    I am changing timeScale while moving with spline, but on low timeScale I can see my character moving in steps. Can i make it move smoothly? I am not using fixed update bool.
    Thanks
     
    Last edited: May 25, 2018
  17. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hi, luvjungle, could you please write a formula, you use for changing Time.timeScale? Which method you use to call it (Update, FixedUpdate)?
     
  18. luvjungle

    luvjungle

    Joined:
    Dec 18, 2017
    Posts:
    47
    I found my problem, it was not with BGCurve, sorry to bother.
     
    Last edited: May 28, 2018
  19. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    719
    Hi, great asset. One small bug I've found is that Cursor component doesn't work/start if points are created in runtime. Setting distance to 0 after adding points was enough to make it work.

    Anyway, what I'm trying to do is make straight line curved (randomly) preserving its length. Any idea how to implement that?
    I will try to generate random control values and just move 2nd point closer till GetDistance is correct but maybe there is easier way to do it?
     
  20. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hi, Kamyker, unfortunately I'm not aware of any of such method
     
  21. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    719
    Actually Cursor changes it's position (distance) when Control points are changed :).

    My solution:
    1. Set cursor distanceRatio to 1 (after few tests setting it to 0.999 is more precise)
    2. Change Control point position
    3. math.Recalculate();
    4. Set 2nd point position to cursor.CalculatePosition()

    It's not perfect but precise enough in my case, it's +-0.004 per 1 point of length
     
  22. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    170
    Does each point on the bezier curve have pivot according to aspect ratio and screen size ? (Use it in UI)

    Also how can I access to the points on the curve for moving my objects ? (I know there is a component for moving but I want to implement it by myself)
     
    Last edited: Jul 11, 2018
  23. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Each point has world coordinates.
    Aspect ratio and screen size are completely ignored.
    Point can be accessed like so: var point = curve[pointIndex];
    There are a lot of examples about accessing points and using Math component here http://www.bansheegz.com/BGCurve/DeveloperGuide/Examples/
    You could also use the source code of existing components to learn about how some tasks are implemented
    If you have more specific questions, please, post it here
     
  24. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    170
    But by accessing to points position throgh script, I can make relation between aspect ratio and points, am I right ?

    Yup, I will check the scripts, because I want to have full control for objects movement backward and forward and also thier speed
     
  25. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Changing points positions should not be a problem.
    I'm not sure about controls positions (2 points which define the curvature)
     
  26. kperil94

    kperil94

    Joined:
    Jul 21, 2018
    Posts:
    5
    Hello, I have the camera attached to the spline I was wondering how I could make the camera follow the player by keeping within proximity but simultaneously sticking to the spline. Would you be able to help me please? Thanks in advance.

    EDIT: Nevermind I figured it out after a few hours of debugging, just closed Unity off, I'll upload the script tomorrow I need sleep haha.

    EDIT: Here it is. First you will need to open the components tab for your spline, add component, add the move and translate object by cursor, drag your camera object onto the empty prefab slot in the purple window, go up to the the top again and click the tick next to the cross to disable the component (you only need it for the maths you don't actually want it enabled or the camera will just be stuck at the start point / the distance ratio variable)

    Create a new script called 'CamPathController', copy and paste the code below into the new script, drag the script onto your spline object, drag the player in to the Player Object prefab slot, drag the camera in to the Cam Object slot, set the Cam Dist variable to whatever you like. The camera will follow the Player by sticking to the spline and keeping the desired distance.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CamPathController : MonoBehaviour {
    6.  
    7.     public GameObject camObject;
    8.     public GameObject playerObject;
    9.     public float camDist;
    10.  
    11.     // Use this for initialization
    12.     void Start () {
    13.      
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update () {
    18.  
    19.         // Get math
    20.         var math = GetComponent<BansheeGz.BGSpline.Components.BGCcMath>();
    21.  
    22.         // Players closest position
    23.         Vector3 playerPos = playerObject.transform.position;
    24.         var playerDist = 0f;
    25.         var playerClosestPos = math.CalcPositionByClosestPoint(playerPos, out playerDist);
    26.  
    27.         playerDist -= camDist;
    28.         camObject.transform.position = math.CalcPositionByDistance(playerDist);//playerClosestPos;//math.CalcPositionByDistance(distance);
    29.  
    30.     }
    31. }
     
    Last edited: Jul 25, 2018
  27. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hello, kperil94,
    Thank you for sharing your script with instructions.

    1) Math component does not need any other component to work. If you download the attached package, take a look at CameraPath GameObject with attached CamPathController (please, ignore PlayerPath, it's just to imitate player's movement.). CameraPath has single Math component attached.
    2) Usually, they advise to assign GetComponent<Type>() to some field in Start method and then use this field in Update
    3) Probably you can get better results if you use smooth motion

    Here is an updated CamPathController with some minor changes:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using BansheeGz.BGSpline.Components;
    4.  
    5. public class CamPathController : MonoBehaviour
    6. {
    7.     public GameObject camObject;
    8.     public GameObject playerObject;
    9.     public float camDist;
    10.  
    11.     public float movementSpeed;
    12.     public float rotationSpeed;
    13.  
    14.     private BGCcMath math;
    15.  
    16.     private Vector3 TargetPosition
    17.     {
    18.         get
    19.         {
    20.             float playerDist;
    21.             math.CalcPositionByClosestPoint(playerObject.transform.position, out playerDist);
    22.             return math.CalcPositionByDistance(playerDist - camDist);
    23.         }
    24.     }
    25.  
    26.     private Quaternion TargetRotation
    27.     {
    28.         get { return Quaternion.LookRotation(playerObject.transform.position - camObject.transform.position); }
    29.     }
    30.  
    31.     void Start()
    32.     {
    33.         //cache component for the sake of performance
    34.         math = GetComponent<BGCcMath>();
    35.         //move camera to initial position
    36.         camObject.transform.position = TargetPosition;
    37.         //rotate camera to initial rotation
    38.         camObject.transform.rotation = TargetRotation;
    39.     }
    40.  
    41.     void Update()
    42.     {
    43.         camObject.transform.position = Vector3.MoveTowards(camObject.transform.position, TargetPosition, movementSpeed * Time.deltaTime);
    44.         camObject.transform.rotation = Quaternion.RotateTowards(camObject.transform.rotation, TargetRotation, rotationSpeed * Time.deltaTime);
    45.     }
    46. }
    47.  
    I'm not sure I 100% understand what you need, but hopefully, it could help.
    I still think there is some room for improvements.
    I attached BGCurve package with a test scene (Assets\BansheeGzSupport\support.unity) and updated CamPathController script so you could download and take a look if you are interested.
     

    Attached Files:

    kperil94 likes this.
  28. OyvindE

    OyvindE

    Joined:
    Feb 1, 2018
    Posts:
    7
    Hi
    I noticed after updating to Unity 2018.2.1f1 that the rectangular selection seems to be way off after the update. Not sure what causes it though. See GIF below.

    https://i.gyazo.com/6310388779b9f820c3696e10493ac884.gif

    Edit: Same with Selection Menu / Point Menu (CTRL + mouse over point)
     
    Last edited: Aug 8, 2018
  29. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Could you please set up a simple scene, which showcases the problem, and send a package (Assets->Export package) to our support email? (support@bansheegz.com)
    We were not able to reproduce it (https://media.giphy.com/media/THYCOn4QYaZXbH6MaE/giphy.gif)
    Thank you.
     
  30. gothParrot

    gothParrot

    Joined:
    Aug 8, 2018
    Posts:
    3
    Hi, this is a great package! I'm trying to get my spline to snap to plane colliders generated at runtime, but it looks like the points won't snap, only just the splitters will, unless I call ApplySnap. I've tried both Points and Curves as SnapType.

    A dirty way to make sure it always snaps is to repeat calling apply snap, but it doesn't seems like the right way to do it...
     
    Last edited: Aug 24, 2018
  31. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hi, gothParrot, thank you for your support!
    1) By default, spline does not monitor its surroundings, cause it's very expensive.
    So, the idea was to call some method (ApplySnapping) to let it know that it needs to recalculate points positions.
    There was a small issue with it, but we fixed it.
    2) If you do not mind performance cost, we have added "snapMonitoring" bool parameter, which enables auto-monitoring.

    I've attached updated package with example scene (Assets\BansheeGzSupport\support.unity)
    Example scene works in both modes:
    1) auto-monitoring. "snapMonitoring" must be toggled on. No additional scripting is required.
    2) calling ApplySnapping manually. "snapMonitoring" must be toggled off. Please, take a look at Assets\BansheeGzSupport\CollideTest.cs for more details.
     

    Attached Files:

  32. MikeChr

    MikeChr

    Joined:
    Feb 2, 2018
    Posts:
    26
    Hi. Is there a method of setting a percentage of visible portion of the spline so that it seeming grows 0-1 along its actual path and length? Remarkable Tool. Thanks.
     
  33. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
  34. enginkadri

    enginkadri

    Joined:
    Sep 5, 2018
    Posts:
    1
    Hi dears, i want to make i game with unity with this asset. I made a curve and animate the ball on the curve road. But how can i move ball in same direction to right side or left side on the curve? i want to make game like Color Road. Thanks.
     
  35. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Hi, enginkadri,

    1) Use cross product of Vector.up and spline's tangent to calculate perpendicular line to move your sphere along. I've setup an example scene (Assets\BansheeGzSupport\support.unity)
    2) If you want to build an "infinite" spline, add/remove points at runtime. As soon as your sphere at section 2 (between points #2 and #3), remove first point (point#0) and add point to the end of the spline. Before deleting point#0, adjust distance value by substracting the length of the first section. distance -= math.Math[0].DistanceFromEndToOrigin;
    3) Take a look at Sweep2d component to get the idea how to build the track procedurally http://www.bansheegz.com/BGCurve/Cc/BGCcSweep2D/
     

    Attached Files:

  36. ngmane

    ngmane

    Joined:
    Apr 25, 2018
    Posts:
    9
    @BansheeGz I have been using BGCurve to build a curved path and transition and rotate along the path.

    I would like to know if given a position which is on the path can i get the distance its at.

    Usecase:
    Say there are two positions A (moving) and B (stationary) on the path i created. And i would like to know if A is near B.
    In this case i have the distance A is at but not sure how i can get the distance value for B position. So that i can check if
    distance(A) <= distance(B).

    Note: I cant just use Vector3.Distance for this usecase.
     
    Last edited: Sep 20, 2018
  37. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    ngmane,
    To get the distance for B position, you could use this method:
    Code (CSharp):
    1.         var pointB = Vector3.one;
    2.         float distance;
    3.         var point = math.CalcPositionByClosestPoint(pointB, out distance);
    4.  
    More details: http://www.bansheegz.com/BGCurve/DeveloperGuide/Math/
     
    ngmane likes this.
  38. ngmane

    ngmane

    Joined:
    Apr 25, 2018
    Posts:
    9
    I have already come across an API which gives the distance for a point which is not on the path.

    Code (CSharp):
    1.  
    2.         var positionYellow2 = math.CalcPositionByClosestPoint(Vector3.zero, out distanceYellow);
    3.  
    Taken from the doc. So i replaced the Vector3.zero with query position and iam getting the distance.
    Hope this will give me correct distance info.

    Also i think the doc can be updated with info that the point parameter can also be a position on the spline path.
     
  39. ngmane

    ngmane

    Joined:
    Apr 25, 2018
    Posts:
    9
    @BansheeGz sorry missed your reply there.
    Thank you very much for the info. Also i think the docs are unclear i would like to contribute to the docs in my free time.
    Do you accept PR for the docs?

    Also thank you for making such a useful asset available for use to everyone.
     
    BansheeGz likes this.
  40. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    ngmane, yes, it should give you the correct distance.
    We will update the doc, thank you for your suggestion
     
    ngmane likes this.
  41. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    Last edited: Sep 21, 2018
    ngmane likes this.
  42. jaleopold

    jaleopold

    Joined:
    Dec 7, 2017
    Posts:
    3
    Hi. I'm wondering if there's a way in c# to toggle on the Transform(to use as point's position) in the Field tab of the BG Curve and assign an object to a point? I didn't see a reference to this in the manual.
     
  43. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    @jaleopold property name is PointTransform (each point has it)
     
    Last edited: Nov 6, 2018
  44. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    166
    I am getting errors on several scripts. I think it is a conflict with something else but I cannot find it in a large project. Any ideas as I am really stuck with this! (Otherwise BGCurve is fantastic!)

    Assets/BansheeGz/BGCurve/Scripts/Curve/BGCc.cs(21,35): error CS0066: `BansheeGz.BGSpline.Curve.BGCc.ChangedParams': event must be of a delegate type
     
  45. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    @Redrag
    Most probably you have EventHandler class/interface/enum somewhere in your project, declared in the global (default) namespace, which conflicts with System.EventHandler delegate.
    The solution could be renaming this class or moving it outside of default namespace.
     
  46. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    166
    Many thanks for that - it was exactly the problem. One other issue - I am animating control points and need to make sure the whole BGCurve runs after the animation each frame. I can't quite establish what is triggering BGCurve to run each frame. I know I can do math.recalcualte but presumably if I do this in LateUpdate each frame it will be runnng twice every frame...
     
  47. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    @Redrag
    You can chose when event is fired (Update or LateUpdate) by setting EventMode (under Points tab)
     
  48. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    @Redrag
    If you use Unity's animation, set EventMode to LateUpdate and set ForceChangedEventMode to EditorAndRuntime
     
  49. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    166
    I had tried the first of the those settings, but not the second. Used together it does seem to work. However I am getting this warning when I click on the gameobject with BGCurve.

    : BGCurve[BGCurveBaseMath] Warning! We noticed you are updating math more than once per frame. This is not optimal. If you use curve.ImmediateChangeEvents by some reason, try to use curve.Transaction to wrap all the changes to one single event.. You can suppress all warnings by using BGCurveBaseMath.SuppressWarning=true;

    Also I am setting various other things in LateUpdate. I wonder is it possible to call the BGCurve explicitly so that I can make sure it executes at exactly the right time? I am thinking of replacing the LateUpdate at line 1101?
     
  50. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    269
    @Redrag
    This is strange.
    So this message shows up only if you select the GameObject with the curve?
    Does this message show up in Playmode only? If yes, do you call Math.Recalculate() manually?
    Does it show up once or it's logged every frame?

    Yes, it is possible.
    Set EventMode=NoEvents .
    All events will be disabled.
    Call Math.Recalculate() manually at any moment you want. (you need to call it after curve is changed)
     
unityunity