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
0
Question by Drum · Apr 02, 2011 at 10:28 PM · raycastterrainitweenwaypoint

Moving Over Terrain with iTween

Hi, I'm trying to move an animated creature over a terrain. I've been using iTween to do the waypoint patrolling, but I'm having trouble making the creature track the Y height of the terrain. Ideally I'd like it to follow the orientation of the terrain mesh, but at this point I'll settle for just tracking the Y.

What I've got is this:

function CheckGround(){
var hit : RaycastHit = new RaycastHit();
if (Physics.Raycast (transform.position,Vector3.down,hit, 2)) {
    myRat.position.y=hit.point.y + 5;
}       

}

which I'm calling from Update().

function tween(){
iTween.MoveTo(gameObject,{"path":path,"time":mySpeed,"orienttopath":true,"looktime":.6,"easetype":"easeInOutSine","oncomplete":"complete"});    

}

which is called from Start();

path is an array of Transforms

So, my understanding of how this should work is that iTween fires up when the game starts and moves the creature through the waypoints in the path. Every frame of that, the creature raycasts downwards and, if it hits an object or the terrain, it will adjust its Y access to be the same as the point where the ray hit plus 5.

The creature is on the Ignore Raycast layer. The waypoint part is fine, but the Raycasting doesn't do anything, in fact the creature sinks slightly in the first few seconds. The size of the terrain is 500x500.

Comment
Add comment · Show 1
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 Drum · Apr 03, 2011 at 11:09 AM 0
Share

Ok, it occurs to me why this is going wrong (or rather not going right), but I have no idea how to fix it.

I'm now thinking that the iTween call, because it is moving the creature to a Vector3, is overriding the changes in transform.position.y that the raycasting function gives in order to keep the creature on track.

If that's the case, is there any way to tell iTween to ignore the Y component of the Vector3?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Thom Denick · Jul 20, 2011 at 04:38 PM

I know this is an old question, but Bob actually has a solution up for this exact problem on his site now. http://itween.pixelplacement.com/examples.php

$1 will get you the source.

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

1 Person is following this question.

avatar image

Related Questions

Instantiated Objects not being set at ground/terrain level?(Solved) 1 Answer

iTween and 2D Platforming Tutorial Merge: Rotation of player and camera needed 1 Answer

Have object follow mouse on terrain 1 Answer

iTween - Traveling around a cylinder 2 Answers

What is the difference of iTween and Waypoint? 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