did you know...few tips about objects

Discuss everything related to custom data creation.

Moderator: NADEO

User avatar
xbx
Nadeo
Nadeo
Posts: 1154
Joined: 14 Jun 2010, 17:35

did you know...few tips about objects

Post by xbx » 13 Aug 2013, 14:13

Hi..

So I've been having a quick look at the speedball title, and I spotted a few (probably not very well documented to say the least :mrgreen: ) things that could be used:
  • for attaching a marker to something (say, a ball), you don't have to change the position marker all the time. Instead
    you can write:

    Code: Select all

      <marker manialinkframeid="Frame_BallMarker" objectid="{{{G_BallObject.Id}}}"/>
    A marker can be attached to:
    pos = "x y z"
    playerlogin="bob"
    objectid="#124124124" (any CSmObject)
    landmarktag="{{{BlockPoles[0].Id}}}" (or any CSmLandmark)
  • You could be actually throwing the ball object around, instead of using rockets / lasers to pass.

    To do this, you have to add more info to the object when importing it in the importer.
    (see next post)

    and then, you have to either

    Code: Select all

     G_BallObject.Throwable = True;
                Player.ThrowSpeed = 10.;
    
    which will have the effect that the player carrying the ball will throw it instead of shooting when they left click.

    Or

    Code: Select all

     
    G_BallObject.Throwable = False;
    G_BallObject.SetPositionAndVel(Player.Postion + offset, Player.AimDirection * throwspeed);
    
    using say CSmModeEvent::EType::OnActionEvent,
    with Event.ActionSlot == CSmModeEvent::EActionSlots::Activable1
    (that is when the player presses '1' on the keyboard.)

User avatar
steeffeen
Translator
Translator
Posts: 2472
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: did you know...

Post by steeffeen » 13 Aug 2013, 14:16

