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 DennisJongmans · Oct 13, 2011 at 10:34 AM · physicsbounceswipewind

Swipe Wind

alt text

Hi guys I have a question,

I want to make a script that lets me swipe my finger in a direction and the object ( the little orange ball) will get a force or velocity in the direction you swipe but also the strengt of the swipe. So if the swipe is short you will get a little bit force or the swipe is big your force will be greater.

I want to use this on the Iphone so a script with touch Is possible. Only curruntly I am not behind a mac computer so I cannot test it. So if the script can be test with the mouse input that would be great.

I use this script to calculate the swipe grapghic.

 var targetPoint : Vector3;
 
 function Update () {
 
 if (Input.GetMouseButton(0)){
 
 var playerPlane = new Plane(Vector3.forward, transform.position);
 
 var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
       
 var hitdist = 0.0; 
      
 if (playerPlane.Raycast (ray, hitdist)) {
      
 targetPoint = ray.GetPoint(hitdist);
 
 transform.position = targetPoint;
     
 }
 
 }
 
 }

I want to use physics so I can bounce of walls.

I have really no clue where to start. I searched the internet for soltions but there was no one post that could help me. Maybe I did mis some posts if is that the cause I hope you can redirect me to that post.

Thanks in advance.

Dennis Jongmans

Comment
Add comment
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

2 Replies

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

Answer by wccrawford · Oct 13, 2011 at 03:11 PM

I don't do mobile development, but...

http://unity3d.com/support/documentation/ScriptReference/Input.GetTouch.html

It looks like you can use getTouch to determine when a touch begins:

if (Input.GetTouch(i).phase == TouchPhase.Began)

and ends (with TouchPhase.Ended) and use those to store the beginning and ending coordinates. Then just determine the distance from 1 to the other.

Alternatively, you could add up the delta distance for each touch and use that, applying it then the touch phase ends.

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 wccrawford · Oct 13, 2011 at 01:36 PM

You'll need store the initial point of the sweep. Then at the end of the sweep, calculate the distance and the direction and use that to apply force to the ball.

Comment
Add comment · Show 1 · 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 DennisJongmans · Oct 13, 2011 at 02:09 PM 0
Share

Yeah I was thinking the same thing, only I dont know where to start to calculate the direction and the force of the ball

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

how do i make pinball ? 1 Answer

Avoid bouncing when ground move down 1 Answer

How do I check when a rigidbody is colliding with the floor? 2 Answers

Creating an octopus / squid that spits ink with a particle system? 1 Answer


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