Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:37:29+00:00 2026-05-28T23:37:29+00:00

I am creating a horizontal side-scrolling shooter which I plan to release on mobile

  • 0

I am creating a horizontal side-scrolling shooter which I plan to release on mobile devices. How can I set up the ship so that:

  • It can be moved up/down/left/right freely (with varying horizontal/vertical speeds)
  • Collide and stop against obstacles (i.e. IF collision with obstacle STOP)
  • Diagonal movement against horizontal plane (down + right input) should move right pressed against floor

The ship must not be able to pass through obstacles.

I created a custom character controller which simply adjust position based on velocity. I cannot figure out how to detect collision and avoid moving through obstacles. There must be an easier way to achieve this simple requirement.

Note: To clarify, the camera follows the ship, it does not automatically scroll. The player can stop the ship by releasing input button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:37:30+00:00Added an answer on May 28, 2026 at 11:37 pm

    I was storing my own velocity vector which I was then applying using transform.Translate. This obviously was ignoring any collision detection and would have required a custom collision detection implementation.

    Instead I found that the Rigidbody component contains its own velocity variable. That velocity value can be easily altered and the object will automatically translate and collide with obstacles. Here is an example:

    using UnityEngine;
    using System.Collections;
    
    public class CharacterController : MonoBehaviour {
    
        public Vector2 maximumSpeed = new Vector2(1.0f, 1.0f);
    
        void Start() {
    
        }
    
        void Update() {
            Rigidbody rigidbody = GetComponent<Rigidbody>();
    
            Vector2 velocity = new Vector2();
    
            velocity.x = Input.GetAxis("Horizontal") * maximumSpeed.x;
            velocity.y = Input.GetAxis("Vertical") * maximumSpeed.y;
    
            rigidbody.velocity = velocity;
        }
    
    }
    

    This appears to work quite well. Comments would be appreciated 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a horizontal site (it could also be any other auto-scrolling site, like
I'm creating a horizontal menu bar. There is an outer div that contains inner
Hello all I am creating a horizontal menu for a site that needs to
I am creating a horizontal scrolling page and I was wondering what the best
I'm interested in creating a horizontal scroll view that snaps to the viewed item,
I am creating a custom view which will have a bitmap so that user
Can anybody please help me creating the same horizontal accordian menu with all the
I am creating an android application in which the user can view the channel
I am creating a horizontal webpage and I am trying to make the body
I'm creating a dynamically generated PDF using FPDF. My PDF requires many exactly horizontal/vertical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.