thanks :clap:
please more of such information!
we would make way more cool stuff if you would just let us know how...
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks

    User avatar
    xbx
    Nadeo
    Nadeo
    Posts: 1154
    Joined: 14 Jun 2010, 17:35

    Re: did you know...

    Post by xbx » 13 Aug 2013, 14:28

    Sooo. to make the object "physical", so that it can bounce around:

    Code: Select all

    <Item Type="DynaObject" Collection="SMCommon">
    	<Phy>
    		<DynaPointModel	Center="0 0 0" Radius="0.2" Restitution= "0.5" Friction="0.5" GravityCoef="2" />
    		<TriggerShape Type="AABB" min="-0.2 -0.2 -0.2" max="0.2 0.2 0.2"/>
    	</Phy>
    	<Vis>
    		<Mesh 				File="Meshes/Ball.Mesh.gbx"/>
    		<LightBallSimple 	Radius="2" sRgb="1 1 1" Pos="0 0 0"/>
    	</Vis>
    	<Pivots>
    		<Pivot Pos="0 -0.5 0" />
    	</Pivots>
    </Item>
    

    User avatar
    Emilieng
    Nadeo
    Nadeo
    Posts: 68
    Joined: 17 Dec 2012, 13:13
    Contact:

    Re: did you know...

    Post by Emilieng » 13 Aug 2013, 14:47

    About the scripting side of dynamic objects...

    In maniascript, the class describing dynamic objects is CSmObject.
    When manipulating dynamic objects, the important thing to have in mind is that, at any moment, an object is in a given "status", namely
    - OnPlayer
    - OnAnchor
    - InWorld
    - Unspawned

    To change the status of an object, use the corresponding method
    - SetPlayer(CSmPlayer)
    - SetAnchor(CSmObjectAnchor)
    - SetPosition(Vec3) or SetPositionAndVel(Vec3, Vec3)
    - SetUnspawned()

    E.g. if a given item was previously "InWorld", a call to the method "SetAnchor" will change its status to "OnAnchor". In other words, calling more than one of these methods during the same frame is useless: only the last method call will be taken into account.

    You can access the status of an object with the field Status, which returns a CSmObject::EStatus.
    When the status is OnPlayer, the field Player gives you which player currently owns the object. Having this field Null is equivalent for the status not to be "OnPlayer".
    When the status is OnAnchor, the field Anchor gives you which anchor currently holds the object. Having this field Null is equivalent for the status not to be "OnAnchor".

    Here is a short description of what the various statuses mean.

    "OnPlayer"
    The object is linked to a player.
    It is not present in the world - in other words, the object only exists "virtually".
    If the field "Throwable" is set to True, then next time the player will use the "shoot" button (presumably, the left click of the mouse) the object will be thrown, which lead to 2 remarks
    1. Its status will switch from "OnPlayer" to "InWorld",
    2. The direction of the throw is given by the players aim, and the force by the field CSmPlayer.ThrowSpeed
    A player throws all objects with the same speed. If the player owns several throwable objects, all of them will be thrown at the same time, with the same speed and the same direction.
    When a player throws an object, he/she does not fires any projectile (like a rocket). He/She has to lift his/her finger and press the fire button again to do so.

    "OnAnchor"
    The object is linked to an anchor defined by the map. Physics does not apply here - the object does not move until its status changes to "InWorld". This presumably will be the status of objects at the beginning of the match if you want them to have a fixed position in the map.

    "InWorld"
    The object is somewhere in the world, visible, and subject just like us to the tough laws of physics. You can get the coordinates of an object with the field CSmObject.Position, and its velocity with CSmObject.Vel.
    Any call to the method "SetPosition" or "SetPositionAndVel" will set the status of an object to "InWorld". The object is "teleported" at the given position, and the given speed vector will be applied. You will probably have to be careful not to set the position inside of a wall or somewhere not reachable.
    If a player touches the object, it reacts like any other item by generating a PlayerTouchesItem event.
    Notice that objects are not affected by special blocks such as trampolines or jump pads, and do not either bounce on players or other objects.

    "Unspawned"
    The object is nowhere, but can be accessed later on.

    User avatar
    Darkminus
    Posts: 226
    Joined: 05 Jun 2012, 20:54
    Location: Dans mon monde.
    Contact:

    Re: did you know...

    Post by Darkminus » 13 Aug 2013, 15:26

    Hello :)
    Thanks for these informations :clap: , you should make more "did you know..." topics :thx:
    Professor Law
    ShootMania-addict since June 2012.
    Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

    System Specs:
    OS: Windows 10 Professionnal x64
    CPU: Intel i5-4670
    GPU: MSI TwinFrozr GTX 760 OC (Nvidia)
    Motherboard: Asus Z87-C
    RAM : 10Gb

    User avatar
    spaii
    Posts: 1085
    Joined: 19 Jun 2010, 00:04
    Location: Rémy - France
    Contact:

    Re: did you know...

    Post by spaii » 13 Aug 2013, 16:41

    :thx: for all precisions :thumbsup:

    Code: Select all

      <marker manialinkframeid="Frame_BallMarker" objectid="{{{G_BallObject.Id}}}"/>
    Could we have more information on manialinkframeid ?

    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2472
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: did you know...

    Post by steeffeen » 13 Aug 2013, 17:17

    spaii wrote:

    Code: Select all

      <marker manialinkframeid="Frame_BallMarker" objectid="{{{G_BallObject.Id}}}"/>
    Could we have more information on manialinkframeid ?
    http://forum.maniaplanet.com/viewtopic. ... 79&t=16793 :thumbsup:
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks

      User avatar
      spaii
      Posts: 1085
      Joined: 19 Jun 2010, 00:04
      Location: Rémy - France
      Contact:

      Re: did you know...

      Post by spaii » 13 Aug 2013, 17:58

      :yes: :thx: steeffeen :thumbsup:

      User avatar
      Rots
      Translator
      Translator
      Posts: 1152
      Joined: 01 Sep 2010, 14:39
      Location: España, Barcelona

      Re: did you know...

      Post by Rots » 13 Aug 2013, 18:59

      xbx wrote:You could be actually throwing the ball object around, instead of using rockets / lasers to pass.
      Image

      I'd like to see that :o
      Image
      Image
      Image
      TrackMania Original brought me here... Here I am since 2006

      User avatar
      steeffeen
      Translator
      Translator
      Posts: 2472
      Joined: 14 Oct 2012, 16:22
      Location: Germany

      Re: did you know...

      Post by steeffeen » 13 Aug 2013, 19:05

      we are doing that the whole evening already :lol:
        Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

        ManiaControl, FancyManiaLinks

        Post Reply

        Return to “Title Pack & Custom Data Creation”

        Who is online

        Users browsing this forum: No registered users and 1 guest