Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Jun 07, 2021 at 03:27 PM by Nithinsvs for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Nithinsvs · Apr 04, 2018 at 04:12 AM · projectilespace shooter

how to make an 'S' Shaped projectile in 2D ?

I'm creating a space shooter game in 2D. I want the enemyship to generate a projectile that travels towards playership in 'S' path(Curvy path). Please help me...

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

  • Sort: 
avatar image
1

Answer by RisheelK · Apr 04, 2018 at 05:01 AM

you can use bezier curve to move your projectile along the path.

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
1

Answer by Cornelis-de-Jager · Apr 04, 2018 at 05:29 AM

How I would go about this is split the forward and sideways movement into two parts. One part that just moves it forward and a second that moves it sideways.

Here is an example script I wrote:

 /* Public Variables */
 public float s_amp = 0.01f;
 public float S_speed = 1f;
 
 public Transform target;
 public bool tracking = false;
 
 public missleSpeed = 1;
 
 /* Private Variables */
 Vector3 targetLocation;
 float timeAlive;
 
 void Start () {
     targetLocation = target.position;
     transform.LookAt (targetLocation);
     timeAlive = 0;
 }
 
 void FixedUpdate () {
     // Forward motion
     MoveToPlayer ();
     
     //Do the Snake motion
     DoSMotion ();
 }
 
 void MoveToPlayer () {
     // Rotate towards target of tracking
     if (tracking) {
         transform.LookAt (target.position);
     }
     
     // Move forward
     transform.Translate (transform.up * Time.DeltaTime * missleSpeed);
 }
 
 void DoSMotion () {
     // Calculate the S motion
     float sideMotion = s_amp * Mathf.Sin(timeAlive);
     
     // Increase the time alive
     timeAlive += Time.DeltaTime * S_speed;
     
     transform.Translate(new Vector3(sideMotion, 0, 0));
 }
 
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

Follow this Question

Answers Answers and Comments

78 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

How to shoot a bullet and animate at the same time??? Its a 2D shooter c# 3 Answers

Firing projectiles on the XZ Plane 2 Answers

[SOLVED] Top down shooter projectiles can shoot side to side, but not up and down, why? 0 Answers

Setting the velocity of a projectile based on the angle of the cannon 2 Answers

How can I achieve precise projectile shooting towards the crosshair in Unity? 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