# How to give the effect on the obstacle?

I want to the obstacle Scale-In and Scale-Out using Dotween PlugIn? means some effect??

Image:

I want to give a effect on the obstacle?

script:

Obstacle.cs

void Update()
{
goTopToDown();
}

void goTopToDown()
{

foreach (Transform item in GetComponentsInChildren<Transform>())
{
if (item.tag == "obstacleobject") //some obtsacle slow
{
item.localPosition += Vector3.down * speed * Time.deltaTime;                   //move top to down object
}
if (item.tag == "movefastobject") //some obstacle fast
{
item.localPosition += Vector3.down * movefastobjectspeed * Time.deltaTime;     //move fast object
}
}
$$$$

• more information is needed for this question to be answered. What effect do you want to be achieved? – Millard Sep 15 at 16:27
• @Millard I want to scale in and scale out on obstacles. see this link:youtube.com/watch?v=_Tq4t0gx49g&t=569s using dotween plugin?? – Rahul Patil Sep 15 at 16:52

Its quit simple, Here the code which will do the job:

    public void ScaleINOutAnimation(Transform objectTransform, float scaleIn, float scaleOut, float duration)
{
objectTransform.DOScale(scaleIn, duration).OnComplete(() =>
{
Debug.Log("Scale In done.");
objectTransform.DOScale(scaleOut, duration).OnComplete(() =>
{
ScaleINOutAnimation(objectTransform, scaleIn, scaleOut, duration);
});
});
}


As in the function parameter I used "Transform" to scale in and out Object if you are using "RectTransform" then just convert "Transform" to "RectTransform" and it will do the job.

How to use this function:

• objectTransform: The object you want to animate.
• scaleIn: The object scale you want for scale in.
• scaleOut: The object scale you want for scale Out.
• duration: Duration for "Scale In" animation or Duration for "Scale Out".

so the call will some thing like this:

ScaleINOutAnimation(this.GetComponent<Transform>(), 0.9f, 10.0f, 0.1f);


or

ScaleINOutAnimation(object, 0.9f, 10.0f, 0.1f);
`

I hope this help, Let me know if you need any help with this.

• how to set your script in my script I edited my question? help – Rahul Patil Sep 16 at 5:42
• Well just copy the function I've posted in the answer and past it to "Obstacle.cs" and then call the animation function from Start() function if you don't have Start function then create one. To call the function from start just past this "ScaleINOutAnimation(this.GetComponent<Transform>(), 0.9f, 10.0f, 0.1f);" in the Start function. and that it. Also make sure to add this to very first line of the script "using DG.Tweening;". – Swati Sep 16 at 6:11
• thanks for the answer. I m first time working with Dotween PlugIn. – Rahul Patil Sep 16 at 12:46