Search Unity

Need Some Help For Use Tweens

Discussion in 'Project Tiny' started by Anton_hc, Apr 12, 2019.

  1. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    i was try to use tween, but always get error: "Not a valid component or field for tweening" how should i be right use tween?

    Code (JavaScript):
    1. let targetPosition = new Vector3(0,0,0);
    2. let startPosition = new Vector3(5,5,0);
    3.            
    4. let tween =  new ut.Tweens.TweenVector3(startPosition,targetPosition);
    5.  
    6. this.world.forEach([ut.Entity, ut.Core2D.TransformLocalPosition, game.help], (entity, position, tag) => {
    7.  
    8. ut.Tweens.TweenService.addTween(
    9. /*world*/ this.world,
    10. /*entity*/ entity,
    11. /*field (static Vector3) */ HelpSystem.tweentst,
    12. /*startval*/ startPosition,
    13. /*targetval*/ targetPosition,
    14. /*duration*/ 2,
    15. /*timeOffset*/ 0,
    16. /*loopmode*/ 0,
    17. /*TweenFunc*/ 1,
    18. /*destroyWhenDone*/ false
    19. );
    20. });
     
  2. Antonia-Chimp

    Antonia-Chimp

    Joined:
    Apr 1, 2019
    Posts:
    11
    you should put "ut.Core2D.TransformLocalPosition.position" instead of HelpSystem.tweentst I think. Thats how I did it.
     
    Anton_hc likes this.
  3. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    i was tried, but still same error:

    Code (CSharp):
    1. this.world.forEach([ut.Entity, ut.Core2D.TransformLocalPosition, game.help], (entity, position, tag) => {
    2. ut.Tweens.TweenService.addTween(
    3. /*world*/ this.world,
    4. /*entity*/ entity,
    5. /*field*/ position.position,
    6. /*startval*/ startPosition,
    7. /*targetval*/ targetPosition,
    8. /*duration*/ 2,
    9. /*timeOffset*/ 0,
    10. /*loopmode*/ 0,
    11. /*TweenFunc*/ 1,
    12. /*destroyWhenDone*/ false);
     
  4. Antonia-Chimp

    Antonia-Chimp

    Joined:
    Apr 1, 2019
    Posts:
    11
    no, you really have to put "ut.Core2D.TransformLocalPosition.position" and not position.position.
     
    Anton_hc likes this.
  5. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    this was unexpected, thanks! it's work.
     
  6. reallyhexln

    reallyhexln

    Joined:
    Jun 18, 2018
    Posts:
    69
    By the way, is there any way to apply tweener for properties of custom component?
    I see, TransformLocalPosition component has some special static properties that are used by tweener. Unfortunately, component definition generates by the editor, so I can't add such fields to my own component.
     
    Anton_hc likes this.