Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by latsushi · Sep 30, 2012 at 07:29 AM · c#itweenmovetostrafemove to

iTween MoveTo

Hello :-)

I'm trying to get my game object to strafe SMOOTHLY. Here's my code:

 using UnityEngine;
 using System.Collections;
 
 public class MoveTo : MonoBehaviour {
 
     
     // Update is called once per frame
     void Update () {
         
         if (Input.GetKeyDown(KeyCode.A))
             iTween.MoveTo(gameObject,iTween.Hash("position",transform.position += Vector3.left*2,"easetype",iTween.EaseType.easeInOutSine,"time",.2f));
         
         if (Input.GetKeyDown(KeyCode.D))
             iTween.MoveTo(gameObject,iTween.Hash("position",transform.position += Vector3.right*2,"easetype",iTween.EaseType.easeInSine,"time",.2f));
     
     }
 }

I noticed that if I set my "time" parameter to a higher number such as 3 and press one of the input keys twice within those three seconds the object will move smoothly. Maybe that'll help one of you understand what the computer is thinking.

Any help is appreciated.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dannyskim · Sep 30, 2012 at 11:13 PM 0
Share

What type of game is this exactly, and what type of behavior are you expecting from Utilizing iTween? What do you mean by smoothly, as well? There could be several different definitions of "smooth" in terms of an tween curve.

If this is a real time character like a FPS and they'll be constantly strafing, I really don't see why you're trying to use iTween to do that.

avatar image hvilela · Sep 30, 2012 at 11:39 PM 0
Share

What exactly is your question?

avatar image latsushi · Oct 01, 2012 at 12:35 AM 0
Share

This is a first person bull rushing game. The character is running away from a pack of bulls behind them and one of the actions the character can perform is strafing. Right now the character just snaps to the left or right when I press A or D. I want the character to smoothly strafe without teleporting essentially. Any input is appreciated.

4 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by DannyB · Oct 01, 2012 at 06:19 PM

Why are you using "transform.position += value" as an argument to iTween?

You are both asking iTween to move the object for you, and you are moving it yourself. Try using a fixed value there, and use MoveBy instead (unless MoveTo is really what you need).

Also, if you want to move on one axis only, use "X" or "y" instead of "position".

 iTween.MoveBy(gameObject,iTween.Hash(
     "x"   , 2,
     "time", 0.2f
 ));

Finally, for a situation such as yours, where you want (I presume) to move the player only while the key is pressed, you should probably avoid "one shot" tweens, and instead use either one of the iTween Update methods (e.g. MoveUpdate), or avoid iTween altogether (for this case) and use transform.Translate()

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image latsushi · Oct 01, 2012 at 07:03 PM 0
Share

Thank you Danny. It's working properly now.

avatar image DannyB · Oct 01, 2012 at 07:13 PM 0
Share

Good to hear and good luck.

avatar image
2

Answer by vanshika · Dec 18, 2013 at 06:14 AM

Try this.

       iTween.MoveTo (gameObject, iTween.Hash ("x", 0 , "islocal", true, "time", 1.5 ,"looptype","none" , "easetype" , "spring"));
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by BLarentis · Oct 01, 2012 at 06:01 PM

You tried to set the ease type to linear, and adjust the time value to match your need ? Hope it helped. Take care !

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Gurc · May 16, 2013 at 10:43 AM

You must call iTween once. You call it each update. For example

 public class doubleTween : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
         iTween.RotateBy(gameObject,iTween.Hash("x", .25,"time",2, "easeType"
             , "easeInOutQuad", "loopType", "pingPong", "delay", .2));
         
         iTween.MoveTo(gameObject,iTween.Hash("x",6,"time",4,"loopType","pingPong"
             ,"delay",.4,"easeType","easeInOutQuad"));
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using iTween to move a gameobject from node to node 1 Answer

Multiple Cars not working 1 Answer

iTween MoveTo doesn't move. [C#] 1 Answer

Distribute terrain in zones 3 Answers

Itween Problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges