Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Creating a mancannon for simple first person game.

Discussion in 'Scripting' started by Jesper Oscar Thomas Andersson, Jul 17, 2015.

  1. Jesper Oscar Thomas Andersson

    Jesper Oscar Thomas Andersson

    Joined:
    Sep 22, 2014
    Posts:
    2
    Hello! I'm working on a simple first person experience in which i want to the player to walk onto a "cannon"-zone which will throw them from point A to B. My aim is to end ut with something that works like the catapults in the Portal games or the mancannons from Halo. I'm using the prefab first person controller so i guess i could use some kind of physics based force, but i can imagine it being very unreliable and glitchy...


    I am a total newcomer when it comes to scripts other that copying, pasting and modyfing others' scripts. Is there anyone with some experience in this that might recommend a method?


    (Portal catapult)


    A halo mancannon



    Thanks!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,817
    I don't think the standard asset FPS controller has a rigidbody, so you wouldn't really be able to impart an impulse to it and throw it, at least not without digging around and figuring out how it drives its position in the game.

    If you google around you can find a Rigidbody-based fPS and with something like that, I imagine all you would need to do is put an invisible trigger area around the man cannon area, and a script that applies a single blast of force to any rigidbody that enters it.

    A more repeatable method (and I think what Halo uses) is a script that accelerates the player over a short period of time (say five frames or so) up to a given fixed velocity, such that his landing destination is somewhat consistent.

    Please wear your crash helmet at all times when playing with thee mancannon.
     
  3. Jesper Oscar Thomas Andersson

    Jesper Oscar Thomas Andersson

    Joined:
    Sep 22, 2014
    Posts:
    2
    Okay thanks for the advice!